From b01f83bcccd58347431c48de46077e82819e79c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:22:13 +0200 Subject: [PATCH 01/23] Update DS Format (#3608) * protobuf datastream --- Makefile | 1 + .../src/proto/datastream/v1/datastream.proto | 64 ++ sequencer/batch.go | 6 + sequencer/datastreamer.go | 27 +- sequencer/finalizer_test.go | 1 + sequencer/forcedbatch.go | 2 +- sequencer/l2block.go | 5 +- sequencer/sequencer.go | 134 ++- state/datastream.go | 482 +++++------ state/datastream/datastream.pb.go | 773 ++++++++++++++++++ state/pgstatestorage/datastream.go | 13 +- state/test/datastream_test.go | 82 -- test/docker-compose.yml | 6 + tools/datastreamer/Makefile | 22 +- tools/datastreamer/config/tool.config.toml | 10 +- tools/datastreamer/main.go | 733 +++++++---------- 16 files changed, 1541 insertions(+), 820 deletions(-) create mode 100644 proto/src/proto/datastream/v1/datastream.proto create mode 100644 state/datastream/datastream.pb.go delete mode 100644 state/test/datastream_test.go diff --git a/Makefile b/Makefile index 83d4fed5fe..ba55fb3429 100644 --- a/Makefile +++ b/Makefile @@ -164,6 +164,7 @@ generate-code-from-proto: ## Generates code from proto files cd proto/src/proto/hashdb/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../merkletree/hashdb --go-grpc_out=../../../../../merkletree/hashdb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative hashdb.proto cd proto/src/proto/executor/v1 && protoc --proto_path=. --go_out=../../../../../state/runtime/executor --go-grpc_out=../../../../../state/runtime/executor --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative executor.proto cd proto/src/proto/aggregator/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../aggregator/prover --go-grpc_out=../../../../../aggregator/prover --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative aggregator.proto + cd proto/src/proto/datastream/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../state/datastream --go-grpc_out=../../../../../state/datastream --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative datastream.proto ## Help display. ## Pulls comments from beside commands and prints a nicely formatted diff --git a/proto/src/proto/datastream/v1/datastream.proto b/proto/src/proto/datastream/v1/datastream.proto new file mode 100644 index 0000000000..6b8a89adc6 --- /dev/null +++ b/proto/src/proto/datastream/v1/datastream.proto @@ -0,0 +1,64 @@ +syntax = "proto3"; + +package datastream.v1; + +option go_package = "github.com/0xPolygonHermez/zkevm-node/state/datastream"; + +message Batch { + uint64 number = 1; + bytes local_exit_root = 2; + bytes state_root = 3; + uint64 fork_id = 4; + uint64 chain_id = 5; +} + +message L2Block { + uint64 number = 1; + uint64 batch_number = 2; + uint64 timestamp = 3; + uint32 delta_timestamp = 4; + uint64 min_timestamp = 5; + bytes l1_blockhash = 6; + uint32 l1_infotree_index = 7; + bytes hash = 8; + bytes state_root = 9; + bytes global_exit_root = 10; + bytes coinbase = 11; +} + +message Transaction { + uint64 l2block_number = 1; + bool is_valid = 2; + bytes encoded = 3; + uint32 effective_gas_price_percentage = 4; + bytes im_state_root = 5; +} + +message UpdateGER { + uint64 batch_number = 1; + uint64 timestamp = 2; + bytes global_exit_root = 3; + bytes coinbase = 4; + uint64 fork_id = 5; + uint64 chain_id = 6; + bytes state_root = 7; +} + +message BookMark { + BookmarkType type = 1; + uint64 value = 2; +} + +enum BookmarkType { + BOOKMARK_TYPE_UNSPECIFIED = 0; + BOOKMARK_TYPE_BATCH = 1; + BOOKMARK_TYPE_L2_BLOCK = 2; +} + +enum EntryType { + ENTRY_TYPE_UNSPECIFIED = 0; + ENTRY_TYPE_BATCH = 1; + ENTRY_TYPE_L2_BLOCK = 2; + ENTRY_TYPE_TRANSACTION = 3; + ENTRY_TYPE_UPDATE_GER = 4; +} diff --git a/sequencer/batch.go b/sequencer/batch.go index ecaa93aca7..8db3320a4d 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -29,6 +29,7 @@ type Batch struct { finalRemainingResources state.BatchResources // remaining batch resources when a L2 block is processed finalHighReservedZKCounters state.ZKCounters closingReason state.ClosingReason + finalLocalExitRoot common.Hash } func (b *Batch) isEmpty() bool { @@ -99,6 +100,7 @@ func (f *finalizer) setWIPBatch(ctx context.Context, wipStateBatch *state.Batch) finalRemainingResources: remainingResources, imHighReservedZKCounters: wipStateBatch.HighReservedZKCounters, finalHighReservedZKCounters: wipStateBatch.HighReservedZKCounters, + finalLocalExitRoot: wipStateBatch.LocalExitRoot, } return wipBatch, nil @@ -312,6 +314,7 @@ func (f *finalizer) openNewWIPBatch(batchNumber uint64, stateRoot common.Hash) * imRemainingResources: maxRemainingResources, finalRemainingResources: maxRemainingResources, closingReason: state.EmptyClosingReason, + finalLocalExitRoot: state.ZeroHash, } } @@ -400,6 +403,9 @@ func (f *finalizer) closeSIPBatch(ctx context.Context, dbTx pgx.Tx) error { }() } + // Sent batch to DS + f.DSSendBatch(f.wipBatch.batchNumber, f.wipBatch.finalStateRoot, f.wipBatch.finalLocalExitRoot) + log.Infof("sip batch %d closed in statedb, closing reason: %s", f.sipBatch.batchNumber, f.sipBatch.closingReason) f.sipBatch = nil diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 7f5e7e763a..81ed1083b0 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -3,9 +3,11 @@ package sequencer import ( "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/state/datastream" + "github.com/ethereum/go-ethereum/common" ) -func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32) error { +func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64) error { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) // Send data to streamer @@ -13,12 +15,13 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce l2Block := state.DSL2Block{ BatchNumber: batchNumber, L2BlockNumber: blockResponse.BlockNumber, - Timestamp: int64(blockResponse.Timestamp), + Timestamp: blockResponse.Timestamp, + Min_timestamp: minTimestamp, L1InfoTreeIndex: l1InfoTreeIndex, L1BlockHash: blockResponse.BlockHashL1, GlobalExitRoot: blockResponse.GlobalExitRoot, Coinbase: f.sequencerAddress, - ForkID: uint16(forkID), + ForkID: forkID, BlockHash: blockResponse.BlockHash, StateRoot: blockResponse.BlockHash, //From etrog, the blockhash is the block root } @@ -57,9 +60,23 @@ func (f *finalizer) DSSendBatchBookmark(batchNumber uint64) { // Check if stream server enabled if f.streamServer != nil { // Send batch bookmark to the streamer - f.dataToStream <- state.DSBookMark{ - Type: state.BookMarkTypeBatch, + f.dataToStream <- datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, Value: batchNumber, } } } + +func (f *finalizer) DSSendBatch(batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) { + forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) + + if f.streamServer != nil { + // Send batch to the streamer + f.dataToStream <- datastream.Batch{ + Number: batchNumber, + ForkId: forkID, + StateRoot: stateRoot.Bytes(), + LocalExitRoot: localExitRoot.Bytes(), + } + } +} diff --git a/sequencer/finalizer_test.go b/sequencer/finalizer_test.go index 6e54c342f8..84a2d6e8cf 100644 --- a/sequencer/finalizer_test.go +++ b/sequencer/finalizer_test.go @@ -980,6 +980,7 @@ func TestFinalizer_finalizeSIPBatch(t *testing.T) { // arrange stateMock.On("BeginStateTransaction", ctx).Return(dbTxMock, nilErr).Once() + stateMock.On("GetForkIDByBatchNumber", mock.Anything).Return(uint64(state.FORKID_BLUEBERRY)) stateMock.On("CloseWIPBatch", ctx, receipt, mock.Anything).Return(tc.managerErr).Once() if tc.managerErr == nil { diff --git a/sequencer/forcedbatch.go b/sequencer/forcedbatch.go index 85f74abee1..21a0c92504 100644 --- a/sequencer/forcedbatch.go +++ b/sequencer/forcedbatch.go @@ -198,7 +198,7 @@ func (f *finalizer) handleProcessForcedBatchResponse(ctx context.Context, newBat } // Send L2 block to data streamer - err = f.DSSendL2Block(newBatchNumber, forcedL2BlockResponse, 0) + err = f.DSSendL2Block(newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d to data streamer, error: %v", forcedL2BlockResponse.BlockNumber, err) diff --git a/sequencer/l2block.go b/sequencer/l2block.go index 43db958ed6..b2b9cd9922 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -260,8 +260,9 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error return fmt.Errorf(overflowLog) } - // Update finalStateRoot of the batch to the newStateRoot for the L2 block + // Update finalStateRoot/finalLocalExitRoot of the batch to the newStateRoot/newLocalExitRoot for the L2 block l2Block.batch.finalStateRoot = l2Block.batchResponse.NewStateRoot + l2Block.batch.finalLocalExitRoot = l2Block.batchResponse.NewLocalExitRoot f.updateFlushIDs(batchResponse.FlushID, batchResponse.StoredFlushID) @@ -493,7 +494,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { log.Infof("[ds-debug] l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum) // Send L2 block to data streamer - err = f.DSSendL2Block(l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex()) + err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index b79ad26c17..d1945234d5 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -11,7 +11,9 @@ import ( "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/state/datastream" "github.com/ethereum/go-ethereum/common" + "google.golang.org/protobuf/proto" ) const ( @@ -137,7 +139,7 @@ func (s *Sequencer) checkStateInconsistency(ctx context.Context) { } func (s *Sequencer) updateDataStreamerFile(ctx context.Context, chainID uint64) { - err := state.GenerateDataStreamerFile(ctx, s.streamServer, s.stateIntf, true, nil, chainID, s.cfg.StreamServer.UpgradeEtrogBatchNumber) + err := state.GenerateDataStreamFile(ctx, s.streamServer, s.stateIntf, true, nil, chainID, s.cfg.StreamServer.UpgradeEtrogBatchNumber) if err != nil { log.Fatalf("failed to generate data streamer file, error: %v", err) } @@ -278,54 +280,77 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { continue } - bookMark := state.DSBookMark{ - Type: state.BookMarkTypeL2Block, + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, Value: l2Block.L2BlockNumber, } //TODO: remove this log log.Infof("[ds-debug] add stream bookmark for l2block %d", l2Block.L2BlockNumber) - _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + log.Errorf("failed to marshal bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) + continue + } + + _, err = s.streamServer.AddStreamBookmark(marshalledBookMark) if err != nil { log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) continue } // Get previous block timestamp to calculate delta timestamp - previousL2Block := state.DSL2BlockStart{} + previousL2Block := datastream.L2Block{} if l2Block.L2BlockNumber > 0 { - bookMark = state.DSBookMark{ - Type: state.BookMarkTypeL2Block, + bookMark = &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, Value: l2Block.L2BlockNumber - 1, } //TODO: remove this log log.Infof("[ds-debug] get previous l2block %d", l2Block.L2BlockNumber-1) - previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + log.Errorf("failed to marshal bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) + continue + } + + previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(marshalledBookMark) if err != nil { log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) continue } - previousL2Block = state.DSL2BlockStart{}.Decode(previousL2BlockEntry.Data) + err = proto.Unmarshal(previousL2BlockEntry.Data, &previousL2Block) + if err != nil { + log.Errorf("failed to unmarshal previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) + continue + } } - blockStart := state.DSL2BlockStart{ + streamL2Block := &datastream.L2Block{ + Number: l2Block.L2BlockNumber, BatchNumber: l2Block.BatchNumber, - L2BlockNumber: l2Block.L2BlockNumber, Timestamp: l2Block.Timestamp, DeltaTimestamp: uint32(l2Block.Timestamp - previousL2Block.Timestamp), - L1InfoTreeIndex: l2Block.L1InfoTreeIndex, - L1BlockHash: l2Block.L1BlockHash, - GlobalExitRoot: l2Block.GlobalExitRoot, - Coinbase: l2Block.Coinbase, - ForkID: l2Block.ForkID, - ChainID: uint32(chainID), + MinTimestamp: l2Block.Min_timestamp, + L1Blockhash: l2Block.L1BlockHash.Bytes(), + L1InfotreeIndex: l2Block.L1InfoTreeIndex, + Hash: l2Block.BlockHash.Bytes(), + StateRoot: l2Block.StateRoot.Bytes(), + GlobalExitRoot: l2Block.GlobalExitRoot.Bytes(), + Coinbase: l2Block.Coinbase.Bytes(), + } + + marshalledL2Block, err := proto.Marshal(streamL2Block) + if err != nil { + log.Errorf("failed to marshal l2block %d, error: %v", l2Block.L2BlockNumber, err) + continue } //TODO: remove this log log.Infof("[ds-debug] add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber) - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) + _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK), marshalledL2Block) if err != nil { log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) continue @@ -334,25 +359,25 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { //TODO: remove this log log.Infof("[ds-debug] adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber) for _, l2Transaction := range l2Block.Txs { - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) + streamL2Transaction := &datastream.Transaction{ + L2BlockNumber: l2Transaction.L2BlockNumber, + IsValid: l2Transaction.IsValid != 0, + Encoded: l2Transaction.Encoded, + EffectiveGasPricePercentage: uint32(l2Transaction.EffectiveGasPricePercentage), + ImStateRoot: l2Transaction.ImStateRoot.Bytes(), + } + + marshalledL2Transaction, err := proto.Marshal(streamL2Transaction) if err != nil { - log.Errorf("failed to add l2tx stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + log.Errorf("failed to marshal l2tx for l2block %d, error: %v", l2Block.L2BlockNumber, err) continue } - } - blockEnd := state.DSL2BlockEnd{ - L2BlockNumber: l2Block.L2BlockNumber, - BlockHash: l2Block.BlockHash, - StateRoot: l2Block.StateRoot, - } - - //TODO: remove this log - log.Infof("[ds-debug] 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 + _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION), marshalledL2Transaction) + if err != nil { + log.Errorf("failed to add l2tx stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + continue + } } //TODO: remove this log @@ -367,24 +392,55 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { log.Infof("[ds-debug] l2block %d sent to datastream", l2Block.L2BlockNumber) // Stream a bookmark - case state.DSBookMark: - bookmark := data + case datastream.BookMark: + err = s.streamServer.StartAtomicOp() + if err != nil { + log.Errorf("failed to start atomic op for bookmark type %d, value %d, error: %v", data.Type, data.Value, err) + continue + } + marshalledBookMark, err := proto.Marshal(&data) + if err != nil { + log.Errorf("failed to marshal bookmark type %d, value %d, error: %v", data.Type, data.Value, err) + continue + } + + _, err = s.streamServer.AddStreamBookmark(marshalledBookMark) + if err != nil { + log.Errorf("failed to add stream bookmark for bookmark type %d, value %d, error: %v", data.Type, data.Value, err) + continue + } + + err = s.streamServer.CommitAtomicOp() + if err != nil { + log.Errorf("failed to commit atomic op for bookmark type %d, value %d, error: %v", data.Type, data.Value, err) + continue + } + case datastream.Batch: err = s.streamServer.StartAtomicOp() if err != nil { - log.Errorf("failed to start atomic op for bookmark type %d, value %d, error: %v", bookmark.Type, bookmark.Value, err) + log.Errorf("failed to start atomic op for batch, error: %v", err) continue } - _, err = s.streamServer.AddStreamBookmark(bookmark.Encode()) + data.ChainId = chainID + + marshalledBatch, err := proto.Marshal(&data) + if err != nil { + log.Errorf("failed to marshal batch, error: %v", err) + continue + } + + _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledBatch) if err != nil { - log.Errorf("failed to add stream bookmark type %d, value %d, error: %v", bookmark.Type, bookmark.Value, err) + log.Errorf("failed to add stream entry for batch, error: %v", err) continue } err = s.streamServer.CommitAtomicOp() if err != nil { - log.Errorf("failed to commit atomic op for bookmark type %d, value %d, error: %v", bookmark.Type, bookmark.Value, err) + log.Errorf("failed to commit atomic op for batch, error: %v", err) + continue } // Invalid stream message type diff --git a/state/datastream.go b/state/datastream.go index d50c7adecf..eb3670e6f9 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -2,14 +2,16 @@ package state import ( "context" - "encoding/binary" "math/big" + "time" "github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer" "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/state/datastream" "github.com/ethereum/go-ethereum/common" "github.com/iden3/go-iden3-crypto/keccak256" "github.com/jackc/pgx/v4" + "google.golang.org/protobuf/proto" ) const ( @@ -17,18 +19,6 @@ const ( StreamTypeSequencer datastreamer.StreamType = 1 // EntryTypeBookMark represents a bookmark entry EntryTypeBookMark datastreamer.EntryType = datastreamer.EtBookmark - // EntryTypeL2BlockStart represents a L2 block start - EntryTypeL2BlockStart datastreamer.EntryType = 1 - // EntryTypeL2Tx represents a L2 transaction - EntryTypeL2Tx datastreamer.EntryType = 2 - // EntryTypeL2BlockEnd represents a L2 block end - EntryTypeL2BlockEnd datastreamer.EntryType = 3 - // EntryTypeUpdateGER represents a GER update - EntryTypeUpdateGER datastreamer.EntryType = 4 - // BookMarkTypeL2Block represents a L2 block bookmark - BookMarkTypeL2Block byte = 0 - // BookMarkTypeBatch represents a batch - BookMarkTypeBatch byte = 1 // SystemSC is the system smart contract address SystemSC = "0x000000000000000000000000000000005ca1ab1e" // posConstant is the constant used to compute the position of the intermediate state root @@ -38,7 +28,8 @@ const ( // DSBatch represents a data stream batch type DSBatch struct { Batch - ForkID uint16 + ForkID uint64 + EtrogTimestamp *time.Time } // DSFullBatch represents a data stream batch ant its L2 blocks @@ -55,64 +46,18 @@ type DSL2FullBlock struct { // DSL2Block is a full l2 block type DSL2Block struct { - BatchNumber uint64 // 8 bytes - L2BlockNumber uint64 // 8 bytes - Timestamp int64 // 8 bytes - L1InfoTreeIndex uint32 // 4 bytes - L1BlockHash common.Hash // 32 bytes - GlobalExitRoot common.Hash // 32 bytes - Coinbase common.Address // 20 bytes - ForkID uint16 // 2 bytes - ChainID uint32 // 4 bytes - BlockHash common.Hash // 32 bytes - StateRoot common.Hash // 32 bytes -} - -// DSL2BlockStart represents a data stream L2 block start -type DSL2BlockStart struct { - BatchNumber uint64 // 8 bytes - L2BlockNumber uint64 // 8 bytes - Timestamp int64 // 8 bytes - DeltaTimestamp uint32 // 4 bytes - L1InfoTreeIndex uint32 // 4 bytes - L1BlockHash common.Hash // 32 bytes - GlobalExitRoot common.Hash // 32 bytes - Coinbase common.Address // 20 bytes - ForkID uint16 // 2 bytes - ChainID uint32 // 4 bytes - -} - -// Encode returns the encoded DSL2BlockStart as a byte slice -func (b DSL2BlockStart) Encode() []byte { - bytes := make([]byte, 0) - bytes = binary.BigEndian.AppendUint64(bytes, b.BatchNumber) - bytes = binary.BigEndian.AppendUint64(bytes, b.L2BlockNumber) - bytes = binary.BigEndian.AppendUint64(bytes, uint64(b.Timestamp)) - bytes = binary.BigEndian.AppendUint32(bytes, b.DeltaTimestamp) - bytes = binary.BigEndian.AppendUint32(bytes, b.L1InfoTreeIndex) - bytes = append(bytes, b.L1BlockHash.Bytes()...) - bytes = append(bytes, b.GlobalExitRoot.Bytes()...) - bytes = append(bytes, b.Coinbase.Bytes()...) - bytes = binary.BigEndian.AppendUint16(bytes, b.ForkID) - bytes = binary.BigEndian.AppendUint32(bytes, b.ChainID) - return bytes -} - -// Decode decodes the DSL2BlockStart from a byte slice -func (b DSL2BlockStart) Decode(data []byte) DSL2BlockStart { - b.BatchNumber = binary.BigEndian.Uint64(data[0:8]) - b.L2BlockNumber = binary.BigEndian.Uint64(data[8:16]) - b.Timestamp = int64(binary.BigEndian.Uint64(data[16:24])) - b.DeltaTimestamp = binary.BigEndian.Uint32(data[24:28]) - b.L1InfoTreeIndex = binary.BigEndian.Uint32(data[28:32]) - b.L1BlockHash = common.BytesToHash(data[32:64]) - b.GlobalExitRoot = common.BytesToHash(data[64:96]) - b.Coinbase = common.BytesToAddress(data[96:116]) - b.ForkID = binary.BigEndian.Uint16(data[116:118]) - b.ChainID = binary.BigEndian.Uint32(data[118:122]) - - return b + BatchNumber uint64 + L2BlockNumber uint64 + Timestamp uint64 + Min_timestamp uint64 + L1InfoTreeIndex uint32 + L1BlockHash common.Hash + GlobalExitRoot common.Hash + Coinbase common.Address + ForkID uint64 + ChainID uint64 + BlockHash common.Hash + StateRoot common.Hash } // DSL2Transaction represents a data stream L2 transaction @@ -126,108 +71,6 @@ type DSL2Transaction struct { Encoded []byte } -// Encode returns the encoded DSL2Transaction as a byte slice -func (l DSL2Transaction) Encode() []byte { - bytes := make([]byte, 0) - bytes = append(bytes, l.EffectiveGasPricePercentage) - bytes = append(bytes, l.IsValid) - bytes = append(bytes, l.StateRoot[:]...) - bytes = binary.BigEndian.AppendUint32(bytes, l.EncodedLength) - bytes = append(bytes, l.Encoded...) - return bytes -} - -// Decode decodes the DSL2Transaction from a byte slice -func (l DSL2Transaction) Decode(data []byte) DSL2Transaction { - l.EffectiveGasPricePercentage = data[0] - l.IsValid = data[1] - l.StateRoot = common.BytesToHash(data[2:34]) - l.EncodedLength = binary.BigEndian.Uint32(data[34:38]) - l.Encoded = data[38:] - return l -} - -// DSL2BlockEnd represents a L2 block end -type DSL2BlockEnd struct { - L2BlockNumber uint64 // 8 bytes - BlockHash common.Hash // 32 bytes - StateRoot common.Hash // 32 bytes -} - -// Encode returns the encoded DSL2BlockEnd as a byte slice -func (b DSL2BlockEnd) Encode() []byte { - bytes := make([]byte, 0) - bytes = binary.BigEndian.AppendUint64(bytes, b.L2BlockNumber) - bytes = append(bytes, b.BlockHash[:]...) - bytes = append(bytes, b.StateRoot[:]...) - return bytes -} - -// Decode decodes the DSL2BlockEnd from a byte slice -func (b DSL2BlockEnd) Decode(data []byte) DSL2BlockEnd { - b.L2BlockNumber = binary.BigEndian.Uint64(data[0:8]) - b.BlockHash = common.BytesToHash(data[8:40]) - b.StateRoot = common.BytesToHash(data[40:72]) - return b -} - -// DSBookMark represents a data stream bookmark -type DSBookMark struct { - Type byte // 1 byte - Value uint64 // 8 bytes -} - -// Encode returns the encoded DSBookMark as a byte slice -func (b DSBookMark) Encode() []byte { - bytes := make([]byte, 0) - bytes = append(bytes, b.Type) - bytes = binary.BigEndian.AppendUint64(bytes, b.Value) - return bytes -} - -// Decode decodes the DSBookMark from a byte slice -func (b DSBookMark) Decode(data []byte) DSBookMark { - b.Type = data[0] - b.Value = binary.BigEndian.Uint64(data[1:9]) - return b -} - -// DSUpdateGER represents a data stream GER update -type DSUpdateGER struct { - BatchNumber uint64 // 8 bytes - Timestamp int64 // 8 bytes - GlobalExitRoot common.Hash // 32 bytes - Coinbase common.Address // 20 bytes - ForkID uint16 // 2 bytes - ChainID uint32 // 4 bytes - StateRoot common.Hash // 32 bytes -} - -// Encode returns the encoded DSUpdateGER as a byte slice -func (g DSUpdateGER) Encode() []byte { - bytes := make([]byte, 0) - bytes = binary.BigEndian.AppendUint64(bytes, g.BatchNumber) - bytes = binary.BigEndian.AppendUint64(bytes, uint64(g.Timestamp)) - bytes = append(bytes, g.GlobalExitRoot[:]...) - bytes = append(bytes, g.Coinbase[:]...) - bytes = binary.BigEndian.AppendUint16(bytes, g.ForkID) - bytes = binary.BigEndian.AppendUint32(bytes, g.ChainID) - bytes = append(bytes, g.StateRoot[:]...) - return bytes -} - -// Decode decodes the DSUpdateGER from a byte slice -func (g DSUpdateGER) Decode(data []byte) DSUpdateGER { - g.BatchNumber = binary.BigEndian.Uint64(data[0:8]) - g.Timestamp = int64(binary.BigEndian.Uint64(data[8:16])) - g.GlobalExitRoot = common.BytesToHash(data[16:48]) - g.Coinbase = common.BytesToAddress(data[48:68]) - g.ForkID = binary.BigEndian.Uint16(data[68:70]) - g.ChainID = binary.BigEndian.Uint32(data[70:74]) - g.StateRoot = common.BytesToHash(data[74:106]) - return g -} - // DSState gathers the methods required to interact with the data stream state. type DSState interface { GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*DSL2Block, error) @@ -240,14 +83,14 @@ type DSState interface { GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) } -// GenerateDataStreamerFile generates or resumes a data stream file -func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.StreamServer, stateDB DSState, readWIPBatch bool, imStateRoots *map[uint64][]byte, chainID uint64, upgradeEtrogBatchNumber uint64) error { +// GenerateDataStreamFile generates or resumes a data stream file +func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.StreamServer, stateDB DSState, readWIPBatch bool, imStateRoots *map[uint64][]byte, chainID uint64, upgradeEtrogBatchNumber uint64) error { header := streamServer.GetHeader() var currentBatchNumber uint64 = 0 var lastAddedL2BlockNumber uint64 = 0 var lastAddedBatchNumber uint64 = 0 - var previousTimestamp int64 = 0 + var previousTimestamp uint64 = 0 if header.TotalEntries == 0 { // Get Genesis block @@ -261,52 +104,73 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St return err } - bookMark := DSBookMark{ - Type: BookMarkTypeBatch, + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, Value: genesisL2Block.BatchNumber, } - _, err = streamServer.AddStreamBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) if err != nil { return err } - bookMark = DSBookMark{ - Type: BookMarkTypeL2Block, + _, err = streamServer.AddStreamBookmark(marshalledBookMark) + if err != nil { + return err + } + + bookMark = &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, Value: genesisL2Block.L2BlockNumber, } - _, err = streamServer.AddStreamBookmark(bookMark.Encode()) + marshalledBookMark, err = proto.Marshal(bookMark) + if err != nil { + return err + } + + _, err = streamServer.AddStreamBookmark(marshalledBookMark) if err != nil { return err } - genesisBlock := DSL2BlockStart{ - BatchNumber: genesisL2Block.BatchNumber, - L2BlockNumber: genesisL2Block.L2BlockNumber, - Timestamp: genesisL2Block.Timestamp, + genesisBlock := &datastream.L2Block{ + Number: genesisL2Block.L2BlockNumber, DeltaTimestamp: 0, - L1InfoTreeIndex: 0, - GlobalExitRoot: genesisL2Block.GlobalExitRoot, - Coinbase: genesisL2Block.Coinbase, - ForkID: genesisL2Block.ForkID, - ChainID: uint32(chainID), + MinTimestamp: 0, + L1InfotreeIndex: 0, + Hash: genesisL2Block.BlockHash.Bytes(), + StateRoot: genesisL2Block.StateRoot.Bytes(), + GlobalExitRoot: genesisL2Block.GlobalExitRoot.Bytes(), + Coinbase: genesisL2Block.Coinbase.Bytes(), } - log.Infof("Genesis block: %+v", genesisBlock) + log.Debugf("Genesis block: %+v", genesisBlock) + + marshalledGenesisBlock, err := proto.Marshal(genesisBlock) + if err != nil { + return err + } - _, err = streamServer.AddStreamEntry(1, genesisBlock.Encode()) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK), marshalledGenesisBlock) if err != nil { return err } - genesisBlockEnd := DSL2BlockEnd{ - L2BlockNumber: genesisL2Block.L2BlockNumber, - BlockHash: genesisL2Block.BlockHash, - StateRoot: genesisL2Block.StateRoot, + genesisBatch := &datastream.Batch{ + Number: genesisL2Block.BatchNumber, + LocalExitRoot: common.Hash{}.Bytes(), + StateRoot: genesisL2Block.StateRoot.Bytes(), + ForkId: genesisL2Block.ForkID, + ChainId: chainID, + } + + marshalledGenesisBatch, err := proto.Marshal(genesisBatch) + if err != nil { + return err } - _, err = streamServer.AddStreamEntry(EntryTypeL2BlockEnd, genesisBlockEnd.Encode()) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledGenesisBatch) if err != nil { return err } @@ -325,35 +189,88 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St log.Infof("Latest entry: %+v", latestEntry) switch latestEntry.Type { - case EntryTypeUpdateGER: + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH): + log.Info("Latest entry type is Batch") + + batch := &datastream.Batch{} + if err := proto.Unmarshal(latestEntry.Data, batch); err != nil { + return err + } + + currentBatchNumber = batch.Number + currentBatchNumber++ + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER): log.Info("Latest entry type is UpdateGER") - currentBatchNumber = binary.BigEndian.Uint64(latestEntry.Data[0:8]) + + updateGer := &datastream.UpdateGER{} + if err := proto.Unmarshal(latestEntry.Data, updateGer); err != nil { + return err + } + + currentBatchNumber = updateGer.BatchNumber currentBatchNumber++ - case EntryTypeL2BlockEnd: - log.Info("Latest entry type is L2BlockEnd") - blockEnd := DSL2BlockEnd{}.Decode(latestEntry.Data) - currentL2BlockNumber := blockEnd.L2BlockNumber - - bookMark := DSBookMark{ - Type: BookMarkTypeL2Block, - Value: currentL2BlockNumber, + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK): + log.Info("Latest entry type is L2Block") + + l2Block := &datastream.L2Block{} + + if err := proto.Unmarshal(latestEntry.Data, l2Block); err != nil { + return err + } + + currentL2BlockNumber := l2Block.Number + currentBatchNumber = l2Block.BatchNumber + previousTimestamp = l2Block.Timestamp + lastAddedL2BlockNumber = currentL2BlockNumber + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION): + log.Info("Latest entry type is Transaction") + + transaction := &datastream.Transaction{} + if err := proto.Unmarshal(latestEntry.Data, transaction); err != nil { + return err + } + + currentL2BlockNumber := transaction.L2BlockNumber + currentBatchNumber = transaction.L2BlockNumber + lastAddedL2BlockNumber = currentL2BlockNumber + + // Get Previous l2block timestamp + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, + Value: currentL2BlockNumber - 1, } - firstEntry, err := streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) if err != nil { return err } - blockStart := DSL2BlockStart{}.Decode(firstEntry.Data) + prevL2BlockEntryNumber, err := streamServer.GetBookmark(marshalledBookMark) + if err != nil { + return err + } + + prevL2BlockEntry, err := streamServer.GetEntry(prevL2BlockEntryNumber) + if err != nil { + return err + } + + prevL2Block := &datastream.L2Block{} + if err := proto.Unmarshal(prevL2BlockEntry.Data, prevL2Block); err != nil { + return err + } + + previousTimestamp = prevL2Block.Timestamp - currentBatchNumber = blockStart.BatchNumber - previousTimestamp = blockStart.Timestamp - lastAddedL2BlockNumber = currentL2BlockNumber case EntryTypeBookMark: log.Info("Latest entry type is BookMark") - bookMark := DSBookMark{} - bookMark = bookMark.Decode(latestEntry.Data) - if bookMark.Type == BookMarkTypeBatch { + + bookMark := &datastream.BookMark{} + if err := proto.Unmarshal(latestEntry.Data, bookMark); err != nil { + return err + } + + if bookMark.Type == datastream.BookmarkType_BOOKMARK_TYPE_BATCH { currentBatchNumber = bookMark.Value } else { log.Fatalf("Latest entry type is an unexpected bookmark type: %v", bookMark.Type) @@ -424,21 +341,26 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St return err } - bookMark := DSBookMark{ - Type: BookMarkTypeBatch, + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, Value: batch.BatchNumber, } + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err + } + missingBatchBookMark := true if b == 0 { - _, err = streamServer.GetBookmark(bookMark.Encode()) + _, err = streamServer.GetBookmark(marshalledBookMark) if err == nil { missingBatchBookMark = false } } if missingBatchBookMark { - _, err = streamServer.AddStreamBookmark(bookMark.Encode()) + _, err = streamServer.AddStreamBookmark(marshalledBookMark) if err != nil { return err } @@ -448,17 +370,22 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St // Empty batch // Check if there is a GER update if batch.GlobalExitRoot != currentGER && batch.GlobalExitRoot != (common.Hash{}) { - updateGer := DSUpdateGER{ + updateGER := &datastream.UpdateGER{ BatchNumber: batch.BatchNumber, - Timestamp: batch.Timestamp.Unix(), - GlobalExitRoot: batch.GlobalExitRoot, - Coinbase: batch.Coinbase, - ForkID: batch.ForkID, - ChainID: uint32(chainID), - StateRoot: batch.StateRoot, + Timestamp: uint64(batch.Timestamp.Unix()), + GlobalExitRoot: batch.GlobalExitRoot.Bytes(), + Coinbase: batch.Coinbase.Bytes(), + ForkId: batch.ForkID, + ChainId: chainID, + StateRoot: batch.StateRoot.Bytes(), + } + + marshalledUpdateGER, err := proto.Marshal(updateGER) + if err != nil { + return err } - _, err = streamServer.AddStreamEntry(EntryTypeUpdateGER, updateGer.Encode()) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER), marshalledUpdateGER) if err != nil { return err } @@ -517,38 +444,57 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St } } - blockStart := DSL2BlockStart{ + streamL2Block := &datastream.L2Block{ + Number: l2Block.L2BlockNumber, BatchNumber: l2Block.BatchNumber, - L2BlockNumber: l2Block.L2BlockNumber, Timestamp: l2Block.Timestamp, DeltaTimestamp: uint32(l2Block.Timestamp - previousTimestamp), - L1InfoTreeIndex: l1InfoTreeIndex, - L1BlockHash: l1BlockHash, - GlobalExitRoot: l2Block.GlobalExitRoot, - Coinbase: l2Block.Coinbase, - ForkID: l2Block.ForkID, - ChainID: uint32(chainID), + MinTimestamp: uint64(batch.Timestamp.Unix()), + L1Blockhash: l1BlockHash.Bytes(), + L1InfotreeIndex: l1InfoTreeIndex, + Hash: l2Block.BlockHash.Bytes(), + StateRoot: l2Block.StateRoot.Bytes(), + GlobalExitRoot: l2Block.GlobalExitRoot.Bytes(), + Coinbase: l2Block.Coinbase.Bytes(), + } + + if l2Block.ForkID >= FORKID_ETROG { + streamL2Block.Hash = l2Block.StateRoot.Bytes() + } + + if l2Block.ForkID == FORKID_ETROG && batch.EtrogTimestamp != nil { + streamL2Block.MinTimestamp = uint64(batch.EtrogTimestamp.Unix()) } previousTimestamp = l2Block.Timestamp - bookMark := DSBookMark{ - Type: BookMarkTypeL2Block, - Value: blockStart.L2BlockNumber, + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, + Value: streamL2Block.Number, + } + + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err } // Check if l2 block was already added - _, err = streamServer.GetBookmark(bookMark.Encode()) + _, err = streamServer.GetBookmark(marshalledBookMark) if err == nil { continue } - _, err = streamServer.AddStreamBookmark(bookMark.Encode()) + _, err = streamServer.AddStreamBookmark(marshalledBookMark) + if err != nil { + return err + } + + marshalledL2Block, err := proto.Marshal(streamL2Block) if err != nil { return err } - _, err = streamServer.AddStreamEntry(EntryTypeL2BlockStart, blockStart.Encode()) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK), marshalledL2Block) if err != nil { return err } @@ -559,7 +505,7 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St // > ETROG => IM State root is retrieved from the receipt.im_state_root if l2Block.ForkID < FORKID_ETROG { // Populate intermediate state root with information from the system SC (or cache if available) - if imStateRoots == nil || (*imStateRoots)[blockStart.L2BlockNumber] == nil { + if imStateRoots == nil || (*imStateRoots)[streamL2Block.Number] == nil { position := GetSystemSCPosition(l2Block.L2BlockNumber) imStateRoot, err := stateDB.GetStorageAt(ctx, common.HexToAddress(SystemSC), big.NewInt(0).SetBytes(position), l2Block.StateRoot) if err != nil { @@ -567,35 +513,53 @@ func GenerateDataStreamerFile(ctx context.Context, streamServer *datastreamer.St } tx.StateRoot = common.BigToHash(imStateRoot) } else { - tx.StateRoot = common.BytesToHash((*imStateRoots)[blockStart.L2BlockNumber]) + tx.StateRoot = common.BytesToHash((*imStateRoots)[streamL2Block.Number]) } } else if l2Block.ForkID > FORKID_ETROG { tx.StateRoot = tx.ImStateRoot } - _, err = streamServer.AddStreamEntry(EntryTypeL2Tx, tx.Encode()) + transaction := &datastream.Transaction{ + L2BlockNumber: tx.L2BlockNumber, + IsValid: tx.IsValid != 0, + Encoded: tx.Encoded, + EffectiveGasPricePercentage: uint32(tx.EffectiveGasPricePercentage), + ImStateRoot: tx.StateRoot.Bytes(), + } + + marshalledTransaction, err := proto.Marshal(transaction) if err != nil { return err } - } - - blockEnd := DSL2BlockEnd{ - L2BlockNumber: l2Block.L2BlockNumber, - BlockHash: l2Block.BlockHash, - StateRoot: l2Block.StateRoot, - } - if l2Block.ForkID >= FORKID_ETROG { - blockEnd.BlockHash = l2Block.StateRoot + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION), marshalledTransaction) + if err != nil { + return err + } } - _, err = streamServer.AddStreamEntry(EntryTypeL2BlockEnd, blockEnd.Encode()) - if err != nil { - return err - } currentGER = l2Block.GlobalExitRoot } } + + batch := &datastream.Batch{ + Number: batch.BatchNumber, + LocalExitRoot: batch.LocalExitRoot.Bytes(), + StateRoot: batch.StateRoot.Bytes(), + ForkId: batch.ForkID, + ChainId: chainID, + } + + marshalledBatch, err := proto.Marshal(batch) + if err != nil { + return err + } + + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledBatch) + if err != nil { + return err + } + // Commit at the end of each batch group err = streamServer.CommitAtomicOp() if err != nil { diff --git a/state/datastream/datastream.pb.go b/state/datastream/datastream.pb.go new file mode 100644 index 0000000000..1f0ede74fc --- /dev/null +++ b/state/datastream/datastream.pb.go @@ -0,0 +1,773 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc v4.25.3 +// source: datastream.proto + +package datastream + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type BookmarkType int32 + +const ( + BookmarkType_BOOKMARK_TYPE_UNSPECIFIED BookmarkType = 0 + BookmarkType_BOOKMARK_TYPE_BATCH BookmarkType = 1 + BookmarkType_BOOKMARK_TYPE_L2_BLOCK BookmarkType = 2 +) + +// Enum value maps for BookmarkType. +var ( + BookmarkType_name = map[int32]string{ + 0: "BOOKMARK_TYPE_UNSPECIFIED", + 1: "BOOKMARK_TYPE_BATCH", + 2: "BOOKMARK_TYPE_L2_BLOCK", + } + BookmarkType_value = map[string]int32{ + "BOOKMARK_TYPE_UNSPECIFIED": 0, + "BOOKMARK_TYPE_BATCH": 1, + "BOOKMARK_TYPE_L2_BLOCK": 2, + } +) + +func (x BookmarkType) Enum() *BookmarkType { + p := new(BookmarkType) + *p = x + return p +} + +func (x BookmarkType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (BookmarkType) Descriptor() protoreflect.EnumDescriptor { + return file_datastream_proto_enumTypes[0].Descriptor() +} + +func (BookmarkType) Type() protoreflect.EnumType { + return &file_datastream_proto_enumTypes[0] +} + +func (x BookmarkType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use BookmarkType.Descriptor instead. +func (BookmarkType) EnumDescriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{0} +} + +type EntryType int32 + +const ( + EntryType_ENTRY_TYPE_UNSPECIFIED EntryType = 0 + EntryType_ENTRY_TYPE_BATCH EntryType = 1 + EntryType_ENTRY_TYPE_L2_BLOCK EntryType = 2 + EntryType_ENTRY_TYPE_TRANSACTION EntryType = 3 + EntryType_ENTRY_TYPE_UPDATE_GER EntryType = 4 +) + +// Enum value maps for EntryType. +var ( + EntryType_name = map[int32]string{ + 0: "ENTRY_TYPE_UNSPECIFIED", + 1: "ENTRY_TYPE_BATCH", + 2: "ENTRY_TYPE_L2_BLOCK", + 3: "ENTRY_TYPE_TRANSACTION", + 4: "ENTRY_TYPE_UPDATE_GER", + } + EntryType_value = map[string]int32{ + "ENTRY_TYPE_UNSPECIFIED": 0, + "ENTRY_TYPE_BATCH": 1, + "ENTRY_TYPE_L2_BLOCK": 2, + "ENTRY_TYPE_TRANSACTION": 3, + "ENTRY_TYPE_UPDATE_GER": 4, + } +) + +func (x EntryType) Enum() *EntryType { + p := new(EntryType) + *p = x + return p +} + +func (x EntryType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (EntryType) Descriptor() protoreflect.EnumDescriptor { + return file_datastream_proto_enumTypes[1].Descriptor() +} + +func (EntryType) Type() protoreflect.EnumType { + return &file_datastream_proto_enumTypes[1] +} + +func (x EntryType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use EntryType.Descriptor instead. +func (EntryType) EnumDescriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{1} +} + +type Batch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + LocalExitRoot []byte `protobuf:"bytes,2,opt,name=local_exit_root,json=localExitRoot,proto3" json:"local_exit_root,omitempty"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` + ForkId uint64 `protobuf:"varint,4,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` + ChainId uint64 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (x *Batch) Reset() { + *x = Batch{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Batch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Batch) ProtoMessage() {} + +func (x *Batch) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Batch.ProtoReflect.Descriptor instead. +func (*Batch) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{0} +} + +func (x *Batch) GetNumber() uint64 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *Batch) GetLocalExitRoot() []byte { + if x != nil { + return x.LocalExitRoot + } + return nil +} + +func (x *Batch) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *Batch) GetForkId() uint64 { + if x != nil { + return x.ForkId + } + return 0 +} + +func (x *Batch) GetChainId() uint64 { + if x != nil { + return x.ChainId + } + return 0 +} + +type L2Block struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + BatchNumber uint64 `protobuf:"varint,2,opt,name=batch_number,json=batchNumber,proto3" json:"batch_number,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + DeltaTimestamp uint32 `protobuf:"varint,4,opt,name=delta_timestamp,json=deltaTimestamp,proto3" json:"delta_timestamp,omitempty"` + MinTimestamp uint64 `protobuf:"varint,5,opt,name=min_timestamp,json=minTimestamp,proto3" json:"min_timestamp,omitempty"` + L1Blockhash []byte `protobuf:"bytes,6,opt,name=l1_blockhash,json=l1Blockhash,proto3" json:"l1_blockhash,omitempty"` + L1InfotreeIndex uint32 `protobuf:"varint,7,opt,name=l1_infotree_index,json=l1InfotreeIndex,proto3" json:"l1_infotree_index,omitempty"` + Hash []byte `protobuf:"bytes,8,opt,name=hash,proto3" json:"hash,omitempty"` + StateRoot []byte `protobuf:"bytes,9,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` + GlobalExitRoot []byte `protobuf:"bytes,10,opt,name=global_exit_root,json=globalExitRoot,proto3" json:"global_exit_root,omitempty"` + Coinbase []byte `protobuf:"bytes,11,opt,name=coinbase,proto3" json:"coinbase,omitempty"` +} + +func (x *L2Block) Reset() { + *x = L2Block{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *L2Block) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*L2Block) ProtoMessage() {} + +func (x *L2Block) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use L2Block.ProtoReflect.Descriptor instead. +func (*L2Block) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{1} +} + +func (x *L2Block) GetNumber() uint64 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *L2Block) GetBatchNumber() uint64 { + if x != nil { + return x.BatchNumber + } + return 0 +} + +func (x *L2Block) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *L2Block) GetDeltaTimestamp() uint32 { + if x != nil { + return x.DeltaTimestamp + } + return 0 +} + +func (x *L2Block) GetMinTimestamp() uint64 { + if x != nil { + return x.MinTimestamp + } + return 0 +} + +func (x *L2Block) GetL1Blockhash() []byte { + if x != nil { + return x.L1Blockhash + } + return nil +} + +func (x *L2Block) GetL1InfotreeIndex() uint32 { + if x != nil { + return x.L1InfotreeIndex + } + return 0 +} + +func (x *L2Block) GetHash() []byte { + if x != nil { + return x.Hash + } + return nil +} + +func (x *L2Block) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *L2Block) GetGlobalExitRoot() []byte { + if x != nil { + return x.GlobalExitRoot + } + return nil +} + +func (x *L2Block) GetCoinbase() []byte { + if x != nil { + return x.Coinbase + } + return nil +} + +type Transaction struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + L2BlockNumber uint64 `protobuf:"varint,1,opt,name=l2block_number,json=l2blockNumber,proto3" json:"l2block_number,omitempty"` + IsValid bool `protobuf:"varint,2,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"` + Encoded []byte `protobuf:"bytes,3,opt,name=encoded,proto3" json:"encoded,omitempty"` + EffectiveGasPricePercentage uint32 `protobuf:"varint,4,opt,name=effective_gas_price_percentage,json=effectiveGasPricePercentage,proto3" json:"effective_gas_price_percentage,omitempty"` + ImStateRoot []byte `protobuf:"bytes,5,opt,name=im_state_root,json=imStateRoot,proto3" json:"im_state_root,omitempty"` +} + +func (x *Transaction) Reset() { + *x = Transaction{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Transaction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Transaction) ProtoMessage() {} + +func (x *Transaction) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Transaction.ProtoReflect.Descriptor instead. +func (*Transaction) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{2} +} + +func (x *Transaction) GetL2BlockNumber() uint64 { + if x != nil { + return x.L2BlockNumber + } + return 0 +} + +func (x *Transaction) GetIsValid() bool { + if x != nil { + return x.IsValid + } + return false +} + +func (x *Transaction) GetEncoded() []byte { + if x != nil { + return x.Encoded + } + return nil +} + +func (x *Transaction) GetEffectiveGasPricePercentage() uint32 { + if x != nil { + return x.EffectiveGasPricePercentage + } + return 0 +} + +func (x *Transaction) GetImStateRoot() []byte { + if x != nil { + return x.ImStateRoot + } + return nil +} + +type UpdateGER struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BatchNumber uint64 `protobuf:"varint,1,opt,name=batch_number,json=batchNumber,proto3" json:"batch_number,omitempty"` + Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + GlobalExitRoot []byte `protobuf:"bytes,3,opt,name=global_exit_root,json=globalExitRoot,proto3" json:"global_exit_root,omitempty"` + Coinbase []byte `protobuf:"bytes,4,opt,name=coinbase,proto3" json:"coinbase,omitempty"` + ForkId uint64 `protobuf:"varint,5,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` + ChainId uint64 `protobuf:"varint,6,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + StateRoot []byte `protobuf:"bytes,7,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` +} + +func (x *UpdateGER) Reset() { + *x = UpdateGER{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateGER) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateGER) ProtoMessage() {} + +func (x *UpdateGER) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateGER.ProtoReflect.Descriptor instead. +func (*UpdateGER) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{3} +} + +func (x *UpdateGER) GetBatchNumber() uint64 { + if x != nil { + return x.BatchNumber + } + return 0 +} + +func (x *UpdateGER) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *UpdateGER) GetGlobalExitRoot() []byte { + if x != nil { + return x.GlobalExitRoot + } + return nil +} + +func (x *UpdateGER) GetCoinbase() []byte { + if x != nil { + return x.Coinbase + } + return nil +} + +func (x *UpdateGER) GetForkId() uint64 { + if x != nil { + return x.ForkId + } + return 0 +} + +func (x *UpdateGER) GetChainId() uint64 { + if x != nil { + return x.ChainId + } + return 0 +} + +func (x *UpdateGER) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +type BookMark struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type BookmarkType `protobuf:"varint,1,opt,name=type,proto3,enum=datastream.v1.BookmarkType" json:"type,omitempty"` + Value uint64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *BookMark) Reset() { + *x = BookMark{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BookMark) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BookMark) ProtoMessage() {} + +func (x *BookMark) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BookMark.ProtoReflect.Descriptor instead. +func (*BookMark) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{4} +} + +func (x *BookMark) GetType() BookmarkType { + if x != nil { + return x.Type + } + return BookmarkType_BOOKMARK_TYPE_UNSPECIFIED +} + +func (x *BookMark) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +var File_datastream_proto protoreflect.FileDescriptor + +var file_datastream_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, + 0x31, 0x22, 0x9a, 0x01, 0x0a, 0x05, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, + 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x6c, 0x6f, + 0x63, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, + 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, + 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x22, 0xf8, + 0x02, 0x0a, 0x07, 0x4c, 0x32, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x64, 0x65, + 0x6c, 0x74, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, 0x0a, 0x0d, + 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x31, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, + 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x31, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x74, + 0x72, 0x65, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0f, 0x6c, 0x31, 0x49, 0x6e, 0x66, 0x6f, 0x74, 0x72, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x68, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, + 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x32, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0d, 0x6c, 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, + 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x65, 0x6e, + 0x63, 0x6f, 0x64, 0x65, 0x64, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, + 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x65, + 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x61, 0x73, 0x50, 0x72, 0x69, 0x63, 0x65, + 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x6d, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0b, 0x69, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xe5, + 0x01, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x45, 0x52, 0x12, 0x21, 0x0a, 0x0c, + 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, + 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, + 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, + 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, + 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x51, 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x4d, 0x61, + 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1b, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, + 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x62, 0x0a, 0x0c, 0x42, 0x6f, 0x6f, + 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x42, 0x4f, 0x4f, + 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x42, 0x4f, 0x4f, 0x4b, + 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, + 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x2a, 0x8d, 0x01, + 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, + 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x54, 0x52, 0x59, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, 0x01, 0x12, 0x17, 0x0a, + 0x13, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, + 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, + 0x10, 0x03, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x45, 0x52, 0x10, 0x04, 0x42, 0x38, 0x5a, + 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, + 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, + 0x6d, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x64, 0x61, 0x74, + 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_datastream_proto_rawDescOnce sync.Once + file_datastream_proto_rawDescData = file_datastream_proto_rawDesc +) + +func file_datastream_proto_rawDescGZIP() []byte { + file_datastream_proto_rawDescOnce.Do(func() { + file_datastream_proto_rawDescData = protoimpl.X.CompressGZIP(file_datastream_proto_rawDescData) + }) + return file_datastream_proto_rawDescData +} + +var file_datastream_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_datastream_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_datastream_proto_goTypes = []interface{}{ + (BookmarkType)(0), // 0: datastream.v1.BookmarkType + (EntryType)(0), // 1: datastream.v1.EntryType + (*Batch)(nil), // 2: datastream.v1.Batch + (*L2Block)(nil), // 3: datastream.v1.L2Block + (*Transaction)(nil), // 4: datastream.v1.Transaction + (*UpdateGER)(nil), // 5: datastream.v1.UpdateGER + (*BookMark)(nil), // 6: datastream.v1.BookMark +} +var file_datastream_proto_depIdxs = []int32{ + 0, // 0: datastream.v1.BookMark.type:type_name -> datastream.v1.BookmarkType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_datastream_proto_init() } +func file_datastream_proto_init() { + if File_datastream_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_datastream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Batch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_datastream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*L2Block); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_datastream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Transaction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_datastream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateGER); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_datastream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BookMark); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_datastream_proto_rawDesc, + NumEnums: 2, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_datastream_proto_goTypes, + DependencyIndexes: file_datastream_proto_depIdxs, + EnumInfos: file_datastream_proto_enumTypes, + MessageInfos: file_datastream_proto_msgTypes, + }.Build() + File_datastream_proto = out.File + file_datastream_proto_rawDesc = nil + file_datastream_proto_goTypes = nil + file_datastream_proto_depIdxs = nil +} diff --git a/state/pgstatestorage/datastream.go b/state/pgstatestorage/datastream.go index 4b15000aeb..31c9814c0a 100644 --- a/state/pgstatestorage/datastream.go +++ b/state/pgstatestorage/datastream.go @@ -78,7 +78,7 @@ func scanL2Block(row pgx.Row) (*state.DSL2Block, error) { } l2Block.GlobalExitRoot = common.HexToHash(gerStr) l2Block.Coinbase = common.HexToAddress(coinbaseStr) - l2Block.Timestamp = timestamp.Unix() + l2Block.Timestamp = uint64(timestamp.Unix()) l2Block.BlockHash = common.HexToHash(blockHashStr) l2Block.StateRoot = common.HexToHash(stateRootStr) @@ -151,9 +151,13 @@ func scanDSL2Transaction(row pgx.Row) (*state.DSL2Transaction, error) { // GetDSBatches returns the DS batches func (p *PostgresStorage) GetDSBatches(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*state.DSBatch, error) { var getBatchByNumberSQL = ` - SELECT b.batch_num, b.global_exit_root, b.local_exit_root, b.acc_input_hash, b.state_root, b.timestamp, b.coinbase, b.raw_txs_data, b.forced_batch_num, b.wip, f.fork_id - FROM state.batch b, state.fork_id f - WHERE b.batch_num >= $1 AND b.batch_num <= $2 AND batch_num between f.from_batch_num AND f.to_batch_num` + SELECT b.batch_num, b.global_exit_root, b.local_exit_root, b.acc_input_hash, b.state_root, b.timestamp, b.coinbase, b.raw_txs_data, b.forced_batch_num, b.wip, f.fork_id, vb.timestamp_batch_etrog + FROM state.batch b + LEFT JOIN + state.fork_id f ON b.batch_num BETWEEN f.from_batch_num AND f.to_batch_num + LEFT JOIN + state.virtual_batch vb ON b.batch_num = vb.batch_num + WHERE b.batch_num >= $1 AND b.batch_num <= $2` if !readWIPBatch { getBatchByNumberSQL += " AND b.wip is false" @@ -205,6 +209,7 @@ func scanDSBatch(row pgx.Row) (state.DSBatch, error) { &batch.ForcedBatchNum, &batch.WIP, &batch.ForkID, + &batch.EtrogTimestamp, ) if err != nil { return batch, err diff --git a/state/test/datastream_test.go b/state/test/datastream_test.go deleted file mode 100644 index 8860cf9740..0000000000 --- a/state/test/datastream_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package test - -import ( - "fmt" - "testing" - "time" - - "github.com/0xPolygonHermez/zkevm-node/state" - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" -) - -func TestL2BlockStartEncode(t *testing.T) { - l2BlockStart := state.DSL2BlockStart{ - BatchNumber: 1, - L2BlockNumber: 2, - Timestamp: 3, - DeltaTimestamp: 4, - L1InfoTreeIndex: 5, - L1BlockHash: common.HexToHash("0x06"), - GlobalExitRoot: common.HexToHash("0x07"), - Coinbase: common.HexToAddress("0x08"), - ForkID: 9, - ChainID: 10, - } - - encoded := l2BlockStart.Encode() - expected := []byte{ - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 3, - 0, 0, 0, 4, - 0, 0, 0, 5, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 0, 9, - 0, 0, 0, 10} - - assert.Equal(t, expected, encoded) -} - -func TestL2TransactionEncode(t *testing.T) { - l2Transaction := state.DSL2Transaction{ - EffectiveGasPricePercentage: 128, // 1 byte - IsValid: 1, // 1 byte - StateRoot: common.HexToHash("0x010203"), // 32 bytes - EncodedLength: 5, // 4 bytes - Encoded: []byte{1, 2, 3, 4, 5}, // 5 bytes - } - - encoded := l2Transaction.Encode() - expected := []byte{128, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 5, 1, 2, 3, 4, 5} - assert.Equal(t, expected, encoded) -} - -func TestL2BlockEndEncode(t *testing.T) { - l2BlockEnd := state.DSL2BlockEnd{ - L2BlockNumber: 1, // 8 bytes - BlockHash: common.HexToHash("0x02"), // 32 bytes - StateRoot: common.HexToHash("0x03"), // 32 bytes - } - - encoded := l2BlockEnd.Encode() - expected := []byte{0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3} - - assert.Equal(t, expected, encoded) -} - -func TestCalculateSCPosition(t *testing.T) { - a := time.Now() - blockNumber := uint64(2934867) - expected := common.HexToHash("0xaa93c484856be45716623765b429a967296594ca362e61e91d671fb422e0f744") - position := state.GetSystemSCPosition(blockNumber) - assert.Equal(t, expected, common.BytesToHash(position)) - b := time.Now() - - c := b.Sub(a) - fmt.Println(c) -} diff --git a/test/docker-compose.yml b/test/docker-compose.yml index a738bdcd1f..a36ea6007b 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -513,9 +513,12 @@ services: zkevm-prover: container_name: zkevm-prover image: hermeznetwork/zkevm-prover:v6.0.0 + platform: linux/amd64 ports: - 50061:50061 # MT - 50071:50071 # Executor + environment: + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 volumes: - ./config/test.prover.config.json:/usr/src/app/config.json environment: @@ -603,7 +606,10 @@ services: zkevm-permissionless-prover: container_name: zkevm-permissionless-prover + platform: linux/amd64 image: hermeznetwork/zkevm-prover:v6.0.0 + environment: + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 ports: # - 50058:50058 # Prover - 50059:50052 # Mock prover diff --git a/tools/datastreamer/Makefile b/tools/datastreamer/Makefile index 5698417c34..e79b0cb1a8 100644 --- a/tools/datastreamer/Makefile +++ b/tools/datastreamer/Makefile @@ -6,12 +6,14 @@ check-go: # Targets that require the checks generate-file: check-go -reprocess: check-go decode-entry-offline: check-go decode-l2block-offline: check-go decode-entry: check-go decode-l2block: check-go +decode-batch: check-go +decode-batch-offline: check-go truncate: check-go +dump-batch: check-go arguments := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) @@ -27,6 +29,10 @@ decode-entry: ## Runs the tool to decode a given entry number decode-l2block: ## Runs the tool to decode a given L2 block go run main.go decode-l2block -cfg config/tool.config.toml -l2block $(arguments) +.PHONY: decode-batch +decode-batch: ## Runs the tool to decode a given batch + go run main.go decode-batch -cfg config/tool.config.toml -batch $(arguments) + .PHONY: decode-entry-offline decode-entry-offline: ## Runs the offline tool to decode a given entry number go run main.go decode-entry-offline -cfg config/tool.config.toml -entry $(arguments) @@ -35,13 +41,21 @@ decode-entry-offline: ## Runs the offline tool to decode a given entry number decode-l2block-offline: ## Runs the offline tool to decode a given L2 block go run main.go decode-l2block-offline -cfg config/tool.config.toml -l2block $(arguments) +.PHONY: decode-batch-offline +decode-batch-offline: ## Runs the offline tool to decode a given batch + go run main.go decode-batch-offline -cfg config/tool.config.toml -batch $(arguments) + .PHONY: truncate truncate: ## Runs the offline tool to truncate the stream file go run main.go truncate -cfg config/tool.config.toml -entry $(arguments) -# .PHONY: reprocess -reprocess: ## Runs the tool to reprocess the information in the stream since a given l2 block - go run main.go reprocess -cfg config/tool.config.toml -genesis ../test/config/test.genesis.config.json -l2block $(arguments) +.PHONY: dump-batch +dump-batch: ## Runs the tool to dump a given batch to file + go run main.go dump-batch -cfg config/tool.config.toml -d -batch $(arguments) + +.PHONY: dump-batch-offline +dump-batch-offline: ## Runs the tool to dump a given batch to file offline + go run main.go dump-batch-offline -cfg config/tool.config.toml -d -batch $(arguments) ## Help display. ## Pulls comments from beside commands and prints a nicely formatted diff --git a/tools/datastreamer/config/tool.config.toml b/tools/datastreamer/config/tool.config.toml index c497f3362f..0e8fc09fc9 100644 --- a/tools/datastreamer/config/tool.config.toml +++ b/tools/datastreamer/config/tool.config.toml @@ -1,11 +1,11 @@ [Online] -URI = "zkevm-sequencer:6900" +URI = "localhost:6900" StreamType = 1 [Offline] Port = 6901 Filename = "datastream.bin" -Version = 1 +Version = 3 ChainID = 1440 UpgradeEtrogBatchNumber = 0 @@ -18,12 +18,8 @@ Port = "5432" EnableLog = false MaxConns = 200 -[Executor] -URI = "zkevm-prover:50071" -MaxGRPCMessageSize = 100000000 - [MerkleTree] -URI = "zkevm-prover:50061" +URI = "localhost:50061" MaxThreads = 20 CacheFile = "merkle_tree_cache.json" diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go index 975e4c7ecd..bb84aeebf3 100644 --- a/tools/datastreamer/main.go +++ b/tools/datastreamer/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/binary" "encoding/json" "fmt" "math/big" @@ -12,19 +11,16 @@ import ( "github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer" "github.com/0xPolygonHermez/zkevm-data-streamer/log" - nodeConfig "github.com/0xPolygonHermez/zkevm-node/config" "github.com/0xPolygonHermez/zkevm-node/db" - "github.com/0xPolygonHermez/zkevm-node/encoding" - "github.com/0xPolygonHermez/zkevm-node/hex" "github.com/0xPolygonHermez/zkevm-node/merkletree" "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/state/datastream" "github.com/0xPolygonHermez/zkevm-node/state/pgstatestorage" - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" "github.com/0xPolygonHermez/zkevm-node/tools/datastreamer/config" "github.com/ethereum/go-ethereum/common" "github.com/fatih/color" - "github.com/google/uuid" "github.com/urfave/cli/v2" + "google.golang.org/protobuf/proto" ) const ( @@ -41,14 +37,6 @@ var ( Required: true, } - genesisFileFlag = cli.StringFlag{ - Name: config.FlagGenesis, - Aliases: []string{"g"}, - Usage: "Genesis `FILE`", - DefaultText: "./config/genesis.json", - Required: true, - } - entryFlag = cli.Uint64Flag{ Name: "entry", Aliases: []string{"e"}, @@ -63,10 +51,17 @@ var ( Required: true, } - updateFileFlag = cli.BoolFlag{ - Name: "update", - Aliases: []string{"u"}, - Usage: "Update `FILE`", + batchFlag = cli.Uint64Flag{ + Name: "batch", + Aliases: []string{"bn"}, + Usage: "Batch `NUMBER`", + Required: true, + } + + dumpFlag = cli.BoolFlag{ + Name: "dump", + Aliases: []string{"d"}, + Usage: "Dump batch to file", Required: false, } ) @@ -86,18 +81,6 @@ func main() { &configFileFlag, }, }, - { - Name: "reprocess", - Aliases: []string{}, - Usage: "Reprocess l2block since a given l2block number", - Action: reprocess, - Flags: []cli.Flag{ - &configFileFlag, - &genesisFileFlag, - &l2blockFlag, - &updateFileFlag, - }, - }, { Name: "decode-entry-offline", Aliases: []string{}, @@ -118,6 +101,16 @@ func main() { &l2blockFlag, }, }, + { + Name: "decode-batch-offline", + Aliases: []string{}, + Usage: "Decodes a batch offline", + Action: decodeBatchOffline, + Flags: []cli.Flag{ + &configFileFlag, + &batchFlag, + }, + }, { Name: "decode-entry", Aliases: []string{}, @@ -138,6 +131,16 @@ func main() { &l2blockFlag, }, }, + { + Name: "decode-batch", + Aliases: []string{}, + Usage: "Decodes a batch", + Action: decodeBatch, + Flags: []cli.Flag{ + &configFileFlag, + &batchFlag, + }, + }, { Name: "truncate", Aliases: []string{}, @@ -148,6 +151,28 @@ func main() { &entryFlag, }, }, + { + Name: "dump-batch", + Aliases: []string{}, + Usage: "Dumps a batch to file", + Action: decodeBatch, + Flags: []cli.Flag{ + &configFileFlag, + &batchFlag, + &dumpFlag, + }, + }, + { + Name: "dump-batch-offline", + Aliases: []string{}, + Usage: "Dumps a batch to file offline", + Action: decodeBatchOffline, + Flags: []cli.Flag{ + &configFileFlag, + &batchFlag, + &dumpFlag, + }, + }, } err := app.Run(os.Args) @@ -272,7 +297,7 @@ func generate(cliCtx *cli.Context) error { } } - err = state.GenerateDataStreamerFile(cliCtx.Context, streamServer, stateDB, false, &imStateRoots, c.Offline.ChainID, c.Offline.UpgradeEtrogBatchNumber) // nolint:gomnd + err = state.GenerateDataStreamFile(cliCtx.Context, streamServer, stateDB, false, &imStateRoots, c.Offline.ChainID, c.Offline.UpgradeEtrogBatchNumber) if err != nil { log.Error(err) os.Exit(1) @@ -299,13 +324,18 @@ func getImStateRoots(ctx context.Context, start, end uint64, isStateRoots *map[u log.Errorf("Error: %v\n", err) os.Exit(1) } + + if common.BytesToHash(imStateRoot.Bytes()) == state.ZeroHash && x != 0 { + break + } + imStateRootMux.Lock() (*isStateRoots)[x] = imStateRoot.Bytes() imStateRootMux.Unlock() } } -func reprocess(cliCtx *cli.Context) error { +func decodeEntry(cliCtx *cli.Context) error { c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -314,230 +344,90 @@ func reprocess(cliCtx *cli.Context) error { log.Init(c.Log) - ctx := cliCtx.Context - - genesisFileAsStr, err := nodeConfig.LoadGenesisFileAsString(cliCtx.String(config.FlagGenesis)) + client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType) if err != nil { - fmt.Printf("failed to load genesis file. Error: %v", err) + log.Error(err) os.Exit(1) } - networkConfig, err := nodeConfig.LoadGenesisFromJSONString(genesisFileAsStr) + err = client.Start() if err != nil { - fmt.Printf("failed to load genesis configuration from file. Error: %v", err) + log.Error(err) os.Exit(1) } - currentL2BlockNumber := cliCtx.Uint64("l2block") - var stateRoot []byte - - streamServer, err := initializeStreamServer(c) + entry, err := client.ExecCommandGetEntry(cliCtx.Uint64("entry")) if err != nil { log.Error(err) os.Exit(1) } - if currentL2BlockNumber == 0 { - printColored(color.FgHiYellow, "\n\nSetting Genesis block\n\n") - - mtDBServerConfig := merkletree.Config{URI: c.MerkleTree.URI} - var mtDBCancel context.CancelFunc - mtDBServiceClient, mtDBClientConn, mtDBCancel := merkletree.NewMTDBServiceClient(ctx, mtDBServerConfig) - defer func() { - mtDBCancel() - mtDBClientConn.Close() - }() - - stateTree := merkletree.NewStateTree(mtDBServiceClient) - - stateRoot, err = setGenesis(ctx, stateTree, networkConfig.Genesis) - if err != nil { - log.Error(err) - os.Exit(1) - } - - // Get Genesis block from the file and validate the state root - bookMark := state.DSBookMark{ - Type: state.BookMarkTypeL2Block, - Value: 0, - } - - firstEntry, err := streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) - if err != nil { - log.Error(err) - os.Exit(1) - } - printEntry(firstEntry) - - secondEntry, err := streamServer.GetEntry(firstEntry.Number + 1) - if err != nil { - log.Error(err) - os.Exit(1) - } - printEntry(secondEntry) + printEntry(entry) + return nil +} - if common.Bytes2Hex(stateRoot) != common.Bytes2Hex(secondEntry.Data[40:72]) { - printColored(color.FgRed, "\nError: Genesis state root does not match\n\n") - os.Exit(1) - } else { - printColored(color.FgGreen, "\nGenesis state root matches\n\n") - } - currentL2BlockNumber++ +func decodeL2Block(cliCtx *cli.Context) error { + c, err := config.Load(cliCtx) + if err != nil { + log.Error(err) + os.Exit(1) } - // Connect to the executor - executorClient, executorClientConn, executorCancel := executor.NewExecutorClient(ctx, c.Executor) - defer func() { - executorCancel() - executorClientConn.Close() - }() + log.Init(c.Log) - bookMark := state.DSBookMark{ - Type: state.BookMarkTypeL2Block, - Value: currentL2BlockNumber, + client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType) + if err != nil { + log.Error(err) + os.Exit(1) } - startEntry, err := streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + err = client.Start() if err != nil { log.Error(err) os.Exit(1) } - var previousStateRoot = stateRoot - var maxEntry = streamServer.GetHeader().TotalEntries - - for x := startEntry.Number; x < maxEntry; x++ { - printColored(color.FgHiYellow, fmt.Sprintf("\nProcessing entity: %d\n", x)) - - currentEntry, err := streamServer.GetEntry(x) - if err != nil { - log.Error(err) - os.Exit(1) - } - - var processBatchRequest *executor.ProcessBatchRequest - var expectedNewRoot []byte - var entryToUpdate *datastreamer.FileEntry - - switch currentEntry.Type { - case state.EntryTypeBookMark: - printEntry(currentEntry) - entryToUpdate = nil - continue - case state.EntryTypeUpdateGER: - printEntry(currentEntry) - processBatchRequest = &executor.ProcessBatchRequest{ - OldBatchNum: binary.BigEndian.Uint64(currentEntry.Data[0:8]) - 1, - Coinbase: common.Bytes2Hex(currentEntry.Data[48:68]), - BatchL2Data: nil, - OldStateRoot: previousStateRoot, - GlobalExitRoot: currentEntry.Data[16:48], - OldAccInputHash: []byte{}, - EthTimestamp: binary.BigEndian.Uint64(currentEntry.Data[8:16]), - UpdateMerkleTree: uint32(1), - ChainId: c.Offline.ChainID, - ForkId: uint64(binary.BigEndian.Uint16(currentEntry.Data[68:70])), - } - - expectedNewRoot = currentEntry.Data[70:102] - entryToUpdate = nil - case state.EntryTypeL2BlockStart: - startEntry = currentEntry - printEntry(startEntry) - - txEntry, err := streamServer.GetEntry(startEntry.Number + 1) - if err != nil { - log.Error(err) - os.Exit(1) - } - printEntry(txEntry) - - endEntry, err := streamServer.GetEntry(startEntry.Number + 2) //nolint:gomnd - if err != nil { - log.Error(err) - os.Exit(1) - } - printEntry(endEntry) - - forkID := uint64(binary.BigEndian.Uint16(startEntry.Data[76:78])) - - tx, err := state.DecodeTx(common.Bytes2Hex((txEntry.Data[6:]))) - if err != nil { - log.Error(err) - os.Exit(1) - } + l2BlockNumber := cliCtx.Uint64("l2block") - // Get the old state root - oldStateRoot := getOldStateRoot(startEntry.Number, streamServer) + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, + Value: l2BlockNumber, + } - // RLP encode the transaction using the proper fork id - batchL2Data, err := state.EncodeTransaction(*tx, txEntry.Data[0], forkID) //nolint:gomnd - if err != nil { - log.Error(err) - os.Exit(1) - } + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err + } - processBatchRequest = &executor.ProcessBatchRequest{ - OldBatchNum: binary.BigEndian.Uint64(startEntry.Data[0:8]) - 1, - Coinbase: common.Bytes2Hex(startEntry.Data[56:76]), - BatchL2Data: batchL2Data, - OldStateRoot: oldStateRoot, - GlobalExitRoot: startEntry.Data[24:56], - OldAccInputHash: []byte{}, - EthTimestamp: binary.BigEndian.Uint64(startEntry.Data[16:24]), - UpdateMerkleTree: uint32(1), - ChainId: c.Offline.ChainID, - ForkId: uint64(binary.BigEndian.Uint16(startEntry.Data[76:78])), - } + firstEntry, err := client.ExecCommandGetBookmark(marshalledBookMark) + if err != nil { + log.Error(err) + os.Exit(1) + } + printEntry(firstEntry) - expectedNewRoot = endEntry.Data[40:72] - entryToUpdate = &endEntry - x += 2 //nolint:gomnd - } + secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1) + if err != nil { + log.Error(err) + os.Exit(1) + } - // Process batch - processBatchResponse, err := executorClient.ProcessBatch(ctx, processBatchRequest) + i := uint64(2) //nolint:gomnd + for secondEntry.Type == datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION) { + printEntry(secondEntry) + entry, err := client.ExecCommandGetEntry(firstEntry.Number + i) if err != nil { log.Error(err) os.Exit(1) } - - if processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { - fmt.Printf("Error: %v\n", processBatchResponse.Error) - os.Exit(1) - } - - if common.Bytes2Hex(processBatchResponse.NewStateRoot) != common.Bytes2Hex(expectedNewRoot) { - printColored(color.FgRed, "\nNew state root does not match\n\n") - printColored(color.FgRed, fmt.Sprintf("Old State Root.........: %s\n", "0x"+common.Bytes2Hex(processBatchRequest.GetOldStateRoot()))) - printColored(color.FgRed, fmt.Sprintf("New State Root.........: %s\n", "0x"+common.Bytes2Hex(processBatchResponse.NewStateRoot))) - printColored(color.FgRed, fmt.Sprintf("Expected New State Root: %s\n", "0x"+common.Bytes2Hex(expectedNewRoot))) - // Check if we must update the file with the new state root - if cliCtx.Bool("update") { - if entryToUpdate.Type != state.EntryTypeL2BlockEnd { - printColored(color.FgRed, "Error: Entry to update is not a L2BlockEnd\n") - os.Exit(1) - } - blockEnd := state.DSL2BlockEnd{}.Decode(entryToUpdate.Data) - blockEnd.StateRoot = common.BytesToHash(processBatchResponse.NewStateRoot) - err = streamServer.UpdateEntryData(entryToUpdate.Number, state.EntryTypeL2BlockEnd, blockEnd.Encode()) - if err != nil { - printColored(color.FgRed, fmt.Sprintf("Error: %v\n", err)) - os.Exit(1) - } - } else { - break - } - } else { - printColored(color.FgGreen, "New state root matches\n") - previousStateRoot = processBatchResponse.NewStateRoot - } + secondEntry = entry + i++ } return nil } -func decodeEntry(cliCtx *cli.Context) error { +func decodeEntryOffline(cliCtx *cli.Context) error { c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -546,29 +436,24 @@ func decodeEntry(cliCtx *cli.Context) error { log.Init(c.Log) - client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType) - if err != nil { - log.Error(err) - os.Exit(1) - } - - err = client.Start() + streamServer, err := initializeStreamServer(c) if err != nil { log.Error(err) os.Exit(1) } - entry, err := client.ExecCommandGetEntry(cliCtx.Uint64("entry")) + entry, err := streamServer.GetEntry(cliCtx.Uint64("entry")) if err != nil { log.Error(err) os.Exit(1) } printEntry(entry) + return nil } -func decodeL2Block(cliCtx *cli.Context) error { +func decodeL2BlockOffline(cliCtx *cli.Context) error { c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -577,13 +462,7 @@ func decodeL2Block(cliCtx *cli.Context) error { log.Init(c.Log) - client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType) - if err != nil { - log.Error(err) - os.Exit(1) - } - - err = client.Start() + streamServer, err := initializeStreamServer(c) if err != nil { log.Error(err) os.Exit(1) @@ -591,41 +470,45 @@ func decodeL2Block(cliCtx *cli.Context) error { l2BlockNumber := cliCtx.Uint64("l2block") - bookMark := state.DSBookMark{ - Type: state.BookMarkTypeL2Block, + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, Value: l2BlockNumber, } - firstEntry, err := client.ExecCommandGetBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err + } + + firstEntry, err := streamServer.GetFirstEventAfterBookmark(marshalledBookMark) if err != nil { log.Error(err) os.Exit(1) } printEntry(firstEntry) - secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1) + secondEntry, err := streamServer.GetEntry(firstEntry.Number + 1) if err != nil { log.Error(err) os.Exit(1) } - printEntry(secondEntry) i := uint64(2) //nolint:gomnd - for secondEntry.Type == state.EntryTypeL2Tx { - entry, err := client.ExecCommandGetEntry(firstEntry.Number + i) + + for secondEntry.Type == datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION) { + printEntry(secondEntry) + secondEntry, err = streamServer.GetEntry(firstEntry.Number + i) if err != nil { log.Error(err) os.Exit(1) } - secondEntry = entry - printEntry(secondEntry) i++ } return nil } -func decodeEntryOffline(cliCtx *cli.Context) error { +func truncate(cliCtx *cli.Context) error { c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -640,18 +523,19 @@ func decodeEntryOffline(cliCtx *cli.Context) error { os.Exit(1) } - entry, err := streamServer.GetEntry(cliCtx.Uint64("entry")) + err = streamServer.TruncateFile(cliCtx.Uint64("entry")) if err != nil { log.Error(err) os.Exit(1) } - printEntry(entry) + printColored(color.FgGreen, "File truncated\n") return nil } -func decodeL2BlockOffline(cliCtx *cli.Context) error { +func decodeBatch(cliCtx *cli.Context) error { + var batchData = []byte{} c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -660,48 +544,85 @@ func decodeL2BlockOffline(cliCtx *cli.Context) error { log.Init(c.Log) - streamServer, err := initializeStreamServer(c) + client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType) if err != nil { log.Error(err) os.Exit(1) } - l2BlockNumber := cliCtx.Uint64("l2block") + err = client.Start() + if err != nil { + log.Error(err) + os.Exit(1) + } - bookMark := state.DSBookMark{ - Type: state.BookMarkTypeL2Block, - Value: l2BlockNumber, + batchNumber := cliCtx.Uint64("batch") + + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, + Value: batchNumber, } - firstEntry, err := streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err + } + + firstEntry, err := client.ExecCommandGetBookmark(marshalledBookMark) if err != nil { log.Error(err) os.Exit(1) } printEntry(firstEntry) - secondEntry, err := streamServer.GetEntry(firstEntry.Number + 1) + batchData = append(batchData, firstEntry.Encode()...) + + secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1) if err != nil { log.Error(err) os.Exit(1) } + printEntry(secondEntry) + + batchData = append(batchData, secondEntry.Encode()...) i := uint64(2) //nolint:gomnd - printEntry(secondEntry) - for secondEntry.Type == state.EntryTypeL2Tx { - secondEntry, err = streamServer.GetEntry(firstEntry.Number + i) + for { + entry, err := client.ExecCommandGetEntry(firstEntry.Number + i) if err != nil { log.Error(err) os.Exit(1) } + + if entry.Type == state.EntryTypeBookMark { + if err := proto.Unmarshal(entry.Data, bookMark); err != nil { + return err + } + if bookMark.Type == datastream.BookmarkType_BOOKMARK_TYPE_BATCH { + break + } + } + + secondEntry = entry printEntry(secondEntry) + batchData = append(batchData, secondEntry.Encode()...) i++ } + // Dump batchdata to a file + if cliCtx.Bool("dump") { + err = os.WriteFile(fmt.Sprintf("batch_%d.bin", batchNumber), batchData, 0644) // nolint:gosec, gomnd + if err != nil { + log.Error(err) + os.Exit(1) + } + } + return nil } -func truncate(cliCtx *cli.Context) error { +func decodeBatchOffline(cliCtx *cli.Context) error { + var batchData = []byte{} c, err := config.Load(cliCtx) if err != nil { log.Error(err) @@ -716,26 +637,84 @@ func truncate(cliCtx *cli.Context) error { os.Exit(1) } - err = streamServer.TruncateFile(cliCtx.Uint64("entry")) + batchNumber := cliCtx.Uint64("batch") + + bookMark := &datastream.BookMark{ + Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, + Value: batchNumber, + } + + marshalledBookMark, err := proto.Marshal(bookMark) + if err != nil { + return err + } + + firstEntry, err := streamServer.GetFirstEventAfterBookmark(marshalledBookMark) if err != nil { log.Error(err) os.Exit(1) } + printEntry(firstEntry) + batchData = append(batchData, firstEntry.Encode()...) - printColored(color.FgGreen, "File truncated\n") + secondEntry, err := streamServer.GetEntry(firstEntry.Number + 1) + if err != nil { + log.Error(err) + os.Exit(1) + } + + i := uint64(2) //nolint:gomnd + printEntry(secondEntry) + batchData = append(batchData, secondEntry.Encode()...) + for { + secondEntry, err = streamServer.GetEntry(firstEntry.Number + i) + if err != nil { + log.Error(err) + os.Exit(1) + } + + if secondEntry.Type == state.EntryTypeBookMark { + if err := proto.Unmarshal(secondEntry.Data, bookMark); err != nil { + return err + } + if bookMark.Type == datastream.BookmarkType_BOOKMARK_TYPE_BATCH { + break + } + } + + printEntry(secondEntry) + batchData = append(batchData, secondEntry.Encode()...) + i++ + } + + // Dump batchdata to a file + if cliCtx.Bool("dump") { + err = os.WriteFile(fmt.Sprintf("offline_batch_%d.bin", batchNumber), batchData, 0644) // nolint:gosec, gomnd + if err != nil { + log.Error(err) + os.Exit(1) + } + } return nil } func printEntry(entry datastreamer.FileEntry) { - var bookmarkTypeDesc = map[byte]string{ - state.BookMarkTypeL2Block: "L2 Block Number", - state.BookMarkTypeBatch: "Batch Number", + var bookmarkTypeDesc = map[datastream.BookmarkType]string{ + datastream.BookmarkType_BOOKMARK_TYPE_UNSPECIFIED: "Unspecified", + datastream.BookmarkType_BOOKMARK_TYPE_BATCH: "Batch Number", + datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK: "L2 Block Number", } switch entry.Type { case state.EntryTypeBookMark: - bookmark := state.DSBookMark{}.Decode(entry.Data) + bookmark := &datastream.BookMark{} + err := proto.Unmarshal(entry.Data, bookmark) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") printColored(color.FgHiYellow, "BookMark\n") printColored(color.FgGreen, "Entry Number....: ") @@ -744,48 +723,83 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%d (%s)\n", bookmark.Type, bookmarkTypeDesc[bookmark.Type])) printColored(color.FgGreen, "Value...........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", bookmark.Value)) - case state.EntryTypeL2BlockStart: - blockStart := state.DSL2BlockStart{}.Decode(entry.Data) + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK): + l2Block := &datastream.L2Block{} + err := proto.Unmarshal(entry.Data, l2Block) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") - printColored(color.FgHiYellow, "L2 Block Start\n") + printColored(color.FgHiYellow, "L2 Block\n") printColored(color.FgGreen, "Entry Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) - printColored(color.FgGreen, "Batch Number....: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.BatchNumber)) printColored(color.FgGreen, "L2 Block Number.: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.L2BlockNumber)) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.Number)) + printColored(color.FgGreen, "Batch Number....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.BatchNumber)) printColored(color.FgGreen, "Timestamp.......: ") - printColored(color.FgHiWhite, fmt.Sprintf("%v (%d)\n", time.Unix(blockStart.Timestamp, 0), blockStart.Timestamp)) + printColored(color.FgHiWhite, fmt.Sprintf("%d (%v)\n", l2Block.Timestamp, time.Unix(int64(l2Block.Timestamp), 0))) printColored(color.FgGreen, "Delta Timestamp.: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.DeltaTimestamp)) - printColored(color.FgGreen, "L1 InfoTree Idx.: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.L1InfoTreeIndex)) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.DeltaTimestamp)) + printColored(color.FgGreen, "Min. Timestamp..: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.MinTimestamp)) printColored(color.FgGreen, "L1 Block Hash...: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", blockStart.L1BlockHash)) + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.L1Blockhash))) + printColored(color.FgGreen, "L1 InfoTree Idx.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.L1InfotreeIndex)) + printColored(color.FgGreen, "Block Hash......: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.Hash))) + printColored(color.FgGreen, "State Root......: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.StateRoot))) printColored(color.FgGreen, "Global Exit Root: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", blockStart.GlobalExitRoot)) + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.GlobalExitRoot))) printColored(color.FgGreen, "Coinbase........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", blockStart.Coinbase)) + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToAddress(l2Block.Coinbase))) + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH): + batch := &datastream.Batch{} + err := proto.Unmarshal(entry.Data, batch) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") + printColored(color.FgHiYellow, "Batch\n") + printColored(color.FgGreen, "Entry Number....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) + printColored(color.FgGreen, "Batch Number....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.Number)) + printColored(color.FgGreen, "State Root......: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.StateRoot))) + printColored(color.FgGreen, "Local Exit Root.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.LocalExitRoot))) printColored(color.FgGreen, "Fork ID.........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.ForkID)) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ForkId)) printColored(color.FgGreen, "Chain ID........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockStart.ChainID)) - case state.EntryTypeL2Tx: - dsTx := state.DSL2Transaction{}.Decode(entry.Data) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ChainId)) + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION): + dsTx := &datastream.Transaction{} + err := proto.Unmarshal(entry.Data, dsTx) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") printColored(color.FgHiYellow, "L2 Transaction\n") printColored(color.FgGreen, "Entry Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) + printColored(color.FgGreen, "L2 Block Number.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", dsTx.L2BlockNumber)) + printColored(color.FgGreen, "Is Valid........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%t\n", dsTx.IsValid)) + printColored(color.FgGreen, "Data............: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(dsTx.Encoded))) printColored(color.FgGreen, "Effec. Gas Price: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", dsTx.EffectiveGasPricePercentage)) - printColored(color.FgGreen, "Is Valid........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%t\n", dsTx.IsValid == 1)) printColored(color.FgGreen, "IM State Root...: ") - printColored(color.FgHiWhite, fmt.Sprint(dsTx.StateRoot.Hex()+"\n")) - printColored(color.FgGreen, "Encoded Length..: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", dsTx.EncodedLength)) - printColored(color.FgGreen, "Encoded.........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(dsTx.Encoded))) + printColored(color.FgHiWhite, fmt.Sprint("0x"+common.Bytes2Hex(dsTx.ImStateRoot)+"\n")) tx, err := state.DecodeTx(common.Bytes2Hex(dsTx.Encoded)) if err != nil { @@ -804,20 +818,14 @@ func printEntry(entry datastreamer.FileEntry) { nonce := tx.Nonce() printColored(color.FgGreen, "Nonce...........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", nonce)) - case state.EntryTypeL2BlockEnd: - blockEnd := state.DSL2BlockEnd{}.Decode(entry.Data) - printColored(color.FgGreen, "Entry Type......: ") - printColored(color.FgHiYellow, "L2 Block End\n") - printColored(color.FgGreen, "Entry Number....: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) - printColored(color.FgGreen, "L2 Block Number.: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", blockEnd.L2BlockNumber)) - printColored(color.FgGreen, "L2 Block Hash...: ") - printColored(color.FgHiWhite, fmt.Sprint(blockEnd.BlockHash.Hex()+"\n")) - printColored(color.FgGreen, "State Root......: ") - printColored(color.FgHiWhite, fmt.Sprint(blockEnd.StateRoot.Hex()+"\n")) - case state.EntryTypeUpdateGER: - updateGer := state.DSUpdateGER{}.Decode(entry.Data) + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER): + updateGer := &datastream.UpdateGER{} + err := proto.Unmarshal(entry.Data, updateGer) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") printColored(color.FgHiYellow, "Update GER\n") printColored(color.FgGreen, "Entry Number....: ") @@ -825,17 +833,17 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgGreen, "Batch Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.BatchNumber)) printColored(color.FgGreen, "Timestamp.......: ") - printColored(color.FgHiWhite, fmt.Sprintf("%v (%d)\n", time.Unix(updateGer.Timestamp, 0), updateGer.Timestamp)) + printColored(color.FgHiWhite, fmt.Sprintf("%v (%d)\n", time.Unix(int64(updateGer.Timestamp), 0), updateGer.Timestamp)) printColored(color.FgGreen, "Global Exit Root: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", updateGer.GlobalExitRoot)) + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.Bytes2Hex(updateGer.GlobalExitRoot))) printColored(color.FgGreen, "Coinbase........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", updateGer.Coinbase)) + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToAddress(updateGer.Coinbase))) printColored(color.FgGreen, "Fork ID.........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.ForkID)) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.ForkId)) printColored(color.FgGreen, "Chain ID........: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.ChainID)) + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.ChainId)) printColored(color.FgGreen, "State Root......: ") - printColored(color.FgHiWhite, fmt.Sprint(updateGer.StateRoot.Hex()+"\n")) + printColored(color.FgHiWhite, fmt.Sprint(common.Bytes2Hex(updateGer.StateRoot)+"\n")) } } @@ -843,112 +851,3 @@ func printColored(color color.Attribute, text string) { colored := fmt.Sprintf("\x1b[%dm%s\x1b[0m", color, text) fmt.Print(colored) } - -// setGenesis populates state with genesis information -func setGenesis(ctx context.Context, tree *merkletree.StateTree, genesis state.Genesis) ([]byte, error) { - var ( - root common.Hash - newRoot []byte - err error - ) - - if tree == nil { - return newRoot, fmt.Errorf("state tree is nil") - } - - uuid := uuid.New().String() - - for _, action := range genesis.Actions { - address := common.HexToAddress(action.Address) - switch action.Type { - case int(merkletree.LeafTypeBalance): - balance, err := encoding.DecodeBigIntHexOrDecimal(action.Value) - if err != nil { - return newRoot, err - } - newRoot, _, err = tree.SetBalance(ctx, address, balance, newRoot, uuid) - if err != nil { - return newRoot, err - } - case int(merkletree.LeafTypeNonce): - nonce, err := encoding.DecodeBigIntHexOrDecimal(action.Value) - if err != nil { - return newRoot, err - } - newRoot, _, err = tree.SetNonce(ctx, address, nonce, newRoot, uuid) - if err != nil { - return newRoot, err - } - case int(merkletree.LeafTypeCode): - code, err := hex.DecodeHex(action.Bytecode) - if err != nil { - return newRoot, fmt.Errorf("could not decode SC bytecode for address %q: %v", address, err) - } - newRoot, _, err = tree.SetCode(ctx, address, code, newRoot, uuid) - if err != nil { - return newRoot, err - } - case int(merkletree.LeafTypeStorage): - // Parse position and value - positionBI, err := encoding.DecodeBigIntHexOrDecimal(action.StoragePosition) - if err != nil { - return newRoot, err - } - valueBI, err := encoding.DecodeBigIntHexOrDecimal(action.Value) - if err != nil { - return newRoot, err - } - // Store - newRoot, _, err = tree.SetStorageAt(ctx, address, positionBI, valueBI, newRoot, uuid) - if err != nil { - return newRoot, err - } - default: - return newRoot, fmt.Errorf("unknown genesis action type %q", action.Type) - } - } - - root.SetBytes(newRoot) - - // flush state db - err = tree.Flush(ctx, root, uuid) - if err != nil { - fmt.Printf("error flushing state tree after genesis: %v", err) - return newRoot, err - } - - return newRoot, nil -} - -func getOldStateRoot(entityNumber uint64, streamServer *datastreamer.StreamServer) []byte { - var found = false - var entry datastreamer.FileEntry - var err error - - for !found && entityNumber > 1 { - entityNumber-- - entry, err = streamServer.GetEntry(entityNumber) - if err != nil { - log.Error(err) - os.Exit(1) - } - - if entry.Type == state.EntryTypeL2BlockEnd || entry.Type == state.EntryTypeUpdateGER { - found = true - } - } - - if !found { - fmt.Printf("Error: Could not find old state root") - os.Exit(1) - } - - printColored(color.FgHiYellow, "Getting Old State Root from\n") - printEntry(entry) - - if entry.Type == state.EntryTypeUpdateGER { - return entry.Data[70:102] - } - - return entry.Data[40:72] -} From 72027431a2940ba6ec2cdbf2bda3f618540ded87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Thu, 2 May 2024 10:56:09 +0200 Subject: [PATCH 02/23] proto batch end (#3612) --- .../src/proto/datastream/v1/datastream.proto | 15 +- sequencer/batch.go | 4 +- sequencer/datastreamer.go | 17 +- sequencer/sequencer.go | 39 +- state/datastream.go | 67 +++- state/datastream/datastream.pb.go | 348 +++++++++++------- tools/datastreamer/main.go | 27 +- 7 files changed, 338 insertions(+), 179 deletions(-) diff --git a/proto/src/proto/datastream/v1/datastream.proto b/proto/src/proto/datastream/v1/datastream.proto index 6b8a89adc6..555bc17733 100644 --- a/proto/src/proto/datastream/v1/datastream.proto +++ b/proto/src/proto/datastream/v1/datastream.proto @@ -4,14 +4,18 @@ package datastream.v1; option go_package = "github.com/0xPolygonHermez/zkevm-node/state/datastream"; -message Batch { +message BatchStart { uint64 number = 1; - bytes local_exit_root = 2; - bytes state_root = 3; uint64 fork_id = 4; uint64 chain_id = 5; } +message BatchEnd { + uint64 number = 1; + bytes local_exit_root = 2; + bytes state_root = 3; +} + message L2Block { uint64 number = 1; uint64 batch_number = 2; @@ -57,8 +61,9 @@ enum BookmarkType { enum EntryType { ENTRY_TYPE_UNSPECIFIED = 0; - ENTRY_TYPE_BATCH = 1; + ENTRY_TYPE_BATCH_START = 1; ENTRY_TYPE_L2_BLOCK = 2; ENTRY_TYPE_TRANSACTION = 3; - ENTRY_TYPE_UPDATE_GER = 4; + ENTRY_TYPE_BATCH_END = 4; + ENTRY_TYPE_UPDATE_GER = 5; } diff --git a/sequencer/batch.go b/sequencer/batch.go index 8db3320a4d..cc2bea283a 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -339,6 +339,8 @@ func (f *finalizer) insertSIPBatch(ctx context.Context, batchNumber uint64, stat // Send batch bookmark to the datastream f.DSSendBatchBookmark(batchNumber) + // Send batch start to the datastream + f.DSSendBatchStart(batchNumber) // Check if synchronizer is up-to-date //TODO: review if this is needed @@ -404,7 +406,7 @@ func (f *finalizer) closeSIPBatch(ctx context.Context, dbTx pgx.Tx) error { } // Sent batch to DS - f.DSSendBatch(f.wipBatch.batchNumber, f.wipBatch.finalStateRoot, f.wipBatch.finalLocalExitRoot) + f.DSSendBatchEnd(f.wipBatch.batchNumber, f.wipBatch.finalStateRoot, f.wipBatch.finalLocalExitRoot) log.Infof("sip batch %d closed in statedb, closing reason: %s", f.sipBatch.batchNumber, f.sipBatch.closingReason) diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 81ed1083b0..8178593978 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -67,14 +67,23 @@ func (f *finalizer) DSSendBatchBookmark(batchNumber uint64) { } } -func (f *finalizer) DSSendBatch(batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) { +func (f *finalizer) DSSendBatchStart(batchNumber uint64) { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) if f.streamServer != nil { - // Send batch to the streamer - f.dataToStream <- datastream.Batch{ + // Send batch start to the streamer + f.dataToStream <- datastream.BatchStart{ + Number: batchNumber, + ForkId: forkID, + } + } +} + +func (f *finalizer) DSSendBatchEnd(batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) { + if f.streamServer != nil { + // Send batch end to the streamer + f.dataToStream <- datastream.BatchEnd{ Number: batchNumber, - ForkId: forkID, StateRoot: stateRoot.Bytes(), LocalExitRoot: localExitRoot.Bytes(), } diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index d1945234d5..a86d955d79 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -416,30 +416,55 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { log.Errorf("failed to commit atomic op for bookmark type %d, value %d, error: %v", data.Type, data.Value, err) continue } - case datastream.Batch: + case datastream.BatchStart: err = s.streamServer.StartAtomicOp() if err != nil { - log.Errorf("failed to start atomic op for batch, error: %v", err) + log.Errorf("failed to start atomic op for batch start, error: %v", err) continue } data.ChainId = chainID - marshalledBatch, err := proto.Marshal(&data) + marshalledBatchStart, err := proto.Marshal(&data) if err != nil { - log.Errorf("failed to marshal batch, error: %v", err) + log.Errorf("failed to marshal batch start error: %v", err) continue } - _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledBatch) + _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START), marshalledBatchStart) if err != nil { - log.Errorf("failed to add stream entry for batch, error: %v", err) + log.Errorf("failed to add stream entry for batch start, error: %v", err) continue } err = s.streamServer.CommitAtomicOp() if err != nil { - log.Errorf("failed to commit atomic op for batch, error: %v", err) + log.Errorf("failed to commit atomic op for batch start, error: %v", err) + continue + } + + case datastream.BatchEnd: + err = s.streamServer.StartAtomicOp() + if err != nil { + log.Errorf("failed to start atomic op for batch end, error: %v", err) + continue + } + + marshalledBatchEnd, err := proto.Marshal(&data) + if err != nil { + log.Errorf("failed to marshal batch end, error: %v", err) + continue + } + + _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END), marshalledBatchEnd) + if err != nil { + log.Errorf("failed to add stream entry for batch end, error: %v", err) + continue + } + + err = s.streamServer.CommitAtomicOp() + if err != nil { + log.Errorf("failed to commit atomic op for batch end, error: %v", err) continue } diff --git a/state/datastream.go b/state/datastream.go index eb3670e6f9..3ad11f3f75 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -157,20 +157,34 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre return err } - genesisBatch := &datastream.Batch{ + genesisBatchStart := &datastream.BatchStart{ + Number: genesisL2Block.BatchNumber, + ForkId: genesisL2Block.ForkID, + ChainId: chainID, + } + + marshalledGenesisBatchStart, err := proto.Marshal(genesisBatchStart) + if err != nil { + return err + } + + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START), marshalledGenesisBatchStart) + if err != nil { + return err + } + + genesisBatchEnd := &datastream.BatchEnd{ Number: genesisL2Block.BatchNumber, LocalExitRoot: common.Hash{}.Bytes(), StateRoot: genesisL2Block.StateRoot.Bytes(), - ForkId: genesisL2Block.ForkID, - ChainId: chainID, } - marshalledGenesisBatch, err := proto.Marshal(genesisBatch) + marshalledGenesisBatchEnd, err := proto.Marshal(genesisBatchEnd) if err != nil { return err } - _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledGenesisBatch) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END), marshalledGenesisBatchEnd) if err != nil { return err } @@ -189,15 +203,24 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre log.Infof("Latest entry: %+v", latestEntry) switch latestEntry.Type { - case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH): - log.Info("Latest entry type is Batch") + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START): + log.Info("Latest entry type is Batch Start") + + batchStart := &datastream.BatchStart{} + if err := proto.Unmarshal(latestEntry.Data, batchStart); err != nil { + return err + } + + currentBatchNumber = batchStart.Number + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END): + log.Info("Latest entry type is Batch End") - batch := &datastream.Batch{} - if err := proto.Unmarshal(latestEntry.Data, batch); err != nil { + batchEnd := &datastream.BatchStart{} + if err := proto.Unmarshal(latestEntry.Data, batchEnd); err != nil { return err } - currentBatchNumber = batch.Number + currentBatchNumber = batchEnd.Number currentBatchNumber++ case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER): log.Info("Latest entry type is UpdateGER") @@ -364,6 +387,22 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre if err != nil { return err } + + batchStart := &datastream.BatchStart{ + Number: batch.BatchNumber, + ForkId: batch.ForkID, + ChainId: chainID, + } + + marshalledBatchStart, err := proto.Marshal(batchStart) + if err != nil { + return err + } + + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START), marshalledBatchStart) + if err != nil { + return err + } } if len(batch.L2Blocks) == 0 { @@ -542,20 +581,18 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre } } - batch := &datastream.Batch{ + batchEnd := &datastream.BatchEnd{ Number: batch.BatchNumber, LocalExitRoot: batch.LocalExitRoot.Bytes(), StateRoot: batch.StateRoot.Bytes(), - ForkId: batch.ForkID, - ChainId: chainID, } - marshalledBatch, err := proto.Marshal(batch) + marshalledBatch, err := proto.Marshal(batchEnd) if err != nil { return err } - _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH), marshalledBatch) + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END), marshalledBatch) if err != nil { return err } diff --git a/state/datastream/datastream.pb.go b/state/datastream/datastream.pb.go index 1f0ede74fc..07a8ff7adf 100644 --- a/state/datastream/datastream.pb.go +++ b/state/datastream/datastream.pb.go @@ -73,27 +73,30 @@ type EntryType int32 const ( EntryType_ENTRY_TYPE_UNSPECIFIED EntryType = 0 - EntryType_ENTRY_TYPE_BATCH EntryType = 1 + EntryType_ENTRY_TYPE_BATCH_START EntryType = 1 EntryType_ENTRY_TYPE_L2_BLOCK EntryType = 2 EntryType_ENTRY_TYPE_TRANSACTION EntryType = 3 - EntryType_ENTRY_TYPE_UPDATE_GER EntryType = 4 + EntryType_ENTRY_TYPE_BATCH_END EntryType = 4 + EntryType_ENTRY_TYPE_UPDATE_GER EntryType = 5 ) // Enum value maps for EntryType. var ( EntryType_name = map[int32]string{ 0: "ENTRY_TYPE_UNSPECIFIED", - 1: "ENTRY_TYPE_BATCH", + 1: "ENTRY_TYPE_BATCH_START", 2: "ENTRY_TYPE_L2_BLOCK", 3: "ENTRY_TYPE_TRANSACTION", - 4: "ENTRY_TYPE_UPDATE_GER", + 4: "ENTRY_TYPE_BATCH_END", + 5: "ENTRY_TYPE_UPDATE_GER", } EntryType_value = map[string]int32{ "ENTRY_TYPE_UNSPECIFIED": 0, - "ENTRY_TYPE_BATCH": 1, + "ENTRY_TYPE_BATCH_START": 1, "ENTRY_TYPE_L2_BLOCK": 2, "ENTRY_TYPE_TRANSACTION": 3, - "ENTRY_TYPE_UPDATE_GER": 4, + "ENTRY_TYPE_BATCH_END": 4, + "ENTRY_TYPE_UPDATE_GER": 5, } ) @@ -124,20 +127,18 @@ func (EntryType) EnumDescriptor() ([]byte, []int) { return file_datastream_proto_rawDescGZIP(), []int{1} } -type Batch struct { +type BatchStart struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` - LocalExitRoot []byte `protobuf:"bytes,2,opt,name=local_exit_root,json=localExitRoot,proto3" json:"local_exit_root,omitempty"` - StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` - ForkId uint64 `protobuf:"varint,4,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` - ChainId uint64 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + ForkId uint64 `protobuf:"varint,4,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` + ChainId uint64 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (x *Batch) Reset() { - *x = Batch{} +func (x *BatchStart) Reset() { + *x = BatchStart{} if protoimpl.UnsafeEnabled { mi := &file_datastream_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -145,13 +146,13 @@ func (x *Batch) Reset() { } } -func (x *Batch) String() string { +func (x *BatchStart) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Batch) ProtoMessage() {} +func (*BatchStart) ProtoMessage() {} -func (x *Batch) ProtoReflect() protoreflect.Message { +func (x *BatchStart) ProtoReflect() protoreflect.Message { mi := &file_datastream_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -163,44 +164,93 @@ func (x *Batch) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Batch.ProtoReflect.Descriptor instead. -func (*Batch) Descriptor() ([]byte, []int) { +// Deprecated: Use BatchStart.ProtoReflect.Descriptor instead. +func (*BatchStart) Descriptor() ([]byte, []int) { return file_datastream_proto_rawDescGZIP(), []int{0} } -func (x *Batch) GetNumber() uint64 { +func (x *BatchStart) GetNumber() uint64 { if x != nil { return x.Number } return 0 } -func (x *Batch) GetLocalExitRoot() []byte { +func (x *BatchStart) GetForkId() uint64 { if x != nil { - return x.LocalExitRoot + return x.ForkId } - return nil + return 0 } -func (x *Batch) GetStateRoot() []byte { +func (x *BatchStart) GetChainId() uint64 { if x != nil { - return x.StateRoot + return x.ChainId } - return nil + return 0 +} + +type BatchEnd struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + LocalExitRoot []byte `protobuf:"bytes,2,opt,name=local_exit_root,json=localExitRoot,proto3" json:"local_exit_root,omitempty"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` } -func (x *Batch) GetForkId() uint64 { +func (x *BatchEnd) Reset() { + *x = BatchEnd{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BatchEnd) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchEnd) ProtoMessage() {} + +func (x *BatchEnd) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BatchEnd.ProtoReflect.Descriptor instead. +func (*BatchEnd) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{1} +} + +func (x *BatchEnd) GetNumber() uint64 { if x != nil { - return x.ForkId + return x.Number } return 0 } -func (x *Batch) GetChainId() uint64 { +func (x *BatchEnd) GetLocalExitRoot() []byte { if x != nil { - return x.ChainId + return x.LocalExitRoot } - return 0 + return nil +} + +func (x *BatchEnd) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil } type L2Block struct { @@ -224,7 +274,7 @@ type L2Block struct { func (x *L2Block) Reset() { *x = L2Block{} if protoimpl.UnsafeEnabled { - mi := &file_datastream_proto_msgTypes[1] + mi := &file_datastream_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -237,7 +287,7 @@ func (x *L2Block) String() string { func (*L2Block) ProtoMessage() {} func (x *L2Block) ProtoReflect() protoreflect.Message { - mi := &file_datastream_proto_msgTypes[1] + mi := &file_datastream_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -250,7 +300,7 @@ func (x *L2Block) ProtoReflect() protoreflect.Message { // Deprecated: Use L2Block.ProtoReflect.Descriptor instead. func (*L2Block) Descriptor() ([]byte, []int) { - return file_datastream_proto_rawDescGZIP(), []int{1} + return file_datastream_proto_rawDescGZIP(), []int{2} } func (x *L2Block) GetNumber() uint64 { @@ -345,7 +395,7 @@ type Transaction struct { func (x *Transaction) Reset() { *x = Transaction{} if protoimpl.UnsafeEnabled { - mi := &file_datastream_proto_msgTypes[2] + mi := &file_datastream_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -358,7 +408,7 @@ func (x *Transaction) String() string { func (*Transaction) ProtoMessage() {} func (x *Transaction) ProtoReflect() protoreflect.Message { - mi := &file_datastream_proto_msgTypes[2] + mi := &file_datastream_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -371,7 +421,7 @@ func (x *Transaction) ProtoReflect() protoreflect.Message { // Deprecated: Use Transaction.ProtoReflect.Descriptor instead. func (*Transaction) Descriptor() ([]byte, []int) { - return file_datastream_proto_rawDescGZIP(), []int{2} + return file_datastream_proto_rawDescGZIP(), []int{3} } func (x *Transaction) GetL2BlockNumber() uint64 { @@ -426,7 +476,7 @@ type UpdateGER struct { func (x *UpdateGER) Reset() { *x = UpdateGER{} if protoimpl.UnsafeEnabled { - mi := &file_datastream_proto_msgTypes[3] + mi := &file_datastream_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -439,7 +489,7 @@ func (x *UpdateGER) String() string { func (*UpdateGER) ProtoMessage() {} func (x *UpdateGER) ProtoReflect() protoreflect.Message { - mi := &file_datastream_proto_msgTypes[3] + mi := &file_datastream_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -452,7 +502,7 @@ func (x *UpdateGER) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateGER.ProtoReflect.Descriptor instead. func (*UpdateGER) Descriptor() ([]byte, []int) { - return file_datastream_proto_rawDescGZIP(), []int{3} + return file_datastream_proto_rawDescGZIP(), []int{4} } func (x *UpdateGER) GetBatchNumber() uint64 { @@ -516,7 +566,7 @@ type BookMark struct { func (x *BookMark) Reset() { *x = BookMark{} if protoimpl.UnsafeEnabled { - mi := &file_datastream_proto_msgTypes[4] + mi := &file_datastream_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -529,7 +579,7 @@ func (x *BookMark) String() string { func (*BookMark) ProtoMessage() {} func (x *BookMark) ProtoReflect() protoreflect.Message { - mi := &file_datastream_proto_msgTypes[4] + mi := &file_datastream_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -542,7 +592,7 @@ func (x *BookMark) ProtoReflect() protoreflect.Message { // Deprecated: Use BookMark.ProtoReflect.Descriptor instead. func (*BookMark) Descriptor() ([]byte, []int) { - return file_datastream_proto_rawDescGZIP(), []int{4} + return file_datastream_proto_rawDescGZIP(), []int{5} } func (x *BookMark) GetType() BookmarkType { @@ -564,92 +614,97 @@ var File_datastream_proto protoreflect.FileDescriptor var file_datastream_proto_rawDesc = []byte{ 0x0a, 0x10, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, - 0x31, 0x22, 0x9a, 0x01, 0x0a, 0x05, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, - 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x6c, 0x6f, - 0x63, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, - 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, - 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x22, 0xf8, - 0x02, 0x0a, 0x07, 0x4c, 0x32, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x64, 0x65, - 0x6c, 0x74, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, 0x0a, 0x0d, - 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x31, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, - 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x31, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x74, - 0x72, 0x65, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x0f, 0x6c, 0x31, 0x49, 0x6e, 0x66, 0x6f, 0x74, 0x72, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, - 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x68, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, - 0x6f, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, - 0x6f, 0x6f, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, - 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x32, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x0d, 0x6c, 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x65, 0x6e, - 0x63, 0x6f, 0x64, 0x65, 0x64, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, - 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x65, - 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x61, 0x73, 0x50, 0x72, 0x69, 0x63, 0x65, - 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x6d, - 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x0b, 0x69, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xe5, - 0x01, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x45, 0x52, 0x12, 0x21, 0x0a, 0x0c, - 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, - 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, - 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, - 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, - 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, - 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, - 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, - 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x51, 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x4d, 0x61, - 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x1b, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, - 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x62, 0x0a, 0x0c, 0x42, 0x6f, 0x6f, - 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x42, 0x4f, 0x4f, - 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x42, 0x4f, 0x4f, 0x4b, - 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, - 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x2a, 0x8d, 0x01, - 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, - 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x54, 0x52, 0x59, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, 0x01, 0x12, 0x17, 0x0a, - 0x13, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, - 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, - 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, - 0x10, 0x03, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x45, 0x52, 0x10, 0x04, 0x42, 0x38, 0x5a, - 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, - 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, - 0x6d, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x64, 0x61, 0x74, - 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x22, 0x58, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, + 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, + 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x69, 0x0a, 0x08, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x45, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x26, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x45, + 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xf8, 0x02, 0x0a, 0x07, 0x4c, 0x32, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, + 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x64, + 0x65, 0x6c, 0x74, 0x61, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, 0x69, 0x6e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x31, 0x5f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x11, + 0x6c, 0x31, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x6c, 0x31, 0x49, 0x6e, 0x66, 0x6f, 0x74, + 0x72, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x67, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, + 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, + 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, + 0x65, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6c, 0x32, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x12, 0x43, 0x0a, + 0x1e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, + 0x72, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, + 0x47, 0x61, 0x73, 0x50, 0x72, 0x69, 0x63, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, + 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, + 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x69, 0x6d, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xe5, 0x01, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x47, 0x45, 0x52, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, + 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, + 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, + 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, + 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, + 0x72, 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x51, + 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, + 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x2a, 0x62, 0x0a, 0x0c, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x17, 0x0a, 0x13, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x4f, 0x4f, + 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, + 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x2a, 0xad, 0x01, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, + 0x54, 0x43, 0x48, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x45, + 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, 0x4f, + 0x43, 0x4b, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, + 0x12, 0x18, 0x0a, 0x14, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, + 0x41, 0x54, 0x43, 0x48, 0x5f, 0x45, 0x4e, 0x44, 0x10, 0x04, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, + 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, + 0x47, 0x45, 0x52, 0x10, 0x05, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, + 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -665,15 +720,16 @@ func file_datastream_proto_rawDescGZIP() []byte { } var file_datastream_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_datastream_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_datastream_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_datastream_proto_goTypes = []interface{}{ (BookmarkType)(0), // 0: datastream.v1.BookmarkType (EntryType)(0), // 1: datastream.v1.EntryType - (*Batch)(nil), // 2: datastream.v1.Batch - (*L2Block)(nil), // 3: datastream.v1.L2Block - (*Transaction)(nil), // 4: datastream.v1.Transaction - (*UpdateGER)(nil), // 5: datastream.v1.UpdateGER - (*BookMark)(nil), // 6: datastream.v1.BookMark + (*BatchStart)(nil), // 2: datastream.v1.BatchStart + (*BatchEnd)(nil), // 3: datastream.v1.BatchEnd + (*L2Block)(nil), // 4: datastream.v1.L2Block + (*Transaction)(nil), // 5: datastream.v1.Transaction + (*UpdateGER)(nil), // 6: datastream.v1.UpdateGER + (*BookMark)(nil), // 7: datastream.v1.BookMark } var file_datastream_proto_depIdxs = []int32{ 0, // 0: datastream.v1.BookMark.type:type_name -> datastream.v1.BookmarkType @@ -691,7 +747,7 @@ func file_datastream_proto_init() { } if !protoimpl.UnsafeEnabled { file_datastream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Batch); i { + switch v := v.(*BatchStart); i { case 0: return &v.state case 1: @@ -703,7 +759,7 @@ func file_datastream_proto_init() { } } file_datastream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*L2Block); i { + switch v := v.(*BatchEnd); i { case 0: return &v.state case 1: @@ -715,7 +771,7 @@ func file_datastream_proto_init() { } } file_datastream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Transaction); i { + switch v := v.(*L2Block); i { case 0: return &v.state case 1: @@ -727,7 +783,7 @@ func file_datastream_proto_init() { } } file_datastream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateGER); i { + switch v := v.(*Transaction); i { case 0: return &v.state case 1: @@ -739,6 +795,18 @@ func file_datastream_proto_init() { } } file_datastream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateGER); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_datastream_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BookMark); i { case 0: return &v.state @@ -757,7 +825,7 @@ func file_datastream_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datastream_proto_rawDesc, NumEnums: 2, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go index bb84aeebf3..97a5eab879 100644 --- a/tools/datastreamer/main.go +++ b/tools/datastreamer/main.go @@ -757,27 +757,40 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.GlobalExitRoot))) printColored(color.FgGreen, "Coinbase........: ") printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToAddress(l2Block.Coinbase))) - case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH): - batch := &datastream.Batch{} + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START): + batch := &datastream.BatchStart{} err := proto.Unmarshal(entry.Data, batch) if err != nil { log.Error(err) os.Exit(1) } printColored(color.FgGreen, "Entry Type......: ") - printColored(color.FgHiYellow, "Batch\n") + printColored(color.FgHiYellow, "Batch Start\n") printColored(color.FgGreen, "Entry Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) printColored(color.FgGreen, "Batch Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.Number)) - printColored(color.FgGreen, "State Root......: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.StateRoot))) - printColored(color.FgGreen, "Local Exit Root.: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.LocalExitRoot))) printColored(color.FgGreen, "Fork ID.........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ForkId)) printColored(color.FgGreen, "Chain ID........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ChainId)) + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END): + batch := &datastream.BatchEnd{} + err := proto.Unmarshal(entry.Data, batch) + if err != nil { + log.Error(err) + os.Exit(1) + } + printColored(color.FgGreen, "Entry Type......: ") + printColored(color.FgHiYellow, "Batch End\n") + printColored(color.FgGreen, "Entry Number....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) + printColored(color.FgGreen, "Batch Number....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.Number)) + printColored(color.FgGreen, "State Root......: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.StateRoot))) + printColored(color.FgGreen, "Local Exit Root.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.LocalExitRoot))) case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION): dsTx := &datastream.Transaction{} err := proto.Unmarshal(entry.Data, dsTx) From 517ec2b0a550d688ab113a0999d033c39c2246b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Fri, 3 May 2024 13:02:11 +0200 Subject: [PATCH 03/23] fix genesis DS (#3615) --- state/datastream.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/state/datastream.go b/state/datastream.go index 3ad11f3f75..08c071feba 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -119,6 +119,22 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre return err } + genesisBatchStart := &datastream.BatchStart{ + Number: genesisL2Block.BatchNumber, + ForkId: genesisL2Block.ForkID, + ChainId: chainID, + } + + marshalledGenesisBatchStart, err := proto.Marshal(genesisBatchStart) + if err != nil { + return err + } + + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START), marshalledGenesisBatchStart) + if err != nil { + return err + } + bookMark = &datastream.BookMark{ Type: datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK, Value: genesisL2Block.L2BlockNumber, @@ -157,22 +173,6 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre return err } - genesisBatchStart := &datastream.BatchStart{ - Number: genesisL2Block.BatchNumber, - ForkId: genesisL2Block.ForkID, - ChainId: chainID, - } - - marshalledGenesisBatchStart, err := proto.Marshal(genesisBatchStart) - if err != nil { - return err - } - - _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START), marshalledGenesisBatchStart) - if err != nil { - return err - } - genesisBatchEnd := &datastream.BatchEnd{ Number: genesisL2Block.BatchNumber, LocalExitRoot: common.Hash{}.Bytes(), From 023549c1d8c56307c9395ed9a06a66136752a123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Fri, 3 May 2024 15:55:30 +0200 Subject: [PATCH 04/23] Fix DSSendL2Block batch number (#3617) * Fix DSSendL2Block batch number --- sequencer/l2block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sequencer/l2block.go b/sequencer/l2block.go index b2b9cd9922..7a2af42cda 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -494,7 +494,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { log.Infof("[ds-debug] 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(), l2Block.timestamp) + err = f.DSSendL2Block(l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) From 43f7ed96fbe128045a61c1074ceedbf8421f0f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Mon, 6 May 2024 17:53:30 +0200 Subject: [PATCH 05/23] latest proto (#3620) --- .../src/proto/datastream/v1/datastream.proto | 32 +- sequencer/batch.go | 2 +- sequencer/datastreamer.go | 26 +- state/datastream.go | 28 +- state/datastream/datastream.pb.go | 445 +++++++++++++----- state/pgstatestorage/datastream.go | 11 +- tools/datastreamer/main.go | 45 +- 7 files changed, 449 insertions(+), 140 deletions(-) diff --git a/proto/src/proto/datastream/v1/datastream.proto b/proto/src/proto/datastream/v1/datastream.proto index 555bc17733..9cdd0266c1 100644 --- a/proto/src/proto/datastream/v1/datastream.proto +++ b/proto/src/proto/datastream/v1/datastream.proto @@ -6,14 +6,17 @@ option go_package = "github.com/0xPolygonHermez/zkevm-node/state/datastream"; message BatchStart { uint64 number = 1; - uint64 fork_id = 4; - uint64 chain_id = 5; + BatchType type = 2; + uint64 fork_id = 3; + uint64 chain_id = 4; + Debug debug = 5; } message BatchEnd { uint64 number = 1; bytes local_exit_root = 2; bytes state_root = 3; + Debug debug = 4; } message L2Block { @@ -28,14 +31,19 @@ message L2Block { bytes state_root = 9; bytes global_exit_root = 10; bytes coinbase = 11; + uint64 block_gas_limit = 12; + bytes block_info_root = 13; + Debug debug = 14; } message Transaction { uint64 l2block_number = 1; - bool is_valid = 2; - bytes encoded = 3; - uint32 effective_gas_price_percentage = 4; - bytes im_state_root = 5; + uint64 index = 2; + bool is_valid = 3; + bytes encoded = 4; + uint32 effective_gas_price_percentage = 5; + bytes im_state_root = 6; + Debug debug = 7; } message UpdateGER { @@ -46,6 +54,7 @@ message UpdateGER { uint64 fork_id = 5; uint64 chain_id = 6; bytes state_root = 7; + Debug debug = 8; } message BookMark { @@ -53,6 +62,10 @@ message BookMark { uint64 value = 2; } +message Debug { + string message = 1; +} + enum BookmarkType { BOOKMARK_TYPE_UNSPECIFIED = 0; BOOKMARK_TYPE_BATCH = 1; @@ -67,3 +80,10 @@ enum EntryType { ENTRY_TYPE_BATCH_END = 4; ENTRY_TYPE_UPDATE_GER = 5; } + +enum BatchType { + BATCH_TYPE_UNSPECIFIED = 0; + BATCH_TYPE_REGULAR = 1; + BATCH_TYPE_FORCED = 2; + BATCH_TYPE_INJECTED = 3; +} diff --git a/sequencer/batch.go b/sequencer/batch.go index cc2bea283a..79d84026dd 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -340,7 +340,7 @@ func (f *finalizer) insertSIPBatch(ctx context.Context, batchNumber uint64, stat // Send batch bookmark to the datastream f.DSSendBatchBookmark(batchNumber) // Send batch start to the datastream - f.DSSendBatchStart(batchNumber) + f.DSSendBatchStart(batchNumber, false) // Check if synchronizer is up-to-date //TODO: review if this is needed diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 8178593978..4c08d6b3e4 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -24,11 +24,12 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce ForkID: forkID, BlockHash: blockResponse.BlockHash, StateRoot: blockResponse.BlockHash, //From etrog, the blockhash is the block root + BlockInfoRoot: blockResponse.BlockInfoRoot, } l2Transactions := []state.DSL2Transaction{} - for _, txResponse := range blockResponse.TransactionResponses { + for i, txResponse := range blockResponse.TransactionResponses { binaryTxData, err := txResponse.Tx.MarshalBinary() if err != nil { return err @@ -37,12 +38,17 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce l2Transaction := state.DSL2Transaction{ L2BlockNumber: blockResponse.BlockNumber, EffectiveGasPricePercentage: uint8(txResponse.EffectivePercentage), + Index: uint64(i), IsValid: 1, EncodedLength: uint32(len(binaryTxData)), Encoded: binaryTxData, StateRoot: txResponse.StateRoot, } + if txResponse.Logs != nil && len(txResponse.Logs) > 0 { + l2Transaction.Index = uint64(txResponse.Logs[0].TxIndex) + } + l2Transactions = append(l2Transactions, l2Transaction) } @@ -67,15 +73,23 @@ func (f *finalizer) DSSendBatchBookmark(batchNumber uint64) { } } -func (f *finalizer) DSSendBatchStart(batchNumber uint64) { +func (f *finalizer) DSSendBatchStart(batchNumber uint64, isForced bool) { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) + batchStart := datastream.BatchStart{ + Number: batchNumber, + ForkId: forkID, + } + + if isForced { + batchStart.Type = datastream.BatchType_BATCH_TYPE_FORCED + } else { + batchStart.Type = datastream.BatchType_BATCH_TYPE_REGULAR + } + if f.streamServer != nil { // Send batch start to the streamer - f.dataToStream <- datastream.BatchStart{ - Number: batchNumber, - ForkId: forkID, - } + f.dataToStream <- batchStart } } diff --git a/state/datastream.go b/state/datastream.go index 08c071feba..90c7ff3211 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -58,16 +58,19 @@ type DSL2Block struct { ChainID uint64 BlockHash common.Hash StateRoot common.Hash + BlockGasLimit uint64 + BlockInfoRoot common.Hash } // DSL2Transaction represents a data stream L2 transaction type DSL2Transaction struct { - L2BlockNumber uint64 // Not included in the encoded data - ImStateRoot common.Hash // Not included in the encoded data - EffectiveGasPricePercentage uint8 // 1 byte - IsValid uint8 // 1 byte - StateRoot common.Hash // 32 bytes - EncodedLength uint32 // 4 bytes + L2BlockNumber uint64 + ImStateRoot common.Hash + EffectiveGasPricePercentage uint8 + IsValid uint8 + Index uint64 + StateRoot common.Hash + EncodedLength uint32 Encoded []byte } @@ -121,6 +124,7 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre genesisBatchStart := &datastream.BatchStart{ Number: genesisL2Block.BatchNumber, + Type: datastream.BatchType_BATCH_TYPE_UNSPECIFIED, ForkId: genesisL2Block.ForkID, ChainId: chainID, } @@ -390,10 +394,19 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre batchStart := &datastream.BatchStart{ Number: batch.BatchNumber, + Type: datastream.BatchType_BATCH_TYPE_REGULAR, ForkId: batch.ForkID, ChainId: chainID, } + if batch.ForkID >= FORKID_ETROG && (batch.BatchNumber == 1 || (upgradeEtrogBatchNumber != 0 && batch.BatchNumber == upgradeEtrogBatchNumber)) { + batchStart.Type = datastream.BatchType_BATCH_TYPE_INJECTED + } + + if batch.ForcedBatchNum != nil { + batchStart.Type = datastream.BatchType_BATCH_TYPE_FORCED + } + marshalledBatchStart, err := proto.Marshal(batchStart) if err != nil { return err @@ -495,6 +508,8 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre StateRoot: l2Block.StateRoot.Bytes(), GlobalExitRoot: l2Block.GlobalExitRoot.Bytes(), Coinbase: l2Block.Coinbase.Bytes(), + BlockInfoRoot: l2Block.BlockInfoRoot.Bytes(), + BlockGasLimit: l2Block.BlockGasLimit, } if l2Block.ForkID >= FORKID_ETROG { @@ -560,6 +575,7 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre transaction := &datastream.Transaction{ L2BlockNumber: tx.L2BlockNumber, + Index: tx.Index, IsValid: tx.IsValid != 0, Encoded: tx.Encoded, EffectiveGasPricePercentage: uint32(tx.EffectiveGasPricePercentage), diff --git a/state/datastream/datastream.pb.go b/state/datastream/datastream.pb.go index 07a8ff7adf..02a0e2267f 100644 --- a/state/datastream/datastream.pb.go +++ b/state/datastream/datastream.pb.go @@ -127,14 +127,68 @@ func (EntryType) EnumDescriptor() ([]byte, []int) { return file_datastream_proto_rawDescGZIP(), []int{1} } +type BatchType int32 + +const ( + BatchType_BATCH_TYPE_UNSPECIFIED BatchType = 0 + BatchType_BATCH_TYPE_REGULAR BatchType = 1 + BatchType_BATCH_TYPE_FORCED BatchType = 2 + BatchType_BATCH_TYPE_INJECTED BatchType = 3 +) + +// Enum value maps for BatchType. +var ( + BatchType_name = map[int32]string{ + 0: "BATCH_TYPE_UNSPECIFIED", + 1: "BATCH_TYPE_REGULAR", + 2: "BATCH_TYPE_FORCED", + 3: "BATCH_TYPE_INJECTED", + } + BatchType_value = map[string]int32{ + "BATCH_TYPE_UNSPECIFIED": 0, + "BATCH_TYPE_REGULAR": 1, + "BATCH_TYPE_FORCED": 2, + "BATCH_TYPE_INJECTED": 3, + } +) + +func (x BatchType) Enum() *BatchType { + p := new(BatchType) + *p = x + return p +} + +func (x BatchType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (BatchType) Descriptor() protoreflect.EnumDescriptor { + return file_datastream_proto_enumTypes[2].Descriptor() +} + +func (BatchType) Type() protoreflect.EnumType { + return &file_datastream_proto_enumTypes[2] +} + +func (x BatchType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use BatchType.Descriptor instead. +func (BatchType) EnumDescriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{2} +} + type BatchStart struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` - ForkId uint64 `protobuf:"varint,4,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` - ChainId uint64 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + Type BatchType `protobuf:"varint,2,opt,name=type,proto3,enum=datastream.v1.BatchType" json:"type,omitempty"` + ForkId uint64 `protobuf:"varint,3,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` + ChainId uint64 `protobuf:"varint,4,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Debug *Debug `protobuf:"bytes,5,opt,name=debug,proto3" json:"debug,omitempty"` } func (x *BatchStart) Reset() { @@ -176,6 +230,13 @@ func (x *BatchStart) GetNumber() uint64 { return 0 } +func (x *BatchStart) GetType() BatchType { + if x != nil { + return x.Type + } + return BatchType_BATCH_TYPE_UNSPECIFIED +} + func (x *BatchStart) GetForkId() uint64 { if x != nil { return x.ForkId @@ -190,6 +251,13 @@ func (x *BatchStart) GetChainId() uint64 { return 0 } +func (x *BatchStart) GetDebug() *Debug { + if x != nil { + return x.Debug + } + return nil +} + type BatchEnd struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -198,6 +266,7 @@ type BatchEnd struct { Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` LocalExitRoot []byte `protobuf:"bytes,2,opt,name=local_exit_root,json=localExitRoot,proto3" json:"local_exit_root,omitempty"` StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` + Debug *Debug `protobuf:"bytes,4,opt,name=debug,proto3" json:"debug,omitempty"` } func (x *BatchEnd) Reset() { @@ -253,6 +322,13 @@ func (x *BatchEnd) GetStateRoot() []byte { return nil } +func (x *BatchEnd) GetDebug() *Debug { + if x != nil { + return x.Debug + } + return nil +} + type L2Block struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -269,6 +345,9 @@ type L2Block struct { StateRoot []byte `protobuf:"bytes,9,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` GlobalExitRoot []byte `protobuf:"bytes,10,opt,name=global_exit_root,json=globalExitRoot,proto3" json:"global_exit_root,omitempty"` Coinbase []byte `protobuf:"bytes,11,opt,name=coinbase,proto3" json:"coinbase,omitempty"` + BlockGasLimit uint64 `protobuf:"varint,12,opt,name=block_gas_limit,json=blockGasLimit,proto3" json:"block_gas_limit,omitempty"` + BlockInfoRoot []byte `protobuf:"bytes,13,opt,name=block_info_root,json=blockInfoRoot,proto3" json:"block_info_root,omitempty"` + Debug *Debug `protobuf:"bytes,14,opt,name=debug,proto3" json:"debug,omitempty"` } func (x *L2Block) Reset() { @@ -380,16 +459,39 @@ func (x *L2Block) GetCoinbase() []byte { return nil } +func (x *L2Block) GetBlockGasLimit() uint64 { + if x != nil { + return x.BlockGasLimit + } + return 0 +} + +func (x *L2Block) GetBlockInfoRoot() []byte { + if x != nil { + return x.BlockInfoRoot + } + return nil +} + +func (x *L2Block) GetDebug() *Debug { + if x != nil { + return x.Debug + } + return nil +} + type Transaction struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields L2BlockNumber uint64 `protobuf:"varint,1,opt,name=l2block_number,json=l2blockNumber,proto3" json:"l2block_number,omitempty"` - IsValid bool `protobuf:"varint,2,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"` - Encoded []byte `protobuf:"bytes,3,opt,name=encoded,proto3" json:"encoded,omitempty"` - EffectiveGasPricePercentage uint32 `protobuf:"varint,4,opt,name=effective_gas_price_percentage,json=effectiveGasPricePercentage,proto3" json:"effective_gas_price_percentage,omitempty"` - ImStateRoot []byte `protobuf:"bytes,5,opt,name=im_state_root,json=imStateRoot,proto3" json:"im_state_root,omitempty"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + IsValid bool `protobuf:"varint,3,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"` + Encoded []byte `protobuf:"bytes,4,opt,name=encoded,proto3" json:"encoded,omitempty"` + EffectiveGasPricePercentage uint32 `protobuf:"varint,5,opt,name=effective_gas_price_percentage,json=effectiveGasPricePercentage,proto3" json:"effective_gas_price_percentage,omitempty"` + ImStateRoot []byte `protobuf:"bytes,6,opt,name=im_state_root,json=imStateRoot,proto3" json:"im_state_root,omitempty"` + Debug *Debug `protobuf:"bytes,7,opt,name=debug,proto3" json:"debug,omitempty"` } func (x *Transaction) Reset() { @@ -431,6 +533,13 @@ func (x *Transaction) GetL2BlockNumber() uint64 { return 0 } +func (x *Transaction) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + func (x *Transaction) GetIsValid() bool { if x != nil { return x.IsValid @@ -459,6 +568,13 @@ func (x *Transaction) GetImStateRoot() []byte { return nil } +func (x *Transaction) GetDebug() *Debug { + if x != nil { + return x.Debug + } + return nil +} + type UpdateGER struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -471,6 +587,7 @@ type UpdateGER struct { ForkId uint64 `protobuf:"varint,5,opt,name=fork_id,json=forkId,proto3" json:"fork_id,omitempty"` ChainId uint64 `protobuf:"varint,6,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` StateRoot []byte `protobuf:"bytes,7,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` + Debug *Debug `protobuf:"bytes,8,opt,name=debug,proto3" json:"debug,omitempty"` } func (x *UpdateGER) Reset() { @@ -554,6 +671,13 @@ func (x *UpdateGER) GetStateRoot() []byte { return nil } +func (x *UpdateGER) GetDebug() *Debug { + if x != nil { + return x.Debug + } + return nil +} + type BookMark struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -609,102 +733,181 @@ func (x *BookMark) GetValue() uint64 { return 0 } +type Debug struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Debug) Reset() { + *x = Debug{} + if protoimpl.UnsafeEnabled { + mi := &file_datastream_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Debug) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Debug) ProtoMessage() {} + +func (x *Debug) ProtoReflect() protoreflect.Message { + mi := &file_datastream_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Debug.ProtoReflect.Descriptor instead. +func (*Debug) Descriptor() ([]byte, []int) { + return file_datastream_proto_rawDescGZIP(), []int{6} +} + +func (x *Debug) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_datastream_proto protoreflect.FileDescriptor var file_datastream_proto_rawDesc = []byte{ 0x0a, 0x10, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, - 0x31, 0x22, 0x58, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, - 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, - 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x69, 0x0a, 0x08, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x45, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, - 0x26, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, - 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x45, - 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xf8, 0x02, 0x0a, 0x07, 0x4c, 0x32, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, - 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x31, 0x22, 0xb2, 0x01, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x72, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x12, + 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x05, 0x64, 0x65, + 0x62, 0x75, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x61, 0x74, 0x61, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, + 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x22, 0x95, 0x01, 0x0a, 0x08, 0x42, 0x61, 0x74, 0x63, 0x68, + 0x45, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x6c, + 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, + 0x6f, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x22, 0xf4, + 0x03, 0x0a, 0x07, 0x4c, 0x32, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x64, 0x65, + 0x6c, 0x74, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, 0x0a, 0x0d, + 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x31, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, + 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x31, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x74, + 0x72, 0x65, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0f, 0x6c, 0x31, 0x49, 0x6e, 0x66, 0x6f, 0x74, 0x72, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x68, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, + 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, + 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, + 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x64, 0x65, 0x62, + 0x75, 0x67, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x05, + 0x64, 0x65, 0x62, 0x75, 0x67, 0x22, 0x94, 0x02, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6c, + 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, + 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x66, 0x66, 0x65, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x5f, 0x70, + 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x1b, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x47, 0x61, 0x73, 0x50, 0x72, 0x69, + 0x63, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0d, + 0x69, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x69, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, + 0x12, 0x2a, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x22, 0x91, 0x02, 0x0a, + 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x45, 0x52, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, + 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x64, - 0x65, 0x6c, 0x74, 0x61, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, 0x69, 0x6e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x31, 0x5f, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x11, - 0x6c, 0x31, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x6c, 0x31, 0x49, 0x6e, 0x66, 0x6f, 0x74, - 0x72, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x67, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, - 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, - 0x65, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6c, 0x32, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6c, 0x32, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x12, 0x43, 0x0a, - 0x1e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, - 0x72, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x1b, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, - 0x47, 0x61, 0x73, 0x50, 0x72, 0x69, 0x63, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, - 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, - 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x69, 0x6d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xe5, 0x01, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x45, 0x52, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, - 0x68, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, - 0x65, 0x78, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x78, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, - 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, - 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, - 0x72, 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x51, - 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, - 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x2a, 0x62, 0x0a, 0x0c, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x17, 0x0a, 0x13, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x4f, 0x4f, - 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, - 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x2a, 0xad, 0x01, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, - 0x54, 0x43, 0x48, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x45, - 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x32, 0x5f, 0x42, 0x4c, 0x4f, - 0x43, 0x4b, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, - 0x12, 0x18, 0x0a, 0x14, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, - 0x41, 0x54, 0x43, 0x48, 0x5f, 0x45, 0x4e, 0x44, 0x10, 0x04, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, - 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, - 0x47, 0x45, 0x52, 0x10, 0x05, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, - 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, + 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, + 0x6f, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, + 0x22, 0x51, 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x4d, 0x61, 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x64, 0x61, 0x74, + 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, + 0x61, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x22, 0x21, 0x0a, 0x05, 0x44, 0x65, 0x62, 0x75, 0x67, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x62, 0x0a, 0x0c, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, + 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, + 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, + 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x10, 0x01, 0x12, 0x1a, + 0x0a, 0x16, 0x42, 0x4f, 0x4f, 0x4b, 0x4d, 0x41, 0x52, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x4c, 0x32, 0x5f, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x2a, 0xad, 0x01, 0x0a, 0x09, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, + 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x01, + 0x12, 0x17, 0x0a, 0x13, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, + 0x32, 0x5f, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x54, + 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x41, 0x43, 0x54, + 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x12, 0x18, 0x0a, 0x14, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x45, 0x4e, 0x44, 0x10, 0x04, 0x12, + 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x50, + 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x45, 0x52, 0x10, 0x05, 0x2a, 0x6f, 0x0a, 0x09, 0x42, 0x61, + 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x41, 0x54, 0x43, 0x48, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x42, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x52, 0x45, 0x47, 0x55, 0x4c, 0x41, 0x52, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x42, + 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x44, + 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x42, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x49, 0x4e, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x42, 0x38, 0x5a, 0x36, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, + 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, + 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -719,25 +922,33 @@ func file_datastream_proto_rawDescGZIP() []byte { return file_datastream_proto_rawDescData } -var file_datastream_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_datastream_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_datastream_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_datastream_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_datastream_proto_goTypes = []interface{}{ (BookmarkType)(0), // 0: datastream.v1.BookmarkType (EntryType)(0), // 1: datastream.v1.EntryType - (*BatchStart)(nil), // 2: datastream.v1.BatchStart - (*BatchEnd)(nil), // 3: datastream.v1.BatchEnd - (*L2Block)(nil), // 4: datastream.v1.L2Block - (*Transaction)(nil), // 5: datastream.v1.Transaction - (*UpdateGER)(nil), // 6: datastream.v1.UpdateGER - (*BookMark)(nil), // 7: datastream.v1.BookMark + (BatchType)(0), // 2: datastream.v1.BatchType + (*BatchStart)(nil), // 3: datastream.v1.BatchStart + (*BatchEnd)(nil), // 4: datastream.v1.BatchEnd + (*L2Block)(nil), // 5: datastream.v1.L2Block + (*Transaction)(nil), // 6: datastream.v1.Transaction + (*UpdateGER)(nil), // 7: datastream.v1.UpdateGER + (*BookMark)(nil), // 8: datastream.v1.BookMark + (*Debug)(nil), // 9: datastream.v1.Debug } var file_datastream_proto_depIdxs = []int32{ - 0, // 0: datastream.v1.BookMark.type:type_name -> datastream.v1.BookmarkType - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 0: datastream.v1.BatchStart.type:type_name -> datastream.v1.BatchType + 9, // 1: datastream.v1.BatchStart.debug:type_name -> datastream.v1.Debug + 9, // 2: datastream.v1.BatchEnd.debug:type_name -> datastream.v1.Debug + 9, // 3: datastream.v1.L2Block.debug:type_name -> datastream.v1.Debug + 9, // 4: datastream.v1.Transaction.debug:type_name -> datastream.v1.Debug + 9, // 5: datastream.v1.UpdateGER.debug:type_name -> datastream.v1.Debug + 0, // 6: datastream.v1.BookMark.type:type_name -> datastream.v1.BookmarkType + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_datastream_proto_init() } @@ -818,14 +1029,26 @@ func file_datastream_proto_init() { return nil } } + file_datastream_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Debug); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datastream_proto_rawDesc, - NumEnums: 2, - NumMessages: 6, + NumEnums: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/state/pgstatestorage/datastream.go b/state/pgstatestorage/datastream.go index 31c9814c0a..a7e99e6528 100644 --- a/state/pgstatestorage/datastream.go +++ b/state/pgstatestorage/datastream.go @@ -11,7 +11,7 @@ import ( // GetDSGenesisBlock returns the genesis block func (p *PostgresStorage) GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*state.DSL2Block, error) { - const genesisL2BlockSQL = `SELECT 0 as batch_num, l2b.block_num, l2b.received_at, '0x0000000000000000000000000000000000000000' as global_exit_root, '0x0000000000000000000000000000000000000000' as block_global_exit_root, l2b.header->>'miner' AS coinbase, 0 as fork_id, l2b.block_hash, l2b.state_root + const genesisL2BlockSQL = `SELECT 0 as batch_num, l2b.block_num, l2b.received_at, '0x0000000000000000000000000000000000000000' as global_exit_root, '0x0000000000000000000000000000000000000000' as block_global_exit_root, l2b.header->>'miner' AS coinbase, 0 as fork_id, l2b.block_hash, l2b.state_root, '0x0000000000000000000000000000000000000000' as block_info_root FROM state.l2block l2b WHERE l2b.block_num = 0` @@ -29,7 +29,7 @@ func (p *PostgresStorage) GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (* // GetDSL2Blocks returns the L2 blocks func (p *PostgresStorage) GetDSL2Blocks(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, dbTx pgx.Tx) ([]*state.DSL2Block, error) { - const l2BlockSQL = `SELECT l2b.batch_num, l2b.block_num, l2b.received_at, b.global_exit_root, COALESCE(l2b.header->>'globalExitRoot', '') AS block_global_exit_root, l2b.header->>'miner' AS coinbase, f.fork_id, l2b.block_hash, l2b.state_root + const l2BlockSQL = `SELECT l2b.batch_num, l2b.block_num, l2b.received_at, b.global_exit_root, COALESCE(l2b.header->>'globalExitRoot', '') AS block_global_exit_root, l2b.header->>'miner' AS coinbase, f.fork_id, l2b.block_hash, l2b.state_root, COALESCE(l2b.header->>'blockInfoRoot', '') AS block_info_root FROM state.l2block l2b, state.batch b, state.fork_id f WHERE l2b.batch_num BETWEEN $1 AND $2 AND l2b.batch_num = b.batch_num AND l2b.batch_num between f.from_batch_num AND f.to_batch_num ORDER BY l2b.block_num ASC` @@ -62,6 +62,7 @@ func scanL2Block(row pgx.Row) (*state.DSL2Block, error) { timestamp time.Time blockHashStr string stateRootStr string + blockInfoStr string ) if err := row.Scan( &l2Block.BatchNumber, @@ -73,6 +74,7 @@ func scanL2Block(row pgx.Row) (*state.DSL2Block, error) { &l2Block.ForkID, &blockHashStr, &stateRootStr, + &blockInfoStr, ); err != nil { return &l2Block, err } @@ -81,6 +83,7 @@ func scanL2Block(row pgx.Row) (*state.DSL2Block, error) { l2Block.Timestamp = uint64(timestamp.Unix()) l2Block.BlockHash = common.HexToHash(blockHashStr) l2Block.StateRoot = common.HexToHash(stateRootStr) + l2Block.BlockInfoRoot = common.HexToHash(blockInfoStr) if l2Block.ForkID >= state.FORKID_ETROG { l2Block.GlobalExitRoot = common.HexToHash(blockGERStr) @@ -91,7 +94,7 @@ func scanL2Block(row pgx.Row) (*state.DSL2Block, error) { // GetDSL2Transactions returns the L2 transactions func (p *PostgresStorage) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error) { - const l2TxSQL = `SELECT l2_block_num, t.effective_percentage, t.encoded, r.post_state, r.im_state_root + const l2TxSQL = `SELECT l2_block_num, t.effective_percentage, t.encoded, r.post_state, r.im_state_root, r.tx_index FROM state.transaction t, state.receipt r WHERE l2_block_num BETWEEN $1 AND $2 AND r.tx_hash = t.hash ORDER BY t.l2_block_num ASC, r.tx_index ASC` @@ -121,12 +124,14 @@ func scanDSL2Transaction(row pgx.Row) (*state.DSL2Transaction, error) { encoded := []byte{} postState := []byte{} imStateRoot := []byte{} + if err := row.Scan( &l2Transaction.L2BlockNumber, &l2Transaction.EffectiveGasPricePercentage, &encoded, &postState, &imStateRoot, + &l2Transaction.Index, ); err != nil { return nil, err } diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go index 97a5eab879..a2e3d19003 100644 --- a/tools/datastreamer/main.go +++ b/tools/datastreamer/main.go @@ -700,12 +700,6 @@ func decodeBatchOffline(cliCtx *cli.Context) error { } func printEntry(entry datastreamer.FileEntry) { - var bookmarkTypeDesc = map[datastream.BookmarkType]string{ - datastream.BookmarkType_BOOKMARK_TYPE_UNSPECIFIED: "Unspecified", - datastream.BookmarkType_BOOKMARK_TYPE_BATCH: "Batch Number", - datastream.BookmarkType_BOOKMARK_TYPE_L2_BLOCK: "L2 Block Number", - } - switch entry.Type { case state.EntryTypeBookMark: bookmark := &datastream.BookMark{} @@ -720,7 +714,7 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgGreen, "Entry Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) printColored(color.FgGreen, "Type............: ") - printColored(color.FgHiWhite, fmt.Sprintf("%d (%s)\n", bookmark.Type, bookmarkTypeDesc[bookmark.Type])) + printColored(color.FgHiWhite, fmt.Sprintf("%d (%s)\n", bookmark.Type, datastream.BookmarkType_name[int32(bookmark.Type)])) printColored(color.FgGreen, "Value...........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", bookmark.Value)) case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK): @@ -757,6 +751,16 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.GlobalExitRoot))) printColored(color.FgGreen, "Coinbase........: ") printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToAddress(l2Block.Coinbase))) + printColored(color.FgGreen, "Block Gas Limit.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", l2Block.BlockGasLimit)) + printColored(color.FgGreen, "Block Info Root.: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.BytesToHash(l2Block.BlockInfoRoot))) + + if l2Block.Debug != nil && l2Block.Debug.Message != "" { + printColored(color.FgGreen, "Debug...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", l2Block.Debug)) + } + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_START): batch := &datastream.BatchStart{} err := proto.Unmarshal(entry.Data, batch) @@ -770,10 +774,18 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) printColored(color.FgGreen, "Batch Number....: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.Number)) + printColored(color.FgGreen, "Batch Type......: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", datastream.BatchType_name[int32(batch.Type)])) printColored(color.FgGreen, "Fork ID.........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ForkId)) printColored(color.FgGreen, "Chain ID........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", batch.ChainId)) + + if batch.Debug != nil && batch.Debug.Message != "" { + printColored(color.FgGreen, "Debug...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", batch.Debug)) + } + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_BATCH_END): batch := &datastream.BatchEnd{} err := proto.Unmarshal(entry.Data, batch) @@ -791,6 +803,12 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.StateRoot))) printColored(color.FgGreen, "Local Exit Root.: ") printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batch.LocalExitRoot))) + + if batch.Debug != nil && batch.Debug.Message != "" { + printColored(color.FgGreen, "Debug...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", batch.Debug)) + } + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_TRANSACTION): dsTx := &datastream.Transaction{} err := proto.Unmarshal(entry.Data, dsTx) @@ -805,6 +823,8 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%d\n", entry.Number)) printColored(color.FgGreen, "L2 Block Number.: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", dsTx.L2BlockNumber)) + printColored(color.FgGreen, "Index...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%d\n", dsTx.Index)) printColored(color.FgGreen, "Is Valid........: ") printColored(color.FgHiWhite, fmt.Sprintf("%t\n", dsTx.IsValid)) printColored(color.FgGreen, "Data............: ") @@ -831,6 +851,12 @@ func printEntry(entry datastreamer.FileEntry) { nonce := tx.Nonce() printColored(color.FgGreen, "Nonce...........: ") printColored(color.FgHiWhite, fmt.Sprintf("%d\n", nonce)) + + if dsTx.Debug != nil && dsTx.Debug.Message != "" { + printColored(color.FgGreen, "Debug...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", dsTx.Debug)) + } + case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER): updateGer := &datastream.UpdateGER{} err := proto.Unmarshal(entry.Data, updateGer) @@ -857,6 +883,11 @@ func printEntry(entry datastreamer.FileEntry) { printColored(color.FgHiWhite, fmt.Sprintf("%d\n", updateGer.ChainId)) printColored(color.FgGreen, "State Root......: ") printColored(color.FgHiWhite, fmt.Sprint(common.Bytes2Hex(updateGer.StateRoot)+"\n")) + + if updateGer.Debug != nil && updateGer.Debug.Message != "" { + printColored(color.FgGreen, "Debug...........: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", updateGer.Debug)) + } } } From 0055aec6ec412f26c4f63cdb6b211c32dbae7ffe Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Mon, 6 May 2024 18:45:34 +0200 Subject: [PATCH 06/23] Fix DSSendBatchEnd (#3621) --- sequencer/batch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sequencer/batch.go b/sequencer/batch.go index 79d84026dd..c6e2700fa8 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -406,7 +406,7 @@ func (f *finalizer) closeSIPBatch(ctx context.Context, dbTx pgx.Tx) error { } // Sent batch to DS - f.DSSendBatchEnd(f.wipBatch.batchNumber, f.wipBatch.finalStateRoot, f.wipBatch.finalLocalExitRoot) + f.DSSendBatchEnd(f.sipBatch.batchNumber, f.sipBatch.finalStateRoot, f.sipBatch.finalLocalExitRoot) log.Infof("sip batch %d closed in statedb, closing reason: %s", f.sipBatch.batchNumber, f.sipBatch.closingReason) From c8655c2d7ac6f5e8150635d18da41584d2dbd570 Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Thu, 9 May 2024 14:18:10 -0300 Subject: [PATCH 07/23] add TxFeeCap config (#3611) --- config/config_test.go | 4 + config/default.go | 1 + docs/config-file/node-config-doc.html | 2 +- docs/config-file/node-config-doc.md | 44 ++++++--- docs/config-file/node-config-schema.json | 5 + pool/config.go | 4 + pool/pool.go | 22 +++++ pool/pool_test.go | 114 ++++++++++++++++++++++- 8 files changed, 180 insertions(+), 16 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 9acee0b98c..90c38eb206 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -306,6 +306,10 @@ func Test_Defaults(t *testing.T) { path: "Pool.GlobalQueue", expectedValue: uint64(1024), }, + { + path: "Pool.TxFeeCap", + expectedValue: float64(1), + }, { path: "Pool.EffectiveGasPrice.Enabled", expectedValue: false, diff --git a/config/default.go b/config/default.go index a0ff2e2941..c0abada7b7 100644 --- a/config/default.go +++ b/config/default.go @@ -44,6 +44,7 @@ MinAllowedGasPriceInterval = "5m" PollMinAllowedGasPriceInterval = "15s" AccountQueue = 64 GlobalQueue = 1024 +TxFeeCap = 1.0 [Pool.EffectiveGasPrice] Enabled = false L1GasPriceFactor = 0.25 diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 955862bf70..5666a3dc16 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -10,7 +10,7 @@
"300ms"
 

Default: "15s"Type: string

PollMinAllowedGasPriceInterval is the interval to poll the suggested min gas price for a tx


Examples:

"1m"
 
"300ms"
-

Default: 64Type: integer

AccountQueue represents the maximum number of non-executable transaction slots permitted per account


Default: 1024Type: integer

GlobalQueue represents the maximum number of non-executable transaction slots for all accounts


EffectiveGasPrice is the config for the effective gas price calculation
Default: falseType: boolean

Enabled is a flag to enable/disable the effective gas price


Default: 0.25Type: number

L1GasPriceFactor is the percentage of the L1 gas price that will be used as the L2 min gas price


Default: 16Type: integer

ByteGasCost is the gas cost per byte that is not 0


Default: 4Type: integer

ZeroByteGasCost is the gas cost per byte that is 0


Default: 1Type: number

NetProfit is the profit margin to apply to the calculated breakEvenGasPrice


Default: 1.1Type: number

BreakEvenFactor is the factor to apply to the calculated breakevenGasPrice when comparing it with the gasPriceSigned of a tx


Default: 10Type: integer

FinalDeviationPct is the max allowed deviation percentage BreakEvenGasPrice on re-calculation


Default: 0Type: integer

EthTransferGasPrice is the fixed gas price returned as effective gas price for txs tha are ETH transfers (0 means disabled)
Only one of EthTransferGasPrice or EthTransferL1GasPriceFactor params can be different than 0. If both params are set to 0, the sequencer will halt and log an error


Default: 0Type: number

EthTransferL1GasPriceFactor is the percentage of L1 gas price returned as effective gas price for txs tha are ETH transfers (0 means disabled)
Only one of EthTransferGasPrice or EthTransferL1GasPriceFactor params can be different than 0. If both params are set to 0, the sequencer will halt and log an error


Default: 0.5Type: number

L2GasPriceSuggesterFactor is the factor to apply to L1 gas price to get the suggested L2 gas price used in the
calculations when the effective gas price is disabled (testing/metrics purposes)


Default: 0Type: integer

ForkID is the current fork ID of the chain


Configuration for RPC service. THis one offers a extended Ethereum JSON-RPC API interface to interact with the node
Default: "0.0.0.0"Type: string

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


Default: 8545Type: integer

Port defines the port to serve the endpoints via HTTP


Default: "1m0s"Type: string

ReadTimeout is the HTTP server read timeout
check net/http.server.ReadTimeout and net/http.server.ReadHeaderTimeout


Examples:

"1m"
+

Default: 64Type: integer

AccountQueue represents the maximum number of non-executable transaction slots permitted per account


Default: 1024Type: integer

GlobalQueue represents the maximum number of non-executable transaction slots for all accounts


EffectiveGasPrice is the config for the effective gas price calculation
Default: falseType: boolean

Enabled is a flag to enable/disable the effective gas price


Default: 0.25Type: number

L1GasPriceFactor is the percentage of the L1 gas price that will be used as the L2 min gas price


Default: 16Type: integer

ByteGasCost is the gas cost per byte that is not 0


Default: 4Type: integer

ZeroByteGasCost is the gas cost per byte that is 0


Default: 1Type: number

NetProfit is the profit margin to apply to the calculated breakEvenGasPrice


Default: 1.1Type: number

BreakEvenFactor is the factor to apply to the calculated breakevenGasPrice when comparing it with the gasPriceSigned of a tx


Default: 10Type: integer

FinalDeviationPct is the max allowed deviation percentage BreakEvenGasPrice on re-calculation


Default: 0Type: integer

EthTransferGasPrice is the fixed gas price returned as effective gas price for txs tha are ETH transfers (0 means disabled)
Only one of EthTransferGasPrice or EthTransferL1GasPriceFactor params can be different than 0. If both params are set to 0, the sequencer will halt and log an error


Default: 0Type: number

EthTransferL1GasPriceFactor is the percentage of L1 gas price returned as effective gas price for txs tha are ETH transfers (0 means disabled)
Only one of EthTransferGasPrice or EthTransferL1GasPriceFactor params can be different than 0. If both params are set to 0, the sequencer will halt and log an error


Default: 0.5Type: number

L2GasPriceSuggesterFactor is the factor to apply to L1 gas price to get the suggested L2 gas price used in the
calculations when the effective gas price is disabled (testing/metrics purposes)


Default: 0Type: integer

ForkID is the current fork ID of the chain


Default: 1Type: number

TxFeeCap is the global transaction fee(price * gaslimit) cap for
send-transaction variants. The unit is ether. 0 means no cap.


Configuration for RPC service. THis one offers a extended Ethereum JSON-RPC API interface to interact with the node
Default: "0.0.0.0"Type: string

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


Default: 8545Type: integer

Port defines the port to serve the endpoints via HTTP


Default: "1m0s"Type: string

ReadTimeout is the HTTP server read timeout
check net/http.server.ReadTimeout and net/http.server.ReadHeaderTimeout


Examples:

"1m"
 
"300ms"
 

Default: "1m0s"Type: string

WriteTimeout is the HTTP server write timeout
check net/http.server.WriteTimeout


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 94765fcf6c..e69b0337d5 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -412,20 +412,21 @@ MaxGasPriceLimit=0
 **Type:** : `object`
 **Description:** Pool service configuration
 
-| Property                                                                        | Pattern | Type    | Deprecated | Definition | Title/Description                                                                                    |
-| ------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------- |
-| - [IntervalToRefreshBlockedAddresses](#Pool_IntervalToRefreshBlockedAddresses ) | No      | string  | No         | -          | Duration                                                                                             |
-| - [IntervalToRefreshGasPrices](#Pool_IntervalToRefreshGasPrices )               | No      | string  | No         | -          | Duration                                                                                             |
-| - [MaxTxBytesSize](#Pool_MaxTxBytesSize )                                       | No      | integer | No         | -          | MaxTxBytesSize is the max size of a transaction in bytes                                             |
-| - [MaxTxDataBytesSize](#Pool_MaxTxDataBytesSize )                               | No      | integer | No         | -          | MaxTxDataBytesSize is the max size of the data field of a transaction in bytes                       |
-| - [DB](#Pool_DB )                                                               | No      | object  | No         | -          | DB is the database configuration                                                                     |
-| - [DefaultMinGasPriceAllowed](#Pool_DefaultMinGasPriceAllowed )                 | No      | integer | No         | -          | DefaultMinGasPriceAllowed is the default min gas price to suggest                                    |
-| - [MinAllowedGasPriceInterval](#Pool_MinAllowedGasPriceInterval )               | No      | string  | No         | -          | Duration                                                                                             |
-| - [PollMinAllowedGasPriceInterval](#Pool_PollMinAllowedGasPriceInterval )       | No      | string  | No         | -          | Duration                                                                                             |
-| - [AccountQueue](#Pool_AccountQueue )                                           | No      | integer | No         | -          | AccountQueue represents the maximum number of non-executable transaction slots permitted per account |
-| - [GlobalQueue](#Pool_GlobalQueue )                                             | No      | integer | No         | -          | GlobalQueue represents the maximum number of non-executable transaction slots for all accounts       |
-| - [EffectiveGasPrice](#Pool_EffectiveGasPrice )                                 | No      | object  | No         | -          | EffectiveGasPrice is the config for the effective gas price calculation                              |
-| - [ForkID](#Pool_ForkID )                                                       | No      | integer | No         | -          | ForkID is the current fork ID of the chain                                                           |
+| Property                                                                        | Pattern | Type    | Deprecated | Definition | Title/Description                                                                                                                   |
+| ------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |
+| - [IntervalToRefreshBlockedAddresses](#Pool_IntervalToRefreshBlockedAddresses ) | No      | string  | No         | -          | Duration                                                                                                                            |
+| - [IntervalToRefreshGasPrices](#Pool_IntervalToRefreshGasPrices )               | No      | string  | No         | -          | Duration                                                                                                                            |
+| - [MaxTxBytesSize](#Pool_MaxTxBytesSize )                                       | No      | integer | No         | -          | MaxTxBytesSize is the max size of a transaction in bytes                                                                            |
+| - [MaxTxDataBytesSize](#Pool_MaxTxDataBytesSize )                               | No      | integer | No         | -          | MaxTxDataBytesSize is the max size of the data field of a transaction in bytes                                                      |
+| - [DB](#Pool_DB )                                                               | No      | object  | No         | -          | DB is the database configuration                                                                                                    |
+| - [DefaultMinGasPriceAllowed](#Pool_DefaultMinGasPriceAllowed )                 | No      | integer | No         | -          | DefaultMinGasPriceAllowed is the default min gas price to suggest                                                                   |
+| - [MinAllowedGasPriceInterval](#Pool_MinAllowedGasPriceInterval )               | No      | string  | No         | -          | Duration                                                                                                                            |
+| - [PollMinAllowedGasPriceInterval](#Pool_PollMinAllowedGasPriceInterval )       | No      | string  | No         | -          | Duration                                                                                                                            |
+| - [AccountQueue](#Pool_AccountQueue )                                           | No      | integer | No         | -          | AccountQueue represents the maximum number of non-executable transaction slots permitted per account                                |
+| - [GlobalQueue](#Pool_GlobalQueue )                                             | No      | integer | No         | -          | GlobalQueue represents the maximum number of non-executable transaction slots for all accounts                                      |
+| - [EffectiveGasPrice](#Pool_EffectiveGasPrice )                                 | No      | object  | No         | -          | EffectiveGasPrice is the config for the effective gas price calculation                                                             |
+| - [ForkID](#Pool_ForkID )                                                       | No      | integer | No         | -          | ForkID is the current fork ID of the chain                                                                                          |
+| - [TxFeeCap](#Pool_TxFeeCap )                                                   | No      | number  | No         | -          | TxFeeCap is the global transaction fee(price * gaslimit) cap for
send-transaction variants. The unit is ether. 0 means no cap. | ### 7.1. `Pool.IntervalToRefreshBlockedAddresses` @@ -890,6 +891,21 @@ L2GasPriceSuggesterFactor=0.5 ForkID=0 ``` +### 7.13. `Pool.TxFeeCap` + +**Type:** : `number` + +**Default:** `1` + +**Description:** TxFeeCap is the global transaction fee(price * gaslimit) cap for +send-transaction variants. The unit is ether. 0 means no cap. + +**Example setting the default value** (1): +``` +[Pool] +TxFeeCap=1 +``` + ## 8. `[RPC]` **Type:** : `object` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index a67ec40bd8..d25197f149 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -327,6 +327,11 @@ "type": "integer", "description": "ForkID is the current fork ID of the chain", "default": 0 + }, + "TxFeeCap": { + "type": "number", + "description": "TxFeeCap is the global transaction fee(price * gaslimit) cap for\nsend-transaction variants. The unit is ether. 0 means no cap.", + "default": 1 } }, "additionalProperties": false, diff --git a/pool/config.go b/pool/config.go index 869c76a86c..62bfcc8512 100644 --- a/pool/config.go +++ b/pool/config.go @@ -43,6 +43,10 @@ type Config struct { // ForkID is the current fork ID of the chain ForkID uint64 `mapstructure:"ForkID"` + + // TxFeeCap is the global transaction fee(price * gaslimit) cap for + // send-transaction variants. The unit is ether. 0 means no cap. + TxFeeCap float64 `mapstructure:"TxFeeCap"` } // EffectiveGasPriceCfg contains the configuration properties for the effective gas price diff --git a/pool/pool.go b/pool/pool.go index e9c3e9e4da..227169c057 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/big" + "strconv" "sync" "time" @@ -16,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" ) var ( @@ -463,6 +465,10 @@ func (p *Pool) validateTx(ctx context.Context, poolTx Transaction) error { return ErrNegativeValue } + if err := checkTxFee(poolTx.GasPrice(), poolTx.Gas(), p.cfg.TxFeeCap); err != nil { + return err + } + // check if sender is blocked _, blocked := p.blockedAddresses.Load(from.String()) if blocked { @@ -740,3 +746,19 @@ func IntrinsicGas(tx types.Transaction) (uint64, error) { func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) { return p.storage.CheckPolicy(ctx, policy, address) } + +// checkTxFee is an internal function used to check whether the fee of +// the given transaction is _reasonable_(under the cap). +func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error { + // Short circuit if there is no cap for transaction fee at all. + if cap == 0 { + return nil + } + feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.Ether))) + feeFloat, _ := feeEth.Float64() + if feeFloat > cap { + feeFloatTruncated := strconv.FormatFloat(feeFloat, 'f', -1, 64) + return fmt.Errorf("tx fee (%s ether) exceeds the configured cap (%.2f ether)", feeFloatTruncated, cap) + } + return nil +} diff --git a/pool/pool_test.go b/pool/pool_test.go index d75302af42..47c30cd849 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -67,6 +67,7 @@ var ( IntervalToRefreshGasPrices: cfgTypes.NewDuration(5 * time.Second), AccountQueue: 15, GlobalQueue: 20, + TxFeeCap: 1, EffectiveGasPrice: pool.EffectiveGasPriceCfg{ Enabled: true, L1GasPriceFactor: 0.25, @@ -1086,10 +1087,12 @@ func Test_TryAddIncompatibleTxs(t *testing.T) { expectedError: fmt.Errorf("chain id higher than allowed, max allowed is %v", uint64(math.MaxUint64)), }, } + c := cfg + c.TxFeeCap = 0 for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { incompatibleTx := testCase.createIncompatibleTx() - p := setupPool(t, cfg, bc, s, st, incompatibleTx.ChainId().Uint64(), ctx, eventLog) + p := setupPool(t, c, bc, s, st, incompatibleTx.ChainId().Uint64(), ctx, eventLog) err = p.AddTx(ctx, incompatibleTx, ip) assert.Equal(t, testCase.expectedError, err) }) @@ -1965,6 +1968,115 @@ func Test_AddTx_IPValidation(t *testing.T) { } } +func Test_AddTx_TxFeeCap(t *testing.T) { + eventStorage, err := nileventstorage.NewNilEventStorage() + if err != nil { + log.Fatal(err) + } + eventLog := event.NewEventLog(event.Config{}, eventStorage) + + initOrResetDB(t) + + stateSqlDB, err := db.NewSQLDB(stateDBCfg) + if err != nil { + panic(err) + } + defer stateSqlDB.Close() //nolint:gosec,errcheck + + poolSqlDB, err := db.NewSQLDB(poolDBCfg) + require.NoError(t, err) + defer poolSqlDB.Close() //nolint:gosec,errcheck + + st := newState(stateSqlDB, eventLog) + + genesisBlock := state.Block{ + BlockNumber: 0, + BlockHash: state.ZeroHash, + ParentHash: state.ZeroHash, + ReceivedAt: time.Now(), + } + genesis := state.Genesis{ + Actions: []*state.GenesisAction{ + { + Address: senderAddress, + Type: int(merkletree.LeafTypeBalance), + Value: "1000000000000000000000", + }, + }, + } + ctx := context.Background() + dbTx, err := st.BeginStateTransaction(ctx) + require.NoError(t, err) + _, err = st.SetGenesis(ctx, genesisBlock, genesis, metrics.SynchronizerCallerLabel, dbTx) + require.NoError(t, err) + require.NoError(t, dbTx.Commit(ctx)) + + s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) + require.NoError(t, err) + + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) + + privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) + require.NoError(t, err) + + auth, err := bind.NewKeyedTransactorWithChainID(privateKey, chainID) + require.NoError(t, err) + + type testCase struct { + name string + nonce uint64 + gas uint64 + gasPrice string + expectedError error + } + + testCases := []testCase{ + { + name: "add tx with fee under cap", + nonce: 0, + gas: uint64(100000), + gasPrice: "9999999999999", + expectedError: nil, + }, + { + name: "add tx with fee exactly as cap", + nonce: 0, + gas: uint64(100000), + gasPrice: "10000000000000", + expectedError: nil, + }, + { + name: "add tx with fee over the cap", + nonce: 0, + gas: uint64(100000), + gasPrice: "10000000000001", + expectedError: fmt.Errorf("tx fee (1.0000000000001 ether) exceeds the configured cap (1.00 ether)"), + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + gasPrice, ok := big.NewInt(0).SetString(tc.gasPrice, encoding.Base10) + require.True(t, ok) + tx := ethTypes.NewTx(ðTypes.LegacyTx{ + Nonce: tc.nonce, + Gas: tc.gas, + GasPrice: gasPrice, + }) + + signedTx, err := auth.Signer(auth.From, tx) + require.NoError(t, err) + + err = p.AddTx(ctx, *signedTx, ip) + if tc.expectedError != nil { + require.Equal(t, err.Error(), tc.expectedError.Error()) + } else { + require.Nil(t, err) + } + }) + } +} + func setupPool(t *testing.T, cfg pool.Config, constraintsCfg state.BatchConstraintsCfg, s *pgpoolstorage.PostgresPoolStorage, st *state.State, chainID uint64, ctx context.Context, eventLog *event.EventLog) *pool.Pool { err := s.SetGasPrices(ctx, gasPrice.Uint64(), l1GasPrice.Uint64()) require.NoError(t, err) From 2e2062bea58a467c6c03b4d02a2bf1e351100af7 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Wed, 22 May 2024 10:49:22 +0200 Subject: [PATCH 08/23] Add delay when getting storedFlushId from the executor/hashdb (#3625) * Add sleep delay when getting storedFlushId from the executor/hashdb * update config doc --- config/config_test.go | 4 ++ config/default.go | 1 + .../environments/local/local.node.config.toml | 1 + docs/config-file/node-config-doc.html | 2 + docs/config-file/node-config-doc.md | 39 ++++++++++++++++--- docs/config-file/node-config-schema.json | 10 +++++ sequencer/config.go | 3 ++ sequencer/finalizer.go | 7 ++++ sequencer/l2block.go | 26 +++++++------ test/config/debug.node.config.toml | 1 + test/config/test.node.config.toml | 1 + 11 files changed, 77 insertions(+), 18 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 90c38eb206..a8d850be0e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -137,6 +137,10 @@ func Test_Defaults(t *testing.T) { path: "Sequencer.Finalizer.BatchMaxDeltaTimestamp", expectedValue: types.NewDuration(1800 * time.Second), }, + { + path: "Sequencer.Finalizer.FlushIdCheckInterval", + expectedValue: types.NewDuration(50 * time.Millisecond), + }, { path: "Sequencer.Finalizer.Metrics.Interval", expectedValue: types.NewDuration(60 * time.Minute), diff --git a/config/default.go b/config/default.go index c0abada7b7..8d20f0b900 100644 --- a/config/default.go +++ b/config/default.go @@ -152,6 +152,7 @@ StateConsistencyCheckInterval = "5s" L2BlockMaxDeltaTimestamp = "3s" ResourceExhaustedMarginPct = 10 StateRootSyncInterval = "3600s" + FlushIdCheckInterval = "50ms" HaltOnBatchNumber = 0 SequentialBatchSanityCheck = false SequentialProcessL2Block = false diff --git a/config/environments/local/local.node.config.toml b/config/environments/local/local.node.config.toml index 436a0d84fa..376465b3c8 100644 --- a/config/environments/local/local.node.config.toml +++ b/config/environments/local/local.node.config.toml @@ -102,6 +102,7 @@ StateConsistencyCheckInterval = "5s" L2BlockMaxDeltaTimestamp = "3s" ResourceExhaustedMarginPct = 10 StateRootSyncInterval = "360s" + FlushIdCheckInterval = "50ms" HaltOnBatchNumber = 0 SequentialBatchSanityCheck = false SequentialProcessL2Block = false diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 5666a3dc16..ecaf59bd45 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -52,6 +52,8 @@
"300ms"
 

Default: "1h0m0s"Type: string

StateRootSyncInterval indicates how often the stateroot generated by the L2 block process will be synchronized with
the stateroot used in the tx-by-tx execution


Examples:

"1m"
 
"300ms"
+

Default: "50ms"Type: string

FlushIdCheckInterval is the time interval to get storedFlushID value from the executor/hashdb


Examples:

"1m"
+
"300ms"
 

Default: 0Type: integer

HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.
The Sequencer will halt after it closes the batch equal to this number


Default: falseType: boolean

SequentialBatchSanityCheck indicates if the reprocess of a closed batch (sanity check) must be done in a
sequential way (instead than in parallel)


Default: falseType: boolean

SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
in the processPendingL2Blocks go func


Metrics is the config for the sequencer metrics
Default: "1h0m0s"Type: string

Interval is the interval of time to calculate sequencer metrics


Examples:

"1m"
 
"300ms"
 

Default: trueType: boolean

EnableLog is a flag to enable/disable metrics logs


StreamServerCfg is the config for the stream server
Default: 0Type: integer

Port to listen on


Default: ""Type: string

Filename of the binary data file


Default: 0Type: integer

Version of the binary data file


Default: 0Type: integer

ChainID is the chain ID


Default: falseType: boolean

Enabled is a flag to enable/disable the data streamer


Log is the log configuration
Default: ""Type: enum (of string)

Must be one of:

  • "production"
  • "development"

Default: ""Type: enum (of string)

Must be one of:

  • "debug"
  • "info"
  • "warn"
  • "error"
  • "dpanic"
  • "panic"
  • "fatal"

Type: array of string

Each item of this array must be:


Default: 0Type: integer

UpgradeEtrogBatchNumber is the batch number of the upgrade etrog


Configuration of the sequence sender service
Default: "5s"Type: string

WaitPeriodSendSequence is the time the sequencer waits until
trying to send a sequence to L1


Examples:

"1m"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index e69b0337d5..32069deb58 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -2115,6 +2115,7 @@ StateConsistencyCheckInterval="5s"
 | - [BatchMaxDeltaTimestamp](#Sequencer_Finalizer_BatchMaxDeltaTimestamp )                       | No      | string  | No         | -          | Duration                                                                                                                                                                                                      |
 | - [L2BlockMaxDeltaTimestamp](#Sequencer_Finalizer_L2BlockMaxDeltaTimestamp )                   | No      | string  | No         | -          | Duration                                                                                                                                                                                                      |
 | - [StateRootSyncInterval](#Sequencer_Finalizer_StateRootSyncInterval )                         | No      | string  | No         | -          | Duration                                                                                                                                                                                                      |
+| - [FlushIdCheckInterval](#Sequencer_Finalizer_FlushIdCheckInterval )                           | No      | string  | No         | -          | Duration                                                                                                                                                                                                      |
 | - [HaltOnBatchNumber](#Sequencer_Finalizer_HaltOnBatchNumber )                                 | No      | integer | No         | -          | HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.
The Sequencer will halt after it closes the batch equal to this number | | - [SequentialBatchSanityCheck](#Sequencer_Finalizer_SequentialBatchSanityCheck ) | No | boolean | No | - | SequentialBatchSanityCheck indicates if the reprocess of a closed batch (sanity check) must be done in a
sequential way (instead than in parallel) | | - [SequentialProcessL2Block](#Sequencer_Finalizer_SequentialProcessL2Block ) | No | boolean | No | - | SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
in the processPendingL2Blocks go func | @@ -2345,7 +2346,33 @@ the stateroot used in the tx-by-tx execution StateRootSyncInterval="1h0m0s" ``` -#### 10.7.11. `Sequencer.Finalizer.HaltOnBatchNumber` +#### 10.7.11. `Sequencer.Finalizer.FlushIdCheckInterval` + +**Title:** Duration + +**Type:** : `string` + +**Default:** `"50ms"` + +**Description:** FlushIdCheckInterval is the time interval to get storedFlushID value from the executor/hashdb + +**Examples:** + +```json +"1m" +``` + +```json +"300ms" +``` + +**Example setting the default value** ("50ms"): +``` +[Sequencer.Finalizer] +FlushIdCheckInterval="50ms" +``` + +#### 10.7.12. `Sequencer.Finalizer.HaltOnBatchNumber` **Type:** : `integer` @@ -2360,7 +2387,7 @@ The Sequencer will halt after it closes the batch equal to this number HaltOnBatchNumber=0 ``` -#### 10.7.12. `Sequencer.Finalizer.SequentialBatchSanityCheck` +#### 10.7.13. `Sequencer.Finalizer.SequentialBatchSanityCheck` **Type:** : `boolean` @@ -2375,7 +2402,7 @@ sequential way (instead than in parallel) SequentialBatchSanityCheck=false ``` -#### 10.7.13. `Sequencer.Finalizer.SequentialProcessL2Block` +#### 10.7.14. `Sequencer.Finalizer.SequentialProcessL2Block` **Type:** : `boolean` @@ -2390,7 +2417,7 @@ in the processPendingL2Blocks go func SequentialProcessL2Block=false ``` -#### 10.7.14. `[Sequencer.Finalizer.Metrics]` +#### 10.7.15. `[Sequencer.Finalizer.Metrics]` **Type:** : `object` **Description:** Metrics is the config for the sequencer metrics @@ -2400,7 +2427,7 @@ SequentialProcessL2Block=false | - [Interval](#Sequencer_Finalizer_Metrics_Interval ) | No | string | No | - | Duration | | - [EnableLog](#Sequencer_Finalizer_Metrics_EnableLog ) | No | boolean | No | - | EnableLog is a flag to enable/disable metrics logs | -##### 10.7.14.1. `Sequencer.Finalizer.Metrics.Interval` +##### 10.7.15.1. `Sequencer.Finalizer.Metrics.Interval` **Title:** Duration @@ -2426,7 +2453,7 @@ SequentialProcessL2Block=false Interval="1h0m0s" ``` -##### 10.7.14.2. `Sequencer.Finalizer.Metrics.EnableLog` +##### 10.7.15.2. `Sequencer.Finalizer.Metrics.EnableLog` **Type:** : `boolean` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index d25197f149..3e1cbe0fc2 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -879,6 +879,16 @@ "300ms" ] }, + "FlushIdCheckInterval": { + "type": "string", + "title": "Duration", + "description": "FlushIdCheckInterval is the time interval to get storedFlushID value from the executor/hashdb", + "default": "50ms", + "examples": [ + "1m", + "300ms" + ] + }, "HaltOnBatchNumber": { "type": "integer", "description": "HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.\nThe Sequencer will halt after it closes the batch equal to this number", diff --git a/sequencer/config.go b/sequencer/config.go index 8b813c52db..c0bfb8968d 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -83,6 +83,9 @@ type FinalizerCfg struct { // the stateroot used in the tx-by-tx execution StateRootSyncInterval types.Duration `mapstructure:"StateRootSyncInterval"` + // FlushIdCheckInterval is the time interval to get storedFlushID value from the executor/hashdb + FlushIdCheckInterval types.Duration `mapstructure:"FlushIdCheckInterval"` + // HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches. // The Sequencer will halt after it closes the batch equal to this number HaltOnBatchNumber uint64 `mapstructure:"HaltOnBatchNumber"` diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index 2e1b0a41c8..d7aabd5005 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -208,8 +208,15 @@ func (f *finalizer) updateProverIdAndFlushId(ctx context.Context) { f.storedFlushID = storedFlushID f.storedFlushIDCond.Broadcast() f.storedFlushIDCond.L.Unlock() + + // Exit the for loop o the storedFlushId is greater or equal that the lastPendingFlushID + if f.storedFlushID >= f.lastPendingFlushID { + break + } } } + + time.Sleep(f.cfg.FlushIdCheckInterval.Duration) } } } diff --git a/sequencer/l2block.go b/sequencer/l2block.go index 7a2af42cda..c5b99ceed0 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -266,10 +266,12 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error f.updateFlushIDs(batchResponse.FlushID, batchResponse.StoredFlushID) + var waitStoreL2Block time.Duration if f.pendingL2BlocksToStoreWG.Count() > 0 { startWait := time.Now() f.pendingL2BlocksToStoreWG.Wait() - log.Debugf("waiting for previous L2 block to be stored took: %v", time.Since(startWait)) + waitStoreL2Block = time.Since(startWait) + log.Debugf("waiting for previous L2 block to be stored took: %v", waitStoreL2Block) } f.addPendingL2BlockToStore(ctx, l2Block) @@ -280,9 +282,9 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error } f.metrics.addL2BlockMetrics(l2Block.metrics) - log.Infof("processed L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, initialStateRoot: %s, newStateRoot: %s, txs: %d/%d, blockHash: %s, infoRoot: %s, counters: {used: %s, reserved: %s, needed: %s, high: %s}, contextId: %s", + log.Infof("processed L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, initialStateRoot: %s, newStateRoot: %s, txs: %d/%d, blockHash: %s, infoRoot: %s, waitStoreL2Block: %v, counters: {used: %s, reserved: %s, needed: %s, high: %s}, contextId: %s", blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, l2Block.deltaTimestamp, l2Block.timestamp, l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex, l2Block.l1InfoTreeExitRootChanged, initialStateRoot, l2Block.batchResponse.NewStateRoot, - len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot, + len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot, waitStoreL2Block, f.logZKCounters(batchResponse.UsedZkCounters), f.logZKCounters(batchResponse.ReservedZkCounters), f.logZKCounters(neededZKCounters), f.logZKCounters(l2Block.batch.finalHighReservedZKCounters), contextId) if f.cfg.Metrics.EnableLog { @@ -369,19 +371,21 @@ func (f *finalizer) executeL2Block(ctx context.Context, initialStateRoot common. func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { startStoring := time.Now() + blockResponse := l2Block.batchResponse.BlockResponses[0] + log.Infof("storing L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, txs: %d/%d, blockHash: %s, infoRoot: %s", + blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, l2Block.deltaTimestamp, l2Block.timestamp, l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex, + l2Block.l1InfoTreeExitRootChanged, len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot.String()) + // Wait until L2 block has been flushed/stored by the executor + startWaitFlushId := time.Now() f.storedFlushIDCond.L.Lock() for f.storedFlushID < l2Block.batchResponse.FlushID { f.storedFlushIDCond.Wait() } f.storedFlushIDCond.L.Unlock() + waitFlushId := time.Since(startWaitFlushId) // If the L2 block has txs now f.storedFlushID >= l2BlockToStore.flushId, we can store tx - blockResponse := l2Block.batchResponse.BlockResponses[0] - log.Infof("storing L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, txs: %d/%d, blockHash: %s, infoRoot: %s", - blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, l2Block.deltaTimestamp, l2Block.timestamp, l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex, - l2Block.l1InfoTreeExitRootChanged, len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot.String()) - dbTx, err := f.stateIntf.BeginStateTransaction(ctx) if err != nil { return fmt.Errorf("error creating db transaction to store L2 block %d [%d], error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) @@ -508,11 +512,9 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { f.workerIntf.DeleteTxPendingToStore(tx.Hash, tx.From) } - endStoring := time.Now() - - log.Infof("stored L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, txs: %d/%d, blockHash: %s, infoRoot: %s, time: %v", + log.Infof("stored L2 block %d [%d], batch: %d, deltaTimestamp: %d, timestamp: %d, l1InfoTreeIndex: %d, l1InfoTreeIndexChanged: %v, txs: %d/%d, blockHash: %s, infoRoot: %s, time: %v, waitFlushId: %v", blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, l2Block.deltaTimestamp, l2Block.timestamp, l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex, - l2Block.l1InfoTreeExitRootChanged, len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot.String(), endStoring.Sub(startStoring)) + l2Block.l1InfoTreeExitRootChanged, len(l2Block.transactions), len(blockResponse.TransactionResponses), blockResponse.BlockHash, blockResponse.BlockInfoRoot.String(), time.Since(startStoring), waitFlushId) return nil } diff --git a/test/config/debug.node.config.toml b/test/config/debug.node.config.toml index ccd423daee..698164c866 100644 --- a/test/config/debug.node.config.toml +++ b/test/config/debug.node.config.toml @@ -101,6 +101,7 @@ StateConsistencyCheckInterval = "5s" L2BlockMaxDeltaTimestamp = "3s" ResourceExhaustedMarginPct = 10 StateRootSyncInterval = "120s" + FlushIdCheckInterval = "50ms" HaltOnBatchNumber = 0 SequentialBatchSanityCheck = false SequentialProcessL2Block = false diff --git a/test/config/test.node.config.toml b/test/config/test.node.config.toml index 4809bcfcd7..51a8ef7b1b 100644 --- a/test/config/test.node.config.toml +++ b/test/config/test.node.config.toml @@ -116,6 +116,7 @@ StateConsistencyCheckInterval = "5s" L2BlockMaxDeltaTimestamp = "4s" ResourceExhaustedMarginPct = 10 StateRootSyncInterval = "60s" + FlushIdCheckInterval = "50ms" HaltOnBatchNumber = 0 SequentialBatchSanityCheck = false SequentialProcessL2Block = false From 2270d087a701c4431bf41783d36b98d7bedcf1cb Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Wed, 22 May 2024 17:31:50 +0200 Subject: [PATCH 09/23] Fix use of L2coinbase configured in sequencesender.L2Coinbase parameter (#3642) * fix use l2coinbase configured in sequencesender.L2Coinbase parameter * update doc --- cmd/run.go | 2 + docs/config-file/node-config-doc.html | 2 +- docs/config-file/node-config-doc.md | 84 +++++++++++++----------- docs/config-file/node-config-schema.json | 9 +++ sequencer/batch.go | 4 +- sequencer/config.go | 4 ++ sequencer/datastreamer.go | 2 +- sequencer/finalizer.go | 6 +- sequencer/finalizer_test.go | 18 ++--- sequencer/forcedbatch.go | 4 +- sequencer/sequencer.go | 11 +--- 11 files changed, 79 insertions(+), 67 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 047724163a..01164aa460 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -507,6 +507,8 @@ func runJSONRPCServer(c config.Config, etherman *etherman.Client, chainID uint64 } func createSequencer(cfg config.Config, pool *pool.Pool, st *state.State, etherman *etherman.Client, eventLog *event.EventLog) *sequencer.Sequencer { + cfg.Sequencer.L2Coinbase = cfg.SequenceSender.L2Coinbase + seq, err := sequencer.New(cfg.Sequencer, cfg.State.Batch, cfg.Pool, pool, st, etherman, eventLog) if err != nil { log.Fatal(err) diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index ecaf59bd45..bba3d2684a 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -38,7 +38,7 @@
"300ms"
 

Default: "5s"Type: string

StateConsistencyCheckInterval is the time the sequencer waits to check if a state inconsistency has happened


Examples:

"1m"
 
"300ms"
-

Finalizer's specific config properties
Default: "1m0s"Type: string

ForcedBatchesTimeout is the time the finalizer waits after receiving closing signal to process Forced Batches


Examples:

"1m"
+

Type: array of integer

L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase

Must contain a minimum of 20 items

Must contain a maximum of 20 items

Each item of this array must be:


Finalizer's specific config properties
Default: "1m0s"Type: string

ForcedBatchesTimeout is the time the finalizer waits after receiving closing signal to process Forced Batches


Examples:

"1m"
 
"300ms"
 

Default: "100ms"Type: string

NewTxsWaitInterval is the time the finalizer sleeps between each iteration, if there are no transactions to be processed


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 32069deb58..8549afee67 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1943,16 +1943,17 @@ DataSourcePriority=["local", "trusted", "external"]
 **Type:** : `object`
 **Description:** Configuration of the sequencer service
 
-| Property                                                                             | Pattern | Type    | Deprecated | Definition | Title/Description                                                                                |
-| ------------------------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------ |
-| - [DeletePoolTxsL1BlockConfirmations](#Sequencer_DeletePoolTxsL1BlockConfirmations ) | No      | integer | No         | -          | DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool |
-| - [DeletePoolTxsCheckInterval](#Sequencer_DeletePoolTxsCheckInterval )               | No      | string  | No         | -          | Duration                                                                                         |
-| - [TxLifetimeCheckInterval](#Sequencer_TxLifetimeCheckInterval )                     | No      | string  | No         | -          | Duration                                                                                         |
-| - [TxLifetimeMax](#Sequencer_TxLifetimeMax )                                         | No      | string  | No         | -          | Duration                                                                                         |
-| - [LoadPoolTxsCheckInterval](#Sequencer_LoadPoolTxsCheckInterval )                   | No      | string  | No         | -          | Duration                                                                                         |
-| - [StateConsistencyCheckInterval](#Sequencer_StateConsistencyCheckInterval )         | No      | string  | No         | -          | Duration                                                                                         |
-| - [Finalizer](#Sequencer_Finalizer )                                                 | No      | object  | No         | -          | Finalizer's specific config properties                                                           |
-| - [StreamServer](#Sequencer_StreamServer )                                           | No      | object  | No         | -          | StreamServerCfg is the config for the stream server                                              |
+| Property                                                                             | Pattern | Type             | Deprecated | Definition | Title/Description                                                                                                      |
+| ------------------------------------------------------------------------------------ | ------- | ---------------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------- |
+| - [DeletePoolTxsL1BlockConfirmations](#Sequencer_DeletePoolTxsL1BlockConfirmations ) | No      | integer          | No         | -          | DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool                       |
+| - [DeletePoolTxsCheckInterval](#Sequencer_DeletePoolTxsCheckInterval )               | No      | string           | No         | -          | Duration                                                                                                               |
+| - [TxLifetimeCheckInterval](#Sequencer_TxLifetimeCheckInterval )                     | No      | string           | No         | -          | Duration                                                                                                               |
+| - [TxLifetimeMax](#Sequencer_TxLifetimeMax )                                         | No      | string           | No         | -          | Duration                                                                                                               |
+| - [LoadPoolTxsCheckInterval](#Sequencer_LoadPoolTxsCheckInterval )                   | No      | string           | No         | -          | Duration                                                                                                               |
+| - [StateConsistencyCheckInterval](#Sequencer_StateConsistencyCheckInterval )         | No      | string           | No         | -          | Duration                                                                                                               |
+| - [L2Coinbase](#Sequencer_L2Coinbase )                                               | No      | array of integer | No         | -          | L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase |
+| - [Finalizer](#Sequencer_Finalizer )                                                 | No      | object           | No         | -          | Finalizer's specific config properties                                                                                 |
+| - [StreamServer](#Sequencer_StreamServer )                                           | No      | object           | No         | -          | StreamServerCfg is the config for the stream server                                                                    |
 
 ### 10.1. `Sequencer.DeletePoolTxsL1BlockConfirmations`
 
@@ -2098,7 +2099,12 @@ LoadPoolTxsCheckInterval="500ms"
 StateConsistencyCheckInterval="5s"
 ```
 
-### 10.7. `[Sequencer.Finalizer]`
+### 10.7. `Sequencer.L2Coinbase`
+
+**Type:** : `array of integer`
+**Description:** L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase
+
+### 10.8. `[Sequencer.Finalizer]`
 
 **Type:** : `object`
 **Description:** Finalizer's specific config properties
@@ -2121,7 +2127,7 @@ StateConsistencyCheckInterval="5s"
 | - [SequentialProcessL2Block](#Sequencer_Finalizer_SequentialProcessL2Block )                   | No      | boolean | No         | -          | SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
in the processPendingL2Blocks go func | | - [Metrics](#Sequencer_Finalizer_Metrics ) | No | object | No | - | Metrics is the config for the sequencer metrics | -#### 10.7.1. `Sequencer.Finalizer.ForcedBatchesTimeout` +#### 10.8.1. `Sequencer.Finalizer.ForcedBatchesTimeout` **Title:** Duration @@ -2147,7 +2153,7 @@ StateConsistencyCheckInterval="5s" ForcedBatchesTimeout="1m0s" ``` -#### 10.7.2. `Sequencer.Finalizer.NewTxsWaitInterval` +#### 10.8.2. `Sequencer.Finalizer.NewTxsWaitInterval` **Title:** Duration @@ -2173,7 +2179,7 @@ ForcedBatchesTimeout="1m0s" NewTxsWaitInterval="100ms" ``` -#### 10.7.3. `Sequencer.Finalizer.ResourceExhaustedMarginPct` +#### 10.8.3. `Sequencer.Finalizer.ResourceExhaustedMarginPct` **Type:** : `integer` @@ -2187,7 +2193,7 @@ NewTxsWaitInterval="100ms" ResourceExhaustedMarginPct=10 ``` -#### 10.7.4. `Sequencer.Finalizer.ForcedBatchesL1BlockConfirmations` +#### 10.8.4. `Sequencer.Finalizer.ForcedBatchesL1BlockConfirmations` **Type:** : `integer` @@ -2201,7 +2207,7 @@ ResourceExhaustedMarginPct=10 ForcedBatchesL1BlockConfirmations=64 ``` -#### 10.7.5. `Sequencer.Finalizer.L1InfoTreeL1BlockConfirmations` +#### 10.8.5. `Sequencer.Finalizer.L1InfoTreeL1BlockConfirmations` **Type:** : `integer` @@ -2215,7 +2221,7 @@ ForcedBatchesL1BlockConfirmations=64 L1InfoTreeL1BlockConfirmations=64 ``` -#### 10.7.6. `Sequencer.Finalizer.ForcedBatchesCheckInterval` +#### 10.8.6. `Sequencer.Finalizer.ForcedBatchesCheckInterval` **Title:** Duration @@ -2241,7 +2247,7 @@ L1InfoTreeL1BlockConfirmations=64 ForcedBatchesCheckInterval="10s" ``` -#### 10.7.7. `Sequencer.Finalizer.L1InfoTreeCheckInterval` +#### 10.8.7. `Sequencer.Finalizer.L1InfoTreeCheckInterval` **Title:** Duration @@ -2267,7 +2273,7 @@ ForcedBatchesCheckInterval="10s" L1InfoTreeCheckInterval="10s" ``` -#### 10.7.8. `Sequencer.Finalizer.BatchMaxDeltaTimestamp` +#### 10.8.8. `Sequencer.Finalizer.BatchMaxDeltaTimestamp` **Title:** Duration @@ -2293,7 +2299,7 @@ L1InfoTreeCheckInterval="10s" BatchMaxDeltaTimestamp="30m0s" ``` -#### 10.7.9. `Sequencer.Finalizer.L2BlockMaxDeltaTimestamp` +#### 10.8.9. `Sequencer.Finalizer.L2BlockMaxDeltaTimestamp` **Title:** Duration @@ -2319,7 +2325,7 @@ BatchMaxDeltaTimestamp="30m0s" L2BlockMaxDeltaTimestamp="3s" ``` -#### 10.7.10. `Sequencer.Finalizer.StateRootSyncInterval` +#### 10.8.10. `Sequencer.Finalizer.StateRootSyncInterval` **Title:** Duration @@ -2346,7 +2352,7 @@ the stateroot used in the tx-by-tx execution StateRootSyncInterval="1h0m0s" ``` -#### 10.7.11. `Sequencer.Finalizer.FlushIdCheckInterval` +#### 10.8.11. `Sequencer.Finalizer.FlushIdCheckInterval` **Title:** Duration @@ -2372,7 +2378,7 @@ StateRootSyncInterval="1h0m0s" FlushIdCheckInterval="50ms" ``` -#### 10.7.12. `Sequencer.Finalizer.HaltOnBatchNumber` +#### 10.8.12. `Sequencer.Finalizer.HaltOnBatchNumber` **Type:** : `integer` @@ -2387,7 +2393,7 @@ The Sequencer will halt after it closes the batch equal to this number HaltOnBatchNumber=0 ``` -#### 10.7.13. `Sequencer.Finalizer.SequentialBatchSanityCheck` +#### 10.8.13. `Sequencer.Finalizer.SequentialBatchSanityCheck` **Type:** : `boolean` @@ -2402,7 +2408,7 @@ sequential way (instead than in parallel) SequentialBatchSanityCheck=false ``` -#### 10.7.14. `Sequencer.Finalizer.SequentialProcessL2Block` +#### 10.8.14. `Sequencer.Finalizer.SequentialProcessL2Block` **Type:** : `boolean` @@ -2417,7 +2423,7 @@ in the processPendingL2Blocks go func SequentialProcessL2Block=false ``` -#### 10.7.15. `[Sequencer.Finalizer.Metrics]` +#### 10.8.15. `[Sequencer.Finalizer.Metrics]` **Type:** : `object` **Description:** Metrics is the config for the sequencer metrics @@ -2427,7 +2433,7 @@ SequentialProcessL2Block=false | - [Interval](#Sequencer_Finalizer_Metrics_Interval ) | No | string | No | - | Duration | | - [EnableLog](#Sequencer_Finalizer_Metrics_EnableLog ) | No | boolean | No | - | EnableLog is a flag to enable/disable metrics logs | -##### 10.7.15.1. `Sequencer.Finalizer.Metrics.Interval` +##### 10.8.15.1. `Sequencer.Finalizer.Metrics.Interval` **Title:** Duration @@ -2453,7 +2459,7 @@ SequentialProcessL2Block=false Interval="1h0m0s" ``` -##### 10.7.15.2. `Sequencer.Finalizer.Metrics.EnableLog` +##### 10.8.15.2. `Sequencer.Finalizer.Metrics.EnableLog` **Type:** : `boolean` @@ -2467,7 +2473,7 @@ Interval="1h0m0s" EnableLog=true ``` -### 10.8. `[Sequencer.StreamServer]` +### 10.9. `[Sequencer.StreamServer]` **Type:** : `object` **Description:** StreamServerCfg is the config for the stream server @@ -2482,7 +2488,7 @@ EnableLog=true | - [Log](#Sequencer_StreamServer_Log ) | No | object | No | - | Log is the log configuration | | - [UpgradeEtrogBatchNumber](#Sequencer_StreamServer_UpgradeEtrogBatchNumber ) | No | integer | No | - | UpgradeEtrogBatchNumber is the batch number of the upgrade etrog | -#### 10.8.1. `Sequencer.StreamServer.Port` +#### 10.9.1. `Sequencer.StreamServer.Port` **Type:** : `integer` @@ -2496,7 +2502,7 @@ EnableLog=true Port=0 ``` -#### 10.8.2. `Sequencer.StreamServer.Filename` +#### 10.9.2. `Sequencer.StreamServer.Filename` **Type:** : `string` @@ -2510,7 +2516,7 @@ Port=0 Filename="" ``` -#### 10.8.3. `Sequencer.StreamServer.Version` +#### 10.9.3. `Sequencer.StreamServer.Version` **Type:** : `integer` @@ -2524,7 +2530,7 @@ Filename="" Version=0 ``` -#### 10.8.4. `Sequencer.StreamServer.ChainID` +#### 10.9.4. `Sequencer.StreamServer.ChainID` **Type:** : `integer` @@ -2538,7 +2544,7 @@ Version=0 ChainID=0 ``` -#### 10.8.5. `Sequencer.StreamServer.Enabled` +#### 10.9.5. `Sequencer.StreamServer.Enabled` **Type:** : `boolean` @@ -2552,7 +2558,7 @@ ChainID=0 Enabled=false ``` -#### 10.8.6. `[Sequencer.StreamServer.Log]` +#### 10.9.6. `[Sequencer.StreamServer.Log]` **Type:** : `object` **Description:** Log is the log configuration @@ -2563,7 +2569,7 @@ Enabled=false | - [Level](#Sequencer_StreamServer_Log_Level ) | No | enum (of string) | No | - | - | | - [Outputs](#Sequencer_StreamServer_Log_Outputs ) | No | array of string | No | - | - | -##### 10.8.6.1. `Sequencer.StreamServer.Log.Environment` +##### 10.9.6.1. `Sequencer.StreamServer.Log.Environment` **Type:** : `enum (of string)` @@ -2579,7 +2585,7 @@ Must be one of: * "production" * "development" -##### 10.8.6.2. `Sequencer.StreamServer.Log.Level` +##### 10.9.6.2. `Sequencer.StreamServer.Log.Level` **Type:** : `enum (of string)` @@ -2600,11 +2606,11 @@ Must be one of: * "panic" * "fatal" -##### 10.8.6.3. `Sequencer.StreamServer.Log.Outputs` +##### 10.9.6.3. `Sequencer.StreamServer.Log.Outputs` **Type:** : `array of string` -#### 10.8.7. `Sequencer.StreamServer.UpgradeEtrogBatchNumber` +#### 10.9.7. `Sequencer.StreamServer.UpgradeEtrogBatchNumber` **Type:** : `integer` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index 3e1cbe0fc2..b33ce420f7 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -792,6 +792,15 @@ "300ms" ] }, + "L2Coinbase": { + "items": { + "type": "integer" + }, + "type": "array", + "maxItems": 20, + "minItems": 20, + "description": "L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase" + }, "Finalizer": { "properties": { "ForcedBatchesTimeout": { diff --git a/sequencer/batch.go b/sequencer/batch.go index c6e2700fa8..a5ada2b61a 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -306,7 +306,7 @@ func (f *finalizer) openNewWIPBatch(batchNumber uint64, stateRoot common.Hash) * return &Batch{ batchNumber: batchNumber, - coinbase: f.sequencerAddress, + coinbase: f.l2Coinbase, initialStateRoot: stateRoot, imStateRoot: stateRoot, finalStateRoot: stateRoot, @@ -323,7 +323,7 @@ func (f *finalizer) insertSIPBatch(ctx context.Context, batchNumber uint64, stat // open next batch newStateBatch := state.Batch{ BatchNumber: batchNumber, - Coinbase: f.sequencerAddress, + Coinbase: f.l2Coinbase, Timestamp: now(), StateRoot: stateRoot, GlobalExitRoot: state.ZeroHash, diff --git a/sequencer/config.go b/sequencer/config.go index c0bfb8968d..03aeeb740b 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -3,6 +3,7 @@ package sequencer import ( "github.com/0xPolygonHermez/zkevm-data-streamer/log" "github.com/0xPolygonHermez/zkevm-node/config/types" + "github.com/ethereum/go-ethereum/common" ) // Config represents the configuration of a sequencer @@ -25,6 +26,9 @@ type Config struct { // StateConsistencyCheckInterval is the time the sequencer waits to check if a state inconsistency has happened StateConsistencyCheckInterval types.Duration `mapstructure:"StateConsistencyCheckInterval"` + // L2Coinbase defines which address is going to receive the fees. It gets the config value from SequenceSender.L2Coinbase + L2Coinbase common.Address `mapstructure:"L2Coinbase"` + // Finalizer's specific config properties Finalizer FinalizerCfg `mapstructure:"Finalizer"` diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 4c08d6b3e4..50321c6c55 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -20,7 +20,7 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce L1InfoTreeIndex: l1InfoTreeIndex, L1BlockHash: blockResponse.BlockHashL1, GlobalExitRoot: blockResponse.GlobalExitRoot, - Coinbase: f.sequencerAddress, + Coinbase: f.l2Coinbase, ForkID: forkID, BlockHash: blockResponse.BlockHash, StateRoot: blockResponse.BlockHash, //From etrog, the blockhash is the block root diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index d7aabd5005..11692d16f2 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -35,7 +35,7 @@ var ( type finalizer struct { cfg FinalizerCfg isSynced func(ctx context.Context) bool - sequencerAddress common.Address + l2Coinbase common.Address workerIntf workerInterface poolIntf txPool stateIntf stateInterface @@ -95,7 +95,7 @@ func newFinalizer( poolIntf txPool, stateIntf stateInterface, etherman ethermanInterface, - sequencerAddr common.Address, + l2Coinbase common.Address, isSynced func(ctx context.Context) bool, batchConstraints state.BatchConstraintsCfg, eventLog *event.EventLog, @@ -106,7 +106,7 @@ func newFinalizer( f := finalizer{ cfg: cfg, isSynced: isSynced, - sequencerAddress: sequencerAddr, + l2Coinbase: l2Coinbase, workerIntf: workerIntf, poolIntf: poolIntf, stateIntf: stateIntf, diff --git a/sequencer/finalizer_test.go b/sequencer/finalizer_test.go index 84a2d6e8cf..35a03ef4ea 100644 --- a/sequencer/finalizer_test.go +++ b/sequencer/finalizer_test.go @@ -79,11 +79,11 @@ var ( } // chainID = new(big.Int).SetInt64(400) // pvtKey = "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e" - nonce1 = uint64(1) - nonce2 = uint64(2) - seqAddr = common.Address{} - oldHash = common.HexToHash("0x01") - newHash = common.HexToHash("0x02") + nonce1 = uint64(1) + nonce2 = uint64(2) + l2Coinbase = common.Address{} + oldHash = common.HexToHash("0x01") + newHash = common.HexToHash("0x02") // newHash2 = common.HexToHash("0x03") // stateRootHashes = []common.Hash{oldHash, newHash, newHash2} // txHash = common.HexToHash("0xf9e4fe4bd2256f782c66cffd76acdb455a76111842bb7e999af2f1b7f4d8d092") @@ -117,7 +117,7 @@ func TestNewFinalizer(t *testing.T) { poolMock.On("GetLastSentFlushID", context.Background()).Return(uint64(0), nil) // arrange and act - f = newFinalizer(cfg, poolCfg, workerMock, poolMock, stateMock, ethermanMock, seqAddr, isSynced, bc, eventLog, nil, newTimeoutCond(&sync.Mutex{}), nil) + f = newFinalizer(cfg, poolCfg, workerMock, poolMock, stateMock, ethermanMock, l2Coinbase, isSynced, bc, eventLog, nil, newTimeoutCond(&sync.Mutex{}), nil) // assert assert.NotNil(t, f) @@ -125,7 +125,7 @@ func TestNewFinalizer(t *testing.T) { assert.Equal(t, f.workerIntf, workerMock) assert.Equal(t, poolMock, poolMock) assert.Equal(t, f.stateIntf, stateMock) - assert.Equal(t, f.sequencerAddress, seqAddr) + assert.Equal(t, f.l2Coinbase, l2Coinbase) assert.Equal(t, f.batchConstraints, bc) } @@ -2197,7 +2197,7 @@ func setupFinalizer(withWipBatch bool) *finalizer { } wipBatch = &Batch{ batchNumber: 1, - coinbase: seqAddr, + coinbase: l2Coinbase, initialStateRoot: oldHash, imStateRoot: newHash, timestamp: now(), @@ -2213,7 +2213,7 @@ func setupFinalizer(withWipBatch bool) *finalizer { return &finalizer{ cfg: cfg, isSynced: isSynced, - sequencerAddress: seqAddr, + l2Coinbase: l2Coinbase, workerIntf: workerMock, poolIntf: poolMock, stateIntf: stateMock, diff --git a/sequencer/forcedbatch.go b/sequencer/forcedbatch.go index 21a0c92504..abe15acc77 100644 --- a/sequencer/forcedbatch.go +++ b/sequencer/forcedbatch.go @@ -85,7 +85,7 @@ func (f *finalizer) processForcedBatch(ctx context.Context, forcedBatch state.Fo // Open new batch on state for the forced batch processingCtx := state.ProcessingContext{ BatchNumber: newBatchNumber, - Coinbase: f.sequencerAddress, + Coinbase: f.l2Coinbase, Timestamp: time.Now(), GlobalExitRoot: forcedBatch.GlobalExitRoot, ForcedBatchNum: &forcedBatch.ForcedBatchNumber, @@ -101,7 +101,7 @@ func (f *finalizer) processForcedBatch(ctx context.Context, forcedBatch state.Fo ForcedBlockHashL1: fbL1Block.ParentHash, OldStateRoot: stateRoot, Transactions: forcedBatch.RawTxsData, - Coinbase: f.sequencerAddress, + Coinbase: f.l2Coinbase, TimestampLimit_V2: uint64(forcedBatch.ForcedAt.Unix()), ForkID: f.stateIntf.GetForkIDByBatchNumber(lastBatchNumber), SkipVerifyL1InfoRoot_V2: true, diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index a86d955d79..72a79cabcb 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -12,7 +12,6 @@ import ( "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/datastream" - "github.com/ethereum/go-ethereum/common" "google.golang.org/protobuf/proto" ) @@ -38,18 +37,11 @@ type Sequencer struct { streamServer *datastreamer.StreamServer dataToStream chan interface{} - address common.Address - numberOfStateInconsistencies uint64 } // New init sequencer 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) - } - sequencer := &Sequencer{ cfg: cfg, batchCfg: batchCfg, @@ -57,7 +49,6 @@ func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txP pool: txPool, stateIntf: stateIntf, etherman: etherman, - address: addr, eventLog: eventLog, } @@ -101,7 +92,7 @@ func (s *Sequencer) Start(ctx context.Context) { s.workerReadyTxsCond = newTimeoutCond(&sync.Mutex{}) s.worker = NewWorker(s.stateIntf, s.batchCfg.Constraints, s.workerReadyTxsCond) - s.finalizer = newFinalizer(s.cfg.Finalizer, s.poolCfg, s.worker, s.pool, s.stateIntf, s.etherman, s.address, s.isSynced, s.batchCfg.Constraints, s.eventLog, s.streamServer, s.workerReadyTxsCond, s.dataToStream) + s.finalizer = newFinalizer(s.cfg.Finalizer, s.poolCfg, s.worker, s.pool, s.stateIntf, s.etherman, s.cfg.L2Coinbase, s.isSynced, s.batchCfg.Constraints, s.eventLog, s.streamServer, s.workerReadyTxsCond, s.dataToStream) go s.finalizer.Start(ctx) go s.loadFromPool(ctx) From 8e6b6cf61cb20e2330cb097884f58076c306c42c Mon Sep 17 00:00:00 2001 From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Date: Thu, 23 May 2024 11:41:04 +0200 Subject: [PATCH 10/23] Feature/3640 synchronizer choose to sync from l2 (#3641) * #3640. New Param Synchronizer.L2Synchronization.Enable to choose if sync from L2 --- config/config_test.go | 4 ++++ config/default.go | 1 + docs/config-file/node-config-doc.md | 20 +++++++++++++++++--- docs/config-file/node-config-schema.json | 5 +++++ synchronizer/l2_sync/config.go | 2 ++ synchronizer/synchronizer.go | 9 ++++++--- synchronizer/synchronizer_test.go | 22 ++++++++++++++++++++++ 7 files changed, 57 insertions(+), 6 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index a8d850be0e..aa78a4a316 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -69,6 +69,10 @@ func Test_Defaults(t *testing.T) { path: "Synchronizer.L2Synchronization.DataSourcePriority", expectedValue: []dataavailability.DataSourcePriority{"local", "trusted", "external"}, }, + { + path: "Synchronizer.L2Synchronization.Enable", + expectedValue: true, + }, { path: "Sequencer.DeletePoolTxsL1BlockConfirmations", expectedValue: uint64(100), diff --git a/config/default.go b/config/default.go index 8d20f0b900..0399a37708 100644 --- a/config/default.go +++ b/config/default.go @@ -129,6 +129,7 @@ L1SyncCheckL2BlockNumberhModulus = 600 AceptableInacctivityTime = "5s" ApplyAfterNumRollupReceived = 10 [Synchronizer.L2Synchronization] + Enable = true AcceptEmptyClosedBatches = false ReprocessFullBatchOnClose = false CheckLastL2BlockHashOnCloseBatch = true diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md index 8549afee67..35d55c4af2 100644 --- a/docs/config-file/node-config-doc.md +++ b/docs/config-file/node-config-doc.md @@ -1881,7 +1881,21 @@ FallbackToSequentialModeOnSynchronized=false | - [CheckLastL2BlockHashOnCloseBatch](#Synchronizer_L2Synchronization_CheckLastL2BlockHashOnCloseBatch ) | No | boolean | No | - | CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash | | - [DataSourcePriority](#Synchronizer_L2Synchronization_DataSourcePriority ) | No | array of string | No | - | DataSourcePriority defines the order in which L2 batch should be retrieved: local, trusted, external | -#### 9.10.1. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches` +#### 9.10.1. `Synchronizer.L2Synchronization.Enable` + +**Type:** : `boolean` + +**Default:** `true` + +**Description:** Enable if is true then the L2 sync process is permitted (only for permissionless) + +**Example setting the default value** (true): +``` +[Synchronizer.L2Synchronization] +Enable=true +``` + +#### 9.10.2. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches` **Type:** : `boolean` @@ -1896,7 +1910,7 @@ if true, the synchronizer will accept empty batches and process them. AcceptEmptyClosedBatches=false ``` -#### 9.10.2. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose` +#### 9.10.3. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose` **Type:** : `boolean` @@ -1910,7 +1924,7 @@ AcceptEmptyClosedBatches=false ReprocessFullBatchOnClose=false ``` -#### 9.10.3. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch` +#### 9.10.4. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch` **Type:** : `boolean` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index b33ce420f7..9b325b4e19 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -698,6 +698,11 @@ }, "L2Synchronization": { "properties": { + "Enable": { + "type": "boolean", + "description": "Enable if is true then the L2 sync process is permitted (only for permissionless)", + "default": true + }, "AcceptEmptyClosedBatches": { "type": "boolean", "description": "AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.\nif true, the synchronizer will accept empty batches and process them.", diff --git a/synchronizer/l2_sync/config.go b/synchronizer/l2_sync/config.go index 8addfb09b1..39f4bf1918 100644 --- a/synchronizer/l2_sync/config.go +++ b/synchronizer/l2_sync/config.go @@ -4,6 +4,8 @@ import "github.com/0xPolygonHermez/zkevm-node/dataavailability" // Config configuration of L2 sync process type Config struct { + // Enable if is true then the L2 sync process is permitted (only for permissionless) + Enable bool `mapstructure:"Enable"` // AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches. // if true, the synchronizer will accept empty batches and process them. AcceptEmptyClosedBatches bool `mapstructure:"AcceptEmptyClosedBatches"` diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index f29421aad6..22fac2d538 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -151,7 +151,7 @@ func NewSynchronizer( time.Second) } - if !isTrustedSequencer { + if !isTrustedSequencer && cfg.L2Synchronization.Enable { log.Info("Permissionless: creating and Initializing L2 synchronization components") L1SyncChecker := l2_sync_etrog.NewCheckSyncStatusToProcessBatch(res.zkEVMClient, res.state) sync := &res @@ -170,7 +170,10 @@ func NewSynchronizer( uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog, uint64(state.FORKID_9): syncTrustedStateEtrog, }, res.state) + } else { + log.Info("L2 synchronization disabled or running in trusted sequencer mode") } + var l1checkerL2Blocks *actions.CheckL2BlockHash if cfg.L1SyncCheckL2BlockHash { if !isTrustedSequencer { @@ -443,7 +446,7 @@ func (s *ClientSynchronizer) Sync() error { // latestSequencedBatchNumber -> last batch on SMC if latestSyncedBatch >= latestSequencedBatchNumber { startTrusted := time.Now() - if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { + if s.syncTrustedStateExecutor != nil { log.Info("Syncing trusted state (permissionless)") //Sync Trusted State log.Debug("Doing reorg check before L2 sync") @@ -801,7 +804,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma } func (s *ClientSynchronizer) syncTrustedState(latestSyncedBatch uint64) error { - if s.syncTrustedStateExecutor == nil || s.isTrustedSequencer { + if s.syncTrustedStateExecutor == nil { return nil } diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 47143e2026..9959f50076 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -16,6 +16,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" "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/l2_sync" syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" "github.com/ethereum/go-ethereum/common" ethTypes "github.com/ethereum/go-ethereum/core/types" @@ -132,6 +133,9 @@ func TestForcedBatchEtrog(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -677,6 +681,9 @@ func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { RollupInfoRetriesSpacing: cfgTypes.Duration{Duration: 1 * time.Second}, FallbackToSequentialModeOnSynchronized: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -933,6 +940,9 @@ func TestReorg(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -1253,6 +1263,9 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -1467,6 +1480,9 @@ func TestRegularReorg(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -1749,6 +1765,9 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ @@ -2025,6 +2044,9 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) { L1BlockCheck: L1BlockCheckConfig{ Enable: false, }, + L2Synchronization: l2_sync.Config{ + Enable: true, + }, } m := mocks{ From 8e34cc2067750437275c9f0140eafdf94381ec11 Mon Sep 17 00:00:00 2001 From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Date: Mon, 27 May 2024 13:34:15 +0200 Subject: [PATCH 11/23] change synchronization config params 'Enable' to 'Enabled' (#3656) * change 'Enable' to 'Enabled' on sync config and changed comments --- config/config_test.go | 10 ++++++++- config/default.go | 6 +++--- docs/config-file/node-config-doc.html | 2 +- docs/config-file/node-config-doc.md | 22 ++++++++++---------- docs/config-file/node-config-schema.json | 12 +++++------ synchronizer/config.go | 10 ++++----- synchronizer/l2_sync/config.go | 4 ++-- synchronizer/synchronizer.go | 6 +++--- synchronizer/synchronizer_test.go | 26 ++++++++++++------------ 9 files changed, 53 insertions(+), 45 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index aa78a4a316..d887003d2f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -70,7 +70,15 @@ func Test_Defaults(t *testing.T) { expectedValue: []dataavailability.DataSourcePriority{"local", "trusted", "external"}, }, { - path: "Synchronizer.L2Synchronization.Enable", + path: "Synchronizer.L1BlockCheck.Enabled", + expectedValue: true, + }, + { + path: "Synchronizer.L1BlockCheck.PreCheckEnabled", + expectedValue: true, + }, + { + path: "Synchronizer.L2Synchronization.Enabled", expectedValue: true, }, { diff --git a/config/default.go b/config/default.go index 0399a37708..7fa767c15e 100644 --- a/config/default.go +++ b/config/default.go @@ -108,11 +108,11 @@ L1SynchronizationMode = "sequential" L1SyncCheckL2BlockHash = true L1SyncCheckL2BlockNumberhModulus = 600 [Synchronizer.L1BlockCheck] - Enable = true + Enabled = true L1SafeBlockPoint = "finalized" L1SafeBlockOffset = 0 ForceCheckBeforeStart = true - PreCheckEnable = true + PreCheckEnabled = true L1PreSafeBlockPoint = "safe" L1PreSafeBlockOffset = 0 [Synchronizer.L1ParallelSynchronization] @@ -129,7 +129,7 @@ L1SyncCheckL2BlockNumberhModulus = 600 AceptableInacctivityTime = "5s" ApplyAfterNumRollupReceived = 10 [Synchronizer.L2Synchronization] - Enable = true + Enabled = true AcceptEmptyClosedBatches = false ReprocessFullBatchOnClose = false CheckLastL2BlockHashOnCloseBatch = true diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index bba3d2684a..9897a5b38d 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: 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"
+

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

If enabled 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

If enabled 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 35d55c4af2..24fa55c89e 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1466,26 +1466,26 @@ L1SyncCheckL2BlockNumberhModulus=600
 
 | 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                                                                                                                                                                                                |
+| - [Enabled](#Synchronizer_L1BlockCheck_Enabled )                             | No      | boolean          | No         | -          | If enabled 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 | +| - [PreCheckEnabled](#Synchronizer_L1BlockCheck_PreCheckEnabled ) | No | boolean | No | - | If enabled 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` +#### 9.7.1. `Synchronizer.L1BlockCheck.Enabled` **Type:** : `boolean` **Default:** `true` -**Description:** Enable if is true then the check l1 Block Hash is active +**Description:** If enabled then the check l1 Block Hash is active **Example setting the default value** (true): ``` [Synchronizer.L1BlockCheck] -Enable=true +Enabled=true ``` #### 9.7.2. `Synchronizer.L1BlockCheck.L1SafeBlockPoint` @@ -1538,18 +1538,18 @@ L1SafeBlockOffset=0 ForceCheckBeforeStart=true ``` -#### 9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnable` +#### 9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnabled` **Type:** : `boolean` **Default:** `true` -**Description:** PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock +**Description:** If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock **Example setting the default value** (true): ``` [Synchronizer.L1BlockCheck] -PreCheckEnable=true +PreCheckEnabled=true ``` #### 9.7.6. `Synchronizer.L1BlockCheck.L1PreSafeBlockPoint` @@ -1881,18 +1881,18 @@ FallbackToSequentialModeOnSynchronized=false | - [CheckLastL2BlockHashOnCloseBatch](#Synchronizer_L2Synchronization_CheckLastL2BlockHashOnCloseBatch ) | No | boolean | No | - | CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash | | - [DataSourcePriority](#Synchronizer_L2Synchronization_DataSourcePriority ) | No | array of string | No | - | DataSourcePriority defines the order in which L2 batch should be retrieved: local, trusted, external | -#### 9.10.1. `Synchronizer.L2Synchronization.Enable` +#### 9.10.1. `Synchronizer.L2Synchronization.Enabled` **Type:** : `boolean` **Default:** `true` -**Description:** Enable if is true then the L2 sync process is permitted (only for permissionless) +**Description:** If enabled then the L2 sync process is permitted (only for permissionless) **Example setting the default value** (true): ``` [Synchronizer.L2Synchronization] -Enable=true +Enabled=true ``` #### 9.10.2. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index 9b325b4e19..9ed804cba0 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -539,9 +539,9 @@ }, "L1BlockCheck": { "properties": { - "Enable": { + "Enabled": { "type": "boolean", - "description": "Enable if is true then the check l1 Block Hash is active", + "description": "If enabled then the check l1 Block Hash is active", "default": true }, "L1SafeBlockPoint": { @@ -564,9 +564,9 @@ "description": "ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks", "default": true }, - "PreCheckEnable": { + "PreCheckEnabled": { "type": "boolean", - "description": "PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock", + "description": "If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock", "default": true }, "L1PreSafeBlockPoint": { @@ -698,9 +698,9 @@ }, "L2Synchronization": { "properties": { - "Enable": { + "Enabled": { "type": "boolean", - "description": "Enable if is true then the L2 sync process is permitted (only for permissionless)", + "description": "If enabled then the L2 sync process is permitted (only for permissionless)", "default": true }, "AcceptEmptyClosedBatches": { diff --git a/synchronizer/config.go b/synchronizer/config.go index ef51d41308..4ca64414f7 100644 --- a/synchronizer/config.go +++ b/synchronizer/config.go @@ -37,8 +37,8 @@ type Config struct { // 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"` + // If enabled then the check l1 Block Hash is active + Enabled bool `mapstructure:"Enabled"` // 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"` @@ -49,8 +49,8 @@ type L1BlockCheckConfig struct { // 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"` + // If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock + PreCheckEnabled bool `mapstructure:"PreCheckEnabled"` // 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"` @@ -61,7 +61,7 @@ type L1BlockCheckConfig struct { } func (c *L1BlockCheckConfig) String() string { - return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enable, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart) + return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enabled, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart) } // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') diff --git a/synchronizer/l2_sync/config.go b/synchronizer/l2_sync/config.go index 39f4bf1918..fcafeafaad 100644 --- a/synchronizer/l2_sync/config.go +++ b/synchronizer/l2_sync/config.go @@ -4,8 +4,8 @@ import "github.com/0xPolygonHermez/zkevm-node/dataavailability" // Config configuration of L2 sync process type Config struct { - // Enable if is true then the L2 sync process is permitted (only for permissionless) - Enable bool `mapstructure:"Enable"` + // If enabled then the L2 sync process is permitted (only for permissionless) + Enabled bool `mapstructure:"Enabled"` // AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches. // if true, the synchronizer will accept empty batches and process them. AcceptEmptyClosedBatches bool `mapstructure:"AcceptEmptyClosedBatches"` diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 22fac2d538..33e7feb1f2 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -125,13 +125,13 @@ func NewSynchronizer( syncBlockProtection: syncBlockProtection, halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd } - if cfg.L1BlockCheck.Enable { + if cfg.L1BlockCheck.Enabled { 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 { + if cfg.L1BlockCheck.PreCheckEnabled { log.Infof("L1BlockChecker enabled precheck from: %s/%d to: %s/%d", cfg.L1BlockCheck.L1SafeBlockPoint, cfg.L1BlockCheck.L1SafeBlockOffset, cfg.L1BlockCheck.L1PreSafeBlockPoint, cfg.L1BlockCheck.L1PreSafeBlockOffset) @@ -151,7 +151,7 @@ func NewSynchronizer( time.Second) } - if !isTrustedSequencer && cfg.L2Synchronization.Enable { + if !isTrustedSequencer && cfg.L2Synchronization.Enabled { log.Info("Permissionless: creating and Initializing L2 synchronization components") L1SyncChecker := l2_sync_etrog.NewCheckSyncStatusToProcessBatch(res.zkEVMClient, res.state) sync := &res diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 9959f50076..90c0e01acd 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -131,10 +131,10 @@ func TestForcedBatchEtrog(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -682,7 +682,7 @@ func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { FallbackToSequentialModeOnSynchronized: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -938,10 +938,10 @@ func TestReorg(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -1261,10 +1261,10 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -1478,10 +1478,10 @@ func TestRegularReorg(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -1763,10 +1763,10 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } @@ -2042,10 +2042,10 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) { L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", L1BlockCheck: L1BlockCheckConfig{ - Enable: false, + Enabled: false, }, L2Synchronization: l2_sync.Config{ - Enable: true, + Enabled: true, }, } From 977d64e6845afce3e2bd1f5c3367bd097f8c21c7 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Mon, 27 May 2024 16:50:06 +0200 Subject: [PATCH 12/23] Cherry-pick #3650: Do fatal when datastream channel is full (workaround to fix datastream blocking issue) (#3654) * Do fatal when datastream channel is full (workaround to fix datastream blocking issue) (#3650) * Do fatal when datastream channel is full (this will restart sequencer automatically) * update datastream library (more ds-debug logs) * fix decrease DataToStreamChannelCount --- go.mod | 2 +- go.sum | 4 ++-- sequencer/batch.go | 6 +++--- sequencer/datastreamer.go | 35 +++++++++++++++++++++++++++++------ sequencer/finalizer.go | 10 ++++++++-- sequencer/forcedbatch.go | 2 +- sequencer/l2block.go | 11 +---------- sequencer/sequencer.go | 24 ++++-------------------- 8 files changed, 49 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index 046855af4d..03642ff6ae 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.2.3-0.20240426122934-6f47d2485fc1 + github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240527085154-ca3561dd370b 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 diff --git a/go.sum b/go.sum index f56238aada..7679f950b4 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.2.3-0.20240426122934-6f47d2485fc1 h1:4wbCJOGcZ8BTuOfNFrcZ1cAVfTWaX1W9EYHaDx3imLc= -github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1/go.mod h1:0QkAXcFa92mFJrCbN3UPUJGJYes851yEgYHLONnaosE= +github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240527085154-ca3561dd370b h1:BzQRXbSnW7BsFvJrnZbCgnxD5+nCGyrYUgqH+3vsnrM= +github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240527085154-ca3561dd370b/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= diff --git a/sequencer/batch.go b/sequencer/batch.go index a5ada2b61a..b7cb731fe5 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -338,9 +338,9 @@ func (f *finalizer) insertSIPBatch(ctx context.Context, batchNumber uint64, stat } // Send batch bookmark to the datastream - f.DSSendBatchBookmark(batchNumber) + f.DSSendBatchBookmark(ctx, batchNumber) // Send batch start to the datastream - f.DSSendBatchStart(batchNumber, false) + f.DSSendBatchStart(ctx, batchNumber, false) // Check if synchronizer is up-to-date //TODO: review if this is needed @@ -406,7 +406,7 @@ func (f *finalizer) closeSIPBatch(ctx context.Context, dbTx pgx.Tx) error { } // Sent batch to DS - f.DSSendBatchEnd(f.sipBatch.batchNumber, f.sipBatch.finalStateRoot, f.sipBatch.finalLocalExitRoot) + f.DSSendBatchEnd(ctx, f.sipBatch.batchNumber, f.sipBatch.finalStateRoot, f.sipBatch.finalLocalExitRoot) log.Infof("sip batch %d closed in statedb, closing reason: %s", f.sipBatch.batchNumber, f.sipBatch.closingReason) diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 50321c6c55..8330c8b11c 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -1,13 +1,15 @@ package sequencer import ( - "github.com/0xPolygonHermez/zkevm-node/log" + "context" + "fmt" + "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/datastream" "github.com/ethereum/go-ethereum/common" ) -func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64) error { +func (f *finalizer) DSSendL2Block(ctx context.Context, batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64) error { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) // Send data to streamer @@ -52,28 +54,35 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce l2Transactions = append(l2Transactions, l2Transaction) } - log.Infof("[ds-debug] sending l2block %d to datastream channel", blockResponse.BlockNumber) + f.checkDSBufferIsFull(ctx) + f.dataToStream <- state.DSL2FullBlock{ DSL2Block: l2Block, Txs: l2Transactions, } + + f.dataToStreamCount.Add(1) } return nil } -func (f *finalizer) DSSendBatchBookmark(batchNumber uint64) { +func (f *finalizer) DSSendBatchBookmark(ctx context.Context, batchNumber uint64) { // Check if stream server enabled if f.streamServer != nil { + f.checkDSBufferIsFull(ctx) + // Send batch bookmark to the streamer f.dataToStream <- datastream.BookMark{ Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH, Value: batchNumber, } + + f.dataToStreamCount.Add(1) } } -func (f *finalizer) DSSendBatchStart(batchNumber uint64, isForced bool) { +func (f *finalizer) DSSendBatchStart(ctx context.Context, batchNumber uint64, isForced bool) { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) batchStart := datastream.BatchStart{ @@ -88,18 +97,32 @@ func (f *finalizer) DSSendBatchStart(batchNumber uint64, isForced bool) { } if f.streamServer != nil { + f.checkDSBufferIsFull(ctx) + // Send batch start to the streamer f.dataToStream <- batchStart + + f.dataToStreamCount.Add(1) } } -func (f *finalizer) DSSendBatchEnd(batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) { +func (f *finalizer) DSSendBatchEnd(ctx context.Context, batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) { if f.streamServer != nil { + f.checkDSBufferIsFull(ctx) + // Send batch end to the streamer f.dataToStream <- datastream.BatchEnd{ Number: batchNumber, StateRoot: stateRoot.Bytes(), LocalExitRoot: localExitRoot.Bytes(), } + + f.dataToStreamCount.Add(1) + } +} + +func (f *finalizer) checkDSBufferIsFull(ctx context.Context) { + if f.dataToStreamCount.Load() == datastreamChannelBufferSize { + f.Halt(ctx, fmt.Errorf("datastream channel buffer full"), true) } } diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index 11692d16f2..00ca6421a2 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -83,8 +83,9 @@ type finalizer struct { // interval metrics metrics *intervalMetrics // stream server - streamServer *datastreamer.StreamServer - dataToStream chan interface{} + streamServer *datastreamer.StreamServer + dataToStream chan interface{} + dataToStreamCount atomic.Int32 } // newFinalizer returns a new instance of Finalizer. @@ -886,6 +887,11 @@ func (f *finalizer) logZKCounters(counters state.ZKCounters) string { counters.Binaries, counters.Sha256Hashes_V2, counters.Steps) } +// Decrease datastreamChannelCount variable +func (f *finalizer) DataToStreamChannelCountAdd(ct int32) { + f.dataToStreamCount.Add(ct) +} + // Halt halts the finalizer func (f *finalizer) Halt(ctx context.Context, err error, isFatal bool) { f.haltFinalizer.Store(true) diff --git a/sequencer/forcedbatch.go b/sequencer/forcedbatch.go index abe15acc77..a9707fd8db 100644 --- a/sequencer/forcedbatch.go +++ b/sequencer/forcedbatch.go @@ -198,7 +198,7 @@ func (f *finalizer) handleProcessForcedBatchResponse(ctx context.Context, newBat } // Send L2 block to data streamer - err = f.DSSendL2Block(newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp) + err = f.DSSendL2Block(ctx, newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d to data streamer, error: %v", forcedL2BlockResponse.BlockNumber, err) diff --git a/sequencer/l2block.go b/sequencer/l2block.go index c5b99ceed0..4d13219ace 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -482,9 +482,6 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { return err } - //TODO: remove this Log - log.Infof("[ds-debug] 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 @@ -494,19 +491,13 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { } } - //TODO: remove this log - log.Infof("[ds-debug] l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum) - // Send L2 block to data streamer - err = f.DSSendL2Block(l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp) + err = f.DSSendL2Block(ctx, l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) } - //TODO: remove this log - log.Infof("[ds-debug] 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.DeleteTxPendingToStore(tx.Hash, tx.From) diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index 72a79cabcb..9eda30cee3 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -16,7 +16,7 @@ import ( ) const ( - datastreamChannelMultiplier = 2 + datastreamChannelBufferSize = 20 ) // Sequencer represents a sequencer @@ -52,9 +52,7 @@ func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txP eventLog: eventLog, } - // TODO: Make configurable - channelBufferSize := 200 * datastreamChannelMultiplier // nolint:gomnd - sequencer.dataToStream = make(chan interface{}, channelBufferSize) + sequencer.dataToStream = make(chan interface{}, datastreamChannelBufferSize) return sequencer, nil } @@ -257,14 +255,14 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { // Read data from channel dataStream := <-s.dataToStream + s.finalizer.DataToStreamChannelCountAdd(-1) + if s.streamServer != nil { switch data := dataStream.(type) { // Stream a complete L2 block with its transactions case state.DSL2FullBlock: l2Block := data - //TODO: remove this log - log.Infof("[ds-debug] 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) @@ -276,8 +274,6 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { Value: l2Block.L2BlockNumber, } - //TODO: remove this log - log.Infof("[ds-debug] add stream bookmark for l2block %d", l2Block.L2BlockNumber) marshalledBookMark, err := proto.Marshal(bookMark) if err != nil { log.Errorf("failed to marshal bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) @@ -298,8 +294,6 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { Value: l2Block.L2BlockNumber - 1, } - //TODO: remove this log - log.Infof("[ds-debug] get previous l2block %d", l2Block.L2BlockNumber-1) marshalledBookMark, err := proto.Marshal(bookMark) if err != nil { log.Errorf("failed to marshal bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) @@ -339,16 +333,12 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { continue } - //TODO: remove this log - log.Infof("[ds-debug] add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber) _, err = s.streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK), marshalledL2Block) 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("[ds-debug] adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber) for _, l2Transaction := range l2Block.Txs { streamL2Transaction := &datastream.Transaction{ L2BlockNumber: l2Transaction.L2BlockNumber, @@ -371,17 +361,11 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { } } - //TODO: remove this log - log.Infof("[ds-debug] 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("[ds-debug] l2block %d sent to datastream", l2Block.L2BlockNumber) - // Stream a bookmark case datastream.BookMark: err = s.streamServer.StartAtomicOp() From a6d604684fafbc8158e173b773e04382678517b0 Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Tue, 28 May 2024 18:59:28 -0300 Subject: [PATCH 13/23] add optimistic gas computation while estimating gas (#3653) --- state/test/forkid_common/common.go | 2 +- state/transaction.go | 142 +++++++++++++++++++---------- test/e2e/jsonrpc1_test.go | 61 +++++++++++++ 3 files changed, 158 insertions(+), 47 deletions(-) diff --git a/state/test/forkid_common/common.go b/state/test/forkid_common/common.go index 478b7e0222..2275276cd0 100644 --- a/state/test/forkid_common/common.go +++ b/state/test/forkid_common/common.go @@ -53,7 +53,7 @@ func InitTestState(stateCfg state.Config) *state.State { panic(err) } - zkProverURI := testutils.GetEnv("ZKPROVER_URI", "zkevm-prover") + zkProverURI := testutils.GetEnv("ZKPROVER_URI", "localhost") executorServerConfig := executor.Config{URI: fmt.Sprintf("%s:50071", zkProverURI), MaxGRPCMessageSize: 100000000} ExecutorClient, executorClientConn, executorCancel = executor.NewExecutorClient(ctx, executorServerConfig) diff --git a/state/transaction.go b/state/transaction.go index f3045ebe40..0e2e36cf64 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" "github.com/google/uuid" "github.com/jackc/pgx/v4" @@ -22,6 +23,13 @@ import ( "google.golang.org/grpc/status" ) +type testGasEstimationResult struct { + failed, reverted, ooc bool + gasUsed, gasRefund uint64 + returnValue []byte + executionError error +} + // GetSender gets the sender from the transaction's signature func GetSender(tx types.Transaction) (common.Address, error) { signer := types.NewEIP155Signer(tx.ChainId()) @@ -807,18 +815,23 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common // Check if the highEnd is a good value to make the transaction pass, if it fails we // can return immediately. log.Debugf("Estimate gas. Trying to execute TX with %v gas", highEnd) - var failed, reverted bool - var gasUsed uint64 - var returnValue []byte + var estimationResult *testGasEstimationResult if forkID < FORKID_ETROG { - failed, reverted, gasUsed, returnValue, err = s.internalTestGasEstimationTransactionV1(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, highEnd, nonce, false) + estimationResult, err = s.internalTestGasEstimationTransactionV1(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, highEnd, nonce, false) } else { - failed, reverted, gasUsed, returnValue, err = s.internalTestGasEstimationTransactionV2(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, highEnd, nonce, false) + estimationResult, err = s.internalTestGasEstimationTransactionV2(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, highEnd, nonce, false) + } + if err != nil { + return 0, nil, err } - if failed { - if reverted { - return 0, returnValue, err + if estimationResult.failed { + if estimationResult.reverted { + return 0, estimationResult.returnValue, estimationResult.executionError + } + + if estimationResult.ooc { + return 0, nil, estimationResult.executionError } // The transaction shouldn't fail, for whatever reason, at highEnd @@ -829,8 +842,28 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common } // sets - if lowEnd < gasUsed { - lowEnd = gasUsed + if lowEnd < estimationResult.gasUsed { + lowEnd = estimationResult.gasUsed + } + + optimisticGasLimit := (estimationResult.gasUsed + estimationResult.gasRefund + params.CallStipend) * 64 / 63 // nolint:gomnd + if optimisticGasLimit < highEnd { + if forkID < FORKID_ETROG { + estimationResult, err = s.internalTestGasEstimationTransactionV1(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, optimisticGasLimit, nonce, false) + } else { + estimationResult, err = s.internalTestGasEstimationTransactionV2(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, optimisticGasLimit, nonce, false) + } + if err != nil { + // This should not happen under normal conditions since if we make it this far the + // transaction had run without error at least once before. + log.Error("Execution error in estimate gas", "err", err) + return 0, nil, err + } + if estimationResult.failed { + lowEnd = optimisticGasLimit + } else { + highEnd = optimisticGasLimit + } } // Start the binary search for the lowest possible gas price @@ -846,20 +879,20 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common log.Debugf("Estimate gas. Trying to execute TX with %v gas", mid) if forkID < FORKID_ETROG { - failed, reverted, _, _, err = s.internalTestGasEstimationTransactionV1(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, mid, nonce, true) + estimationResult, err = s.internalTestGasEstimationTransactionV1(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, mid, nonce, true) } else { - failed, reverted, _, _, err = s.internalTestGasEstimationTransactionV2(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, mid, nonce, true) + estimationResult, err = s.internalTestGasEstimationTransactionV2(ctx, batch, l2Block, latestL2BlockNumber, transaction, forkID, senderAddress, mid, nonce, true) } executionTime := time.Since(txExecutionStart) totalExecutionTime += executionTime txExecutions = append(txExecutions, executionTime) - if err != nil && !reverted { + if err != nil && !estimationResult.reverted { // Reverts are ignored in the binary search, but are checked later on // during the execution for the optimal gas limit found return 0, nil, err } - if failed { + if estimationResult.failed { // If the transaction failed => increase the gas lowEnd = mid + 1 } else { @@ -882,7 +915,7 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common // before ETROG func (s *State) internalTestGasEstimationTransactionV1(ctx context.Context, batch *Batch, l2Block *L2Block, latestL2BlockNumber uint64, transaction *types.Transaction, forkID uint64, senderAddress common.Address, - gas uint64, nonce uint64, shouldOmitErr bool) (failed, reverted bool, gasUsed uint64, returnValue []byte, err error) { + gas uint64, nonce uint64, shouldOmitErr bool) (*testGasEstimationResult, error) { timestamp := l2Block.Time() if l2Block.NumberU64() == latestL2BlockNumber { timestamp = uint64(time.Now().Unix()) @@ -900,7 +933,7 @@ func (s *State) internalTestGasEstimationTransactionV1(ctx context.Context, batc batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) if err != nil { log.Errorf("error encoding unsigned transaction ", err) - return false, false, gasUsed, nil, err + return nil, err } // Create a batch to be sent to the executor @@ -939,38 +972,44 @@ func (s *State) internalTestGasEstimationTransactionV1(ctx context.Context, batc log.Debugf("executor time: %vms", time.Since(txExecutionOnExecutorTime).Milliseconds()) if err != nil { log.Errorf("error estimating gas: %v", err) - return false, false, gasUsed, nil, err + return nil, err } if processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { err = executor.ExecutorErr(processBatchResponse.Error) s.eventLog.LogExecutorError(ctx, processBatchResponse.Error, processBatchRequestV1) - return false, false, gasUsed, nil, err + return nil, err } - gasUsed = processBatchResponse.Responses[0].GasUsed txResponse := processBatchResponse.Responses[0] + result := &testGasEstimationResult{} + result.gasUsed = txResponse.GasUsed + result.gasRefund = txResponse.GasRefunded // Check if an out of gas error happened during EVM execution if txResponse.Error != executor.RomError_ROM_ERROR_NO_ERROR { - err := executor.RomErr(txResponse.Error) + result.failed = true + result.executionError = executor.RomErr(txResponse.Error) - if (isGasEVMError(err) || isGasApplyError(err)) && shouldOmitErr { + if (isGasEVMError(result.executionError) || isGasApplyError(result.executionError)) && shouldOmitErr { // Specifying the transaction failed, but not providing an error // is an indication that a valid error occurred due to low gas, // which will increase the lower bound for the search - return true, false, gasUsed, nil, nil - } - - if isEVMRevertError(err) { + return result, nil + } else if isEVMRevertError(result.executionError) { // The EVM reverted during execution, attempt to extract the // error message and return it - returnValue := txResponse.ReturnValue - return true, true, gasUsed, returnValue, ConstructErrorFromRevert(err, returnValue) + result.reverted = true + result.returnValue = txResponse.ReturnValue + result.executionError = ConstructErrorFromRevert(err, txResponse.ReturnValue) + } else if isOOCError(result.executionError) { + // The EVM got into an OOC error + result.ooc = true + return result, nil } - return true, false, gasUsed, nil, err + return result, nil } - return false, false, gasUsed, nil, nil + return result, nil } // internalTestGasEstimationTransactionV2 is used by the EstimateGas to test the tx execution @@ -978,7 +1017,7 @@ func (s *State) internalTestGasEstimationTransactionV1(ctx context.Context, batc // after ETROG func (s *State) internalTestGasEstimationTransactionV2(ctx context.Context, batch *Batch, l2Block *L2Block, latestL2BlockNumber uint64, transaction *types.Transaction, forkID uint64, senderAddress common.Address, - gas uint64, nonce uint64, shouldOmitErr bool) (failed, reverted bool, gasUsed uint64, returnValue []byte, err error) { + gas uint64, nonce uint64, shouldOmitErr bool) (*testGasEstimationResult, error) { deltaTimestamp := uint32(uint64(time.Now().Unix()) - l2Block.Time()) transactions := s.BuildChangeL2Block(deltaTimestamp, uint32(0)) @@ -994,7 +1033,7 @@ func (s *State) internalTestGasEstimationTransactionV2(ctx context.Context, batc batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) if err != nil { log.Errorf("error encoding unsigned transaction ", err) - return false, false, gasUsed, nil, err + return nil, err } transactions = append(transactions, batchL2Data...) @@ -1040,43 +1079,48 @@ func (s *State) internalTestGasEstimationTransactionV2(ctx context.Context, batc log.Debugf("executor time: %vms", time.Since(txExecutionOnExecutorTime).Milliseconds()) if err != nil { log.Errorf("error estimating gas: %v", err) - return false, false, gasUsed, nil, err + return nil, err } if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { err = executor.ExecutorErr(processBatchResponseV2.Error) s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) - return false, false, gasUsed, nil, err + return nil, err } if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { err = executor.RomErr(processBatchResponseV2.ErrorRom) - return false, false, gasUsed, nil, err + return nil, err } - gasUsed = processBatchResponseV2.BlockResponses[0].GasUsed - txResponse := processBatchResponseV2.BlockResponses[0].Responses[0] + result := &testGasEstimationResult{} + result.gasUsed = txResponse.GasUsed + result.gasRefund = txResponse.GasRefunded // Check if an out of gas error happened during EVM execution if txResponse.Error != executor.RomError_ROM_ERROR_NO_ERROR { - err := executor.RomErr(txResponse.Error) + result.failed = true + result.executionError = executor.RomErr(txResponse.Error) - if (isGasEVMError(err) || isGasApplyError(err)) && shouldOmitErr { + if (isGasEVMError(result.executionError) || isGasApplyError(result.executionError)) && shouldOmitErr { // Specifying the transaction failed, but not providing an error // is an indication that a valid error occurred due to low gas, // which will increase the lower bound for the search - return true, false, gasUsed, nil, nil - } - - if isEVMRevertError(err) { + return result, nil + } else if isEVMRevertError(result.executionError) { // The EVM reverted during execution, attempt to extract the // error message and return it - returnValue := txResponse.ReturnValue - return true, true, gasUsed, returnValue, ConstructErrorFromRevert(err, returnValue) + result.reverted = true + result.returnValue = txResponse.ReturnValue + result.executionError = ConstructErrorFromRevert(result.executionError, txResponse.ReturnValue) + } else if isOOCError(result.executionError) { + // The EVM got into an OOC error + result.ooc = true + return result, nil } - return true, false, gasUsed, nil, err + return result, nil } - return false, false, gasUsed, nil, nil + return result, nil } // Checks if executor level valid gas errors occurred @@ -1093,3 +1137,9 @@ func isGasEVMError(err error) bool { func isEVMRevertError(err error) bool { return errors.Is(err, runtime.ErrExecutionReverted) } + +// Checks if the EVM stopped tx execution due to OOC error +func isOOCError(err error) bool { + romErr := executor.RomErrorCode(err) + return executor.IsROMOutOfCountersError(romErr) +} diff --git a/test/e2e/jsonrpc1_test.go b/test/e2e/jsonrpc1_test.go index c0c867bb50..5267d32208 100644 --- a/test/e2e/jsonrpc1_test.go +++ b/test/e2e/jsonrpc1_test.go @@ -6,6 +6,7 @@ import ( "math/big" "reflect" "testing" + "time" "github.com/0xPolygonHermez/zkevm-node/hex" "github.com/0xPolygonHermez/zkevm-node/jsonrpc/client" @@ -791,3 +792,63 @@ func Test_EstimateCounters(t *testing.T) { }) } } + +func Test_Gas_Bench2(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.Background() + setup() + defer teardown() + ethClient, err := ethclient.Dial(operations.DefaultL2NetworkURL) + require.NoError(t, err) + auth, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID) + require.NoError(t, err) + + type testCase struct { + name string + execute func(*testing.T, context.Context, *triggerErrors.TriggerErrors, *ethclient.Client, bind.TransactOpts) string + expectedError string + } + + testCases := []testCase{ + { + name: "estimate gas with given gas limit", + execute: func(t *testing.T, ctx context.Context, sc *triggerErrors.TriggerErrors, c *ethclient.Client, a bind.TransactOpts) string { + a.GasLimit = 30000000 + a.NoSend = true + tx, err := sc.OutOfCountersPoseidon(&a) + require.NoError(t, err) + + t0 := time.Now() + _, err = c.EstimateGas(ctx, ethereum.CallMsg{ + From: a.From, + To: tx.To(), + Gas: tx.Gas(), + GasPrice: tx.GasPrice(), + Value: tx.Value(), + Data: tx.Data(), + }) + log.Infof("EstimateGas time: %v", time.Since(t0)) + if err != nil { + return err.Error() + } + return "" + }, + expectedError: "", + }, + } + + // deploy triggerErrors SC + _, tx, sc, err := triggerErrors.DeployTriggerErrors(auth, ethClient) + require.NoError(t, err) + + err = operations.WaitTxToBeMined(ctx, ethClient, tx, operations.DefaultTimeoutTxToBeMined) + require.NoError(t, err) + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + testCase.execute(t, context.Background(), sc, ethClient, *auth) + }) + } +} From 74304e0edf9cbd7287587d6293f05c026da704ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Thu, 30 May 2024 11:49:55 +0200 Subject: [PATCH 14/23] Use Eth block hash for l2 blocks in data stream (#3661) * Use Eth block hash for l2 blocks in data stream * handle minTimestamp --- sequencer/datastreamer.go | 10 +++++-- sequencer/forcedbatch.go | 4 +-- sequencer/interfaces.go | 2 +- sequencer/l2block.go | 4 +-- sequencer/mock_state.go | 22 +++++++++++---- sequencer/sequencer.go | 2 +- state/batchV2.go | 2 +- state/datastream.go | 16 ++++++++--- state/transaction.go | 10 +++---- .../mocks/state_full_interface.go | 28 +++++++++++++------ synchronizer/common/syncinterfaces/state.go | 2 +- .../executor_trusted_batch_sync.go | 4 +-- .../l2_sync_etrog/mocks/state_interface.go | 28 +++++++++++++------ synchronizer/synchronizer_test.go | 2 +- 14 files changed, 92 insertions(+), 44 deletions(-) diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 8330c8b11c..0766ed348e 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (f *finalizer) DSSendL2Block(ctx context.Context, batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64) error { +func (f *finalizer) DSSendL2Block(ctx context.Context, batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64, blockHash common.Hash) error { forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber) // Send data to streamer @@ -18,17 +18,21 @@ func (f *finalizer) DSSendL2Block(ctx context.Context, batchNumber uint64, block BatchNumber: batchNumber, L2BlockNumber: blockResponse.BlockNumber, Timestamp: blockResponse.Timestamp, - Min_timestamp: minTimestamp, + MinTimestamp: minTimestamp, L1InfoTreeIndex: l1InfoTreeIndex, L1BlockHash: blockResponse.BlockHashL1, GlobalExitRoot: blockResponse.GlobalExitRoot, Coinbase: f.l2Coinbase, ForkID: forkID, - BlockHash: blockResponse.BlockHash, + BlockHash: blockHash, StateRoot: blockResponse.BlockHash, //From etrog, the blockhash is the block root BlockInfoRoot: blockResponse.BlockInfoRoot, } + if l2Block.ForkID >= state.FORKID_ETROG && l2Block.L1InfoTreeIndex == 0 { + l2Block.MinTimestamp = 0 + } + l2Transactions := []state.DSL2Transaction{} for i, txResponse := range blockResponse.TransactionResponses { diff --git a/sequencer/forcedbatch.go b/sequencer/forcedbatch.go index a9707fd8db..de1082c347 100644 --- a/sequencer/forcedbatch.go +++ b/sequencer/forcedbatch.go @@ -180,7 +180,7 @@ func (f *finalizer) handleProcessForcedBatchResponse(ctx context.Context, newBat // process L2 blocks responses for the forced batch for _, forcedL2BlockResponse := range batchResponse.BlockResponses { // Store forced L2 blocks in the state - err := f.stateIntf.StoreL2Block(ctx, newBatchNumber, forcedL2BlockResponse, nil, dbTx) + blockHash, err := f.stateIntf.StoreL2Block(ctx, newBatchNumber, forcedL2BlockResponse, nil, dbTx) if err != nil { return fmt.Errorf("database error on storing L2 block %d, error: %v", forcedL2BlockResponse.BlockNumber, err) } @@ -198,7 +198,7 @@ func (f *finalizer) handleProcessForcedBatchResponse(ctx context.Context, newBat } // Send L2 block to data streamer - err = f.DSSendL2Block(ctx, newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp) + err = f.DSSendL2Block(ctx, newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp, blockHash) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d to data streamer, error: %v", forcedL2BlockResponse.BlockNumber, err) diff --git a/sequencer/interfaces.go b/sequencer/interfaces.go index c92f502e10..72beb71578 100644 --- a/sequencer/interfaces.go +++ b/sequencer/interfaces.go @@ -72,7 +72,7 @@ type stateInterface interface { GetDSL2Blocks(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, dbTx pgx.Tx) ([]*state.DSL2Block, error) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error) - StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error + StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error) GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) diff --git a/sequencer/l2block.go b/sequencer/l2block.go index 4d13219ace..d38b9be30b 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -425,7 +425,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { } // Store L2 block in the state - err = f.stateIntf.StoreL2Block(ctx, l2Block.batch.batchNumber, blockResponse, txsEGPLog, dbTx) + blockHash, err := f.stateIntf.StoreL2Block(ctx, l2Block.batch.batchNumber, blockResponse, txsEGPLog, dbTx) if err != nil { return rollbackOnError(fmt.Errorf("database error on storing L2 block %d [%d], error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)) } @@ -492,7 +492,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { } // Send L2 block to data streamer - err = f.DSSendL2Block(ctx, l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp) + err = f.DSSendL2Block(ctx, l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp, blockHash) if err != nil { //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) diff --git a/sequencer/mock_state.go b/sequencer/mock_state.go index f7f3861d4b..0c1edc59e5 100644 --- a/sequencer/mock_state.go +++ b/sequencer/mock_state.go @@ -1019,21 +1019,33 @@ func (_m *StateMock) ProcessBatchV2(ctx context.Context, request state.ProcessRe } // StoreL2Block provides a mock function with given fields: ctx, batchNumber, l2Block, txsEGPLog, dbTx -func (_m *StateMock) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error { +func (_m *StateMock) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) { ret := _m.Called(ctx, batchNumber, l2Block, txsEGPLog, dbTx) if len(ret) == 0 { panic("no return value specified for StoreL2Block") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) (common.Hash, error)); ok { + return rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) common.Hash); ok { r0 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.Hash) + } } - return r0 + if rf, ok := ret.Get(1).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + r1 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // UpdateBatchAsChecked provides a mock function with given fields: ctx, batchNumber, dbTx diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index 9eda30cee3..c573c09924 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -318,7 +318,7 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { BatchNumber: l2Block.BatchNumber, Timestamp: l2Block.Timestamp, DeltaTimestamp: uint32(l2Block.Timestamp - previousL2Block.Timestamp), - MinTimestamp: l2Block.Min_timestamp, + MinTimestamp: l2Block.MinTimestamp, L1Blockhash: l2Block.L1BlockHash.Bytes(), L1InfotreeIndex: l2Block.L1InfoTreeIndex, Hash: l2Block.BlockHash.Bytes(), diff --git a/state/batchV2.go b/state/batchV2.go index 5b8a6f2a97..7dfaa1b194 100644 --- a/state/batchV2.go +++ b/state/batchV2.go @@ -404,7 +404,7 @@ func (s *State) ProcessAndStoreClosedBatchV2(ctx context.Context, processingCtx if len(processedBatch.BlockResponses) > 0 && !processedBatch.IsRomOOCError && processedBatch.RomError_V2 == nil { for _, blockResponse := range processedBatch.BlockResponses { - err = s.StoreL2Block(ctx, processingCtx.BatchNumber, blockResponse, nil, dbTx) + _, err = s.StoreL2Block(ctx, processingCtx.BatchNumber, blockResponse, nil, dbTx) if err != nil { log.Errorf("%s error StoreL2Block: %v", debugPrefix, err) return common.Hash{}, noFlushID, noProverID, err diff --git a/state/datastream.go b/state/datastream.go index 90c7ff3211..09fa7184b1 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -49,7 +49,7 @@ type DSL2Block struct { BatchNumber uint64 L2BlockNumber uint64 Timestamp uint64 - Min_timestamp uint64 + MinTimestamp uint64 L1InfoTreeIndex uint32 L1BlockHash common.Hash GlobalExitRoot common.Hash @@ -512,14 +512,22 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre BlockGasLimit: l2Block.BlockGasLimit, } - if l2Block.ForkID >= FORKID_ETROG { - streamL2Block.Hash = l2Block.StateRoot.Bytes() - } + // Keep the l2 block hash as it is, as the state root can be found in the StateRoot field + // So disable this + /* + if l2Block.ForkID >= FORKID_ETROG { + streamL2Block.Hash = l2Block.StateRoot.Bytes() + } + */ if l2Block.ForkID == FORKID_ETROG && batch.EtrogTimestamp != nil { streamL2Block.MinTimestamp = uint64(batch.EtrogTimestamp.Unix()) } + if l2Block.ForkID >= FORKID_ETROG && l2Block.L1InfoTreeIndex == 0 { + streamL2Block.MinTimestamp = 0 + } + previousTimestamp = l2Block.Timestamp bookMark := &datastream.BookMark{ diff --git a/state/transaction.go b/state/transaction.go index 0e2e36cf64..ea12c23359 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -208,9 +208,9 @@ func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, proce } // StoreL2Block stores a l2 block into the state -func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *ProcessBlockResponse, txsEGPLog []*EffectiveGasPriceLog, dbTx pgx.Tx) error { +func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *ProcessBlockResponse, txsEGPLog []*EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) { if dbTx == nil { - return ErrDBTxNil + return common.Hash{}, ErrDBTxNil } log.Debugf("storing l2 block %d, txs %d, hash %s", l2Block.BlockNumber, len(l2Block.TransactionResponses), l2Block.BlockHash.String()) @@ -218,7 +218,7 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P prevL2BlockHash, err := s.GetL2BlockHashByNumber(ctx, l2Block.BlockNumber-1, dbTx) if err != nil { - return err + return common.Hash{}, err } forkID := s.GetForkIDByBatchNumber(batchNumber) @@ -289,12 +289,12 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P // Store L2 block and its transactions if err := s.AddL2Block(ctx, batchNumber, block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil { - return err + return common.Hash{}, err } log.Debugf("stored L2 block %d for batch %d, storing time %v", header.Number, batchNumber, time.Since(start)) - return nil + return block.Hash(), nil } // PreProcessUnsignedTransaction processes the unsigned transaction in order to calculate its zkCounters diff --git a/synchronizer/common/syncinterfaces/mocks/state_full_interface.go b/synchronizer/common/syncinterfaces/mocks/state_full_interface.go index ec779c4854..248c817fa6 100644 --- a/synchronizer/common/syncinterfaces/mocks/state_full_interface.go +++ b/synchronizer/common/syncinterfaces/mocks/state_full_interface.go @@ -2799,21 +2799,33 @@ func (_c *StateFullInterface_SetLastBatchInfoSeenOnEthereum_Call) RunAndReturn(r } // StoreL2Block provides a mock function with given fields: ctx, batchNumber, l2Block, txsEGPLog, dbTx -func (_m *StateFullInterface) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error { +func (_m *StateFullInterface) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) { ret := _m.Called(ctx, batchNumber, l2Block, txsEGPLog, dbTx) if len(ret) == 0 { panic("no return value specified for StoreL2Block") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) (common.Hash, error)); ok { + return rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) common.Hash); ok { r0 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.Hash) + } } - return r0 + if rf, ok := ret.Get(1).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + r1 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // StateFullInterface_StoreL2Block_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StoreL2Block' @@ -2838,12 +2850,12 @@ func (_c *StateFullInterface_StoreL2Block_Call) Run(run func(ctx context.Context return _c } -func (_c *StateFullInterface_StoreL2Block_Call) Return(_a0 error) *StateFullInterface_StoreL2Block_Call { - _c.Call.Return(_a0) +func (_c *StateFullInterface_StoreL2Block_Call) Return(_a0 common.Hash, _a1 error) *StateFullInterface_StoreL2Block_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *StateFullInterface_StoreL2Block_Call) RunAndReturn(run func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error) *StateFullInterface_StoreL2Block_Call { +func (_c *StateFullInterface_StoreL2Block_Call) RunAndReturn(run func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) (common.Hash, error)) *StateFullInterface_StoreL2Block_Call { _c.Call.Return(run) return _c } diff --git a/synchronizer/common/syncinterfaces/state.go b/synchronizer/common/syncinterfaces/state.go index 2fb9ea2f16..41d7acbedc 100644 --- a/synchronizer/common/syncinterfaces/state.go +++ b/synchronizer/common/syncinterfaces/state.go @@ -66,7 +66,7 @@ type StateFullInterface interface { GetForkIDByBlockNumber(blockNumber uint64) uint64 GetStoredFlushID(ctx context.Context) (uint64, string, error) AddL1InfoTreeLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error) - StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error + StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error) diff --git a/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go b/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go index 67977961c4..ff3b465f46 100644 --- a/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go +++ b/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go @@ -38,7 +38,7 @@ type StateInterface interface { ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error ProcessBatchV2(ctx context.Context, request state.ProcessRequest, updateMerkleTree bool) (*state.ProcessBatchResponse, string, error) - StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error + StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error) GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error) } @@ -393,7 +393,7 @@ func (b *SyncTrustedBatchExecutorForEtrog) processAndStoreTxs(ctx context.Contex } for _, block := range processBatchResp.BlockResponses { log.Debugf("%s Storing trusted tx %d", debugPrefix, block.BlockNumber) - if err = b.state.StoreL2Block(ctx, request.BatchNumber, block, nil, dbTx); err != nil { + if _, err = b.state.StoreL2Block(ctx, request.BatchNumber, block, nil, dbTx); err != nil { newErr := fmt.Errorf("%s failed to store l2block: %v err:%w", debugPrefix, block.BlockNumber, err) log.Error(newErr.Error()) return nil, newErr diff --git a/synchronizer/l2_sync/l2_sync_etrog/mocks/state_interface.go b/synchronizer/l2_sync/l2_sync_etrog/mocks/state_interface.go index 43e84ffba5..0b4d85bce7 100644 --- a/synchronizer/l2_sync/l2_sync_etrog/mocks/state_interface.go +++ b/synchronizer/l2_sync/l2_sync_etrog/mocks/state_interface.go @@ -538,21 +538,33 @@ func (_c *StateInterface_ResetTrustedState_Call) RunAndReturn(run func(context.C } // StoreL2Block provides a mock function with given fields: ctx, batchNumber, l2Block, txsEGPLog, dbTx -func (_m *StateInterface) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error { +func (_m *StateInterface) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error) { ret := _m.Called(ctx, batchNumber, l2Block, txsEGPLog, dbTx) if len(ret) == 0 { panic("no return value specified for StoreL2Block") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) (common.Hash, error)); ok { + return rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) common.Hash); ok { r0 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.Hash) + } } - return r0 + if rf, ok := ret.Get(1).(func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error); ok { + r1 = rf(ctx, batchNumber, l2Block, txsEGPLog, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // StateInterface_StoreL2Block_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StoreL2Block' @@ -577,12 +589,12 @@ func (_c *StateInterface_StoreL2Block_Call) Run(run func(ctx context.Context, ba return _c } -func (_c *StateInterface_StoreL2Block_Call) Return(_a0 error) *StateInterface_StoreL2Block_Call { - _c.Call.Return(_a0) +func (_c *StateInterface_StoreL2Block_Call) Return(_a0 common.Hash, _a1 error) *StateInterface_StoreL2Block_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *StateInterface_StoreL2Block_Call) RunAndReturn(run func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) error) *StateInterface_StoreL2Block_Call { +func (_c *StateInterface_StoreL2Block_Call) RunAndReturn(run func(context.Context, uint64, *state.ProcessBlockResponse, []*state.EffectiveGasPriceLog, pgx.Tx) (common.Hash, error)) *StateInterface_StoreL2Block_Call { _c.Call.Return(run) return _c } diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 90c0e01acd..045642e7e7 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -901,7 +901,7 @@ func expectedCallsForsyncTrustedState(t *testing.T, m *mocks, sync *ClientSynchr m.State.EXPECT().ProcessBatchV2(mock.Anything, mock.Anything, mock.Anything). Return(&processedBatch, "", nil).Times(1) m.State.EXPECT().StoreL2Block(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). - Return(nil).Times(1) + Return(common.Hash{}, nil).Times(1) m.State.EXPECT().UpdateWIPBatch(mock.Anything, mock.Anything, mock.Anything). Return(nil).Times(1) m.State.EXPECT().GetBatchByNumber(mock.Anything, mock.Anything, mock.Anything). From 43817d6bff7d78d7f2d40990a4869944432a5fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Thu, 30 May 2024 15:12:10 +0200 Subject: [PATCH 15/23] empty imStateRoot (#3663) * empty imStateRoot * fix comment --- sequencer/sequencer.go | 8 ++++++++ state/datastream.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index c573c09924..f191973767 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -12,6 +12,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/datastream" + "github.com/ethereum/go-ethereum/common" "google.golang.org/protobuf/proto" ) @@ -348,6 +349,13 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { ImStateRoot: l2Transaction.ImStateRoot.Bytes(), } + // Clear the state root if the ForkID is >= ETROG + // currently this is redundant as the current implementation of the sequencer + // leaves the ImStateRoot empty + if l2Block.ForkID >= state.FORKID_ETROG { + streamL2Transaction.ImStateRoot = common.Hash{}.Bytes() + } + marshalledL2Transaction, err := proto.Marshal(streamL2Transaction) if err != nil { log.Errorf("failed to marshal l2tx for l2block %d, error: %v", l2Block.L2BlockNumber, err) diff --git a/state/datastream.go b/state/datastream.go index 09fa7184b1..ecb211d6c2 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -590,6 +590,11 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre ImStateRoot: tx.StateRoot.Bytes(), } + // Clear the state root if the ForkID is >= ETROG + if l2Block.ForkID >= FORKID_ETROG { + transaction.ImStateRoot = common.Hash{}.Bytes() + } + marshalledTransaction, err := proto.Marshal(transaction) if err != nil { return err From 7833eedee340a04f42377a20994e5e55ae6db663 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Fri, 31 May 2024 16:18:01 +0200 Subject: [PATCH 16/23] Cherry-pick #3659,#3662: Remove sync with virtual state (synchronizer). Add L1 block confirmations (#3666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove sync with virtual state (synchronizer). Add L1 block confirmat… (#3659) * Remove sync with virtual state (synchronizer). Add L1 block confirmations to consider sequence final * fix get monitored tx receipt * update doc * Skip wait L1 block confirmations after restart (#3662) * skip wait L1 block confirmations after restart * skip checking last batch sequenced in SC after restart * set default value of SequenceL1BlockConfirmations to 32 * set default value of SequenceL1BlockConfirmations to 2 for debug/test * fix config_test * fix doc --- config/config_test.go | 4 + config/default.go | 1 + .../environments/local/local.node.config.toml | 1 + sequencesender/config.go | 2 + sequencesender/sequencesender.go | 105 +++++++++++++----- sequencesender/sequencesender_test.go | 12 +- test/config/debug.node.config.toml | 1 + test/config/test.node.config.toml | 1 + 8 files changed, 96 insertions(+), 31 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index d887003d2f..3f8c52d5bc 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -201,6 +201,10 @@ func Test_Defaults(t *testing.T) { path: "SequenceSender.MaxBatchesForL1", expectedValue: uint64(300), }, + { + path: "SequenceSender.SequenceL1BlockConfirmations", + expectedValue: uint64(32), + }, { path: "Etherman.URL", expectedValue: "http://localhost:8545", diff --git a/config/default.go b/config/default.go index 7fa767c15e..f35bdad794 100644 --- a/config/default.go +++ b/config/default.go @@ -171,6 +171,7 @@ WaitPeriodSendSequence = "5s" LastBatchVirtualizationTimeMaxWaitPeriod = "5s" L1BlockTimestampMargin = "30s" MaxTxSizeForL1 = 131072 +SequenceL1BlockConfirmations = 32 L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} GasOffset = 80000 diff --git a/config/environments/local/local.node.config.toml b/config/environments/local/local.node.config.toml index 376465b3c8..11077845ca 100644 --- a/config/environments/local/local.node.config.toml +++ b/config/environments/local/local.node.config.toml @@ -119,6 +119,7 @@ WaitPeriodSendSequence = "5s" LastBatchVirtualizationTimeMaxWaitPeriod = "5s" L1BlockTimestampMargin = "30s" MaxTxSizeForL1 = 131072 +SequenceL1BlockConfirmations = 32 L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} diff --git a/sequencesender/config.go b/sequencesender/config.go index 745546927b..be8d23781b 100644 --- a/sequencesender/config.go +++ b/sequencesender/config.go @@ -43,4 +43,6 @@ type Config struct { GasOffset uint64 `mapstructure:"GasOffset"` // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"` + // SequenceL1BlockConfirmations is number of blocks to consider a sequence sent to L1 as final + SequenceL1BlockConfirmations uint64 `mapstructure:"SequenceL1BlockConfirmations"` } diff --git a/sequencesender/sequencesender.go b/sequencesender/sequencesender.go index 754c0cad6e..8dc189baa7 100644 --- a/sequencesender/sequencesender.go +++ b/sequencesender/sequencesender.go @@ -11,6 +11,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/event" "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/ethereum/go-ethereum/common" "github.com/jackc/pgx/v4" ) @@ -19,6 +20,7 @@ const ( monitoredIDFormat = "sequence-from-%v-to-%v" retriesSanityCheck = 8 waitRetrySanityCheck = 15 * time.Second + waitRetryGetL1Block = 2 * time.Second ) var ( @@ -34,12 +36,14 @@ var ( // SequenceSender represents a sequence sender type SequenceSender struct { - cfg Config - state stateInterface - ethTxManager ethTxManager - etherman etherman - eventLog *event.EventLog - da dataAbilitier + cfg Config + da dataAbilitier + state stateInterface + ethTxManager ethTxManager + etherman etherman + eventLog *event.EventLog + lastSequenceInitialBatch uint64 + lastSequenceEndBatch uint64 } // New inits sequence sender @@ -63,7 +67,7 @@ func (s *SequenceSender) Start(ctx context.Context) { // marginTimeElapsed checks if the time between currentTime and l2BlockTimestamp is greater than timeMargin. // If it's greater returns true, otherwise it returns false and the waitTime needed to achieve this timeMargin -func (s *SequenceSender) marginTimeElapsed(ctx context.Context, l2BlockTimestamp uint64, currentTime uint64, timeMargin int64) (bool, int64) { +func (s *SequenceSender) marginTimeElapsed(l2BlockTimestamp uint64, currentTime uint64, timeMargin int64) (bool, int64) { // Check the time difference between L2 block and currentTime var timeDiff int64 if l2BlockTimestamp >= currentTime { @@ -91,7 +95,58 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { retry := false // process monitored sequences before starting a next cycle s.ethTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { - if result.Status == ethtxmanager.MonitoredTxStatusFailed { + if result.Status == ethtxmanager.MonitoredTxStatusConfirmed { + if len(result.Txs) > 0 { + var txL1BlockNumber uint64 + var txHash common.Hash + receiptFound := false + for _, tx := range result.Txs { + if tx.Receipt != nil { + txL1BlockNumber = tx.Receipt.BlockNumber.Uint64() + txHash = tx.Tx.Hash() + receiptFound = true + break + } + } + + if !receiptFound { + s.halt(ctx, fmt.Errorf("monitored tx %s for sequence [%d-%d] is confirmed but doesn't have a receipt", result.ID, s.lastSequenceInitialBatch, s.lastSequenceEndBatch)) + } + + // wait L1 confirmation blocks + log.Infof("waiting %d L1 block confirmations for sequence [%d-%d], L1 block: %d, tx: %s", + s.cfg.SequenceL1BlockConfirmations, s.lastSequenceInitialBatch, s.lastSequenceEndBatch, txL1BlockNumber, txHash) + for { + lastL1BlockHeader, err := s.etherman.GetLatestBlockHeader(ctx) + if err != nil { + log.Errorf("failed to get last L1 block number, err: %v", err) + } else { + lastL1BlockNumber := lastL1BlockHeader.Number.Uint64() + + if lastL1BlockNumber >= txL1BlockNumber+s.cfg.SequenceL1BlockConfirmations { + log.Infof("continuing, last L1 block: %d", lastL1BlockNumber) + break + } + } + time.Sleep(waitRetryGetL1Block) + } + + lastSCBatchNum, err := s.etherman.GetLatestBatchNumber() + if err != nil { + log.Warnf("failed to get from the SC last sequenced batch number, err: %v", err) + return + } + + // If it's the first time we call that function after the restart of the sequence-sender (lastSequenceBatch is 0) and we are having the + // confirmation of a pending L1 tx sent before the sequence-sender was restarted, we don't know which batch was the last sequenced. + // Therefore we cannot compare the last sequenced batch in the SC with the last sequenced from sequence-sender. We skip this check + if s.lastSequenceEndBatch != 0 && (lastSCBatchNum != s.lastSequenceEndBatch) { + s.halt(ctx, fmt.Errorf("last sequenced batch from SC %d doesn't match last sequenced batch sent %d", lastSCBatchNum, s.lastSequenceEndBatch)) + } + } else { + s.halt(ctx, fmt.Errorf("monitored tx %s for sequence [%d-%d] doesn't have transactions to be checked", result.ID, s.lastSequenceInitialBatch, s.lastSequenceEndBatch)) + } + } else { // Monitored tx is failed retry = true mTxResultLogger := ethtxmanager.CreateMonitoredTxResultLogger(ethTxManagerOwner, result) mTxResultLogger.Error("failed to send sequence, TODO: review this fatal and define what to do in this case") @@ -102,13 +157,12 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { return } - // Check if synchronizer is up to date - synced, err := s.isSynced(ctx, retriesSanityCheck, waitRetrySanityCheck) + sanityCheckOk, err := s.sanityCheck(ctx, retriesSanityCheck, waitRetrySanityCheck) if err != nil { s.halt(ctx, err) } - if !synced { - log.Info("wait virtual state to be synced...") + if !sanityCheckOk { + log.Info("sanity check failed, retrying...") time.Sleep(5 * time.Second) // nolint:gomnd return } @@ -126,7 +180,7 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { return } - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) + lastVirtualBatchNum, err := s.etherman.GetLatestBatchNumber() if err != nil { log.Errorf("failed to get last virtual batch num, err: %v", err) return @@ -153,7 +207,7 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { return } - elapsed, waitTime := s.marginTimeElapsed(ctx, lastL2BlockTimestamp, lastL1BlockHeader.Time, timeMargin) + elapsed, waitTime := s.marginTimeElapsed(lastL2BlockTimestamp, lastL1BlockHeader.Time, timeMargin) if !elapsed { log.Infof("waiting at least %d seconds to send sequences, time difference between last L1 block %d (ts: %d) and last L2 block %d (ts: %d) in the sequence is lower than %d seconds", @@ -170,7 +224,7 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { for { currentTime := uint64(time.Now().Unix()) - elapsed, waitTime := s.marginTimeElapsed(ctx, lastL2BlockTimestamp, currentTime, timeMargin) + elapsed, waitTime := s.marginTimeElapsed(lastL2BlockTimestamp, currentTime, timeMargin) // Wait if the time difference is less than timeMargin (L1BlockTimestampMargin) if !elapsed { @@ -205,13 +259,16 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) { mTxLogger.Errorf("error to add sequences tx to eth tx manager: ", err) return } + + s.lastSequenceInitialBatch = sequences[0].BatchNumber + s.lastSequenceEndBatch = lastSequence.BatchNumber } // getSequencesToSend generates an array of sequences to be send to L1. // If the array is empty, it doesn't necessarily mean that there are no sequences to be sent, // it could be that it's not worth it to do so yet. func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequence, error) { - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) + lastVirtualBatchNum, err := s.etherman.GetLatestBatchNumber() if err != nil { return nil, fmt.Errorf("failed to get last virtual batch num, err: %v", err) } @@ -326,7 +383,7 @@ func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequen return nil, nil } -func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { +func (s *SequenceSender) sanityCheck(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) if err != nil && err != state.ErrNotFound { log.Warnf("failed to get last virtual batch number, err: %v", err) @@ -345,10 +402,8 @@ func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry ti return false, nil } - if lastVirtualBatchNum < lastSCBatchNum { - log.Infof("waiting for the state to be synced, last virtual batch: %d, last SC sequenced batch: %d", lastVirtualBatchNum, lastSCBatchNum) - return false, nil - } else if lastVirtualBatchNum > lastSCBatchNum { // Sanity check: virtual batch number cannot be greater than last batch sequenced in the SC + // Sanity check: virtual batch number cannot be greater than last batch sequenced in the SC + if lastVirtualBatchNum > lastSCBatchNum { // we will retry some times to check that really the last sequenced batch in the SC is lower that the las virtual batch log.Warnf("last virtual batch %d is greater than last SC sequenced batch %d, retrying...", lastVirtualBatchNum, lastSCBatchNum) for i := 0; i < retries; i++ { @@ -368,13 +423,13 @@ func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry ti log.Infof("last virtual batch %d is equal to last SC sequenced batch %d, continuing...", lastVirtualBatchNum, lastSCBatchNum) } - // At this point lastVirtualBatchNum = lastEthBatchNum. Check trusted batches - if lastTrustedBatchClosed.BatchNumber >= lastVirtualBatchNum { - return true, nil - } else { // Sanity check: virtual batch number cannot be greater than last trusted batch closed + // Sanity check: virtual batch number cannot be greater than last trusted batch closed + if lastTrustedBatchClosed.BatchNumber < lastVirtualBatchNum { log.Errorf("last virtual batch %d is greater than last trusted batch closed %d", lastVirtualBatchNum, lastTrustedBatchClosed.BatchNumber) return false, ErrSyncVirtualGreaterTrusted } + + return true, nil } // halt halts the SequenceSender diff --git a/sequencesender/sequencesender_test.go b/sequencesender/sequencesender_test.go index 0337cebef0..a96a4d2b0a 100644 --- a/sequencesender/sequencesender_test.go +++ b/sequencesender/sequencesender_test.go @@ -35,7 +35,7 @@ func TestIsSynced(t *testing.T) { testCases := []IsSyncedTestCase{ { - name: "is synced", + name: "sanity check ok", lastVirtualBatchNum: 10, lastTrustedBatchClosed: 12, lastSCBatchNum: []uint64{10}, @@ -43,11 +43,11 @@ func TestIsSynced(t *testing.T) { err: nil, }, { - name: "not synced", + name: "sanity check ok", lastVirtualBatchNum: 9, lastTrustedBatchClosed: 12, lastSCBatchNum: []uint64{10}, - expectedResult: false, + expectedResult: true, err: nil, }, { @@ -67,7 +67,7 @@ func TestIsSynced(t *testing.T) { err: ErrSyncVirtualGreaterSequenced, }, { - name: "is synced, sc sequenced retries", + name: "sanity check ok: sc sequenced retries", lastVirtualBatchNum: 11, lastTrustedBatchClosed: 12, lastSCBatchNum: []uint64{10, 10, 11}, @@ -75,7 +75,7 @@ func TestIsSynced(t *testing.T) { err: nil, }, { - name: "is synced, sc sequenced retries (last)", + name: "sanity check ok: sc sequenced retries (last)", lastVirtualBatchNum: 11, lastTrustedBatchClosed: 12, lastSCBatchNum: []uint64{10, 10, 10, 11}, @@ -134,7 +134,7 @@ func TestIsSynced(t *testing.T) { } } - synced, err := ssender.isSynced(context.Background(), retries, waitRetry) + synced, err := ssender.sanityCheck(context.Background(), retries, waitRetry) assert.EqualValues(t, tc.expectedResult, synced) assert.EqualValues(t, tc.err, err) diff --git a/test/config/debug.node.config.toml b/test/config/debug.node.config.toml index 698164c866..68f7dd17ce 100644 --- a/test/config/debug.node.config.toml +++ b/test/config/debug.node.config.toml @@ -119,6 +119,7 @@ WaitPeriodSendSequence = "15s" LastBatchVirtualizationTimeMaxWaitPeriod = "10s" L1BlockTimestampMargin = "5s" MaxTxSizeForL1 = 131072 +SequenceL1BlockConfirmations = 2 L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" PrivateKey = {Path = "./test/sequencer.keystore", Password = "testonly"} diff --git a/test/config/test.node.config.toml b/test/config/test.node.config.toml index 51a8ef7b1b..9fbb48d8ce 100644 --- a/test/config/test.node.config.toml +++ b/test/config/test.node.config.toml @@ -136,6 +136,7 @@ WaitPeriodSendSequence = "15s" LastBatchVirtualizationTimeMaxWaitPeriod = "10s" L1BlockTimestampMargin = "5s" MaxTxSizeForL1 = 131072 +SequenceL1BlockConfirmations = 2 L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} [SequenceSender.StreamClient] From 3373c7ff899b35a2fe4736144fe955540a040c1b Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Wed, 5 Jun 2024 10:17:03 -0300 Subject: [PATCH 17/23] remove db tx from RPC (#3648) (#3683) --- jsonrpc/dbtxmanager.go | 41 -- jsonrpc/dbtxmanager_test.go | 99 --- jsonrpc/endpoints_debug.go | 249 ++++--- jsonrpc/endpoints_eth.go | 818 +++++++++++------------ jsonrpc/endpoints_eth_test.go | 1106 ++++--------------------------- jsonrpc/endpoints_zkevm.go | 713 ++++++++++---------- jsonrpc/endpoints_zkevm_test.go | 707 +++----------------- jsonrpc/mocks/mock_dbtx.go | 350 ---------- jsonrpc/server_test.go | 31 +- jsonrpc/types/codec_test.go | 66 +- test/Makefile | 1 - 11 files changed, 1133 insertions(+), 3048 deletions(-) delete mode 100644 jsonrpc/dbtxmanager.go delete mode 100644 jsonrpc/dbtxmanager_test.go delete mode 100644 jsonrpc/mocks/mock_dbtx.go diff --git a/jsonrpc/dbtxmanager.go b/jsonrpc/dbtxmanager.go deleted file mode 100644 index bb073d0369..0000000000 --- a/jsonrpc/dbtxmanager.go +++ /dev/null @@ -1,41 +0,0 @@ -package jsonrpc - -import ( - "context" - - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" - "github.com/jackc/pgx/v4" -) - -// DBTxManager allows to do scopped DB txs -type DBTxManager struct{} - -// DBTxScopedFn function to do scopped DB txs -type DBTxScopedFn func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) - -// DBTxer interface to begin DB txs -type DBTxer interface { - BeginStateTransaction(ctx context.Context) (pgx.Tx, error) -} - -// NewDbTxScope function to initiate DB scopped txs -func (f *DBTxManager) NewDbTxScope(db DBTxer, scopedFn DBTxScopedFn) (interface{}, types.Error) { - ctx := context.Background() - dbTx, err := db.BeginStateTransaction(ctx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to connect to the state", err, true) - } - - v, rpcErr := scopedFn(ctx, dbTx) - if rpcErr != nil { - if txErr := dbTx.Rollback(context.Background()); txErr != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to rollback db transaction", txErr, true) - } - return v, rpcErr - } - - if txErr := dbTx.Commit(context.Background()); txErr != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to commit db transaction", txErr, true) - } - return v, rpcErr -} diff --git a/jsonrpc/dbtxmanager_test.go b/jsonrpc/dbtxmanager_test.go deleted file mode 100644 index b3dba72625..0000000000 --- a/jsonrpc/dbtxmanager_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package jsonrpc - -import ( - "context" - "errors" - "testing" - - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/mocks" - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" - "github.com/jackc/pgx/v4" - "github.com/stretchr/testify/assert" -) - -func TestNewDbTxScope(t *testing.T) { - type testCase struct { - Name string - Fn DBTxScopedFn - ExpectedResult interface{} - ExpectedError types.Error - SetupMocks func(s *mocks.StateMock, d *mocks.DBTxMock) - } - - testCases := []testCase{ - { - Name: "Run scoped func commits DB tx", - Fn: func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return 1, nil - }, - ExpectedResult: 1, - ExpectedError: nil, - SetupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock) { - d.On("Commit", context.Background()).Return(nil).Once() - s.On("BeginStateTransaction", context.Background()).Return(d, nil).Once() - }, - }, - { - Name: "Run scoped func rollbacks DB tx", - Fn: func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return nil, types.NewRPCError(types.DefaultErrorCode, "func returned an error") - }, - ExpectedResult: nil, - ExpectedError: types.NewRPCError(types.DefaultErrorCode, "func returned an error"), - SetupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock) { - d.On("Rollback", context.Background()).Return(nil).Once() - s.On("BeginStateTransaction", context.Background()).Return(d, nil).Once() - }, - }, - { - Name: "Run scoped func but fails create a db tx", - Fn: func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return nil, nil - }, - ExpectedResult: nil, - ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to connect to the state"), - SetupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock) { - s.On("BeginStateTransaction", context.Background()).Return(nil, errors.New("failed to create db tx")).Once() - }, - }, - { - Name: "Run scoped func but fails to commit DB tx", - Fn: func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return 1, nil - }, - ExpectedResult: nil, - ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to commit db transaction"), - SetupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock) { - d.On("Commit", context.Background()).Return(errors.New("failed to commit db tx")).Once() - s.On("BeginStateTransaction", context.Background()).Return(d, nil).Once() - }, - }, - { - Name: "Run scoped func but fails to rollbacks DB tx", - Fn: func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return nil, types.NewRPCError(types.DefaultErrorCode, "func returned an error") - }, - ExpectedResult: nil, - ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to rollback db transaction"), - SetupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock) { - d.On("Rollback", context.Background()).Return(errors.New("failed to rollback db tx")).Once() - s.On("BeginStateTransaction", context.Background()).Return(d, nil).Once() - }, - }, - } - - dbTxManager := DBTxManager{} - s := mocks.NewStateMock(t) - d := mocks.NewDBTxMock(t) - - for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { - tc := testCase - tc.SetupMocks(s, d) - - result, err := dbTxManager.NewDbTxScope(s, tc.Fn) - assert.Equal(t, tc.ExpectedResult, result) - assert.Equal(t, tc.ExpectedError, err) - }) - } -} diff --git a/jsonrpc/endpoints_debug.go b/jsonrpc/endpoints_debug.go index a91cd924da..2309db7c5c 100644 --- a/jsonrpc/endpoints_debug.go +++ b/jsonrpc/endpoints_debug.go @@ -31,7 +31,6 @@ type DebugEndpoints struct { cfg Config state types.StateInterface etherman types.EthermanInterface - txMan DBTxManager } // NewDebugEndpoints returns DebugEndpoints @@ -64,54 +63,51 @@ type traceBatchTransactionResponse struct { // TraceTransaction creates a response for debug_traceTransaction request. // See https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction func (d *DebugEndpoints) TraceTransaction(hash types.ArgHash, cfg *traceConfig) (interface{}, types.Error) { - return d.txMan.NewDbTxScope(d.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return d.buildTraceTransaction(ctx, hash.Hash(), cfg, dbTx) - }) + ctx := context.Background() + return d.buildTraceTransaction(ctx, hash.Hash(), cfg, nil) } // TraceBlockByNumber creates a response for debug_traceBlockByNumber request. // See https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbynumber func (d *DebugEndpoints) TraceBlockByNumber(number types.BlockNumber, cfg *traceConfig) (interface{}, types.Error) { - return d.txMan.NewDbTxScope(d.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, d.state, d.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, d.state, d.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - block, err := d.state.GetL2BlockByNumber(ctx, blockNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("block #%d not found", blockNumber)) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by number", err, true) - } + block, err := d.state.GetL2BlockByNumber(ctx, blockNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("block #%d not found", blockNumber)) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by number", err, true) + } - traces, rpcErr := d.buildTraceBlock(ctx, block.Transactions(), cfg, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + traces, rpcErr := d.buildTraceBlock(ctx, block.Transactions(), cfg, nil) + if rpcErr != nil { + return nil, rpcErr + } - return traces, nil - }) + return traces, nil } // TraceBlockByHash creates a response for debug_traceBlockByHash request. // See https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbyhash func (d *DebugEndpoints) TraceBlockByHash(hash types.ArgHash, cfg *traceConfig) (interface{}, types.Error) { - return d.txMan.NewDbTxScope(d.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - block, err := d.state.GetL2BlockByHash(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("block %s not found", hash.Hash().String())) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash", err, true) - } + ctx := context.Background() + block, err := d.state.GetL2BlockByHash(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("block %s not found", hash.Hash().String())) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash", err, true) + } - traces, rpcErr := d.buildTraceBlock(ctx, block.Transactions(), cfg, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + traces, rpcErr := d.buildTraceBlock(ctx, block.Transactions(), cfg, nil) + if rpcErr != nil { + return nil, rpcErr + } - return traces, nil - }) + return traces, nil } // TraceBatchByNumber creates a response for debug_traceBatchByNumber request. @@ -144,113 +140,112 @@ func (d *DebugEndpoints) TraceBatchByNumber(httpRequest *http.Request, number ty // how many txs it will process in parallel. const bufferSize = 10 - return d.txMan.NewDbTxScope(d.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - batchNumber, rpcErr := number.GetNumericBatchNumber(ctx, d.state, d.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + batchNumber, rpcErr := number.GetNumericBatchNumber(ctx, d.state, d.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - batch, err := d.state.GetBatchByNumber(ctx, batchNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("batch #%d not found", batchNumber)) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get batch by number", err, true) - } + batch, err := d.state.GetBatchByNumber(ctx, batchNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, types.NewRPCError(types.DefaultErrorCode, fmt.Sprintf("batch #%d not found", batchNumber)) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get batch by number", err, true) + } - txs, _, err := d.state.GetTransactionsByBatchNumber(ctx, batch.BatchNumber, dbTx) - if !errors.Is(err, state.ErrNotFound) && err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch txs from state by number %v to create the traces", batchNumber), err, true) - } + txs, _, err := d.state.GetTransactionsByBatchNumber(ctx, batch.BatchNumber, nil) + if !errors.Is(err, state.ErrNotFound) && err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch txs from state by number %v to create the traces", batchNumber), err, true) + } - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := d.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v to get trace", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := d.state.GetTransactionReceipt(ctx, tx.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v to get trace", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - requests := make(chan (ethTypes.Receipt), bufferSize) - - mu := &sync.Mutex{} - wg := sync.WaitGroup{} - wg.Add(len(receipts)) - responses := make([]traceResponse, 0, len(receipts)) - - // gets the trace from the jRPC and adds it to the responses - loadTraceByTxHash := func(d *DebugEndpoints, receipt ethTypes.Receipt, cfg *traceConfig) { - response := traceResponse{ - blockNumber: receipt.BlockNumber.Uint64(), - txIndex: uint64(receipt.TransactionIndex), - txHash: receipt.TxHash, - } - - defer wg.Done() - trace, err := d.TraceTransaction(types.ArgHash(receipt.TxHash), cfg) - if err != nil { - err := fmt.Errorf("failed to get tx trace for tx %v, err: %w", receipt.TxHash.String(), err) - log.Errorf(err.Error()) - response.err = err - } else { - response.trace = trace - } - - // add to the responses - mu.Lock() - defer mu.Unlock() - responses = append(responses, response) + requests := make(chan (ethTypes.Receipt), bufferSize) + + mu := &sync.Mutex{} + wg := sync.WaitGroup{} + wg.Add(len(receipts)) + responses := make([]traceResponse, 0, len(receipts)) + + // gets the trace from the jRPC and adds it to the responses + loadTraceByTxHash := func(d *DebugEndpoints, receipt ethTypes.Receipt, cfg *traceConfig) { + response := traceResponse{ + blockNumber: receipt.BlockNumber.Uint64(), + txIndex: uint64(receipt.TransactionIndex), + txHash: receipt.TxHash, } - // goes through the buffer and loads the trace - // by all the transactions added in the buffer - // then add the results to the responses map - go func() { - index := uint(0) - for req := range requests { - go loadTraceByTxHash(d, req, cfg) - index++ - } - }() - - // add receipts to the buffer - for _, receipt := range receipts { - requests <- receipt + defer wg.Done() + trace, err := d.TraceTransaction(types.ArgHash(receipt.TxHash), cfg) + if err != nil { + err := fmt.Errorf("failed to get tx trace for tx %v, err: %w", receipt.TxHash.String(), err) + log.Errorf(err.Error()) + response.err = err + } else { + response.trace = trace } - // wait the traces to be loaded - if waitTimeout(&wg, d.cfg.ReadTimeout.Duration) { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("failed to get traces for batch %v: timeout reached", batchNumber), nil, true) + // add to the responses + mu.Lock() + defer mu.Unlock() + responses = append(responses, response) + } + + // goes through the buffer and loads the trace + // by all the transactions added in the buffer + // then add the results to the responses map + go func() { + index := uint(0) + for req := range requests { + go loadTraceByTxHash(d, req, cfg) + index++ } + }() - close(requests) - - // since the txs are attached to a L2 Block and the L2 Block is - // the struct attached to the Batch, in order to always respond - // the traces in the same order, we need to order the transactions - // first by block number and then by tx index, so we can have something - // close to the txs being sorted by a tx index related to the batch - sort.Slice(responses, func(i, j int) bool { - if responses[i].txIndex != responses[j].txIndex { - return responses[i].txIndex < responses[j].txIndex - } - return responses[i].blockNumber < responses[j].blockNumber - }) + // add receipts to the buffer + for _, receipt := range receipts { + requests <- receipt + } + + // wait the traces to be loaded + if waitTimeout(&wg, d.cfg.ReadTimeout.Duration) { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("failed to get traces for batch %v: timeout reached", batchNumber), nil, true) + } + + close(requests) - // build the batch trace response array - traces := make([]traceBatchTransactionResponse, 0, len(receipts)) - for _, response := range responses { - if response.err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("failed to get traces for batch %v: failed to get trace for tx: %v, err: %v", batchNumber, response.txHash.String(), response.err.Error()), nil, true) - } - - traces = append(traces, traceBatchTransactionResponse{ - TxHash: response.txHash, - Result: response.trace, - }) + // since the txs are attached to a L2 Block and the L2 Block is + // the struct attached to the Batch, in order to always respond + // the traces in the same order, we need to order the transactions + // first by block number and then by tx index, so we can have something + // close to the txs being sorted by a tx index related to the batch + sort.Slice(responses, func(i, j int) bool { + if responses[i].txIndex != responses[j].txIndex { + return responses[i].txIndex < responses[j].txIndex } - return traces, nil + return responses[i].blockNumber < responses[j].blockNumber }) + + // build the batch trace response array + traces := make([]traceBatchTransactionResponse, 0, len(receipts)) + for _, response := range responses { + if response.err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("failed to get traces for batch %v: failed to get trace for tx: %v, err: %v", batchNumber, response.txHash.String(), response.err.Error()), nil, true) + } + + traces = append(traces, traceBatchTransactionResponse{ + TxHash: response.txHash, + Result: response.trace, + }) + } + return traces, nil } func (d *DebugEndpoints) buildTraceBlock(ctx context.Context, txs []*ethTypes.Transaction, cfg *traceConfig, dbTx pgx.Tx) (interface{}, types.Error) { diff --git a/jsonrpc/endpoints_eth.go b/jsonrpc/endpoints_eth.go index 2a3ba32b86..b406961c91 100644 --- a/jsonrpc/endpoints_eth.go +++ b/jsonrpc/endpoints_eth.go @@ -37,7 +37,6 @@ type EthEndpoints struct { state types.StateInterface etherman types.EthermanInterface storage storageInterface - txMan DBTxManager } // NewEthEndpoints creates an new instance of Eth @@ -50,14 +49,13 @@ func NewEthEndpoints(cfg Config, chainID uint64, p types.PoolInterface, s types. // BlockNumber returns current block number func (e *EthEndpoints) BlockNumber() (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - lastBlockNumber, err := e.state.GetLastL2BlockNumber(ctx, dbTx) - if err != nil { - return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state") - } + ctx := context.Background() + lastBlockNumber, err := e.state.GetLastL2BlockNumber(ctx, nil) + if err != nil { + return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state") + } - return hex.EncodeUint64(lastBlockNumber), nil - }) + return hex.EncodeUint64(lastBlockNumber), nil } // Call executes a new message call immediately and returns the value of @@ -65,62 +63,61 @@ func (e *EthEndpoints) BlockNumber() (interface{}, types.Error) { // Note, this function doesn't make any changes in the state/blockchain and is // useful to execute view/pure methods and retrieve values. func (e *EthEndpoints) Call(arg *types.TxArgs, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - 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) - } - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) - if respErr != nil { - return nil, respErr - } - var blockToProcess *uint64 - if blockArg != nil { - blockNumArg := blockArg.Number() - if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { - blockToProcess = nil - } else { - n := block.NumberU64() - blockToProcess = &n - } - } - - // If the caller didn't supply the gas limit in the message, then we set it to maximum possible => block gas limit - if arg.Gas == nil || uint64(*arg.Gas) <= 0 { - header, err := e.state.GetL2BlockHeaderByNumber(ctx, block.NumberU64(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block header", err, true) - } - - gas := types.ArgUint64(header.GasLimit) - arg.Gas = &gas + ctx := context.Background() + if arg == nil { + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) + } + block, respErr := e.getBlockByArg(ctx, blockArg, nil) + if respErr != nil { + return nil, respErr + } + var blockToProcess *uint64 + if blockArg != nil { + blockNumArg := blockArg.Number() + if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { + blockToProcess = nil + } else { + n := block.NumberU64() + blockToProcess = &n } + } - defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) - sender, tx, err := arg.ToTransaction(ctx, e.state, state.MaxTxGasLimit, block.Root(), defaultSenderAddress, dbTx) + // If the caller didn't supply the gas limit in the message, then we set it to maximum possible => block gas limit + if arg.Gas == nil || uint64(*arg.Gas) <= 0 { + header, err := e.state.GetL2BlockHeaderByNumber(ctx, block.NumberU64(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block header", err, true) } - result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) - if err != nil { - errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) - logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas)) - return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) - } + gas := types.ArgUint64(header.GasLimit) + arg.Gas = &gas + } - 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() { + defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) + sender, tx, err := arg.ToTransaction(ctx, e.state, state.MaxTxGasLimit, block.Root(), defaultSenderAddress, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) + } + + result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, nil) + if err != nil { + errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) + logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas) + return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) + } + + 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()) + } - return types.ArgBytesPtr(result.ReturnValue), nil - }) + return types.ArgBytesPtr(result.ReturnValue), nil } // ChainId returns the chain id of the client @@ -161,46 +158,45 @@ func (e *EthEndpoints) getCoinbaseFromSequencerNode() (interface{}, types.Error) // used by the transaction, for a variety of reasons including EVM mechanics and // node performance. func (e *EthEndpoints) EstimateGas(arg *types.TxArgs, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - 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) - } + ctx := context.Background() + if arg == nil { + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) + } - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) - if respErr != nil { - return nil, respErr - } + block, respErr := e.getBlockByArg(ctx, blockArg, nil) + if respErr != nil { + return nil, respErr + } - var blockToProcess *uint64 - if blockArg != nil { - blockNumArg := blockArg.Number() - if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { - blockToProcess = nil - } else { - n := block.NumberU64() - blockToProcess = &n - } + var blockToProcess *uint64 + if blockArg != nil { + blockNumArg := blockArg.Number() + if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { + blockToProcess = nil + } else { + n := block.NumberU64() + blockToProcess = &n } + } - defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) - sender, tx, err := arg.ToTransaction(ctx, e.state, state.MaxTxGasLimit, block.Root(), defaultSenderAddress, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) - } + defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) + sender, tx, err := arg.ToTransaction(ctx, e.state, state.MaxTxGasLimit, block.Root(), defaultSenderAddress, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) + } - gasEstimation, returnValue, err := e.state.EstimateGas(tx, sender, blockToProcess, dbTx) - 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 { + gasEstimation, returnValue, err := e.state.EstimateGas(tx, sender, blockToProcess, nil) + 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 hex.EncodeUint64(gasEstimation), nil - }) + return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data) + } else if err != nil { + return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) + } + return hex.EncodeUint64(gasEstimation), nil } // GasPrice returns the average gas price based on the last x blocks @@ -253,21 +249,20 @@ func (e *EthEndpoints) getHighestL2BlockFromTrustedNode() (interface{}, types.Er // GetBalance returns the account's balance at the referenced block func (e *EthEndpoints) GetBalance(address types.ArgAddress, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - block, rpcErr := e.getBlockByArg(ctx, blockArg, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + block, rpcErr := e.getBlockByArg(ctx, blockArg, nil) + if rpcErr != nil { + return nil, rpcErr + } - balance, err := e.state.GetBalance(ctx, address.Address(), block.Root()) - if errors.Is(err, state.ErrNotFound) { - return hex.EncodeUint64(0), nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get balance from state", err, true) - } + balance, err := e.state.GetBalance(ctx, address.Address(), block.Root()) + if errors.Is(err, state.ErrNotFound) { + return hex.EncodeUint64(0), nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get balance from state", err, true) + } - return hex.EncodeBig(balance), nil - }) + return hex.EncodeBig(balance), nil } func (e *EthEndpoints) getBlockByArg(ctx context.Context, blockArg *types.BlockNumberOrHash, dbTx pgx.Tx) (*state.L2Block, types.Error) { @@ -308,111 +303,108 @@ func (e *EthEndpoints) getBlockByArg(ctx context.Context, blockArg *types.BlockN // GetBlockByHash returns information about a block by hash func (e *EthEndpoints) GetBlockByHash(hash types.ArgHash, fullTx bool, includeExtraInfo *bool) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - l2Block, err := e.state.GetL2BlockByHash(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) - } - - txs := l2Block.Transactions() - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) - } + ctx := context.Background() + l2Block, err := e.state.GetL2BlockByHash(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) + } - rpcBlock, err := types.NewBlock(ctx, e.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, false, includeExtraInfo, dbTx) + txs := l2Block.Transactions() + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by hash %v", hash.Hash()), err, true) + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - return rpcBlock, nil - }) + rpcBlock, err := types.NewBlock(ctx, e.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, false, includeExtraInfo, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by hash %v", hash.Hash()), err, true) + } + + return rpcBlock, nil } // GetBlockByNumber returns information about a block by block number func (e *EthEndpoints) GetBlockByNumber(number types.BlockNumber, fullTx bool, includeExtraInfo *bool) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - if number == types.PendingBlockNumber { - lastBlock, err := e.state.GetLastL2Block(ctx, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block", err, true) - } - l2Header := state.NewL2Header(ðTypes.Header{ - ParentHash: lastBlock.Hash(), - Number: big.NewInt(0).SetUint64(lastBlock.Number().Uint64() + 1), - TxHash: ethTypes.EmptyRootHash, - UncleHash: ethTypes.EmptyUncleHash, - }) - l2Block := state.NewL2BlockWithHeader(l2Header) - rpcBlock, err := types.NewBlock(ctx, e.state, nil, l2Block, nil, fullTx, false, includeExtraInfo, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "couldn't build the pending block response", err, true) - } - - // clean fields that are not available for pending block - rpcBlock.Hash = nil - rpcBlock.Miner = nil - rpcBlock.Nonce = nil - rpcBlock.TotalDifficulty = nil - - return rpcBlock, nil + ctx := context.Background() + if number == types.PendingBlockNumber { + lastBlock, err := e.state.GetLastL2Block(ctx, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block", err, true) } - var err error - blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr + l2Header := state.NewL2Header(ðTypes.Header{ + ParentHash: lastBlock.Hash(), + Number: big.NewInt(0).SetUint64(lastBlock.Number().Uint64() + 1), + TxHash: ethTypes.EmptyRootHash, + UncleHash: ethTypes.EmptyUncleHash, + }) + l2Block := state.NewL2BlockWithHeader(l2Header) + rpcBlock, err := types.NewBlock(ctx, e.state, nil, l2Block, nil, fullTx, false, includeExtraInfo, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "couldn't build the pending block response", err, true) } - l2Block, err := e.state.GetL2BlockByNumber(ctx, blockNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load block from state by number %v", blockNumber), err, true) - } + // clean fields that are not available for pending block + rpcBlock.Hash = nil + rpcBlock.Miner = nil + rpcBlock.Nonce = nil + rpcBlock.TotalDifficulty = nil - txs := l2Block.Transactions() - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) - } + return rpcBlock, nil + } + var err error + blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - rpcBlock, err := types.NewBlock(ctx, e.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, false, includeExtraInfo, dbTx) + l2Block, err := e.state.GetL2BlockByNumber(ctx, blockNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load block from state by number %v", blockNumber), err, true) + } + + txs := l2Block.Transactions() + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by number %v", blockNumber), err, true) + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - return rpcBlock, nil - }) + rpcBlock, err := types.NewBlock(ctx, e.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, false, includeExtraInfo, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by number %v", blockNumber), err, true) + } + + return rpcBlock, nil } // GetCode returns account code at given block number func (e *EthEndpoints) GetCode(address types.ArgAddress, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var err error - block, rpcErr := e.getBlockByArg(ctx, blockArg, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + var err error + block, rpcErr := e.getBlockByArg(ctx, blockArg, nil) + if rpcErr != nil { + return nil, rpcErr + } - code, err := e.state.GetCode(ctx, address.Address(), block.Root()) - if errors.Is(err, state.ErrNotFound) { - return "0x", nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get code", err, true) - } + code, err := e.state.GetCode(ctx, address.Address(), block.Root()) + if errors.Is(err, state.ErrNotFound) { + return "0x", nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get code", err, true) + } - return types.ArgBytes(code), nil - }) + return types.ArgBytes(code), nil } // GetCompilers eth_getCompilers @@ -511,9 +503,8 @@ func (e *EthEndpoints) GetFilterLogs(filterID string) (interface{}, types.Error) // GetLogs returns a list of logs accordingly to the provided filter func (e *EthEndpoints) GetLogs(filter LogFilter) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return e.internalGetLogs(ctx, dbTx, filter) - }) + ctx := context.Background() + return e.internalGetLogs(ctx, nil, filter) } func (e *EthEndpoints) internalGetLogs(ctx context.Context, dbTx pgx.Tx, filter LogFilter) (interface{}, types.Error) { @@ -549,92 +540,123 @@ func (e *EthEndpoints) internalGetLogs(ctx context.Context, dbTx pgx.Tx, filter // GetStorageAt gets the value stored for an specific address and position func (e *EthEndpoints) GetStorageAt(address types.ArgAddress, storageKeyStr string, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { + ctx := context.Background() storageKey := types.ArgHash{} err := storageKey.UnmarshalText([]byte(storageKeyStr)) if err != nil { return RPCErrorResponse(types.DefaultErrorCode, "unable to decode storage key: hex string invalid", nil, false) } - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) - if respErr != nil { - return nil, respErr - } + block, respErr := e.getBlockByArg(ctx, blockArg, nil) + if respErr != nil { + return nil, respErr + } - value, err := e.state.GetStorageAt(ctx, address.Address(), storageKey.Hash().Big(), block.Root()) - if errors.Is(err, state.ErrNotFound) { - return types.ArgBytesPtr(common.Hash{}.Bytes()), nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get storage value from state", err, true) - } + value, err := e.state.GetStorageAt(ctx, address.Address(), storageKey.Hash().Big(), block.Root()) + if errors.Is(err, state.ErrNotFound) { + return types.ArgBytesPtr(common.Hash{}.Bytes()), nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get storage value from state", err, true) + } - return types.ArgBytesPtr(common.BigToHash(value).Bytes()), nil - }) + return types.ArgBytesPtr(common.BigToHash(value).Bytes()), nil } // GetTransactionByBlockHashAndIndex returns information about a transaction by // block hash and transaction index position. func (e *EthEndpoints) GetTransactionByBlockHashAndIndex(hash types.ArgHash, index types.Index, includeExtraInfo *bool) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - tx, err := e.state.GetTransactionByL2BlockHashAndIndex(ctx, hash.Hash(), uint64(index), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction", err, true) - } - - receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction receipt", err, true) - } + ctx := context.Background() + tx, err := e.state.GetTransactionByL2BlockHashAndIndex(ctx, hash.Hash(), uint64(index), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction", err, true) + } - var l2Hash *common.Hash - if includeExtraInfo != nil && *includeExtraInfo { - l2h, err := e.state.GetL2TxHashByTxHash(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) - } - l2Hash = l2h - } + receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction receipt", err, true) + } - res, err := types.NewTransaction(*tx, receipt, false, l2Hash) + var l2Hash *common.Hash + if includeExtraInfo != nil && *includeExtraInfo { + l2h, err := e.state.GetL2TxHashByTxHash(ctx, tx.Hash(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) + return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) } + l2Hash = l2h + } - return res, nil - }) + res, err := types.NewTransaction(*tx, receipt, false, l2Hash) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) + } + + return res, nil } // GetTransactionByBlockNumberAndIndex returns information about a transaction by // block number and transaction index position. func (e *EthEndpoints) GetTransactionByBlockNumberAndIndex(number *types.BlockNumber, index types.Index, includeExtraInfo *bool) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var err error - blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + var err error + blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - tx, err := e.state.GetTransactionByL2BlockNumberAndIndex(ctx, blockNumber, uint64(index), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction", err, true) + tx, err := e.state.GetTransactionByL2BlockNumberAndIndex(ctx, blockNumber, uint64(index), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction", err, true) + } + + receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction receipt", err, true) + } + + var l2Hash *common.Hash + if includeExtraInfo != nil && *includeExtraInfo { + l2h, err := e.state.GetL2TxHashByTxHash(ctx, tx.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) } + l2Hash = l2h + } + + res, err := types.NewTransaction(*tx, receipt, false, l2Hash) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) + } + + return res, nil +} - receipt, err := e.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) +// GetTransactionByHash returns a transaction by his hash +func (e *EthEndpoints) GetTransactionByHash(hash types.ArgHash, includeExtraInfo *bool) (interface{}, types.Error) { + ctx := context.Background() + // try to get tx from state + tx, err := e.state.GetTransactionByHash(ctx, hash.Hash(), nil) + if err != nil && !errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by hash from state", err, true) + } + if tx != nil { + receipt, err := e.state.GetTransactionReceipt(ctx, hash.Hash(), nil) if errors.Is(err, state.ErrNotFound) { - return nil, nil + return RPCErrorResponse(types.DefaultErrorCode, "transaction receipt not found", err, false) } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get transaction receipt", err, true) + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction receipt from state", err, true) } var l2Hash *common.Hash if includeExtraInfo != nil && *includeExtraInfo { - l2h, err := e.state.GetL2TxHashByTxHash(ctx, tx.Hash(), dbTx) + l2h, err := e.state.GetL2TxHashByTxHash(ctx, hash.Hash(), nil) if err != nil { return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) } @@ -647,62 +669,27 @@ func (e *EthEndpoints) GetTransactionByBlockNumberAndIndex(number *types.BlockNu } return res, nil - }) -} - -// GetTransactionByHash returns a transaction by his hash -func (e *EthEndpoints) GetTransactionByHash(hash types.ArgHash, includeExtraInfo *bool) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - // try to get tx from state - tx, err := e.state.GetTransactionByHash(ctx, hash.Hash(), dbTx) - if err != nil && !errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by hash from state", err, true) - } - if tx != nil { - receipt, err := e.state.GetTransactionReceipt(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, "transaction receipt not found", err, false) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction receipt from state", err, true) - } - - var l2Hash *common.Hash - if includeExtraInfo != nil && *includeExtraInfo { - l2h, err := e.state.GetL2TxHashByTxHash(ctx, hash.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) - } - l2Hash = l2h - } - - res, err := types.NewTransaction(*tx, receipt, false, l2Hash) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) - } - - return res, nil - } + } - // if the tx does not exist in the state, look for it in the pool - if e.cfg.SequencerNodeURI != "" { - return e.getTransactionByHashFromSequencerNode(hash.Hash(), includeExtraInfo) - } - poolTx, err := e.pool.GetTransactionByHash(ctx, hash.Hash()) - if errors.Is(err, pool.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by hash from pool", err, true) - } - if poolTx.Status == pool.TxStatusPending { - tx = &poolTx.Transaction - res, err := types.NewTransaction(*tx, nil, false, nil) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) - } - return res, nil - } + // if the tx does not exist in the state, look for it in the pool + if e.cfg.SequencerNodeURI != "" { + return e.getTransactionByHashFromSequencerNode(hash.Hash(), includeExtraInfo) + } + poolTx, err := e.pool.GetTransactionByHash(ctx, hash.Hash()) + if errors.Is(err, pool.ErrNotFound) { return nil, nil - }) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by hash from pool", err, true) + } + if poolTx.Status == pool.TxStatusPending { + tx = &poolTx.Transaction + res, err := types.NewTransaction(*tx, nil, false, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) + } + return res, nil + } + return nil, nil } func (e *EthEndpoints) getTransactionByHashFromSequencerNode(hash common.Hash, includeExtraInfo *bool) (interface{}, types.Error) { @@ -729,45 +716,44 @@ func (e *EthEndpoints) getTransactionByHashFromSequencerNode(hash common.Hash, i // GetTransactionCount returns account nonce func (e *EthEndpoints) GetTransactionCount(address types.ArgAddress, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var ( - pendingNonce uint64 - nonce uint64 - err error - ) - - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) - if respErr != nil { - return nil, respErr - } + ctx := context.Background() + var ( + pendingNonce uint64 + nonce uint64 + err error + ) + + block, respErr := e.getBlockByArg(ctx, blockArg, nil) + if respErr != nil { + return nil, respErr + } - if blockArg != nil { - blockNumArg := blockArg.Number() - if blockNumArg != nil && *blockNumArg == types.PendingBlockNumber { - if e.cfg.SequencerNodeURI != "" { - return e.getTransactionCountFromSequencerNode(address.Address(), blockArg.Number()) - } - pendingNonce, err = e.pool.GetNonce(ctx, address.Address()) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to count pending transactions", err, true) - } + if blockArg != nil { + blockNumArg := blockArg.Number() + if blockNumArg != nil && *blockNumArg == types.PendingBlockNumber { + if e.cfg.SequencerNodeURI != "" { + return e.getTransactionCountFromSequencerNode(address.Address(), blockArg.Number()) + } + pendingNonce, err = e.pool.GetNonce(ctx, address.Address()) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to count pending transactions", err, true) } } + } - nonce, err = e.state.GetNonce(ctx, address.Address(), block.Root()) + nonce, err = e.state.GetNonce(ctx, address.Address(), block.Root()) - if errors.Is(err, state.ErrNotFound) { - return hex.EncodeUint64(0), nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) - } + if errors.Is(err, state.ErrNotFound) { + return hex.EncodeUint64(0), nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) + } - if pendingNonce > nonce { - nonce = pendingNonce - } + if pendingNonce > nonce { + nonce = pendingNonce + } - return hex.EncodeUint64(nonce), nil - }) + return hex.EncodeUint64(nonce), nil } func (e *EthEndpoints) getTransactionCountFromSequencerNode(address common.Address, number *types.BlockNumber) (interface{}, types.Error) { @@ -791,44 +777,42 @@ func (e *EthEndpoints) getTransactionCountFromSequencerNode(address common.Addre // GetBlockTransactionCountByHash returns the number of transactions in a // block from a block matching the given block hash. func (e *EthEndpoints) GetBlockTransactionCountByHash(hash types.ArgHash) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - c, err := e.state.GetL2BlockTransactionCountByHash(ctx, hash.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) - } + ctx := context.Background() + c, err := e.state.GetL2BlockTransactionCountByHash(ctx, hash.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) + } - return types.ArgUint64(c), nil - }) + return types.ArgUint64(c), nil } // GetBlockTransactionCountByNumber returns the number of transactions in a // block from a block matching the given block number. func (e *EthEndpoints) GetBlockTransactionCountByNumber(number *types.BlockNumber) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - if number != nil && *number == types.PendingBlockNumber { - if e.cfg.SequencerNodeURI != "" { - return e.getBlockTransactionCountByNumberFromSequencerNode(number) - } - c, err := e.pool.CountPendingTransactions(ctx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to count pending transactions", err, true) - } - return types.ArgUint64(c), nil - } - - var err error - blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr + ctx := context.Background() + if number != nil && *number == types.PendingBlockNumber { + if e.cfg.SequencerNodeURI != "" { + return e.getBlockTransactionCountByNumberFromSequencerNode(number) } - - c, err := e.state.GetL2BlockTransactionCountByNumber(ctx, blockNumber, dbTx) + c, err := e.pool.CountPendingTransactions(ctx) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) + return RPCErrorResponse(types.DefaultErrorCode, "failed to count pending transactions", err, true) } - return types.ArgUint64(c), nil - }) + } + + var err error + blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, e.state, e.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } + + c, err := e.state.GetL2BlockTransactionCountByNumber(ctx, blockNumber, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to count transactions", err, true) + } + + return types.ArgUint64(c), nil } func (e *EthEndpoints) getBlockTransactionCountByNumberFromSequencerNode(number *types.BlockNumber) (interface{}, types.Error) { @@ -851,28 +835,27 @@ func (e *EthEndpoints) getBlockTransactionCountByNumberFromSequencerNode(number // GetTransactionReceipt returns a transaction receipt by his hash func (e *EthEndpoints) GetTransactionReceipt(hash types.ArgHash) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - tx, err := e.state.GetTransactionByHash(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx from state", err, true) - } + ctx := context.Background() + tx, err := e.state.GetTransactionByHash(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx from state", err, true) + } - r, err := e.state.GetTransactionReceipt(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx receipt from state", err, true) - } + r, err := e.state.GetTransactionReceipt(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx receipt from state", err, true) + } - receipt, err := types.NewReceipt(*tx, r, nil) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build the receipt response", err, true) - } + receipt, err := types.NewReceipt(*tx, r, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build the receipt response", err, true) + } - return receipt, nil - }) + return receipt, nil } // NewBlockFilter creates a filter in the node, to notify when @@ -896,9 +879,8 @@ func (e *EthEndpoints) newBlockFilter(wsConn *concurrentWsConn) (interface{}, ty // to notify when the state changes (logs). To check if the state // has changed, call eth_getFilterChanges. func (e *EthEndpoints) NewFilter(filter LogFilter) (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - return e.newFilter(ctx, nil, filter, dbTx) - }) + ctx := context.Background() + return e.newFilter(ctx, nil, filter, nil) } // internal @@ -1009,46 +991,45 @@ func (e *EthEndpoints) UninstallFilter(filterID string) (interface{}, types.Erro // Syncing returns an object with data about the sync status or false. // https://eth.wiki/json-rpc/API#eth_syncing func (e *EthEndpoints) Syncing() (interface{}, types.Error) { - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - _, err := e.state.GetLastL2BlockNumber(ctx, dbTx) - if errors.Is(err, state.ErrStateNotSynchronized) { - return nil, types.NewRPCError(types.DefaultErrorCode, state.ErrStateNotSynchronized.Error()) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get last block number from state", err, true) - } + ctx := context.Background() + _, err := e.state.GetLastL2BlockNumber(ctx, nil) + if errors.Is(err, state.ErrStateNotSynchronized) { + return nil, types.NewRPCError(types.DefaultErrorCode, state.ErrStateNotSynchronized.Error()) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get last block number from state", err, true) + } - syncInfo, err := e.state.GetSyncingInfo(ctx, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get syncing info from state", err, true) - } + syncInfo, err := e.state.GetSyncingInfo(ctx, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get syncing info from state", err, true) + } - if !syncInfo.IsSynchronizing { - return false, nil - } - if e.cfg.SequencerNodeURI != "" { - // If we have a trusted node we ask it for the highest l2 block - res, err := e.getHighestL2BlockFromTrustedNode() - if err != nil { - log.Warnf("failed to get highest l2 block from trusted node: %v", err) + if !syncInfo.IsSynchronizing { + return false, nil + } + if e.cfg.SequencerNodeURI != "" { + // If we have a trusted node we ask it for the highest l2 block + res, err := e.getHighestL2BlockFromTrustedNode() + if err != nil { + log.Warnf("failed to get highest l2 block from trusted node: %v", err) + } else { + highestL2BlockInTrusted := res.(uint64) + if highestL2BlockInTrusted > syncInfo.CurrentBlockNumber { + syncInfo.EstimatedHighestBlock = highestL2BlockInTrusted } else { - highestL2BlockInTrusted := res.(uint64) - if highestL2BlockInTrusted > syncInfo.CurrentBlockNumber { - syncInfo.EstimatedHighestBlock = highestL2BlockInTrusted - } else { - log.Warnf("highest l2 block in trusted node (%d) is lower than the current block number in the state (%d)", highestL2BlockInTrusted, syncInfo.CurrentBlockNumber) - } + log.Warnf("highest l2 block in trusted node (%d) is lower than the current block number in the state (%d)", highestL2BlockInTrusted, syncInfo.CurrentBlockNumber) } } - return struct { - S types.ArgUint64 `json:"startingBlock"` - C types.ArgUint64 `json:"currentBlock"` - H types.ArgUint64 `json:"highestBlock"` - }{ - S: types.ArgUint64(syncInfo.InitialSyncingBlock), - C: types.ArgUint64(syncInfo.CurrentBlockNumber), - H: types.ArgUint64(syncInfo.EstimatedHighestBlock), - }, nil - }) + } + return struct { + S types.ArgUint64 `json:"startingBlock"` + C types.ArgUint64 `json:"currentBlock"` + H types.ArgUint64 `json:"highestBlock"` + }{ + S: types.ArgUint64(syncInfo.InitialSyncingBlock), + C: types.ArgUint64(syncInfo.CurrentBlockNumber), + H: types.ArgUint64(syncInfo.EstimatedHighestBlock), + }, nil } // GetUncleByBlockHashAndIndex returns information about a uncle of a @@ -1112,13 +1093,12 @@ func (e *EthEndpoints) Subscribe(wsConn *concurrentWsConn, name string, logFilte case "newHeads": return e.newBlockFilter(wsConn) case "logs": - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var lf LogFilter - if logFilter != nil { - lf = *logFilter - } - return e.newFilter(ctx, wsConn, lf, dbTx) - }) + ctx := context.Background() + var lf LogFilter + if logFilter != nil { + lf = *logFilter + } + return e.newFilter(ctx, wsConn, lf, nil) case "pendingTransactions", "newPendingTransactions": return e.newPendingTransactionFilter(wsConn) case "syncing": diff --git a/jsonrpc/endpoints_eth_test.go b/jsonrpc/endpoints_eth_test.go index 5da1d6a380..ae1daada23 100644 --- a/jsonrpc/endpoints_eth_test.go +++ b/jsonrpc/endpoints_eth_test.go @@ -64,18 +64,8 @@ func TestBlockNumber(t *testing.T) { ExpectedError: nil, ExpectedResult: blockNumTen.Uint64(), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumTen.Uint64(), nil). Once() }, @@ -85,18 +75,8 @@ func TestBlockNumber(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), ExpectedResult: 0, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -156,8 +136,6 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -172,10 +150,10 @@ func TestCall(t *testing.T) { return match }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumOneUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumOneUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -199,11 +177,9 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { @@ -219,7 +195,7 @@ func TestCall(t *testing.T) { }) m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumOneUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumOneUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -241,9 +217,7 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -258,10 +232,10 @@ func TestCall(t *testing.T) { return match }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -283,11 +257,9 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { @@ -303,7 +275,7 @@ func TestCall(t *testing.T) { }) m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumTenUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumTenUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -325,8 +297,6 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -340,10 +310,10 @@ func TestCall(t *testing.T) { tx.Nonce() == nonce }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, nil).Return(block, nil).Once() m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumTenUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, &blockNumTenUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -363,10 +333,8 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { blockHeader := state.NewL2Header(ðTypes.Header{GasLimit: s.Config.MaxCumulativeGasUsed}) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() - m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(blockHeader, nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(blockHeader, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -380,9 +348,9 @@ func TestCall(t *testing.T) { return hasTx && gasMatch && toMatch && gasPriceMatch && valueMatch && dataMatch }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -402,10 +370,8 @@ func TestCall(t *testing.T) { expectedError: nil, setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { blockHeader := state.NewL2Header(ðTypes.Header{GasLimit: s.Config.MaxCumulativeGasUsed}) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() - m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(blockHeader, nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(blockHeader, nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -419,9 +385,9 @@ func TestCall(t *testing.T) { return hasTx && gasMatch && toMatch && gasPriceMatch && valueMatch && dataMatch }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, true, nil). Return(&runtime.ExecutionResult{ReturnValue: testCase.expectedResult}, nil). Once() }, @@ -440,12 +406,10 @@ func TestCall(t *testing.T) { expectedResult: nil, expectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get block header"), setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { - m.DbTx.On("Rollback", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() - m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(nil, errors.New("failed to get block header")).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() + m.State.On("GetL2BlockHeaderByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(nil, errors.New("failed to get block header")).Once() }, }, { @@ -465,9 +429,7 @@ func TestCall(t *testing.T) { expectedError: types.NewRPCError(types.DefaultErrorCode, "failed to process unsigned transaction"), setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) - m.DbTx.On("Rollback", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -482,10 +444,10 @@ func TestCall(t *testing.T) { return hasTx && gasMatch && toMatch && gasPriceMatch && valueMatch && dataMatch && nonceMatch }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, nil). Return(&runtime.ExecutionResult{Err: errors.New("failed to process unsigned transaction")}, nil). Once() }, @@ -507,9 +469,7 @@ func TestCall(t *testing.T) { 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() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(blockNumOne.Uint64(), nil).Once() + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(blockNumOne.Uint64(), nil).Once() txArgs := testCase.params[0].(types.TxArgs) txMatchBy := mock.MatchedBy(func(tx *ethTypes.Transaction) bool { gasPrice := big.NewInt(0).SetBytes(*txArgs.GasPrice) @@ -524,10 +484,10 @@ func TestCall(t *testing.T) { return hasTx && gasMatch && toMatch && gasPriceMatch && valueMatch && dataMatch && nonceMatch }) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOneUint64, nil).Return(block, nil).Once() m.State.On("GetNonce", context.Background(), *txArgs.From, blockRoot).Return(nonce, nil).Once() m.State. - On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, m.DbTx). + On("ProcessUnsignedTransaction", context.Background(), txMatchBy, *txArgs.From, nilUint64, true, nil). Return(&runtime.ExecutionResult{Err: runtime.ErrExecutionReverted}, nil). Once() }, @@ -678,18 +638,15 @@ func TestEstimateGas(t *testing.T) { return matchTo && matchGasPrice && matchValue && matchData && matchNonce }) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetLastL2Block", context.Background(), m.DbTx).Return(block, nil).Once() + m.State.On("GetLastL2Block", context.Background(), nil).Return(block, nil).Once() m.State. On("GetNonce", context.Background(), *txArgs.From, blockRoot). Return(nonce, nil). Once() m.State. - On("EstimateGas", txMatchBy, *txArgs.From, nilUint64, m.DbTx). + On("EstimateGas", txMatchBy, *txArgs.From, nilUint64, nil). Return(*testCase.expectedResult, nil, nil). Once() }, @@ -723,14 +680,11 @@ func TestEstimateGas(t *testing.T) { return matchTo && matchGasPrice && matchValue && matchData && matchNonce }) - m.DbTx.On("Commit", context.Background()).Return(nil).Once() - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetLastL2Block", context.Background(), m.DbTx).Return(block, nil).Once() + m.State.On("GetLastL2Block", context.Background(), nil).Return(block, nil).Once() m.State. - On("EstimateGas", txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, m.DbTx). + On("EstimateGas", txMatchBy, common.HexToAddress(state.DefaultSenderAddress), nilUint64, nil). Return(*testCase.expectedResult, nil, nil). Once() }, @@ -823,18 +777,8 @@ func TestGetBalance(t *testing.T) { expectedBalance: 0, expectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), setupMocks: func(m *mocksWrapper, t *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(nil, errors.New("failed to get last block number")).Once() }, }, @@ -847,19 +791,9 @@ func TestGetBalance(t *testing.T) { expectedBalance: 1000, expectedError: nil, setupMocks: func(m *mocksWrapper, t *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(block, nil).Once() m.State. @@ -880,19 +814,9 @@ func TestGetBalance(t *testing.T) { expectedBalance: 1000, expectedError: nil, setupMocks: func(m *mocksWrapper, t *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil). Once() @@ -911,18 +835,8 @@ func TestGetBalance(t *testing.T) { expectedBalance: 0, expectedError: nil, setupMocks: func(m *mocksWrapper, t *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetLastL2Block", context.Background(), m.DbTx).Return(block, nil).Once() + m.State.On("GetLastL2Block", context.Background(), nil).Return(block, nil).Once() m.State. On("GetBalance", context.Background(), addressArg, blockRoot). @@ -939,18 +853,8 @@ func TestGetBalance(t *testing.T) { expectedBalance: 0, expectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get balance from state"), setupMocks: func(m *mocksWrapper, t *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetLastL2Block", context.Background(), m.DbTx).Return(block, nil).Once() + m.State.On("GetLastL2Block", context.Background(), nil).Return(block, nil).Once() m.State. On("GetBalance", context.Background(), addressArg, blockRoot). @@ -1005,18 +909,8 @@ func TestGetL2BlockByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: ethereum.NotFound, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound) }, }, @@ -1026,18 +920,8 @@ func TestGetL2BlockByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get block by hash from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get block from state")). Once() }, @@ -1060,24 +944,14 @@ func TestGetL2BlockByHash(t *testing.T) { } block := state.NewL2Block(state.NewL2Header(tc.ExpectedResult.Header()), tc.ExpectedResult.Transactions(), uncles, []*ethTypes.Receipt{ethTypes.NewReceipt([]byte{}, false, uint64(0))}, st) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(block, nil). Once() for _, tx := range tc.ExpectedResult.Transactions() { m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil). Once() } @@ -1265,18 +1139,8 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetL2BlockByNumber", context.Background(), tc.Number.Uint64(), m.DbTx). + On("GetL2BlockByNumber", context.Background(), tc.Number.Uint64(), nil). Return(nil, state.ErrNotFound) }, }, @@ -1286,30 +1150,20 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: rpcBlock, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByNumber", context.Background(), tc.Number.Uint64(), m.DbTx). + On("GetL2BlockByNumber", context.Background(), tc.Number.Uint64(), nil). Return(l2Block, nil). Once() for _, receipt := range receipts { m.State. - On("GetTransactionReceipt", context.Background(), receipt.TxHash, m.DbTx). + On("GetTransactionReceipt", context.Background(), receipt.TxHash, nil). Return(receipt, nil). Once() } for _, signedTx := range signedTransactions { m.State. - On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), nil). Return(state.Ptr(signedTx.Hash()), nil). Once() } @@ -1321,35 +1175,25 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: rpcBlock, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(tc.ExpectedResult.Number), nil). Once() m.State. - On("GetL2BlockByNumber", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetL2BlockByNumber", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(l2Block, nil). Once() for _, receipt := range receipts { m.State. - On("GetTransactionReceipt", context.Background(), receipt.TxHash, m.DbTx). + On("GetTransactionReceipt", context.Background(), receipt.TxHash, nil). Return(receipt, nil). Once() } for _, signedTx := range signedTransactions { m.State. - On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), nil). Return(state.Ptr(signedTx.Hash()), nil). Once() } @@ -1361,18 +1205,8 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -1383,23 +1217,13 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load block from state by number 1"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(1), nil). Once() m.State. - On("GetL2BlockByNumber", context.Background(), uint64(1), m.DbTx). + On("GetL2BlockByNumber", context.Background(), uint64(1), nil). Return(nil, errors.New("failed to load block by number")). Once() }, @@ -1428,18 +1252,8 @@ func TestGetL2BlockByNumber(t *testing.T) { tc.ExpectedResult.Nonce = nil tc.ExpectedResult.TotalDifficulty = nil - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(lastBlock, nil). Once() }, @@ -1450,18 +1264,8 @@ func TestGetL2BlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(nil, errors.New("failed to load last block")). Once() }, @@ -1627,18 +1431,8 @@ func TestGetCode(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(nil, errors.New("failed to get last block number")). Once() }, @@ -1653,18 +1447,8 @@ func TestGetCode(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get code"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(block, nil).Once() m.State. On("GetCode", context.Background(), addressArg, blockRoot). @@ -1682,18 +1466,8 @@ func TestGetCode(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(block, nil).Once() m.State. On("GetCode", context.Background(), addressArg, blockRoot). @@ -1711,18 +1485,8 @@ func TestGetCode(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumOne, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumOne.Uint64(), nil).Return(block, nil).Once() m.State. On("GetCode", context.Background(), addressArg, blockRoot). @@ -1739,19 +1503,9 @@ func TestGetCode(t *testing.T) { ExpectedResult: []byte{1, 2, 3}, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil). Once() @@ -1820,18 +1574,8 @@ func TestGetStorageAt(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(nil, errors.New("failed to get last block number")). Once() }, @@ -1849,19 +1593,9 @@ func TestGetStorageAt(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get storage value from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - blockNumber := big.NewInt(1) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumber, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), nil).Return(block, nil).Once() m.State. On("GetStorageAt", context.Background(), addressArg, keyArg.Big(), blockRoot). @@ -1882,19 +1616,9 @@ func TestGetStorageAt(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - blockNumber := big.NewInt(1) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumber, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), nil).Return(block, nil).Once() m.State. On("GetStorageAt", context.Background(), addressArg, keyArg.Big(), blockRoot). @@ -1915,19 +1639,9 @@ func TestGetStorageAt(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - blockNumber := big.NewInt(1) block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumber, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumber.Uint64(), nil).Return(block, nil).Once() m.State. On("GetStorageAt", context.Background(), addressArg, keyArg.Big(), blockRoot). @@ -1948,19 +1662,9 @@ func TestGetStorageAt(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil). Once() @@ -2031,18 +1735,8 @@ func TestSyncing(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get last block number from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last l2 block number from state")). Once() }, @@ -2052,23 +1746,13 @@ func TestSyncing(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get syncing info from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(10), nil). Once() m.State. - On("GetSyncingInfo", context.Background(), m.DbTx). + On("GetSyncingInfo", context.Background(), nil). Return(state.SyncingInfo{}, errors.New("failed to get syncing info from state")). Once() }, @@ -2078,23 +1762,13 @@ func TestSyncing(t *testing.T) { ExpectedResult: ðereum.SyncProgress{StartingBlock: 1, CurrentBlock: 2, HighestBlock: 3}, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(10), nil). Once() m.State. - On("GetSyncingInfo", context.Background(), m.DbTx). + On("GetSyncingInfo", context.Background(), nil). Return(state.SyncingInfo{InitialSyncingBlock: 1, CurrentBlockNumber: 2, EstimatedHighestBlock: 3, IsSynchronizing: true}, nil). Once() }, @@ -2104,23 +1778,13 @@ func TestSyncing(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(10), nil). Once() m.State. - On("GetSyncingInfo", context.Background(), m.DbTx). + On("GetSyncingInfo", context.Background(), nil). Return(state.SyncingInfo{InitialSyncingBlock: 1, CurrentBlockNumber: 1, EstimatedHighestBlock: 3, IsSynchronizing: false}, nil). Once() }, @@ -2130,23 +1794,13 @@ func TestSyncing(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(10), nil). Once() m.State. - On("GetSyncingInfo", context.Background(), m.DbTx). + On("GetSyncingInfo", context.Background(), nil). Return(state.SyncingInfo{InitialSyncingBlock: 1, CurrentBlockNumber: 2, EstimatedHighestBlock: 3, IsSynchronizing: false}, nil). Once() }, @@ -2208,18 +1862,9 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { tx := tc.ExpectedResult - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() m.State. - On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), nil). Return(tx, nil). Once() @@ -2229,7 +1874,7 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { receipt.TransactionIndex = tc.Index m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(receipt, nil). Once() }, @@ -2241,18 +1886,8 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { ExpectedResult: nil, ExpectedError: ethereum.NotFound, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), nil). Return(nil, state.ErrNotFound). Once() }, @@ -2264,18 +1899,8 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get transaction"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), nil). Return(nil, errors.New("failed to get transaction by block and index from state")). Once() }, @@ -2288,23 +1913,14 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { ExpectedError: ethereum.NotFound, SetupMocks: func(m *mocksWrapper, tc testCase) { tx := ethTypes.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), []byte{}) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(nil, state.ErrNotFound). Once() }, @@ -2317,23 +1933,14 @@ func TestGetTransactionL2onByBlockHashAndIndex(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get transaction receipt"), SetupMocks: func(m *mocksWrapper, tc testCase) { tx := ethTypes.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), []byte{}) - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() m.State. - On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockHashAndIndex", context.Background(), tc.Hash, uint64(tc.Index), nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(nil, errors.New("failed to get transaction receipt from state")). Once() }, @@ -2396,18 +2003,9 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { SetupMocks: func(m *mocksWrapper, tc testCase) { tx := tc.ExpectedResult blockNumber, _ := encoding.DecodeUint64orHex(&tc.BlockNumber) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), nil). Return(tx, nil). Once() @@ -2416,7 +2014,7 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { receipt.BlockNumber = big.NewInt(1) receipt.TransactionIndex = tc.Index m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(receipt, nil). Once() }, @@ -2428,18 +2026,8 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -2452,18 +2040,8 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { blockNumber, _ := encoding.DecodeUint64orHex(&tc.BlockNumber) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), nil). Return(nil, state.ErrNotFound). Once() }, @@ -2476,18 +2054,8 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get transaction"), SetupMocks: func(m *mocksWrapper, tc testCase) { blockNumber, _ := encoding.DecodeUint64orHex(&tc.BlockNumber) - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), nil). Return(nil, errors.New("failed to get transaction by block and index from state")). Once() }, @@ -2502,23 +2070,13 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { tx := ethTypes.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), []byte{}) blockNumber, _ := encoding.DecodeUint64orHex(&tc.BlockNumber) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(nil, state.ErrNotFound). Once() }, @@ -2533,23 +2091,13 @@ func TestGetTransactionByBlockNumberAndIndex(t *testing.T) { tx := ethTypes.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), []byte{}) blockNumber, _ := encoding.DecodeUint64orHex(&tc.BlockNumber) - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), m.DbTx). + On("GetTransactionByL2BlockNumberAndIndex", context.Background(), blockNumber, uint64(tc.Index), nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(nil, errors.New("failed to get transaction receipt from state")). Once() }, @@ -2616,18 +2164,8 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedResult: signedTx, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(tc.ExpectedResult, nil). Once() @@ -2636,7 +2174,7 @@ func TestGetTransactionByHash(t *testing.T) { receipt.BlockNumber = big.NewInt(1) m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(receipt, nil). Once() }, @@ -2648,18 +2186,8 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedResult: ethTypes.NewTransaction(1, common.Address{}, big.NewInt(1), 1, big.NewInt(1), []byte{}), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2676,18 +2204,8 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: ethereum.NotFound, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2704,18 +2222,8 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction by hash from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to load transaction by hash from state")). Once() }, @@ -2727,18 +2235,8 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction by hash from pool"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2756,23 +2254,14 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "transaction receipt not found"), SetupMocks: func(m *mocksWrapper, tc testCase) { tx := ðTypes.Transaction{} - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -2785,23 +2274,14 @@ func TestGetTransactionByHash(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction receipt from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { tx := ðTypes.Transaction{} - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to load transaction receipt from state")). Once() }, @@ -2852,18 +2332,8 @@ func TestGetBlockTransactionCountByHash(t *testing.T) { ExpectedResult: uint(10), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetL2BlockTransactionCountByHash", context.Background(), tc.BlockHash, m.DbTx). + On("GetL2BlockTransactionCountByHash", context.Background(), tc.BlockHash, nil). Return(uint64(10), nil). Once() }, @@ -2874,18 +2344,8 @@ func TestGetBlockTransactionCountByHash(t *testing.T) { ExpectedResult: 0, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to count transactions"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockTransactionCountByHash", context.Background(), tc.BlockHash, m.DbTx). + On("GetL2BlockTransactionCountByHash", context.Background(), tc.BlockHash, nil). Return(uint64(0), errors.New("failed to count txs")). Once() }, @@ -2933,23 +2393,14 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { blockNumber := uint64(10) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumber, nil). Once() m.State. - On("GetL2BlockTransactionCountByNumber", context.Background(), blockNumber, m.DbTx). + On("GetL2BlockTransactionCountByNumber", context.Background(), blockNumber, nil). Return(uint64(10), nil). Once() }, @@ -2960,16 +2411,6 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ExpectedResult: uint(10), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Pool. On("CountPendingTransactions", context.Background()). Return(uint64(10), nil). @@ -2982,18 +2423,8 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ExpectedResult: 0, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -3005,23 +2436,14 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to count transactions"), SetupMocks: func(m *mocksWrapper, tc testCase) { blockNumber := uint64(10) - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumber, nil). Once() m.State. - On("GetL2BlockTransactionCountByNumber", context.Background(), blockNumber, m.DbTx). + On("GetL2BlockTransactionCountByNumber", context.Background(), blockNumber, nil). Return(uint64(0), errors.New("failed to count")). Once() }, @@ -3032,16 +2454,6 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ExpectedResult: 0, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to count pending transactions"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Pool. On("CountPendingTransactions", context.Background()). Return(uint64(0), errors.New("failed to count")). @@ -3094,18 +2506,8 @@ func TestGetTransactionCount(t *testing.T) { ExpectedResult: uint(10), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetLastL2Block", context.Background(), m.DbTx).Return(block, nil).Once() + m.State.On("GetLastL2Block", context.Background(), nil).Return(block, nil).Once() m.State. On("GetNonce", context.Background(), addressArg, blockRoot). @@ -3122,19 +2524,9 @@ func TestGetTransactionCount(t *testing.T) { ExpectedResult: uint(10), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) m.State. - On("GetL2BlockByHash", context.Background(), blockHash, m.DbTx). + On("GetL2BlockByHash", context.Background(), blockHash, nil). Return(block, nil). Once() @@ -3153,23 +2545,13 @@ func TestGetTransactionCount(t *testing.T) { ExpectedResult: 0, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumTen.Uint64(), nil). Once() block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, nil).Return(block, nil).Once() m.State. On("GetNonce", context.Background(), addressArg, blockRoot). @@ -3186,18 +2568,8 @@ func TestGetTransactionCount(t *testing.T) { ExpectedResult: 0, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -3211,23 +2583,13 @@ func TestGetTransactionCount(t *testing.T) { ExpectedResult: 0, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to count transactions"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumTen.Uint64(), nil). Once() block := state.NewL2BlockWithHeader(state.NewL2Header(ðTypes.Header{Number: blockNumTen, Root: blockRoot})) - m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, m.DbTx).Return(block, nil).Once() + m.State.On("GetL2BlockByNumber", context.Background(), blockNumTenUint64, nil).Return(block, nil).Once() m.State. On("GetNonce", context.Background(), addressArg, blockRoot). @@ -3337,23 +2699,13 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: &rpcReceipt, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(receipt, nil). Once() }, @@ -3364,18 +2716,8 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -3386,18 +2728,8 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get tx from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get tx")). Once() }, @@ -3408,23 +2740,13 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -3435,23 +2757,13 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get tx receipt from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get tx receipt from state")). Once() }, @@ -3462,23 +2774,13 @@ func TestGetTransactionReceipt(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to build the receipt response"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByHash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByHash", context.Background(), tc.Hash, nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(receipt, nil). Once() }, @@ -3853,16 +3155,6 @@ func TestNewFilter(t *testing.T) { ExpectedResult: "1", ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Storage. On("NewLogFilter", mock.IsType(&concurrentWsConn{}), mock.IsType(LogFilter{})). Return("1", nil). @@ -3877,16 +3169,6 @@ func TestNewFilter(t *testing.T) { ExpectedResult: "1", ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Storage. On("NewLogFilter", mock.IsType(&concurrentWsConn{}), mock.IsType(LogFilter{})). Return("1", nil). @@ -3902,15 +3184,6 @@ func TestNewFilter(t *testing.T) { ExpectedResult: "", ExpectedError: types.NewRPCError(types.InvalidParamsErrorCode, "invalid block range"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, { @@ -3922,15 +3195,6 @@ func TestNewFilter(t *testing.T) { ExpectedResult: "", ExpectedError: types.NewRPCError(types.InvalidParamsErrorCode, "logs are limited to a 10000 block range"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, { @@ -3941,15 +3205,6 @@ func TestNewFilter(t *testing.T) { ExpectedResult: "", ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to create new log filter"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() m.Storage. On("NewLogFilter", mock.IsType(&concurrentWsConn{}), mock.IsType(LogFilter{})). Return("", errors.New("failed to add new filter")). @@ -4216,18 +3471,8 @@ func TestGetLogs(t *testing.T) { logs = append(logs, &l) } - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, m.DbTx). + On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, nil). Return(logs, nil). Once() }, @@ -4245,18 +3490,8 @@ func TestGetLogs(t *testing.T) { }, SetupMocks: func(m *mocksWrapper, tc testCase) { var since *time.Time - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, m.DbTx). + On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, nil). Return(nil, errors.New("failed to get logs from state")). Once() }, @@ -4273,18 +3508,8 @@ func TestGetLogs(t *testing.T) { tc.ExpectedError = types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state") }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number from state")). Once() }, @@ -4301,18 +3526,8 @@ func TestGetLogs(t *testing.T) { tc.ExpectedError = types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state") }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number from state")). Once() }, @@ -4329,15 +3544,6 @@ func TestGetLogs(t *testing.T) { tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "logs are limited to a 10000 block range") }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, { @@ -4353,18 +3559,9 @@ func TestGetLogs(t *testing.T) { }, SetupMocks: func(m *mocksWrapper, tc testCase) { var since *time.Time - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, m.DbTx). + On("GetLogs", context.Background(), tc.Filter.FromBlock.Uint64(), tc.Filter.ToBlock.Uint64(), tc.Filter.Addresses, tc.Filter.Topics, tc.Filter.BlockHash, since, nil). Return(nil, state.ErrMaxLogsCountLimitExceeded). Once() }, @@ -4445,23 +3642,13 @@ func TestGetFilterLogs(t *testing.T) { Parameters: logFilter, } - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Storage. On("GetFilter", tc.FilterID). Return(filter, nil). Once() m.State. - On("GetLogs", context.Background(), uint64(*logFilter.FromBlock), uint64(*logFilter.ToBlock), logFilter.Addresses, logFilter.Topics, logFilter.BlockHash, since, m.DbTx). + On("GetLogs", context.Background(), uint64(*logFilter.FromBlock), uint64(*logFilter.ToBlock), logFilter.Addresses, logFilter.Topics, logFilter.BlockHash, since, nil). Return(logs, nil). Once() }, @@ -5199,16 +4386,6 @@ func TestSubscribeNewLogs(t *testing.T) { } }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Storage. On("NewLogFilter", mock.IsType(&concurrentWsConn{}), mock.IsType(LogFilter{})). Return("0x1", nil). @@ -5224,16 +4401,6 @@ func TestSubscribeNewLogs(t *testing.T) { } }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.Storage. On("NewLogFilter", mock.IsType(&concurrentWsConn{}), mock.IsType(LogFilter{})). Return("", fmt.Errorf("failed to add filter to storage")). @@ -5249,15 +4416,6 @@ func TestSubscribeNewLogs(t *testing.T) { } }, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, } diff --git a/jsonrpc/endpoints_zkevm.go b/jsonrpc/endpoints_zkevm.go index 636239361b..9e12a9d9b4 100644 --- a/jsonrpc/endpoints_zkevm.go +++ b/jsonrpc/endpoints_zkevm.go @@ -27,7 +27,6 @@ type ZKEVMEndpoints struct { pool types.PoolInterface state types.StateInterface etherman types.EthermanInterface - txMan DBTxManager } // NewZKEVMEndpoints returns ZKEVMEndpoints @@ -42,166 +41,158 @@ func NewZKEVMEndpoints(cfg Config, pool types.PoolInterface, state types.StateIn // ConsolidatedBlockNumber returns last block number related to the last verified batch func (z *ZKEVMEndpoints) ConsolidatedBlockNumber() (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - lastBlockNumber, err := z.state.GetLastConsolidatedL2BlockNumber(ctx, dbTx) - if err != nil { - const errorMessage = "failed to get last consolidated block number from state" - log.Errorf("%v:%v", errorMessage, err) - return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) - } + ctx := context.Background() + lastBlockNumber, err := z.state.GetLastConsolidatedL2BlockNumber(ctx, nil) + if err != nil { + const errorMessage = "failed to get last consolidated block number from state" + log.Errorf("%v:%v", errorMessage, err) + return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) + } - return hex.EncodeUint64(lastBlockNumber), nil - }) + return hex.EncodeUint64(lastBlockNumber), nil } // IsBlockConsolidated returns the consolidation status of a provided block number func (z *ZKEVMEndpoints) IsBlockConsolidated(blockNumber types.ArgUint64) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - IsL2BlockConsolidated, err := z.state.IsL2BlockConsolidated(ctx, uint64(blockNumber), dbTx) - if err != nil { - const errorMessage = "failed to check if the block is consolidated" - log.Errorf("%v: %v", errorMessage, err) - return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) - } + ctx := context.Background() + IsL2BlockConsolidated, err := z.state.IsL2BlockConsolidated(ctx, uint64(blockNumber), nil) + if err != nil { + const errorMessage = "failed to check if the block is consolidated" + log.Errorf("%v: %v", errorMessage, err) + return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) + } - return IsL2BlockConsolidated, nil - }) + return IsL2BlockConsolidated, nil } // IsBlockVirtualized returns the virtualization status of a provided block number func (z *ZKEVMEndpoints) IsBlockVirtualized(blockNumber types.ArgUint64) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - IsL2BlockVirtualized, err := z.state.IsL2BlockVirtualized(ctx, uint64(blockNumber), dbTx) - if err != nil { - const errorMessage = "failed to check if the block is virtualized" - log.Errorf("%v: %v", errorMessage, err) - return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) - } + ctx := context.Background() + IsL2BlockVirtualized, err := z.state.IsL2BlockVirtualized(ctx, uint64(blockNumber), nil) + if err != nil { + const errorMessage = "failed to check if the block is virtualized" + log.Errorf("%v: %v", errorMessage, err) + return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) + } - return IsL2BlockVirtualized, nil - }) + return IsL2BlockVirtualized, nil } // BatchNumberByBlockNumber returns the batch number from which the passed block number is created func (z *ZKEVMEndpoints) BatchNumberByBlockNumber(blockNumber types.ArgUint64) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - batchNum, err := z.state.BatchNumberByL2BlockNumber(ctx, uint64(blockNumber), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - const errorMessage = "failed to get batch number from block number" - log.Errorf("%v: %v", errorMessage, err.Error()) - return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) - } + ctx := context.Background() + batchNum, err := z.state.BatchNumberByL2BlockNumber(ctx, uint64(blockNumber), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + const errorMessage = "failed to get batch number from block number" + log.Errorf("%v: %v", errorMessage, err.Error()) + return nil, types.NewRPCError(types.DefaultErrorCode, errorMessage) + } - return hex.EncodeUint64(batchNum), nil - }) + return hex.EncodeUint64(batchNum), nil } // BatchNumber returns the latest trusted batch number func (z *ZKEVMEndpoints) BatchNumber() (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - lastBatchNumber, err := z.state.GetLastBatchNumber(ctx, dbTx) - if err != nil { - return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last batch number from state") - } + ctx := context.Background() + lastBatchNumber, err := z.state.GetLastBatchNumber(ctx, nil) + if err != nil { + return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last batch number from state") + } - return hex.EncodeUint64(lastBatchNumber), nil - }) + return hex.EncodeUint64(lastBatchNumber), nil } // VirtualBatchNumber returns the latest virtualized batch number func (z *ZKEVMEndpoints) VirtualBatchNumber() (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - lastBatchNumber, err := z.state.GetLastVirtualBatchNum(ctx, dbTx) - if err != nil { - return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last virtual batch number from state") - } + ctx := context.Background() + lastBatchNumber, err := z.state.GetLastVirtualBatchNum(ctx, nil) + if err != nil { + return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last virtual batch number from state") + } - return hex.EncodeUint64(lastBatchNumber), nil - }) + return hex.EncodeUint64(lastBatchNumber), nil } // VerifiedBatchNumber returns the latest verified batch number func (z *ZKEVMEndpoints) VerifiedBatchNumber() (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - lastBatch, err := z.state.GetLastVerifiedBatch(ctx, dbTx) - if err != nil { - return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last verified batch number from state") - } - return hex.EncodeUint64(lastBatch.BatchNumber), nil - }) + ctx := context.Background() + lastBatch, err := z.state.GetLastVerifiedBatch(ctx, nil) + if err != nil { + return "0x0", types.NewRPCError(types.DefaultErrorCode, "failed to get the last verified batch number from state") + } + return hex.EncodeUint64(lastBatch.BatchNumber), nil } // GetBatchByNumber returns information about a batch by batch number func (z *ZKEVMEndpoints) GetBatchByNumber(batchNumber types.BatchNumber, fullTx bool) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var err error - batchNumber, rpcErr := batchNumber.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + var err error + numericBatchNumber, rpcErr := batchNumber.GetNumericBatchNumber(ctx, z.state, z.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - batch, err := z.state.GetBatchByNumber(ctx, batchNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch from state by number %v", batchNumber), err, true) - } - batchTimestamp, err := z.state.GetBatchTimestamp(ctx, batchNumber, nil, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch timestamp from state by number %v", batchNumber), err, true) - } + batch, err := z.state.GetBatchByNumber(ctx, numericBatchNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch from state by number %v", numericBatchNumber), err, true) + } + batchTimestamp, err := z.state.GetBatchTimestamp(ctx, numericBatchNumber, nil, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch timestamp from state by number %v", numericBatchNumber), err, true) + } - if batchTimestamp == nil { - batch.Timestamp = time.Time{} - } else { - batch.Timestamp = *batchTimestamp - } + if batchTimestamp == nil { + batch.Timestamp = time.Time{} + } else { + batch.Timestamp = *batchTimestamp + } - txs, _, err := z.state.GetTransactionsByBatchNumber(ctx, batchNumber, dbTx) - if !errors.Is(err, state.ErrNotFound) && err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch txs from state by number %v", batchNumber), err, true) - } + txs, _, err := z.state.GetTransactionsByBatchNumber(ctx, numericBatchNumber, nil) + if !errors.Is(err, state.ErrNotFound) && err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load batch txs from state by number %v", numericBatchNumber), err, true) + } - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - virtualBatch, err := z.state.GetVirtualBatch(ctx, batchNumber, dbTx) - if err != nil && !errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load virtual batch from state by number %v", batchNumber), err, true) - } + virtualBatch, err := z.state.GetVirtualBatch(ctx, numericBatchNumber, nil) + if err != nil && !errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load virtual batch from state by number %v", numericBatchNumber), err, true) + } - verifiedBatch, err := z.state.GetVerifiedBatch(ctx, batchNumber, dbTx) - if err != nil && !errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load virtual batch from state by number %v", batchNumber), err, true) - } + verifiedBatch, err := z.state.GetVerifiedBatch(ctx, numericBatchNumber, nil) + if err != nil && !errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load virtual batch from state by number %v", numericBatchNumber), err, true) + } - ger, err := z.state.GetExitRootByGlobalExitRoot(ctx, batch.GlobalExitRoot, dbTx) - if err != nil && !errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load full GER from state by number %v", batchNumber), err, true) - } else if errors.Is(err, state.ErrNotFound) { - ger = &state.GlobalExitRoot{} - } + ger, err := z.state.GetExitRootByGlobalExitRoot(ctx, batch.GlobalExitRoot, nil) + if err != nil && !errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load full GER from state by number %v", numericBatchNumber), err, true) + } else if errors.Is(err, state.ErrNotFound) { + ger = &state.GlobalExitRoot{} + } - blocks, err := z.state.GetL2BlocksByBatchNumber(ctx, batchNumber, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load blocks associated to the batch %v", batchNumber), err, true) - } + blocks, err := z.state.GetL2BlocksByBatchNumber(ctx, numericBatchNumber, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load blocks associated to the batch %v", numericBatchNumber), err, true) + } - batch.Transactions = txs - rpcBatch, err := types.NewBatch(ctx, z.state, batch, virtualBatch, verifiedBatch, blocks, receipts, fullTx, true, ger, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build the batch %v response", batchNumber), err, true) - } - return rpcBatch, nil - }) + batch.Transactions = txs + rpcBatch, err := types.NewBatch(ctx, z.state, batch, virtualBatch, verifiedBatch, blocks, receipts, fullTx, true, ger, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build the batch %v response", numericBatchNumber), err, true) + } + return rpcBatch, nil } type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) @@ -253,195 +244,190 @@ func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) // GetFullBlockByNumber returns information about a block by block number func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - if number == types.PendingBlockNumber { - lastBlock, err := z.state.GetLastL2Block(ctx, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block", err, true) - } - l2Header := state.NewL2Header(ðTypes.Header{ - ParentHash: lastBlock.Hash(), - Number: big.NewInt(0).SetUint64(lastBlock.Number().Uint64() + 1), - TxHash: ethTypes.EmptyRootHash, - UncleHash: ethTypes.EmptyUncleHash, - }) - l2Block := state.NewL2BlockWithHeader(l2Header) - rpcBlock, err := types.NewBlock(ctx, z.state, nil, l2Block, nil, fullTx, false, state.Ptr(true), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "couldn't build the pending block response", err, true) - } - - // clean fields that are not available for pending block - rpcBlock.Hash = nil - rpcBlock.Miner = nil - rpcBlock.Nonce = nil - rpcBlock.TotalDifficulty = nil - - return rpcBlock, nil - } - var err error - blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, z.state, z.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr + ctx := context.Background() + if number == types.PendingBlockNumber { + lastBlock, err := z.state.GetLastL2Block(ctx, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block", err, true) + } + l2Header := state.NewL2Header(ðTypes.Header{ + ParentHash: lastBlock.Hash(), + Number: big.NewInt(0).SetUint64(lastBlock.Number().Uint64() + 1), + TxHash: ethTypes.EmptyRootHash, + UncleHash: ethTypes.EmptyUncleHash, + }) + l2Block := state.NewL2BlockWithHeader(l2Header) + rpcBlock, err := types.NewBlock(ctx, z.state, nil, l2Block, nil, fullTx, false, state.Ptr(true), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "couldn't build the pending block response", err, true) } - l2Block, err := z.state.GetL2BlockByNumber(ctx, blockNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load block from state by number %v", blockNumber), err, true) - } + // clean fields that are not available for pending block + rpcBlock.Hash = nil + rpcBlock.Miner = nil + rpcBlock.Nonce = nil + rpcBlock.TotalDifficulty = nil - txs := l2Block.Transactions() - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) - } + return rpcBlock, nil + } + var err error + blockNumber, rpcErr := number.GetNumericBlockNumber(ctx, z.state, z.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - rpcBlock, err := types.NewBlock(ctx, z.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, true, state.Ptr(true), dbTx) + l2Block, err := z.state.GetL2BlockByNumber(ctx, blockNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load block from state by number %v", blockNumber), err, true) + } + + txs := l2Block.Transactions() + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by number %v", blockNumber), err, true) + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - return rpcBlock, nil - }) + rpcBlock, err := types.NewBlock(ctx, z.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, true, state.Ptr(true), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by number %v", blockNumber), err, true) + } + + return rpcBlock, nil } // GetFullBlockByHash returns information about a block by hash func (z *ZKEVMEndpoints) GetFullBlockByHash(hash types.ArgHash, fullTx bool) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - l2Block, err := z.state.GetL2BlockByHash(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) - } - - txs := l2Block.Transactions() - receipts := make([]ethTypes.Receipt, 0, len(txs)) - for _, tx := range txs { - receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) - } - receipts = append(receipts, *receipt) - } + ctx := context.Background() + l2Block, err := z.state.GetL2BlockByHash(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) + } - rpcBlock, err := types.NewBlock(ctx, z.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, true, state.Ptr(true), dbTx) + txs := l2Block.Transactions() + receipts := make([]ethTypes.Receipt, 0, len(txs)) + for _, tx := range txs { + receipt, err := z.state.GetTransactionReceipt(ctx, tx.Hash(), nil) if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by hash %v", hash.Hash()), err, true) + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't load receipt for tx %v", tx.Hash().String()), err, true) } + receipts = append(receipts, *receipt) + } - return rpcBlock, nil - }) + rpcBlock, err := types.NewBlock(ctx, z.state, state.Ptr(l2Block.Hash()), l2Block, receipts, fullTx, true, state.Ptr(true), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, fmt.Sprintf("couldn't build block response for block by hash %v", hash.Hash()), err, true) + } + + return rpcBlock, nil } // GetNativeBlockHashesInRange return the state root for the blocks in range func (z *ZKEVMEndpoints) GetNativeBlockHashesInRange(filter NativeBlockHashBlockRangeFilter) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - fromBlockNumber, toBlockNumber, rpcErr := filter.GetNumericBlockNumbers(ctx, z.cfg, z.state, z.etherman, dbTx) - if rpcErr != nil { - return nil, rpcErr - } + ctx := context.Background() + fromBlockNumber, toBlockNumber, rpcErr := filter.GetNumericBlockNumbers(ctx, z.cfg, z.state, z.etherman, nil) + if rpcErr != nil { + return nil, rpcErr + } - nativeBlockHashes, err := z.state.GetNativeBlockHashesInRange(ctx, fromBlockNumber, toBlockNumber, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if errors.Is(err, state.ErrMaxNativeBlockHashBlockRangeLimitExceeded) { - errMsg := fmt.Sprintf(state.ErrMaxNativeBlockHashBlockRangeLimitExceeded.Error(), z.cfg.MaxNativeBlockHashBlockRange) - return RPCErrorResponse(types.InvalidParamsErrorCode, errMsg, nil, false) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) - } + nativeBlockHashes, err := z.state.GetNativeBlockHashesInRange(ctx, fromBlockNumber, toBlockNumber, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if errors.Is(err, state.ErrMaxNativeBlockHashBlockRangeLimitExceeded) { + errMsg := fmt.Sprintf(state.ErrMaxNativeBlockHashBlockRangeLimitExceeded.Error(), z.cfg.MaxNativeBlockHashBlockRange) + return RPCErrorResponse(types.InvalidParamsErrorCode, errMsg, nil, false) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get block by hash from state", err, true) + } - return nativeBlockHashes, nil - }) + return nativeBlockHashes, nil } // GetTransactionByL2Hash returns a transaction by his l2 hash func (z *ZKEVMEndpoints) GetTransactionByL2Hash(hash types.ArgHash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - // try to get tx from state - tx, err := z.state.GetTransactionByL2Hash(ctx, hash.Hash(), dbTx) - if err != nil && !errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by l2 hash from state", err, true) + ctx := context.Background() + // try to get tx from state + tx, err := z.state.GetTransactionByL2Hash(ctx, hash.Hash(), nil) + if err != nil && !errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by l2 hash from state", err, true) + } + if tx != nil { + receipt, err := z.state.GetTransactionReceipt(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return RPCErrorResponse(types.DefaultErrorCode, "transaction receipt not found", err, false) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction receipt from state", err, true) } - if tx != nil { - receipt, err := z.state.GetTransactionReceipt(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return RPCErrorResponse(types.DefaultErrorCode, "transaction receipt not found", err, false) - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction receipt from state", err, true) - } - - l2Hash, err := z.state.GetL2TxHashByTxHash(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) - } - - res, err := types.NewTransaction(*tx, receipt, false, l2Hash) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) - } - return res, nil + l2Hash, err := z.state.GetL2TxHashByTxHash(ctx, tx.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) } - // if the tx does not exist in the state, look for it in the pool - if z.cfg.SequencerNodeURI != "" { - return z.getTransactionByL2HashFromSequencerNode(hash.Hash()) - } - poolTx, err := z.pool.GetTransactionByL2Hash(ctx, hash.Hash()) - if errors.Is(err, pool.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by l2 hash from pool", err, true) - } - if poolTx.Status == pool.TxStatusPending { - tx = &poolTx.Transaction - res, err := types.NewTransaction(*tx, nil, false, nil) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) - } - return res, nil + res, err := types.NewTransaction(*tx, receipt, false, l2Hash) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) } + + return res, nil + } + + // if the tx does not exist in the state, look for it in the pool + if z.cfg.SequencerNodeURI != "" { + return z.getTransactionByL2HashFromSequencerNode(hash.Hash()) + } + poolTx, err := z.pool.GetTransactionByL2Hash(ctx, hash.Hash()) + if errors.Is(err, pool.ErrNotFound) { return nil, nil - }) + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to load transaction by l2 hash from pool", err, true) + } + if poolTx.Status == pool.TxStatusPending { + tx = &poolTx.Transaction + res, err := types.NewTransaction(*tx, nil, false, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build transaction response", err, true) + } + return res, nil + } + return nil, nil } // GetTransactionReceiptByL2Hash returns a transaction receipt by his hash func (z *ZKEVMEndpoints) GetTransactionReceiptByL2Hash(hash types.ArgHash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - tx, err := z.state.GetTransactionByL2Hash(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx from state", err, true) - } + ctx := context.Background() + tx, err := z.state.GetTransactionByL2Hash(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx from state", err, true) + } - r, err := z.state.GetTransactionReceipt(ctx, hash.Hash(), dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx receipt from state", err, true) - } + r, err := z.state.GetTransactionReceipt(ctx, hash.Hash(), nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get tx receipt from state", err, true) + } - l2Hash, err := z.state.GetL2TxHashByTxHash(ctx, tx.Hash(), dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) - } + l2Hash, err := z.state.GetL2TxHashByTxHash(ctx, tx.Hash(), nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get l2 transaction hash", err, true) + } - receipt, err := types.NewReceipt(*tx, r, l2Hash) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to build the receipt response", err, true) - } + receipt, err := types.NewReceipt(*tx, r, l2Hash) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to build the receipt response", err, true) + } - return receipt, nil - }) + return receipt, nil } func (z *ZKEVMEndpoints) getTransactionByL2HashFromSequencerNode(hash common.Hash) (interface{}, types.Error) { @@ -464,43 +450,40 @@ func (z *ZKEVMEndpoints) getTransactionByL2HashFromSequencerNode(hash common.Has // GetExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root func (z *ZKEVMEndpoints) GetExitRootsByGER(globalExitRoot common.Hash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - exitRoots, err := z.state.GetExitRootByGlobalExitRoot(ctx, globalExitRoot, dbTx) - if errors.Is(err, state.ErrNotFound) { - return nil, nil - } else if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to get exit roots by global exit root from state", err, true) - } + ctx := context.Background() + exitRoots, err := z.state.GetExitRootByGlobalExitRoot(ctx, globalExitRoot, nil) + if errors.Is(err, state.ErrNotFound) { + return nil, nil + } else if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to get exit roots by global exit root from state", err, true) + } - return types.ExitRoots{ - BlockNumber: types.ArgUint64(exitRoots.BlockNumber), - Timestamp: types.ArgUint64(exitRoots.Timestamp.Unix()), - MainnetExitRoot: exitRoots.MainnetExitRoot, - RollupExitRoot: exitRoots.RollupExitRoot, - }, nil - }) + return types.ExitRoots{ + BlockNumber: types.ArgUint64(exitRoots.BlockNumber), + Timestamp: types.ArgUint64(exitRoots.Timestamp.Unix()), + MainnetExitRoot: exitRoots.MainnetExitRoot, + RollupExitRoot: exitRoots.RollupExitRoot, + }, nil } // EstimateGasPrice returns an estimate gas price for the transaction. func (z *ZKEVMEndpoints) EstimateGasPrice(arg *types.TxArgs, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - gasPrice, _, err := z.internalEstimateGasPriceAndFee(ctx, arg, blockArg, dbTx) - if err != nil { - return nil, err - } - return hex.EncodeBig(gasPrice), nil - }) + ctx := context.Background() + gasPrice, _, err := z.internalEstimateGasPriceAndFee(ctx, arg, blockArg, nil) + if err != nil { + return nil, err + } + return hex.EncodeBig(gasPrice), nil } // EstimateFee returns an estimate fee for the transaction. func (z *ZKEVMEndpoints) EstimateFee(arg *types.TxArgs, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - _, fee, err := z.internalEstimateGasPriceAndFee(ctx, arg, blockArg, dbTx) - if err != nil { - return nil, err - } - return hex.EncodeBig(fee), nil - }) + ctx := context.Background() + _, fee, err := z.internalEstimateGasPriceAndFee(ctx, arg, blockArg, nil) + if err != nil { + return nil, err + } + return hex.EncodeBig(fee), nil } // internalEstimateGasPriceAndFee computes the estimated gas price and the estimated fee for the transaction @@ -509,7 +492,7 @@ func (z *ZKEVMEndpoints) internalEstimateGasPriceAndFee(ctx context.Context, arg return nil, nil, types.NewRPCError(types.InvalidParamsErrorCode, "missing value for required argument 0") } - block, respErr := z.getBlockByArg(ctx, blockArg, dbTx) + block, respErr := z.getBlockByArg(ctx, blockArg, nil) if respErr != nil { return nil, nil, respErr } @@ -526,12 +509,12 @@ func (z *ZKEVMEndpoints) internalEstimateGasPriceAndFee(ctx context.Context, arg } defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) - sender, tx, err := arg.ToTransaction(ctx, z.state, z.cfg.MaxCumulativeGasUsed, block.Root(), defaultSenderAddress, dbTx) + sender, tx, err := arg.ToTransaction(ctx, z.state, z.cfg.MaxCumulativeGasUsed, block.Root(), defaultSenderAddress, nil) if err != nil { return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction") } - gasEstimation, returnValue, err := z.state.EstimateGas(tx, sender, blockToProcess, dbTx) + gasEstimation, returnValue, err := z.state.EstimateGas(tx, sender, blockToProcess, nil) if errors.Is(err, runtime.ErrExecutionReverted) { data := make([]byte, len(returnValue)) copy(data, returnValue) @@ -587,78 +570,77 @@ func (z *ZKEVMEndpoints) internalEstimateGasPriceAndFee(ctx context.Context, arg // EstimateCounters returns an estimation of the counters that are going to be used while executing // this transaction. func (z *ZKEVMEndpoints) EstimateCounters(arg *types.TxArgs, blockArg *types.BlockNumberOrHash) (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.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) - } + ctx := context.Background() + if arg == nil { + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) + } - block, respErr := z.getBlockByArg(ctx, blockArg, dbTx) - if respErr != nil { - return nil, respErr - } + block, respErr := z.getBlockByArg(ctx, blockArg, nil) + if respErr != nil { + return nil, respErr + } - var blockToProcess *uint64 - if blockArg != nil { - blockNumArg := blockArg.Number() - if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { - blockToProcess = nil - } else { - n := block.NumberU64() - blockToProcess = &n - } + var blockToProcess *uint64 + if blockArg != nil { + blockNumArg := blockArg.Number() + if blockNumArg != nil && (*blockArg.Number() == types.LatestBlockNumber || *blockArg.Number() == types.PendingBlockNumber) { + blockToProcess = nil + } else { + n := block.NumberU64() + blockToProcess = &n } + } - defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) - sender, tx, err := arg.ToTransaction(ctx, z.state, z.cfg.MaxCumulativeGasUsed, block.Root(), defaultSenderAddress, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) - } + defaultSenderAddress := common.HexToAddress(state.DefaultSenderAddress) + sender, tx, err := arg.ToTransaction(ctx, z.state, z.cfg.MaxCumulativeGasUsed, block.Root(), defaultSenderAddress, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "failed to convert arguments into an unsigned transaction", err, false) + } - var oocErr error - processBatchResponse, err := z.state.PreProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, dbTx) - if err != nil { - if executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) { - oocErr = err - } else { - errMsg := fmt.Sprintf("failed to estimate counters: %v", err.Error()) - return nil, types.NewRPCError(types.DefaultErrorCode, errMsg) - } + var oocErr error + processBatchResponse, err := z.state.PreProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, nil) + if err != nil { + if executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) { + oocErr = err + } else { + errMsg := fmt.Sprintf("failed to estimate counters: %v", err.Error()) + return nil, types.NewRPCError(types.DefaultErrorCode, errMsg) } + } - var revert *types.RevertInfo - if len(processBatchResponse.BlockResponses) > 0 && len(processBatchResponse.BlockResponses[0].TransactionResponses) > 0 { - txResponse := processBatchResponse.BlockResponses[0].TransactionResponses[0] - err = txResponse.RomError - if errors.Is(err, runtime.ErrExecutionReverted) { - returnValue := make([]byte, len(txResponse.ReturnValue)) - copy(returnValue, txResponse.ReturnValue) - err := state.ConstructErrorFromRevert(err, returnValue) - revert = &types.RevertInfo{ - Message: err.Error(), - Data: state.Ptr(types.ArgBytes(returnValue)), - } + var revert *types.RevertInfo + if len(processBatchResponse.BlockResponses) > 0 && len(processBatchResponse.BlockResponses[0].TransactionResponses) > 0 { + txResponse := processBatchResponse.BlockResponses[0].TransactionResponses[0] + err = txResponse.RomError + if errors.Is(err, runtime.ErrExecutionReverted) { + returnValue := make([]byte, len(txResponse.ReturnValue)) + copy(returnValue, txResponse.ReturnValue) + err := state.ConstructErrorFromRevert(err, returnValue) + revert = &types.RevertInfo{ + Message: err.Error(), + Data: state.Ptr(types.ArgBytes(returnValue)), } } + } - limits := types.ZKCountersLimits{ - MaxGasUsed: types.ArgUint64(state.MaxTxGasLimit), - MaxKeccakHashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxKeccakHashes), - MaxPoseidonHashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxPoseidonHashes), - MaxPoseidonPaddings: types.ArgUint64(z.cfg.ZKCountersLimits.MaxPoseidonPaddings), - MaxMemAligns: types.ArgUint64(z.cfg.ZKCountersLimits.MaxMemAligns), - MaxArithmetics: types.ArgUint64(z.cfg.ZKCountersLimits.MaxArithmetics), - MaxBinaries: types.ArgUint64(z.cfg.ZKCountersLimits.MaxBinaries), - MaxSteps: types.ArgUint64(z.cfg.ZKCountersLimits.MaxSteps), - MaxSHA256Hashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxSHA256Hashes), - } - return types.NewZKCountersResponse(processBatchResponse.UsedZkCounters, limits, revert, oocErr), nil - }) + limits := types.ZKCountersLimits{ + MaxGasUsed: types.ArgUint64(state.MaxTxGasLimit), + MaxKeccakHashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxKeccakHashes), + MaxPoseidonHashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxPoseidonHashes), + MaxPoseidonPaddings: types.ArgUint64(z.cfg.ZKCountersLimits.MaxPoseidonPaddings), + MaxMemAligns: types.ArgUint64(z.cfg.ZKCountersLimits.MaxMemAligns), + MaxArithmetics: types.ArgUint64(z.cfg.ZKCountersLimits.MaxArithmetics), + MaxBinaries: types.ArgUint64(z.cfg.ZKCountersLimits.MaxBinaries), + MaxSteps: types.ArgUint64(z.cfg.ZKCountersLimits.MaxSteps), + MaxSHA256Hashes: types.ArgUint64(z.cfg.ZKCountersLimits.MaxSHA256Hashes), + } + return types.NewZKCountersResponse(processBatchResponse.UsedZkCounters, limits, revert, oocErr), nil } func (z *ZKEVMEndpoints) getBlockByArg(ctx context.Context, blockArg *types.BlockNumberOrHash, dbTx pgx.Tx) (*state.L2Block, types.Error) { // If no block argument is provided, return the latest block if blockArg == nil { - block, err := z.state.GetLastL2Block(ctx, dbTx) + block, err := z.state.GetLastL2Block(ctx, nil) if err != nil { return nil, types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state") } @@ -667,7 +649,7 @@ func (z *ZKEVMEndpoints) getBlockByArg(ctx context.Context, blockArg *types.Bloc // If we have a block hash, try to get the block by hash if blockArg.IsHash() { - block, err := z.state.GetL2BlockByHash(ctx, blockArg.Hash().Hash(), dbTx) + block, err := z.state.GetL2BlockByHash(ctx, blockArg.Hash().Hash(), nil) if errors.Is(err, state.ErrNotFound) { return nil, types.NewRPCError(types.DefaultErrorCode, "header for hash not found") } else if err != nil { @@ -677,11 +659,11 @@ func (z *ZKEVMEndpoints) getBlockByArg(ctx context.Context, blockArg *types.Bloc } // Otherwise, try to get the block by number - blockNum, rpcErr := blockArg.Number().GetNumericBlockNumber(ctx, z.state, z.etherman, dbTx) + blockNum, rpcErr := blockArg.Number().GetNumericBlockNumber(ctx, z.state, z.etherman, nil) if rpcErr != nil { return nil, rpcErr } - block, err := z.state.GetL2BlockByNumber(context.Background(), blockNum, dbTx) + block, err := z.state.GetL2BlockByNumber(context.Background(), blockNum, nil) if errors.Is(err, state.ErrNotFound) || block == nil { return nil, types.NewRPCError(types.DefaultErrorCode, "header not found") } else if err != nil { @@ -693,14 +675,13 @@ func (z *ZKEVMEndpoints) getBlockByArg(ctx context.Context, blockArg *types.Bloc // GetLatestGlobalExitRoot returns the last global exit root used by l2 func (z *ZKEVMEndpoints) GetLatestGlobalExitRoot() (interface{}, types.Error) { - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { - var err error + ctx := context.Background() + var err error - ger, err := z.state.GetLatestBatchGlobalExitRoot(ctx, dbTx) - if err != nil { - return RPCErrorResponse(types.DefaultErrorCode, "couldn't load the last global exit root", err, true) - } + ger, err := z.state.GetLatestBatchGlobalExitRoot(ctx, nil) + if err != nil { + return RPCErrorResponse(types.DefaultErrorCode, "couldn't load the last global exit root", err, true) + } - return ger.String(), nil - }) + return ger.String(), nil } diff --git a/jsonrpc/endpoints_zkevm_test.go b/jsonrpc/endpoints_zkevm_test.go index af2ed9022d..5d74da2ddc 100644 --- a/jsonrpc/endpoints_zkevm_test.go +++ b/jsonrpc/endpoints_zkevm_test.go @@ -46,18 +46,8 @@ func TestConsolidatedBlockNumber(t *testing.T) { Name: "Get consolidated block number successfully", ExpectedResult: state.Ptr(uint64(10)), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastConsolidatedL2BlockNumber", context.Background(), m.DbTx). + On("GetLastConsolidatedL2BlockNumber", context.Background(), nil). Return(uint64(10), nil). Once() }, @@ -67,18 +57,8 @@ func TestConsolidatedBlockNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get last consolidated block number from state"), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastConsolidatedL2BlockNumber", context.Background(), m.DbTx). + On("GetLastConsolidatedL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last consolidated block number")). Once() }, @@ -124,18 +104,8 @@ func TestIsBlockConsolidated(t *testing.T) { Name: "Query status of block number successfully", ExpectedResult: true, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("IsL2BlockConsolidated", context.Background(), uint64(1), m.DbTx). + On("IsL2BlockConsolidated", context.Background(), uint64(1), nil). Return(true, nil). Once() }, @@ -145,18 +115,8 @@ func TestIsBlockConsolidated(t *testing.T) { ExpectedResult: false, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to check if the block is consolidated"), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("IsL2BlockConsolidated", context.Background(), uint64(1), m.DbTx). + On("IsL2BlockConsolidated", context.Background(), uint64(1), nil). Return(false, errors.New("failed to check if the block is consolidated")). Once() }, @@ -202,18 +162,8 @@ func TestIsBlockVirtualized(t *testing.T) { Name: "Query status of block number successfully", ExpectedResult: true, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("IsL2BlockVirtualized", context.Background(), uint64(1), m.DbTx). + On("IsL2BlockVirtualized", context.Background(), uint64(1), nil). Return(true, nil). Once() }, @@ -223,18 +173,8 @@ func TestIsBlockVirtualized(t *testing.T) { ExpectedResult: false, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to check if the block is virtualized"), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("IsL2BlockVirtualized", context.Background(), uint64(1), m.DbTx). + On("IsL2BlockVirtualized", context.Background(), uint64(1), nil). Return(false, errors.New("failed to check if the block is virtualized")). Once() }, @@ -282,18 +222,8 @@ func TestBatchNumberByBlockNumber(t *testing.T) { Name: "get batch number by block number successfully", ExpectedResult: &batchNumber, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, m.DbTx). + On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, nil). Return(batchNumber, nil). Once() }, @@ -303,18 +233,8 @@ func TestBatchNumberByBlockNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get batch number from block number"), SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, m.DbTx). + On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, nil). Return(uint64(0), errors.New("failed to get batch number of l2 batchNum")). Once() }, @@ -324,18 +244,8 @@ func TestBatchNumberByBlockNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, m.DbTx). + On("BatchNumberByL2BlockNumber", context.Background(), blockNumber, nil). Return(uint64(0), state.ErrNotFound). Once() }, @@ -393,18 +303,8 @@ func TestBatchNumber(t *testing.T) { ExpectedError: nil, ExpectedResult: 10, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastBatchNumber", context.Background(), m.DbTx). + On("GetLastBatchNumber", context.Background(), nil). Return(uint64(10), nil). Once() }, @@ -414,18 +314,8 @@ func TestBatchNumber(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last batch number from state"), ExpectedResult: 0, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastBatchNumber", context.Background(), m.DbTx). + On("GetLastBatchNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last batch number")). Once() }, @@ -472,18 +362,8 @@ func TestVirtualBatchNumber(t *testing.T) { ExpectedError: nil, ExpectedResult: 10, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastVirtualBatchNum", context.Background(), m.DbTx). + On("GetLastVirtualBatchNum", context.Background(), nil). Return(uint64(10), nil). Once() }, @@ -493,18 +373,8 @@ func TestVirtualBatchNumber(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last virtual batch number from state"), ExpectedResult: 0, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastVirtualBatchNum", context.Background(), m.DbTx). + On("GetLastVirtualBatchNum", context.Background(), nil). Return(uint64(0), errors.New("failed to get last batch number")). Once() }, @@ -551,18 +421,8 @@ func TestVerifiedBatchNumber(t *testing.T) { ExpectedError: nil, ExpectedResult: 10, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastVerifiedBatch", context.Background(), m.DbTx). + On("GetLastVerifiedBatch", context.Background(), nil). Return(&state.VerifiedBatch{BatchNumber: uint64(10)}, nil). Once() }, @@ -572,18 +432,8 @@ func TestVerifiedBatchNumber(t *testing.T) { ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last verified batch number from state"), ExpectedResult: 0, SetupMocks: func(m *mocksWrapper) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastVerifiedBatch", context.Background(), m.DbTx). + On("GetLastVerifiedBatch", context.Background(), nil). Return(nil, errors.New("failed to get last batch number")). Once() }, @@ -630,18 +480,8 @@ func TestGetBatchByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(nil, state.ErrNotFound) }, }, @@ -661,16 +501,6 @@ func TestGetBatchByNumber(t *testing.T) { }, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - txs := []*ethTypes.Transaction{ signTx(ethTypes.NewTransaction(1001, common.HexToAddress("0x1000"), big.NewInt(1000), 1001, big.NewInt(1002), []byte("1003")), s.ChainID()), signTx(ethTypes.NewTransaction(1002, common.HexToAddress("0x1000"), big.NewInt(1000), 1001, big.NewInt(1002), []byte("1003")), s.ChainID()), @@ -733,12 +563,12 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(batch, nil). Once() m.State. - On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), m.DbTx). + On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), nil). Return(&batch.Timestamp, nil). Once() @@ -747,7 +577,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVirtualBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetVirtualBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(virtualBatch, nil). Once() @@ -756,7 +586,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVerifiedBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetVerifiedBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(verifiedBatch, nil). Once() @@ -766,27 +596,27 @@ func TestGetBatchByNumber(t *testing.T) { GlobalExitRoot: common.HexToHash("0x4"), } m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, nil). Return(&ger, nil). Once() for i, tx := range txs { m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(receipts[i], nil). Once() m.State. - On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), nil). Return(state.Ptr(tx.Hash()), nil). Once() } m.State. - On("GetTransactionsByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetTransactionsByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(batchTxs, effectivePercentages, nil). Once() m.State. - On("GetL2BlocksByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetL2BlocksByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(blocks, nil). Once() }, @@ -807,16 +637,6 @@ func TestGetBatchByNumber(t *testing.T) { }, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - txs := []*ethTypes.Transaction{ signTx(ethTypes.NewTransaction(1001, common.HexToAddress("0x1000"), big.NewInt(1000), 1001, big.NewInt(1002), []byte("1003")), s.ChainID()), signTx(ethTypes.NewTransaction(1002, common.HexToAddress("0x1000"), big.NewInt(1000), 1001, big.NewInt(1002), []byte("1003")), s.ChainID()), @@ -861,12 +681,12 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetBatchByNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(batch, nil). Once() m.State. - On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), m.DbTx). + On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), nil). Return(&batch.Timestamp, nil). Once() @@ -875,7 +695,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVirtualBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetVirtualBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(virtualBatch, nil). Once() @@ -884,7 +704,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVerifiedBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetVerifiedBatch", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(verifiedBatch, nil). Once() @@ -894,22 +714,22 @@ func TestGetBatchByNumber(t *testing.T) { GlobalExitRoot: common.HexToHash("0x4"), } m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, nil). Return(&ger, nil). Once() for i, tx := range txs { m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(receipts[i], nil). Once() } m.State. - On("GetTransactionsByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetTransactionsByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(batchTxs, effectivePercentages, nil). Once() m.State. - On("GetL2BlocksByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), m.DbTx). + On("GetL2BlocksByBatchNumber", context.Background(), hex.DecodeBig(tc.Number).Uint64(), nil). Return(blocks, nil). Once() @@ -933,18 +753,8 @@ func TestGetBatchByNumber(t *testing.T) { }, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastClosedBatchNumber", context.Background(), m.DbTx). + On("GetLastClosedBatchNumber", context.Background(), nil). Return(uint64(tc.ExpectedResult.Number), nil). Once() @@ -1018,12 +828,12 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetBatchByNumber", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetBatchByNumber", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(batch, nil). Once() m.State. - On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), m.DbTx). + On("GetBatchTimestamp", mock.Anything, mock.Anything, (*uint64)(nil), nil). Return(&batch.Timestamp, nil). Once() @@ -1032,7 +842,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVirtualBatch", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetVirtualBatch", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(virtualBatch, nil). Once() @@ -1041,7 +851,7 @@ func TestGetBatchByNumber(t *testing.T) { } m.State. - On("GetVerifiedBatch", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetVerifiedBatch", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(verifiedBatch, nil). Once() @@ -1051,28 +861,28 @@ func TestGetBatchByNumber(t *testing.T) { GlobalExitRoot: common.HexToHash("0x4"), } m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), batch.GlobalExitRoot, nil). Return(&ger, nil). Once() for i, tx := range txs { m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(receipts[i], nil). Once() m.State. - On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), nil). Return(state.Ptr(tx.Hash()), nil). Once() } m.State. - On("GetTransactionsByBatchNumber", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetTransactionsByBatchNumber", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(batchTxs, effectivePercentages, nil). Once() m.State. - On("GetL2BlocksByBatchNumber", context.Background(), uint64(tc.ExpectedResult.Number), m.DbTx). + On("GetL2BlocksByBatchNumber", context.Background(), uint64(tc.ExpectedResult.Number), nil). Return(blocks, nil). Once() tc.ExpectedResult.BatchL2Data = batchL2Data @@ -1084,18 +894,8 @@ func TestGetBatchByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last batch number from state"), SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastClosedBatchNumber", context.Background(), m.DbTx). + On("GetLastClosedBatchNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last batch number")). Once() }, @@ -1106,23 +906,13 @@ func TestGetBatchByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load batch from state by number 1"), SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastClosedBatchNumber", context.Background(), m.DbTx). + On("GetLastClosedBatchNumber", context.Background(), nil). Return(uint64(1), nil). Once() m.State. - On("GetBatchByNumber", context.Background(), uint64(1), m.DbTx). + On("GetBatchByNumber", context.Background(), uint64(1), nil). Return(nil, errors.New("failed to load batch by number")). Once() }, @@ -1218,18 +1008,8 @@ func TestGetL2FullBlockByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound) }, }, @@ -1239,18 +1019,8 @@ func TestGetL2FullBlockByHash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get block by hash from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get block from state")). Once() }, @@ -1274,24 +1044,14 @@ func TestGetL2FullBlockByHash(t *testing.T) { st := trie.NewStackTrie(nil) block := state.NewL2Block(state.NewL2Header(tc.ExpectedResult.Header()), tc.ExpectedResult.Transactions(), uncles, []*ethTypes.Receipt{ethTypes.NewReceipt([]byte{}, false, uint64(0))}, st) - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByHash", context.Background(), tc.Hash, m.DbTx). + On("GetL2BlockByHash", context.Background(), tc.Hash, nil). Return(block, nil). Once() for _, tx := range tc.ExpectedResult.Transactions() { m.State. - On("GetTransactionReceipt", context.Background(), tx.Hash(), m.DbTx). + On("GetTransactionReceipt", context.Background(), tx.Hash(), nil). Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil). Once() } @@ -1486,18 +1246,8 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetL2BlockByNumber", context.Background(), hex.DecodeUint64(tc.Number), m.DbTx). + On("GetL2BlockByNumber", context.Background(), hex.DecodeUint64(tc.Number), nil). Return(nil, state.ErrNotFound). Once() }, @@ -1508,24 +1258,14 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: rpcBlock, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetL2BlockByNumber", context.Background(), hex.DecodeUint64(tc.Number), m.DbTx). + On("GetL2BlockByNumber", context.Background(), hex.DecodeUint64(tc.Number), nil). Return(l2Block, nil). Once() for _, receipt := range receipts { m.State. - On("GetTransactionReceipt", context.Background(), receipt.TxHash, m.DbTx). + On("GetTransactionReceipt", context.Background(), receipt.TxHash, nil). Return(receipt, nil). Once() } @@ -1537,31 +1277,21 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: rpcBlock, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - blockNumber := uint64(1) m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(blockNumber, nil). Once() m.State. - On("GetL2BlockByNumber", context.Background(), blockNumber, m.DbTx). + On("GetL2BlockByNumber", context.Background(), blockNumber, nil). Return(l2Block, nil). Once() for _, receipt := range receipts { m.State. - On("GetTransactionReceipt", context.Background(), receipt.TxHash, m.DbTx). + On("GetTransactionReceipt", context.Background(), receipt.TxHash, nil). Return(receipt, nil). Once() } @@ -1573,18 +1303,8 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get the last block number from state"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(0), errors.New("failed to get last block number")). Once() }, @@ -1595,23 +1315,13 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load block from state by number 1"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2BlockNumber", context.Background(), m.DbTx). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(1), nil). Once() m.State. - On("GetL2BlockByNumber", context.Background(), uint64(1), m.DbTx). + On("GetL2BlockByNumber", context.Background(), uint64(1), nil). Return(nil, errors.New("failed to load block by number")). Once() }, @@ -1640,18 +1350,8 @@ func TestGetL2FullBlockByNumber(t *testing.T) { tc.ExpectedResult.Nonce = nil tc.ExpectedResult.TotalDifficulty = nil - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(lastBlock, nil). Once() }, @@ -1662,18 +1362,8 @@ func TestGetL2FullBlockByNumber(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load last block from state to compute the pending block"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLastL2Block", context.Background(), m.DbTx). + On("GetLastL2Block", context.Background(), nil). Return(nil, errors.New("failed to load last block")). Once() }, @@ -1769,21 +1459,11 @@ func TestGetNativeBlockHashesInRange(t *testing.T) { ExpectedResult: state.Ptr([]string{}), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - fromBlock, _ := tc.Filter.FromBlock.GetNumericBlockNumber(context.Background(), nil, nil, nil) toBlock, _ := tc.Filter.ToBlock.GetNumericBlockNumber(context.Background(), nil, nil, nil) m.State. - On("GetNativeBlockHashesInRange", context.Background(), fromBlock, toBlock, m.DbTx). + On("GetNativeBlockHashesInRange", context.Background(), fromBlock, toBlock, nil). Return([]common.Hash{}, nil). Once() }, @@ -1797,16 +1477,6 @@ func TestGetNativeBlockHashesInRange(t *testing.T) { ExpectedResult: state.Ptr([]string{}), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - fromBlock, _ := tc.Filter.FromBlock.GetNumericBlockNumber(context.Background(), nil, nil, nil) toBlock, _ := tc.Filter.ToBlock.GetNumericBlockNumber(context.Background(), nil, nil, nil) hashes := []common.Hash{} @@ -1820,7 +1490,7 @@ func TestGetNativeBlockHashesInRange(t *testing.T) { tc.ExpectedResult = &expectedResult m.State. - On("GetNativeBlockHashesInRange", context.Background(), fromBlock, toBlock, m.DbTx). + On("GetNativeBlockHashesInRange", context.Background(), fromBlock, toBlock, nil). Return(hashes, nil). Once() }, @@ -1834,15 +1504,7 @@ func TestGetNativeBlockHashesInRange(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.InvalidParamsErrorCode, "invalid block range"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, { @@ -1854,15 +1516,7 @@ func TestGetNativeBlockHashesInRange(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.InvalidParamsErrorCode, "native block hashes are limited to a 60000 block range"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() }, }, } @@ -1969,28 +1623,18 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: &rpcTransaction, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(receipt, nil). Once() m.State. - On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), nil). Return(&l2Hash, nil). Once() }, @@ -2007,18 +1651,8 @@ func TestGetTransactionByL2Hash(t *testing.T) { tc.ExpectedResult.TxIndex = nil tc.ExpectedResult.L2Hash = nil - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2035,18 +1669,8 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2063,18 +1687,8 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction by l2 hash from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to load transaction by l2 hash from state")). Once() }, @@ -2086,18 +1700,8 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction by l2 hash from pool"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() @@ -2114,23 +1718,13 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "transaction receipt not found"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -2142,23 +1736,13 @@ func TestGetTransactionByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to load transaction receipt from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to load transaction receipt from state")). Once() }, @@ -2285,28 +1869,18 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: &rpcReceipt, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(receipt, nil). Once() m.State. - On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), signedTx.Hash(), nil). Return(&l2Hash, nil). Once() }, @@ -2317,18 +1891,8 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -2339,18 +1903,8 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get tx from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get tx")). Once() }, @@ -2361,23 +1915,13 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, state.ErrNotFound). Once() }, @@ -2388,23 +1932,13 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to get tx receipt from state"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(signedTx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(nil, errors.New("failed to get tx receipt from state")). Once() }, @@ -2415,28 +1949,18 @@ func TestGetTransactionReceiptByL2Hash(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "failed to build the receipt response"), SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetTransactionByL2Hash", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionByL2Hash", context.Background(), tc.Hash, nil). Return(tx, nil). Once() m.State. - On("GetTransactionReceipt", context.Background(), tc.Hash, m.DbTx). + On("GetTransactionReceipt", context.Background(), tc.Hash, nil). Return(ethTypes.NewReceipt([]byte{}, false, 0), nil). Once() m.State. - On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), m.DbTx). + On("GetL2TxHashByTxHash", context.Background(), tx.Hash(), nil). Return(&l2Hash, nil). Once() }, @@ -2530,18 +2054,8 @@ func TestGetExitRootsByGER(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, nil). Return(nil, state.ErrNotFound) }, }, @@ -2551,18 +2065,8 @@ func TestGetExitRootsByGER(t *testing.T) { ExpectedResult: nil, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, nil). Return(nil, fmt.Errorf("failed to load exit roots from state")) }, }, @@ -2577,15 +2081,6 @@ func TestGetExitRootsByGER(t *testing.T) { }, ExpectedError: nil, SetupMocks: func(s *mockedServer, m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() er := &state.GlobalExitRoot{ BlockNumber: uint64(tc.ExpectedResult.BlockNumber), Timestamp: time.Unix(int64(tc.ExpectedResult.Timestamp), 0), @@ -2594,7 +2089,7 @@ func TestGetExitRootsByGER(t *testing.T) { } m.State. - On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, m.DbTx). + On("GetExitRootByGlobalExitRoot", context.Background(), tc.GER, nil). Return(er, nil) }, }, @@ -2642,18 +2137,8 @@ func TestGetLatestGlobalExitRoot(t *testing.T) { ExpectedResult: nil, ExpectedError: types.NewRPCError(types.DefaultErrorCode, "couldn't load the last global exit root"), SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Rollback", context.Background()). - Return(nil). - Once() - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - - m.State. - On("GetLatestBatchGlobalExitRoot", context.Background(), m.DbTx). + On("GetLatestBatchGlobalExitRoot", context.Background(), nil). Return(nil, fmt.Errorf("failed to load GER from state")). Once() }, @@ -2663,18 +2148,8 @@ func TestGetLatestGlobalExitRoot(t *testing.T) { ExpectedResult: state.Ptr(common.HexToHash("0x1")), ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc *testCase) { - m.DbTx. - On("Commit", context.Background()). - Return(nil). - Once() - - m.State. - On("BeginStateTransaction", context.Background()). - Return(m.DbTx, nil). - Once() - m.State. - On("GetLatestBatchGlobalExitRoot", context.Background(), m.DbTx). + On("GetLatestBatchGlobalExitRoot", context.Background(), nil). Return(common.HexToHash("0x1"), nil). Once() }, diff --git a/jsonrpc/mocks/mock_dbtx.go b/jsonrpc/mocks/mock_dbtx.go deleted file mode 100644 index c17e30a024..0000000000 --- a/jsonrpc/mocks/mock_dbtx.go +++ /dev/null @@ -1,350 +0,0 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - pgconn "github.com/jackc/pgconn" - mock "github.com/stretchr/testify/mock" - - pgx "github.com/jackc/pgx/v4" -) - -// DBTxMock is an autogenerated mock type for the Tx type -type DBTxMock struct { - mock.Mock -} - -// Begin provides a mock function with given fields: ctx -func (_m *DBTxMock) Begin(ctx context.Context) (pgx.Tx, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Begin") - } - - var r0 pgx.Tx - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (pgx.Tx, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) pgx.Tx); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgx.Tx) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// BeginFunc provides a mock function with given fields: ctx, f -func (_m *DBTxMock) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error { - ret := _m.Called(ctx, f) - - if len(ret) == 0 { - panic("no return value specified for BeginFunc") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, func(pgx.Tx) error) error); ok { - r0 = rf(ctx, f) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Commit provides a mock function with given fields: ctx -func (_m *DBTxMock) Commit(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Commit") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Conn provides a mock function with given fields: -func (_m *DBTxMock) Conn() *pgx.Conn { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Conn") - } - - var r0 *pgx.Conn - if rf, ok := ret.Get(0).(func() *pgx.Conn); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*pgx.Conn) - } - } - - return r0 -} - -// CopyFrom provides a mock function with given fields: ctx, tableName, columnNames, rowSrc -func (_m *DBTxMock) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) { - ret := _m.Called(ctx, tableName, columnNames, rowSrc) - - if len(ret) == 0 { - panic("no return value specified for CopyFrom") - } - - var r0 int64 - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) (int64, error)); ok { - return rf(ctx, tableName, columnNames, rowSrc) - } - if rf, ok := ret.Get(0).(func(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) int64); ok { - r0 = rf(ctx, tableName, columnNames, rowSrc) - } else { - r0 = ret.Get(0).(int64) - } - - if rf, ok := ret.Get(1).(func(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) error); ok { - r1 = rf(ctx, tableName, columnNames, rowSrc) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Exec provides a mock function with given fields: ctx, sql, arguments -func (_m *DBTxMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) { - var _ca []interface{} - _ca = append(_ca, ctx, sql) - _ca = append(_ca, arguments...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for Exec") - } - - var r0 pgconn.CommandTag - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) (pgconn.CommandTag, error)); ok { - return rf(ctx, sql, arguments...) - } - if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) pgconn.CommandTag); ok { - r0 = rf(ctx, sql, arguments...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgconn.CommandTag) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, ...interface{}) error); ok { - r1 = rf(ctx, sql, arguments...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// LargeObjects provides a mock function with given fields: -func (_m *DBTxMock) LargeObjects() pgx.LargeObjects { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for LargeObjects") - } - - var r0 pgx.LargeObjects - if rf, ok := ret.Get(0).(func() pgx.LargeObjects); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(pgx.LargeObjects) - } - - return r0 -} - -// Prepare provides a mock function with given fields: ctx, name, sql -func (_m *DBTxMock) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error) { - ret := _m.Called(ctx, name, sql) - - if len(ret) == 0 { - panic("no return value specified for Prepare") - } - - var r0 *pgconn.StatementDescription - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*pgconn.StatementDescription, error)); ok { - return rf(ctx, name, sql) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *pgconn.StatementDescription); ok { - r0 = rf(ctx, name, sql) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*pgconn.StatementDescription) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, name, sql) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Query provides a mock function with given fields: ctx, sql, args -func (_m *DBTxMock) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) { - var _ca []interface{} - _ca = append(_ca, ctx, sql) - _ca = append(_ca, args...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for Query") - } - - var r0 pgx.Rows - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) (pgx.Rows, error)); ok { - return rf(ctx, sql, args...) - } - if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) pgx.Rows); ok { - r0 = rf(ctx, sql, args...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgx.Rows) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, ...interface{}) error); ok { - r1 = rf(ctx, sql, args...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// QueryFunc provides a mock function with given fields: ctx, sql, args, scans, f -func (_m *DBTxMock) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) { - ret := _m.Called(ctx, sql, args, scans, f) - - if len(ret) == 0 { - panic("no return value specified for QueryFunc") - } - - var r0 pgconn.CommandTag - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, []interface{}, []interface{}, func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)); ok { - return rf(ctx, sql, args, scans, f) - } - if rf, ok := ret.Get(0).(func(context.Context, string, []interface{}, []interface{}, func(pgx.QueryFuncRow) error) pgconn.CommandTag); ok { - r0 = rf(ctx, sql, args, scans, f) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgconn.CommandTag) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, []interface{}, []interface{}, func(pgx.QueryFuncRow) error) error); ok { - r1 = rf(ctx, sql, args, scans, f) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// QueryRow provides a mock function with given fields: ctx, sql, args -func (_m *DBTxMock) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row { - var _ca []interface{} - _ca = append(_ca, ctx, sql) - _ca = append(_ca, args...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for QueryRow") - } - - var r0 pgx.Row - if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) pgx.Row); ok { - r0 = rf(ctx, sql, args...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgx.Row) - } - } - - return r0 -} - -// Rollback provides a mock function with given fields: ctx -func (_m *DBTxMock) Rollback(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Rollback") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendBatch provides a mock function with given fields: ctx, b -func (_m *DBTxMock) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults { - ret := _m.Called(ctx, b) - - if len(ret) == 0 { - panic("no return value specified for SendBatch") - } - - var r0 pgx.BatchResults - if rf, ok := ret.Get(0).(func(context.Context, *pgx.Batch) pgx.BatchResults); ok { - r0 = rf(ctx, b) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pgx.BatchResults) - } - } - - return r0 -} - -// NewDBTxMock creates a new instance of DBTxMock. 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 NewDBTxMock(t interface { - mock.TestingT - Cleanup(func()) -}) *DBTxMock { - mock := &DBTxMock{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/jsonrpc/server_test.go b/jsonrpc/server_test.go index ffb60f8717..ae30947e13 100644 --- a/jsonrpc/server_test.go +++ b/jsonrpc/server_test.go @@ -42,7 +42,6 @@ type mocksWrapper struct { State *mocks.StateMock Etherman *mocks.EthermanMock Storage *storageMock - DbTx *mocks.DBTxMock } func newMockedServer(t *testing.T, cfg Config) (*mockedServer, *mocksWrapper, *ethclient.Client) { @@ -50,7 +49,6 @@ func newMockedServer(t *testing.T, cfg Config) (*mockedServer, *mocksWrapper, *e st := mocks.NewStateMock(t) etherman := mocks.NewEthermanMock(t) storage := newStorageMock(t) - dbTx := mocks.NewDBTxMock(t) apis := map[string]bool{ APIEth: true, APINet: true, @@ -143,7 +141,6 @@ func newMockedServer(t *testing.T, cfg Config) (*mockedServer, *mocksWrapper, *e State: st, Etherman: etherman, Storage: storage, - DbTx: dbTx, } return msv, mks, ethClient @@ -262,11 +259,9 @@ func TestBatchRequests(t *testing.T) { NumberOfRequests: 100, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx.On("Commit", context.Background()).Return(nil).Times(tc.NumberOfRequests) - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Times(tc.NumberOfRequests) - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) - m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), m.DbTx).Return(block, nil).Times(tc.NumberOfRequests) - m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, m.DbTx).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) + m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), nil).Return(block, nil).Times(tc.NumberOfRequests) + m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, nil).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) }, }, { @@ -276,11 +271,9 @@ func TestBatchRequests(t *testing.T) { NumberOfRequests: 5, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx.On("Commit", context.Background()).Return(nil).Times(tc.NumberOfRequests) - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Times(tc.NumberOfRequests) - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) - m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), m.DbTx).Return(block, nil).Times(tc.NumberOfRequests) - m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, m.DbTx).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) + m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), nil).Return(block, nil).Times(tc.NumberOfRequests) + m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, nil).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) }, }, { @@ -290,11 +283,9 @@ func TestBatchRequests(t *testing.T) { NumberOfRequests: 4, ExpectedError: nil, SetupMocks: func(m *mocksWrapper, tc testCase) { - m.DbTx.On("Commit", context.Background()).Return(nil).Times(tc.NumberOfRequests) - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Times(tc.NumberOfRequests) - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) - m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), m.DbTx).Return(block, nil).Times(tc.NumberOfRequests) - m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, m.DbTx).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(block.Number().Uint64(), nil).Times(tc.NumberOfRequests) + m.State.On("GetL2BlockByNumber", context.Background(), block.Number().Uint64(), nil).Return(block, nil).Times(tc.NumberOfRequests) + m.State.On("GetTransactionReceipt", context.Background(), mock.Anything, nil).Return(ethTypes.NewReceipt([]byte{}, false, uint64(0)), nil) }, }, } @@ -589,9 +580,7 @@ func TestMaxRequestPerIPPerSec(t *testing.T) { // this makes us sure the code is calling these methods only for // allowed requests times := int(cfg.MaxRequestsPerIPAndSecond) - m.DbTx.On("Commit", context.Background()).Return(nil).Times(times) - m.State.On("BeginStateTransaction", context.Background()).Return(m.DbTx, nil).Times(times) - m.State.On("GetLastL2BlockNumber", context.Background(), m.DbTx).Return(uint64(1), nil).Times(times) + m.State.On("GetLastL2BlockNumber", context.Background(), nil).Return(uint64(1), nil).Times(times) // prepare the workers to process the requests as long as a job is available requestsLimitedCount := uint64(0) diff --git a/jsonrpc/types/codec_test.go b/jsonrpc/types/codec_test.go index d08dbd8ed6..33da973651 100644 --- a/jsonrpc/types/codec_test.go +++ b/jsonrpc/types/codec_test.go @@ -54,7 +54,7 @@ func TestGetNumericBlockNumber(t *testing.T) { bn *BlockNumber expectedBlockNumber uint64 expectedError Error - setupMocks func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) + setupMocks func(s *mocks.StateMock, t *testCase) } testCases := []testCase{ @@ -63,9 +63,9 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: nil, expectedBlockNumber: 40, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastL2BlockNumber", context.Background(), d). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(40), nil). Once() }, @@ -75,9 +75,9 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: state.Ptr(LatestBlockNumber), expectedBlockNumber: 50, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastL2BlockNumber", context.Background(), d). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(50), nil). Once() }, @@ -87,9 +87,9 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: state.Ptr(PendingBlockNumber), expectedBlockNumber: 30, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastL2BlockNumber", context.Background(), d). + On("GetLastL2BlockNumber", context.Background(), nil). Return(uint64(30), nil). Once() }, @@ -99,14 +99,14 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: state.Ptr(EarliestBlockNumber), expectedBlockNumber: 0, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, { name: "BlockNumber SafeBlockNumber", bn: state.Ptr(SafeBlockNumber), expectedBlockNumber: 40, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { safeBlockNumber := uint64(30) e. On("GetSafeBlockNumber", context.Background()). @@ -114,7 +114,7 @@ func TestGetNumericBlockNumber(t *testing.T) { Once() s. - On("GetLastVerifiedL2BlockNumberUntilL1Block", context.Background(), safeBlockNumber, d). + On("GetLastVerifiedL2BlockNumberUntilL1Block", context.Background(), safeBlockNumber, nil). Return(uint64(40), nil). Once() }, @@ -124,7 +124,7 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: state.Ptr(FinalizedBlockNumber), expectedBlockNumber: 60, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { finalizedBlockNumber := uint64(50) e. On("GetFinalizedBlockNumber", context.Background()). @@ -132,7 +132,7 @@ func TestGetNumericBlockNumber(t *testing.T) { Once() s. - On("GetLastVerifiedL2BlockNumberUntilL1Block", context.Background(), finalizedBlockNumber, d). + On("GetLastVerifiedL2BlockNumberUntilL1Block", context.Background(), finalizedBlockNumber, nil). Return(uint64(60), nil). Once() }, @@ -142,23 +142,22 @@ func TestGetNumericBlockNumber(t *testing.T) { bn: state.Ptr(BlockNumber(int64(10))), expectedBlockNumber: 10, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, { name: "BlockNumber Negative Number <= -6", bn: state.Ptr(BlockNumber(int64(-6))), expectedBlockNumber: 0, expectedError: NewRPCError(InvalidParamsErrorCode, "invalid block number: -6"), - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { tc := testCase - dbTx := mocks.NewDBTxMock(t) - testCase.setupMocks(s, dbTx, &tc) - result, rpcErr := testCase.bn.GetNumericBlockNumber(context.Background(), s, e, dbTx) + testCase.setupMocks(s, &tc) + result, rpcErr := testCase.bn.GetNumericBlockNumber(context.Background(), s, e, nil) assert.Equal(t, testCase.expectedBlockNumber, result) if rpcErr != nil || testCase.expectedError != nil { assert.Equal(t, testCase.expectedError.ErrorCode(), rpcErr.ErrorCode()) @@ -177,7 +176,7 @@ func TestGetNumericBatchNumber(t *testing.T) { bn *BatchNumber expectedBatchNumber uint64 expectedError Error - setupMocks func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) + setupMocks func(s *mocks.StateMock, t *testCase) } testCases := []testCase{ @@ -186,9 +185,9 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: nil, expectedBatchNumber: 40, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastClosedBatchNumber", context.Background(), d). + On("GetLastClosedBatchNumber", context.Background(), nil). Return(uint64(40), nil). Once() }, @@ -198,9 +197,9 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: state.Ptr(LatestBatchNumber), expectedBatchNumber: 50, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastClosedBatchNumber", context.Background(), d). + On("GetLastClosedBatchNumber", context.Background(), nil). Return(uint64(50), nil). Once() }, @@ -210,9 +209,9 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: state.Ptr(PendingBatchNumber), expectedBatchNumber: 90, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { s. - On("GetLastBatchNumber", context.Background(), d). + On("GetLastBatchNumber", context.Background(), nil). Return(uint64(90), nil). Once() }, @@ -222,14 +221,14 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: state.Ptr(EarliestBatchNumber), expectedBatchNumber: 0, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, { name: "BatchNumber SafeBatchNumber", bn: state.Ptr(SafeBatchNumber), expectedBatchNumber: 40, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { safeBlockNumber := uint64(30) e. On("GetSafeBlockNumber", context.Background()). @@ -237,7 +236,7 @@ func TestGetNumericBatchNumber(t *testing.T) { Once() s. - On("GetLastVerifiedBatchNumberUntilL1Block", context.Background(), safeBlockNumber, d). + On("GetLastVerifiedBatchNumberUntilL1Block", context.Background(), safeBlockNumber, nil). Return(uint64(40), nil). Once() }, @@ -247,7 +246,7 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: state.Ptr(FinalizedBatchNumber), expectedBatchNumber: 60, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) { + setupMocks: func(s *mocks.StateMock, t *testCase) { finalizedBlockNumber := uint64(50) e. On("GetFinalizedBlockNumber", context.Background()). @@ -255,7 +254,7 @@ func TestGetNumericBatchNumber(t *testing.T) { Once() s. - On("GetLastVerifiedBatchNumberUntilL1Block", context.Background(), finalizedBlockNumber, d). + On("GetLastVerifiedBatchNumberUntilL1Block", context.Background(), finalizedBlockNumber, nil). Return(uint64(60), nil). Once() }, @@ -265,23 +264,22 @@ func TestGetNumericBatchNumber(t *testing.T) { bn: state.Ptr(BatchNumber(int64(10))), expectedBatchNumber: 10, expectedError: nil, - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, { name: "BatchNumber Negative Number <= -6", bn: state.Ptr(BatchNumber(int64(-6))), expectedBatchNumber: 0, expectedError: NewRPCError(InvalidParamsErrorCode, "invalid batch number: -6"), - setupMocks: func(s *mocks.StateMock, d *mocks.DBTxMock, t *testCase) {}, + setupMocks: func(s *mocks.StateMock, t *testCase) {}, }, } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { tc := testCase - dbTx := mocks.NewDBTxMock(t) - testCase.setupMocks(s, dbTx, &tc) - result, rpcErr := testCase.bn.GetNumericBatchNumber(context.Background(), s, e, dbTx) + testCase.setupMocks(s, &tc) + result, rpcErr := testCase.bn.GetNumericBatchNumber(context.Background(), s, e, nil) assert.Equal(t, testCase.expectedBatchNumber, result) if rpcErr != nil || testCase.expectedError != nil { assert.Equal(t, testCase.expectedError.ErrorCode(), rpcErr.ErrorCode()) diff --git a/test/Makefile b/test/Makefile index 35cd659924..23f7a480d2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -678,7 +678,6 @@ generate-mocks-jsonrpc: ## Generates mocks for jsonrpc , using mockery tool export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=PoolInterface --dir=../jsonrpc/types --output=../jsonrpc/mocks --outpkg=mocks --structname=PoolMock --filename=mock_pool.go export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StateInterface --dir=../jsonrpc/types --output=../jsonrpc/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../jsonrpc/types --output=../jsonrpc/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../jsonrpc/mocks --outpkg=mocks --structname=DBTxMock --filename=mock_dbtx.go .PHONY: generate-mocks-sequencer generate-mocks-sequencer: ## Generates mocks for sequencer , using mockery tool From cd0b777269cdbcaee1b1372b7b7af8267dbbe702 Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Wed, 5 Jun 2024 10:17:20 -0300 Subject: [PATCH 18/23] remove synchronizer dependency from eth tx manager to confirm monitored tx (#3658) (#3677) --- ethtxmanager/ethtxmanager.go | 23 ++------------- ethtxmanager/ethtxmanager_test.go | 49 ++----------------------------- 2 files changed, 5 insertions(+), 67 deletions(-) diff --git a/ethtxmanager/ethtxmanager.go b/ethtxmanager/ethtxmanager.go index 1c48071cf0..79f9262962 100644 --- a/ethtxmanager/ethtxmanager.go +++ b/ethtxmanager/ethtxmanager.go @@ -13,7 +13,6 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-node/log" - "github.com/0xPolygonHermez/zkevm-node/state" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -457,25 +456,9 @@ func (c *Client) monitorTx(ctx context.Context, mTx monitoredTx, logger *log.Log // if mined, check receipt and mark as Failed or Confirmed if lastReceiptChecked.Status == types.ReceiptStatusSuccessful { - receiptBlockNum := lastReceiptChecked.BlockNumber.Uint64() - - // check if state is already synchronized until the block - // where the tx was mined - block, err := c.state.GetLastBlock(ctx, nil) - if errors.Is(err, state.ErrStateNotSynchronized) { - logger.Debugf("state not synchronized yet, waiting for L1 block %v to be synced", receiptBlockNum) - return - } else if err != nil { - logger.Errorf("failed to check if L1 block %v is already synced: %v", receiptBlockNum, err) - return - } else if block.BlockNumber < receiptBlockNum { - logger.Debugf("L1 block %v not synchronized yet, waiting for L1 block to be synced in order to confirm monitored tx", receiptBlockNum) - return - } else { - mTx.status = MonitoredTxStatusConfirmed - mTx.blockNumber = lastReceiptChecked.BlockNumber - logger.Info("confirmed") - } + mTx.status = MonitoredTxStatusConfirmed + mTx.blockNumber = lastReceiptChecked.BlockNumber + logger.Info("confirmed") } else { // if we should continue to monitor, we move to the next one and this will // be reviewed in the next monitoring cycle diff --git a/ethtxmanager/ethtxmanager_test.go b/ethtxmanager/ethtxmanager_test.go index 0ca53086fd..350332aae7 100644 --- a/ethtxmanager/ethtxmanager_test.go +++ b/ethtxmanager/ethtxmanager_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-node/config/types" - "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/test/dbutils" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" @@ -118,14 +117,6 @@ func TestTxGetMined(t *testing.T) { Return("", nil). Once() - block := &state.Block{ - BlockNumber: blockNumber.Uint64(), - } - st. - On("GetLastBlock", ctx, nil). - Return(block, nil). - Once() - err = ethTxManagerClient.Add(ctx, owner, id, from, to, value, data, gasOffset, nil) require.NoError(t, err) @@ -263,14 +254,6 @@ func TestTxGetMinedAfterReviewed(t *testing.T) { Return(receipt, nil). Once() - block := &state.Block{ - BlockNumber: blockNumber.Uint64(), - } - st. - On("GetLastBlock", ctx, nil). - Return(block, nil). - Once() - // Build result etherman. On("GetTx", ctx, firstSignedTx.Hash()). @@ -383,16 +366,8 @@ func TestTxGetMinedAfterConfirmedAndReorged(t *testing.T) { } etherman. On("GetTxReceipt", ctx, signedTx.Hash()). - Return(receipt, nil). - Once() - - block := &state.Block{ - BlockNumber: blockNumber.Uint64(), - } - st. - On("GetLastBlock", ctx, nil). Run(func(args mock.Arguments) { ethTxManagerClient.Stop() }). // stops the management cycle to avoid problems with mocks - Return(block, nil). + Return(receipt, nil). Once() // Build Result 1 @@ -433,12 +408,8 @@ func TestTxGetMinedAfterConfirmedAndReorged(t *testing.T) { // Monitoring Cycle 3 etherman. On("CheckTxWasMined", ctx, signedTx.Hash()). - Return(true, receipt, nil). - Once() - st. - On("GetLastBlock", ctx, nil). Run(func(args mock.Arguments) { ethTxManagerClient.Stop() }). // stops the management cycle to avoid problems with mocks - Return(block, nil). + Return(true, receipt, nil). Once() // Build Result 3 @@ -643,14 +614,6 @@ func TestExecutionReverted(t *testing.T) { Return(receipt, nil). Once() - block := &state.Block{ - BlockNumber: blockNumber.Uint64(), - } - st. - On("GetLastBlock", ctx, nil). - Return(block, nil). - Once() - // Build result etherman. On("GetTx", ctx, firstSignedTx.Hash()). @@ -959,14 +922,6 @@ func TestFailedToEstimateTxWithForcedGasGetMined(t *testing.T) { Return("", nil). Once() - block := &state.Block{ - BlockNumber: blockNumber.Uint64(), - } - st. - On("GetLastBlock", ctx, nil). - Return(block, nil). - Once() - err = ethTxManagerClient.Add(ctx, owner, id, from, to, value, data, gasOffset, nil) require.NoError(t, err) From 9f0bbc11b1a73ff178838cc855df0324ef6b38c9 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:56:37 +0200 Subject: [PATCH 19/23] Cherry-pick #3669: Add WriteTimeout config parameter to StreamServer (#3690) * Add WriteTimeout config parameter to StreamServer (#3669) * Add WriteTimeout config parameter to StreamServer. Update DS library * update doc * update default value for StreamServer.WriteTimeout config parameter. Increase buffer for datastream channel * fix doc * fix config test * fix doc --- config/config_test.go | 4 +++ config/default.go | 1 + .../environments/local/local.node.config.toml | 1 + docs/config-file/node-config-doc.html | 4 ++- docs/config-file/node-config-doc.md | 27 +++++++++++++++++++ docs/config-file/node-config-schema.json | 10 +++++++ go.mod | 2 +- go.sum | 4 +-- sequencer/config.go | 2 ++ sequencer/l2block.go | 4 +-- sequencer/sequencer.go | 4 +-- test/config/debug.node.config.toml | 1 + test/config/test.node.config.toml | 1 + tools/datastreamer/config/config.go | 3 +++ tools/datastreamer/config/tool.config.toml | 1 + tools/datastreamer/main.go | 2 +- 16 files changed, 62 insertions(+), 9 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 3f8c52d5bc..cc3b998d9e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -173,6 +173,10 @@ func Test_Defaults(t *testing.T) { path: "Sequencer.StreamServer.Version", expectedValue: uint8(0), }, + { + path: "Sequencer.StreamServer.WriteTimeout", + expectedValue: types.NewDuration(5 * time.Second), + }, { path: "Sequencer.StreamServer.Enabled", expectedValue: false, diff --git a/config/default.go b/config/default.go index f35bdad794..d76a6a14a8 100644 --- a/config/default.go +++ b/config/default.go @@ -164,6 +164,7 @@ StateConsistencyCheckInterval = "5s" Port = 0 Filename = "" Version = 0 + WriteTimeout = "5s" Enabled = false [SequenceSender] diff --git a/config/environments/local/local.node.config.toml b/config/environments/local/local.node.config.toml index 11077845ca..c403a0718a 100644 --- a/config/environments/local/local.node.config.toml +++ b/config/environments/local/local.node.config.toml @@ -112,6 +112,7 @@ StateConsistencyCheckInterval = "5s" [Sequencer.StreamServer] Port = 0 Filename = "" + WriteTimeout = "5s" Enabled = false [SequenceSender] diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 9897a5b38d..b1a0f16a0d 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -56,7 +56,9 @@
"300ms"
 

Default: 0Type: integer

HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.
The Sequencer will halt after it closes the batch equal to this number


Default: falseType: boolean

SequentialBatchSanityCheck indicates if the reprocess of a closed batch (sanity check) must be done in a
sequential way (instead than in parallel)


Default: falseType: boolean

SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
in the processPendingL2Blocks go func


Metrics is the config for the sequencer metrics
Default: "1h0m0s"Type: string

Interval is the interval of time to calculate sequencer metrics


Examples:

"1m"
 
"300ms"
-

Default: trueType: boolean

EnableLog is a flag to enable/disable metrics logs


StreamServerCfg is the config for the stream server
Default: 0Type: integer

Port to listen on


Default: ""Type: string

Filename of the binary data file


Default: 0Type: integer

Version of the binary data file


Default: 0Type: integer

ChainID is the chain ID


Default: falseType: boolean

Enabled is a flag to enable/disable the data streamer


Log is the log configuration
Default: ""Type: enum (of string)

Must be one of:

  • "production"
  • "development"

Default: ""Type: enum (of string)

Must be one of:

  • "debug"
  • "info"
  • "warn"
  • "error"
  • "dpanic"
  • "panic"
  • "fatal"

Type: array of string

Each item of this array must be:


Default: 0Type: integer

UpgradeEtrogBatchNumber is the batch number of the upgrade etrog


Configuration of the sequence sender service
Default: "5s"Type: string

WaitPeriodSendSequence is the time the sequencer waits until
trying to send a sequence to L1


Examples:

"1m"
+

Default: trueType: boolean

EnableLog is a flag to enable/disable metrics logs


StreamServerCfg is the config for the stream server
Default: 0Type: integer

Port to listen on


Default: ""Type: string

Filename of the binary data file


Default: 0Type: integer

Version of the binary data file


Default: 0Type: integer

ChainID is the chain ID


Default: falseType: boolean

Enabled is a flag to enable/disable the data streamer


Log is the log configuration
Default: ""Type: enum (of string)

Must be one of:

  • "production"
  • "development"

Default: ""Type: enum (of string)

Must be one of:

  • "debug"
  • "info"
  • "warn"
  • "error"
  • "dpanic"
  • "panic"
  • "fatal"

Type: array of string

Each item of this array must be:


Default: 0Type: integer

UpgradeEtrogBatchNumber is the batch number of the upgrade etrog


Default: "5s"Type: string

WriteTimeout is the TCP write timeout when sending data to a datastream client


Examples:

"1m"
+
"300ms"
+

Configuration of the sequence sender service
Default: "5s"Type: string

WaitPeriodSendSequence is the time the sequencer waits until
trying to send a sequence to L1


Examples:

"1m"
 
"300ms"
 

Default: "5s"Type: string

LastBatchVirtualizationTimeMaxWaitPeriod is time since sequences should be sent


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 24fa55c89e..b42b4a7aa0 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -2501,6 +2501,7 @@ EnableLog=true
 | - [Enabled](#Sequencer_StreamServer_Enabled )                                 | No      | boolean | No         | -          | Enabled is a flag to enable/disable the data streamer            |
 | - [Log](#Sequencer_StreamServer_Log )                                         | No      | object  | No         | -          | Log is the log configuration                                     |
 | - [UpgradeEtrogBatchNumber](#Sequencer_StreamServer_UpgradeEtrogBatchNumber ) | No      | integer | No         | -          | UpgradeEtrogBatchNumber is the batch number of the upgrade etrog |
+| - [WriteTimeout](#Sequencer_StreamServer_WriteTimeout )                       | No      | string  | No         | -          | Duration                                                         |
 
 #### 10.9.1. `Sequencer.StreamServer.Port`
 
@@ -2638,6 +2639,32 @@ Must be one of:
 UpgradeEtrogBatchNumber=0
 ```
 
+#### 10.9.8. `Sequencer.StreamServer.WriteTimeout`
+
+**Title:** Duration
+
+**Type:** : `string`
+
+**Default:** `"5s"`
+
+**Description:** WriteTimeout is the TCP write timeout when sending data to a datastream client
+
+**Examples:** 
+
+```json
+"1m"
+```
+
+```json
+"300ms"
+```
+
+**Example setting the default value** ("5s"):
+```
+[Sequencer.StreamServer]
+WriteTimeout="5s"
+```
+
 ## 11. `[SequenceSender]`
 
 **Type:** : `object`
diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json
index 9ed804cba0..bc4df6337e 100644
--- a/docs/config-file/node-config-schema.json
+++ b/docs/config-file/node-config-schema.json
@@ -1010,6 +1010,16 @@
 							"type": "integer",
 							"description": "UpgradeEtrogBatchNumber is the batch number of the upgrade etrog",
 							"default": 0
+						},
+						"WriteTimeout": {
+							"type": "string",
+							"title": "Duration",
+							"description": "WriteTimeout is the TCP write timeout when sending data to a datastream client",
+							"default": "5s",
+							"examples": [
+								"1m",
+								"300ms"
+							]
 						}
 					},
 					"additionalProperties": false,
diff --git a/go.mod b/go.mod
index 03642ff6ae..3abb064d43 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.2.3-0.20240527085154-ca3561dd370b
+	github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-RC4
 	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
diff --git a/go.sum b/go.sum
index 7679f950b4..070d78f5c2 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.2.3-0.20240527085154-ca3561dd370b h1:BzQRXbSnW7BsFvJrnZbCgnxD5+nCGyrYUgqH+3vsnrM=
-github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240527085154-ca3561dd370b/go.mod h1:0QkAXcFa92mFJrCbN3UPUJGJYes851yEgYHLONnaosE=
+github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-RC4 h1:+4K+xSzv0ImbK30B/T9FauNTrTFUmWcNKYhIgwsE4C4=
+github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-RC4/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=
diff --git a/sequencer/config.go b/sequencer/config.go
index 03aeeb740b..5f34cad1d9 100644
--- a/sequencer/config.go
+++ b/sequencer/config.go
@@ -52,6 +52,8 @@ type StreamServerCfg struct {
 	Log log.Config `mapstructure:"Log"`
 	// UpgradeEtrogBatchNumber is the batch number of the upgrade etrog
 	UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
+	// WriteTimeout is the TCP write timeout when sending data to a datastream client
+	WriteTimeout types.Duration `mapstructure:"WriteTimeout"`
 }
 
 // FinalizerCfg contains the finalizer's configuration properties
diff --git a/sequencer/l2block.go b/sequencer/l2block.go
index d38b9be30b..10489cbae0 100644
--- a/sequencer/l2block.go
+++ b/sequencer/l2block.go
@@ -245,7 +245,7 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error
 		if subOverflow { // Sanity check, this cannot happen as reservedZKCounters should be >= that usedZKCounters
 			return fmt.Errorf("error subtracting L2 block %d [%d] needed resources from the batch %d, overflow resource: %s, batch bytes: %d, L2 block bytes: %d, counters: {batch: %s, used: %s, reserved: %s, needed: %s, high: %s}",
 				blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, overflowResource, l2Block.batch.finalRemainingResources.Bytes, batchL2DataSize,
-				f.logZKCounters(l2Block.batch.finalRemainingResources.ZKCounters), f.logZKCounters(batchResponse.UsedZkCounters), f.logZKCounters(batchResponse.ReservedZkCounters), f.logZKCounters(neededZKCounters), f.logZKCounters(l2Block.batch.imHighReservedZKCounters))
+				f.logZKCounters(l2Block.batch.finalRemainingResources.ZKCounters), f.logZKCounters(batchResponse.UsedZkCounters), f.logZKCounters(batchResponse.ReservedZkCounters), f.logZKCounters(neededZKCounters), f.logZKCounters(l2Block.batch.finalHighReservedZKCounters))
 		}
 
 		l2Block.batch.finalHighReservedZKCounters = newHighZKCounters
@@ -253,7 +253,7 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error
 	} else {
 		overflowLog := fmt.Sprintf("L2 block %d [%d] needed resources exceeds the remaining batch %d resources, overflow resource: %s, batch bytes: %d, L2 block bytes: %d, counters: {batch: %s, used: %s, reserved: %s, needed: %s, high: %s}",
 			blockResponse.BlockNumber, l2Block.trackingNum, l2Block.batch.batchNumber, overflowResource, l2Block.batch.finalRemainingResources.Bytes, batchL2DataSize,
-			f.logZKCounters(l2Block.batch.finalRemainingResources.ZKCounters), f.logZKCounters(batchResponse.UsedZkCounters), f.logZKCounters(batchResponse.ReservedZkCounters), f.logZKCounters(neededZKCounters), f.logZKCounters(l2Block.batch.imHighReservedZKCounters))
+			f.logZKCounters(l2Block.batch.finalRemainingResources.ZKCounters), f.logZKCounters(batchResponse.UsedZkCounters), f.logZKCounters(batchResponse.ReservedZkCounters), f.logZKCounters(neededZKCounters), f.logZKCounters(l2Block.batch.finalHighReservedZKCounters))
 
 		f.LogEvent(ctx, event.Level_Warning, event.EventID_ReservedZKCountersOverflow, overflowLog, nil)
 
diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go
index f191973767..92909e2946 100644
--- a/sequencer/sequencer.go
+++ b/sequencer/sequencer.go
@@ -17,7 +17,7 @@ import (
 )
 
 const (
-	datastreamChannelBufferSize = 20
+	datastreamChannelBufferSize = 50
 )
 
 // Sequencer represents a sequencer
@@ -72,7 +72,7 @@ func (s *Sequencer) Start(ctx context.Context) {
 
 	// Start stream server if enabled
 	if s.cfg.StreamServer.Enabled {
-		s.streamServer, err = datastreamer.NewServer(s.cfg.StreamServer.Port, s.cfg.StreamServer.Version, s.cfg.StreamServer.ChainID, state.StreamTypeSequencer, s.cfg.StreamServer.Filename, &s.cfg.StreamServer.Log)
+		s.streamServer, err = datastreamer.NewServer(s.cfg.StreamServer.Port, s.cfg.StreamServer.Version, s.cfg.StreamServer.ChainID, state.StreamTypeSequencer, s.cfg.StreamServer.Filename, s.cfg.StreamServer.WriteTimeout.Duration, &s.cfg.StreamServer.Log)
 		if err != nil {
 			log.Fatalf("failed to create stream server, error: %v", err)
 		}
diff --git a/test/config/debug.node.config.toml b/test/config/debug.node.config.toml
index 68f7dd17ce..54ca62a789 100644
--- a/test/config/debug.node.config.toml
+++ b/test/config/debug.node.config.toml
@@ -112,6 +112,7 @@ StateConsistencyCheckInterval = "5s"
 		Port = 6900
 		Filename = "/datastreamer/datastream.bin"
 		Version = 1
+		WriteTimeout = "5s"
 		Enabled = true
 
 [SequenceSender]
diff --git a/test/config/test.node.config.toml b/test/config/test.node.config.toml
index 9fbb48d8ce..d6ee17c5c6 100644
--- a/test/config/test.node.config.toml
+++ b/test/config/test.node.config.toml
@@ -128,6 +128,7 @@ StateConsistencyCheckInterval = "5s"
 		Filename = "/datastreamer/datastream.bin"
 		Version = 1
 		ChainID = 1337
+		WriteTimeout = "5s"
 		Enabled = true
 		
 
diff --git a/tools/datastreamer/config/config.go b/tools/datastreamer/config/config.go
index 0acb225cf9..b6c841e591 100644
--- a/tools/datastreamer/config/config.go
+++ b/tools/datastreamer/config/config.go
@@ -7,6 +7,7 @@ import (
 
 	"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
 	"github.com/0xPolygonHermez/zkevm-data-streamer/log"
+	"github.com/0xPolygonHermez/zkevm-node/config/types"
 	"github.com/0xPolygonHermez/zkevm-node/db"
 	"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
 	"github.com/mitchellh/mapstructure"
@@ -48,6 +49,8 @@ type StreamServerCfg struct {
 	Log log.Config `mapstructure:"Log"`
 	// UpgradeEtrogBatchNumber is the batch number of the upgrade etrog
 	UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
+	// WriteTimeout is the TCP write timeout when sending data to a datastream client
+	WriteTimeout types.Duration `mapstructure:"WriteTimeout"`
 }
 
 // Config is the configuration for the tool
diff --git a/tools/datastreamer/config/tool.config.toml b/tools/datastreamer/config/tool.config.toml
index 0e8fc09fc9..f5530b8271 100644
--- a/tools/datastreamer/config/tool.config.toml
+++ b/tools/datastreamer/config/tool.config.toml
@@ -7,6 +7,7 @@ Port = 6901
 Filename = "datastream.bin"
 Version = 3
 ChainID = 1440
+WriteTimeout = "5s"
 UpgradeEtrogBatchNumber = 0
 
 [StateDB]
diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go
index a2e3d19003..fc069117af 100644
--- a/tools/datastreamer/main.go
+++ b/tools/datastreamer/main.go
@@ -184,7 +184,7 @@ func main() {
 
 func initializeStreamServer(c *config.Config) (*datastreamer.StreamServer, error) {
 	// Create a stream server
-	streamServer, err := datastreamer.NewServer(c.Offline.Port, c.Offline.Version, c.Offline.ChainID, state.StreamTypeSequencer, c.Offline.Filename, &c.Log)
+	streamServer, err := datastreamer.NewServer(c.Offline.Port, c.Offline.Version, c.Offline.ChainID, state.StreamTypeSequencer, c.Offline.Filename, c.Offline.WriteTimeout.Duration, &c.Log)
 	if err != nil {
 		return nil, err
 	}

From 061db8d1876f225613467dabcdd4ada3401daf62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toni=20Ram=C3=ADrez?=
 <58293609+ToniRamirezM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 18:27:27 +0200
Subject: [PATCH 20/23] change imstateroot handling in DS (#3698)

* change imstateroot handling in DS
---
 sequencer/sequencer.go | 4 ++--
 state/datastream.go    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go
index 92909e2946..3f57d9cc85 100644
--- a/sequencer/sequencer.go
+++ b/sequencer/sequencer.go
@@ -349,10 +349,10 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 						ImStateRoot:                 l2Transaction.ImStateRoot.Bytes(),
 					}
 
-					// Clear the state root if the ForkID is >= ETROG
+					// Clear the state root if the ForkID is > ETROG
 					// currently this is redundant as the current implementation of the sequencer
 					// leaves the ImStateRoot empty
-					if l2Block.ForkID >= state.FORKID_ETROG {
+					if l2Block.ForkID > state.FORKID_ETROG {
 						streamL2Transaction.ImStateRoot = common.Hash{}.Bytes()
 					}
 
diff --git a/state/datastream.go b/state/datastream.go
index ecb211d6c2..236a69df43 100644
--- a/state/datastream.go
+++ b/state/datastream.go
@@ -590,8 +590,8 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre
 							ImStateRoot:                 tx.StateRoot.Bytes(),
 						}
 
-						// Clear the state root if the ForkID is >= ETROG
-						if l2Block.ForkID >= FORKID_ETROG {
+						// Clear the state root if the ForkID is > ETROG
+						if l2Block.ForkID > FORKID_ETROG {
 							transaction.ImStateRoot = common.Hash{}.Bytes()
 						}
 

From 89ebbdc29b6b26806bacc5ab31b0a1d09b3ce4ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= 
Date: Wed, 26 Jun 2024 15:43:55 +0200
Subject: [PATCH 21/23] Fix tests

---
 jsonrpc/endpoints_zkevm.go      | 53 ++++++++++++++++-----------------
 jsonrpc/endpoints_zkevm_test.go |  5 ----
 test/docker-compose.yml         |  4 ---
 3 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/jsonrpc/endpoints_zkevm.go b/jsonrpc/endpoints_zkevm.go
index 9e12a9d9b4..ae363b840f 100644
--- a/jsonrpc/endpoints_zkevm.go
+++ b/jsonrpc/endpoints_zkevm.go
@@ -208,38 +208,37 @@ func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (
 }
 
 func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) (interface{}, types.Error) {
-	return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
-		batchNumbers := make([]uint64, 0, len(filter.Numbers))
-		for _, bn := range filter.Numbers {
-			n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx)
-			if rpcErr != nil {
-				return nil, rpcErr
-			}
-			batchNumbers = append(batchNumbers, n)
+	ctx := context.Background()
+	batchNumbers := make([]uint64, 0, len(filter.Numbers))
+	for _, bn := range filter.Numbers {
+		n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, nil)
+		if rpcErr != nil {
+			return nil, rpcErr
 		}
+		batchNumbers = append(batchNumbers, n)
+	}
 
-		batchesData, err := f(ctx, batchNumbers, dbTx)
-		if errors.Is(err, state.ErrNotFound) {
-			return nil, nil
-		} else if err != nil {
-			return RPCErrorResponse(types.DefaultErrorCode,
-				fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true)
-		}
+	batchesData, err := f(ctx, batchNumbers, nil)
+	if errors.Is(err, state.ErrNotFound) {
+		return nil, nil
+	} else if err != nil {
+		return RPCErrorResponse(types.DefaultErrorCode,
+			fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true)
+	}
 
-		ret := make([]*types.BatchData, 0, len(batchNumbers))
-		for _, n := range batchNumbers {
-			data := &types.BatchData{Number: types.ArgUint64(n)}
-			if b, ok := batchesData[n]; ok {
-				data.BatchL2Data = b
-				data.Empty = false
-			} else {
-				data.Empty = true
-			}
-			ret = append(ret, data)
+	ret := make([]*types.BatchData, 0, len(batchNumbers))
+	for _, n := range batchNumbers {
+		data := &types.BatchData{Number: types.ArgUint64(n)}
+		if b, ok := batchesData[n]; ok {
+			data.BatchL2Data = b
+			data.Empty = false
+		} else {
+			data.Empty = true
 		}
+		ret = append(ret, data)
+	}
 
-		return types.BatchDataResult{Data: ret}, nil
-	})
+	return types.BatchDataResult{Data: ret}, nil
 }
 
 // GetFullBlockByNumber returns information about a block by block number
diff --git a/jsonrpc/endpoints_zkevm_test.go b/jsonrpc/endpoints_zkevm_test.go
index 5d74da2ddc..46a10bb9ca 100644
--- a/jsonrpc/endpoints_zkevm_test.go
+++ b/jsonrpc/endpoints_zkevm_test.go
@@ -2195,11 +2195,6 @@ func TestClient_BatchesByNumbers(t *testing.T) {
 	m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything).
 		Return(batchesDataMap, nil).Once()
 
-	m.State.On("BeginStateTransaction", context.Background()).
-		Return(m.DbTx, nil).Once()
-
-	m.DbTx.On("Commit", context.Background()).Return(nil).Once()
-
 	zkEVMClient := client.NewClient(s.ServerURL)
 	reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)}
 	result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum)
diff --git a/test/docker-compose.yml b/test/docker-compose.yml
index a36ea6007b..faaad6610c 100644
--- a/test/docker-compose.yml
+++ b/test/docker-compose.yml
@@ -521,8 +521,6 @@ services:
       - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
     volumes:
       - ./config/test.prover.config.json:/usr/src/app/config.json
-    environment:
-      - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
     command: >
       zkProver -c /usr/src/app/config.json
 
@@ -617,8 +615,6 @@ services:
       - 50078:50071 # Executor
     volumes:
       - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json
-    environment:
-      - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
     command: >
       zkProver -c /usr/src/app/config.json
 

From 0a561c9fea14937d18002033707b15bb8b80e6d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= 
Date: Wed, 26 Jun 2024 15:47:05 +0200
Subject: [PATCH 22/23] Generate node config doc

---
 docs/config-file/node-config-doc.html    |  4 ++--
 docs/config-file/node-config-doc.md      | 18 +++++++++++++++++-
 docs/config-file/node-config-schema.json |  5 +++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html
index b1a0f16a0d..166b5d3820 100644
--- a/docs/config-file/node-config-doc.html
+++ b/docs/config-file/node-config-doc.html
@@ -28,7 +28,7 @@
 
"300ms"
 

Default: "5s"Type: string

RollupInfoRetriesSpacing is the minimum time between retries to request rollup info (it will sleep for fulfill this time) to avoid spamming L1


Examples:

"1m"
 
"300ms"
-

Default: falseType: boolean

FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized


L2Synchronization Configuration for L2 synchronization
Default: falseType: boolean

AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them.


Default: falseType: boolean

ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again


Default: trueType: boolean

CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash


Default: ["local", "trusted", "external"]Type: array of string

DataSourcePriority defines the order in which L2 batch should be retrieved: local, trusted, external

Each item of this array must be:


Configuration of the sequencer service
Default: 100Type: integer

DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool


Default: "12h0m0s"Type: string

DeletePoolTxsCheckInterval is frequency with which txs will be checked for deleting


Examples:

"1m"
+

Default: falseType: boolean

FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized


L2Synchronization Configuration for L2 synchronization
Default: trueType: boolean

If enabled then the L2 sync process is permitted (only for permissionless)


Default: falseType: boolean

AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them.


Default: falseType: boolean

ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again


Default: trueType: boolean

CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash


Default: ["local", "trusted", "external"]Type: array of string

DataSourcePriority defines the order in which L2 batch should be retrieved: local, trusted, external

Each item of this array must be:


Configuration of the sequencer service
Default: 100Type: integer

DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool


Default: "12h0m0s"Type: string

DeletePoolTxsCheckInterval is frequency with which txs will be checked for deleting


Examples:

"1m"
 
"300ms"
 

Default: "10m0s"Type: string

TxLifetimeCheckInterval is the time the sequencer waits to check txs lifetime


Examples:

"1m"
 
"300ms"
@@ -64,7 +64,7 @@
 
"300ms"
 

Default: "30s"Type: string

L1BlockTimestampMargin is the time difference (margin) that must exists between last L1 block and last L2 block in the sequence before
to send the sequence to L1. If the difference is lower than this value then sequencesender will wait until the difference is equal or greater


Examples:

"1m"
 
"300ms"
-

Default: 131072Type: integer

MaxTxSizeForL1 is the maximum size a single transaction can have. This field has
non-trivial consequences: larger transactions than 128KB are significantly harder and
more expensive to propagate; larger transactions also take more resources
to validate whether they fit into the pool or not.


Type: array of integer

SenderAddress defines which private key the eth tx manager needs to use
to sign the L1 txs

Must contain a minimum of 20 items

Must contain a maximum of 20 items

Each item of this array must be:


Default: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"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:


PrivateKey defines all the key store files that are going to be read in order to provide the private keys to sign the L1 txs
Default: "/pk/sequencer.keystore"Type: string

Path is the file path for the key store file


Default: "testonly"Type: string

Password is the password to decrypt the key store file


Default: 0Type: integer

Batch number where there is a forkid change (fork upgrade)


Default: 80000Type: integer

GasOffset is the amount of gas to be added to the gas estimation in order
to provide an amount that is higher than the estimated one. This is used
to avoid the TX getting reverted in case something has changed in the network
state after the estimation which can cause the TX to require more gas to be
executed.

ex:
gas estimation: 1000
gas offset: 100
final gas: 1100


Default: 300Type: integer

MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx


Configuration of the aggregator service
Default: "0.0.0.0"Type: string

Host for the grpc server


Default: 50081Type: integer

Port for the grpc server


Default: "5s"Type: string

RetryTime is the time the aggregator main loop sleeps if there are no proofs to aggregate
or batches to generate proofs. It is also used in the isSynced loop


Examples:

"1m"
+

Default: 131072Type: integer

MaxTxSizeForL1 is the maximum size a single transaction can have. This field has
non-trivial consequences: larger transactions than 128KB are significantly harder and
more expensive to propagate; larger transactions also take more resources
to validate whether they fit into the pool or not.


Type: array of integer

SenderAddress defines which private key the eth tx manager needs to use
to sign the L1 txs

Must contain a minimum of 20 items

Must contain a maximum of 20 items

Each item of this array must be:


Default: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"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:


PrivateKey defines all the key store files that are going to be read in order to provide the private keys to sign the L1 txs
Default: "/pk/sequencer.keystore"Type: string

Path is the file path for the key store file


Default: "testonly"Type: string

Password is the password to decrypt the key store file


Default: 0Type: integer

Batch number where there is a forkid change (fork upgrade)


Default: 80000Type: integer

GasOffset is the amount of gas to be added to the gas estimation in order
to provide an amount that is higher than the estimated one. This is used
to avoid the TX getting reverted in case something has changed in the network
state after the estimation which can cause the TX to require more gas to be
executed.

ex:
gas estimation: 1000
gas offset: 100
final gas: 1100


Default: 300Type: integer

MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx


Default: 32Type: integer

SequenceL1BlockConfirmations is number of blocks to consider a sequence sent to L1 as final


Configuration of the aggregator service
Default: "0.0.0.0"Type: string

Host for the grpc server


Default: 50081Type: integer

Port for the grpc server


Default: "5s"Type: string

RetryTime is the time the aggregator main loop sleeps if there are no proofs to aggregate
or batches to generate proofs. It is also used in the isSynced loop


Examples:

"1m"
 
"300ms"
 

Default: "1m30s"Type: string

VerifyProofInterval is the interval of time to verify/send an proof in L1


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index b42b4a7aa0..af2f1c4308 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1876,6 +1876,7 @@ FallbackToSequentialModeOnSynchronized=false
 
 | Property                                                                                                | Pattern | Type            | Deprecated | Definition | Title/Description                                                                                                                                                   |
 | ------------------------------------------------------------------------------------------------------- | ------- | --------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| - [Enabled](#Synchronizer_L2Synchronization_Enabled )                                                   | No      | boolean         | No         | -          | If enabled then the L2 sync process is permitted (only for permissionless)                                                                                          |
 | - [AcceptEmptyClosedBatches](#Synchronizer_L2Synchronization_AcceptEmptyClosedBatches )                 | No      | boolean         | No         | -          | AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them. | | - [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 | @@ -1938,7 +1939,7 @@ ReprocessFullBatchOnClose=false CheckLastL2BlockHashOnCloseBatch=true ``` -#### 9.10.4. `Synchronizer.L2Synchronization.DataSourcePriority` +#### 9.10.5. `Synchronizer.L2Synchronization.DataSourcePriority` **Type:** : `array of string` @@ -2682,6 +2683,7 @@ WriteTimeout="5s" | - [ForkUpgradeBatchNumber](#SequenceSender_ForkUpgradeBatchNumber ) | No | integer | No | - | Batch number where there is a forkid change (fork upgrade) | | - [GasOffset](#SequenceSender_GasOffset ) | No | integer | No | - | GasOffset is the amount of gas to be added to the gas estimation in order
to provide an amount that is higher than the estimated one. This is used
to avoid the TX getting reverted in case something has changed in the network
state after the estimation which can cause the TX to require more gas to be
executed.

ex:
gas estimation: 1000
gas offset: 100
final gas: 1100 | | - [MaxBatchesForL1](#SequenceSender_MaxBatchesForL1 ) | No | integer | No | - | MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx | +| - [SequenceL1BlockConfirmations](#SequenceSender_SequenceL1BlockConfirmations ) | No | integer | No | - | SequenceL1BlockConfirmations is number of blocks to consider a sequence sent to L1 as final | ### 11.1. `SequenceSender.WaitPeriodSendSequence` @@ -2890,6 +2892,20 @@ GasOffset=80000 MaxBatchesForL1=300 ``` +### 11.11. `SequenceSender.SequenceL1BlockConfirmations` + +**Type:** : `integer` + +**Default:** `32` + +**Description:** SequenceL1BlockConfirmations is number of blocks to consider a sequence sent to L1 as final + +**Example setting the default value** (32): +``` +[SequenceSender] +SequenceL1BlockConfirmations=32 +``` + ## 12. `[Aggregator]` **Type:** : `object` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index bc4df6337e..1b4c105e24 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -1118,6 +1118,11 @@ "type": "integer", "description": "MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx", "default": 300 + }, + "SequenceL1BlockConfirmations": { + "type": "integer", + "description": "SequenceL1BlockConfirmations is number of blocks to consider a sequence sent to L1 as final", + "default": 32 } }, "additionalProperties": false, From f310741db886f6472c1bb7ac6cac16242a607ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 26 Jun 2024 16:51:12 +0200 Subject: [PATCH 23/23] Update the diff --- docs/diff/diff.html | 327101 +++++++---------------------------------- 1 file changed, 49868 insertions(+), 277233 deletions(-) diff --git a/docs/diff/diff.html b/docs/diff/diff.html index 7cb663b904..8a7876c592 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 (208) + Files changed (85) 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 - +840 - -38 + +171 + -35 @@ -78,47 +78,11 @@

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

{/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go - +154 - -84 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/batch.go - - +0 - -427 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobinner.go - - +0 + +77 -7
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobouter.go - - +0 - -11 - - -
  • 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 - +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 + +1 + -0
  • @@ -246,8 +150,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go - +140 - -29 + +143 + -17 @@ -294,7 +198,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go - +13 + +16 -7 @@ -306,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 - +7 - -2 + +6 + -0 @@ -390,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 - +152 + +183 -0 @@ -443,126 +347,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0013_test.go - - +19 - -25 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql - - +19 - -75 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go - - +107 - -81 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0021.sql - - +0 - -1 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022.sql - - +0 - -25 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022_test.go - - +0 - -145 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0023.sql - - +0 - -12 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0023_test.go - - +0 - -106 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0024.sql - - +0 - -57 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/utils_test.go - - +0 - -159 - - -
  • 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 - +407 - -332 + +283 + -133
  • @@ -666,80 +414,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go - +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 + +42 + -31
  • @@ -762,83 +438,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - +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 + +27 -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/eventlog.go - - +25 - -1 - - -
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod - +43 - -37 + +9 + -7
  • @@ -918,8 +510,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 + +3 + -0 @@ -942,8 +534,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go - +48 - -1 + +46 + -0 @@ -954,7 +546,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go - +29 + +24 -0 @@ -991,7 +583,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go +3 - -1 + -0 @@ -1007,102 +599,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go - - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice.go - - +1 - -35 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice_test.go - - +3 - -5 - - -
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go - +13 - -2 + +12 + -0
  • @@ -1170,8 +666,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go - +67 - -1 + +66 + -0 @@ -1182,8 +678,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 - +2 - -246 + +1 + -0 @@ -1194,8 +690,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - +6 - -5 + +1 + -0 @@ -1206,19 +702,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go - +12 - -1 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go - - +17 + +2 -0 @@ -1254,8 +738,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go - +18 - -107 + +15 + -99
  • @@ -1271,30 +755,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sonar-project.properties - - +2 - -7 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batch_pending.go - - +0 - -11 - - -
  • zkevm-node version: v0.6.0

    {/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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV3.go - - +0 - -137 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_in.go - - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV3.go - - +0 - -79 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go - - +2 - -0 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go - - +44 + +3 -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 - - +3 - -5 - - -
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - +13 - -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 - - +29 - -1 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch_pending.go - - +0 - -1 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_inner_in.go - - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go - - +27 - -66 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree_recursive.go - - +0 - -46 + +3 + -0
  • @@ -1650,44 +810,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - - +0 - -2 + +109 + -1
  • @@ -1697,129 +821,9 @@

    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 → .}/state/runtime/executor/client.go - - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go - - +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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go - - +10 - -2 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go +7 - -3 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go - - +32 - -47 + -0
  • @@ -1828,10 +832,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_initial_sequence_batches.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go - +3 - -3 + +2 + -0 @@ -1842,20 +846,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 - +8 - -55 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update.go - - +3 - -3 + +5 + -52
  • @@ -1864,7 +856,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go +1 -1 @@ -1876,22 +868,10 @@

    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 - - +16 - -4 - -
    - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/config.go - +11 - -3 + +5 + -0
  • @@ -1900,10 +880,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_update_etrog_sequence.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go - +3 - -3 + +1 + -0 @@ -1912,10 +892,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_info_tree_update.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - +0 - -54 + +1 + -0 @@ -1924,10 +904,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - +0 - -189 + +35 + -5 @@ -1936,10 +916,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - +0 - -102 + +8 + -8 @@ -1948,10 +928,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol - +3 - -23 + +24 + -0 @@ -1960,10 +940,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forced_batches.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go - +3 - -3 + +224 + -0 @@ -1972,10 +952,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go - +4 - -3 + +1 + -1 @@ -1984,9 +964,9 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_global_exit_root.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml - +3 + +51 -3 @@ -1996,10 +976,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go - +3 - -3 + +270 + -0 @@ -2008,9 +988,9 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go - +0 + +1 -1 @@ -2020,10 +1000,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_force_batches.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go - +3 - -3 + +2 + -2 @@ -2032,10 +1012,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_verify_batch.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go - +3 - -3 + +1 + -1 @@ -2044,9 +1024,9 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/processor_base.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - +6 + +60 -16 @@ -2056,22 +1036,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/block_range_processor.go - - +0 - -21 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go - +0 - -6 + +21 + -1
  • @@ -2080,10 +1048,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/l1_event_processor_manager.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go - +0 - -14 + +2 + -2 @@ -2092,22 +1060,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 → .}/tools/state/main.go +1 - -13 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/sync_pre_rollup_syncer.go - - +0 - -10 + -1
  • @@ -2116,442 +1072,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 → .}/tools/state/reprocess_cmd.go - +2 - -2 - - - -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/default_l1processors.go - - +0 - -2 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go - - +11 - -5 - - -
  • -
  • - - {/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 - - +7 - -7 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync_test.go - - +68 - -0 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - - +1 - -0 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_block_range_process.go - - +0 - -166 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - - +90 - -104 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup.go - - +0 - -122 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup_test.go - - +0 - -89 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - - +23 - -17 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol - - +24 - -0 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml - - +55 - -11 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go - - +270 - -0 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go - - +6 - -6 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go - - +2 - -2 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc1_test.go - - +13 - -14 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/shared.go - - +2 - -2 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go - - +1 - -1 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - - +66 - -44 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go - - +22 - -6 - - -
  • -
  • - - {/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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go - - +1 - -156 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/Makefile - - +0 - -8 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/egp/main.go - - +85 - -183 - - -
  • -
  • - - {/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 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/main.go - - +1 - -1 - - -
  • -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/reprocess_cmd.go - - +2 - -2 + +1 + -1
  • @@ -2577,7 +1101,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -2,8 +2,11 @@
    +
    @@ -2,6 +2,7 @@
    @@ -2612,16 +1136,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    - - - -
    @@ -2636,7 +1150,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "errors" + "encoding/json"
    @@ -2646,17 +1160,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "fmt" -
    - - - - - - -
    -   -
    + "errors"
    @@ -2666,37 +1170,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "net" -
    - - - - 8 - - -
    -   - "strconv" -
    - - - - 9 - - -
    -   - "strings" + "fmt"
    -
    @@ -64,6 +71,9 @@
    +
    @@ -67,6 +71,9 @@
    - 64 + 67
    @@ -2706,7 +1190,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 65 + 68
    @@ -2716,7 +1200,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 66 + 69
    @@ -2756,7 +1240,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 67 + 70
    @@ -2766,7 +1250,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 68 + 71
    @@ -2776,7 +1260,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 69 + 72
    @@ -2787,11 +1271,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -72,6 +82,8 @@
    +
    @@ -75,6 +82,8 @@
    - 72 + 75
    @@ -2801,7 +1285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 73 + 76
    @@ -2811,7 +1295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 74 + 77
    @@ -2841,7 +1325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 75 + 78
    @@ -2851,7 +1335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 76 + 79
    @@ -2861,7 +1345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 77 + 80
    @@ -2872,11 +1356,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -93,6 +105,9 @@
    +
    @@ -96,6 +105,9 @@
    - 93 + 96
    @@ -2886,7 +1370,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 94 + 97
    @@ -2896,7 +1380,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 95 + 98
    @@ -2936,7 +1420,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 96 + 99
    @@ -2946,7 +1430,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 97 + 100
    @@ -2956,7 +1440,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 98 + 101
    @@ -2967,296 +1451,366 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -116,7 +131,7 @@
    +
    @@ -215,6 +227,11 @@
    - 116 + 215
      - }, nil) + _, err = a.tryBuildFinalProof(ctx, prover, nil)
    - 117 + 216
      -
    + if err != nil {
    - 118 + 217
      - // Delete ungenerated recursive proofs + log.Errorf("Error checking proofs to verify: %v", err)
    - - 119 + + - -
    - - - err := a.State.DeleteUngeneratedBatchProofs(ctx, nil) + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    - 120 + 218
      - if err != nil { + }
    - 121 + 219
      - return fmt.Errorf("failed to initialize proofs cache %w", err) +
    - 122 + 220
      - } + proofGenerated, err := a.tryAggregateProofs(ctx, prover)
    -
    @@ -212,46 +227,819 @@
    +
    @@ -269,34 +286,139 @@
    - 212 + 269
      - _, err = a.tryBuildFinalProof(ctx, prover, nil) +
    - 213 + 270
      - if err != nil { + log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot)
    - 214 + 271
    -   - log.Errorf("Error checking proofs to verify: %v", err) -
    - - - - - - -
     
    - - + + 272 - -
    -   -
    + +
    + - + // add batch verification to be monitored
    - - + + 273 - -
    -   -
    + +
    + - + sender := common.HexToAddress(a.cfg.SenderAddress)
    - - + + 274 - -
    -   -
    + +
    + - + to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs, sender)
    - - + + 275 - -
    -   -
    + +
    + - + if err != nil {
    - - 215 + + 276 - +
    -   - } + - + log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
    - - 216 + + 277 - +
    -   -
    + - + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - 217 + 278
    - - proofGenerated, err := a.tryAggregateBlobOuterProofs(ctx, prover) + continue
    - - 218 + + 279 - +
    -   - if err != nil { + - + }
    - 219 + 280
    - - log.Errorf("Error trying to aggregate blobOuter proofs: %v", err) + monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal)
    - - 220 + + 281 - +
    -   - } + - + err = a.EthTxManager.Add(ctx, ethTxManagerOwner, monitoredTxID, sender, to, nil, data, a.cfg.GasOffset, nil)
    - 221 + 282
    - -
    + if err != nil {
    - - 222 + + 283 - +
    -   - if !proofGenerated { + - + mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to)
    - - 223 + + 284 - +
    - - proofGenerated, err = a.tryGenerateBlobOuterProof(ctx, prover) + mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err)
    - - 224 + + 285 - +
    -   - if err != nil { + - + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - - 225 + + 286 - +
    - - log.Errorf("Error trying to generate blobOuter proofs: %v", err) + continue
    - 226 + 287
      - } + }
    - 227 + 288
      - } +
    - 228 + 289 + + +
    + - + // process monitored batch verifications before starting a next cycle +
    + + + + 290 + + +
    + - + a.EthTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { +
    + + + + 291 + + +
    + - + a.handleMonitoredTxResult(result) +
    + + + + 292 + + +
    + - + }, nil) +
    + + + + 293
    @@ -3266,60 +1820,60 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 229 + 294
      - if !proofGenerated { + a.resetVerifyProofTime()
    - - 230 + + 295 - +
    - - - proofGenerated, err = a.tryGenerateBlobInnerProof(ctx, prover) +   + a.endProofVerification()
    - - 231 + + 296 - +
    - - - if err != nil { +   + }
    - - 232 + + 297 - +
    - - - log.Errorf("Error trying to aggregate blobInner proofs: %v", err) +   + }
    - - 233 + + 298 - +
    - - - } +   + }
    - - + + 299 - -
    + +
     
    @@ -3585,65 +2139,15 @@

    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) -
    - @@ -3765,75 +2269,15 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 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) -
    - @@ -4595,661 +3039,681 @@

    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
    - - + + +
    @@ -373,10 +495,9 @@
    - -
    + + + 373 + + +
      -
    + }
    - - + + 374 - -
    + +
      -
    + log.Debug("Send final proof time reached")
    - - + + 375 - -
    + +
     
    - - + + 376 - -
    -   -
    + +
    + - + for !a.isSynced(ctx, nil) {
    - - + + 377 - -
    -   -
    + +
    + - + log.Info("Waiting for synchronizer to sync...")
    - - + + 378 - -
    -   -
    + +
    + - + time.Sleep(a.cfg.RetryTime.Duration)
    - - + + 379 - -
    -   -
    + +
    + - + continue
    - - + + 380 - -
    + +
      -
    + }
    - - + + 381 - -
    + +
     
    - - + + 382 - -
    + +
      -
    + var lastVerifiedBatchNum uint64
    - - + + +
    @@ -952,41 +1073,41 @@
    - -
    + + + 952 + + +
     
    - - + + 953 - -
    + +
      -
    + // isSynced checks if the state is synchronized with L1. If a batch number is
    - - + + 954 - -
    + +
      -
    + // provided, it makes sure that the state is synced with that batch.
    - - + + 955 - -
    -   -
    + +
    + - + func (a *Aggregator) isSynced(ctx context.Context, batchNum *uint64) bool {
    - - + + 956 - -
    + +
      -
    + // get latest verified batch as seen by the synchronizer
    - - + + 957 - -
    + +
      -
    + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil)
    - - + + 958 - -
    + +
      -
    + if err == state.ErrNotFound {
    - - + + 959 - -
    -   -
    + +
    + - + return false
    - - + + 960 - -
    + +
      -
    + }
    - - + + 961 - -
    + +
      -
    + if err != nil {
    - - + + 962 - -
    + +
      -
    + log.Warnf("Failed to get last consolidated batch: %v", err)
    - - + + 963 - -
    -   -
    + +
    + - + return false
    - - + + 964 - -
    + +
      -
    + }
    - - + + 965 - -
    + +
     
    - - + + 966 - -
    + +
      -
    + if lastVerifiedBatch == nil {
    - - + + 967 - -
    -   -
    + +
    + - + return false
    - - + + 968 - -
    + +
      -
    + }
    - - + + 969 - -
    + +
     
    - - + + 970 - -
    + +
      -
    + if batchNum != nil && lastVerifiedBatch.BatchNumber < *batchNum {
    - - + + 971 - -
    + +
      -
    + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, waiting for batch: %d", lastVerifiedBatch.BatchNumber, batchNum)
    - - + + 972 - -
    -   -
    + +
    + - + return false
    - - + + 973 - -
    + +
      -
    + }
    - - + + 974 - -
    + +
     
    - - + + 975 - -
    + +
      -
    + // latest verified batch in L1
    - - + + 976 - -
    + +
      -
    + lastVerifiedEthBatchNum, err := a.Ethman.GetLatestVerifiedBatchNum()
    - - + + 977 - -
    + +
      -
    + if err != nil {
    - - + + 978 - -
    + +
      -
    + log.Warnf("Failed to get last eth batch, err: %v", err)
    - - + + 979 - -
    -   -
    + +
    + - + return false
    - - + + 980 - -
    + +
      -
    + }
    - - + + 981 - -
    + +
     
    - - + + 982 - -
    + +
      -
    + // check if L2 is synced with L1
    - - + + 983 - -
    + +
      -
    + if lastVerifiedBatch.BatchNumber < lastVerifiedEthBatchNum {
    - - + + 984 - -
    + +
      -
    + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, lastVerifiedEthBatchNum: %d, waiting for batch",
    - - + + 985 - -
    + +
      -
    + lastVerifiedBatch.BatchNumber, lastVerifiedEthBatchNum)
    - - + + 986 - -
    -   -
    + +
    + - + return false
    - - + + 987 - -
    + +
      -
    + }
    - - + + 988 - -
    + +
     
    - - + + 989 - -
    -   -
    + +
    + - + return true
    - - + + 990 - -
    + +
      -
    + }
    - - + + 991 - -
    + +
     
    - - + + 992 - -
    + +
      -
    + func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*prover.InputProver, error) {
    - - + + +
    @@ -1180,9 +1301,9 @@
    - -
    + + + 1180 + + +
     
    - - + + 1181 - -
    + +
      -
    + // wait for the synchronizer to catch up the verified batches
    - - + + 1182 - -
    + +
      -
    + log.Debug("A final proof has been sent, waiting for the network to be synced")
    - - + + 1183 - -
    -   -
    + +
    + - + for !a.isSynced(a.ctx, &proofBatchNumberFinal) {
    - - + + 1184 - -
    -   -
    + +
    + - + log.Info("Waiting for synchronizer to sync...")
    - - + + 1185 - -
    -   -
    + +
    + - + time.Sleep(a.cfg.RetryTime.Duration)
    - - + + 1186 - -
    + +
      -
    + }
    - - + + 1187 - -
    + +
     
    - - + + 1188 - -
    + +
      -
    + // network is synced with the final proof, we can safely delete all recursive
    - - + + +
    @@ -1193,6 +1314,24 @@
    - -
    + + + 1193 + + +
      -
    + }
    - - + + 1194 - -
    + +
      -
    + }
    - - + + 1195 - -
    + +
     
    @@ -5435,563 +3899,632 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + 1196 - -
    + +
      -
    + func buildMonitoredTxID(batchNumber, batchNumberFinal uint64) string {
    - - + + 1197 - -
    + +
      -
    + return fmt.Sprintf(monitoredIDFormat, batchNumber, batchNumberFinal)
    - - + + 1198 - -
    + +
      -
    + } +
    + + + + +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - + + + + + + + + + @@ -6055,21 +4588,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -7465,1213 +5983,1282 @@

    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
    - + +
     
    -
    +
    + 227 + +
      -
    + _, err = a.tryBuildFinalProof(ctx, prover, nil)
    - + + 228 -
    +
    +
      -
    + if err != nil {
    - + + 229 -
    +
    +
      -
    + log.Errorf("Error checking proofs to verify: %v", err)
    - + + 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 -
    +
    +
      -
    + }
    - + + 236 -
    +
    +
     
    - + + 237 -
    +
    +
      -
    + proofGenerated, err := a.tryAggregateProofs(ctx, prover)
    - + +
     
    -
    +
    + 286 + +
     
    - + + 287 -
    +
    +
      -
    + log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot)
    - + + 288 -
    +
    +
     
    - + + 289 -
    -   -
    +
    +
    + + + switch a.cfg.SettlementBackend {
    - + + 290 -
    -   -
    +
    +
    + + + case AggLayer:
    - + + 291 -
    -   -
    +
    +
    + + + if success := a.settleWithAggLayer(ctx, proof, inputs); !success {
    - + + 292 -
    -   -
    +
    +
    + + + continue
    - + + 293 -
    -   -
    +
    +
    + + + }
    - + + 294 -
    -   -
    +
    +
    + + + default: +
    +
    + 295 + +
    + + + if success := a.settleDirect(ctx, proof, inputs); !success { +
    +
    + 296 + +
    + + + continue +
    +
    + 297 + +
    + + + }
    - + + 298 -
    +
    +
      -
    + }
    - + + 299 -
    +
    +
     
    @@ -6126,1332 +4659,1317 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 247 + 300
      - } + a.resetVerifyProofTime()
    - 248 + 301
      - } + a.endProofVerification()
    - 249 + + 302 +
    - - - if !proofGenerated { +   + }
    - 250 + + 303 +
    - - - // if no proof was generated (aggregated or batch) wait some time before retry +   + }
    - 251 + + 304 +
    - - - time.Sleep(a.cfg.RetryTime.Duration) +   + }
    - 252 + + 305 +
    - - - } // if proof was generated we retry immediately as probably we have more proofs to process -
    -
    - - -
     
    - + + 306 -
    -   -
    +
    +
    + + + func (a *Aggregator) settleDirect(
    - + + 307 -
    -   -
    +
    +
    + + + ctx context.Context,
    - + + 308 -
    -   -
    +
    +
    + + + proof *state.Proof,
    - + + 309 -
    -   -
    +
    +
    + + + inputs ethmanTypes.FinalProofInputs,
    - + + 310 -
    -   -
    +
    +
    + + + ) (success bool) {
    - + + 311 -
    -   -
    +
    +
    + + + // add batch verification to be monitored
    - + + 312 -
    -   -
    +
    +
    + + + sender := common.HexToAddress(a.cfg.SenderAddress)
    - + + 313 -
    -   +
    +
    + +
    - + + 314 -
    -   -
    +
    +
    + + + to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(
    - + + 315 -
    -   -
    +
    +
    + + + proof.BatchNumber-1,
    - + + 316 -
    -   -
    +
    +
    + + + proof.BatchNumberFinal,
    - + + 317 -
    -   -
    +
    +
    + + + &inputs,
    - + + 318 -
    -   -
    +
    +
    + + + sender,
    - + + 319 -
    -   -
    +
    +
    + + + )
    - + + 320 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 321 -
    -   -
    +
    +
    + + + log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
    - + + 322 -
    -   -
    +
    +
    + + + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - + + 323 -
    -   +
    +
    + +
    - + + 324 -
    -   -
    +
    +
    + + + return false
    - + + 325 -
    -   -
    +
    +
    + + + }
    - + + 326 -
    -   +
    +
    + +
    - + + 327 -
    -   -
    +
    +
    + + + monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal)
    - + + 328 -
    -   -
    +
    +
    + + + err = a.EthTxManager.Add(
    - + + 329 -
    -   -
    +
    +
    + + + ctx,
    - + + 330 -
    -   -
    +
    +
    + + + ethTxManagerOwner,
    - + + 331 -
    -   -
    +
    +
    + + + monitoredTxID,
    - + + 332 -
    -   -
    +
    +
    + + + sender,
    - + + 333 -
    -   -
    +
    +
    + + + to,
    - + + 334 -
    -   -
    +
    +
    + + + nil,
    - + + 335 -
    -   -
    +
    +
    + + + data,
    - + + 336 -
    -   -
    +
    +
    + + + a.cfg.GasOffset,
    - + + 337 -
    -   -
    +
    +
    + + + nil,
    - + + 338 -
    -   -
    +
    +
    + + + )
    - + + 339 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 340 -
    -   -
    +
    +
    + + + mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to)
    - + + 341 -
    -   -
    +
    +
    + + + mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err)
    - + + 342 -
    -   -
    +
    +
    + + + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - + + 343 -
    -   +
    +
    + +
    - + + 344 -
    -   -
    +
    +
    + + + return false
    - + + 345 -
    -   -
    +
    +
    + + + }
    - + + 346 -
    -   +
    +
    + +
    - + + 347 -
    -   -
    +
    +
    + + + // process monitored batch verifications before starting a next cycle
    - + + 348 -
    -   -
    +
    +
    + + + a.EthTxManager.ProcessPendingMonitoredTxs(
    - + + 349 -
    -   -
    +
    +
    + + + ctx,
    - + + 350 -
    -   -
    +
    +
    + + + ethTxManagerOwner,
    - + + 351 -
    -   -
    +
    +
    + + + func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) {
    - + + 352 -
    -   -
    +
    +
    + + + a.handleMonitoredTxResult(result)
    - + + 353 -
    -   -
    +
    +
    + + + },
    - + + 354 -
    -   -
    +
    +
    + + + nil,
    - + + 355 -
    -   -
    +
    +
    + + + )
    - + + 356 -
    -   +
    +
    + +
    - + + 357 -
    -   -
    +
    +
    + + + return true
    - + + 358 -
    -   -
    +
    +
    + + + }
    - + + 359 -
    -   +
    +
    + +
    - + + 360 -
    -   -
    +
    +
    + + + func (a *Aggregator) settleWithAggLayer(
    - + + 361 -
    -   -
    +
    +
    + + + ctx context.Context,
    - 253 - + + 362 +
    -   - } + + + proof *state.Proof,
    - 254 + + 363 +
    -   - } + + + inputs ethmanTypes.FinalProofInputs,
    - + + 364 -
    -   -
    +
    +
    + + + ) (success bool) {
    - + + 365 -
    -   -
    +
    +
    + + + proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x")
    - + + 366 -
    -   -
    +
    +
    + + + proofBytes := common.Hex2Bytes(proofStrNo0x)
    - + + 367 -
    -   -
    +
    +
    + + + tx := tx.Tx{
    - + + 368 -
    -   -
    +
    +
    + + + LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1),
    - + + 369 -
    -   -
    +
    +
    + + + NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal),
    - + + 370 -
    -   -
    +
    +
    + + + ZKP: tx.ZKP{
    - + + 371 -
    -   -
    +
    +
    + + + NewStateRoot: common.BytesToHash(inputs.NewStateRoot),
    - + + 372 -
    -   -
    +
    +
    + + + NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot),
    - + + 373 -
    -   -
    +
    +
    + + + Proof: agglayerTypes.ArgBytes(proofBytes),
    - + + 374 -
    -   -
    +
    +
    + + + },
    - + + 375 -
    -   -
    +
    +
    + + + RollupID: a.Ethman.GetRollupId(),
    - + + 376 -
    -   -
    +
    +
    + + + }
    - + + 377 -
    -   -
    +
    +
    + + + signedTx, err := tx.Sign(a.sequencerPrivateKey)
    - + + 378 -
    -   +
    +
    + +
    - + + 379 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 380 -
    -   -
    +
    +
    + + + log.Errorf("failed to sign tx: %v", err)
    - + + 381 -
    -   -
    +
    +
    + + + a.handleFailureToSendToAggLayer(ctx, proof)
    - + + 382 -
    -   +
    +
    + +
    - + + 383 -
    -   -
    +
    +
    + + + return false
    - + + 384 -
    -   -
    +
    +
    + + + }
    - + + 385 -
    -   +
    +
    + +
    - + + 386 -
    -   -
    +
    +
    + + + log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex())
    - + + 387 -
    -   -
    +
    +
    + + + txHash, err := a.AggLayerClient.SendTx(*signedTx)
    - + + 388 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 389 -
    -   -
    +
    +
    + + + log.Errorf("failed to send tx to the interop: %v", err)
    - + + 390 -
    -   -
    +
    +
    + + + a.handleFailureToSendToAggLayer(ctx, proof)
    - + + 391 -
    -   +
    +
    + +
    - + + 392 -
    -   -
    +
    +
    + + + return false
    - + + 393 -
    -   -
    +
    +
    + + + }
    - + + 394 -
    -   +
    +
    + +
    - + + 395 -
    -   -
    +
    +
    + + + log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex())
    - + + 396 -
    -   -
    +
    +
    + + + log.Debugf("Timeout set to %f seconds", a.cfg.AggLayerTxTimeout.Duration.Seconds())
    - + + 397 -
    -   -
    +
    +
    + + + waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.AggLayerTxTimeout.Duration))
    - + + 398 -
    -   -
    +
    +
    + + + defer cancelFunc()
    - + + 399 -
    -   -
    +
    +
    + + + if err := a.AggLayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil {
    - + + 400 -
    -   -
    +
    +
    + + + log.Errorf("interop didn't mine the tx: %v", err)
    - + + 401 -
    -   -
    +
    +
    + + + a.handleFailureToSendToAggLayer(ctx, proof)
    - + + 402 -
    -   +
    +
    + +
    - + + 403 -
    -   -
    +
    +
    + + + return false
    - + + 404 -
    -   -
    +
    +
    + + + }
    - + + 405 -
    -   +
    +
    + +
    - + + 406 -
    -   -
    +
    +
    + + + // TODO: wait for synchronizer to catch up
    - + + 407 -
    -   -
    +
    +
    + + + return true
    - + + 408 -
    -   -
    +
    +
    + + + }
    - + + 409 -
    -   +
    +
    + +
    - + + 410 -
    -   -
    +
    +
    + + + func (a *Aggregator) handleFailureToSendToAggLayer(ctx context.Context, proof *state.Proof) {
    - + + 411 -
    -   -
    +
    +
    + + + log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
    - + + 412 -
    -   -
    +
    +
    + + + proof.GeneratingSince = nil
    - + + 413 -
    -   +
    +
    + +
    - + + 414 -
    -   -
    +
    +
    + + + err := a.State.UpdateGeneratedProof(ctx, proof, nil)
    - + + 415 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 416 -
    -   -
    +
    +
    + + + log.Errorf("Failed updating proof state (false): %v", err)
    - + + 417 -
    -   -
    +
    +
    + + + }
    - + + 418 -
    -   +
    +
    + +
    - + + 419 -
    -   -
    +
    +
    + + + a.endProofVerification()
    - + + 420 -
    -   -
    +
    +
    + + + }
    - + + 421 -
    -   +
    +
    + +
    - + + 422 -
    +
    +
      -
    + func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) {
    - + + 423 -
    +
    +
      -
    + log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
    - + + 424 -
    +
    +
      -
    + proof.GeneratingSince = nil
    - - -
    -   -
    -
    +
    +
     
    - + + 495 -
    +
    +
      -
    + }
    - + + 496 -
    +
    +
      -
    + log.Debug("Send final proof time reached")
    - + + 497 -
    +
    +
     
    - + + 498 -
    -   -
    +
    +
    + + + if err = a.waitForSynchronizerToSyncUp(ctx, nil); err != nil {
    - + + 499 -
    -   -
    +
    +
    + + + log.Warn("waiting for the synchronizer to sync up was canceled", err)
    - + + 500 -
    -   -
    +
    +
    + + + return false, err
    - + + 501 -
    +
    +
      -
    + }
    - + + 502 -
    +
    +
     
    - + + 503 -
    +
    +
      -
    + var lastVerifiedBatchNum uint64
    - + +
     
    -
    +
    + 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) {
    - + +
     
    -
    +
    + 1301 + +
     
    - + + 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 -
    +
    +
      -
    + // network is synced with the final proof, we can safely delete all recursive
    - + +
     
    -
    +
    + 1314 + +
      -
    + }
    - + + 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 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - @@ -9384,454 +7971,433 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - + +
    +
    @@ -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)
    - + +
    @@ -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)
    - + +
    @@ -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 -
    +
    +
      -
    + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - @@ -9845,781 +8411,810 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 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)
    - - -
    -   -
    -
    +
    +
     
    - + + 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)
    - - -
    -   -
    -
    +
    +
     
    - + + 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 -
    -   -
    +
    +
    + + + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/config.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
    @@ -8,6 +8,17 @@
    - + + 8 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/encoding"
    - + + 9 -
    +
    +
      -
    + )
    - + + 10 -
    +
    +
     
    @@ -10735,61 +9330,66 @@

    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 -
    +
    +
     
    @@ -10915,353 +9515,436 @@

    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 -
    -   -
    +
    +
    + + + // 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 + +
    + +
    - 255 + 115
      - } + // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch
    - 256 + 116
      -
    + BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"`
    - 257 + 117
      - // canVerifyProof returns true if we have reached the timeout to verify a proof + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go + RENAMED + +
    +
    +
    +
    + + + - - - - - + +
    -
    @@ -285,41 +1073,41 @@
    +
    @@ -38,6 +38,7 @@
    - 285 + 38
    @@ -11271,167 +9954,190 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 286 + 39
      - // isSynced checks if the state is synchronized with L1. If a batch number is + // etherman contains the methods required to interact with ethereum
    - 287 + 40
      - // provided, it makes sure that the state is synced with that batch. + type etherman interface {
    - 288 + + -
    - - - func (a *Aggregator) isSynced(ctx context.Context, batchNum *uint64) bool { +
    +
    +   +
    - 289 + 41
      - // get latest verified batch as seen by the synchronizer + GetLatestVerifiedBatchNum() (uint64, error)
    - 290 + 42
      - lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) + BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
    - 291 + 43
      - if err == state.ErrNotFound { + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - 292 - -
    - - - return false +
    +
    +
    +
    + + + + + - - - - - + +
    +
     
    - 293 + 38
      - } +
    - 294 + 39
      - if err != nil { + // etherman contains the methods required to interact with ethereum
    - 295 + 40
      - log.Warnf("Failed to get last consolidated batch: %v", err) + type etherman interface {
    - 296 + + 41 +
    - - - return false + + + GetRollupId() uint32
    - 297 + 42
      - } + GetLatestVerifiedBatchNum() (uint64, error)
    - 298 + 43
      -
    + BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
    - 299 + 44
      - if lastVerifiedBatch == nil { + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - 300 - -
    - - - return false +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/approve.go + RENAMED + +
    +
    +
    +
    + + + + + - - - + + +
    +
    @@ -51,14 +51,14 @@
    - 301 + 51
      - } + setupLog(c.Log)
    - 302 + 52
    @@ -11441,217 +10147,221 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 303 - -
    -   - if batchNum != nil && lastVerifiedBatch.BatchNumber < *batchNum { -
    -
    - 304 + 53
      - log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, waiting for batch: %d", lastVerifiedBatch.BatchNumber, batchNum) + // Check if it is already registered
    - 305 + 54
    - - return false + etherman, err := newEtherman(*c)
    - 306 + 55
      - } + if err != nil {
    - 307 + 56
      -
    + log.Fatal(err)
    - 308 + 57
      - // latest verified batch in L1 + return err
    - 309 + 58
      - lastVerifiedEthBatchNum, err := a.Ethman.GetLatestVerifiedBatchNum() + }
    - 310 + 59
      - if err != nil { +
    - 311 + 60
      - log.Warnf("Failed to get last eth batch, err: %v", err) + // load auth from keystore file
    - 312 + 61
    - - return false + auth, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword)
    - 313 + 62
      - } + if err != nil {
    - 314 + 63
      -
    + log.Fatal(err)
    - 315 + 64
      - // check if L2 is synced with L1 + return err +
    +
    +
    +
    +
    + + + + + - - - - - - + + + +
    +
     
    - 316 + 51
      - if lastVerifiedBatch.BatchNumber < lastVerifiedEthBatchNum { + setupLog(c.Log)
    - 317 + 52
      - log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, lastVerifiedEthBatchNum: %d, waiting for batch", +
    - 318 + 53
      - lastVerifiedBatch.BatchNumber, lastVerifiedEthBatchNum) + // Check if it is already registered
    - 319 + + 54 +
    - - - return false + + + etherman, err := newEtherman(*c, nil)
    - 320 + 55
      - } + if err != nil {
    - 321 + 56
      -
    + log.Fatal(err)
    - 322 + + 57 +
    - - - return true +   + return err
    - 323 + 58
      - } + }
    - 324 + 59
    @@ -11661,257 +10371,480 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 325 + 60
      - func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*prover.InputProver, error) { + // load auth from keystore file
    -
    @@ -383,10 +1171,10 @@
    +
    + 61 + +
    + + + auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    - 383 + 62
      - } + if err != nil {
    - 384 + 63
      - if l1InfoRoot != nil && *l1InfoRoot != calculatedL1InfoRoot { + log.Fatal(err)
    - 385 + 64
      - for i, l := range aLeaves { + return err
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + +
    +
    @@ -47,7 +47,7 @@
    +
    - 386 + + 47 +
    - - - log.Infof("AllLeaves[%d]: %s", i, common.Bytes2Hex(l[:])) +   + networkFlag = cli.StringFlag{
    - 387 + 48
      - } + Name: config.FlagNetwork,
    - 388 + 49
      - for i, s := range smtProof { + Aliases: []string{"net"},
    - 389 + 50
    - - log.Infof("smtProof[%d]: %s", i, common.Bytes2Hex(s[:])) + Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `cardona`, `custom`]",
    - 390 + 51
      - } + Required: true,
    - 391 + 52
      - return nil, fmt.Errorf("error: l1InfoRoot mismatch. L1InfoRoot: %s, calculatedL1InfoRoot: %s. l1InfoTreeIndex: %d", l1InfoRoot.String(), calculatedL1InfoRoot.String(), l2blockRaw.IndexL1InfoTree) + }
    - 392 + 53
      - } + customNetworkFlag = cli.StringFlag{
    -
    @@ -513,19 +1301,37 @@
    +
    @@ -186,6 +186,13 @@
    +
    + 186 + +
    +   + Action: restore, +
    +
    + 187 + +
    +   + Flags: restoreFlags, +
    - 513 + 188
    +   + }, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
     
    - 514 + 189
      - // wait for the synchronizer to catch up the verified batches + }
    - 515 + 190
      - log.Debug("A final proof has been sent, waiting for the network to be synced") +
    - 516 + + 191 +
    - - - for !a.isSynced(a.ctx, &proofBatchNumberFinal) { +   + err := app.Run(os.Args)
    +
    +
    +
    +
    + + + + + - - - - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    - 517 + + 47 +
    - - - log.Info("Waiting for synchronizer to sync...") +   + networkFlag = cli.StringFlag{
    - 518 + + 48 +
    - - - time.Sleep(a.cfg.RetryTime.Duration) +   + Name: config.FlagNetwork,
    - 519 + 49
      - } + Aliases: []string{"net"}, +
    +
    + 50 + +
    + + + Usage: "Load default network configuration. Supported values: [`custom`]",
    - 520 + 51
      -
    + Required: true,
    - 521 + 52
      - // network is synced with the final proof, we can safely delete all recursive + }
    - 522 + 53
      - // proofs up to the last synced batch + customNetworkFlag = cli.StringFlag{
    - 523 + +
     
    +
    + 186 +
    - - - err = a.State.CleanupBatchProofs(a.ctx, proofBatchNumberFinal, nil) +   + Action: restore,
    - 524 + 187
      - if err != nil { + Flags: restoreFlags,
    - 525 + 188
      - log.Errorf("Failed to store proof aggregation result: %v", err) + }, +
    +
    + 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 + +
    + + + },
    - 526 + 196
    @@ -11921,24 +10854,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 527 + 197
      - } +
    - 528 + 198
      -
    + err := app.Run(os.Args)
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/policy.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -0,0 +1,308 @@
    +
    @@ -12120,727 +11082,703 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 529 + + -
    +
    +
      - func buildMonitoredTxID(batchNumber, batchNumberFinal uint64) string { +
    - 530 + + -
    +
    +
      - return fmt.Sprintf(monitoredIDFormat, batchNumber, batchNumberFinal) +
    - 531 + + -
    +
    +
      - } +
    -
    @@ -536,7 +1342,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 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -12854,63 +11792,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - @@ -12924,228708 +11862,623 @@

    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 + + -
    +
    +
      - } +
    -
     
    +
    + + +
    +   +
    +
    - 227 + + -
    +
    +
      - _, err = a.tryBuildFinalProof(ctx, prover, nil) +
    - 228 + + -
    +
    +
      - if err != nil { +
    - 229 + + -
    +
    +
      - log.Errorf("Error checking proofs to verify: %v", err) +
    - 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 + + -
    +
    +
      - } +
    - 236 + + -
    +
    +
     
    - 237 + + -
    - + - proofGenerated, err := a.tryAggregateProofs(ctx, prover) +
    +
    +   +
    - 238 + + -
    +
    +
      - if err != nil { +
    - 239 + + -
    - + - log.Errorf("Error trying to aggregate proofs: %v", err) +
    +
    +   +
    - 240 + + -
    +
    +
      - } +
    - 241 + + -
    +
    +
      - if !proofGenerated { +
    - 242 + + -
    - + - proofGenerated, err = a.tryGenerateBatchProof(ctx, prover) +
    +
    +   +
    - 243 + + -
    +
    +
      - if err != nil { +
    - 244 + + -
    - + - log.Errorf("Error trying to generate proof: %v", err) +
    +
    +   +
    - 245 + + -
    +
    +
      - } +
    - 246 + + -
    +
    +
      - } +
    - 247 + + -
    +
    +
      - if !proofGenerated { +
    - 248 + + -
    - + - // if no proof was generated (aggregated or batch) wait some time before retry +
    +
    +   +
    - 249 + + -
    - + - time.Sleep(a.cfg.RetryTime.Duration) +
    +
    +   +
    - 250 + + -
    - + - } // if proof was generated we retry immediately as probably we have more proofs to process +
    +
    +   +
    - 251 + + -
    - + - } +
    +
    +   +
    - 252 + + -
    - + - } +
    +
    +   +
    - 253 + + -
    - + - } +
    +
    +   +
    - 254 + + -
    - + +
    +
    +  
    - 255 + + -
    - + - // This function waits to receive a final proof from a prover. Once it receives +
    +
    +   +
    - 256 + + -
    - + - // the proof, it performs these steps in order: +
    +
    +   +
    - 257 + + -
    - + - // - send the final proof to L1 +
    +
    +   +
    - 258 + + -
    - + - // - wait for the synchronizer to catch up +
    +
    +   +
    - 259 + + -
    - + - // - clean up the cache of recursive proofs +
    +
    +   +
    - 260 + + -
    - + - func (a *Aggregator) sendFinalProof() { +
    +
    +   +
    - 261 + + -
    - + - for { +
    +
    +   +
    - 262 + + -
    - + - select { +
    +
    +   +
    - 263 + + -
    - + - case <-a.ctx.Done(): +
    +
    +   +
    - 264 + + -
    - + - return +
    +
    +   +
    - 265 + + -
    - + - case msg := <-a.finalProof: +
    +
    +   +
    - 266 + + -
    - + - ctx := a.ctx +
    +
    +   +
    - 267 + + -
    - + - proof := msg.recursiveProof +
    +
    +   +
    - 268 + + -
    - + +
    +
    +  
    - 269 + + -
    - + - log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    +
    +   +
    - 270 + + -
    - + - log.Info("Verifying final proof with ethereum smart contract") +
    +
    +   +
    - 271 + + -
    - + +
    +
    +  
    - 272 + + -
    - + - a.startProofVerification() +
    +
    +   +
    - 273 + + -
    - + +
    +
    +  
    - 274 + + -
    - + - finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil) +
    +
    +   +
    - 275 + + -
    - + - if err != nil { +
    +
    +   +
    - 276 + + -
    - + - log.Errorf("Failed to retrieve batch with number [%d]: %v", proof.BatchNumberFinal, err) +
    +
    +   +
    - 277 + + -
    - + - a.endProofVerification() +
    +
    +   +
    - 278 + + -
    - + - continue +
    +
    +   +
    - 279 + + -
    +
    +
      - } +
    - 280 + + -
    +
    +
     
    - 281 + + -
    - + - inputs := ethmanTypes.FinalProofInputs{ +
    +
    +   +
    - 282 + + -
    - + - FinalProof: msg.finalProof, +
    +
    +   +
    - 283 + + -
    - + - NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(), +
    +
    +   +
    - 284 + + -
    - + - NewStateRoot: finalBatch.StateRoot.Bytes(), +
    +
    +   +
    - 285 + + -
    - + - } +
    +
    +   +
    - 286 + + -
    - + +
    +
    +  
    - 287 + + -
    - + - log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot) +
    +
    +   +
    - 288 + + -
    - + +
    +
    +  
    - 289 + + -
    - + - switch a.cfg.SettlementBackend { +
    +
    +   +
    - 290 + + -
    - + - case AggLayer: +
    +
    +   +
    - 291 + + -
    - + - if success := a.settleWithAggLayer(ctx, proof, inputs); !success { +
    +
    +   +
    - 292 + + -
    - + - continue +
    +
    +   +
    - 293 + + -
    - + - } +
    +
    +   +
    - 294 + + -
    - + - default: +
    +
    +   +
    - 295 + + -
    - + - if success := a.settleDirect(ctx, proof, inputs); !success { +
    +
    +   +
    - 296 + + -
    - + - continue +
    +
    +   +
    - 297 + + -
    +
    +
      - } +
    - 298 + + -
    +
    +
      - } +
    - 299 + + -
    +
    +
     
    - 300 + + -
    - + - a.resetVerifyProofTime() +
    +
    +   +
    - 301 + + -
    - + - a.endProofVerification() +
    +
    +   +
    - 302 + + -
    - + - } +
    +
    +   +
    - 303 + + -
    - + - } +
    +
    +   +
    - 304 + + -
    - + - } +
    +
    +   +
    - 305 + + -
    - + +
    +
    +  
    - 306 + + -
    - + - func (a *Aggregator) settleDirect( +
    +
    +   +
    - 307 + + -
    - + - ctx context.Context, +
    +
    +   +
    - 308 + + -
    - + - proof *state.Proof, -
    -
    - 309 - -
    - + - inputs ethmanTypes.FinalProofInputs, -
    -
    - 310 - -
    - + - ) (success bool) { -
    -
    - 311 - -
    - + - // add batch verification to be monitored -
    -
    - 312 - -
    - + - sender := common.HexToAddress(a.cfg.SenderAddress) -
    -
    - 313 - -
    - + -
    -
    -
    - 314 - -
    - + - to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData( -
    -
    - 315 - -
    - + - proof.BatchNumber-1, -
    -
    - 316 - -
    - + - proof.BatchNumberFinal, -
    -
    - 317 - -
    - + - &inputs, -
    -
    - 318 - -
    - + - sender, -
    -
    - 319 - -
    - + - ) -
    -
    - 320 - -
    - + - if err != nil { -
    -
    - 321 - -
    - + - log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err) -
    -
    - 322 - -
    - + - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) -
    -
    - 323 - -
    - + -
    -
    -
    - 324 - -
    - + - return false -
    -
    - 325 - -
    - + - } -
    -
    - 326 - -
    - + -
    -
    -
    - 327 - -
    - + - monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal) -
    -
    - 328 - -
    - + - err = a.EthTxManager.Add( -
    -
    - 329 - -
    - + - ctx, -
    -
    - 330 - -
    - + - ethTxManagerOwner, -
    -
    - 331 - -
    - + - monitoredTxID, -
    -
    - 332 - -
    - + - sender, -
    -
    - 333 - -
    - + - to, -
    -
    - 334 - -
    - + - nil, -
    -
    - 335 - -
    - + - data, -
    -
    - 336 - -
    - + - a.cfg.GasOffset, -
    -
    - 337 - -
    - + - nil, -
    -
    - 338 - -
    - + - ) -
    -
    - 339 - -
    - + - if err != nil { -
    -
    - 340 - -
    - + - mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to) -
    -
    - 341 - -
    - + - mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err) -
    -
    - 342 - -
    - + - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) -
    -
    - 343 - -
    - + -
    -
    -
    - 344 - -
    - + - return false -
    -
    - 345 - -
    - + - } -
    -
    - 346 - -
    - + -
    -
    -
    - 347 - -
    - + - // process monitored batch verifications before starting a next cycle -
    -
    - 348 - -
    - + - a.EthTxManager.ProcessPendingMonitoredTxs( -
    -
    - 349 - -
    - + - ctx, -
    -
    - 350 - -
    - + - ethTxManagerOwner, -
    -
    - 351 - -
    - + - func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { -
    -
    - 352 - -
    - + - a.handleMonitoredTxResult(result) -
    -
    - 353 - -
    - + - }, -
    -
    - 354 - -
    - + - nil, -
    -
    - 355 - -
    - + - ) -
    -
    - 356 - -
    - + -
    -
    -
    - 357 - -
    - + - return true -
    -
    - 358 - -
    - + - } -
    -
    - 359 - -
    - + -
    -
    -
    - 360 - -
    - + - func (a *Aggregator) settleWithAggLayer( -
    -
    - 361 - -
    - + - ctx context.Context, -
    -
    - 362 - -
    - + - proof *state.Proof, -
    -
    - 363 - -
    - + - inputs ethmanTypes.FinalProofInputs, -
    -
    - 364 - -
    - + - ) (success bool) { -
    -
    - 365 - -
    - + - proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x") -
    -
    - 366 - -
    - + - proofBytes := common.Hex2Bytes(proofStrNo0x) -
    -
    - 367 - -
    - + - tx := tx.Tx{ -
    -
    - 368 - -
    - + - LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1), -
    -
    - 369 - -
    - + - NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal), -
    -
    - 370 - -
    - + - ZKP: tx.ZKP{ -
    -
    - 371 - -
    - + - NewStateRoot: common.BytesToHash(inputs.NewStateRoot), -
    -
    - 372 - -
    - + - NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot), -
    -
    - 373 - -
    - + - Proof: agglayerTypes.ArgBytes(proofBytes), -
    -
    - 374 - -
    - + - }, -
    -
    - 375 - -
    - + - RollupID: a.Ethman.GetRollupId(), -
    -
    - 376 - -
    - + - } -
    -
    - 377 - -
    - + - signedTx, err := tx.Sign(a.sequencerPrivateKey) -
    -
    - 378 - -
    - + -
    -
    -
    - 379 - -
    - + - if err != nil { -
    -
    - 380 - -
    - + - log.Errorf("failed to sign tx: %v", err) -
    -
    - 381 - -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) -
    -
    - 382 - -
    - + -
    -
    -
    - 383 - -
    - + - return false -
    -
    - 384 - -
    - + - } -
    -
    - 385 - -
    - + -
    -
    -
    - 386 - -
    - + - log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex()) -
    -
    - 387 - -
    - + - txHash, err := a.AggLayerClient.SendTx(*signedTx) -
    -
    - 388 - -
    - + - if err != nil { -
    -
    - 389 - -
    - + - log.Errorf("failed to send tx to the interop: %v", err) -
    -
    - 390 - -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) -
    -
    - 391 - -
    - + -
    -
    -
    - 392 - -
    - + - return false -
    -
    - 393 - -
    - + - } -
    -
    - 394 - -
    - + -
    -
    -
    - 395 - -
    - + - log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex()) -
    -
    - 396 - -
    - + - log.Debugf("Timeout set to %f seconds", a.cfg.AggLayerTxTimeout.Duration.Seconds()) -
    -
    - 397 - -
    - + - waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.AggLayerTxTimeout.Duration)) -
    -
    - 398 - -
    - + - defer cancelFunc() -
    -
    - 399 - -
    - + - if err := a.AggLayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil { -
    -
    - 400 - -
    - + - log.Errorf("interop didn't mine the tx: %v", err) -
    -
    - 401 - -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) -
    -
    - 402 - -
    - + -
    -
    -
    - 403 - -
    - + - return false -
    -
    - 404 - -
    - + - } -
    -
    - 405 - -
    - + -
    -
    -
    - 406 - -
    - + - // TODO: wait for synchronizer to catch up -
    -
    - 407 - -
    - + - return true -
    -
    - 408 - -
    - + - } -
    -
    - 409 - -
    - + -
    -
    -
    - 410 - -
    - + - func (a *Aggregator) handleFailureToSendToAggLayer(ctx context.Context, proof *state.Proof) { -
    -
    - 411 - -
    - + - log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) -
    -
    - 412 - -
    - + - proof.GeneratingSince = nil -
    -
    - 413 - -
    - + -
    -
    -
    - 414 - -
    - + - err := a.State.UpdateGeneratedProof(ctx, proof, nil) -
    -
    - 415 - -
    - + - if err != nil { -
    -
    - 416 - -
    - + - log.Errorf("Failed updating proof state (false): %v", err) -
    -
    - 417 - -
    - + - } -
    -
    - 418 - -
    - + -
    -
    -
    - 419 - -
    - + - a.endProofVerification() -
    -
    - 420 - -
    - + - } -
    -
    - 421 - -
    - + -
    -
    -
    - 422 - -
    - + - func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) { -
    -
    - 423 - -
    - + - log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) -
    -
    - 424 - -
    - + - proof.GeneratingSince = nil -
    -
    - 425 - -
    - + - err := a.State.UpdateGeneratedProof(ctx, proof, nil) -
    -
    - 426 - -
    - + - if err != nil { -
    -
    - 427 - -
    - + - log.Errorf("Failed updating proof state (false): %v", err) -
    -
    - 428 - -
    - + - } -
    -
    - 429 - -
    - + - a.endProofVerification() -
    -
    - 430 - -
    - + - } -
    -
    - 431 - -
    - + -
    -
    -
    - 432 - -
    - + - // buildFinalProof builds and return the final proof for an aggregated/batch proof. -
    -
    - 433 - -
    - + - func (a *Aggregator) buildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (*prover.FinalProof, error) { -
    -
    - 434 - -
    - + - log := log.WithFields( -
    -
    - 435 - -
    - + - "prover", prover.Name(), -
    -
    - 436 - -
    - + - "proverId", prover.ID(), -
    -
    - 437 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 438 - -
    - + - "recursiveProofId", *proof.ProofID, -
    -
    - 439 - -
    - + - "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal), -
    -
    - 440 - -
    - + - ) -
    -
    - 441 - -
    - + - log.Info("Generating final proof") -
    -
    - 442 - -
    - + -
    -
    -
    - 443 - -
    - + - finalProofID, err := prover.FinalProof(proof.Proof, a.cfg.SenderAddress) -
    -
    - 444 - -
    - + - if err != nil { -
    -
    - 445 - -
    - + - return nil, fmt.Errorf("failed to get final proof id: %w", err) -
    -
    - 446 - -
    - + - } -
    -
    - 447 - -
    - + - proof.ProofID = finalProofID -
    -
    - 448 - -
    - + -
    -
    -
    - 449 - -
    - + - log.Infof("Final proof ID for batches [%d-%d]: %s", proof.BatchNumber, proof.BatchNumberFinal, *proof.ProofID) -
    -
    - 450 - -
    - + - log = log.WithFields("finalProofId", finalProofID) -
    -
    - 451 - -
    - + -
    -
    -
    - 452 - -
    - + - finalProof, err := prover.WaitFinalProof(ctx, *proof.ProofID) -
    -
    - 453 - -
    - + - if err != nil { -
    -
    - 454 - -
    - + - return nil, fmt.Errorf("failed to get final proof from prover: %w", err) -
    -
    - 455 - -
    - + - } -
    -
    - 456 - -
    - + -
    -
    -
    - 457 - -
    - + - log.Info("Final proof generated") -
    -
    - 458 - -
    - + -
    -
    -
    - 459 - -
    - + - // mock prover sanity check -
    -
    - 460 - -
    - + - if string(finalProof.Public.NewStateRoot) == mockedStateRoot && string(finalProof.Public.NewLocalExitRoot) == mockedLocalExitRoot { -
    -
    - 461 - -
    - + - // This local exit root and state root come from the mock -
    -
    - 462 - -
    - + - // prover, use the one captured by the executor instead -
    -
    - 463 - -
    - + - finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil) -
    -
    - 464 - -
    - + - if err != nil { -
    -
    - 465 - -
    - + - return nil, fmt.Errorf("failed to retrieve batch with number [%d]", proof.BatchNumberFinal) -
    -
    - 466 - -
    - + - } -
    -
    - 467 - -
    - + - log.Warnf("NewLocalExitRoot and NewStateRoot look like a mock values, using values from executor instead: LER: %v, SR: %v", -
    -
    - 468 - -
    - + - finalBatch.LocalExitRoot.TerminalString(), finalBatch.StateRoot.TerminalString()) -
    -
    - 469 - -
    - + - finalProof.Public.NewStateRoot = finalBatch.StateRoot.Bytes() -
    -
    - 470 - -
    - + - finalProof.Public.NewLocalExitRoot = finalBatch.LocalExitRoot.Bytes() -
    -
    - 471 - -
    - + - } -
    -
    - 472 - -
    - + -
    -
    -
    - 473 - -
    - + - return finalProof, nil -
    -
    - 474 - -
    - + - } -
    -
    - 475 - -
    - + -
    -
    -
    - 476 - -
    - + - // tryBuildFinalProof checks if the provided proof is eligible to be used to -
    -
    - 477 - -
    - + - // build the final proof. If no proof is provided it looks for a previously -
    -
    - 478 - -
    - + - // generated proof. If the proof is eligible, then the final proof generation -
    -
    - 479 - -
    - + - // is triggered. -
    -
    - 480 - -
    - + - func (a *Aggregator) tryBuildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (bool, error) { -
    -
    - 481 - -
    - + - proverName := prover.Name() -
    -
    - 482 - -
    - + - proverID := prover.ID() -
    -
    - 483 - -
    - + -
    -
    -
    - 484 - -
    - + - log := log.WithFields( -
    -
    - 485 - -
    - + - "prover", proverName, -
    -
    - 486 - -
    - + - "proverId", proverID, -
    -
    - 487 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 488 - -
    - + - ) -
    -
    - 489 - -
    - + - log.Debug("tryBuildFinalProof start") -
    -
    - 490 - -
    - + -
    -
    -
    - 491 - -
    - + - var err error -
    -
    - 492 - -
    - + - if !a.canVerifyProof() { -
    -
    - 493 - -
    - + - log.Debug("Time to verify proof not reached or proof verification in progress") -
    -
    - 494 - -
    - + - return false, nil -
    -
    - 495 - -
    - + - } -
    -
    - 496 - -
    - + - log.Debug("Send final proof time reached") -
    -
    - 497 - -
    - + -
    -
    -
    - 498 - -
    - + - if err = a.waitForSynchronizerToSyncUp(ctx, nil); err != nil { -
    -
    - 499 - -
    - + - log.Warn("waiting for the synchronizer to sync up was canceled", err) -
    -
    - 500 - -
    - + - return false, err -
    -
    - 501 - -
    - + - } -
    -
    - 502 - -
    - + -
    -
    -
    - 503 - -
    - + - var lastVerifiedBatchNum uint64 -
    -
    - 504 - -
    - + - lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) -
    -
    - 505 - -
    - + - if err != nil && !errors.Is(err, state.ErrNotFound) { -
    -
    - 506 - -
    - + - return false, fmt.Errorf("failed to get last verified batch, %w", err) -
    -
    - 507 - -
    - + - } -
    -
    - 508 - -
    - + - if lastVerifiedBatch != nil { -
    -
    - 509 - -
    - + - lastVerifiedBatchNum = lastVerifiedBatch.BatchNumber -
    -
    - 510 - -
    - + - } -
    -
    - 511 - -
    - + -
    -
    -
    - 512 - -
    - + - if proof == nil { -
    -
    - 513 - -
    - + - // we don't have a proof generating at the moment, check if we -
    -
    - 514 - -
    - + - // have a proof ready to verify -
    -
    - 515 - -
    - + -
    -
    -
    - 516 - -
    - + - proof, err = a.getAndLockProofReadyToVerify(ctx, prover, lastVerifiedBatchNum) -
    -
    - 517 - -
    - + - if errors.Is(err, state.ErrNotFound) { -
    -
    - 518 - -
    - + - // nothing to verify, swallow the error -
    -
    - 519 - -
    - + - log.Debug("No proof ready to verify") -
    -
    - 520 - -
    - + - return false, nil -
    -
    - 521 - -
    - + - } -
    -
    - 522 - -
    - + - if err != nil { -
    -
    - 523 - -
    - + - return false, err -
    -
    - 524 - -
    - + - } -
    -
    - 525 - -
    - + -
    -
    -
    - 526 - -
    - + - defer func() { -
    -
    - 527 - -
    - + - if err != nil { -
    -
    - 528 - -
    - + - // Set the generating state to false for the proof ("unlock" it) -
    -
    - 529 - -
    - + - proof.GeneratingSince = nil -
    -
    - 530 - -
    - + - err2 := a.State.UpdateGeneratedProof(a.ctx, proof, nil) -
    -
    - 531 - -
    - + - if err2 != nil { -
    -
    - 532 - -
    - + - log.Errorf("Failed to unlock proof: %v", err2) -
    -
    - 533 - -
    -   - } -
    -
    - 534 - -
    -   - } -
    -
    - 535 - -
    - + - }() -
    -
    - 536 - -
    - + - } else { -
    -
    - 537 - -
    - + - // we do have a proof generating at the moment, check if it is -
    -
    - 538 - -
    - + - // eligible to be verified -
    -
    - 539 - -
    - + - eligible, err := a.validateEligibleFinalProof(ctx, proof, lastVerifiedBatchNum) -
    -
    - 540 - -
    - + - if err != nil { -
    -
    - 541 - -
    - + - return false, fmt.Errorf("failed to validate eligible final proof, %w", err) -
    -
    - 542 - -
    - + - } -
    -
    - 543 - -
    - + - if !eligible { -
    -
    - 544 - -
    - + - return false, nil -
    -
    - 545 - -
    - + - } -
    -
    - 546 - -
    - + - } -
    -
    - 547 - -
    - + -
    -
    -
    - 548 - -
    - + - log = log.WithFields( -
    -
    - 549 - -
    - + - "proofId", *proof.ProofID, -
    -
    - 550 - -
    - + - "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal), -
    -
    - 551 - -
    - + - ) -
    -
    - 552 - -
    - + -
    -
    -
    - 553 - -
    - + - // at this point we have an eligible proof, build the final one using it -
    -
    - 554 - -
    - + - finalProof, err := a.buildFinalProof(ctx, prover, proof) -
    -
    - 555 - -
    - + - if err != nil { -
    -
    - 556 - -
    - + - err = fmt.Errorf("failed to build final proof, %w", err) -
    -
    - 557 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 558 - -
    - + - return false, err -
    -
    - 559 - -
    - + - } -
    -
    - 560 - -
    - + -
    -
    -
    - 561 - -
    - + - msg := finalProofMsg{ -
    -
    - 562 - -
    - + - proverName: proverName, -
    -
    - 563 - -
    - + - proverID: proverID, -
    -
    - 564 - -
    - + - recursiveProof: proof, -
    -
    - 565 - -
    - + - finalProof: finalProof, -
    -
    - 566 - -
    - + - } -
    -
    - 567 - -
    - + -
    -
    -
    - 568 - -
    - + - select { -
    -
    - 569 - -
    - + - case <-a.ctx.Done(): -
    -
    - 570 - -
    - + - return false, a.ctx.Err() -
    -
    - 571 - -
    - + - case a.finalProof <- msg: -
    -
    - 572 - -
    - + - } -
    -
    - 573 - -
    - + -
    -
    -
    - 574 - -
    - + - log.Debug("tryBuildFinalProof end") -
    -
    - 575 - -
    - + - return true, nil -
    -
    - 576 - -
    - + - } -
    -
    - 577 - -
    - + -
    -
    -
    - 578 - -
    - + - func (a *Aggregator) validateEligibleFinalProof(ctx context.Context, proof *state.Proof, lastVerifiedBatchNum uint64) (bool, error) { -
    -
    - 579 - -
    - + - batchNumberToVerify := lastVerifiedBatchNum + 1 -
    -
    - 580 - -
    - + -
    -
    -
    - 581 - -
    - + - if proof.BatchNumber != batchNumberToVerify { -
    -
    - 582 - -
    - + - if proof.BatchNumber < batchNumberToVerify && proof.BatchNumberFinal >= batchNumberToVerify { -
    -
    - 583 - -
    - + - // We have a proof that contains some batches below the last batch verified, anyway can be eligible as final proof -
    -
    - 584 - -
    - + - 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) -
    -
    - 585 - -
    - + - } else if proof.BatchNumberFinal < batchNumberToVerify { -
    -
    - 586 - -
    - + - // We have a proof that contains batches below that the last batch verified, we need to delete this proof -
    -
    - 587 - -
    - + - log.Warnf("Proof %d-%d lower than next batch to verify %d. Deleting it", proof.BatchNumber, proof.BatchNumberFinal, batchNumberToVerify) -
    -
    - 588 - -
    - + - err := a.State.DeleteGeneratedProofs(ctx, proof.BatchNumber, proof.BatchNumberFinal, nil) -
    -
    - 589 - -
    - + - if err != nil { -
    -
    - 590 - -
    - + - return false, fmt.Errorf("failed to delete discarded proof, err: %w", err) -
    -
    - 591 - -
    - + - } -
    -
    - 592 - -
    - + - return false, nil -
    -
    - 593 - -
    - + - } else { -
    -
    - 594 - -
    - + - log.Debugf("Proof batch number %d is not the following to last verfied batch number %d", proof.BatchNumber, lastVerifiedBatchNum) -
    -
    - 595 - -
    - + - return false, nil -
    -
    - 596 - -
    -   - } -
    -
    - 597 - -
    -   - } -
    -
    - 598 - -
    - + -
    -
    -
    - 599 - -
    - + - bComplete, err := a.State.CheckProofContainsCompleteSequences(ctx, proof, nil) -
    -
    - 600 - -
    - + - if err != nil { -
    -
    - 601 - -
    - + - return false, fmt.Errorf("failed to check if proof contains complete sequences, %w", err) -
    -
    - 602 - -
    - + - } -
    -
    - 603 - -
    - + - if !bComplete { -
    -
    - 604 - -
    - + - log.Infof("Recursive proof %d-%d not eligible to be verified: not containing complete sequences", proof.BatchNumber, proof.BatchNumberFinal) -
    -
    - 605 - -
    - + - return false, nil -
    -
    - 606 - -
    - + - } -
    -
    - 607 - -
    - + - return true, nil -
    -
    - 608 - -
    - + - } -
    -
    - 609 - -
    - + -
    -
    -
    - 610 - -
    - + - func (a *Aggregator) getAndLockProofReadyToVerify(ctx context.Context, prover proverInterface, lastVerifiedBatchNum uint64) (*state.Proof, error) { -
    -
    - 611 - -
    - + - a.StateDBMutex.Lock() -
    -
    - 612 - -
    - + - defer a.StateDBMutex.Unlock() -
    -
    - 613 - -
    - + -
    -
    -
    - 614 - -
    - + - // Get proof ready to be verified -
    -
    - 615 - -
    - + - proofToVerify, err := a.State.GetProofReadyToVerify(ctx, lastVerifiedBatchNum, nil) -
    -
    - 616 - -
    - + - if err != nil { -
    -
    - 617 - -
    - + - return nil, err -
    -
    - 618 - -
    - + - } -
    -
    - 619 - -
    - + -
    -
    -
    - 620 - -
    - + - now := time.Now().Round(time.Microsecond) -
    -
    - 621 - -
    - + - proofToVerify.GeneratingSince = &now -
    -
    - 622 - -
    - + -
    -
    -
    - 623 - -
    - + - err = a.State.UpdateGeneratedProof(ctx, proofToVerify, nil) -
    -
    - 624 - -
    - + - if err != nil { -
    -
    - 625 - -
    - + - return nil, err -
    -
    - 626 - -
    - + - } -
    -
    - 627 - -
    - + -
    -
    -
    - 628 - -
    - + - return proofToVerify, nil -
    -
    - 629 - -
    - + - } -
    -
    - 630 - -
    - + -
    -
    -
    - 631 - -
    - + - func (a *Aggregator) unlockProofsToAggregate(ctx context.Context, proof1 *state.Proof, proof2 *state.Proof) error { -
    -
    - 632 - -
    - + - // Release proofs from generating state in a single transaction -
    -
    - 633 - -
    - + - dbTx, err := a.State.BeginStateTransaction(ctx) -
    -
    - 634 - -
    - + - if err != nil { -
    -
    - 635 - -
    - + - log.Warnf("Failed to begin transaction to release proof aggregation state, err: %v", err) -
    -
    - 636 - -
    - + - return err -
    -
    - 637 - -
    - + - } -
    -
    - 638 - -
    - + -
    -
    -
    - 639 - -
    - + - proof1.GeneratingSince = nil -
    -
    - 640 - -
    - + - err = a.State.UpdateGeneratedProof(ctx, proof1, dbTx) -
    -
    - 641 - -
    - + - if err == nil { -
    -
    - 642 - -
    - + - proof2.GeneratingSince = nil -
    -
    - 643 - -
    - + - err = a.State.UpdateGeneratedProof(ctx, proof2, dbTx) -
    -
    - 644 - -
    - + - } -
    -
    - 645 - -
    - + -
    -
    -
    - 646 - -
    - + - if err != nil { -
    -
    - 647 - -
    - + - if err := dbTx.Rollback(ctx); err != nil { -
    -
    - 648 - -
    - + - err := fmt.Errorf("failed to rollback proof aggregation state: %w", err) -
    -
    - 649 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 650 - -
    - + - return err -
    -
    - 651 - -
    - + - } -
    -
    - 652 - -
    - + - return fmt.Errorf("failed to release proof aggregation state: %w", err) -
    -
    - 653 - -
    - + - } -
    -
    - 654 - -
    - + -
    -
    -
    - 655 - -
    - + - err = dbTx.Commit(ctx) -
    -
    - 656 - -
    - + - if err != nil { -
    -
    - 657 - -
    - + - return fmt.Errorf("failed to release proof aggregation state %w", err) -
    -
    - 658 - -
    - + - } -
    -
    - 659 - -
    - + -
    -
    -
    - 660 - -
    - + - return nil -
    -
    - 661 - -
    - + - } -
    -
    - 662 - -
    - + -
    -
    -
    - 663 - -
    - + - func (a *Aggregator) getAndLockProofsToAggregate(ctx context.Context, prover proverInterface) (*state.Proof, *state.Proof, error) { -
    -
    - 664 - -
    - + - log := log.WithFields( -
    -
    - 665 - -
    - + - "prover", prover.Name(), -
    -
    - 666 - -
    - + - "proverId", prover.ID(), -
    -
    - 667 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 668 - -
    - + - ) -
    -
    - 669 - -
    - + -
    -
    -
    - 670 - -
    - + - a.StateDBMutex.Lock() -
    -
    - 671 - -
    - + - defer a.StateDBMutex.Unlock() -
    -
    - 672 - -
    - + -
    -
    -
    - 673 - -
    - + - proof1, proof2, err := a.State.GetProofsToAggregate(ctx, nil) -
    -
    - 674 - -
    - + - if err != nil { -
    -
    - 675 - -
    - + - return nil, nil, err -
    -
    - 676 - -
    - + - } -
    -
    - 677 - -
    - + -
    -
    -
    - 678 - -
    - + - // Set proofs in generating state in a single transaction -
    -
    - 679 - -
    - + - dbTx, err := a.State.BeginStateTransaction(ctx) -
    -
    - 680 - -
    - + - if err != nil { -
    -
    - 681 - -
    - + - log.Errorf("Failed to begin transaction to set proof aggregation state, err: %v", err) -
    -
    - 682 - -
    - + - return nil, nil, err -
    -
    - 683 - -
    - + - } -
    -
    - 684 - -
    - + -
    -
    -
    - 685 - -
    - + - now := time.Now().Round(time.Microsecond) -
    -
    - 686 - -
    - + - proof1.GeneratingSince = &now -
    -
    - 687 - -
    - + - err = a.State.UpdateGeneratedProof(ctx, proof1, dbTx) -
    -
    - 688 - -
    - + - if err == nil { -
    -
    - 689 - -
    - + - proof2.GeneratingSince = &now -
    -
    - 690 - -
    - + - err = a.State.UpdateGeneratedProof(ctx, proof2, dbTx) -
    -
    - 691 - -
    - + - } -
    -
    - 692 - -
    - + -
    -
    -
    - 693 - -
    - + - if err != nil { -
    -
    - 694 - -
    - + - if err := dbTx.Rollback(ctx); err != nil { -
    -
    - 695 - -
    - + - err := fmt.Errorf("failed to rollback proof aggregation state %w", err) -
    -
    - 696 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 697 - -
    - + - return nil, nil, err -
    -
    - 698 - -
    - + - } -
    -
    - 699 - -
    - + - return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err) -
    -
    - 700 - -
    - + - } -
    -
    - 701 - -
    - + -
    -
    -
    - 702 - -
    - + - err = dbTx.Commit(ctx) -
    -
    - 703 - -
    - + - if err != nil { -
    -
    - 704 - -
    - + - return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err) -
    -
    - 705 - -
    - + - } -
    -
    - 706 - -
    - + -
    -
    -
    - 707 - -
    - + - return proof1, proof2, nil -
    -
    - 708 - -
    - + - } -
    -
    - 709 - -
    - + -
    -
    -
    - 710 - -
    - + - func (a *Aggregator) tryAggregateProofs(ctx context.Context, prover proverInterface) (bool, error) { -
    -
    - 711 - -
    - + - proverName := prover.Name() -
    -
    - 712 - -
    - + - proverID := prover.ID() -
    -
    - 713 - -
    - + -
    -
    -
    - 714 - -
    - + - log := log.WithFields( -
    -
    - 715 - -
    - + - "prover", proverName, -
    -
    - 716 - -
    - + - "proverId", proverID, -
    -
    - 717 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 718 - -
    - + - ) -
    -
    - 719 - -
    - + - log.Debug("tryAggregateProofs start") -
    -
    - 720 - -
    - + -
    -
    -
    - 721 - -
    - + - proof1, proof2, err0 := a.getAndLockProofsToAggregate(ctx, prover) -
    -
    - 722 - -
    - + - if errors.Is(err0, state.ErrNotFound) { -
    -
    - 723 - -
    - + - // nothing to aggregate, swallow the error -
    -
    - 724 - -
    - + - log.Debug("Nothing to aggregate") -
    -
    - 725 - -
    - + - return false, nil -
    -
    - 726 - -
    - + - } -
    -
    - 727 - -
    - + - if err0 != nil { -
    -
    - 728 - -
    - + - return false, err0 -
    -
    - 729 - -
    - + - } -
    -
    - 730 - -
    - + -
    -
    -
    - 731 - -
    - + - var ( -
    -
    - 732 - -
    - + - aggrProofID *string -
    -
    - 733 - -
    - + - err error -
    -
    - 734 - -
    - + - ) -
    -
    - 735 - -
    - + -
    -
    -
    - 736 - -
    - + - defer func() { -
    -
    - 737 - -
    - + - if err != nil { -
    -
    - 738 - -
    - + - err2 := a.unlockProofsToAggregate(a.ctx, proof1, proof2) -
    -
    - 739 - -
    - + - if err2 != nil { -
    -
    - 740 - -
    - + - log.Errorf("Failed to release aggregated proofs, err: %v", err2) -
    -
    - 741 - -
    - + - } -
    -
    - 742 - -
    - + - } -
    -
    - 743 - -
    - + - log.Debug("tryAggregateProofs end") -
    -
    - 744 - -
    - + - }() -
    -
    - 745 - -
    - + -
    -
    -
    - 746 - -
    - + - log.Infof("Aggregating proofs: %d-%d and %d-%d", proof1.BatchNumber, proof1.BatchNumberFinal, proof2.BatchNumber, proof2.BatchNumberFinal) -
    -
    - 747 - -
    - + -
    -
    -
    - 748 - -
    - + - batches := fmt.Sprintf("%d-%d", proof1.BatchNumber, proof2.BatchNumberFinal) -
    -
    - 749 - -
    - + - log = log.WithFields("batches", batches) -
    -
    - 750 - -
    - + -
    -
    -
    - 751 - -
    - + - inputProver := map[string]interface{}{ -
    -
    - 752 - -
    - + - "recursive_proof_1": proof1.Proof, -
    -
    - 753 - -
    - + - "recursive_proof_2": proof2.Proof, -
    -
    - 754 - -
    - + - } -
    -
    - 755 - -
    - + - b, err := json.Marshal(inputProver) -
    -
    - 756 - -
    - + - if err != nil { -
    -
    - 757 - -
    - + - err = fmt.Errorf("failed to serialize input prover, %w", err) -
    -
    - 758 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 759 - -
    - + - return false, err -
    -
    - 760 - -
    - + - } -
    -
    - 761 - -
    - + -
    -
    -
    - 762 - -
    - + - proof := &state.Proof{ -
    -
    - 763 - -
    - + - BatchNumber: proof1.BatchNumber, -
    -
    - 764 - -
    - + - BatchNumberFinal: proof2.BatchNumberFinal, -
    -
    - 765 - -
    - + - Prover: &proverName, -
    -
    - 766 - -
    - + - ProverID: &proverID, -
    -
    - 767 - -
    - + - InputProver: string(b), -
    -
    - 768 - -
    - + - } -
    -
    - 769 - -
    - + -
    -
    -
    - 770 - -
    - + - aggrProofID, err = prover.AggregatedProof(proof1.Proof, proof2.Proof) -
    -
    - 771 - -
    - + - if err != nil { -
    -
    - 772 - -
    - + - err = fmt.Errorf("failed to get aggregated proof id, %w", err) -
    -
    - 773 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 774 - -
    - + - return false, err -
    -
    - 775 - -
    - + - } -
    -
    - 776 - -
    - + -
    -
    -
    - 777 - -
    - + - proof.ProofID = aggrProofID -
    -
    - 778 - -
    - + -
    -
    -
    - 779 - -
    - + - log.Infof("Proof ID for aggregated proof: %v", *proof.ProofID) -
    -
    - 780 - -
    - + - log = log.WithFields("proofId", *proof.ProofID) -
    -
    - 781 - -
    - + -
    -
    -
    - 782 - -
    - + - recursiveProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID) -
    -
    - 783 - -
    - + - if err != nil { -
    -
    - 784 - -
    - + - err = fmt.Errorf("failed to get aggregated proof from prover, %w", err) -
    -
    - 785 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 786 - -
    - + - return false, err -
    -
    - 787 - -
    - + - } -
    -
    - 788 - -
    - + -
    -
    -
    - 789 - -
    - + - log.Info("Aggregated proof generated") -
    -
    - 790 - -
    - + -
    -
    -
    - 791 - -
    - + - proof.Proof = recursiveProof -
    -
    - 792 - -
    - + -
    -
    -
    - 793 - -
    - + - // update the state by removing the 2 aggregated proofs and storing the -
    -
    - 794 - -
    - + - // newly generated recursive proof -
    -
    - 795 - -
    - + - dbTx, err := a.State.BeginStateTransaction(ctx) -
    -
    - 796 - -
    - + - if err != nil { -
    -
    - 797 - -
    - + - err = fmt.Errorf("failed to begin transaction to update proof aggregation state, %w", err) -
    -
    - 798 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 799 - -
    - + - return false, err -
    -
    - 800 - -
    - + - } -
    -
    - 801 - -
    - + -
    -
    -
    - 802 - -
    - + - err = a.State.DeleteGeneratedProofs(ctx, proof1.BatchNumber, proof2.BatchNumberFinal, dbTx) -
    -
    - 803 - -
    - + - if err != nil { -
    -
    - 804 - -
    - + - if err := dbTx.Rollback(ctx); err != nil { -
    -
    - 805 - -
    - + - err := fmt.Errorf("failed to rollback proof aggregation state, %w", err) -
    -
    - 806 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 807 - -
    - + - return false, err -
    -
    - 808 - -
    - + - } -
    -
    - 809 - -
    - + - err = fmt.Errorf("failed to delete previously aggregated proofs, %w", err) -
    -
    - 810 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 811 - -
    - + - return false, err -
    -
    - 812 - -
    - + - } -
    -
    - 813 - -
    - + -
    -
    -
    - 814 - -
    - + - now := time.Now().Round(time.Microsecond) -
    -
    - 815 - -
    - + - proof.GeneratingSince = &now -
    -
    - 816 - -
    - + -
    -
    -
    - 817 - -
    - + - err = a.State.AddGeneratedProof(ctx, proof, dbTx) -
    -
    - 818 - -
    - + - if err != nil { -
    -
    - 819 - -
    - + - if err := dbTx.Rollback(ctx); err != nil { -
    -
    - 820 - -
    - + - err := fmt.Errorf("failed to rollback proof aggregation state, %w", err) -
    -
    - 821 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 822 - -
    - + - return false, err -
    -
    - 823 - -
    - + - } -
    -
    - 824 - -
    - + - err = fmt.Errorf("failed to store the recursive proof, %w", err) -
    -
    - 825 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 826 - -
    - + - return false, err -
    -
    - 827 - -
    - + - } -
    -
    - 828 - -
    - + -
    -
    -
    - 829 - -
    - + - err = dbTx.Commit(ctx) -
    -
    - 830 - -
    - + - if err != nil { -
    -
    - 831 - -
    - + - err = fmt.Errorf("failed to store the recursive proof, %w", err) -
    -
    - 832 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 833 - -
    - + - return false, err -
    -
    - 834 - -
    - + - } -
    -
    - 835 - -
    - + -
    -
    -
    - 836 - -
    - + - // NOTE(pg): the defer func is useless from now on, use a different variable -
    -
    - 837 - -
    - + - // name for errors (or shadow err in inner scopes) to not trigger it. -
    -
    - 838 - -
    - + -
    -
    -
    - 839 - -
    - + - // state is up to date, check if we can send the final proof using the -
    -
    - 840 - -
    - + - // one just crafted. -
    -
    - 841 - -
    - + - finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof) -
    -
    - 842 - -
    - + - if finalProofErr != nil { -
    -
    - 843 - -
    - + - // just log the error and continue to handle the aggregated proof -
    -
    - 844 - -
    - + - log.Errorf("Failed trying to check if recursive proof can be verified: %v", finalProofErr) -
    -
    - 845 - -
    - + - } -
    -
    - 846 - -
    - + -
    -
    -
    - 847 - -
    - + - // NOTE(pg): prover is done, use a.ctx from now on -
    -
    - 848 - -
    - + -
    -
    -
    - 849 - -
    - + - if !finalProofBuilt { -
    -
    - 850 - -
    - + - proof.GeneratingSince = nil -
    -
    - 851 - -
    - + -
    -
    -
    - 852 - -
    - + - // final proof has not been generated, update the recursive proof -
    -
    - 853 - -
    - + - err := a.State.UpdateGeneratedProof(a.ctx, proof, nil) -
    -
    - 854 - -
    - + - if err != nil { -
    -
    - 855 - -
    - + - err = fmt.Errorf("failed to store batch proof result, %w", err) -
    -
    - 856 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 857 - -
    - + - return false, err -
    -
    - 858 - -
    - + - } -
    -
    - 859 - -
    - + - } -
    -
    - 860 - -
    - + -
    -
    -
    - 861 - -
    - + - return true, nil -
    -
    - 862 - -
    - + - } -
    -
    - 863 - -
    - + -
    -
    -
    - 864 - -
    - + - func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverInterface) (*state.Batch, *state.Proof, error) { -
    -
    - 865 - -
    - + - proverID := prover.ID() -
    -
    - 866 - -
    - + - proverName := prover.Name() -
    -
    - 867 - -
    - + -
    -
    -
    - 868 - -
    - + - log := log.WithFields( -
    -
    - 869 - -
    - + - "prover", proverName, -
    -
    - 870 - -
    - + - "proverId", proverID, -
    -
    - 871 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 872 - -
    - + - ) -
    -
    - 873 - -
    - + -
    -
    -
    - 874 - -
    - + - a.StateDBMutex.Lock() -
    -
    - 875 - -
    - + - defer a.StateDBMutex.Unlock() -
    -
    - 876 - -
    - + -
    -
    -
    - 877 - -
    - + - lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) -
    -
    - 878 - -
    - + - if err != nil { -
    -
    - 879 - -
    - + - return nil, nil, err -
    -
    - 880 - -
    - + - } -
    -
    - 881 - -
    - + -
    -
    -
    - 882 - -
    - + - // Get header of the last L1 block -
    -
    - 883 - -
    - + - lastL1BlockHeader, err := a.Ethman.GetLatestBlockHeader(ctx) -
    -
    - 884 - -
    - + - if err != nil { -
    -
    - 885 - -
    - + - log.Errorf("Failed to get last L1 block header, err: %v", err) -
    -
    - 886 - -
    - + - return nil, nil, err -
    -
    - 887 - -
    - + - } -
    -
    - 888 - -
    - + - lastL1BlockNumber := lastL1BlockHeader.Number.Uint64() -
    -
    - 889 - -
    - + -
    -
    -
    - 890 - -
    - + - // Calculate max L1 block number for getting next virtual batch to prove -
    -
    - 891 - -
    - + - maxL1BlockNumber := uint64(0) -
    -
    - 892 - -
    - + - if a.cfg.BatchProofL1BlockConfirmations <= lastL1BlockNumber { -
    -
    - 893 - -
    - + - maxL1BlockNumber = lastL1BlockNumber - a.cfg.BatchProofL1BlockConfirmations -
    -
    - 894 - -
    - + - } -
    -
    - 895 - -
    - + - log.Debugf("Max L1 block number for getting next virtual batch to prove: %d", maxL1BlockNumber) -
    -
    - 896 - -
    - + -
    -
    -
    - 897 - -
    - + - // Get virtual batch pending to generate proof -
    -
    - 898 - -
    - + - batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, maxL1BlockNumber, nil) -
    -
    - 899 - -
    - + - if err != nil { -
    -
    - 900 - -
    - + - return nil, nil, err -
    -
    - 901 - -
    - + - } -
    -
    - 902 - -
    - + -
    -
    -
    - 903 - -
    - + - log.Infof("Found virtual batch %d pending to generate proof", batchToVerify.BatchNumber) -
    -
    - 904 - -
    - + - log = log.WithFields("batch", batchToVerify.BatchNumber) -
    -
    - 905 - -
    - + -
    -
    -
    - 906 - -
    - + - log.Info("Checking profitability to aggregate batch") -
    -
    - 907 - -
    - + -
    -
    -
    - 908 - -
    - + - // pass pol collateral as zero here, bcs in smart contract fee for aggregator is not defined yet -
    -
    - 909 - -
    - + - isProfitable, err := a.ProfitabilityChecker.IsProfitable(ctx, big.NewInt(0)) -
    -
    - 910 - -
    - + - if err != nil { -
    -
    - 911 - -
    - + - log.Errorf("Failed to check aggregator profitability, err: %v", err) -
    -
    - 912 - -
    - + - return nil, nil, err -
    -
    - 913 - -
    - + - } -
    -
    - 914 - -
    - + -
    -
    -
    - 915 - -
    - + - if !isProfitable { -
    -
    - 916 - -
    - + - log.Infof("Batch is not profitable, pol collateral %d", big.NewInt(0)) -
    -
    - 917 - -
    - + - return nil, nil, err -
    -
    - 918 - -
    - + - } -
    -
    - 919 - -
    - + -
    -
    -
    - 920 - -
    - + - now := time.Now().Round(time.Microsecond) -
    -
    - 921 - -
    - + - proof := &state.Proof{ -
    -
    - 922 - -
    - + - BatchNumber: batchToVerify.BatchNumber, -
    -
    - 923 - -
    - + - BatchNumberFinal: batchToVerify.BatchNumber, -
    -
    - 924 - -
    - + - Prover: &proverName, -
    -
    - 925 - -
    - + - ProverID: &proverID, -
    -
    - 926 - -
    - + - GeneratingSince: &now, -
    -
    - 927 - -
    - + - } -
    -
    - 928 - -
    - + -
    -
    -
    - 929 - -
    - + - // Avoid other prover to process the same batch -
    -
    - 930 - -
    - + - err = a.State.AddGeneratedProof(ctx, proof, nil) -
    -
    - 931 - -
    - + - if err != nil { -
    -
    - 932 - -
    - + - log.Errorf("Failed to add batch proof, err: %v", err) -
    -
    - 933 - -
    - + - return nil, nil, err -
    -
    - 934 - -
    - + - } -
    -
    - 935 - -
    - + -
    -
    -
    - 936 - -
    - + - return batchToVerify, proof, nil -
    -
    - 937 - -
    - + - } -
    -
    - 938 - -
    - + -
    -
    -
    - 939 - -
    - + - func (a *Aggregator) tryGenerateBatchProof(ctx context.Context, prover proverInterface) (bool, error) { -
    -
    - 940 - -
    - + - log := log.WithFields( -
    -
    - 941 - -
    - + - "prover", prover.Name(), -
    -
    - 942 - -
    - + - "proverId", prover.ID(), -
    -
    - 943 - -
    - + - "proverAddr", prover.Addr(), -
    -
    - 944 - -
    - + - ) -
    -
    - 945 - -
    - + - log.Debug("tryGenerateBatchProof start") -
    -
    - 946 - -
    - + -
    -
    -
    - 947 - -
    - + - batchToProve, proof, err0 := a.getAndLockBatchToProve(ctx, prover) -
    -
    - 948 - -
    - + - if errors.Is(err0, state.ErrNotFound) { -
    -
    - 949 - -
    - + - // nothing to proof, swallow the error -
    -
    - 950 - -
    - + - log.Debug("Nothing to generate proof") -
    -
    - 951 - -
    - + - return false, nil -
    -
    - 952 - -
    - + - } -
    -
    - 953 - -
    - + - if err0 != nil { -
    -
    - 954 - -
    - + - return false, err0 -
    -
    - 955 - -
    - + - } -
    -
    - 956 - -
    - + -
    -
    -
    - 957 - -
    - + - log = log.WithFields("batch", batchToProve.BatchNumber) -
    -
    - 958 - -
    - + -
    -
    -
    - 959 - -
    - + - var ( -
    -
    - 960 - -
    - + - genProofID *string -
    -
    - 961 - -
    - + - err error -
    -
    - 962 - -
    - + - ) -
    -
    - 963 - -
    - + -
    -
    -
    - 964 - -
    - + - defer func() { -
    -
    - 965 - -
    - + - if err != nil { -
    -
    - 966 - -
    - + - err2 := a.State.DeleteGeneratedProofs(a.ctx, proof.BatchNumber, proof.BatchNumberFinal, nil) -
    -
    - 967 - -
    - + - if err2 != nil { -
    -
    - 968 - -
    - + - log.Errorf("Failed to delete proof in progress, err: %v", err2) -
    -
    - 969 - -
    - + - } -
    -
    - 970 - -
    - + - } -
    -
    - 971 - -
    - + - log.Debug("tryGenerateBatchProof end") -
    -
    - 972 - -
    - + - }() -
    -
    - 973 - -
    - + -
    -
    -
    - 974 - -
    - + - log.Info("Generating proof from batch") -
    -
    - 975 - -
    - + -
    -
    -
    - 976 - -
    - + - log.Infof("Sending zki + batch to the prover, batchNumber [%d]", batchToProve.BatchNumber) -
    -
    - 977 - -
    - + - inputProver, err := a.buildInputProver(ctx, batchToProve) -
    -
    - 978 - -
    - + - if err != nil { -
    -
    - 979 - -
    - + - err = fmt.Errorf("failed to build input prover, %w", err) -
    -
    - 980 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 981 - -
    - + - return false, err -
    -
    - 982 - -
    - + - } -
    -
    - 983 - -
    - + -
    -
    -
    - 984 - -
    - + - b, err := json.Marshal(inputProver) -
    -
    - 985 - -
    - + - if err != nil { -
    -
    - 986 - -
    - + - err = fmt.Errorf("failed to serialize input prover, %w", err) -
    -
    - 987 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 988 - -
    - + - return false, err -
    -
    - 989 - -
    - + - } -
    -
    - 990 - -
    - + -
    -
    -
    - 991 - -
    - + - proof.InputProver = string(b) -
    -
    - 992 - -
    - + -
    -
    -
    - 993 - -
    - + - log.Infof("Sending a batch to the prover. OldStateRoot [%#x], OldBatchNum [%d]", -
    -
    - 994 - -
    - + - inputProver.PublicInputs.OldStateRoot, inputProver.PublicInputs.OldBatchNum) -
    -
    - 995 - -
    - + -
    -
    -
    - 996 - -
    - + - genProofID, err = prover.BatchProof(inputProver) -
    -
    - 997 - -
    - + - if err != nil { -
    -
    - 998 - -
    - + - err = fmt.Errorf("failed to get batch proof id, %w", err) -
    -
    - 999 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 1000 - -
    - + - return false, err -
    -
    - 1001 - -
    - + - } -
    -
    - 1002 - -
    - + -
    -
    -
    - 1003 - -
    - + - proof.ProofID = genProofID -
    -
    - 1004 - -
    - + -
    -
    -
    - 1005 - -
    - + - log.Infof("Proof ID %v", *proof.ProofID) -
    -
    - 1006 - -
    - + - log = log.WithFields("proofId", *proof.ProofID) -
    -
    - 1007 - -
    - + -
    -
    -
    - 1008 - -
    - + - resGetProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID) -
    -
    - 1009 - -
    - + - if err != nil { -
    -
    - 1010 - -
    - + - err = fmt.Errorf("failed to get proof from prover, %w", err) -
    -
    - 1011 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 1012 - -
    - + - return false, err -
    -
    - 1013 - -
    - + - } -
    -
    - 1014 - -
    - + -
    -
    -
    - 1015 - -
    - + - log.Info("Batch proof generated") -
    -
    - 1016 - -
    - + -
    -
    -
    - 1017 - -
    - + - proof.Proof = resGetProof -
    -
    - 1018 - -
    - + -
    -
    -
    - 1019 - -
    - + - // NOTE(pg): the defer func is useless from now on, use a different variable -
    -
    - 1020 - -
    - + - // name for errors (or shadow err in inner scopes) to not trigger it. -
    -
    - 1021 - -
    - + -
    -
    -
    - 1022 - -
    - + - finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof) -
    -
    - 1023 - -
    - + - if finalProofErr != nil { -
    -
    - 1024 - -
    - + - // just log the error and continue to handle the generated proof -
    -
    - 1025 - -
    - + - log.Errorf("Error trying to build final proof: %v", finalProofErr) -
    -
    - 1026 - -
    - + - } -
    -
    - 1027 - -
    - + -
    -
    -
    - 1028 - -
    - + - // NOTE(pg): prover is done, use a.ctx from now on -
    -
    - 1029 - -
    - + -
    -
    -
    - 1030 - -
    - + - if !finalProofBuilt { -
    -
    - 1031 - -
    - + - proof.GeneratingSince = nil -
    -
    - 1032 - -
    - + -
    -
    -
    - 1033 - -
    - + - // final proof has not been generated, update the batch proof -
    -
    - 1034 - -
    - + - err := a.State.UpdateGeneratedProof(a.ctx, proof, nil) -
    -
    - 1035 - -
    - + - if err != nil { -
    -
    - 1036 - -
    - + - err = fmt.Errorf("failed to store batch proof result, %w", err) -
    -
    - 1037 - -
    - + - log.Error(FirstToUpper(err.Error())) -
    -
    - 1038 - -
    - + - return false, err -
    -
    - 1039 - -
    - + - } -
    -
    - 1040 - -
    - + - } -
    -
    - 1041 - -
    - + -
    -
    -
    - 1042 - -
    - + - return true, nil -
    -
    - 1043 - -
    -   - } -
    -
    - 1044 - -
    -   -
    -
    -
    - 1045 - -
    -   - // canVerifyProof returns true if we have reached the timeout to verify a proof -
    -
    -
     
    -
    - 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 - -
    -   - } -
    -
    - 1172 - -
    -   - if l1InfoRoot != nil && *l1InfoRoot != calculatedL1InfoRoot { -
    -
    - 1173 - -
    -   - for i, l := range aLeaves { -
    -
    - 1174 - -
    - + - log.Info("AllLeaves[%d]: %s", i, common.Bytes2Hex(l[:])) -
    -
    - 1175 - -
    -   - } -
    -
    - 1176 - -
    -   - for i, s := range smtProof { -
    -
    - 1177 - -
    - + - log.Info("smtProof[%d]: %s", i, common.Bytes2Hex(s[:])) -
    -
    - 1178 - -
    -   - } -
    -
    - 1179 - -
    -   - return nil, fmt.Errorf("error: l1InfoRoot mismatch. L1InfoRoot: %s, calculatedL1InfoRoot: %s. l1InfoTreeIndex: %d", l1InfoRoot.String(), calculatedL1InfoRoot.String(), l2blockRaw.IndexL1InfoTree) -
    -
    - 1180 - -
    -   - } -
    -
    -
     
    -
    - 1301 - -
    -   -
    -
    -
    - 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 - -
    -   - // network is synced with the final proof, we can safely delete all recursive -
    -
    - 1310 - -
    -   - // proofs up to the last synced batch -
    -
    - 1311 - -
    - + - err = a.State.CleanupGeneratedProofs(a.ctx, proofBatchNumberFinal, nil) -
    -
    - 1312 - -
    -   - if err != nil { -
    -
    - 1313 - -
    -   - log.Errorf("Failed to store proof aggregation result: %v", err) -
    -
    - 1314 - -
    -   - } -
    -
    - 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 - -
    -   - } -
    -
    -
     
    -
    - 1342 - -
    -   - case <-a.ctx.Done(): -
    -
    - 1343 - -
    -   - return -
    -
    - 1344 - -
    -   - case <-time.After(a.TimeCleanupLockedProofs.Duration): -
    -
    - 1345 - -
    - + - n, err := a.State.CleanupLockedProofs(a.ctx, a.cfg.GeneratingProofCleanupThreshold, nil) -
    -
    - 1346 - -
    -   - if err != nil { -
    -
    - 1347 - -
    -   - log.Errorf("Failed to cleanup locked proofs: %v", err) -
    -
    - 1348 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -89,7 +89,7 @@
    -
    - 89 - -
    -   - m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) { -
    -
    - 90 - -
    -   - assert.True(a.verifyingProof) -
    -
    - 91 - -
    -   - }).Return(nil, nil, errBanana).Once() -
    -
    - 92 - -
    - - - m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 93 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 94 - -
    -   - a.exit() -
    -
    - 95 - -
    -   - }).Return(nil).Once() -
    -
    -
    @@ -99,7 +99,7 @@
    -
    - 99 - -
    -   - }, -
    -
    - 100 - -
    -   - }, -
    -
    - 101 - -
    -   - { -
    -
    - 102 - -
    - - - name: "UpdateBatchProof error after BuildTrustedVerifyBatchesTxData error", -
    -
    - 103 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 104 - -
    -   - m.stateMock.On("GetBatchByNumber", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) { -
    -
    - 105 - -
    -   - assert.True(a.verifyingProof) -
    -
    -
    @@ -112,7 +112,7 @@
    -
    - 112 - -
    -   - m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) { -
    -
    - 113 - -
    -   - assert.True(a.verifyingProof) -
    -
    - 114 - -
    -   - }).Return(nil, nil, errBanana).Once() -
    -
    - 115 - -
    - - - m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 116 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 117 - -
    -   - a.exit() -
    -
    - 118 - -
    -   - }).Return(errBanana).Once() -
    -
    -
    @@ -137,7 +137,7 @@
    -
    - 137 - -
    -   - }).Return(&to, data, nil).Once() -
    -
    - 138 - -
    -   - monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal) -
    -
    - 139 - -
    -   - m.ethTxManager.On("Add", mock.Anything, ethTxManagerOwner, monitoredTxID, from, &to, value, data, cfg.GasOffset, nil).Return(errBanana).Once() -
    -
    - 140 - -
    - - - m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 141 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 142 - -
    -   - a.exit() -
    -
    - 143 - -
    -   - }).Return(nil).Once() -
    -
    -
    @@ -175,7 +175,7 @@
    -
    - 175 - -
    -   - } -
    -
    - 176 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&verifiedBatch, nil).Once() -
    -
    - 177 - -
    -   - m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNumFinal, nil).Once() -
    -
    - 178 - -
    - - - m.stateMock.On("CleanupBatchProofs", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) { -
    -
    - 179 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 180 - -
    -   - a.exit() -
    -
    - 181 - -
    -   - }).Return(nil).Once() -
    -
    -
    @@ -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{ -
    -
    -
    @@ -251,12 +251,12 @@
    -
    - 251 - -
    -   - asserts func(bool, *Aggregator, error) -
    -
    - 252 - -
    -   - }{ -
    -
    - 253 - -
    -   - { -
    -
    - 254 - -
    - - - name: "getAndLockBatchProofsToAggregate returns generic error", -
    -
    - 255 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 256 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 257 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    - 258 - -
    -   - m.proverMock.On("Addr").Return("addr") -
    -
    - 259 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, errBanana).Once() -
    -
    - 260 - -
    -   - }, -
    -
    - 261 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 262 - -
    -   - assert.False(result) -
    -
    -
    @@ -264,12 +264,12 @@
    -
    - 264 - -
    -   - }, -
    -
    - 265 - -
    -   - }, -
    -
    - 266 - -
    -   - { -
    -
    - 267 - -
    - - - name: "getAndLockBatchProofsToAggregate returns ErrNotFound", -
    -
    - 268 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 269 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 270 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    - 271 - -
    -   - m.proverMock.On("Addr").Return("addr") -
    -
    - 272 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, state.ErrNotFound).Once() -
    -
    - 273 - -
    -   - }, -
    -
    - 274 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 275 - -
    -   - assert.False(result) -
    -
    -
    @@ -277,7 +277,7 @@
    -
    - 277 - -
    -   - }, -
    -
    - 278 - -
    -   - }, -
    -
    - 279 - -
    -   - { -
    -
    - 280 - -
    - - - name: "getAndLockBatchProofsToAggregate error updating proofs", -
    -
    - 281 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 282 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 283 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
    @@ -285,9 +285,9 @@
    -
    - 285 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 286 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 287 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once() -
    -
    - 288 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 289 - -
    -   - m.stateMock. -
    -
    - 290 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 291 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 292 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 293 - -
    -   - }). -
    -
    -
    @@ -300,7 +300,7 @@
    -
    - 300 - -
    -   - }, -
    -
    - 301 - -
    -   - }, -
    -
    - 302 - -
    -   - { -
    -
    - 303 - -
    - - - name: "AggregatedBatchProof prover error", -
    -
    - 304 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 305 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 306 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
    @@ -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 @@
    -
    - 407 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 408 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once() -
    -
    - 409 - -
    -   - dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 410 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 411 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 412 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 413 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 414 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 415 - -
    -   - }). -
    -
    - 416 - -
    -   - Return(nil). -
    -
    - 417 - -
    -   - Once() -
    -
    - 418 - -
    -   - m.stateMock. -
    -
    - 419 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 420 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 421 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 422 - -
    -   - }). -
    -
    -
    @@ -426,7 +426,7 @@
    -
    - 426 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once() -
    -
    - 427 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 428 - -
    -   - m.stateMock. -
    -
    - 429 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 430 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 431 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 432 - -
    -   - }). -
    -
    -
    @@ -441,7 +441,7 @@
    -
    - 441 - -
    -   - }, -
    -
    - 442 - -
    -   - }, -
    -
    - 443 - -
    -   - { -
    -
    - 444 - -
    - - - name: "rollback after DeleteBatchProofs error in db transaction", -
    -
    - 445 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 446 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 447 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
    @@ -449,16 +449,16 @@
    -
    - 449 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 450 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 451 - -
    -   - lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 452 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 453 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 454 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 455 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 456 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 457 - -
    -   - }). -
    -
    - 458 - -
    -   - Return(nil). -
    -
    - 459 - -
    -   - Once() -
    -
    - 460 - -
    -   - proof2GeneratingTrueCall := m.stateMock. -
    -
    - 461 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 462 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 463 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 464 - -
    -   - }). -
    -
    -
    @@ -466,11 +466,11 @@
    -
    - 466 - -
    -   - Once() -
    -
    - 467 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 468 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 469 - -
    - - - m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(errBanana).Once() -
    -
    - 470 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 471 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 472 - -
    -   - m.stateMock. -
    -
    - 473 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 474 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 475 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 476 - -
    -   - }). -
    -
    -
    @@ -478,7 +478,7 @@
    -
    - 478 - -
    -   - Once(). -
    -
    - 479 - -
    -   - NotBefore(proof1GeneratingTrueCall) -
    -
    - 480 - -
    -   - m.stateMock. -
    -
    - 481 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx). -
    -
    - 482 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 483 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 484 - -
    -   - }). -
    -
    -
    @@ -493,7 +493,7 @@
    -
    - 493 - -
    -   - }, -
    -
    - 494 - -
    -   - }, -
    -
    - 495 - -
    -   - { -
    -
    - 496 - -
    - - - name: "rollback after AddBatchProof error in db transaction", -
    -
    - 497 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 498 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 499 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
    @@ -501,16 +501,16 @@
    -
    - 501 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 502 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 503 - -
    -   - lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 504 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 505 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 506 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 507 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 508 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 509 - -
    -   - }). -
    -
    - 510 - -
    -   - Return(nil). -
    -
    - 511 - -
    -   - Once() -
    -
    - 512 - -
    -   - proof2GeneratingTrueCall := m.stateMock. -
    -
    - 513 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 514 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 515 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 516 - -
    -   - }). -
    -
    -
    @@ -518,12 +518,12 @@
    -
    - 518 - -
    -   - Once() -
    -
    - 519 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 520 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 521 - -
    - - - m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once() -
    -
    - 522 - -
    - - - m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Return(errBanana).Once() -
    -
    - 523 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 524 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 525 - -
    -   - m.stateMock. -
    -
    - 526 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 527 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 528 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 529 - -
    -   - }). -
    -
    -
    @@ -531,7 +531,7 @@
    -
    - 531 - -
    -   - Once(). -
    -
    - 532 - -
    -   - NotBefore(proof1GeneratingTrueCall) -
    -
    - 533 - -
    -   - m.stateMock. -
    -
    - 534 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx). -
    -
    - 535 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 536 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 537 - -
    -   - }). -
    -
    -
    @@ -554,16 +554,16 @@
    -
    - 554 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 555 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 556 - -
    -   - dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice() -
    -
    - 557 - -
    - - - m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 558 - -
    -   - m.stateMock. -
    -
    - 559 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 560 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 561 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 562 - -
    -   - }). -
    -
    - 563 - -
    -   - Return(nil). -
    -
    - 564 - -
    -   - Once() -
    -
    - 565 - -
    -   - m.stateMock. -
    -
    - 566 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 567 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 568 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 569 - -
    -   - }). -
    -
    -
    @@ -571,14 +571,14 @@
    -
    - 571 - -
    -   - Once() -
    -
    - 572 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 573 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 574 - -
    - - - m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once() -
    -
    - 575 - -
    -   - expectedInputProver := map[string]interface{}{ -
    -
    - 576 - -
    -   - "recursive_proof_1": proof1.Proof, -
    -
    - 577 - -
    -   - "recursive_proof_2": proof2.Proof, -
    -
    - 578 - -
    -   - } -
    -
    - 579 - -
    -   - b, err := json.Marshal(expectedInputProver) -
    -
    - 580 - -
    -   - require.NoError(err) -
    -
    - 581 - -
    - - - m.stateMock.On("AddBatchProof", 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,7 +590,7 @@
    -
    - 590 - -
    -   - assert.InDelta(time.Now().Unix(), proof.GeneratingSince.Unix(), float64(time.Second)) -
    -
    - 591 - -
    -   - }, -
    -
    - 592 - -
    -   - ).Return(nil).Once() -
    -
    - 593 - -
    - - - m.stateMock.On("UpdateBatchProof", 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,16 +618,16 @@
    -
    - 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("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 622 - -
    -   - m.stateMock. -
    -
    - 623 - -
    - - - On("UpdateBatchProof", 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("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 631 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 632 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 633 - -
    -   - }). -
    -
    -
    @@ -635,14 +635,14 @@
    -
    - 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("DeleteBatchProofs", 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("AddBatchProof", 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,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) -
    -
    - 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) -
    -
    -
    @@ -1138,11 +1138,11 @@
    -
    - 1138 - -
    -   - m.proverMock.On("Addr").Return("addr").Twice() -
    -
    - 1139 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice() -
    -
    - 1140 - -
    -   - m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once() -
    -
    - 1141 - -
    - - - m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() -
    -
    - 1142 - -
    - - - proofGeneratingTrueCall := m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once() -
    -
    - 1143 - -
    -   - m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(nil, errBanana).Once() -
    -
    - 1144 - -
    -   - m.stateMock. -
    -
    - 1145 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil). -
    -
    - 1146 - -
    -   - Return(nil). -
    -
    - 1147 - -
    -   - Once(). -
    -
    - 1148 - -
    -   - NotBefore(proofGeneratingTrueCall) -
    -
    -
    @@ -1160,12 +1160,12 @@
    -
    - 1160 - -
    -   - m.proverMock.On("Addr").Return("addr").Twice() -
    -
    - 1161 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice() -
    -
    - 1162 - -
    -   - m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once() -
    -
    - 1163 - -
    - - - 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() -
    -
    - 1165 - -
    -   - m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once() -
    -
    - 1166 - -
    -   - m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(nil, errBanana).Once() -
    -
    - 1167 - -
    -   - m.stateMock. -
    -
    - 1168 - -
    - - - On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil). -
    -
    - 1169 - -
    -   - Return(nil). -
    -
    - 1170 - -
    -   - Once(). -
    -
    - 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 @@
    -
    - 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("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() -
    -
    - 1217 - -
    - - - m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once() -
    -
    - 1218 - -
    -   - m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once() -
    -
    - 1219 - -
    -   - m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(&finalProof, nil).Once() -
    -
    - 1220 - -
    -   - }, -
    -
    -
    @@ -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) -
    -
    -
    @@ -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 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 89 - -
    -   - m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) { -
    -
    - 90 - -
    -   - assert.True(a.verifyingProof) -
    -
    - 91 - -
    -   - }).Return(nil, nil, errBanana).Once() -
    -
    - 92 - -
    - + - m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 93 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 94 - -
    -   - a.exit() -
    -
    - 95 - -
    -   - }).Return(nil).Once() -
    -
    -
     
    -
    - 99 - -
    -   - }, -
    -
    - 100 - -
    -   - }, -
    -
    - 101 - -
    -   - { -
    -
    - 102 - -
    - + - name: "UpdateGeneratedProof error after BuildTrustedVerifyBatchesTxData error", -
    -
    - 103 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 104 - -
    -   - m.stateMock.On("GetBatchByNumber", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) { -
    -
    - 105 - -
    -   - assert.True(a.verifyingProof) -
    -
    -
     
    -
    - 112 - -
    -   - m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) { -
    -
    - 113 - -
    -   - assert.True(a.verifyingProof) -
    -
    - 114 - -
    -   - }).Return(nil, nil, errBanana).Once() -
    -
    - 115 - -
    - + - m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 116 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 117 - -
    -   - a.exit() -
    -
    - 118 - -
    -   - }).Return(errBanana).Once() -
    -
    -
     
    -
    - 137 - -
    -   - }).Return(&to, data, nil).Once() -
    -
    - 138 - -
    -   - monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal) -
    -
    - 139 - -
    -   - m.ethTxManager.On("Add", mock.Anything, ethTxManagerOwner, monitoredTxID, from, &to, value, data, cfg.GasOffset, nil).Return(errBanana).Once() -
    -
    - 140 - -
    - + - m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) { -
    -
    - 141 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 142 - -
    -   - a.exit() -
    -
    - 143 - -
    -   - }).Return(nil).Once() -
    -
    -
     
    -
    - 175 - -
    -   - } -
    -
    - 176 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&verifiedBatch, nil).Once() -
    -
    - 177 - -
    -   - m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNumFinal, nil).Once() -
    -
    - 178 - -
    - + - m.stateMock.On("CleanupGeneratedProofs", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) { -
    -
    - 179 - -
    -   - // test is done, stop the sendFinalProof method -
    -
    - 180 - -
    -   - a.exit() -
    -
    - 181 - -
    -   - }).Return(nil).Once() -
    -
    -
     
    -
    - 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{ -
    -
    -
     
    -
    - 251 - -
    -   - asserts func(bool, *Aggregator, error) -
    -
    - 252 - -
    -   - }{ -
    -
    - 253 - -
    -   - { -
    -
    - 254 - -
    - + - name: "getAndLockProofsToAggregate returns generic error", -
    -
    - 255 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 256 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 257 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    - 258 - -
    -   - m.proverMock.On("Addr").Return("addr") -
    -
    - 259 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, errBanana).Once() -
    -
    - 260 - -
    -   - }, -
    -
    - 261 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 262 - -
    -   - assert.False(result) -
    -
    -
     
    -
    - 264 - -
    -   - }, -
    -
    - 265 - -
    -   - }, -
    -
    - 266 - -
    -   - { -
    -
    - 267 - -
    - + - name: "getAndLockProofsToAggregate returns ErrNotFound", -
    -
    - 268 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 269 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 270 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    - 271 - -
    -   - m.proverMock.On("Addr").Return("addr") -
    -
    - 272 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, state.ErrNotFound).Once() -
    -
    - 273 - -
    -   - }, -
    -
    - 274 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 275 - -
    -   - assert.False(result) -
    -
    -
     
    -
    - 277 - -
    -   - }, -
    -
    - 278 - -
    -   - }, -
    -
    - 279 - -
    -   - { -
    -
    - 280 - -
    - + - name: "getAndLockProofsToAggregate error updating proofs", -
    -
    - 281 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 282 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 283 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
     
    -
    - 285 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 286 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 287 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once() -
    -
    - 288 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 289 - -
    -   - m.stateMock. -
    -
    - 290 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 291 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 292 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 293 - -
    -   - }). -
    -
    -
     
    -
    - 300 - -
    -   - }, -
    -
    - 301 - -
    -   - }, -
    -
    - 302 - -
    -   - { -
    -
    - 303 - -
    - + - name: "AggregatedProof prover error", -
    -
    - 304 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 305 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 306 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
     
    -
    - 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("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 312 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 313 - -
    - + - On("UpdateGeneratedProof", 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("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 321 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 322 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 323 - -
    -   - }). -
    -
    -
     
    -
    - 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("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 330 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 331 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 332 - -
    -   - }). -
    -
    -
     
    -
    - 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 - -
    -   - }). -
    -
    -
     
    -
    - 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("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 361 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 362 - -
    - + - On("UpdateGeneratedProof", 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("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 370 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 371 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 372 - -
    -   - }). -
    -
    -
     
    -
    - 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). -
    -
    - 380 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 381 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 382 - -
    -   - }). -
    -
    -
     
    -
    - 384 - -
    -   - Once(). -
    -
    - 385 - -
    -   - NotBefore(proof1GeneratingTrueCall) -
    -
    - 386 - -
    -   - m.stateMock. -
    -
    - 387 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx). -
    -
    - 388 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 389 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 390 - -
    -   - }). -
    -
    -
     
    -
    - 399 - -
    -   - }, -
    -
    - 400 - -
    -   - }, -
    -
    - 401 - -
    -   - { -
    -
    - 402 - -
    - + - name: "unlockProofsToAggregate 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 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 408 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once() -
    -
    - 409 - -
    -   - dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 410 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 411 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 412 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 413 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 414 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 415 - -
    -   - }). -
    -
    - 416 - -
    -   - Return(nil). -
    -
    - 417 - -
    -   - Once() -
    -
    - 418 - -
    -   - m.stateMock. -
    -
    - 419 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 420 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 421 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 422 - -
    -   - }). -
    -
    -
     
    -
    - 426 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once() -
    -
    - 427 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 428 - -
    -   - m.stateMock. -
    -
    - 429 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 430 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 431 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 432 - -
    -   - }). -
    -
    -
     
    -
    - 441 - -
    -   - }, -
    -
    - 442 - -
    -   - }, -
    -
    - 443 - -
    -   - { -
    -
    - 444 - -
    - + - name: "rollback after DeleteGeneratedProofs error in db transaction", -
    -
    - 445 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 446 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 447 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
     
    -
    - 449 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 450 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 451 - -
    -   - lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 452 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 453 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 454 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 455 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 456 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 457 - -
    -   - }). -
    -
    - 458 - -
    -   - Return(nil). -
    -
    - 459 - -
    -   - Once() -
    -
    - 460 - -
    -   - proof2GeneratingTrueCall := m.stateMock. -
    -
    - 461 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 462 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 463 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 464 - -
    -   - }). -
    -
    -
     
    -
    - 466 - -
    -   - Once() -
    -
    - 467 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 468 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 469 - -
    - + - m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(errBanana).Once() -
    -
    - 470 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 471 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 472 - -
    -   - m.stateMock. -
    -
    - 473 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 474 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 475 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 476 - -
    -   - }). -
    -
    -
     
    -
    - 478 - -
    -   - Once(). -
    -
    - 479 - -
    -   - NotBefore(proof1GeneratingTrueCall) -
    -
    - 480 - -
    -   - m.stateMock. -
    -
    - 481 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx). -
    -
    - 482 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 483 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 484 - -
    -   - }). -
    -
    -
     
    -
    - 493 - -
    -   - }, -
    -
    - 494 - -
    -   - }, -
    -
    - 495 - -
    -   - { -
    -
    - 496 - -
    - + - name: "rollback after AddGeneratedProof error in db transaction", -
    -
    - 497 - -
    -   - setup: func(m mox, a *Aggregator) { -
    -
    - 498 - -
    -   - m.proverMock.On("Name").Return(proverName).Twice() -
    -
    - 499 - -
    -   - m.proverMock.On("ID").Return(proverID).Twice() -
    -
    -
     
    -
    - 501 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 502 - -
    -   - lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 503 - -
    -   - lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 504 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 505 - -
    -   - proof1GeneratingTrueCall := m.stateMock. -
    -
    - 506 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 507 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 508 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 509 - -
    -   - }). -
    -
    - 510 - -
    -   - Return(nil). -
    -
    - 511 - -
    -   - Once() -
    -
    - 512 - -
    -   - proof2GeneratingTrueCall := m.stateMock. -
    -
    - 513 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 514 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 515 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 516 - -
    -   - }). -
    -
    -
     
    -
    - 518 - -
    -   - Once() -
    -
    - 519 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 520 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 521 - -
    - + - m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once() -
    -
    - 522 - -
    - + - m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Return(errBanana).Once() -
    -
    - 523 - -
    -   - dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once() -
    -
    - 524 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin) -
    -
    - 525 - -
    -   - m.stateMock. -
    -
    - 526 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx). -
    -
    - 527 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 528 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 529 - -
    -   - }). -
    -
    -
     
    -
    - 531 - -
    -   - Once(). -
    -
    - 532 - -
    -   - NotBefore(proof1GeneratingTrueCall) -
    -
    - 533 - -
    -   - m.stateMock. -
    -
    - 534 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx). -
    -
    - 535 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 536 - -
    -   - assert.Nil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 537 - -
    -   - }). -
    -
    -
     
    -
    - 554 - -
    -   - dbTx := &mocks.DbTxMock{} -
    -
    - 555 - -
    -   - m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice() -
    -
    - 556 - -
    -   - dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice() -
    -
    - 557 - -
    - + - m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() -
    -
    - 558 - -
    -   - m.stateMock. -
    -
    - 559 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx). -
    -
    - 560 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 561 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 562 - -
    -   - }). -
    -
    - 563 - -
    -   - Return(nil). -
    -
    - 564 - -
    -   - Once() -
    -
    - 565 - -
    -   - m.stateMock. -
    -
    - 566 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). -
    -
    - 567 - -
    -   - Run(func(args mock.Arguments) { -
    -
    - 568 - -
    -   - assert.NotNil(args[1].(*state.Proof).GeneratingSince) -
    -
    - 569 - -
    -   - }). -
    -
    -
     
    -
    - 571 - -
    -   - Once() -
    -
    - 572 - -
    -   - m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once() -
    -
    - 573 - -
    -   - m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once() -
    -
    - 574 - -
    - + - m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once() -
    -
    - 575 - -
    -   - expectedInputProver := map[string]interface{}{ -
    -
    - 576 - -
    -   - "recursive_proof_1": proof1.Proof, -
    -
    - 577 - -
    -   - "recursive_proof_2": proof2.Proof, -
    -
    - 578 - -
    -   - } -
    -
    - 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 - -
    -   - }, -
    -
    - 898 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 899 - -
    -   - assert.False(result) -
    -
    -
     
    -
    - 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("AddGeneratedProof", 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 - -
    -   - 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("UpdateGeneratedProof", 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 - -
    -   - 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("AddGeneratedProof", 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 - -
    -   - 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("UpdateGeneratedProof", 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 - -
    -   - 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) -
    -
    -
     
    -
    - 1138 - -
    -   - m.proverMock.On("Addr").Return("addr").Twice() -
    -
    - 1139 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice() -
    -
    - 1140 - -
    -   - m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once() -
    -
    - 1141 - -
    - + - m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() -
    -
    - 1142 - -
    - + - proofGeneratingTrueCall := m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once() -
    -
    - 1143 - -
    -   - m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(nil, errBanana).Once() -
    -
    - 1144 - -
    -   - m.stateMock. -
    -
    - 1145 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil). -
    -
    - 1146 - -
    -   - Return(nil). -
    -
    - 1147 - -
    -   - Once(). -
    -
    - 1148 - -
    -   - NotBefore(proofGeneratingTrueCall) -
    -
    -
     
    -
    - 1160 - -
    -   - m.proverMock.On("Addr").Return("addr").Twice() -
    -
    - 1161 - -
    -   - m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice() -
    -
    - 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() -
    -
    - 1166 - -
    -   - m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(nil, errBanana).Once() -
    -
    - 1167 - -
    -   - m.stateMock. -
    -
    - 1168 - -
    - + - On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil). -
    -
    - 1169 - -
    -   - Return(nil). -
    -
    - 1170 - -
    -   - Once(). -
    -
    - 1171 - -
    -   - NotBefore(proofGeneratingTrueCall) -
    -
    -
     
    -
    - 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("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(nil, errBanana).Once() -
    -
    - 1187 - -
    -   - }, -
    -
    - 1188 - -
    -   - asserts: func(result bool, a *Aggregator, err error) { -
    -
    - 1189 - -
    -   - assert.False(result) -
    -
    -
     
    -
    - 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("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() -
    -
    - 1218 - -
    -   - m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once() -
    -
    - 1219 - -
    -   - m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(&finalProof, nil).Once() -
    -
    - 1220 - -
    -   - }, -
    -
    -
     
    -
    - 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) -
    -
    -
     
    -
    - 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 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/batch.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,427 +0,0 @@
    -
    - 1 - -
    - - - package aggregator -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "encoding/json" -
    -
    - 6 - -
    - - - "errors" -
    -
    - 7 - -
    - - - "fmt" -
    -
    - 8 - -
    - - - "math/big" -
    -
    - 9 - -
    - - - "time" -
    -
    - 10 - -
    - - -
    -
    -
    - 11 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 12 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 13 - -
    - - - ) -
    -
    - 14 - -
    - - -
    -
    -
    - 15 - -
    - - - func (a *Aggregator) tryGenerateBatchProof(ctx context.Context, prover proverInterface) (bool, error) { -
    -
    - 16 - -
    - - - log := log.WithFields( -
    -
    - 17 - -
    - - - "prover", prover.Name(), -
    -
    - 18 - -
    - - - "proverId", prover.ID(), -
    -
    - 19 - -
    - - - "proverAddr", prover.Addr(), -
    -
    - 20 - -
    - - - ) -
    -
    - 21 - -
    - - - log.Debug("tryGenerateBatchProof start") -
    -
    - 22 - -
    - - -
    -
    -
    - 23 - -
    - - - batchToProve, proof, err0 := a.getAndLockBatchToProve(ctx, prover) -
    -
    - 24 - -
    - - - if errors.Is(err0, state.ErrNotFound) { -
    -
    - 25 - -
    - - - // nothing to proof, swallow the error -
    -
    - 26 - -
    - - - log.Debug("Nothing to generate proof") -
    -
    - 27 - -
    - - - return false, nil -
    -
    - 28 - -
    - - - } -
    -
    - 29 - -
    - - - if err0 != nil { -
    -
    - 30 - -
    - - - return false, err0 -
    -
    - 31 - -
    - - - } -
    -
    - 32 - -
    - - -
    -
    -
    - 33 - -
    - - - log = log.WithFields("batch", batchToProve.BatchNumber) -
    -
    - 34 - -
    - - -
    -
    -
    - 35 - -
    - - - var ( -
    -
    - 36 - -
    - - - genProofID *string -
    -
    - 37 - -
    - - - err error -
    -
    - 38 - -
    - - - ) -
    -
    - 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 - -
    - - -
    -
    -
    - 52 - -
    - - - log.Infof("Sending zki + batch to the prover, batchNumber [%d]", batchToProve.BatchNumber) -
    -
    - 53 - -
    - - - inputProver, err := a.buildInputProver(ctx, batchToProve) -
    -
    - 54 - -
    - - - if err != nil { -
    -
    - 55 - -
    - - - err = fmt.Errorf("failed to build input prover, %w", err) -
    -
    - 56 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 57 - -
    - - - return false, err -
    -
    - 58 - -
    - - - } -
    -
    - 59 - -
    - - -
    -
    -
    - 60 - -
    - - - b, err := json.Marshal(inputProver) -
    -
    - 61 - -
    - - - if err != nil { -
    -
    - 62 - -
    - - - err = fmt.Errorf("failed to serialize input prover, %w", err) -
    -
    - 63 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 64 - -
    - - - return false, err -
    -
    - 65 - -
    - - - } -
    -
    - 66 - -
    - - -
    -
    -
    - 67 - -
    - - - proof.InputProver = string(b) -
    -
    - 68 - -
    - - -
    -
    -
    - 69 - -
    - - - log.Infof("Sending a batch to the prover. OldStateRoot [%#x], OldBatchNum [%d]", -
    -
    - 70 - -
    - - - inputProver.PublicInputs.OldStateRoot, inputProver.PublicInputs.OldBatchNum) -
    -
    - 71 - -
    - - -
    -
    -
    - 72 - -
    - - - genProofID, err = prover.BatchProof(inputProver) -
    -
    - 73 - -
    - - - if err != nil { -
    -
    - 74 - -
    - - - err = fmt.Errorf("failed to get batch proof id, %w", err) -
    -
    - 75 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 76 - -
    - - - return false, err -
    -
    - 77 - -
    - - - } -
    -
    - 78 - -
    - - -
    -
    -
    - 79 - -
    - - - proof.ProofID = genProofID -
    -
    - 80 - -
    - - -
    -
    -
    - 81 - -
    - - - log.Infof("Proof ID %v", *proof.ProofID) -
    -
    - 82 - -
    - - - log = log.WithFields("proofId", *proof.ProofID) -
    -
    - 83 - -
    - - -
    -
    -
    - 84 - -
    - - - resGetProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID) -
    -
    - 85 - -
    - - - if err != nil { -
    -
    - 86 - -
    - - - err = fmt.Errorf("failed to get proof from prover, %w", err) -
    -
    - 87 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 88 - -
    - - - return false, err -
    -
    - 89 - -
    - - - } -
    -
    - 90 - -
    - - -
    -
    -
    - 91 - -
    - - - log.Info("Batch proof generated") -
    -
    - 92 - -
    - - -
    -
    -
    - 93 - -
    - - - proof.Proof = resGetProof -
    -
    - 94 - -
    - - -
    -
    -
    - 95 - -
    - - - // NOTE(pg): the defer func is useless from now on, use a different variable -
    -
    - 96 - -
    - - - // name for errors (or shadow err in inner scopes) to not trigger it. -
    -
    - 97 - -
    - - -
    -
    -
    - 98 - -
    - - - finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof) -
    -
    - 99 - -
    - - - if finalProofErr != nil { -
    -
    - 100 - -
    - - - // just log the error and continue to handle the generated proof -
    -
    - 101 - -
    - - - log.Errorf("Error trying to build final proof: %v", finalProofErr) -
    -
    - 102 - -
    - - - } -
    -
    - 103 - -
    - - -
    -
    -
    - 104 - -
    - - - // NOTE(pg): prover is done, use a.ctx from now on -
    -
    - 105 - -
    - - -
    -
    -
    - 106 - -
    - - - if !finalProofBuilt { -
    -
    - 107 - -
    - - - proof.GeneratingSince = nil -
    -
    - 108 - -
    - - -
    -
    -
    - 109 - -
    - - - // final proof has not been generated, update the batch proof -
    -
    - 110 - -
    - - - err := a.State.UpdateBatchProof(a.ctx, proof, nil) -
    -
    - 111 - -
    - - - if err != nil { -
    -
    - 112 - -
    - - - err = fmt.Errorf("failed to store batch proof result, %w", err) -
    -
    - 113 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 114 - -
    - - - return false, err -
    -
    - 115 - -
    - - - } -
    -
    - 116 - -
    - - - } -
    -
    - 117 - -
    - - -
    -
    -
    - 118 - -
    - - - return true, nil -
    -
    - 119 - -
    - - - } -
    -
    - 120 - -
    - - -
    -
    -
    - 121 - -
    - - - func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverInterface) (*state.Batch, *state.Proof, error) { -
    -
    - 122 - -
    - - - proverID := prover.ID() -
    -
    - 123 - -
    - - - proverName := prover.Name() -
    -
    - 124 - -
    - - -
    -
    -
    - 125 - -
    - - - log := log.WithFields( -
    -
    - 126 - -
    - - - "prover", proverName, -
    -
    - 127 - -
    - - - "proverId", proverID, -
    -
    - 128 - -
    - - - "proverAddr", prover.Addr(), -
    -
    - 129 - -
    - - - ) -
    -
    - 130 - -
    - - -
    -
    -
    - 131 - -
    - - - a.StateDBMutex.Lock() -
    -
    - 132 - -
    - - - defer a.StateDBMutex.Unlock() -
    -
    - 133 - -
    - - -
    -
    -
    - 134 - -
    - - - lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) -
    -
    - 135 - -
    - - - if err != nil { -
    -
    - 136 - -
    - - - return nil, nil, err -
    -
    - 137 - -
    - - - } -
    -
    - 138 - -
    - - -
    -
    -
    - 139 - -
    - - - // Get header of the last L1 block -
    -
    - 140 - -
    - - - lastL1BlockHeader, err := a.Ethman.GetLatestBlockHeader(ctx) -
    -
    - 141 - -
    - - - if err != nil { -
    -
    - 142 - -
    - - - log.Errorf("Failed to get last L1 block header, err: %v", err) -
    -
    - 143 - -
    - - - return nil, nil, err -
    -
    - 144 - -
    - - - } -
    -
    - 145 - -
    - - - lastL1BlockNumber := lastL1BlockHeader.Number.Uint64() -
    -
    - 146 - -
    - - -
    -
    -
    - 147 - -
    - - - // Calculate max L1 block number for getting next virtual batch to prove -
    -
    - 148 - -
    - - - maxL1BlockNumber := uint64(0) -
    -
    - 149 - -
    - - - if a.cfg.BatchProofL1BlockConfirmations <= lastL1BlockNumber { -
    -
    - 150 - -
    - - - maxL1BlockNumber = lastL1BlockNumber - a.cfg.BatchProofL1BlockConfirmations -
    -
    - 151 - -
    - - - } -
    -
    - 152 - -
    - - - log.Debugf("Max L1 block number for getting next virtual batch to prove: %d", maxL1BlockNumber) -
    -
    - 153 - -
    - - -
    -
    -
    - 154 - -
    - - - // Get virtual batch pending to generate proof -
    -
    - 155 - -
    - - - batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, maxL1BlockNumber, nil) -
    -
    - 156 - -
    - - - if err != nil { -
    -
    - 157 - -
    - - - return nil, nil, err -
    -
    - 158 - -
    - - - } -
    -
    - 159 - -
    - - -
    -
    -
    - 160 - -
    - - - log.Infof("Found virtual batch %d pending to generate proof", batchToVerify.BatchNumber) -
    -
    - 161 - -
    - - - log = log.WithFields("batch", batchToVerify.BatchNumber) -
    -
    - 162 - -
    - - -
    -
    -
    - 163 - -
    - - - log.Info("Checking profitability to aggregate batch") -
    -
    - 164 - -
    - - -
    -
    -
    - 165 - -
    - - - // pass pol collateral as zero here, bcs in smart contract fee for aggregator is not defined yet -
    -
    - 166 - -
    - - - isProfitable, err := a.ProfitabilityChecker.IsProfitable(ctx, big.NewInt(0)) -
    -
    - 167 - -
    - - - if err != nil { -
    -
    - 168 - -
    - - - log.Errorf("Failed to check aggregator profitability, err: %v", err) -
    -
    - 169 - -
    - - - return nil, nil, err -
    -
    - 170 - -
    - - - } -
    -
    - 171 - -
    - - -
    -
    -
    - 172 - -
    - - - if !isProfitable { -
    -
    - 173 - -
    - - - log.Infof("Batch is not profitable, pol collateral %d", big.NewInt(0)) -
    -
    - 174 - -
    - - - return nil, nil, err -
    -
    - 175 - -
    - - - } -
    -
    - 176 - -
    - - -
    -
    -
    - 177 - -
    - - - now := time.Now().Round(time.Microsecond) -
    -
    - 178 - -
    - - - proof := &state.Proof{ -
    -
    - 179 - -
    - - - BatchNumber: batchToVerify.BatchNumber, -
    -
    - 180 - -
    - - - BatchNumberFinal: batchToVerify.BatchNumber, -
    -
    - 181 - -
    - - - Prover: &proverName, -
    -
    - 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) -
    -
    - 292 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 293 - -
    - - - return false, err -
    -
    - 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 { -
    -
    - 306 - -
    - - - err := fmt.Errorf("failed to rollback proof aggregation state, %w", err) -
    -
    - 307 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 308 - -
    - - - return false, err -
    -
    - 309 - -
    - - - } -
    -
    - 310 - -
    - - - err = fmt.Errorf("failed to store the recursive proof, %w", err) -
    -
    - 311 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 312 - -
    - - - return false, err -
    -
    - 313 - -
    - - - } -
    -
    - 314 - -
    - - -
    -
    -
    - 315 - -
    - - - err = dbTx.Commit(ctx) -
    -
    - 316 - -
    - - - if err != nil { -
    -
    - 317 - -
    - - - err = fmt.Errorf("failed to store the recursive proof, %w", err) -
    -
    - 318 - -
    - - - log.Error(FirstToUpper(err.Error())) -
    -
    - 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) -
    -
    - 328 - -
    - - - if finalProofErr != nil { -
    -
    - 329 - -
    - - - // just log the error and continue to handle the aggregated proof -
    -
    - 330 - -
    - - - log.Errorf("Failed trying to check if recursive proof can be verified: %v", finalProofErr) -
    -
    - 331 - -
    - - - } -
    -
    - 332 - -
    - - -
    -
    -
    - 333 - -
    - - - // Prover is done, use a.ctx from now on -
    -
    - 334 - -
    - - -
    -
    -
    - 335 - -
    - - - if !finalProofBuilt { -
    -
    - 336 - -
    - - - proof.GeneratingSince = nil -
    -
    - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/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", -
    -
    -
    @@ -178,24 +178,28 @@
    -
    - 178 - -
    -   - expectedValue: uint64(80000), -
    -
    - 179 - -
    -   - }, -
    -
    - 180 - -
    -   - { -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 181 - -
    -   - path: "Etherman.URL", -
    -
    - 182 - -
    -   - expectedValue: "http://localhost:8545", -
    -
    - 183 - -
    -   - }, -
    -
    - 184 - -
    -   - { -
    -
    - 185 - -
    -   - path: "NetworkConfig.L1Config.L1ChainID", -
    -
    - 186 - -
    - - - expectedValue: uint64(5), -
    -
    - 187 - -
    -   - }, -
    -
    - 188 - -
    -   - { -
    -
    - 189 - -
    -   - path: "NetworkConfig.L1Config.ZkEVMAddr", -
    -
    - 190 - -
    - - - expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"), -
    -
    - 191 - -
    -   - }, -
    -
    - 192 - -
    -   - { -
    -
    - 193 - -
    -   - path: "NetworkConfig.L1Config.PolAddr", -
    -
    - 194 - -
    - - - expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"), -
    -
    - 195 - -
    -   - }, -
    -
    - 196 - -
    -   - { -
    -
    - 197 - -
    -   - path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", -
    -
    - 198 - -
    - - - expectedValue: common.HexToAddress("0x4d9427DCA0406358445bC0a8F88C26b704004f74"), -
    -
    - 199 - -
    -   - }, -
    -
    - 200 - -
    -   - { -
    -
    - 201 - -
    -   - path: "Etherman.MultiGasProvider", -
    -
    -
    @@ -551,7 +555,8 @@
    -
    - 551 - -
    -   - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) -
    -
    - 552 - -
    -   -
    -
    -
    - 553 - -
    -   - flagSet := flag.NewFlagSet("", flag.PanicOnError) -
    -
    - 554 - -
    - - - flagSet.String(config.FlagNetwork, "testnet", "") -
    -
    - - -
    -   -
    -
    -
    - 555 - -
    -   - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) -
    -
    - 556 - -
    -   - cfg, err := config.Load(ctx, true) -
    -
    - 557 - -
    -   - if err != nil { -
    -
    -
    @@ -589,7 +594,8 @@
    -
    - 589 - -
    -   - }() -
    -
    - 590 - -
    -   - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) -
    -
    - 591 - -
    -   - flagSet := flag.NewFlagSet("", flag.PanicOnError) -
    -
    - 592 - -
    - - - flagSet.String(config.FlagNetwork, "testnet", "") -
    -
    - - -
    -   -
    -
    -
    - 593 - -
    -   - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) -
    -
    - 594 - -
    -   -
    -
    -
    - 595 - -
    -   - 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", -
    -
    -
     
    -
    - 178 - -
    -   - expectedValue: uint64(80000), -
    -
    - 179 - -
    -   - }, -
    -
    - 180 - -
    -   - { -
    -
    - 181 - -
    - + - path: "SequenceSender.MaxBatchesForL1", -
    -
    - 182 - -
    - + - expectedValue: uint64(300), -
    -
    - 183 - -
    - + - }, -
    -
    - 184 - -
    - + - { -
    -
    - 185 - -
    -   - path: "Etherman.URL", -
    -
    - 186 - -
    -   - expectedValue: "http://localhost:8545", -
    -
    - 187 - -
    -   - }, -
    -
    - 188 - -
    -   - { -
    -
    - 189 - -
    -   - path: "NetworkConfig.L1Config.L1ChainID", -
    -
    - 190 - -
    - + - expectedValue: uint64(1337), -
    -
    - 191 - -
    -   - }, -
    -
    - 192 - -
    -   - { -
    -
    - 193 - -
    -   - path: "NetworkConfig.L1Config.ZkEVMAddr", -
    -
    - 194 - -
    - + - expectedValue: common.HexToAddress("0x8dAF17A20c9DBA35f005b6324F493785D239719d"), -
    -
    - 195 - -
    -   - }, -
    -
    - 196 - -
    -   - { -
    -
    - 197 - -
    -   - path: "NetworkConfig.L1Config.PolAddr", -
    -
    - 198 - -
    - + - expectedValue: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"), -
    -
    - 199 - -
    -   - }, -
    -
    - 200 - -
    -   - { -
    -
    - 201 - -
    -   - path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", -
    -
    - 202 - -
    - + - expectedValue: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), -
    -
    - 203 - -
    -   - }, -
    -
    - 204 - -
    -   - { -
    -
    - 205 - -
    -   - path: "Etherman.MultiGasProvider", -
    -
    -
     
    -
    - 555 - -
    -   - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) -
    -
    - 556 - -
    -   -
    -
    -
    - 557 - -
    -   - flagSet := flag.NewFlagSet("", flag.PanicOnError) -
    -
    - 558 - -
    - + - flagSet.String(config.FlagNetwork, "custom", "") -
    -
    - 559 - -
    - + - flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") -
    -
    - 560 - -
    -   - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) -
    -
    - 561 - -
    -   - cfg, err := config.Load(ctx, true) -
    -
    - 562 - -
    -   - if err != nil { -
    -
    -
     
    -
    - 594 - -
    -   - }() -
    -
    - 595 - -
    -   - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) -
    -
    - 596 - -
    -   - flagSet := flag.NewFlagSet("", flag.PanicOnError) -
    -
    - 597 - -
    - + - flagSet.String(config.FlagNetwork, "custom", "") -
    -
    - 598 - -
    - + - flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") -
    -
    - 599 - -
    -   - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) -
    -
    - 600 - -
    -   -
    -
    -
    - 601 - -
    -   - 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] -
    -
    -
    @@ -170,6 +170,7 @@
    -
    - 170 - -
    -   - L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" -
    -
    - 171 - -
    -   - PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} -
    -
    - 172 - -
    -   - GasOffset = 80000 -
    -
    - - -
    -   -
    -
    -
    - 173 - -
    -   -
    -
    -
    - 174 - -
    -   - [Aggregator] -
    -
    - 175 - -
    -   - Host = "0.0.0.0" -
    -
    -
    @@ -184,6 +185,10 @@
    -
    - 184 - -
    -   - GasOffset = 0 -
    -
    - 185 - -
    -   - UpgradeEtrogBatchNumber = 0 -
    -
    - 186 - -
    -   - BatchProofL1BlockConfirmations = 2 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 187 - -
    -   -
    -
    -
    - 188 - -
    -   - [L2GasPriceSuggester] -
    -
    - 189 - -
    -   - 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] -
    -
    -
     
    -
    - 170 - -
    -   - L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" -
    -
    - 171 - -
    -   - PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} -
    -
    - 172 - -
    -   - GasOffset = 80000 -
    -
    - 173 - -
    - + - MaxBatchesForL1 = 300 -
    -
    - 174 - -
    -   -
    -
    -
    - 175 - -
    -   - [Aggregator] -
    -
    - 176 - -
    -   - Host = "0.0.0.0" -
    -
    -
     
    -
    - 185 - -
    -   - GasOffset = 0 -
    -
    - 186 - -
    -   - UpgradeEtrogBatchNumber = 0 -
    -
    - 187 - -
    -   - BatchProofL1BlockConfirmations = 2 -
    -
    - 188 - -
    - + - SettlementBackend = "agglayer" -
    -
    - 189 - -
    - + - AggLayerTxTimeout = "5m" -
    -
    - 190 - -
    - + - AggLayerURL = "http://zkevm-agglayer" -
    -
    - 191 - -
    - + - SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} -
    -
    - 192 - -
    -   -
    -
    -
    - 193 - -
    -   - [L2GasPriceSuggester] -
    -
    - 194 - -
    -   - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
    @@ -5,4 +5,3 @@
    -
    - 5 - -
    -   - -- +migrate Down -
    -
    - 6 - -
    -   - ALTER TABLE state.batch -
    -
    - 7 - -
    -   - DROP COLUMN high_reserved_counters; -
    -
    - 8 - -
    - - - -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 5 - -
    -   - -- +migrate Down -
    -
    - 6 - -
    -   - ALTER TABLE state.batch -
    -
    - 7 - -
    -   - DROP COLUMN high_reserved_counters; -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022.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/0022_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 migrationTest0022TestCase struct { -
    -
    - 13 - -
    - - - Name string -
    -
    - 14 - -
    - - - Block migrationTest0022TestCaseBlock -
    -
    - 15 - -
    - - - } -
    -
    - 16 - -
    - - -
    -
    -
    - 17 - -
    - - - type migrationTest0022TestCaseBlock struct { -
    -
    - 18 - -
    - - - Transactions []migrationTest0022TestCaseTransaction -
    -
    - 19 - -
    - - - } -
    -
    - 20 - -
    - - -
    -
    -
    - 21 - -
    - - - type migrationTest0022TestCaseTransaction struct { -
    -
    - 22 - -
    - - - CurrentIndex uint -
    -
    - 23 - -
    - - - } -
    -
    - 24 - -
    - - -
    -
    -
    - 25 - -
    - - - type migrationTest0022 struct { -
    -
    - 26 - -
    - - - TestCases []migrationTest0022TestCase -
    -
    - 27 - -
    - - - } -
    -
    - 28 - -
    - - -
    -
    -
    - 29 - -
    - - - func (m migrationTest0022) 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 migrationTest0022) 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 migrationTest0022) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { -
    -
    - 89 - -
    - - - m.RunAssertsAfterMigrationUp(t, db) -
    -
    - 90 - -
    - - - } -
    -
    - 91 - -
    - - -
    -
    -
    - 92 - -
    - - - func TestMigration0022(t *testing.T) { -
    -
    - 93 - -
    - - - runMigrationTest(t, 22, migrationTest0022{ -
    -
    - 94 - -
    - - - TestCases: []migrationTest0022TestCase{ -
    -
    - 95 - -
    - - - { -
    -
    - 96 - -
    - - - Name: "single tx with correct index", -
    -
    - 97 - -
    - - - Block: migrationTest0022TestCaseBlock{ -
    -
    - 98 - -
    - - - Transactions: []migrationTest0022TestCaseTransaction{ -
    -
    - 99 - -
    - - - {CurrentIndex: 0}, -
    -
    - 100 - -
    - - - }, -
    -
    - 101 - -
    - - - }, -
    -
    - 102 - -
    - - - }, -
    -
    - 103 - -
    - - - { -
    -
    - 104 - -
    - - - Name: "multiple txs indexes are correct", -
    -
    - 105 - -
    - - - Block: migrationTest0022TestCaseBlock{ -
    -
    - 106 - -
    - - - Transactions: []migrationTest0022TestCaseTransaction{ -
    -
    - 107 - -
    - - - {CurrentIndex: 0}, -
    -
    - 108 - -
    - - - {CurrentIndex: 1}, -
    -
    - 109 - -
    - - - {CurrentIndex: 2}, -
    -
    - 110 - -
    - - - }, -
    -
    - 111 - -
    - - - }, -
    -
    - 112 - -
    - - - }, -
    -
    - 113 - -
    - - - { -
    -
    - 114 - -
    - - - Name: "single tx with wrong tx index", -
    -
    - 115 - -
    - - - Block: migrationTest0022TestCaseBlock{ -
    -
    - 116 - -
    - - - Transactions: []migrationTest0022TestCaseTransaction{ -
    -
    - 117 - -
    - - - {CurrentIndex: 3}, -
    -
    - 118 - -
    - - - }, -
    -
    - 119 - -
    - - - }, -
    -
    - 120 - -
    - - - }, -
    -
    - 121 - -
    - - - { -
    -
    - 122 - -
    - - - Name: "multiple txs missing 0 index", -
    -
    - 123 - -
    - - - Block: migrationTest0022TestCaseBlock{ -
    -
    - 124 - -
    - - - Transactions: []migrationTest0022TestCaseTransaction{ -
    -
    - 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: migrationTest0022TestCaseBlock{ -
    -
    - 135 - -
    - - - Transactions: []migrationTest0022TestCaseTransaction{ -
    -
    - 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/0023.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/0023_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 migrationTest0023 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 migrationTest0023) 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 migrationTest0023) 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 migrationTest0023) 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 migrationTest0023) 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 migrationTest0023) 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 migrationTest0023) 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 TestMigration0023(t *testing.T) { -
    -
    - 88 - -
    - - - m := migrationTest0023{ -
    -
    - 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, 23, m) -
    -
    - 106 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0024.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 - -
    - + - -- +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 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 → .}/docker-compose.yml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -107,7 +107,7 @@
    -
    - 107 - -
    -   - zkevm-prover: -
    -
    - 108 - -
    -   - container_name: zkevm-prover -
    -
    - 109 - -
    -   - restart: unless-stopped -
    -
    - 110 - -
    - - - image: hermeznetwork/zkevm-prover:v6.0.2-RC2 -
    -
    - 111 - -
    -   - depends_on: -
    -
    - 112 - -
    -   - zkevm-state-db: -
    -
    - 113 - -
    -   - condition: service_healthy -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 107 - -
    -   - zkevm-prover: -
    -
    - 108 - -
    -   - container_name: zkevm-prover -
    -
    - 109 - -
    -   - restart: unless-stopped -
    -
    - 110 - -
    - + - image: hermeznetwork/zkevm-prover:v6.0.0 -
    -
    - 111 - -
    -   - depends_on: -
    -
    - 112 - -
    -   - zkevm-state-db: -
    -
    - 113 - -
    -   - condition: service_healthy -
    -
    -
    -
    -
    -
    -
    -
    - - {/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 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -6,8 +6,6 @@
    -
    - 6 - -
    -   - type Config struct { -
    -
    - 7 - -
    -   - // URL is the URL of the Ethereum node for L1 -
    -
    - 8 - -
    -   - URL string `mapstructure:"URL"` -
    -
    - 9 - -
    - - - // ConsensusL1URL is the URL of the consensus L1 RPC endpoint -
    -
    - 10 - -
    - - - ConsensusL1URL string `mapstructure:"ConsensusL1URL"` -
    -
    - 11 - -
    -   -
    -
    -
    - 12 - -
    -   - // ForkIDChunkSize is the max interval for each call to L1 provider to get the forkIDs -
    -
    - 13 - -
    -   - ForkIDChunkSize uint64 `mapstructure:"ForkIDChunkSize"` -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 6 - -
    -   - type Config struct { -
    -
    - 7 - -
    -   - // URL is the URL of the Ethereum node for L1 -
    -
    - 8 - -
    -   - URL string `mapstructure:"URL"` -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 9 - -
    -   -
    -
    -
    - 10 - -
    -   - // ForkIDChunkSize is the max interval for each call to L1 provider to get the forkIDs -
    -
    - 11 - -
    -   - ForkIDChunkSize uint64 `mapstructure:"ForkIDChunkSize"` -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/eip4844/eip4844.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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, -
    -
    - 305 - -
    - - - EtrogGlobalExitRootManager: etrogGlobalExitRoot, -
    -
    - 306 - -
    - - - PreEtrogGlobalExitRootManager: preEtrogGlobalExitRoot, -
    -
    - 307 - -
    - - - SCAddresses: scAddresses, -
    -
    - 308 - -
    - - - RollupID: rollupID, -
    -
    - - -
    -   -
    -
    -
    - 309 - -
    -   - GasProviders: externalGasProviders{ -
    -
    - 310 - -
    -   - MultiGasProvider: cfg.MultiGasProvider, -
    -
    - 311 - -
    -   - Providers: gProviders, -
    -
    - 312 - -
    -   - }, -
    -
    - 313 - -
    - - - l1Cfg: l1Config, -
    -
    - 314 - -
    - - - cfg: cfg, -
    -
    - 315 - -
    - - - auth: map[common.Address]bind.TransactOpts{}, -
    -
    - 316 - -
    - - - EIP4844: eip4844, -
    -
    - 317 - -
    - - - } -
    -
    - 318 - -
    - - - if feijoaEnabled { -
    -
    - 319 - -
    - - - eventFeijoaManager := NewEventManager(client, NewCallDataExtratorGeth(ethClient)) -
    -
    - 320 - -
    - - - eventFeijoaManager.AddProcessor(NewEventFeijoaSequenceBlobsProcessor(feijoaContracts)) -
    -
    - 321 - -
    - - - client.eventFeijoaManager = eventFeijoaManager -
    -
    - 322 - -
    - - - } -
    -
    - 323 - -
    - - - return client, nil -
    -
    - 324 - -
    -   - } -
    -
    - 325 - -
    -   -
    -
    -
    - 326 - -
    -   - // VerifyGenBlockNumber verifies if the genesis Block Number is valid -
    -
    - 327 - -
    -   - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { -
    -
    - - -
    -   -
    -
    -
    - 328 - -
    -   - start := time.Now() -
    -
    - 329 - -
    -   - log.Info("Verifying genesis blockNumber: ", genBlockNumber) -
    -
    - 330 - -
    -   - // Filter query -
    -
    -
    @@ -342,11 +330,11 @@
    -
    - 342 - -
    -   - if len(logs) == 0 { -
    -
    - 343 - -
    -   - return false, fmt.Errorf("the specified genBlockNumber in config file does not contain any forkID event. Please use the proper blockNumber.") -
    -
    - 344 - -
    -   - } -
    -
    - 345 - -
    - - - var zkevmVersion preetrogpolygonzkevm.PreetrogpolygonzkevmUpdateZkEVMVersion -
    -
    - 346 - -
    -   - switch logs[0].Topics[0] { -
    -
    - 347 - -
    -   - case updateZkEVMVersionSignatureHash: -
    -
    - 348 - -
    -   - log.Debug("UpdateZkEVMVersion event detected during the Verification of the GenBlockNumber") -
    -
    - 349 - -
    - - - zkevmV, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(logs[0]) -
    -
    - 350 - -
    -   - if err != nil { -
    -
    - 351 - -
    -   - return false, err -
    -
    - 352 - -
    -   - } -
    -
    -
    @@ -355,12 +343,12 @@
    -
    - 355 - -
    -   - } -
    -
    - 356 - -
    -   - case createNewRollupSignatureHash: -
    -
    - 357 - -
    -   - log.Debug("CreateNewRollup event detected during the Verification of the GenBlockNumber") -
    -
    - 358 - -
    - - - createNewRollupEvent, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(logs[0]) -
    -
    - 359 - -
    -   - if err != nil { -
    -
    - 360 - -
    -   - return false, err -
    -
    - 361 - -
    -   - } -
    -
    - 362 - -
    -   - // Query to get the forkID -
    -
    - 363 - -
    - - - rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID) -
    -
    - 364 - -
    -   - if err != nil { -
    -
    - 365 - -
    -   - log.Error(err) -
    -
    - 366 - -
    -   - return false, err -
    -
    -
    @@ -375,36 +363,16 @@
    -
    - 375 - -
    -   - return true, nil -
    -
    - 376 - -
    -   - } -
    -
    - 377 - -
    -   -
    -
    -
    - 378 - -
    - - - // GetL1BlockUpgradeLxLy It returns the block genesis for LxLy before genesisBlock or error -
    -
    - 379 - -
    - - - // TODO: Check if all RPC providers support this range of blocks -
    -
    - 380 - -
    - - - func (etherMan *Client) GetL1BlockUpgradeLxLy(ctx context.Context, genesisBlock uint64) (uint64, error) { -
    -
    - 381 - -
    - - - it, err := etherMan.EtrogRollupManager.FilterInitialized(&bind.FilterOpts{ -
    -
    - 382 - -
    - - - Start: 1, -
    -
    - 383 - -
    - - - End: &genesisBlock, -
    -
    - 384 - -
    - - - Context: ctx, -
    -
    - 385 - -
    - - - }) -
    -
    - 386 - -
    - - - if err != nil { -
    -
    - 387 - -
    - - - return uint64(0), err -
    -
    - 388 - -
    - - - } -
    -
    - 389 - -
    - - - for it.Next() { -
    -
    - 390 - -
    - - - log.Debugf("BlockNumber: %d Topics:Initialized(%d)", it.Event.Raw.BlockNumber, it.Event.Version) -
    -
    - 391 - -
    - - - if it.Event.Version == ETrogUpgradeVersion { // 2 is ETROG (LxLy upgrade) -
    -
    - 392 - -
    - - - log.Infof("LxLy upgrade found at blockNumber: %d", it.Event.Raw.BlockNumber) -
    -
    - 393 - -
    - - - return it.Event.Raw.BlockNumber, nil -
    -
    - 394 - -
    - - - } -
    -
    - 395 - -
    - - - } -
    -
    - 396 - -
    - - - return uint64(0), ErrNotFound -
    -
    - 397 - -
    - - - } -
    -
    - 398 - -
    - - -
    -
    -
    - 399 - -
    -   - // GetForks returns fork information -
    -
    - 400 - -
    -   - func (etherMan *Client) GetForks(ctx context.Context, genBlockNumber uint64, lastL1BlockSynced uint64) ([]state.ForkIDInterval, error) { -
    -
    - 401 - -
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) -
    -
    - 402 - -
    -   - start := time.Now() -
    -
    - 403 - -
    -   - var logs []types.Log -
    -
    - 404 - -
    - - - // At minimum it checks the GenesisBlock -
    -
    - 405 - -
    -   - if lastL1BlockSynced < genBlockNumber { -
    -
    - 406 - -
    -   - lastL1BlockSynced = genBlockNumber -
    -
    - 407 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - 408 - -
    -   - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) -
    -
    - 409 - -
    -   - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { -
    -
    - 410 - -
    -   - final := i + etherMan.cfg.ForkIDChunkSize -
    -
    -
    @@ -429,11 +397,11 @@
    -
    - 429 - -
    -   -
    -
    -
    - 430 - -
    -   - var forks []state.ForkIDInterval -
    -
    - 431 - -
    -   - for i, l := range logs { -
    -
    - 432 - -
    - - - var zkevmVersion preetrogpolygonzkevm.PreetrogpolygonzkevmUpdateZkEVMVersion -
    -
    - 433 - -
    -   - switch l.Topics[0] { -
    -
    - 434 - -
    -   - case updateZkEVMVersionSignatureHash: -
    -
    - 435 - -
    -   - log.Debug("updateZkEVMVersion Event received") -
    -
    - 436 - -
    - - - zkevmV, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(l) -
    -
    - 437 - -
    -   - if err != nil { -
    -
    - 438 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 439 - -
    -   - } -
    -
    -
    @@ -442,7 +410,7 @@
    -
    - 442 - -
    -   - } -
    -
    - 443 - -
    -   - case updateRollupSignatureHash: -
    -
    - 444 - -
    -   - log.Debug("updateRollup Event received") -
    -
    - 445 - -
    - - - updateRollupEvent, err := etherMan.EtrogRollupManager.ParseUpdateRollup(l) -
    -
    - 446 - -
    -   - if err != nil { -
    -
    - 447 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 448 - -
    -   - } -
    -
    -
    @@ -450,7 +418,7 @@
    -
    - 450 - -
    -   - continue -
    -
    - 451 - -
    -   - } -
    -
    - 452 - -
    -   - // Query to get the forkID -
    -
    - 453 - -
    - - - rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollupEvent.NewRollupTypeID) -
    -
    - 454 - -
    -   - if err != nil { -
    -
    - 455 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 456 - -
    -   - } -
    -
    -
    @@ -459,7 +427,7 @@
    -
    - 459 - -
    -   -
    -
    -
    - 460 - -
    -   - case addExistingRollupSignatureHash: -
    -
    - 461 - -
    -   - log.Debug("addExistingRollup Event received") -
    -
    - 462 - -
    - - - addExistingRollupEvent, err := etherMan.EtrogRollupManager.ParseAddExistingRollup(l) -
    -
    - 463 - -
    -   - if err != nil { -
    -
    - 464 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 465 - -
    -   - } -
    -
    -
    @@ -471,7 +439,7 @@
    -
    - 471 - -
    -   -
    -
    -
    - 472 - -
    -   - case createNewRollupSignatureHash: -
    -
    - 473 - -
    -   - log.Debug("createNewRollup Event received") -
    -
    - 474 - -
    - - - createNewRollupEvent, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(l) -
    -
    - 475 - -
    -   - if err != nil { -
    -
    - 476 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 477 - -
    -   - } -
    -
    -
    @@ -479,7 +447,7 @@
    -
    - 479 - -
    -   - continue -
    -
    - 480 - -
    -   - } -
    -
    - 481 - -
    -   - // Query to get the forkID -
    -
    - 482 - -
    - - - rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID) -
    -
    - 483 - -
    -   - if err != nil { -
    -
    - 484 - -
    -   - log.Error(err) -
    -
    - 485 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    -
    @@ -531,25 +499,6 @@
    -
    - 531 - -
    -   - return blocks, blocksOrder, nil -
    -
    - 532 - -
    -   - } -
    -
    - 533 - -
    -   -
    -
    -
    - 534 - -
    - - - // GetRollupInfoByBlockRangePreviousRollupGenesis function retrieves the Rollup information that are included in all this ethereum blocks -
    -
    - 535 - -
    - - - // but it only retrieves the information from the previous rollup genesis block to the current block. -
    -
    - 536 - -
    - - - func (etherMan *Client) GetRollupInfoByBlockRangePreviousRollupGenesis(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]Block, map[common.Hash][]Order, error) { -
    -
    - 537 - -
    - - - // Filter query -
    -
    - 538 - -
    - - - query := ethereum.FilterQuery{ -
    -
    - 539 - -
    - - - FromBlock: new(big.Int).SetUint64(fromBlock), -
    -
    - 540 - -
    - - - Addresses: []common.Address{etherMan.l1Cfg.GlobalExitRootManagerAddr}, -
    -
    - 541 - -
    - - - Topics: [][]common.Hash{{updateL1InfoTreeSignatureHash}}, -
    -
    - 542 - -
    - - - } -
    -
    - 543 - -
    - - - if toBlock != nil { -
    -
    - 544 - -
    - - - query.ToBlock = new(big.Int).SetUint64(*toBlock) -
    -
    - 545 - -
    - - - } -
    -
    - 546 - -
    - - - blocks, blocksOrder, err := etherMan.readEvents(ctx, query) -
    -
    - 547 - -
    - - - if err != nil { -
    -
    - 548 - -
    - - - return nil, nil, err -
    -
    - 549 - -
    - - - } -
    -
    - 550 - -
    - - - return blocks, blocksOrder, nil -
    -
    - 551 - -
    - - - } -
    -
    - 552 - -
    - - -
    -
    -
    - 553 - -
    -   - // Order contains the event order to let the synchronizer store the information following this order. -
    -
    - 554 - -
    -   - type Order struct { -
    -
    - 555 - -
    -   - Name EventOrder -
    -
    -
    @@ -580,17 +529,8 @@
    -
    - 580 - -
    -   - metrics.ReadAndProcessAllEventsTime(time.Since(start)) -
    -
    - 581 - -
    -   - return blocks, blocksOrder, nil -
    -
    - 582 - -
    -   - } -
    -
    - 583 - -
    - - - func (etherMan *Client) processEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 584 - -
    - - - if etherMan.eventFeijoaManager != nil { -
    -
    - 585 - -
    - - - processed, err := etherMan.eventFeijoaManager.ProcessEvent(ctx, vLog, blocks, blocksOrder) -
    -
    - 586 - -
    - - - if processed || err != nil { -
    -
    - 587 - -
    - - - return err -
    -
    - 588 - -
    - - - } -
    -
    - 589 - -
    - - - } -
    -
    - 590 - -
    - - - return etherMan.processEventLegacy(ctx, vLog, blocks, blocksOrder) -
    -
    - 591 - -
    - - - } -
    -
    - 592 - -
    -   -
    -
    -
    - 593 - -
    - - - func (etherMan *Client) processEventLegacy(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 594 - -
    -   - switch vLog.Topics[0] { -
    -
    - 595 - -
    -   - case sequenceBatchesSignatureHash: -
    -
    - 596 - -
    -   - return etherMan.sequencedBatchesEvent(ctx, vLog, blocks, blocksOrder) -
    -
    -
    @@ -612,8 +552,8 @@
    -
    - 612 - -
    -   - case rollupManagerVerifyBatchesSignatureHash: -
    -
    - 613 - -
    -   - log.Debug("RollupManagerVerifyBatches event detected. Ignoring...") -
    -
    - 614 - -
    -   - return nil -
    -
    - 615 - -
    - - - case preEtrogVerifyBatchesTrustedAggregatorSignatureHash: -
    -
    - 616 - -
    - - - return etherMan.preEtrogVerifyBatchesTrustedAggregatorEvent(ctx, vLog, blocks, blocksOrder) -
    -
    - 617 - -
    -   - case verifyBatchesSignatureHash: -
    -
    - 618 - -
    -   - return etherMan.verifyBatchesEvent(ctx, vLog, blocks, blocksOrder) -
    -
    - 619 - -
    -   - case sequenceForceBatchesSignatureHash: -
    -
    -
    @@ -653,8 +593,8 @@
    -
    - 653 - -
    -   - case consolidatePendingStateSignatureHash: -
    -
    - 654 - -
    -   - log.Debug("ConsolidatePendingState event detected. Ignoring...") -
    -
    - 655 - -
    -   - return nil -
    -
    - 656 - -
    - - - case preEtrogConsolidatePendingStateSignatureHash: -
    -
    - 657 - -
    - - - log.Debug("PreEtrogConsolidatePendingState event detected. Ignoring...") -
    -
    - 658 - -
    -   - return nil -
    -
    - 659 - -
    -   - case setTrustedAggregatorTimeoutSignatureHash: -
    -
    - 660 - -
    -   - log.Debug("SetTrustedAggregatorTimeout event detected. Ignoring...") -
    -
    -
    @@ -689,8 +629,8 @@
    -
    - 689 - -
    -   - case overridePendingStateSignatureHash: -
    -
    - 690 - -
    -   - log.Debug("OverridePendingState event detected. Ignoring...") -
    -
    - 691 - -
    -   - return nil -
    -
    - 692 - -
    - - - case preEtrogOverridePendingStateSignatureHash: -
    -
    - 693 - -
    - - - log.Debug("PreEtrogOverridePendingState event detected. Ignoring...") -
    -
    - 694 - -
    -   - return nil -
    -
    - 695 - -
    -   - case roleAdminChangedSignatureHash: -
    -
    - 696 - -
    -   - log.Debug("RoleAdminChanged event detected. Ignoring...") -
    -
    -
    @@ -726,7 +666,7 @@
    -
    - 726 - -
    -   -
    -
    -
    - 727 - -
    -   - func (etherMan *Client) updateZkevmVersion(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 728 - -
    -   - log.Debug("UpdateZkEVMVersion event detected") -
    -
    - 729 - -
    - - - zkevmVersion, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(vLog) -
    -
    - 730 - -
    -   - if err != nil { -
    -
    - 731 - -
    -   - log.Error("error parsing UpdateZkEVMVersion event. Error: ", err) -
    -
    - 732 - -
    -   - return err -
    -
    -
    @@ -736,12 +676,12 @@
    -
    - 736 - -
    -   -
    -
    -
    - 737 - -
    -   - func (etherMan *Client) updateRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 738 - -
    -   - log.Debug("UpdateRollup event detected") -
    -
    - 739 - -
    - - - updateRollup, err := etherMan.EtrogRollupManager.ParseUpdateRollup(vLog) -
    -
    - 740 - -
    -   - if err != nil { -
    -
    - 741 - -
    -   - log.Error("error parsing UpdateRollup event. Error: ", err) -
    -
    - 742 - -
    -   - return err -
    -
    - 743 - -
    -   - } -
    -
    - 744 - -
    - - - rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollup.NewRollupTypeID) -
    -
    - 745 - -
    -   - if err != nil { -
    -
    - 746 - -
    -   - return err -
    -
    - 747 - -
    -   - } -
    -
    -
    @@ -750,12 +690,12 @@
    -
    - 750 - -
    -   -
    -
    -
    - 751 - -
    -   - func (etherMan *Client) createNewRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 752 - -
    -   - log.Debug("createNewRollup event detected") -
    -
    - 753 - -
    - - - createRollup, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(vLog) -
    -
    - 754 - -
    -   - if err != nil { -
    -
    - 755 - -
    -   - log.Error("error parsing createNewRollup event. Error: ", err) -
    -
    - 756 - -
    -   - return err -
    -
    - 757 - -
    -   - } -
    -
    - 758 - -
    - - - rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createRollup.RollupTypeID) -
    -
    - 759 - -
    -   - if err != nil { -
    -
    - 760 - -
    -   - return err -
    -
    - 761 - -
    -   - } -
    -
    -
    @@ -764,7 +704,7 @@
    -
    - 764 - -
    -   -
    -
    -
    - 765 - -
    -   - func (etherMan *Client) addExistingRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 766 - -
    -   - log.Debug("addExistingRollup event detected") -
    -
    - 767 - -
    - - - addExistingRollup, err := etherMan.EtrogRollupManager.ParseAddExistingRollup(vLog) -
    -
    - 768 - -
    -   - if err != nil { -
    -
    - 769 - -
    -   - log.Error("error parsing createNewRollup event. Error: ", err) -
    -
    - 770 - -
    -   - return err -
    -
    -
    @@ -773,66 +713,13 @@
    -
    - 773 - -
    -   - return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID) -
    -
    - 774 - -
    -   - } -
    -
    - 775 - -
    -   -
    -
    -
    - 776 - -
    - - - func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 777 - -
    - - - log.Debug("updateEtrogSequence event detected") -
    -
    - 778 - -
    - - - updateEtrogSequence, err := etherMan.ElderberryZKEVM.ParseUpdateEtrogSequence(vLog) -
    -
    - 779 - -
    - - - if err != nil { -
    -
    - 780 - -
    - - - log.Error("error parsing updateEtrogSequence event. Error: ", err) -
    -
    - 781 - -
    - - - return err -
    -
    - 782 - -
    - - - } -
    -
    - 783 - -
    - - -
    -
    -
    - 784 - -
    - - - // Read the tx for this event. -
    -
    - 785 - -
    - - - tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) -
    -
    - 786 - -
    - - - if err != nil { -
    -
    - 787 - -
    - - - return err -
    -
    - 788 - -
    - - - } -
    -
    - 789 - -
    - - - if tx.Hash() != vLog.TxHash { -
    -
    - 790 - -
    - - - return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String()) -
    -
    - 791 - -
    - - - } -
    -
    - 792 - -
    - - - msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0)) -
    -
    - 793 - -
    - - - if err != nil { -
    -
    - 794 - -
    - - - return err -
    -
    - 795 - -
    - - - } -
    -
    - 796 - -
    - - - fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash) -
    -
    - 797 - -
    - - - if err != nil { -
    -
    - 798 - -
    - - - return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err) -
    -
    - 799 - -
    - - - } -
    -
    - 800 - -
    - - -
    -
    -
    - 801 - -
    - - - log.Info("update Etrog transaction sequence...") -
    -
    - 802 - -
    - - - sequence := UpdateEtrogSequence{ -
    -
    - 803 - -
    - - - BatchNumber: updateEtrogSequence.NumBatch, -
    -
    - 804 - -
    - - - SequencerAddr: updateEtrogSequence.Sequencer, -
    -
    - 805 - -
    - - - TxHash: vLog.TxHash, -
    -
    - 806 - -
    - - - Nonce: msg.Nonce, -
    -
    - 807 - -
    - - - PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ -
    -
    - 808 - -
    - - - Transactions: updateEtrogSequence.Transactions, -
    -
    - 809 - -
    - - - ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot, -
    -
    - 810 - -
    - - - ForcedTimestamp: fullBlock.Time(), -
    -
    - 811 - -
    - - - ForcedBlockHashL1: fullBlock.ParentHash(), -
    -
    - 812 - -
    - - - }, -
    -
    - 813 - -
    - - - } -
    -
    - 814 - -
    - - -
    -
    -
    - 815 - -
    - - - if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { -
    -
    - 816 - -
    - - - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) -
    -
    - 817 - -
    - - - block.UpdateEtrogSequence = sequence -
    -
    - 818 - -
    - - - *blocks = append(*blocks, block) -
    -
    - 819 - -
    - - - } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { -
    -
    - 820 - -
    - - - (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence -
    -
    - 821 - -
    - - - } else { -
    -
    - 822 - -
    - - - log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber) -
    -
    - 823 - -
    - - - return fmt.Errorf("error processing UpdateEtrogSequence event") -
    -
    - 824 - -
    - - - } -
    -
    - 825 - -
    - - - or := Order{ -
    -
    - 826 - -
    - - - Name: UpdateEtrogSequenceOrder, -
    -
    - 827 - -
    - - - Pos: 0, -
    -
    - 828 - -
    - - - } -
    -
    - 829 - -
    - - - (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or) -
    -
    - 830 - -
    - - - return nil -
    -
    - 831 - -
    -   - } -
    -
    - 832 - -
    -   -
    -
    -
    - 833 - -
    -   - func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 834 - -
    -   - log.Debug("initialSequenceBatches event detected") -
    -
    - 835 - -
    - - - initialSequenceBatches, err := etherMan.EtrogZkEVM.ParseInitialSequenceBatches(vLog) -
    -
    - 836 - -
    -   - if err != nil { -
    -
    - 837 - -
    -   - log.Error("error parsing initialSequenceBatches event. Error: ", err) -
    -
    - 838 - -
    -   - return err -
    -
    -
    @@ -862,7 +749,7 @@
    -
    - 862 - -
    -   - SequencerAddr: initialSequenceBatches.Sequencer, -
    -
    - 863 - -
    -   - TxHash: vLog.TxHash, -
    -
    - 864 - -
    -   - Nonce: msg.Nonce, -
    -
    - 865 - -
    - - - PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ -
    -
    - 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 @@
    -
    - 1276 - -
    -   - func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1277 - -
    -   - log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:])) -
    -
    - 1278 - -
    -   -
    -
    -
    - 1279 - -
    - - - sb, err := etherMan.EtrogZkEVM.ParseSequenceBatches(vLog) -
    -
    - 1280 - -
    -   - if err != nil { -
    -
    - 1281 - -
    -   - return err -
    -
    - 1282 - -
    -   - } -
    -
    -
    @@ -1289,7 +1175,7 @@
    -
    - 1289 - -
    -   - if tx.Hash() != vLog.TxHash { -
    -
    - 1290 - -
    -   - return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String()) -
    -
    - 1291 - -
    -   - } -
    -
    - 1292 - -
    - - - msg, err := core.TransactionToMessage(tx, types.NewCancunSigner(tx.ChainId()), big.NewInt(0)) -
    -
    - 1293 - -
    -   - if err != nil { -
    -
    - 1294 - -
    -   - return err -
    -
    - 1295 - -
    -   - } -
    -
    -
    @@ -1298,13 +1184,15 @@
    -
    - 1298 - -
    -   - if sb.NumBatch != 1 { -
    -
    - 1299 - -
    -   - methodId := tx.Data()[:4] -
    -
    - 1300 - -
    -   - log.Debugf("MethodId: %s", common.Bytes2Hex(methodId)) -
    -
    - 1301 - -
    - - - if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) { -
    -
    - 1302 - -
    - - - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) -
    -
    - - -
    -   -
    -
    -
    - 1303 - -
    -   - if err != nil { -
    -
    - 1304 - -
    -   - return fmt.Errorf("error decoding the sequences (etrog): %v", err) -
    -
    - 1305 - -
    -   - } -
    -
    - 1306 - -
    - - - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) { -
    -
    - 1307 - -
    - - - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) -
    -
    - - -
    -   -
    -
    -
    - 1308 - -
    -   - if err != nil { -
    -
    - 1309 - -
    -   - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) -
    -
    - 1310 - -
    -   - } -
    -
    -
    @@ -1345,7 +1233,7 @@
    -
    - 1345 - -
    -   -
    -
    -
    - 1346 - -
    -   - func (etherMan *Client) sequencedBatchesPreEtrogEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1347 - -
    -   - log.Debug("Pre etrog SequenceBatches event detected") -
    -
    - 1348 - -
    - - - sb, err := etherMan.PreEtrogZkEVM.ParseSequenceBatches(vLog) -
    -
    - 1349 - -
    -   - if err != nil { -
    -
    - 1350 - -
    -   - return err -
    -
    - 1351 - -
    -   - } -
    -
    -
    @@ -1390,7 +1278,20 @@
    -
    - 1390 - -
    -   - return nil -
    -
    - 1391 - -
    -   - } -
    -
    - 1392 - -
    -   -
    -
    -
    - 1393 - -
    - - - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1394 - -
    -   - // Extract coded txs. -
    -
    - 1395 - -
    -   - // Load contract ABI -
    -
    - 1396 - -
    -   - smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) -
    -
    -
    @@ -1398,6 +1299,13 @@
    -
    - 1398 - -
    -   - return nil, err -
    -
    - 1399 - -
    -   - } -
    -
    - 1400 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1401 - -
    -   - // Recover Method from signature and ABI -
    -
    - 1402 - -
    -   - method, err := smcAbi.MethodById(txData[:4]) -
    -
    - 1403 - -
    -   - if err != nil { -
    -
    -
    @@ -1409,93 +1317,218 @@
    -
    - 1409 - -
    -   - if err != nil { -
    -
    - 1410 - -
    -   - return nil, err -
    -
    - 1411 - -
    -   - } -
    -
    - 1412 - -
    - - - var sequences []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 1413 - -
    -   - bytedata, err := json.Marshal(data[0]) -
    -
    - 1414 - -
    -   - if err != nil { -
    -
    - 1415 - -
    -   - return nil, err -
    -
    - 1416 - -
    -   - } -
    -
    - 1417 - -
    - - - err = json.Unmarshal(bytedata, &sequences) -
    -
    - 1418 - -
    - - - if err != nil { -
    -
    - 1419 - -
    - - - return nil, err -
    -
    - 1420 - -
    - - - } -
    -
    - 1421 - -
    - - - maxSequenceTimestamp := data[1].(uint64) -
    -
    - 1422 - -
    - - - initSequencedBatchNumber := data[2].(uint64) -
    -
    - 1423 - -
    - - - coinbase := (data[3]).(common.Address) -
    -
    - 1424 - -
    - - - sequencedBatches := make([]SequencedBatch, len(sequences)) -
    -
    - 1425 - -
    -   -
    -
    -
    - 1426 - -
    - - - for i, seq := range sequences { -
    -
    - 1427 - -
    - - - elderberry := SequencedBatchElderberryData{ -
    -
    - 1428 - -
    - - - MaxSequenceTimestamp: maxSequenceTimestamp, -
    -
    - 1429 - -
    - - - InitSequencedBatchNumber: initSequencedBatchNumber, -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1430 - -
    -   - } -
    -
    - 1431 - -
    - - - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) -
    -
    - 1432 - -
    - - - s := seq -
    -
    - 1433 - -
    - - - sequencedBatches[i] = SequencedBatch{ -
    -
    - 1434 - -
    - - - BatchNumber: bn, -
    -
    - 1435 - -
    - - - L1InfoRoot: &l1InfoRoot, -
    -
    - 1436 - -
    - - - SequencerAddr: sequencer, -
    -
    - 1437 - -
    - - - TxHash: txHash, -
    -
    - 1438 - -
    - - - Nonce: nonce, -
    -
    - 1439 - -
    - - - Coinbase: coinbase, -
    -
    - 1440 - -
    - - - PolygonRollupBaseEtrogBatchData: &s, -
    -
    - 1441 - -
    - - - SequencedBatchElderberryData: &elderberry, -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1442 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1443 - -
    -   - } -
    -
    - 1444 - -
    -   -
    -
    -
    - 1445 - -
    - - - return sequencedBatches, nil -
    -
    - 1446 - -
    -   - } -
    -
    - 1447 - -
    -   -
    -
    -
    - 1448 - -
    - - - func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { -
    -
    - 1449 - -
    - - - // Extract coded txs. -
    -
    - 1450 - -
    - - - // Load contract ABI -
    -
    - 1451 - -
    - - - smcAbi, err := abi.JSON(strings.NewReader(elderberrypolygonzkevm.ElderberrypolygonzkevmABI)) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1452 - -
    -   - if err != nil { -
    -
    - 1453 - -
    -   - return nil, err -
    -
    - 1454 - -
    -   - } -
    -
    - 1455 - -
    - - -
    -
    -
    - 1456 - -
    - - - // Recover Method from signature and ABI -
    -
    - 1457 - -
    - - - method, err := smcAbi.MethodById(txData[:4]) -
    -
    - 1458 - -
    -   - if err != nil { -
    -
    - 1459 - -
    -   - return nil, err -
    -
    - 1460 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1461 - -
    -   -
    -
    -
    - 1462 - -
    - - - // Unpack method inputs -
    -
    - 1463 - -
    - - - data, err := method.Inputs.Unpack(txData[4:]) -
    -
    - 1464 - -
    - - - if err != nil { -
    -
    - 1465 - -
    - - - return nil, err -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1466 - -
    -   - } -
    -
    - 1467 - -
    - - - var sequences []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 1468 - -
    - - - bytedata, err := json.Marshal(data[0]) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1469 - -
    -   - if err != nil { -
    -
    - 1470 - -
    -   - return nil, err -
    -
    - 1471 - -
    -   - } -
    -
    - 1472 - -
    - - - err = json.Unmarshal(bytedata, &sequences) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1473 - -
    -   - if err != nil { -
    -
    - 1474 - -
    -   - return nil, err -
    -
    - 1475 - -
    -   - } -
    -
    - 1476 - -
    - - - coinbase := (data[1]).(common.Address) -
    -
    - 1477 - -
    - - - sequencedBatches := make([]SequencedBatch, len(sequences)) -
    -
    - 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 - -
    - - - TxHash: txHash, -
    -
    - 1486 - -
    - - - Nonce: nonce, -
    -
    - 1487 - -
    - - - Coinbase: coinbase, -
    -
    - 1488 - -
    - - - PolygonRollupBaseEtrogBatchData: &s, -
    -
    - 1489 - -
    -   - } -
    -
    - 1490 - -
    -   - } -
    -
    - 1491 - -
    - - -
    -
    -
    - 1492 - -
    - - - return sequencedBatches, nil -
    -
    - 1493 - -
    -   - } -
    -
    - 1494 - -
    -   -
    -
    -
    - 1495 - -
    -   - func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { -
    -
    - 1496 - -
    -   - // Extract coded txs. -
    -
    - 1497 - -
    -   - // Load contract ABI -
    -
    - 1498 - -
    - - - smcAbi, err := abi.JSON(strings.NewReader(preetrogpolygonzkevm.PreetrogpolygonzkevmABI)) -
    -
    - 1499 - -
    -   - if err != nil { -
    -
    - 1500 - -
    -   - return nil, err -
    -
    - 1501 - -
    -   - } -
    -
    -
    @@ -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") -
    -
    - 1543 - -
    - - - var vb *preetrogpolygonzkevm.PreetrogpolygonzkevmVerifyBatchesTrustedAggregator -
    -
    - 1544 - -
    - - - vb, err := etherMan.PreEtrogZkEVM.ParseVerifyBatchesTrustedAggregator(vLog) -
    -
    - 1545 - -
    -   - if err != nil { -
    -
    - 1546 - -
    -   - log.Error("error parsing TrustedVerifyBatches event. Error: ", err) -
    -
    - 1547 - -
    -   - return err -
    -
    -
    @@ -1551,7 +1584,7 @@
    -
    - 1551 - -
    -   -
    -
    -
    - 1552 - -
    -   - func (etherMan *Client) verifyBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1553 - -
    -   - log.Debug("VerifyBatches event detected") -
    -
    - 1554 - -
    - - - vb, err := etherMan.EtrogZkEVM.ParseVerifyBatches(vLog) -
    -
    - 1555 - -
    -   - if err != nil { -
    -
    - 1556 - -
    -   - log.Error("error parsing VerifyBatches event. Error: ", err) -
    -
    - 1557 - -
    -   - return err -
    -
    -
    @@ -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 - -
    -   - } -
    -
    - 1823 - -
    -   -
    -
    -
    - 1824 - -
    -   - // GetL2ChainID returns L2 Chain ID -
    -
    - 1825 - -
    -   - func (etherMan *Client) GetL2ChainID() (uint64, error) { -
    -
    - 1826 - -
    - - - chainID, err := etherMan.PreEtrogZkEVM.ChainID(&bind.CallOpts{Pending: false}) -
    -
    - 1827 - -
    - - - log.Debug("chainID read from preEtrogZkevm: ", chainID) -
    -
    - 1828 - -
    -   - if err != nil || chainID == 0 { -
    -
    - 1829 - -
    - - - log.Debug("error from preEtrogZkevm: ", err) -
    -
    - 1830 - -
    - - - rollupData, err := etherMan.EtrogRollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID) -
    -
    - 1831 - -
    - - - log.Debugf("ChainID read from EtrogRollupManager: %d using rollupID: %d", rollupData.ChainID, etherMan.RollupID) -
    -
    - 1832 - -
    -   - if err != nil { -
    -
    - 1833 - -
    - - - log.Debug("error from EtrogRollupManager: ", err) -
    -
    - 1834 - -
    -   - return 0, err -
    -
    - 1835 - -
    -   - } else if rollupData.ChainID == 0 { -
    -
    - 1836 - -
    -   - return rollupData.ChainID, fmt.Errorf("error: chainID received is 0!!") -
    -
    -
    @@ -1861,11 +1916,6 @@
    -
    - 1861 - -
    -   - return etherMan.EthClient.SendTransaction(ctx, tx) -
    -
    - 1862 - -
    -   - } -
    -
    - 1863 - -
    -   -
    -
    -
    - 1864 - -
    - - - // PendingNonce returns the pending nonce for the provided account -
    -
    - 1865 - -
    - - - func (etherMan *Client) PendingNonce(ctx context.Context, account common.Address) (uint64, error) { -
    -
    - 1866 - -
    - - - return etherMan.EthClient.PendingNonceAt(ctx, account) -
    -
    - 1867 - -
    - - - } -
    -
    - 1868 - -
    - - -
    -
    -
    - 1869 - -
    -   - // CurrentNonce returns the current nonce for the provided account -
    -
    - 1870 - -
    -   - func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error) { -
    -
    - 1871 - -
    -   - return etherMan.EthClient.NonceAt(ctx, account, nil) -
    -
    -
    @@ -1898,7 +1948,7 @@
    -
    - 1898 - -
    -   - opts.BlockNumber = new(big.Int).SetUint64(*blockNumber) -
    -
    - 1899 - -
    -   - } -
    -
    - 1900 - -
    -   -
    -
    -
    - 1901 - -
    - - - return etherman.EtrogGlobalExitRootManager.DepositCount(opts) -
    -
    - 1902 - -
    -   - } -
    -
    - 1903 - -
    -   -
    -
    -
    - 1904 - -
    -   - // CheckTxWasMined check if a tx was already mined -
    -
    -
    @@ -1955,15 +2005,15 @@
    -
    - 1955 - -
    -   - } -
    -
    - 1956 - -
    -   -
    -
    -
    - 1957 - -
    -   - // LoadAuthFromKeyStore loads an authorization from a key store file -
    -
    - 1958 - -
    - - - func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) { -
    -
    - 1959 - -
    - - - auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID) -
    -
    - 1960 - -
    -   - if err != nil { -
    -
    - 1961 - -
    - - - return nil, err -
    -
    - 1962 - -
    -   - } -
    -
    - 1963 - -
    -   -
    -
    -
    - 1964 - -
    -   - log.Infof("loaded authorization for address: %v", auth.From.String()) -
    -
    - 1965 - -
    -   - etherMan.auth[auth.From] = auth -
    -
    - 1966 - -
    - - - return &auth, nil -
    -
    - 1967 - -
    -   - } -
    -
    - 1968 - -
    -   -
    -
    -
    - 1969 - -
    -   - // newKeyFromKeystore creates an instance of a keystore key from a keystore file -
    -
    -
    @@ -1984,20 +2034,20 @@
    -
    - 1984 - -
    -   - } -
    -
    - 1985 - -
    -   -
    -
    -
    - 1986 - -
    -   - // newAuthFromKeystore an authorization instance from a keystore file -
    -
    - 1987 - -
    - - - func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) { -
    -
    - 1988 - -
    -   - log.Infof("reading key from: %v", path) -
    -
    - 1989 - -
    -   - key, err := newKeyFromKeystore(path, password) -
    -
    - 1990 - -
    -   - if err != nil { -
    -
    - 1991 - -
    - - - return bind.TransactOpts{}, err -
    -
    - 1992 - -
    -   - } -
    -
    - 1993 - -
    -   - if key == nil { -
    -
    - 1994 - -
    - - - return bind.TransactOpts{}, nil -
    -
    - 1995 - -
    -   - } -
    -
    - 1996 - -
    -   - auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID)) -
    -
    - 1997 - -
    -   - if err != nil { -
    -
    - 1998 - -
    - - - return bind.TransactOpts{}, err -
    -
    - 1999 - -
    -   - } -
    -
    - 2000 - -
    - - - return *auth, nil -
    -
    - 2001 - -
    -   - } -
    -
    - 2002 - -
    -   -
    -
    -
    - 2003 - -
    -   - // getAuthByAddress tries to get an authorization from the authorizations map -
    -
    -
    @@ -2025,3 +2075,28 @@
    -
    - 2025 - -
    -   -
    -
    -
    - 2026 - -
    -   - return *auth, nil -
    -
    - 2027 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 3 - -
    -   - import ( -
    -
    - 4 - -
    -   - "bytes" -
    -
    - 5 - -
    -   - "context" -
    -
    - 6 - -
    - + - "crypto/ecdsa" -
    -
    - 7 - -
    -   - "encoding/json" -
    -
    - 8 - -
    -   - "errors" -
    -
    - 9 - -
    -   - "fmt" -
    -
    -
     
    -
    - 44 - -
    -   - "golang.org/x/crypto/sha3" -
    -
    - 45 - -
    -   - ) -
    -
    - 46 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -   - } -
    -
    - 287 - -
    -   - log.Debug("rollupID: ", rollupID) -
    -
    - 288 - -
    -   -
    -
    -
    - 289 - -
    - + - return &Client{ -
    -
    - 290 - -
    - + - EthClient: ethClient, -
    -
    - 291 - -
    - + - ZkEVM: zkevm, -
    -
    - 292 - -
    - + - EtrogZKEVM: etrogZkevm, -
    -
    - 293 - -
    - + - OldZkEVM: oldZkevm, -
    -
    - 294 - -
    - + - RollupManager: rollupManager, -
    -
    - 295 - -
    - + - Pol: pol, -
    -
    - 296 - -
    - + - GlobalExitRootManager: globalExitRoot, -
    -
    - 297 - -
    - + - DAProtocol: dap, -
    -
    - 298 - -
    - + - OldGlobalExitRootManager: oldGlobalExitRoot, -
    -
    - 299 - -
    - + - SCAddresses: scAddresses, -
    -
    - 300 - -
    - + - RollupID: rollupID, -
    -
    - 301 - -
    -   - GasProviders: externalGasProviders{ -
    -
    - 302 - -
    -   - MultiGasProvider: cfg.MultiGasProvider, -
    -
    - 303 - -
    -   - Providers: gProviders, -
    -
    - 304 - -
    -   - }, -
    -
    - 305 - -
    - + - l1Cfg: l1Config, -
    -
    - 306 - -
    - + - cfg: cfg, -
    -
    - 307 - -
    - + - auth: map[common.Address]bind.TransactOpts{}, -
    -
    - 308 - -
    - + - da: da, -
    -
    - 309 - -
    - + - state: st, -
    -
    - 310 - -
    - + - }, nil -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 311 - -
    -   - } -
    -
    - 312 - -
    -   -
    -
    -
    - 313 - -
    -   - // VerifyGenBlockNumber verifies if the genesis Block Number is valid -
    -
    - 314 - -
    -   - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { -
    -
    - 315 - -
    - + - // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block -
    -
    - 316 - -
    -   - start := time.Now() -
    -
    - 317 - -
    -   - log.Info("Verifying genesis blockNumber: ", genBlockNumber) -
    -
    - 318 - -
    -   - // Filter query -
    -
    -
     
    -
    - 330 - -
    -   - if len(logs) == 0 { -
    -
    - 331 - -
    -   - return false, fmt.Errorf("the specified genBlockNumber in config file does not contain any forkID event. Please use the proper blockNumber.") -
    -
    - 332 - -
    -   - } -
    -
    - 333 - -
    - + - var zkevmVersion oldpolygonzkevm.OldpolygonzkevmUpdateZkEVMVersion -
    -
    - 334 - -
    -   - switch logs[0].Topics[0] { -
    -
    - 335 - -
    -   - case updateZkEVMVersionSignatureHash: -
    -
    - 336 - -
    -   - log.Debug("UpdateZkEVMVersion event detected during the Verification of the GenBlockNumber") -
    -
    - 337 - -
    - + - zkevmV, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(logs[0]) -
    -
    - 338 - -
    -   - if err != nil { -
    -
    - 339 - -
    -   - return false, err -
    -
    - 340 - -
    -   - } -
    -
    -
     
    -
    - 343 - -
    -   - } -
    -
    - 344 - -
    -   - case createNewRollupSignatureHash: -
    -
    - 345 - -
    -   - log.Debug("CreateNewRollup event detected during the Verification of the GenBlockNumber") -
    -
    - 346 - -
    - + - createNewRollupEvent, err := etherMan.RollupManager.ParseCreateNewRollup(logs[0]) -
    -
    - 347 - -
    -   - if err != nil { -
    -
    - 348 - -
    -   - return false, err -
    -
    - 349 - -
    -   - } -
    -
    - 350 - -
    -   - // Query to get the forkID -
    -
    - 351 - -
    - + - rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID) -
    -
    - 352 - -
    -   - if err != nil { -
    -
    - 353 - -
    -   - log.Error(err) -
    -
    - 354 - -
    -   - return false, err -
    -
    -
     
    -
    - 363 - -
    -   - return true, nil -
    -
    - 364 - -
    -   - } -
    -
    - 365 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 366 - -
    -   - // GetForks returns fork information -
    -
    - 367 - -
    -   - func (etherMan *Client) GetForks(ctx context.Context, genBlockNumber uint64, lastL1BlockSynced uint64) ([]state.ForkIDInterval, error) { -
    -
    - 368 - -
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) -
    -
    - 369 - -
    -   - start := time.Now() -
    -
    - 370 - -
    -   - var logs []types.Log -
    -
    - 371 - -
    - + -
    -
    -
    - 372 - -
    -   - if lastL1BlockSynced < genBlockNumber { -
    -
    - 373 - -
    -   - lastL1BlockSynced = genBlockNumber -
    -
    - 374 - -
    -   - } -
    -
    - 375 - -
    - + -
    -
    -
    - 376 - -
    -   - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) -
    -
    - 377 - -
    -   - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { -
    -
    - 378 - -
    -   - final := i + etherMan.cfg.ForkIDChunkSize -
    -
    -
     
    -
    - 397 - -
    -   -
    -
    -
    - 398 - -
    -   - var forks []state.ForkIDInterval -
    -
    - 399 - -
    -   - for i, l := range logs { -
    -
    - 400 - -
    - + - var zkevmVersion oldpolygonzkevm.OldpolygonzkevmUpdateZkEVMVersion -
    -
    - 401 - -
    -   - switch l.Topics[0] { -
    -
    - 402 - -
    -   - case updateZkEVMVersionSignatureHash: -
    -
    - 403 - -
    -   - log.Debug("updateZkEVMVersion Event received") -
    -
    - 404 - -
    - + - zkevmV, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(l) -
    -
    - 405 - -
    -   - if err != nil { -
    -
    - 406 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 407 - -
    -   - } -
    -
    -
     
    -
    - 410 - -
    -   - } -
    -
    - 411 - -
    -   - case updateRollupSignatureHash: -
    -
    - 412 - -
    -   - log.Debug("updateRollup Event received") -
    -
    - 413 - -
    - + - updateRollupEvent, err := etherMan.RollupManager.ParseUpdateRollup(l) -
    -
    - 414 - -
    -   - if err != nil { -
    -
    - 415 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 416 - -
    -   - } -
    -
    -
     
    -
    - 418 - -
    -   - continue -
    -
    - 419 - -
    -   - } -
    -
    - 420 - -
    -   - // Query to get the forkID -
    -
    - 421 - -
    - + - rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollupEvent.NewRollupTypeID) -
    -
    - 422 - -
    -   - if err != nil { -
    -
    - 423 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 424 - -
    -   - } -
    -
    -
     
    -
    - 427 - -
    -   -
    -
    -
    - 428 - -
    -   - case addExistingRollupSignatureHash: -
    -
    - 429 - -
    -   - log.Debug("addExistingRollup Event received") -
    -
    - 430 - -
    - + - addExistingRollupEvent, err := etherMan.RollupManager.ParseAddExistingRollup(l) -
    -
    - 431 - -
    -   - if err != nil { -
    -
    - 432 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 433 - -
    -   - } -
    -
    -
     
    -
    - 439 - -
    -   -
    -
    -
    - 440 - -
    -   - case createNewRollupSignatureHash: -
    -
    - 441 - -
    -   - log.Debug("createNewRollup Event received") -
    -
    - 442 - -
    - + - createNewRollupEvent, err := etherMan.RollupManager.ParseCreateNewRollup(l) -
    -
    - 443 - -
    -   - if err != nil { -
    -
    - 444 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    - 445 - -
    -   - } -
    -
    -
     
    -
    - 447 - -
    -   - continue -
    -
    - 448 - -
    -   - } -
    -
    - 449 - -
    -   - // Query to get the forkID -
    -
    - 450 - -
    - + - rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID) -
    -
    - 451 - -
    -   - if err != nil { -
    -
    - 452 - -
    -   - log.Error(err) -
    -
    - 453 - -
    -   - return []state.ForkIDInterval{}, err -
    -
    -
     
    -
    - 499 - -
    -   - return blocks, blocksOrder, nil -
    -
    - 500 - -
    -   - } -
    -
    - 501 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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) -
    -
    -
     
    -
    - 552 - -
    -   - case rollupManagerVerifyBatchesSignatureHash: -
    -
    - 553 - -
    -   - log.Debug("RollupManagerVerifyBatches event detected. Ignoring...") -
    -
    - 554 - -
    -   - return nil -
    -
    - 555 - -
    - + - case oldVerifyBatchesTrustedAggregatorSignatureHash: -
    -
    - 556 - -
    - + - return etherMan.oldVerifyBatchesTrustedAggregatorEvent(ctx, vLog, blocks, blocksOrder) -
    -
    - 557 - -
    -   - case verifyBatchesSignatureHash: -
    -
    - 558 - -
    -   - return etherMan.verifyBatchesEvent(ctx, vLog, blocks, blocksOrder) -
    -
    - 559 - -
    -   - case sequenceForceBatchesSignatureHash: -
    -
    -
     
    -
    - 593 - -
    -   - case consolidatePendingStateSignatureHash: -
    -
    - 594 - -
    -   - log.Debug("ConsolidatePendingState event detected. Ignoring...") -
    -
    - 595 - -
    -   - return nil -
    -
    - 596 - -
    - + - case oldConsolidatePendingStateSignatureHash: -
    -
    - 597 - -
    - + - log.Debug("OldConsolidatePendingState event detected. Ignoring...") -
    -
    - 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 - -
    - + - case oldOverridePendingStateSignatureHash: -
    -
    - 633 - -
    - + - log.Debug("OldOverridePendingState event detected. Ignoring...") -
    -
    - 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 - -
    - + - zkevmVersion, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(vLog) -
    -
    - 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 - -
    - + - updateRollup, err := etherMan.RollupManager.ParseUpdateRollup(vLog) -
    -
    - 680 - -
    -   - if err != nil { -
    -
    - 681 - -
    -   - log.Error("error parsing UpdateRollup event. Error: ", err) -
    -
    - 682 - -
    -   - return err -
    -
    - 683 - -
    -   - } -
    -
    - 684 - -
    - + - rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollup.NewRollupTypeID) -
    -
    - 685 - -
    -   - if err != nil { -
    -
    - 686 - -
    -   - return err -
    -
    - 687 - -
    -   - } -
    -
    -
     
    -
    - 690 - -
    -   -
    -
    -
    - 691 - -
    -   - func (etherMan *Client) createNewRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 692 - -
    -   - log.Debug("createNewRollup event detected") -
    -
    - 693 - -
    - + - createRollup, err := etherMan.RollupManager.ParseCreateNewRollup(vLog) -
    -
    - 694 - -
    -   - if err != nil { -
    -
    - 695 - -
    -   - log.Error("error parsing createNewRollup event. Error: ", err) -
    -
    - 696 - -
    -   - return err -
    -
    - 697 - -
    -   - } -
    -
    - 698 - -
    - + - rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createRollup.RollupTypeID) -
    -
    - 699 - -
    -   - if err != nil { -
    -
    - 700 - -
    -   - return err -
    -
    - 701 - -
    -   - } -
    -
    -
     
    -
    - 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 - -
    -   - } -
    -
    -
     
    -
    - 842 - -
    -   - return nil -
    -
    - 843 - -
    -   - } -
    -
    - 844 - -
    -   -
    -
    -
    - 845 - -
    - + - func (etherMan *Client) retrieveFullBlockForEvent(ctx context.Context, vLog types.Log) (*Block, error) { -
    -
    - - -
    -   -
    -
    -
    - 846 - -
    -   - fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash) -
    -
    - 847 - -
    -   - if err != nil { -
    -
    - 848 - -
    -   - return nil, fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %w", vLog.BlockNumber, err) -
    -
    -
     
    -
    - 861 - -
    -   -
    -
    -
    - 862 - -
    -   - func (etherMan *Client) updateGlobalExitRootEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 863 - -
    -   - log.Debug("UpdateGlobalExitRoot event detected") -
    -
    - 864 - -
    - + - oldglobalExitRoot, err := etherMan.OldGlobalExitRootManager.ParseUpdateGlobalExitRoot(vLog) -
    -
    - 865 - -
    -   - if err != nil { -
    -
    - 866 - -
    -   - return err -
    -
    - 867 - -
    -   - } -
    -
    - 868 - -
    - + - return etherMan.processUpdateGlobalExitRootEvent(ctx, oldglobalExitRoot.MainnetExitRoot, oldglobalExitRoot.RollupExitRoot, vLog, blocks, blocksOrder) -
    -
    - 869 - -
    -   - } -
    -
    - 870 - -
    -   -
    -
    -
    - 871 - -
    -   - func (etherMan *Client) processUpdateGlobalExitRootEvent(ctx context.Context, mainnetExitRoot, rollupExitRoot common.Hash, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    -
     
    -
    - 913 - -
    -   - } -
    -
    - 914 - -
    -   -
    -
    -
    - 915 - -
    -   - // 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) { -
    -
    - 917 - -
    -   - opts, err := etherMan.getAuthByAddress(sender) -
    -
    - 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) -
    -
    - 924 - -
    -   - if err != nil { -
    -
    - 925 - -
    -   - return nil, err -
    -
    - 926 - -
    -   - } -
    -
    -
     
    -
    - 929 - -
    -   - } -
    -
    - 930 - -
    -   -
    -
    -
    - 931 - -
    -   - // 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) { -
    -
    - 933 - -
    -   - opts, err := etherMan.getAuthByAddress(sender) -
    -
    - 934 - -
    -   - if err == ErrNotFound { -
    -
    - 935 - -
    -   - return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound) -
    -
    -
     
    -
    - 940 - -
    -   - opts.GasLimit = uint64(1) -
    -
    - 941 - -
    -   - opts.GasPrice = big.NewInt(1) -
    -
    - 942 - -
    -   -
    -
    -
    - 943 - -
    - + - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) -
    -
    - 944 - -
    -   - if err != nil { -
    -
    - 945 - -
    -   - return nil, nil, err -
    -
    - 946 - -
    -   - } -
    -
    -
     
    -
    - 948 - -
    -   - return tx.To(), tx.Data(), nil -
    -
    - 949 - -
    -   - } -
    -
    - 950 - -
    -   -
    -
    -
    - 951 - -
    - + - func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) { -
    -
    - 952 - -
    - + - var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData -
    -
    - 953 - -
    -   - for _, seq := range sequences { -
    -
    - 954 - -
    -   - var ger common.Hash -
    -
    - 955 - -
    -   - if seq.ForcedBatchTimestamp > 0 { -
    -
    - 956 - -
    -   - ger = seq.GlobalExitRoot -
    -
    - 957 - -
    -   - } -
    -
    - 958 - -
    - + - batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ -
    -
    - 959 - -
    - + - TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data), -
    -
    - 960 - -
    -   - ForcedGlobalExitRoot: ger, -
    -
    - 961 - -
    -   - ForcedTimestamp: uint64(seq.ForcedBatchTimestamp), -
    -
    - 962 - -
    -   - ForcedBlockHashL1: seq.PrevBlockHash, -
    -
    -
     
    -
    - 965 - -
    -   - batches = append(batches, batch) -
    -
    - 966 - -
    -   - } -
    -
    - 967 - -
    -   -
    -
    -
    - 968 - -
    - + - tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) -
    -
    - 969 - -
    -   - if err != nil { -
    -
    - 970 - -
    -   - log.Debugf("Batches to send: %+v", batches) -
    -
    - 971 - -
    -   - log.Debug("l2CoinBase: ", l2Coinbase) -
    -
    - 972 - -
    -   - log.Debug("Sequencer address: ", opts.From) -
    -
    - 973 - -
    - + - a, err2 := polygonzkevm.PolygonzkevmMetaData.GetAbi() -
    -
    - 974 - -
    -   - if err2 != nil { -
    -
    - 975 - -
    -   - log.Error("error getting abi. Error: ", err2) -
    -
    - 976 - -
    -   - } -
    -
    -
     
    -
    - 1030 - -
    -   -
    -
    -
    - 1031 - -
    -   - const pendStateNum = 0 // TODO hardcoded for now until we implement the pending state feature -
    -
    - 1032 - -
    -   -
    -
    -
    - 1033 - -
    - + - tx, err := etherMan.RollupManager.VerifyBatchesTrustedAggregator( -
    -
    - 1034 - -
    -   - &opts, -
    -
    - 1035 - -
    -   - etherMan.RollupID, -
    -
    - 1036 - -
    -   - pendStateNum, -
    -
    -
     
    -
    - 1072 - -
    -   -
    -
    -
    - 1073 - -
    -   - // GetSendSequenceFee get super/trusted sequencer fee -
    -
    - 1074 - -
    -   - func (etherMan *Client) GetSendSequenceFee(numBatches uint64) (*big.Int, error) { -
    -
    - 1075 - -
    - + - f, err := etherMan.RollupManager.GetBatchFee(&bind.CallOpts{Pending: false}) -
    -
    - 1076 - -
    -   - if err != nil { -
    -
    - 1077 - -
    -   - return nil, err -
    -
    - 1078 - -
    -   - } -
    -
    -
     
    -
    - 1082 - -
    -   -
    -
    -
    - 1083 - -
    -   - // TrustedSequencer gets trusted sequencer address -
    -
    - 1084 - -
    -   - func (etherMan *Client) TrustedSequencer() (common.Address, error) { -
    -
    - 1085 - -
    - + - return etherMan.ZkEVM.TrustedSequencer(&bind.CallOpts{Pending: false}) -
    -
    - 1086 - -
    -   - } -
    -
    - 1087 - -
    -   -
    -
    -
    - 1088 - -
    -   - func (etherMan *Client) forcedBatchEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1089 - -
    -   - log.Debug("ForceBatch event detected") -
    -
    - 1090 - -
    - + - fb, err := etherMan.ZkEVM.ParseForceBatch(vLog) -
    -
    - 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) { -
    -
    - 1189 - -
    - + - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state) -
    -
    - 1190 - -
    -   - if err != nil { -
    -
    - 1191 - -
    -   - return fmt.Errorf("error decoding the sequences (etrog): %v", err) -
    -
    - 1192 - -
    -   - } -
    -
    - 1193 - -
    - + - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) || -
    -
    - 1194 - -
    - + - bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) { -
    -
    - 1195 - -
    - + - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state) -
    -
    - 1196 - -
    -   - if err != nil { -
    -
    - 1197 - -
    -   - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) -
    -
    - 1198 - -
    -   - } -
    -
    -
     
    -
    - 1233 - -
    -   -
    -
    -
    - 1234 - -
    -   - func (etherMan *Client) sequencedBatchesPreEtrogEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1235 - -
    -   - log.Debug("Pre etrog SequenceBatches event detected") -
    -
    - 1236 - -
    - + - sb, err := etherMan.OldZkEVM.ParseSequenceBatches(vLog) -
    -
    - 1237 - -
    -   - if err != nil { -
    -
    - 1238 - -
    -   - return err -
    -
    - 1239 - -
    -   - } -
    -
    -
     
    -
    - 1278 - -
    -   - return nil -
    -
    - 1279 - -
    -   - } -
    -
    - 1280 - -
    -   -
    -
    -
    - 1281 - -
    - + - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, -
    -
    - 1282 - -
    - + - l1InfoRoot common.Hash, da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) { -
    -
    - 1283 - -
    - + - // Extract coded txs. -
    -
    - 1284 - -
    - + - // Load contract ABI -
    -
    - 1285 - -
    - + - smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) -
    -
    - 1286 - -
    - + - if err != nil { -
    -
    - 1287 - -
    - + - return nil, err -
    -
    - 1288 - -
    - + - } -
    -
    - 1289 - -
    - + -
    -
    -
    - 1290 - -
    - + - return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st) -
    -
    - 1291 - -
    - + - } -
    -
    - 1292 - -
    - + -
    -
    -
    - 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 -
    -
    - 1329 - -
    - + - ) -
    -
    - 1330 - -
    - + -
    -
    -
    - 1331 - -
    - + - switch method.Name { -
    -
    - 1332 - -
    - + - case "sequenceBatches": -
    -
    - 1333 - -
    - + - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 1334 - -
    - + - err := json.Unmarshal(bytedata, &sequences) -
    -
    - 1335 - -
    - + - if err != nil { -
    -
    - 1336 - -
    - + - return nil, err -
    -
    - 1337 - -
    -   - } -
    -
    - 1338 - -
    - + -
    -
    -
    - 1339 - -
    - + - switch forkID { -
    -
    - 1340 - -
    - + - case state.FORKID_ETROG: -
    -
    - 1341 - -
    - + - coinbase = data[1].(common.Address) -
    -
    - 1342 - -
    - + -
    -
    -
    - 1343 - -
    - + - case state.FORKID_ELDERBERRY: -
    -
    - 1344 - -
    - + - maxSequenceTimestamp = data[1].(uint64) -
    -
    - 1345 - -
    - + - initSequencedBatchNumber = data[2].(uint64) -
    -
    - 1346 - -
    - + - coinbase = data[3].(common.Address) -
    -
    - 1347 - -
    - + - } -
    -
    - 1348 - -
    - + -
    -
    -
    - 1349 - -
    - + - sequencedBatches := make([]SequencedBatch, len(sequences)) -
    -
    - 1350 - -
    - + - for i, seq := range sequences { -
    -
    - 1351 - -
    - + - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) -
    -
    - 1352 - -
    - + - s := seq -
    -
    - 1353 - -
    - + - batch := SequencedBatch{ -
    -
    - 1354 - -
    - + - BatchNumber: bn, -
    -
    - 1355 - -
    - + - L1InfoRoot: &l1InfoRoot, -
    -
    - 1356 - -
    - + - SequencerAddr: sequencer, -
    -
    - 1357 - -
    - + - TxHash: txHash, -
    -
    - 1358 - -
    - + - Nonce: nonce, -
    -
    - 1359 - -
    - + - Coinbase: coinbase, -
    -
    - 1360 - -
    - + - PolygonRollupBaseEtrogBatchData: &s, -
    -
    - 1361 - -
    - + - } -
    -
    - 1362 - -
    - + - if forkID >= state.FORKID_ELDERBERRY { -
    -
    - 1363 - -
    - + - batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{ -
    -
    - 1364 - -
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, -
    -
    - 1365 - -
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, -
    -
    - 1366 - -
    - + - } -
    -
    - 1367 - -
    - + - } -
    -
    - 1368 - -
    - + - sequencedBatches[i] = batch -
    -
    - 1369 - -
    - + - } -
    -
    - 1370 - -
    - + -
    -
    -
    - 1371 - -
    - + - return sequencedBatches, nil -
    -
    - 1372 - -
    - + - case "sequenceBatchesValidium": -
    -
    - 1373 - -
    - + - var ( -
    -
    - 1374 - -
    - + - sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData -
    -
    - 1375 - -
    - + - dataAvailabilityMsg []byte -
    -
    - 1376 - -
    - + - ) -
    -
    - 1377 - -
    - + - err := json.Unmarshal(bytedata, &sequencesValidium) -
    -
    - 1378 - -
    - + - if err != nil { -
    -
    - 1379 - -
    - + - return nil, err -
    -
    - 1380 - -
    - + - } -
    -
    - 1381 - -
    - + -
    -
    -
    - 1382 - -
    - + - switch forkID { -
    -
    - 1383 - -
    - + - case state.FORKID_ETROG: -
    -
    - 1384 - -
    - + - coinbase = data[1].(common.Address) -
    -
    - 1385 - -
    - + - dataAvailabilityMsg = data[2].([]byte) -
    -
    - 1386 - -
    - + -
    -
    -
    - 1387 - -
    - + - case state.FORKID_ELDERBERRY: -
    -
    - 1388 - -
    - + - maxSequenceTimestamp = data[1].(uint64) -
    -
    - 1389 - -
    - + - initSequencedBatchNumber = data[2].(uint64) -
    -
    - 1390 - -
    - + - coinbase = data[3].(common.Address) -
    -
    - 1391 - -
    - + - dataAvailabilityMsg = data[4].([]byte) -
    -
    - 1392 - -
    - + - } -
    -
    - 1393 - -
    - + -
    -
    -
    - 1394 - -
    - + - // Pair the batch number, hash, and if it is forced. This will allow -
    -
    - 1395 - -
    - + - // retrieval from different sources, and keep them in original order. -
    -
    - 1396 - -
    - + - var batchInfos []batchInfo -
    -
    - 1397 - -
    - + - for i, d := range sequencesValidium { -
    -
    - 1398 - -
    - + - bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1)) -
    -
    - 1399 - -
    - + - forced := d.ForcedTimestamp > 0 -
    -
    - 1400 - -
    - + - h := d.TransactionsHash -
    -
    - 1401 - -
    - + - batchInfos = append(batchInfos, batchInfo{num: bn, hash: h, isForced: forced}) -
    -
    - 1402 - -
    - + - } -
    -
    - 1403 - -
    - + -
    -
    -
    - 1404 - -
    - + - batchData, err := retrieveBatchData(da, st, batchInfos, dataAvailabilityMsg) -
    -
    - 1405 - -
    - + - if err != nil { -
    -
    - 1406 - -
    - + - return nil, err -
    -
    - 1407 - -
    - + - } -
    -
    - 1408 - -
    - + -
    -
    -
    - 1409 - -
    - + - sequencedBatches := make([]SequencedBatch, len(sequencesValidium)) -
    -
    - 1410 - -
    - + - for i, info := range batchInfos { -
    -
    - 1411 - -
    - + - bn := info.num -
    -
    - 1412 - -
    - + - s := polygonzkevm.PolygonRollupBaseEtrogBatchData{ -
    -
    - 1413 - -
    - + - Transactions: batchData[i], -
    -
    - 1414 - -
    - + - ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot, -
    -
    - 1415 - -
    - + - ForcedTimestamp: sequencesValidium[i].ForcedTimestamp, -
    -
    - 1416 - -
    - + - ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1, -
    -
    - 1417 - -
    - + - } -
    -
    - 1418 - -
    - + - batch := SequencedBatch{ -
    -
    - 1419 - -
    - + - BatchNumber: bn, -
    -
    - 1420 - -
    - + - L1InfoRoot: &l1InfoRoot, -
    -
    - 1421 - -
    - + - SequencerAddr: sequencer, -
    -
    - 1422 - -
    - + - TxHash: txHash, -
    -
    - 1423 - -
    - + - Nonce: nonce, -
    -
    - 1424 - -
    - + - Coinbase: coinbase, -
    -
    - 1425 - -
    - + - PolygonRollupBaseEtrogBatchData: &s, -
    -
    - 1426 - -
    - + - } -
    -
    - 1427 - -
    - + - if forkID >= state.FORKID_ELDERBERRY { -
    -
    - 1428 - -
    - + - elderberry := &SequencedBatchElderberryData{ -
    -
    - 1429 - -
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, -
    -
    - 1430 - -
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, -
    -
    - 1431 - -
    - + - } -
    -
    - 1432 - -
    - + - batch.SequencedBatchElderberryData = elderberry -
    -
    - 1433 - -
    - + - } -
    -
    - 1434 - -
    - + - sequencedBatches[i] = batch -
    -
    - 1435 - -
    -   - } -
    -
    - 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) { -
    -
    - 1529 - -
    -   - // Extract coded txs. -
    -
    - 1530 - -
    -   - // Load contract ABI -
    -
    - 1531 - -
    - + - smcAbi, err := abi.JSON(strings.NewReader(oldpolygonzkevm.OldpolygonzkevmABI)) -
    -
    - 1532 - -
    -   - if err != nil { -
    -
    - 1533 - -
    -   - return nil, err -
    -
    - 1534 - -
    -   - } -
    -
    -
     
    -
    - 1544 - -
    -   - if err != nil { -
    -
    - 1545 - -
    -   - return nil, err -
    -
    - 1546 - -
    -   - } -
    -
    - 1547 - -
    - + - var sequences []oldpolygonzkevm.PolygonZkEVMBatchData -
    -
    - 1548 - -
    -   - bytedata, err := json.Marshal(data[0]) -
    -
    - 1549 - -
    -   - if err != nil { -
    -
    - 1550 - -
    -   - return nil, err -
    -
    -
     
    -
    - 1571 - -
    -   - return sequencedBatches, nil -
    -
    - 1572 - -
    -   - } -
    -
    - 1573 - -
    -   -
    -
    -
    - 1574 - -
    - + - func (etherMan *Client) oldVerifyBatchesTrustedAggregatorEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1575 - -
    -   - log.Debug("TrustedVerifyBatches event detected") -
    -
    - 1576 - -
    - + - var vb *oldpolygonzkevm.OldpolygonzkevmVerifyBatchesTrustedAggregator -
    -
    - 1577 - -
    - + - vb, err := etherMan.OldZkEVM.ParseVerifyBatchesTrustedAggregator(vLog) -
    -
    - 1578 - -
    -   - if err != nil { -
    -
    - 1579 - -
    -   - log.Error("error parsing TrustedVerifyBatches event. Error: ", err) -
    -
    - 1580 - -
    -   - return err -
    -
    -
     
    -
    - 1584 - -
    -   -
    -
    -
    - 1585 - -
    -   - func (etherMan *Client) verifyBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1586 - -
    -   - log.Debug("VerifyBatches event detected") -
    -
    - 1587 - -
    - + - vb, err := etherMan.ZkEVM.ParseVerifyBatches(vLog) -
    -
    - 1588 - -
    -   - if err != nil { -
    -
    - 1589 - -
    -   - log.Error("error parsing VerifyBatches event. Error: ", err) -
    -
    - 1590 - -
    -   - return err -
    -
    -
     
    -
    - 1631 - -
    -   -
    -
    -
    - 1632 - -
    -   - func (etherMan *Client) forceSequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { -
    -
    - 1633 - -
    -   - log.Debug("SequenceForceBatches event detect") -
    -
    - 1634 - -
    - + - fsb, err := etherMan.ZkEVM.ParseSequenceForceBatches(vLog) -
    -
    - 1635 - -
    -   - if err != nil { -
    -
    - 1636 - -
    -   - return err -
    -
    - 1637 - -
    -   - } -
    -
    -
     
    -
    - 1680 - -
    -   - func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, block *types.Block, nonce uint64) ([]SequencedForceBatch, error) { -
    -
    - 1681 - -
    -   - // Extract coded txs. -
    -
    - 1682 - -
    -   - // Load contract ABI -
    -
    - 1683 - -
    - + - abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) -
    -
    - 1684 - -
    -   - if err != nil { -
    -
    - 1685 - -
    -   - return nil, err -
    -
    - 1686 - -
    -   - } -
    -
    -
     
    -
    - 1697 - -
    -   - return nil, err -
    -
    - 1698 - -
    -   - } -
    -
    - 1699 - -
    -   -
    -
    -
    - 1700 - -
    - + - var forceBatches []polygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 1701 - -
    -   - bytedata, err := json.Marshal(data[0]) -
    -
    - 1702 - -
    -   - if err != nil { -
    -
    - 1703 - -
    -   - return nil, err -
    -
    -
     
    -
    - 1761 - -
    -   -
    -
    -
    - 1762 - -
    -   - // GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc -
    -
    - 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 - -
    - + - } -
    -
    - 1772 - -
    - + - } else { -
    -
    - 1773 - -
    - + - latestBatchNum = rollupData.LastBatchSequenced -
    -
    - 1774 - -
    -   - } -
    -
    - 1775 - -
    - + - return latestBatchNum, nil -
    -
    - 1776 - -
    -   - } -
    -
    - 1777 - -
    -   -
    -
    -
    - 1778 - -
    -   - // GetLatestBlockHeader gets the latest block header from the ethereum -
    -
    -
     
    -
    - 1819 - -
    -   -
    -
    -
    - 1820 - -
    -   - // GetLatestVerifiedBatchNum gets latest verified batch from ethereum -
    -
    - 1821 - -
    -   - func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error) { -
    -
    - 1822 - -
    - + - var lastVerifiedBatchNum uint64 -
    -
    - 1823 - -
    - + - rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID) -
    -
    - 1824 - -
    -   - if err != nil { -
    -
    - 1825 - -
    - + - log.Debug("error getting lastVerifiedBatchNum from rollupManager. Trying old zkevm smc... Error: ", err) -
    -
    - 1826 - -
    - + - lastVerifiedBatchNum, err = etherMan.OldZkEVM.LastVerifiedBatch(&bind.CallOpts{Pending: false}) -
    -
    - 1827 - -
    - + - if err != nil { -
    -
    - 1828 - -
    - + - return lastVerifiedBatchNum, err -
    -
    - 1829 - -
    - + - } -
    -
    - 1830 - -
    - + - } else { -
    -
    - 1831 - -
    - + - lastVerifiedBatchNum = rollupData.LastVerifiedBatch -
    -
    - 1832 - -
    -   - } -
    -
    - 1833 - -
    - + - return lastVerifiedBatchNum, nil -
    -
    - 1834 - -
    -   - } -
    -
    - 1835 - -
    -   -
    -
    -
    - 1836 - -
    -   - // GetTx function get ethereum tx -
    -
    -
     
    -
    - 1865 - -
    -   -
    -
    -
    - 1866 - -
    -   - // GetTrustedSequencerURL Gets the trusted sequencer url from rollup smc -
    -
    - 1867 - -
    -   - func (etherMan *Client) GetTrustedSequencerURL() (string, error) { -
    -
    - 1868 - -
    - + - url, err := etherMan.ZkEVM.TrustedSequencerURL(&bind.CallOpts{Pending: false}) -
    -
    - 1869 - -
    - + - //TODO: remove this code because is for compatibility with oldZkEVM -
    -
    - 1870 - -
    - + - if err != nil || url == "" { -
    -
    - 1871 - -
    - + - // Getting from oldZkEVM Contract -
    -
    - 1872 - -
    - + - log.Debug("getting trusted sequencer URL from oldZkevm smc") -
    -
    - 1873 - -
    - + - return etherMan.OldZkEVM.TrustedSequencerURL(&bind.CallOpts{Pending: false}) -
    -
    - 1874 - -
    - + - } -
    -
    - 1875 - -
    - + - // err is always nil -
    -
    - 1876 - -
    - + - return url, nil -
    -
    - 1877 - -
    -   - } -
    -
    - 1878 - -
    -   -
    -
    -
    - 1879 - -
    -   - // GetL2ChainID returns L2 Chain ID -
    -
    - 1880 - -
    -   - func (etherMan *Client) GetL2ChainID() (uint64, error) { -
    -
    - 1881 - -
    - + - chainID, err := etherMan.OldZkEVM.ChainID(&bind.CallOpts{Pending: false}) -
    -
    - 1882 - -
    - + - log.Debug("chainID read from oldZkevm: ", chainID) -
    -
    - 1883 - -
    -   - if err != nil || chainID == 0 { -
    -
    - 1884 - -
    - + - log.Debug("error from oldZkevm: ", err) -
    -
    - 1885 - -
    - + - rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID) -
    -
    - 1886 - -
    - + - log.Debugf("ChainID read from rollupManager: %d using rollupID: %d", rollupData.ChainID, etherMan.RollupID) -
    -
    - 1887 - -
    -   - if err != nil { -
    -
    - 1888 - -
    - + - log.Debug("error from rollupManager: ", err) -
    -
    - 1889 - -
    -   - return 0, err -
    -
    - 1890 - -
    -   - } else if rollupData.ChainID == 0 { -
    -
    - 1891 - -
    -   - return rollupData.ChainID, fmt.Errorf("error: chainID received is 0!!") -
    -
    -
     
    -
    - 1916 - -
    -   - return etherMan.EthClient.SendTransaction(ctx, tx) -
    -
    - 1917 - -
    -   - } -
    -
    - 1918 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 1919 - -
    -   - // CurrentNonce returns the current nonce for the provided account -
    -
    - 1920 - -
    -   - func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error) { -
    -
    - 1921 - -
    -   - return etherMan.EthClient.NonceAt(ctx, account, nil) -
    -
    -
     
    -
    - 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 -
    -
    -
     
    -
    - 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 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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) -
    -
    - 97 - -
    -   - require.NoError(t, err) -
    -
    - 98 - -
    -   -
    -
    -
    - 99 - -
    - - - amount, err := etherman.EtrogRollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false}) -
    -
    - 100 - -
    -   - require.NoError(t, err) -
    -
    - 101 - -
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" -
    -
    - 102 - -
    -   - data, err := hex.DecodeString(rawTxs) -
    -
    - 103 - -
    -   - require.NoError(t, err) -
    -
    - 104 - -
    - - - _, err = etherman.EtrogZkEVM.ForceBatch(auth, data, amount) -
    -
    - 105 - -
    -   - require.NoError(t, err) -
    -
    - 106 - -
    -   -
    -
    -
    - 107 - -
    -   - // Mine the tx in a block -
    -
    -
    @@ -114,8 +116,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 +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) -
    -
    - 141 - -
    -   -
    -
    -
    - 142 - -
    - - - amount, err := etherman.EtrogRollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false}) -
    -
    - 143 - -
    -   - require.NoError(t, err) -
    -
    - 144 - -
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" -
    -
    - 145 - -
    -   - data, err := hex.DecodeString(rawTxs) -
    -
    - 146 - -
    -   - require.NoError(t, err) -
    -
    - 147 - -
    - - - _, err = etherman.EtrogZkEVM.ForceBatch(auth, data, amount) -
    -
    - 148 - -
    -   - require.NoError(t, err) -
    -
    - 149 - -
    -   - require.NoError(t, err) -
    -
    - 150 - -
    -   - ethBackend.Commit() -
    -
    -
    @@ -156,13 +158,19 @@
    -
    - 156 - -
    -   - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber) -
    -
    - 157 - -
    -   - require.NoError(t, err) -
    -
    - 158 - -
    -   - t.Log("Blocks: ", blocks) -
    -
    - 159 - -
    - - - 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 @@
    -
    - 197 - -
    -   - require.NoError(t, err) -
    -
    - 198 - -
    -   -
    -
    -
    - 199 - -
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" -
    -
    - 200 - -
    - - - tx := etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ -
    -
    - 201 - -
    - - - Transactions: common.Hex2Bytes(rawTxs), -
    -
    - 202 - -
    -   - } -
    -
    - 203 - -
    - - - //TODO: Fix params -
    -
    - 204 - -
    - - - _, err = etherman.EtrogZkEVM.SequenceBatches(auth, []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From) -
    -
    - 205 - -
    -   - require.NoError(t, err) -
    -
    - - -
    -   -
    -
    -
    - 206 - -
    -   -
    -
    -
    - 207 - -
    -   - // Mine the tx in a block -
    -
    - 208 - -
    -   - ethBackend.Commit() -
    -
    - 209 - -
    -   -
    -
    -
    - 210 - -
    - - - _, err = etherman.EtrogRollupManager.VerifyBatchesTrustedAggregator(auth, 1, uint64(0), uint64(0), uint64(1), [32]byte{}, [32]byte{}, auth.From, [24][32]byte{}) -
    -
    - 211 - -
    -   - require.NoError(t, err) -
    -
    - 212 - -
    -   -
    -
    -
    - 213 - -
    -   - // Mine the tx in a block -
    -
    -
    @@ -220,7 +229,7 @@
    -
    - 220 - -
    -   - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) -
    -
    - 221 - -
    -   - require.NoError(t, err) -
    -
    - 222 - -
    -   - t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order) -
    -
    - 223 - -
    - - - assert.Equal(t, uint64(9), blocks[1].BlockNumber) -
    -
    - 224 - -
    -   - assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber) -
    -
    - 225 - -
    -   - assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator) -
    -
    - 226 - -
    -   - assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash) -
    -
    -
    @@ -232,19 +241,19 @@
    -
    - 232 - -
    -   -
    -
    -
    - 233 - -
    -   - func TestSequenceForceBatchesEvent(t *testing.T) { -
    -
    - 234 - -
    -   - // Set up testing environment -
    -
    - 235 - -
    - - - etherman, ethBackend, auth, _, _ := newTestingEnv() -
    -
    - 236 - -
    -   -
    -
    -
    - 237 - -
    -   - // Read currentBlock -
    -
    - 238 - -
    -   - ctx := context.Background() -
    -
    - 239 - -
    -   - initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil) -
    -
    - 240 - -
    -   - require.NoError(t, err) -
    -
    - 241 - -
    -   -
    -
    -
    - 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)) -
    -
    - 267 - -
    -   - require.NoError(t, err) -
    -
    - 268 - -
    -   - forcedBlockHashL1 := prevBlock.Hash() -
    -
    - 269 - -
    - - - forceBatchData := etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ -
    -
    - 270 - -
    -   - Transactions: blocks[0].ForcedBatches[0].RawTxsData, -
    -
    - 271 - -
    -   - ForcedGlobalExitRoot: forcedGer, -
    -
    - 272 - -
    -   - ForcedTimestamp: forcedTimestamp, -
    -
    - 273 - -
    -   - ForcedBlockHashL1: forcedBlockHashL1, -
    -
    - 274 - -
    -   - } -
    -
    - 275 - -
    - - - _, err = etherman.EtrogZkEVM.SequenceForceBatches(auth, []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{forceBatchData}) -
    -
    - 276 - -
    -   - require.NoError(t, err) -
    -
    - 277 - -
    -   - ethBackend.Commit() -
    -
    - 278 - -
    -   -
    -
    -
    -
    @@ -283,7 +292,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 +302,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 +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) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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() -
    -
    - 98 - -
    -   - initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil) -
    -
    - 99 - -
    -   - require.NoError(t, err) -
    -
    - 100 - -
    -   -
    -
    -
    - 101 - -
    - + - amount, err := etherman.RollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false}) -
    -
    - 102 - -
    -   - require.NoError(t, err) -
    -
    - 103 - -
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" -
    -
    - 104 - -
    -   - data, err := hex.DecodeString(rawTxs) -
    -
    - 105 - -
    -   - require.NoError(t, err) -
    -
    - 106 - -
    - + - _, err = etherman.ZkEVM.ForceBatch(auth, data, amount) -
    -
    - 107 - -
    -   - require.NoError(t, err) -
    -
    - 108 - -
    -   -
    -
    -
    - 109 - -
    -   - // Mine the tx in a block -
    -
    -
     
    -
    - 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() -
    -
    -
     
    -
    - 141 - -
    -   - ethBackend.Commit() -
    -
    - 142 - -
    -   - auth.Value = big.NewInt(0) -
    -
    - 143 - -
    -   -
    -
    -
    - 144 - -
    - + - amount, err := etherman.RollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false}) -
    -
    - 145 - -
    -   - require.NoError(t, err) -
    -
    - 146 - -
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" -
    -
    - 147 - -
    -   - data, err := hex.DecodeString(rawTxs) -
    -
    - 148 - -
    -   - require.NoError(t, err) -
    -
    - 149 - -
    - + - _, err = etherman.ZkEVM.ForceBatch(auth, data, amount) -
    -
    - 150 - -
    -   - require.NoError(t, err) -
    -
    - 151 - -
    -   - require.NoError(t, err) -
    -
    - 152 - -
    -   - ethBackend.Commit() -
    -
    -
     
    -
    - 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() -
    -
    - 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}) -
    -
    - 285 - -
    -   - require.NoError(t, err) -
    -
    - 286 - -
    -   - ethBackend.Commit() -
    -
    - 287 - -
    -   -
    -
    -
    -
     
    -
    - 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/events_helper.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,191 +0,0 @@
    -
    - 1 - -
    - - - package etherman -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "bytes" -
    -
    - 5 - -
    - - - "context" -
    -
    - 6 - -
    - - - "fmt" -
    -
    - 7 - -
    - - - "math/big" -
    -
    - 8 - -
    - - -
    -
    -
    - 9 - -
    - - - "github.com/ethereum/go-ethereum" -
    -
    - 10 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 11 - -
    - - - "github.com/ethereum/go-ethereum/core" -
    -
    - 12 - -
    - - - "github.com/ethereum/go-ethereum/core/types" -
    -
    - 13 - -
    - - - ) -
    -
    - 14 - -
    - - -
    -
    -
    - 15 - -
    - - - // BlockRetriever is the interface required from etherman main object -
    -
    - 16 - -
    - - - type BlockRetriever interface { -
    -
    - 17 - -
    - - - RetrieveFullBlockForEvent(ctx context.Context, vLog types.Log) (*Block, error) -
    -
    - 18 - -
    - - - } -
    -
    - 19 - -
    - - -
    -
    -
    - 20 - -
    - - - // GenericEventProcessor is the interface that a processor must implement -
    -
    - 21 - -
    - - - type GenericEventProcessor interface { -
    -
    - 22 - -
    - - - // EventSignature returns the signature of the event supported -
    -
    - 23 - -
    - - - // evaluate if make sens to support multiples signatures -
    -
    - 24 - -
    - - - EventSignature() common.Hash -
    -
    - 25 - -
    - - - AddEventDataToBlock(ctx context.Context, vLog types.Log, block *Block, callData *CallData) (*Order, error) -
    -
    - 26 - -
    - - - } -
    -
    - 27 - -
    - - -
    -
    -
    - 28 - -
    - - - // CallDataExtractor is the interface required to extract the call data from a transaction -
    -
    - 29 - -
    - - - type CallDataExtractor interface { -
    -
    - 30 - -
    - - - ExtractCallData(ctx context.Context, blockHash, txHash common.Hash, txIndex uint) (*CallData, error) -
    -
    - 31 - -
    - - - } -
    -
    - 32 - -
    - - -
    -
    -
    - 33 - -
    - - - // EventManager is a struct that manages the L1 events -
    -
    - 34 - -
    - - - // The way of using this is create and add Processor -
    -
    - 35 - -
    - - - // A processor only need to code the specific part of adding specific data -
    -
    - 36 - -
    - - - // to the block -
    -
    - 37 - -
    - - - type EventManager struct { -
    -
    - 38 - -
    - - - blockRetriever BlockRetriever -
    -
    - 39 - -
    - - - callDataExtractor CallDataExtractor -
    -
    - 40 - -
    - - -
    -
    -
    - 41 - -
    - - - processors []GenericEventProcessor -
    -
    - 42 - -
    - - - } -
    -
    - 43 - -
    - - -
    -
    -
    - 44 - -
    - - - // NewEventManager creates a new EventManager -
    -
    - 45 - -
    - - - func NewEventManager(blockRetriever BlockRetriever, callDataExtractor CallDataExtractor) *EventManager { -
    -
    - 46 - -
    - - - return &EventManager{ -
    -
    - 47 - -
    - - - blockRetriever: blockRetriever, -
    -
    - 48 - -
    - - - callDataExtractor: callDataExtractor, -
    -
    - 49 - -
    - - - processors: []GenericEventProcessor{}, -
    -
    - 50 - -
    - - - } -
    -
    - 51 - -
    - - - } -
    -
    - 52 - -
    - - -
    -
    -
    - 53 - -
    - - - // AddProcessor adds a new processor to the EventManager -
    -
    - 54 - -
    - - - func (e *EventManager) AddProcessor(processor GenericEventProcessor) { -
    -
    - 55 - -
    - - - e.processors = append(e.processors, processor) -
    -
    - 56 - -
    - - - } -
    -
    - 57 - -
    - - -
    -
    -
    - 58 - -
    - - - // ProcessEvent processes an event -
    -
    - 59 - -
    - - - // this is the interface with etherman -
    -
    - 60 - -
    - - - // it returns true if this event belong to this processor -
    -
    - 61 - -
    - - - func (e *EventManager) ProcessEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) (bool, error) { -
    -
    - 62 - -
    - - - for idx := range e.processors { -
    -
    - 63 - -
    - - - processor := e.processors[idx] -
    -
    - 64 - -
    - - - if len(vLog.Topics) > 0 && vLog.Topics[0] == processor.EventSignature() { -
    -
    - 65 - -
    - - - return true, e.processGenericEvent(ctx, vLog, blocks, blocksOrder, processor) -
    -
    - 66 - -
    - - - } -
    -
    - 67 - -
    - - - } -
    -
    - 68 - -
    - - - return false, nil -
    -
    - 69 - -
    - - - } -
    -
    - 70 - -
    - - -
    -
    -
    - 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 - -
    - - - } -
    -
    - 80 - -
    - - - order, err := processor.AddEventDataToBlock(ctx, vLog, block, callData) -
    -
    - 81 - -
    - - - if err != nil { -
    -
    - 82 - -
    - - - return err -
    -
    - 83 - -
    - - - } -
    -
    - 84 - -
    - - - addNewOrder(order, block.BlockHash, blocksOrder) -
    -
    - 85 - -
    - - - return nil -
    -
    - 86 - -
    - - - } -
    -
    - 87 - -
    - - -
    -
    -
    - 88 - -
    - - - func addNewOrder(order *Order, blockHash common.Hash, blocksOrder *map[common.Hash][]Order) { -
    -
    - 89 - -
    - - - (*blocksOrder)[blockHash] = append((*blocksOrder)[blockHash], *order) -
    -
    - 90 - -
    - - - } -
    -
    - 91 - -
    - - -
    -
    -
    - 92 - -
    - - - // addNewEvent adds a new event to the blocks array and order array. -
    -
    - 93 - -
    - - - // it returns the block that must be filled with event data -
    -
    - 94 - -
    - - - func (e *EventManager) addNewBlockToResult(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) (*Block, error) { -
    -
    - 95 - -
    - - - var block *Block -
    -
    - 96 - -
    - - - var err error -
    -
    - 97 - -
    - - - if !isheadBlockInArray(blocks, vLog.BlockHash, vLog.BlockNumber) { -
    -
    - 98 - -
    - - - // Need to add the block, doesnt mind if inside the blocks because I have to respect the order so insert at end -
    -
    - 99 - -
    - - - //TODO: Check if the block is already in the blocks array and copy it instead of retrieve it again -
    -
    - 100 - -
    - - - block, err = e.blockRetriever.RetrieveFullBlockForEvent(ctx, vLog) -
    -
    - 101 - -
    - - - if err != nil { -
    -
    - 102 - -
    - - - return nil, err -
    -
    - 103 - -
    - - - } -
    -
    - 104 - -
    - - - *blocks = append(*blocks, *block) -
    -
    - 105 - -
    - - - } -
    -
    - 106 - -
    - - - block = &(*blocks)[len(*blocks)-1] -
    -
    - 107 - -
    - - - return block, nil -
    -
    - 108 - -
    - - - } -
    -
    - 109 - -
    - - -
    -
    -
    - 110 - -
    - - - // CallData is a struct that contains the calldata of a transaction -
    -
    - 111 - -
    - - - type CallData struct { -
    -
    - 112 - -
    - - - data []byte -
    -
    - 113 - -
    - - - nonce uint64 -
    -
    - 114 - -
    - - - from common.Address -
    -
    - 115 - -
    - - - } -
    -
    - 116 - -
    - - -
    -
    -
    - 117 - -
    - - - // NewCallData creates a new CallData struct -
    -
    - 118 - -
    - - - func NewCallData(data []byte, nonce uint64, from common.Address) *CallData { -
    -
    - 119 - -
    - - - return &CallData{ -
    -
    - 120 - -
    - - - data: data, -
    -
    - 121 - -
    - - - nonce: nonce, -
    -
    - 122 - -
    - - - from: from, -
    -
    - 123 - -
    - - - } -
    -
    - 124 - -
    - - - } -
    -
    - 125 - -
    - - -
    -
    -
    - 126 - -
    - - - // MethodID returns the method ID of the transaction -
    -
    - 127 - -
    - - - func (c *CallData) MethodID() []byte { -
    -
    - 128 - -
    - - - return c.data[:4] -
    -
    - 129 - -
    - - - } -
    -
    - 130 - -
    - - -
    -
    -
    - 131 - -
    - - - // InputData returns the input data of the transaction -
    -
    - 132 - -
    - - - func (c *CallData) InputData() []byte { -
    -
    - 133 - -
    - - - return c.data[4:] -
    -
    - 134 - -
    - - - } -
    -
    - 135 - -
    - - -
    -
    -
    - 136 - -
    - - - // Nonce returns the nonce of the transaction -
    -
    - 137 - -
    - - - func (c *CallData) Nonce() uint64 { -
    -
    - 138 - -
    - - - return c.nonce -
    -
    - 139 - -
    - - - } -
    -
    - 140 - -
    - - -
    -
    -
    - 141 - -
    - - - // From returns the address of the sender of the transaction -
    -
    - 142 - -
    - - - func (c *CallData) From() common.Address { -
    -
    - 143 - -
    - - - return c.from -
    -
    - 144 - -
    - - - } -
    -
    - 145 - -
    - - -
    -
    -
    - 146 - -
    - - - // CallDataExtratorGeth is a CallDataExtractor based on Geth -
    -
    - 147 - -
    - - - type CallDataExtratorGeth struct { -
    -
    - 148 - -
    - - - ethClient ethereum.ChainReader -
    -
    - 149 - -
    - - - } -
    -
    - 150 - -
    - - -
    -
    -
    - 151 - -
    - - - // NewCallDataExtratorGeth creates a new CallDataExtrator based on Geth -
    -
    - 152 - -
    - - - func NewCallDataExtratorGeth(ethClient ethereum.ChainReader) *CallDataExtratorGeth { -
    -
    - 153 - -
    - - - return &CallDataExtratorGeth{ -
    -
    - 154 - -
    - - - ethClient: ethClient, -
    -
    - 155 - -
    - - - } -
    -
    - 156 - -
    - - - } -
    -
    - 157 - -
    - - -
    -
    -
    - 158 - -
    - - - // ExtractCallData get the call data from a transaction -
    -
    - 159 - -
    - - - func (e *CallDataExtratorGeth) ExtractCallData(ctx context.Context, blockHash, txHash common.Hash, txIndex uint) (*CallData, error) { -
    -
    - 160 - -
    - - - // Read the tx for this event. -
    -
    - 161 - -
    - - - tx, err := e.ethClient.TransactionInBlock(ctx, blockHash, txIndex) -
    -
    - 162 - -
    - - - if err != nil { -
    -
    - 163 - -
    - - - return nil, err -
    -
    - 164 - -
    - - - } -
    -
    - 165 - -
    - - - if tx == nil { -
    -
    - 166 - -
    - - - return nil, fmt.Errorf("error: tx not found in block %s at index %d", blockHash.String(), txIndex) -
    -
    - 167 - -
    - - - } -
    -
    - 168 - -
    - - - //log.Debug("tx: ", tx2string(tx)) -
    -
    - 169 - -
    - - - if tx.Hash() != txHash { -
    -
    - 170 - -
    - - - return nil, fmt.Errorf("error: tx hash mismatch. want: %s have: %s", txHash, tx.Hash().String()) -
    -
    - 171 - -
    - - - } -
    -
    - 172 - -
    - - - msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0)) -
    -
    - 173 - -
    - - - if err != nil { -
    -
    - 174 - -
    - - - return nil, err -
    -
    - 175 - -
    - - - } -
    -
    - 176 - -
    - - - return &CallData{ -
    -
    - 177 - -
    - - - data: tx.Data(), -
    -
    - 178 - -
    - - - nonce: msg.Nonce, -
    -
    - 179 - -
    - - - from: msg.From, -
    -
    - 180 - -
    - - - }, nil -
    -
    - 181 - -
    - - - } -
    -
    - 182 - -
    - - -
    -
    -
    - 183 - -
    - - - // Function used to convert a transaction to a string to used as input data for unittest -
    -
    - 184 - -
    - - - func tx2string(tx *types.Transaction) string { //nolint:unused -
    -
    - 185 - -
    - - - writer := new(bytes.Buffer) -
    -
    - 186 - -
    - - - err := tx.EncodeRLP(writer) -
    -
    - 187 - -
    - - - if err != nil { -
    -
    - 188 - -
    - - - return "error:" + err.Error() -
    -
    - 189 - -
    - - - } -
    -
    - 190 - -
    - - - return common.Bytes2Hex(writer.Bytes()) -
    -
    - 191 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/events_helper_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,180 +0,0 @@
    -
    - 1 - -
    - - - package etherman_test -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "bytes" -
    -
    - 5 - -
    - - - "context" -
    -
    - 6 - -
    - - - "fmt" -
    -
    - 7 - -
    - - - "math/big" -
    -
    - 8 - -
    - - - "testing" -
    -
    - 9 - -
    - - -
    -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" -
    -
    - 11 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/mockseth" -
    -
    - 12 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 13 - -
    - - - "github.com/ethereum/go-ethereum/core/types" -
    -
    - 14 - -
    - - - "github.com/ethereum/go-ethereum/rlp" -
    -
    - 15 - -
    - - - "github.com/stretchr/testify/mock" -
    -
    - 16 - -
    - - - "github.com/stretchr/testify/require" -
    -
    - 17 - -
    - - - ) -
    -
    - 18 - -
    - - -
    -
    -
    - 19 - -
    - - - type EventManagerTestData struct { -
    -
    - 20 - -
    - - - mockBlockRetiever *mockseth.BlockRetriever -
    -
    - 21 - -
    - - -
    -
    -
    - 22 - -
    - - - mockProcessor *mockseth.GenericEventProcessor -
    -
    - 23 - -
    - - - mockCallDataExtractor *mockseth.CallDataExtractor -
    -
    - 24 - -
    - - - sut *etherman.EventManager -
    -
    - 25 - -
    - - - ctx context.Context -
    -
    - 26 - -
    - - - } -
    -
    - 27 - -
    - - -
    -
    -
    - 28 - -
    - - - func NewEventManagerTestData(t *testing.T) *EventManagerTestData { -
    -
    - 29 - -
    - - - mockBlockRetriever := mockseth.NewBlockRetriever(t) -
    -
    - 30 - -
    - - - mockCallDataExtractor := mockseth.NewCallDataExtractor(t) -
    -
    - 31 - -
    - - - return &EventManagerTestData{ -
    -
    - 32 - -
    - - - mockBlockRetiever: mockBlockRetriever, -
    -
    - 33 - -
    - - - mockCallDataExtractor: mockCallDataExtractor, -
    -
    - 34 - -
    - - - mockProcessor: mockseth.NewGenericEventProcessor(t), -
    -
    - 35 - -
    - - - sut: etherman.NewEventManager(mockBlockRetriever, mockCallDataExtractor), -
    -
    - 36 - -
    - - - ctx: context.TODO(), -
    -
    - 37 - -
    - - - } -
    -
    - 38 - -
    - - - } -
    -
    - 39 - -
    - - -
    -
    -
    - 40 - -
    - - - func TestEventManagerNoEventToProcess(t *testing.T) { -
    -
    - 41 - -
    - - - data := NewEventManagerTestData(t) -
    -
    - 42 - -
    - - - vLog := types.Log{} -
    -
    - 43 - -
    - - -
    -
    -
    - 44 - -
    - - - processed, err := data.sut.ProcessEvent(context.TODO(), vLog, nil, nil) -
    -
    - 45 - -
    - - - require.False(t, processed) -
    -
    - 46 - -
    - - - require.NoError(t, err) -
    -
    - 47 - -
    - - - } -
    -
    - 48 - -
    - - -
    -
    -
    - 49 - -
    - - - func TestEventManagerEventToProcessHappyPathIntegratedWithSequenceBlobs(t *testing.T) { -
    -
    - 50 - -
    - - - data := NewEventManagerTestData(t) -
    -
    - 51 - -
    - - - mockChainReader := etherman.NewChainReaderMock(t) -
    -
    - 52 - -
    - - - data.sut = etherman.NewEventManager(data.mockBlockRetiever, etherman.NewCallDataExtratorGeth(mockChainReader)) -
    -
    - 53 - -
    - - - contracts, err := etherman.NewFeijoaContracts(nil, etherman.L1Config{}) -
    -
    - 54 - -
    - - - require.NoError(t, err) -
    -
    - 55 - -
    - - - processor := etherman.NewEventFeijoaSequenceBlobsProcessor(contracts) -
    -
    - 56 - -
    - - - data.sut.AddProcessor(processor) -
    -
    - 57 - -
    - - - block := etherman.Block{ -
    -
    - 58 - -
    - - - BlockHash: common.HexToHash("0x1"), -
    -
    - 59 - -
    - - - BlockNumber: 1234, -
    -
    - 60 - -
    - - - } -
    -
    - 61 - -
    - - -
    -
    -
    - 62 - -
    - - - tx := txExample() -
    -
    - 63 - -
    - - - vLog := types.Log{ -
    -
    - 64 - -
    - - - Topics: []common.Hash{processor.EventSignature(), -
    -
    - 65 - -
    - - - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000074")}, -
    -
    - 66 - -
    - - - BlockNumber: block.BlockNumber, -
    -
    - 67 - -
    - - - BlockHash: block.BlockHash, -
    -
    - 68 - -
    - - - TxHash: tx.Hash(), -
    -
    - 69 - -
    - - - } -
    -
    - 70 - -
    - - - blocks := []etherman.Block{} -
    -
    - 71 - -
    - - -
    -
    -
    - 72 - -
    - - - data.mockBlockRetiever.EXPECT().RetrieveFullBlockForEvent(data.ctx, vLog).Return(&block, nil).Once() -
    -
    - 73 - -
    - - - mockChainReader.EXPECT().TransactionInBlock(data.ctx, block.BlockHash, uint(0)).Return(tx, nil).Once() -
    -
    - 74 - -
    - - - blocksOrder := map[common.Hash][]etherman.Order{} -
    -
    - 75 - -
    - - -
    -
    -
    - 76 - -
    - - - processed, err := data.sut.ProcessEvent(data.ctx, vLog, &blocks, &blocksOrder) -
    -
    - 77 - -
    - - -
    -
    -
    - 78 - -
    - - - require.True(t, processed) -
    -
    - 79 - -
    - - - require.NoError(t, err) -
    -
    - 80 - -
    - - - } -
    -
    - 81 - -
    - - -
    -
    -
    - 82 - -
    - - - func TestEventManagerEventToProcessHappyPath(t *testing.T) { -
    -
    - 83 - -
    - - - data := NewEventManagerTestData(t) -
    -
    - 84 - -
    - - - block := etherman.Block{ -
    -
    - 85 - -
    - - - BlockHash: common.HexToHash("0x1"), -
    -
    - 86 - -
    - - - BlockNumber: 1234, -
    -
    - 87 - -
    - - - } -
    -
    - 88 - -
    - - - eventSignature := common.HexToHash("0x2") -
    -
    - 89 - -
    - - - tx := txExample() -
    -
    - 90 - -
    - - - vLog := types.Log{ -
    -
    - 91 - -
    - - - Topics: []common.Hash{eventSignature}, -
    -
    - 92 - -
    - - - BlockNumber: block.BlockNumber, -
    -
    - 93 - -
    - - - BlockHash: block.BlockHash, -
    -
    - 94 - -
    - - - TxHash: tx.Hash(), -
    -
    - 95 - -
    - - - } -
    -
    - 96 - -
    - - - blocks := []etherman.Block{} -
    -
    - 97 - -
    - - - data.mockProcessor.EXPECT().EventSignature().Return(eventSignature).Once() -
    -
    - 98 - -
    - - -
    -
    -
    - 99 - -
    - - - data.mockBlockRetiever.EXPECT().RetrieveFullBlockForEvent(data.ctx, vLog).Return(&block, nil).Once() -
    -
    - 100 - -
    - - - data.mockCallDataExtractor.EXPECT().ExtractCallData(data.ctx, block.BlockHash, tx.Hash(), uint(0)).Return(&etherman.CallData{}, nil) -
    -
    - 101 - -
    - - - data.mockProcessor.EXPECT().AddEventDataToBlock(data.ctx, vLog, &block, mock.Anything).Return(&etherman.Order{}, nil).Once() -
    -
    - 102 - -
    - - - data.sut.AddProcessor(data.mockProcessor) -
    -
    - 103 - -
    - - -
    -
    -
    - 104 - -
    - - - blocksOrder := map[common.Hash][]etherman.Order{} -
    -
    - 105 - -
    - - -
    -
    -
    - 106 - -
    - - - processed, err := data.sut.ProcessEvent(data.ctx, vLog, &blocks, &blocksOrder) -
    -
    - 107 - -
    - - -
    -
    -
    - 108 - -
    - - - require.True(t, processed) -
    -
    - 109 - -
    - - - require.NoError(t, err) -
    -
    - 110 - -
    - - - } -
    -
    - 111 - -
    - - -
    -
    -
    - 112 - -
    - - - func TestCallDataExtractorExtarctCallDataHappyPath(t *testing.T) { -
    -
    - 113 - -
    - - - mockChainRetriever := etherman.NewChainReaderMock(t) -
    -
    - 114 - -
    - - - blockHash := common.HexToHash("0x1") -
    -
    - 115 - -
    - - - indexTx := uint(12) -
    -
    - 116 - -
    - - - tx := txExample() -
    -
    - 117 - -
    - - - mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once() -
    -
    - 118 - -
    - - - callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever) -
    -
    - 119 - -
    - - - _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, tx.Hash(), indexTx) -
    -
    - 120 - -
    - - - require.NoError(t, err) -
    -
    - 121 - -
    - - - } -
    -
    - 122 - -
    - - -
    -
    -
    - 123 - -
    - - - func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnsErr(t *testing.T) { -
    -
    - 124 - -
    - - - mockChainRetriever := etherman.NewChainReaderMock(t) -
    -
    - 125 - -
    - - - blockHash := common.HexToHash("0x1") -
    -
    - 126 - -
    - - - indexTx := uint(12) -
    -
    - 127 - -
    - - - errReturned := fmt.Errorf("mock error") -
    -
    - 128 - -
    - - - mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(nil, errReturned).Once() -
    -
    - 129 - -
    - - - callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever) -
    -
    - 130 - -
    - - - _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx) -
    -
    - 131 - -
    - - - require.ErrorIs(t, err, errReturned) -
    -
    - 132 - -
    - - - } -
    -
    - 133 - -
    - - -
    -
    -
    - 134 - -
    - - - func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnsNilTx(t *testing.T) { -
    -
    - 135 - -
    - - - mockChainRetriever := etherman.NewChainReaderMock(t) -
    -
    - 136 - -
    - - - blockHash := common.HexToHash("0x1") -
    -
    - 137 - -
    - - - indexTx := uint(12) -
    -
    - 138 - -
    - - -
    -
    -
    - 139 - -
    - - - mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(nil, nil).Once() -
    -
    - 140 - -
    - - - callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever) -
    -
    - 141 - -
    - - - _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx) -
    -
    - 142 - -
    - - - require.Error(t, err) -
    -
    - 143 - -
    - - - } -
    -
    - 144 - -
    - - -
    -
    -
    - 145 - -
    - - - func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnTxHashNotMatch(t *testing.T) { -
    -
    - 146 - -
    - - - mockChainRetriever := etherman.NewChainReaderMock(t) -
    -
    - 147 - -
    - - - blockHash := common.HexToHash("0x1") -
    -
    - 148 - -
    - - - indexTx := uint(12) -
    -
    - 149 - -
    - - - tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil) -
    -
    - 150 - -
    - - - mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once() -
    -
    - 151 - -
    - - - callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever) -
    -
    - 152 - -
    - - - _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx) -
    -
    - 153 - -
    - - - require.Error(t, err) -
    -
    - 154 - -
    - - - } -
    -
    - 155 - -
    - - -
    -
    -
    - 156 - -
    - - - func TestCallDataExtractorExtarctCallDataWrongTxData(t *testing.T) { -
    -
    - 157 - -
    - - - mockChainRetriever := etherman.NewChainReaderMock(t) -
    -
    - 158 - -
    - - - blockHash := common.HexToHash("0x1") -
    -
    - 159 - -
    - - - indexTx := uint(12) -
    -
    - 160 - -
    - - - tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil) -
    -
    - 161 - -
    - - - mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once() -
    -
    - 162 - -
    - - - callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever) -
    -
    - 163 - -
    - - - _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, tx.Hash(), indexTx) -
    -
    - 164 - -
    - - - require.Error(t, err) -
    -
    - 165 - -
    - - - } -
    -
    - 166 - -
    - - -
    -
    -
    - 167 - -
    - - - func txExample() *types.Transaction { -
    -
    - 168 - -
    - - - var tx types.Transaction -
    -
    - 169 - -
    - - - reader := bytes.NewBuffer(common.Hex2Bytes(txExampleRLP)) -
    -
    - 170 - -
    - - - stream := rlp.NewStream(reader, 0) -
    -
    - 171 - -
    - - - err := tx.DecodeRLP(stream) -
    -
    - 172 - -
    - - - if err != nil { -
    -
    - 173 - -
    - - - panic(err) -
    -
    - 174 - -
    - - - } -
    -
    - 175 - -
    - - - return &tx -
    -
    - 176 - -
    - - - } -
    -
    - 177 - -
    - - -
    -
    -
    - 178 - -
    - - - const ( -
    -
    - 179 - -
    - - - txExampleRLP = "fa01cc3181c28501699d83808310360194d23c761025306cf5038d74feeb077cf66de134da80ba01cbc438793b4f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000006c50a878df81d7e49424968dfac5e1409bccb68fde08efdeb2225f233039b7f5fa2bb0dc95bcf9c884b2f388092e3db6ff3484770000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000001cac00000000000000000000000000000000000000000000000000000000065f3006b00000000000000000000000000000000000000000000000000000001836e210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000001ca1a000001ca15000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007110b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000000000000008401546d72a04a4304c05e4033d414115b3ad1f652e9da459614f84e7ac2eec2ed6c07660023a013aa534e2b3544baadeb9b82b368d3587b50495086318f0d8289f77912180d18" -
    -
    - 180 - -
    - - - ) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_contracts.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,38 +0,0 @@
    -
    - 1 - -
    - - - package etherman -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/feijoapolygonzkevm" -
    -
    - 5 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 6 - -
    - - - "github.com/ethereum/go-ethereum/accounts/abi/bind" -
    -
    - 7 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 8 - -
    - - - ) -
    -
    - 9 - -
    - - -
    -
    -
    - 10 - -
    - - - // FeijoaContracts represents the contracts of the Feijoa upgrade -
    -
    - 11 - -
    - - - type FeijoaContracts struct { -
    -
    - 12 - -
    - - - FeijoaZKEVMAddress common.Address -
    -
    - 13 - -
    - - - FeijoaZKEVM *feijoapolygonzkevm.Feijoapolygonzkevm -
    -
    - 14 - -
    - - - //FeijoaRollupManager *feijoapolygonrollupmanager.Feijoapolygonrollupmanager -
    -
    - 15 - -
    - - - //FeijoaGlobalExitRootManager *feijoapolygonzkevmglobalexitroot.Feijoapolygonzkevmglobalexitroot -
    -
    - 16 - -
    - - - } -
    -
    - 17 - -
    - - -
    -
    -
    - 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 - -
    - - - return nil, err -
    -
    - 25 - -
    - - - } -
    -
    - 26 - -
    - - -
    -
    -
    - 27 - -
    - - - return &FeijoaContracts{ -
    -
    - 28 - -
    - - - FeijoaZKEVMAddress: FeijoaZKEVMAddress, -
    -
    - 29 - -
    - - - FeijoaZKEVM: FeijoaZKEVM, -
    -
    - 30 - -
    - - - }, nil -
    -
    - 31 - -
    - - - } -
    -
    - 32 - -
    - - -
    -
    -
    - 33 - -
    - - - // GetAddresses returns the addresses of the contracts -
    -
    - 34 - -
    - - - func (f *FeijoaContracts) GetAddresses() []common.Address { -
    -
    - 35 - -
    - - - return []common.Address{ -
    -
    - 36 - -
    - - - f.FeijoaZKEVMAddress, -
    -
    - 37 - -
    - - - } -
    -
    - 38 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_event_sequence_blobs.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,173 +0,0 @@
    -
    - 1 - -
    - - - package etherman -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "encoding/json" -
    -
    - 6 - -
    - - - "fmt" -
    -
    - 7 - -
    - - - "strings" -
    -
    - 8 - -
    - - -
    -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/feijoapolygonzkevm" -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 11 - -
    - - - "github.com/ethereum/go-ethereum/accounts/abi" -
    -
    - 12 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 13 - -
    - - - "github.com/ethereum/go-ethereum/core/types" -
    -
    - 14 - -
    - - - "github.com/ethereum/go-ethereum/crypto" -
    -
    - 15 - -
    - - - ) -
    -
    - 16 - -
    - - -
    -
    -
    - 17 - -
    - - - const ( -
    -
    - 18 - -
    - - - // SequenceBlobsOrder identifies a SequenceBlobs order -
    -
    - 19 - -
    - - - SequenceBlobsOrder EventOrder = "SequenceBlobs" -
    -
    - 20 - -
    - - - ) -
    -
    - 21 - -
    - - -
    -
    -
    - 22 - -
    - - - var ( -
    -
    - 23 - -
    - - - // Events Feijoa Signatures -
    -
    - 24 - -
    - - - // Events new ZkEvm/RollupBase -
    -
    - 25 - -
    - - - // lastBlobSequenced is the count of blob sequenced after process this event -
    -
    - 26 - -
    - - - // if the first event have 1 blob -> lastBlobSequenced=1 -
    -
    - 27 - -
    - - - eventSequenceBlobsSignatureHash = crypto.Keccak256Hash([]byte("SequenceBlobs(uint64)")) -
    -
    - 28 - -
    - - - ) -
    -
    - 29 - -
    - - -
    -
    -
    - 30 - -
    - - - // EventFeijoaSequenceBlobsProcessor is the processor for event SequenceBlobs(uint64) -
    -
    - 31 - -
    - - - type EventFeijoaSequenceBlobsProcessor struct { -
    -
    - 32 - -
    - - - contracts *FeijoaContracts -
    -
    - 33 - -
    - - - } -
    -
    - 34 - -
    - - -
    -
    -
    - 35 - -
    - - - // NewEventFeijoaSequenceBlobsProcessor creates a new EventFeijoaSequenceBlobsProcessor -
    -
    - 36 - -
    - - - func NewEventFeijoaSequenceBlobsProcessor(contracts *FeijoaContracts) *EventFeijoaSequenceBlobsProcessor { -
    -
    - 37 - -
    - - - return &EventFeijoaSequenceBlobsProcessor{ -
    -
    - 38 - -
    - - - contracts: contracts, -
    -
    - 39 - -
    - - - } -
    -
    - 40 - -
    - - - } -
    -
    - 41 - -
    - - -
    -
    -
    - 42 - -
    - - - // EventSignature returns the event signature supported -
    -
    - 43 - -
    - - - func (e *EventFeijoaSequenceBlobsProcessor) EventSignature() common.Hash { -
    -
    - 44 - -
    - - - return eventSequenceBlobsSignatureHash -
    -
    - 45 - -
    - - - } -
    -
    - 46 - -
    - - -
    -
    -
    - 47 - -
    - - - // AddEventDataToBlock adds the event data to the block and returns the Order -
    -
    - 48 - -
    - - - func (e *EventFeijoaSequenceBlobsProcessor) AddEventDataToBlock(ctx context.Context, vLog types.Log, block *Block, callData *CallData) (*Order, error) { -
    -
    - 49 - -
    - - - //err := contract.UnpackLog(&event, "SequenceBlobs", vLog.Data) -
    -
    - 50 - -
    - - - eventData, err := e.contracts.FeijoaZKEVM.ParseSequenceBlobs(vLog) -
    -
    - 51 - -
    - - - if err != nil { -
    -
    - 52 - -
    - - - return nil, err -
    -
    - 53 - -
    - - - } -
    -
    - 54 - -
    - - - for idx := range vLog.Topics { -
    -
    - 55 - -
    - - - log.Debugf("vlog.Topics[%d]: %s ", idx, vLog.Topics[idx].Hex()) -
    -
    - 56 - -
    - - - } -
    -
    - 57 - -
    - - - log.Debugf("LastBlobSequenced: %d", eventData.LastBlobSequenced) -
    -
    - 58 - -
    - - - // decode Data -
    -
    - 59 - -
    - - - inputData, err := e.parseCallData(callData) -
    -
    - 60 - -
    - - - if err != nil { -
    -
    - 61 - -
    - - - return nil, err -
    -
    - 62 - -
    - - - } -
    -
    - 63 - -
    - - - inputData.EventData = &SequenceBlobsEventData{ -
    -
    - 64 - -
    - - - LastBlobSequenced: eventData.LastBlobSequenced, -
    -
    - 65 - -
    - - - } -
    -
    - 66 - -
    - - -
    -
    -
    - 67 - -
    - - - if inputData.thereIsAnyBlobType() { -
    -
    - 68 - -
    - - - // TODO:Retrieve blobs -
    -
    - 69 - -
    - - - return nil, fmt.Errorf("data-availability in blobs: not supported yet") -
    -
    - 70 - -
    - - - } -
    -
    - 71 - -
    - - - // Add the blobs to the block list -
    -
    - 72 - -
    - - - block.SequenceBlobs = append(block.SequenceBlobs, *inputData) -
    -
    - 73 - -
    - - - order := Order{ -
    -
    - 74 - -
    - - - Name: SequenceBatchesOrder, -
    -
    - 75 - -
    - - - Pos: len(block.SequenceBlobs) - 1, -
    -
    - 76 - -
    - - - } -
    -
    - 77 - -
    - - -
    -
    -
    - 78 - -
    - - - return &order, nil -
    -
    - 79 - -
    - - - // Extract Calldata -
    -
    - 80 - -
    - - - } -
    -
    - 81 - -
    - - -
    -
    -
    - 82 - -
    - - - 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 { -
    -
    - 86 - -
    - - - return nil, err -
    -
    - 87 - -
    - - - } -
    -
    - 88 - -
    - - - method, err := smcAbi.MethodById(callData.MethodID()) -
    -
    - 89 - -
    - - - if err != nil { -
    -
    - 90 - -
    - - - return nil, err -
    -
    - 91 - -
    - - - } -
    -
    - 92 - -
    - - - // Unpack method inputs -
    -
    - 93 - -
    - - - data, err := method.Inputs.Unpack(callData.InputData()) -
    -
    - 94 - -
    - - - if err != nil { -
    -
    - 95 - -
    - - - return nil, err -
    -
    - 96 - -
    - - - } -
    -
    - 97 - -
    - - - bytedata, err := json.Marshal(data[0]) -
    -
    - 98 - -
    - - - if err != nil { -
    -
    - 99 - -
    - - - return nil, err -
    -
    - 100 - -
    - - - } -
    -
    - 101 - -
    - - - // Solidity: function sequenceBlobs((uint8,bytes)[] blobsRaw, address l2Coinbase, bytes32 finalAccInputHash) returns() -
    -
    - 102 - -
    - - - var blobsRaw []feijoapolygonzkevm.PolygonRollupBaseFeijoaBlobData -
    -
    - 103 - -
    - - - err = json.Unmarshal(bytedata, &blobsRaw) -
    -
    - 104 - -
    - - - if err != nil { -
    -
    - 105 - -
    - - - return nil, err -
    -
    - 106 - -
    - - - } -
    -
    - 107 - -
    - - - blobs := make([]SequenceBlob, 0) -
    -
    - 108 - -
    - - -
    -
    -
    - 109 - -
    - - - for i := range blobsRaw { -
    -
    - 110 - -
    - - - //log.Debugf("BlobType: %d", blobs[i].BlobType) -
    -
    - 111 - -
    - - - var blobBlobTypeParams *BlobBlobTypeParams -
    -
    - 112 - -
    - - - var blobTypeParams *BlobCommonParams -
    -
    - 113 - -
    - - - var txData []byte -
    -
    - 114 - -
    - - - switch BlobType(blobsRaw[i].BlobType) { -
    -
    - 115 - -
    - - - case TypeCallData: -
    -
    - 116 - -
    - - - blobTypeParams, txData, err = parseBlobCallDataTypeParams(blobsRaw[i].BlobTypeParams) -
    -
    - 117 - -
    - - - if err != nil { -
    -
    - 118 - -
    - - - return nil, err -
    -
    - 119 - -
    - - - } -
    -
    - 120 - -
    - - - case TypeBlobTransaction: -
    -
    - 121 - -
    - - - return nil, fmt.Errorf("blobType 'BlobTransaction' not supported yet") -
    -
    - 122 - -
    - - - default: -
    -
    - 123 - -
    - - - return nil, fmt.Errorf("blobType not supported") -
    -
    - 124 - -
    - - - } -
    -
    - 125 - -
    - - - blobs = append(blobs, SequenceBlob{ -
    -
    - 126 - -
    - - - Type: BlobType(blobsRaw[i].BlobType), -
    -
    - 127 - -
    - - - Params: *blobTypeParams, -
    -
    - 128 - -
    - - - Data: txData, -
    -
    - 129 - -
    - - - BlobBlobTypeParams: blobBlobTypeParams, -
    -
    - 130 - -
    - - - }) -
    -
    - 131 - -
    - - - } -
    -
    - 132 - -
    - - - l1CoinBase := (data[1]).(common.Address) -
    -
    - 133 - -
    - - - finalAccInputHashRaw := (data[2]).([32]byte) -
    -
    - 134 - -
    - - - finalAccInputHash := common.Hash(finalAccInputHashRaw) -
    -
    - 135 - -
    - - -
    -
    -
    - 136 - -
    - - - return &SequenceBlobs{ -
    -
    - 137 - -
    - - - Blobs: blobs, -
    -
    - 138 - -
    - - - L2Coinbase: l1CoinBase, -
    -
    - 139 - -
    - - - FinalAccInputHash: finalAccInputHash, -
    -
    - 140 - -
    - - - }, nil -
    -
    - 141 - -
    - - - } -
    -
    - 142 - -
    - - -
    -
    -
    - 143 - -
    - - - // returns data and the transtaction_data -
    -
    - 144 - -
    - - - func parseBlobCallDataTypeParams(data []byte) (*BlobCommonParams, []byte, error) { -
    -
    - 145 - -
    - - - // https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/feijoa/contracts/v2/lib/PolygonRollupBaseFeijoa.sol -
    -
    - 146 - -
    - - - // case: if (currentBlob.blobType == CALLDATA_BLOB_TYPE) -
    -
    - 147 - -
    - - - // -
    -
    - 148 - -
    - - - // maxSequenceTimestamp uint64 -
    -
    - 149 - -
    - - - // zkGasLimit uint64 -
    -
    - 150 - -
    - - - // l1InfoLeafIndex uint32 -
    -
    - 151 - -
    - - - // transactions []byte -
    -
    - 152 - -
    - - -
    -
    -
    - 153 - -
    - - - // Prepare blob params using ABI encoder -
    -
    - 154 - -
    - - - uint64Ty, _ := abi.NewType("uint64", "", nil) -
    -
    - 155 - -
    - - - uint32Ty, _ := abi.NewType("uint32", "", nil) -
    -
    - 156 - -
    - - - bytesTy, _ := abi.NewType("bytes", "", nil) -
    -
    - 157 - -
    - - - arguments := abi.Arguments{ -
    -
    - 158 - -
    - - - {Type: uint64Ty}, -
    -
    - 159 - -
    - - - {Type: uint64Ty}, -
    -
    - 160 - -
    - - - {Type: uint32Ty}, -
    -
    - 161 - -
    - - - {Type: bytesTy}, -
    -
    - 162 - -
    - - - } -
    -
    - 163 - -
    - - - unpacked, err := arguments.Unpack(data) -
    -
    - 164 - -
    - - - if err != nil { -
    -
    - 165 - -
    - - - return nil, nil, err -
    -
    - 166 - -
    - - - } -
    -
    - 167 - -
    - - - result := &BlobCommonParams{} -
    -
    - 168 - -
    - - - result.MaxSequenceTimestamp = unpacked[0].(uint64) -
    -
    - 169 - -
    - - - result.ZkGasLimit = unpacked[1].(uint64) -
    -
    - 170 - -
    - - - result.L1InfoLeafIndex = unpacked[2].(uint32) -
    -
    - 171 - -
    - - - transactionData := unpacked[3].([]byte) -
    -
    - 172 - -
    - - - return result, transactionData, nil -
    -
    - 173 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,76 +0,0 @@
    -
    - 1 - -
    - - - package etherman -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "fmt" -
    -
    - 5 - -
    - - - "math/big" -
    -
    - 6 - -
    - - -
    -
    -
    - 7 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 8 - -
    - - - "github.com/ethereum/go-ethereum/crypto/kzg4844" -
    -
    - 9 - -
    - - - ) -
    -
    - 10 - -
    - - -
    -
    -
    - 11 - -
    - - - // BlobType is the type of the blob type -
    -
    - 12 - -
    - - - type BlobType uint8 -
    -
    - 13 - -
    - - -
    -
    -
    - 14 - -
    - - - const ( -
    -
    - 15 - -
    - - - // TypeCallData The data is stored on call data directly -
    -
    - 16 - -
    - - - TypeCallData BlobType = 0 -
    -
    - 17 - -
    - - - // TypeBlobTransaction The data is stored on a blob -
    -
    - 18 - -
    - - - TypeBlobTransaction BlobType = 1 -
    -
    - 19 - -
    - - - // TypeForcedBlob The data is a forced Blob -
    -
    - 20 - -
    - - - TypeForcedBlob BlobType = 2 -
    -
    - 21 - -
    - - - ) -
    -
    - 22 - -
    - - -
    -
    -
    - 23 - -
    - - - // SequenceBlob is for each Blob inside a SequenceBlobs -
    -
    - 24 - -
    - - - type SequenceBlob struct { -
    -
    - 25 - -
    - - - Type BlobType -
    -
    - 26 - -
    - - - Params BlobCommonParams -
    -
    - 27 - -
    - - - Data []byte -
    -
    - 28 - -
    - - - // Field only valid if BlobType == BlobTransaction -
    -
    - 29 - -
    - - - BlobBlobTypeParams *BlobBlobTypeParams -
    -
    - 30 - -
    - - - } -
    -
    - 31 - -
    - - -
    -
    -
    - 32 - -
    - - - func (s *SequenceBlob) String() string { -
    -
    - 33 - -
    - - - return fmt.Sprintf("Type: %d, Params: %v, Data: %v, BlobBlobTypeParams: %v", s.Type, s.Params, s.Data, s.BlobBlobTypeParams) -
    -
    - 34 - -
    - - - } -
    -
    - 35 - -
    - - -
    -
    -
    - 36 - -
    - - - // BlobCommonParams is the data for a SequenceBlob -
    -
    - 37 - -
    - - - type BlobCommonParams struct { -
    -
    - 38 - -
    - - - MaxSequenceTimestamp uint64 -
    -
    - 39 - -
    - - - ZkGasLimit uint64 -
    -
    - 40 - -
    - - - L1InfoLeafIndex uint32 -
    -
    - 41 - -
    - - - } -
    -
    - 42 - -
    - - -
    -
    -
    - 43 - -
    - - - // BlobBlobTypeParams is the data for a SequenceBlob stored on a Blob -
    -
    - 44 - -
    - - - // case: if (currentBlob.blobType ==> BLOBTX_BLOB_TYPE) -
    -
    - 45 - -
    - - - // sames as calldata plus BlobIndex, ... -
    -
    - 46 - -
    - - - type BlobBlobTypeParams struct { -
    -
    - 47 - -
    - - - BlobIndex *big.Int -
    -
    - 48 - -
    - - - Z []byte -
    -
    - 49 - -
    - - - Y []byte -
    -
    - 50 - -
    - - - Commitment kzg4844.Commitment -
    -
    - 51 - -
    - - - Proof kzg4844.Proof -
    -
    - 52 - -
    - - - } -
    -
    - 53 - -
    - - -
    -
    -
    - 54 - -
    - - - // SequenceBlobs is the data in the event SequenceBlobs -
    -
    - 55 - -
    - - - type SequenceBlobs struct { -
    -
    - 56 - -
    - - - Blobs []SequenceBlob -
    -
    - 57 - -
    - - - L2Coinbase common.Address // from Calldata -
    -
    - 58 - -
    - - - FinalAccInputHash common.Hash -
    -
    - 59 - -
    - - - EventData *SequenceBlobsEventData -
    -
    - 60 - -
    - - - } -
    -
    - 61 - -
    - - -
    -
    -
    - 62 - -
    - - - // SequenceBlobsEventData is the data in the event SequenceBlobs -
    -
    - 63 - -
    - - - type SequenceBlobsEventData struct { -
    -
    - 64 - -
    - - - // LastBlobSequenced is the count of blob sequenced after process this event -
    -
    - 65 - -
    - - - // if the first event have 1 blob -> lastBlobSequenced=1 -
    -
    - 66 - -
    - - - LastBlobSequenced uint64 -
    -
    - 67 - -
    - - - } -
    -
    - 68 - -
    - - -
    -
    -
    - 69 - -
    - - - func (s *SequenceBlobs) thereIsAnyBlobType() bool { -
    -
    - 70 - -
    - - - for blobIndex := range s.Blobs { -
    -
    - 71 - -
    - - - if s.Blobs[blobIndex].Type == TypeBlobTransaction { -
    -
    - 72 - -
    - - - return true -
    -
    - 73 - -
    - - - } -
    -
    - 74 - -
    - - - } -
    -
    - 75 - -
    - - - return false -
    -
    - 76 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,17 +0,0 @@
    -
    - 1 - -
    - - - package etherman -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "testing" -
    -
    - 5 - -
    - - -
    -
    -
    - 6 - -
    - - - "github.com/stretchr/testify/require" -
    -
    - 7 - -
    - - - ) -
    -
    - 8 - -
    - - -
    -
    -
    - 9 - -
    - - - func TestXxx(t *testing.T) { -
    -
    - 10 - -
    - - - _, err := NewFeijoaContracts(nil, L1Config{}) -
    -
    - 11 - -
    - - - require.NoError(t, err) -
    -
    - 12 - -
    - - - } -
    -
    - 13 - -
    - - -
    -
    -
    - 14 - -
    - - - func TestFeijoaEventsSignature(t *testing.T) { -
    -
    - 15 - -
    - - - // Signature extracted from https://sepolia.etherscan.io/tx/0x644699c839d34a61c531d7ecf12390bf38c06a62715ca4edce978b9213ce3cd1#eventlog -
    -
    - 16 - -
    - - - require.Equal(t, "0x470f4ca4b003755c839b80ab00c3efbeb69d6eafec00e1a3677482933ec1fd0c", eventSequenceBlobsSignatureHash.String()) -
    -
    - 17 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,16 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - package etherman -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + -
    -
    -
    - 6 - -
    - + - "github.com/ethereum/go-ethereum/common" -
    -
    - 7 - -
    - + - "github.com/jackc/pgx/v4" -
    -
    - 8 - -
    - + - ) -
    -
    - 9 - -
    - + -
    -
    -
    - 10 - -
    - + - type dataAvailabilityProvider interface { -
    -
    - 11 - -
    - + - GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) -
    -
    - 12 - -
    - + - } -
    -
    - 13 - -
    - + -
    -
    -
    - 14 - -
    - + - type stateProvider interface { -
    -
    - 15 - -
    - + - GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) -
    -
    - 16 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -5,25 +5,26 @@
    -
    - 5 - -
    -   - "fmt" -
    -
    - 6 - -
    -   - "math/big" -
    -
    - 7 - -
    -   -
    -
    -
    - 8 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonrollupmanager" -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevm" -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevmbridge" -
    -
    - 11 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevmglobalexitroot" -
    -
    - 12 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mocketrogpolygonrollupmanager" -
    -
    - 13 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockverifier" -
    -
    - 14 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/pol" -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 15 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proxy" -
    -
    - 16 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 17 - -
    -   - "github.com/ethereum/go-ethereum/accounts/abi/bind" -
    -
    - 18 - -
    -   - "github.com/ethereum/go-ethereum/common" -
    -
    - 19 - -
    - - - "github.com/ethereum/go-ethereum/core/types" -
    -
    - 20 - -
    -   - "github.com/ethereum/go-ethereum/crypto" -
    -
    - 21 - -
    -   - "github.com/ethereum/go-ethereum/ethclient/simulated" -
    -
    - 22 - -
    -   - ) -
    -
    - 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, *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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 { -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 5 - -
    -   - "fmt" -
    -
    - 6 - -
    -   - "math/big" -
    -
    - 7 - -
    -   -
    -
    -
    - 8 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockpolygonrollupmanager" -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -19,7 +19,6 @@
    -
    - 19 - -
    -   - VerifiedBatches []VerifiedBatch -
    -
    - 20 - -
    -   - SequencedForceBatches [][]SequencedForceBatch -
    -
    - 21 - -
    -   - ForkIDs []ForkID -
    -
    - 22 - -
    - - - SequenceBlobs []SequenceBlobs -
    -
    - 23 - -
    -   - ReceivedAt time.Time -
    -
    - 24 - -
    -   - // GER data -
    -
    - 25 - -
    -   - GlobalExitRoots, L1InfoTree []GlobalExitRoot -
    -
    -
    @@ -50,9 +49,9 @@
    -
    - 50 - -
    -   - Nonce uint64 -
    -
    - 51 - -
    -   - Coinbase common.Address -
    -
    - 52 - -
    -   - // Struct used in preEtrog forks -
    -
    - 53 - -
    - - - *preetrogpolygonzkevm.PolygonZkEVMBatchData -
    -
    - 54 - -
    -   - // Struct used in Etrog -
    -
    - 55 - -
    - - - *etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 56 - -
    -   - // Struct used in Elderberry -
    -
    - 57 - -
    -   - *SequencedBatchElderberryData -
    -
    - 58 - -
    -   - } -
    -
    -
    @@ -64,7 +63,7 @@
    -
    - 64 - -
    -   - TxHash common.Hash -
    -
    - 65 - -
    -   - Nonce uint64 -
    -
    - 66 - -
    -   - // Struct used in Etrog -
    -
    - 67 - -
    - - - *etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 68 - -
    -   - } -
    -
    - 69 - -
    -   -
    -
    -
    - 70 - -
    -   - // ForcedBatch represents a ForcedBatch -
    -
    -
    @@ -93,7 +92,7 @@
    -
    - 93 - -
    -   - TxHash common.Hash -
    -
    - 94 - -
    -   - Timestamp time.Time -
    -
    - 95 - -
    -   - Nonce uint64 -
    -
    - 96 - -
    - - - etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 97 - -
    -   - } -
    -
    - 98 - -
    -   -
    -
    -
    - 99 - -
    -   - // ForkID is a sturct to track the ForkID event. -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 19 - -
    -   - VerifiedBatches []VerifiedBatch -
    -
    - 20 - -
    -   - SequencedForceBatches [][]SequencedForceBatch -
    -
    - 21 - -
    -   - ForkIDs []ForkID -
    -
    - - -
    -   -
    -
    -
    - 22 - -
    -   - ReceivedAt time.Time -
    -
    - 23 - -
    -   - // GER data -
    -
    - 24 - -
    -   - GlobalExitRoots, L1InfoTree []GlobalExitRoot -
    -
    -
     
    -
    - 49 - -
    -   - Nonce uint64 -
    -
    - 50 - -
    -   - Coinbase common.Address -
    -
    - 51 - -
    -   - // Struct used in preEtrog forks -
    -
    - 52 - -
    - + - *oldpolygonzkevm.PolygonZkEVMBatchData -
    -
    - 53 - -
    -   - // Struct used in Etrog -
    -
    - 54 - -
    - + - *polygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 55 - -
    -   - // Struct used in Elderberry -
    -
    - 56 - -
    -   - *SequencedBatchElderberryData -
    -
    - 57 - -
    -   - } -
    -
    -
     
    -
    - 63 - -
    -   - TxHash common.Hash -
    -
    - 64 - -
    -   - Nonce uint64 -
    -
    - 65 - -
    -   - // Struct used in Etrog -
    -
    - 66 - -
    - + - *polygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 67 - -
    -   - } -
    -
    - 68 - -
    -   -
    -
    -
    - 69 - -
    -   - // ForcedBatch represents a ForcedBatch -
    -
    -
     
    -
    - 92 - -
    -   - TxHash common.Hash -
    -
    - 93 - -
    -   - Timestamp time.Time -
    -
    - 94 - -
    -   - Nonce uint64 -
    -
    - 95 - -
    - + - polygonzkevm.PolygonRollupBaseEtrogBatchData -
    -
    - 96 - -
    -   - } -
    -
    - 97 - -
    -   -
    -
    -
    - 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 @@
    -
    - 59 - -
    -   - return c -
    -
    - 60 - -
    -   - } -
    -
    - 61 - -
    -   -
    -
    -
    - 62 - -
    - - - // getTxNonce get the nonce for the given account -
    -
    - 63 - -
    - - - func (c *Client) getTxNonce(ctx context.Context, from common.Address) (uint64, error) { -
    -
    - 64 - -
    - - - // Get created transactions from the database for the given account -
    -
    - 65 - -
    - - - createdTxs, err := c.storage.GetBySenderAndStatus(ctx, from, []MonitoredTxStatus{MonitoredTxStatusCreated}, nil) -
    -
    - 66 - -
    - - - if err != nil { -
    -
    - 67 - -
    - - - return 0, fmt.Errorf("failed to get created monitored txs: %w", err) -
    -
    - 68 - -
    - - - } -
    -
    - 69 - -
    - - -
    -
    -
    - 70 - -
    - - - var nonce uint64 -
    -
    - 71 - -
    - - - if len(createdTxs) > 0 { -
    -
    - 72 - -
    - - - // if there are pending txs, we adjust the nonce accordingly -
    -
    - 73 - -
    - - - for _, createdTx := range createdTxs { -
    -
    - 74 - -
    - - - if createdTx.nonce > nonce { -
    -
    - 75 - -
    - - - nonce = createdTx.nonce -
    -
    - 76 - -
    - - - } -
    -
    - 77 - -
    - - - } -
    -
    - 78 - -
    - - -
    -
    -
    - 79 - -
    - - - nonce++ -
    -
    - 80 - -
    - - - } else { -
    -
    - 81 - -
    - - - // if there are no pending txs, we get the pending nonce from the etherman -
    -
    - 82 - -
    - - - if nonce, err = c.etherman.PendingNonce(ctx, from); err != nil { -
    -
    - 83 - -
    - - - return 0, fmt.Errorf("failed to get pending nonce: %w", err) -
    -
    - 84 - -
    - - - } -
    -
    - 85 - -
    - - - } -
    -
    - 86 - -
    - - -
    -
    -
    - 87 - -
    - - - return nonce, nil -
    -
    - 88 - -
    - - - } -
    -
    - 89 - -
    - - -
    -
    -
    - 90 - -
    -   - // Add a transaction to be sent and monitored -
    -
    - 91 - -
    -   - 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 { -
    -
    - 92 - -
    - - - // get nonce -
    -
    - 93 - -
    - - - nonce, err := c.getTxNonce(ctx, from) -
    -
    - 94 - -
    -   - if err != nil { -
    -
    - 95 - -
    - - - err := fmt.Errorf("failed to get nonce: %w", err) -
    -
    - 96 - -
    -   - log.Errorf(err.Error()) -
    -
    - 97 - -
    -   - return err -
    -
    - 98 - -
    -   - } -
    -
    - 99 - -
    - - -
    -
    -
    - 100 - -
    -   - // get gas -
    -
    - 101 - -
    -   - gas, err := c.etherman.EstimateGas(ctx, from, to, value, data) -
    -
    - 102 - -
    -   - if err != nil { -
    -
    -
    @@ -594,7 +565,7 @@
    -
    - 594 - -
    -   - // causing possible side effects and wasting resources. -
    -
    - 595 - -
    -   - func (c *Client) reviewMonitoredTxNonce(ctx context.Context, mTx *monitoredTx, mTxLogger *log.Logger) error { -
    -
    - 596 - -
    -   - mTxLogger.Debug("reviewing nonce") -
    -
    - 597 - -
    - - - nonce, err := c.getTxNonce(ctx, mTx.from) -
    -
    - 598 - -
    -   - if err != nil { -
    -
    - 599 - -
    -   - err := fmt.Errorf("failed to load current nonce for acc %v: %w", mTx.from.String(), err) -
    -
    - 600 - -
    -   - mTxLogger.Errorf(err.Error()) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 59 - -
    -   - return c -
    -
    - 60 - -
    -   - } -
    -
    - 61 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 62 - -
    -   - // Add a transaction to be sent and monitored -
    -
    - 63 - -
    -   - 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 { -
    -
    - 64 - -
    - + - // get next nonce -
    -
    - 65 - -
    - + - nonce, err := c.etherman.CurrentNonce(ctx, from) -
    -
    - 66 - -
    -   - if err != nil { -
    -
    - 67 - -
    - + - err := fmt.Errorf("failed to get current nonce: %w", err) -
    -
    - 68 - -
    -   - log.Errorf(err.Error()) -
    -
    - 69 - -
    -   - return err -
    -
    - 70 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - 71 - -
    -   - // get gas -
    -
    - 72 - -
    -   - gas, err := c.etherman.EstimateGas(ctx, from, to, value, data) -
    -
    - 73 - -
    -   - if err != nil { -
    -
    -
     
    -
    - 565 - -
    -   - // causing possible side effects and wasting resources. -
    -
    - 566 - -
    -   - func (c *Client) reviewMonitoredTxNonce(ctx context.Context, mTx *monitoredTx, mTxLogger *log.Logger) error { -
    -
    - 567 - -
    -   - mTxLogger.Debug("reviewing nonce") -
    -
    - 568 - -
    - + - nonce, err := c.etherman.CurrentNonce(ctx, mTx.from) -
    -
    - 569 - -
    -   - if err != nil { -
    -
    - 570 - -
    -   - err := fmt.Errorf("failed to load current nonce for acc %v: %w", mTx.from.String(), err) -
    -
    - 571 - -
    -   - mTxLogger.Errorf(err.Error()) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/ethtxmanager_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -47,7 +47,7 @@
    -
    - 47 - -
    -   -
    -
    -
    - 48 - -
    -   - currentNonce := uint64(1) -
    -
    - 49 - -
    -   - etherman. -
    -
    - 50 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 51 - -
    -   - Return(currentNonce, nil). -
    -
    - 52 - -
    -   - Once() -
    -
    - 53 - -
    -   -
    -
    -
    -
    @@ -165,7 +165,7 @@
    -
    - 165 - -
    -   - // Add -
    -
    - 166 - -
    -   - currentNonce := uint64(1) -
    -
    - 167 - -
    -   - etherman. -
    -
    - 168 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 169 - -
    -   - Return(currentNonce, nil). -
    -
    - 170 - -
    -   - Once() -
    -
    - 171 - -
    -   -
    -
    -
    -
    @@ -331,7 +331,7 @@
    -
    - 331 - -
    -   - // Add -
    -
    - 332 - -
    -   - currentNonce := uint64(1) -
    -
    - 333 - -
    -   - etherman. -
    -
    - 334 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 335 - -
    -   - Return(currentNonce, nil). -
    -
    - 336 - -
    -   - Once() -
    -
    - 337 - -
    -   -
    -
    -
    -
    @@ -521,7 +521,7 @@
    -
    - 521 - -
    -   - // Add -
    -
    - 522 - -
    -   - currentNonce := uint64(1) -
    -
    - 523 - -
    -   - etherman. -
    -
    - 524 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 525 - -
    -   - Return(currentNonce, nil). -
    -
    - 526 - -
    -   - Once() -
    -
    - 527 - -
    -   -
    -
    -
    -
    @@ -593,7 +593,7 @@
    -
    - 593 - -
    -   -
    -
    -
    - 594 - -
    -   - currentNonce = uint64(2) -
    -
    - 595 - -
    -   - etherman. -
    -
    - 596 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 597 - -
    -   - Return(currentNonce, nil). -
    -
    - 598 - -
    -   - Once() -
    -
    - 599 - -
    -   - secondGasEstimation := uint64(2) -
    -
    -
    @@ -751,7 +751,7 @@
    -
    - 751 - -
    -   -
    -
    -
    - 752 - -
    -   - currentNonce := uint64(1) -
    -
    - 753 - -
    -   - etherman. -
    -
    - 754 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 755 - -
    -   - Return(currentNonce, nil). -
    -
    - 756 - -
    -   - Once() -
    -
    - 757 - -
    -   -
    -
    -
    -
    @@ -832,7 +832,7 @@
    -
    - 832 - -
    -   -
    -
    -
    - 833 - -
    -   - currentNonce := uint64(1) -
    -
    - 834 - -
    -   - etherman. -
    -
    - 835 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 836 - -
    -   - Return(currentNonce, nil). -
    -
    - 837 - -
    -   - Once() -
    -
    - 838 - -
    -   -
    -
    -
    -
    @@ -886,7 +886,7 @@
    -
    - 886 - -
    -   -
    -
    -
    - 887 - -
    -   - currentNonce := uint64(1) -
    -
    - 888 - -
    -   - etherman. -
    -
    - 889 - -
    - - - On("PendingNonce", ctx, from). -
    -
    - 890 - -
    -   - Return(currentNonce, nil). -
    -
    - 891 - -
    -   - Once() -
    -
    - 892 - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 47 - -
    -   -
    -
    -
    - 48 - -
    -   - currentNonce := uint64(1) -
    -
    - 49 - -
    -   - etherman. -
    -
    - 50 - -
    - + - On("CurrentNonce", ctx, from). -
    -
    - 51 - -
    -   - Return(currentNonce, nil). -
    -
    - 52 - -
    -   - Once() -
    -
    - 53 - -
    -   -
    -
    -
    -
     
    -
    - 165 - -
    -   - // Add -
    -
    - 166 - -
    -   - currentNonce := uint64(1) -
    -
    - 167 - -
    -   - etherman. -
    -
    - 168 - -
    - + - On("CurrentNonce", ctx, from). -
    -
    - 169 - -
    -   - Return(currentNonce, nil). -
    -
    - 170 - -
    -   - Once() -
    -
    - 171 - -
    -   -
    -
    -
    -
     
    -
    - 331 - -
    -   - // Add -
    -
    - 332 - -
    -   - currentNonce := uint64(1) -
    -
    - 333 - -
    -   - etherman. -
    -
    - 334 - -
    - + - On("CurrentNonce", ctx, from). -
    -
    - 335 - -
    -   - Return(currentNonce, nil). -
    -
    - 336 - -
    -   - Once() -
    -
    - 337 - -
    -   -
    -
    -
    -
     
    -
    - 521 - -
    -   - // Add -
    -
    - 522 - -
    -   - currentNonce := uint64(1) -
    -
    - 523 - -
    -   - etherman. -
    -
    - 524 - -
    - + - On("CurrentNonce", ctx, from). -
    -
    - 525 - -
    -   - Return(currentNonce, nil). -
    -
    - 526 - -
    -   - Once() -
    -
    - 527 - -
    -   -
    -
    -
    -
     
    -
    - 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 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -   - CurrentNonce(ctx context.Context, account common.Address) (uint64, error) -
    -
    - 20 - -
    -   - SuggestedGasPrice(ctx context.Context) (*big.Int, error) -
    -
    - 21 - -
    -   - EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte) (uint64, error) -
    -
    -
     
    -
    - 28 - -
    -   - Add(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error -
    -
    - 29 - -
    -   - Get(ctx context.Context, owner, id string, dbTx pgx.Tx) (monitoredTx, error) -
    -
    - 30 - -
    -   - GetByStatus(ctx context.Context, owner *string, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error) -
    -
    - - -
    -   -
    -
    -
    - 31 - -
    -   - GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error) -
    -
    - 32 - -
    -   - Update(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error -
    -
    - 33 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/pgstorage.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -123,50 +123,6 @@
    -
    - 123 - -
    -   - return mTxs, nil -
    -
    - 124 - -
    -   - } -
    -
    - 125 - -
    -   -
    -
    -
    - 126 - -
    - - - // GetBySenderAndStatus loads all monitored txs of the given sender that match the provided status -
    -
    - 127 - -
    - - - func (s *PostgresStorage) GetBySenderAndStatus(ctx context.Context, sender common.Address, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error) { -
    -
    - 128 - -
    - - - hasStatusToFilter := len(statuses) > 0 -
    -
    - 129 - -
    - - -
    -
    -
    - 130 - -
    - - - conn := s.dbConn(dbTx) -
    -
    - 131 - -
    - - - cmd := ` -
    -
    - 132 - -
    - - - SELECT owner, id, from_addr, to_addr, nonce, value, data, gas, gas_offset, gas_price, status, block_num, history, created_at, updated_at -
    -
    - 133 - -
    - - - FROM state.monitored_txs -
    -
    - 134 - -
    - - - WHERE from_addr = $1` -
    -
    - 135 - -
    - - - if hasStatusToFilter { -
    -
    - 136 - -
    - - - cmd += ` -
    -
    - 137 - -
    - - - AND status = ANY($2)` -
    -
    - 138 - -
    - - - } -
    -
    - 139 - -
    - - - cmd += ` -
    -
    - 140 - -
    - - - ORDER BY created_at` -
    -
    - 141 - -
    - - -
    -
    -
    - 142 - -
    - - - mTxs := []monitoredTx{} -
    -
    - 143 - -
    - - -
    -
    -
    - 144 - -
    - - - var rows pgx.Rows -
    -
    - 145 - -
    - - - var err error -
    -
    - 146 - -
    - - - if hasStatusToFilter { -
    -
    - 147 - -
    - - - rows, err = conn.Query(ctx, cmd, sender.String(), statuses) -
    -
    - 148 - -
    - - - } else { -
    -
    - 149 - -
    - - - rows, err = conn.Query(ctx, cmd, sender.String()) -
    -
    - 150 - -
    - - - } -
    -
    - 151 - -
    - - -
    -
    -
    - 152 - -
    - - - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 153 - -
    - - - return []monitoredTx{}, nil -
    -
    - 154 - -
    - - - } else if err != nil { -
    -
    - 155 - -
    - - - return nil, err -
    -
    - 156 - -
    - - - } -
    -
    - 157 - -
    - - -
    -
    -
    - 158 - -
    - - - for rows.Next() { -
    -
    - 159 - -
    - - - mTx := monitoredTx{} -
    -
    - 160 - -
    - - - err := s.scanMtx(rows, &mTx) -
    -
    - 161 - -
    - - - if err != nil { -
    -
    - 162 - -
    - - - return nil, err -
    -
    - 163 - -
    - - - } -
    -
    - 164 - -
    - - - mTxs = append(mTxs, mTx) -
    -
    - 165 - -
    - - - } -
    -
    - 166 - -
    - - -
    -
    -
    - 167 - -
    - - - return mTxs, nil -
    -
    - 168 - -
    - - - } -
    -
    - 169 - -
    - - -
    -
    -
    - 170 - -
    -   - // GetByBlock loads all monitored tx that have the blockNumber between -
    -
    - 171 - -
    -   - // fromBlock and toBlock -
    -
    - 172 - -
    -   - func (s *PostgresStorage) GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error) { -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 123 - -
    -   - return mTxs, nil -
    -
    - 124 - -
    -   - } -
    -
    - 125 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -163,72 +163,6 @@
    -
    - 163 - -
    -   - assert.Equal(t, "confirmed2", mTxs[7].id) -
    -
    - 164 - -
    -   - } -
    -
    - 165 - -
    -   -
    -
    -
    - 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 -
    -
    - 199 - -
    - - - baseMtx.createdAt = baseMtx.createdAt.Add(time.Microsecond) -
    -
    - 200 - -
    - - - baseMtx.updatedAt = baseMtx.updatedAt.Add(time.Microsecond) -
    -
    - 201 - -
    - - - err = storage.Add(context.Background(), baseMtx, nil) -
    -
    - 202 - -
    - - - require.NoError(t, err) -
    -
    - 203 - -
    - - - } -
    -
    - 204 - -
    - - -
    -
    -
    - 205 - -
    - - - mTxs, err := storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{MonitoredTxStatusConfirmed}, nil) -
    -
    - 206 - -
    - - - require.NoError(t, err) -
    -
    - 207 - -
    - - - assert.Equal(t, 2, len(mTxs)) -
    -
    - 208 - -
    - - - assert.Equal(t, "confirmed1", mTxs[0].id) -
    -
    - 209 - -
    - - - assert.Equal(t, "confirmed2", mTxs[1].id) -
    -
    - 210 - -
    - - -
    -
    -
    - 211 - -
    - - - mTxs, err = storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{MonitoredTxStatusSent, MonitoredTxStatusCreated}, nil) -
    -
    - 212 - -
    - - - require.NoError(t, err) -
    -
    - 213 - -
    - - - assert.Equal(t, 4, len(mTxs)) -
    -
    - 214 - -
    - - - assert.Equal(t, "created1", mTxs[0].id) -
    -
    - 215 - -
    - - - assert.Equal(t, "sent1", mTxs[1].id) -
    -
    - 216 - -
    - - - assert.Equal(t, "created2", mTxs[2].id) -
    -
    - 217 - -
    - - - assert.Equal(t, "sent2", mTxs[3].id) -
    -
    - 218 - -
    - - -
    -
    -
    - 219 - -
    - - - mTxs, err = storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{}, nil) -
    -
    - 220 - -
    - - - require.NoError(t, err) -
    -
    - 221 - -
    - - - assert.Equal(t, 8, len(mTxs)) -
    -
    - 222 - -
    - - - assert.Equal(t, "created1", mTxs[0].id) -
    -
    - 223 - -
    - - - assert.Equal(t, "sent1", mTxs[1].id) -
    -
    - 224 - -
    - - - assert.Equal(t, "failed1", mTxs[2].id) -
    -
    - 225 - -
    - - - assert.Equal(t, "confirmed1", mTxs[3].id) -
    -
    - 226 - -
    - - - assert.Equal(t, "created2", mTxs[4].id) -
    -
    - 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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 166 - -
    -   - func TestAddRepeated(t *testing.T) { -
    -
    - 167 - -
    -   - dbCfg := dbutils.NewStateConfigFromEnv() -
    -
    - 168 - -
    -   - require.NoError(t, dbutils.InitOrResetState(dbCfg)) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -42,6 +42,9 @@
    -
    - 42 - -
    -   - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" -
    -
    - 43 - -
    -   - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts -
    -
    - 44 - -
    -   - EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT" -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 45 - -
    -   - // EventID_NodeOOC is triggered when an OOC at node level is detected -
    -
    - 46 - -
    -   - EventID_NodeOOC EventID = "NODE OOC" -
    -
    - 47 - -
    -   - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 42 - -
    -   - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" -
    -
    - 43 - -
    -   - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts -
    -
    - 44 - -
    -   - 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 - -
    - + -
    -
    -
    - 48 - -
    -   - // EventID_NodeOOC is triggered when an OOC at node level is detected -
    -
    - 49 - -
    -   - EventID_NodeOOC EventID = "NODE OOC" -
    -
    - 50 - -
    -   - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/event/eventlog.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -29,7 +29,7 @@
    -
    - 29 - -
    -   - } -
    -
    - 30 - -
    -   -
    -
    -
    - 31 - -
    -   - // LogExecutorError is used to store Executor error for runtime debugging -
    -
    - 32 - -
    - - - func (e *EventLog) LogExecutorError(ctx context.Context, responseError executor.ExecutorError, processBatchRequest interface{}) { -
    -
    - 33 - -
    -   - timestamp := time.Now() -
    -
    - 34 - -
    -   -
    -
    -
    - 35 - -
    -   - // if it's a user related error, ignore it -
    -
    -
    @@ -47,6 +47,30 @@
    -
    - 47 - -
    -   - log.Errorf("error found in the executor: %v at %v", responseError, timestamp) -
    -
    - 48 - -
    -   - payload, err := json.Marshal(processBatchRequest) -
    -
    - 49 - -
    -   - if err != nil { -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 50 - -
    -   - log.Errorf("error marshaling payload: %v", err) -
    -
    - 51 - -
    -   - } else { -
    -
    - 52 - -
    -   - event := &Event{ -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 29 - -
    -   - } -
    -
    - 30 - -
    -   -
    -
    -
    - 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 - -
    -   -
    -
    -
    - 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 { -
    -
    - 50 - -
    - + - log.Errorf("error marshaling payload: %v", err) -
    -
    - 51 - -
    - + - } else { -
    -
    - 52 - -
    - + - event := &Event{ -
    -
    - 53 - -
    - + - ReceivedAt: timestamp, -
    -
    - 54 - -
    - + - Source: Source_Node, -
    -
    - 55 - -
    - + - Component: Component_Executor, -
    -
    - 56 - -
    - + - Level: Level_Error, -
    -
    - 57 - -
    - + - EventID: EventID_ExecutorError, -
    -
    - 58 - -
    - + - Description: responseError.String(), -
    -
    - 59 - -
    - + - Json: string(payload), -
    -
    - 60 - -
    - + - } -
    -
    - 61 - -
    - + - err = e.storage.LogEvent(ctx, event) -
    -
    - 62 - -
    - + - if err != nil { -
    -
    - 63 - -
    - + - log.Errorf("error storing event: %v", err) -
    -
    - 64 - -
    - + - } -
    -
    - 65 - -
    - + - } -
    -
    - 66 - -
    - + - } -
    -
    - 67 - -
    - + -
    -
    -
    - 68 - -
    - + - // LogExecutorErrorV2 is used to store Executor error for runtime debugging -
    -
    - 69 - -
    - + - func (e *EventLog) LogExecutorErrorV2(ctx context.Context, responseError executor.ExecutorError, processBatchRequest *executor.ProcessBatchRequestV2) { -
    -
    - 70 - -
    - + - timestamp := time.Now() -
    -
    - 71 - -
    - + - log.Errorf("error found in the executor: %v at %v", responseError, timestamp) -
    -
    - 72 - -
    - + - payload, err := json.Marshal(processBatchRequest) -
    -
    - 73 - -
    - + - if err != nil { -
    -
    - 74 - -
    -   - log.Errorf("error marshaling payload: %v", err) -
    -
    - 75 - -
    -   - } else { -
    -
    - 76 - -
    -   - event := &Event{ -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 - -
    -   - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -6,32 +6,32 @@
    -
    - 6 - -
    -   - github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1 -
    -
    - 7 - -
    -   - github.com/didip/tollbooth/v6 v6.1.2 -
    -
    - 8 - -
    -   - github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 -
    -
    - 9 - -
    - - - github.com/ethereum/go-ethereum v1.13.14 -
    -
    - 10 - -
    -   - github.com/go-git/go-billy/v5 v5.5.0 -
    -
    - 11 - -
    - - - github.com/go-git/go-git/v5 v5.12.0 -
    -
    - 12 - -
    -   - github.com/gobuffalo/packr/v2 v2.8.3 -
    -
    - 13 - -
    - - - github.com/google/uuid v1.6.0 -
    -
    - 14 - -
    -   - github.com/habx/pg-commands v0.6.1 -
    -
    - 15 - -
    -   - github.com/hermeznetwork/tracerr v0.3.2 -
    -
    - 16 - -
    - - - github.com/iden3/go-iden3-crypto v0.0.16 -
    -
    - 17 - -
    -   - github.com/invopop/jsonschema v0.12.0 -
    -
    - 18 - -
    - - - github.com/jackc/pgconn v1.14.3 -
    -
    - 19 - -
    - - - github.com/jackc/pgx/v4 v4.18.3 -
    -
    - 20 - -
    -   - github.com/mitchellh/mapstructure v1.5.0 -
    -
    - 21 - -
    - - - github.com/prometheus/client_model v0.6.1 -
    -
    - 22 - -
    - - - github.com/prometheus/common v0.53.0 -
    -
    - 23 - -
    -   - github.com/rubenv/sql-migrate v1.6.1 -
    -
    - 24 - -
    -   - github.com/spf13/afero v1.11.0 -
    -
    - 25 - -
    - - - github.com/spf13/viper v1.17.0 -
    -
    - 26 - -
    - - - github.com/stretchr/testify v1.9.0 -
    -
    - 27 - -
    - - - github.com/umbracle/ethgo v0.1.3 -
    -
    - 28 - -
    - - - github.com/urfave/cli/v2 v2.27.2 -
    -
    - 29 - -
    - - - go.uber.org/zap v1.27.0 -
    -
    - 30 - -
    - - - golang.org/x/crypto v0.22.0 -
    -
    - 31 - -
    - - - golang.org/x/net v0.24.0 -
    -
    - 32 - -
    - - - golang.org/x/sync v0.7.0 -
    -
    - 33 - -
    - - - google.golang.org/grpc v1.63.2 -
    -
    - 34 - -
    - - - google.golang.org/protobuf v1.34.0 -
    -
    - 35 - -
    -   - gopkg.in/yaml.v2 v2.4.0 -
    -
    - 36 - -
    -   - gopkg.in/yaml.v3 v3.0.1 -
    -
    - 37 - -
    -   - ) -
    -
    -
    @@ -40,16 +40,16 @@
    -
    - 40 - -
    -   - dario.cat/mergo v1.0.0 // indirect -
    -
    - 41 - -
    -   - github.com/DataDog/zstd v1.5.2 // indirect -
    -
    - 42 - -
    -   - github.com/Microsoft/go-winio v0.6.1 // indirect -
    -
    - 43 - -
    - - - github.com/ProtonMail/go-crypto v1.0.0 // indirect -
    -
    - 44 - -
    -   - github.com/StackExchange/wmi v1.2.1 // indirect -
    -
    - 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.10.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 -
    -
    - 52 - -
    - - - github.com/cloudflare/circl v1.3.7 // indirect -
    -
    - 53 - -
    -   - github.com/cockroachdb/errors v1.9.1 // indirect -
    -
    - 54 - -
    -   - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect -
    -
    - 55 - -
    -   - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect -
    -
    -
    @@ -57,18 +57,18 @@
    -
    - 57 - -
    -   - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect -
    -
    - 58 - -
    -   - github.com/consensys/bavard v0.1.13 // indirect -
    -
    - 59 - -
    -   - github.com/consensys/gnark-crypto v0.12.1 // indirect -
    -
    - 60 - -
    - - - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect -
    -
    - 61 - -
    -   - github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect -
    -
    - 62 - -
    -   - github.com/crate-crypto/go-kzg-4844 v0.7.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.1.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.2 // indirect -
    -
    - 71 - -
    - - - github.com/fsnotify/fsnotify v1.6.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 -
    -
    -
    @@ -83,23 +83,25 @@
    -
    - 83 - -
    -   - github.com/gogo/protobuf v1.3.2 // indirect -
    -
    - 84 - -
    -   - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect -
    -
    - 85 - -
    -   - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect -
    -
    - - -
    -   -
    -
    -
    - 86 - -
    -   - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect -
    -
    - 87 - -
    -   - github.com/google/gofuzz v1.2.0 // indirect -
    -
    - 88 - -
    -   - github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect -
    -
    - 89 - -
    -   - github.com/hashicorp/go-bexpr v0.1.10 // indirect -
    -
    - 90 - -
    -   - github.com/hashicorp/hcl v1.0.0 // indirect -
    -
    - 91 - -
    - - - github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect -
    -
    - 92 - -
    -   - github.com/holiman/bloomfilter/v2 v2.0.3 // indirect -
    -
    - 93 - -
    -   - github.com/huin/goupnp v1.3.0 // indirect -
    -
    - 94 - -
    -   - github.com/jackc/chunkreader/v2 v2.0.1 // indirect -
    -
    - 95 - -
    -   - github.com/jackc/pgio v1.0.0 // indirect -
    -
    - 96 - -
    -   - github.com/jackc/pgpassfile v1.0.0 // indirect -
    -
    - 97 - -
    - - - github.com/jackc/pgproto3/v2 v2.3.3 // indirect -
    -
    - 98 - -
    -   - github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect -
    -
    - 99 - -
    -   - github.com/jackc/pgtype v1.14.0 // indirect -
    -
    - 100 - -
    -   - github.com/jackc/puddle v1.3.0 // indirect -
    -
    - 101 - -
    -   - github.com/jackpal/go-nat-pmp v1.0.2 // indirect -
    -
    - 102 - -
    -   - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect -
    -
    - - -
    -   -
    -
    -
    - 103 - -
    -   - github.com/karrick/godirwalk v1.17.0 // indirect -
    -
    - 104 - -
    -   - github.com/kevinburke/ssh_config v1.2.0 // indirect -
    -
    - 105 - -
    -   - github.com/klauspost/compress v1.17.0 // indirect -
    -
    -
    @@ -114,6 +116,8 @@
    -
    - 114 - -
    -   - github.com/mattn/go-colorable v0.1.13 // indirect -
    -
    - 115 - -
    -   - github.com/mattn/go-isatty v0.0.20 // indirect -
    -
    - 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 -
    -
    - 128 - -
    -   - github.com/russross/blackfriday/v2 v2.1.0 // indirect -
    -
    - 129 - -
    - - - github.com/sagikazarmark/locafero v0.3.0 // indirect -
    -
    - 130 - -
    -   - github.com/sagikazarmark/slog-shim v0.1.0 // indirect -
    -
    - 131 - -
    - - - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect -
    -
    - 132 - -
    -   - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect -
    -
    - 133 - -
    -   - github.com/sirupsen/logrus v1.9.0 // indirect -
    -
    - 134 - -
    - - - github.com/skeema/knownhosts v1.2.2 // indirect -
    -
    - 135 - -
    -   - github.com/sourcegraph/conc v0.3.0 // indirect -
    -
    - 136 - -
    - - - github.com/spf13/cast v1.5.1 // indirect -
    -
    - 137 - -
    -   - github.com/spf13/pflag v1.0.5 // indirect -
    -
    - 138 - -
    -   - github.com/status-im/keycard-go v0.2.0 // indirect -
    -
    - 139 - -
    - - - github.com/stretchr/objx v0.5.2 // indirect -
    -
    - 140 - -
    -   - github.com/subosito/gotenv v1.6.0 // indirect -
    -
    - 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 - -
    -   - ) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 6 - -
    -   - github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1 -
    -
    - 7 - -
    -   - github.com/didip/tollbooth/v6 v6.1.2 -
    -
    - 8 - -
    -   - github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 -
    -
    - 9 - -
    - + - github.com/ethereum/go-ethereum v1.13.11 -
    -
    - 10 - -
    -   - github.com/go-git/go-billy/v5 v5.5.0 -
    -
    - 11 - -
    - + - github.com/go-git/go-git/v5 v5.11.0 -
    -
    - 12 - -
    -   - github.com/gobuffalo/packr/v2 v2.8.3 -
    -
    - 13 - -
    - + - github.com/google/uuid v1.5.0 -
    -
    - 14 - -
    -   - github.com/habx/pg-commands v0.6.1 -
    -
    - 15 - -
    -   - github.com/hermeznetwork/tracerr v0.3.2 -
    -
    - 16 - -
    - + - github.com/iden3/go-iden3-crypto v0.0.15 -
    -
    - 17 - -
    -   - github.com/invopop/jsonschema v0.12.0 -
    -
    - 18 - -
    - + - github.com/jackc/pgconn v1.14.1 -
    -
    - 19 - -
    - + - github.com/jackc/pgx/v4 v4.18.1 -
    -
    - 20 - -
    -   - github.com/mitchellh/mapstructure v1.5.0 -
    -
    - 21 - -
    - + - github.com/prometheus/client_model v0.5.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 -
    -
    - 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 -
    -
    - 35 - -
    -   - gopkg.in/yaml.v2 v2.4.0 -
    -
    - 36 - -
    -   - gopkg.in/yaml.v3 v3.0.1 -
    -
    - 37 - -
    -   - ) -
    -
    -
     
    -
    - 40 - -
    -   - dario.cat/mergo v1.0.0 // indirect -
    -
    - 41 - -
    -   - github.com/DataDog/zstd v1.5.2 // indirect -
    -
    - 42 - -
    -   - github.com/Microsoft/go-winio v0.6.1 // indirect -
    -
    - 43 - -
    - + - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect -
    -
    - 44 - -
    -   - github.com/StackExchange/wmi v1.2.1 // indirect -
    -
    - 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 -
    -
    - 52 - -
    - + - github.com/cloudflare/circl v1.3.3 // indirect -
    -
    - 53 - -
    -   - github.com/cockroachdb/errors v1.9.1 // indirect -
    -
    - 54 - -
    -   - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect -
    -
    - 55 - -
    -   - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect -
    -
    -
     
    -
    - 57 - -
    -   - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect -
    -
    - 58 - -
    -   - github.com/consensys/bavard v0.1.13 // indirect -
    -
    - 59 - -
    -   - github.com/consensys/gnark-crypto v0.12.1 // indirect -
    -
    - 60 - -
    - + - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect -
    -
    - 61 - -
    -   - github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect -
    -
    - 62 - -
    -   - github.com/crate-crypto/go-kzg-4844 v0.7.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 -
    -
    -
     
    -
    - 83 - -
    -   - github.com/gogo/protobuf v1.3.2 // indirect -
    -
    - 84 - -
    -   - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect -
    -
    - 85 - -
    -   - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect -
    -
    - 86 - -
    - + - github.com/golang/protobuf v1.5.3 // indirect -
    -
    - 87 - -
    -   - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect -
    -
    - 88 - -
    -   - github.com/google/gofuzz v1.2.0 // indirect -
    -
    - 89 - -
    -   - github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect -
    -
    - 90 - -
    -   - github.com/hashicorp/go-bexpr v0.1.10 // indirect -
    -
    - 91 - -
    -   - github.com/hashicorp/hcl v1.0.0 // indirect -
    -
    - 92 - -
    - + - 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 -
    -
    - 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 -
    -
    -
     
    -
    - 116 - -
    -   - github.com/mattn/go-colorable v0.1.13 // 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 -
    -
    - 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 -
    -
    - 154 - -
    -   - go.uber.org/multierr v1.10.0 // indirect -
    -
    - 155 - -
    -   - golang.org/x/mod v0.14.0 // indirect -
    -
    - 156 - -
    - + - golang.org/x/sys v0.16.0 // indirect -
    -
    - 157 - -
    - + - golang.org/x/term v0.16.0 // indirect -
    -
    - 158 - -
    -   - golang.org/x/text v0.14.0 // indirect -
    -
    - 159 - -
    -   - golang.org/x/time v0.5.0 // indirect -
    -
    - 160 - -
    -   - golang.org/x/tools v0.15.0 // indirect -
    -
    - 161 - -
    - + - google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect -
    -
    - 162 - -
    -   - gopkg.in/ini.v1 v1.67.0 // indirect -
    -
    - 163 - -
    -   - gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect -
    -
    - 164 - -
    -   - gopkg.in/warnings.v0 v0.1.2 // 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 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -58,6 +58,46 @@
    -
    - 58 - -
    -   - return result, nil -
    -
    - 59 - -
    -   - } -
    -
    - 60 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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()) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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()) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -104,7 +104,7 @@
    -
    - 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 - -
    -   -
    -
    -
    -
    @@ -945,6 +945,9 @@
    -
    - 945 - -
    -   - if e.cfg.SequencerNodeURI != "" { -
    -
    - 946 - -
    -   - return e.relayTxToSequencerNode(input) -
    -
    - 947 - -
    -   - } else { -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 948 - -
    -   - ip := "" -
    -
    - 949 - -
    -   - ips := httpRequest.Header.Get("X-Forwarded-For") -
    -
    - 950 - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -   -
    -
    -
    -
     
    -
    - 945 - -
    -   - if e.cfg.SequencerNodeURI != "" { -
    -
    - 946 - -
    -   - return e.relayTxToSequencerNode(input) -
    -
    - 947 - -
    -   - } else { -
    -
    - 948 - -
    - + - if err := checkPolicy(context.Background(), e.pool, input); err != nil { -
    -
    - 949 - -
    - + - return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false) -
    -
    - 950 - -
    - + - } -
    -
    - 951 - -
    -   - ip := "" -
    -
    - 952 - -
    -   - ips := httpRequest.Header.Get("X-Forwarded-For") -
    -
    - 953 - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -6,6 +6,7 @@
    -
    - 6 - -
    -   - "errors" -
    -
    - 7 - -
    -   - "fmt" -
    -
    - 8 - -
    -   - "math/big" -
    -
    - - -
    -   -
    -
    -
    - 9 - -
    -   - "sync" -
    -
    - 10 - -
    -   - "testing" -
    -
    - 11 - -
    -   - "time" -
    -
    -
    @@ -5416,3 +5417,237 @@
    -
    - 5416 - -
    -   - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) -
    -
    - 5417 - -
    -   - assert.ElementsMatch(t, []int{16}, results[5]) -
    -
    - 5418 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 6 - -
    -   - "errors" -
    -
    - 7 - -
    -   - "fmt" -
    -
    - 8 - -
    -   - "math/big" -
    -
    - 9 - -
    - + - "strings" -
    -
    - 10 - -
    -   - "sync" -
    -
    - 11 - -
    -   - "testing" -
    -
    - 12 - -
    -   - "time" -
    -
    -
     
    -
    - 5417 - -
    -   - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) -
    -
    - 5418 - -
    -   - assert.ElementsMatch(t, []int{16}, results[5]) -
    -
    - 5419 - -
    -   - } -
    -
    - 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) -
    -
    - 5430 - -
    - + - disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1)) -
    -
    - 5431 - -
    - + - require.NoError(t, err) -
    -
    - 5432 - -
    - + - require.NotNil(t, disallowed) -
    -
    - 5433 - -
    - + -
    -
    -
    - 5434 - -
    - + - allowedContract := common.HexToAddress("0x1") -
    -
    - 5435 - -
    - + - disallowedContract := common.HexToAddress("0x2") -
    -
    - 5436 - -
    - + -
    -
    -
    - 5437 - -
    - + - senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy") -
    -
    - 5438 - -
    - + - 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 - -
    - + - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -204,6 +204,53 @@
    -
    - 204 - -
    -   - }) -
    -
    - 205 - -
    -   - } -
    -
    - 206 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 +563,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 - -
    - + - type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) -
    -
    - 208 - -
    - + -
    -
    -
    - 209 - -
    - + - // GetBatchDataByNumbers returns L2 batch data by batch numbers. -
    -
    - 210 - -
    - + - func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) { -
    -
    - 211 - -
    - + - return z.getBatchData(filter, z.state.GetBatchL2DataByNumbers) -
    -
    - 212 - -
    - + - } -
    -
    - 213 - -
    - + -
    -
    -
    - 214 - -
    - + - // GetForcedBatchDataByNumbers returns forced batch data by batch numbers. -
    -
    - 215 - -
    - + - func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) { -
    -
    - 216 - -
    - + - return z.getBatchData(filter, z.state.GetForcedBatchDataByNumbers) -
    -
    - 217 - -
    - + - } -
    -
    - 218 - -
    - + -
    -
    -
    - 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 - -
    - + - batchNumbers := make([]uint64, 0, len(filter.Numbers)) -
    -
    - 222 - -
    - + - for _, bn := range filter.Numbers { -
    -
    - 223 - -
    - + - n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx) -
    -
    - 224 - -
    - + - if rpcErr != nil { -
    -
    - 225 - -
    - + - return nil, rpcErr -
    -
    - 226 - -
    - + - } -
    -
    - 227 - -
    - + - batchNumbers = append(batchNumbers, n) -
    -
    - 228 - -
    - + - } -
    -
    - 229 - -
    - + -
    -
    -
    - 230 - -
    - + - batchesData, err := f(ctx, batchNumbers, dbTx) -
    -
    - 231 - -
    - + - if errors.Is(err, state.ErrNotFound) { -
    -
    - 232 - -
    - + - return nil, nil -
    -
    - 233 - -
    - + - } else if err != nil { -
    -
    - 234 - -
    - + - return RPCErrorResponse(types.DefaultErrorCode, -
    -
    - 235 - -
    - + - fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true) -
    -
    - 236 - -
    - + - } -
    -
    - 237 - -
    - + -
    -
    -
    - 238 - -
    - + - ret := make([]*types.BatchData, 0, len(batchNumbers)) -
    -
    - 239 - -
    - + - for _, n := range batchNumbers { -
    -
    - 240 - -
    - + - data := &types.BatchData{Number: types.ArgUint64(n)} -
    -
    - 241 - -
    - + - if b, ok := batchesData[n]; ok { -
    -
    - 242 - -
    - + - data.BatchL2Data = b -
    -
    - 243 - -
    - + - data.Empty = false -
    -
    - 244 - -
    - + - } else { -
    -
    - 245 - -
    - + - data.Empty = true -
    -
    - 246 - -
    - + - } -
    -
    - 247 - -
    - + - ret = append(ret, data) -
    -
    - 248 - -
    - + - } -
    -
    - 249 - -
    - + -
    -
    -
    - 250 - -
    - + - return types.BatchDataResult{Data: ret}, nil -
    -
    - 251 - -
    - + - }) -
    -
    - 252 - -
    - + - } -
    -
    - 253 - -
    - + -
    -
    -
    - 254 - -
    -   - // GetFullBlockByNumber returns information about a block by block number -
    -
    - 255 - -
    -   - func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { -
    -
    - 256 - -
    -   - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -2705,3 +2705,32 @@
    -
    - 2705 - -
    -   - }) -
    -
    - 2706 - -
    -   - } -
    -
    - 2707 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 2705 - -
    -   - }) -
    -
    - 2706 - -
    -   - } -
    -
    - 2707 - -
    -   - } -
    -
    - 2708 - -
    - + -
    -
    -
    - 2709 - -
    - + - func TestClient_BatchesByNumbers(t *testing.T) { -
    -
    - 2710 - -
    - + - const batchesCount = 6 -
    -
    - 2711 - -
    - + -
    -
    -
    - 2712 - -
    - + - s, m, _ := newSequencerMockedServer(t) -
    -
    - 2713 - -
    - + - defer s.Stop() -
    -
    - 2714 - -
    - + -
    -
    -
    - 2715 - -
    - + - batchesDataMap := make(map[uint64][]byte, batchesCount) -
    -
    - 2716 - -
    - + - for i := 0; i < batchesCount; i++ { -
    -
    - 2717 - -
    - + - batchesDataMap[uint64(i+1)] = []byte(fmt.Sprintf("batch %d data", i+1)) -
    -
    - 2718 - -
    - + - } -
    -
    - 2719 - -
    - + -
    -
    -
    - 2720 - -
    - + - m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything). -
    -
    - 2721 - -
    - + - Return(batchesDataMap, nil).Once() -
    -
    - 2722 - -
    - + -
    -
    -
    - 2723 - -
    - + - m.State.On("BeginStateTransaction", context.Background()). -
    -
    - 2724 - -
    - + - Return(m.DbTx, nil).Once() -
    -
    - 2725 - -
    - + -
    -
    -
    - 2726 - -
    - + - m.DbTx.On("Commit", context.Background()).Return(nil).Once() -
    -
    - 2727 - -
    - + -
    -
    -
    - 2728 - -
    - + - zkEVMClient := client.NewClient(s.ServerURL) -
    -
    - 2729 - -
    - + - reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)} -
    -
    - 2730 - -
    - + - result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum) -
    -
    - 2731 - -
    - + - require.NoError(t, err) -
    -
    - 2732 - -
    - + - require.Len(t, result, len(reqBatchesNum)) -
    -
    - 2733 - -
    - + - for i, batchNum := range reqBatchesNum { -
    -
    - 2734 - -
    - + - require.Equal(t, hex.EncodeToHex(batchesDataMap[batchNum.Uint64()]), result[i].BatchL2Data.Hex()) -
    -
    - 2735 - -
    - + - } -
    -
    - 2736 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,61 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -15,6 +15,8 @@
    -
    - 15 - -
    -   - InvalidParamsErrorCode = -32602 -
    -
    - 16 - -
    -   - // ParserErrorCode error code for parsing errors -
    -
    - 17 - -
    -   - ParserErrorCode = -32700 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 18 - -
    -   - ) -
    -
    - 19 - -
    -   -
    -
    -
    - 20 - -
    -   - var ( -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -   - ) -
    -
    - 21 - -
    -   -
    -
    -
    - 22 - -
    -   - var ( -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -23,8 +23,8 @@
    -
    - 23 - -
    -   - CountPendingTransactions(ctx context.Context) (uint64, error) -
    -
    - 24 - -
    -   - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) -
    -
    - 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) -
    -
    - 28 - -
    -   - EffectiveGasPriceEnabled() bool -
    -
    - 29 - -
    -   - } -
    -
    - 30 - -
    -   -
    -
    -
    -
    @@ -64,6 +64,8 @@
    -
    - 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 - -
    -   - GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error) -
    -
    - 68 - -
    -   - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) -
    -
    - 69 - -
    -   - GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 23 - -
    -   - CountPendingTransactions(ctx context.Context) (uint64, error) -
    -
    - 24 - -
    -   - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) -
    -
    - 25 - -
    -   - 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) -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    - + - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -446,6 +446,23 @@
    -
    - 446 - -
    -   - return res, nil -
    -
    - 447 - -
    -   - } -
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -192,11 +192,6 @@
    -
    - 192 - -
    -   - return mt.ComputeMerkleProof(mt.count, initialLeaves) -
    -
    - 193 - -
    -   - } -
    -
    - 194 - -
    -   -
    -
    -
    - 195 - -
    - - - // GetRoot returns the root of the L1InfoTree -
    -
    - 196 - -
    - - - func (mt *L1InfoTree) GetRoot() common.Hash { -
    -
    - 197 - -
    - - - return mt.currentRoot -
    -
    - 198 - -
    - - - } -
    -
    - 199 - -
    - - -
    -
    -
    - 200 - -
    -   - // GetCurrentRootCountAndSiblings returns the latest root, count and sibblings -
    -
    - 201 - -
    -   - func (mt *L1InfoTree) GetCurrentRootCountAndSiblings() (common.Hash, uint32, [][32]byte) { -
    -
    - 202 - -
    -   - return mt.currentRoot, mt.count, mt.siblings -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 192 - -
    -   - return mt.ComputeMerkleProof(mt.count, initialLeaves) -
    -
    - 193 - -
    -   - } -
    -
    - 194 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 195 - -
    -   - // GetCurrentRootCountAndSiblings returns the latest root, count and sibblings -
    -
    - 196 - -
    -   - func (mt *L1InfoTree) GetCurrentRootCountAndSiblings() (common.Hash, uint32, [][32]byte) { -
    -
    - 197 - -
    -   - return mt.currentRoot, mt.count, mt.siblings -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,94 +0,0 @@
    -
    - 1 - -
    - - - package l1infotree -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 5 - -
    - - - "github.com/ethereum/go-ethereum/crypto" -
    -
    - 6 - -
    - - - ) -
    -
    - 7 - -
    - - -
    -
    -
    - 8 - -
    - - - const ( -
    -
    - 9 - -
    - - - emptyHistoricL1InfoTreeRoot = "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757" -
    -
    - 10 - -
    - - - ) -
    -
    - 11 - -
    - - -
    -
    -
    - 12 - -
    - - - // L1InfoTreeRecursive is a recursive implementation of the L1InfoTree of Feijoa -
    -
    - 13 - -
    - - - type L1InfoTreeRecursive struct { -
    -
    - 14 - -
    - - - historicL1InfoTree *L1InfoTree -
    -
    - 15 - -
    - - - currentLeaf common.Hash -
    -
    - 16 - -
    - - - } -
    -
    - 17 - -
    - - -
    -
    -
    - 18 - -
    - - - // L1InfoTreeRecursiveSnapshot provides the information generated when a new -
    -
    - 19 - -
    - - - // leaf is added to the tree -
    -
    - 20 - -
    - - - type L1InfoTreeRecursiveSnapshot struct { -
    -
    - 21 - -
    - - - HistoricL1InfoTreeRoot common.Hash -
    -
    - 22 - -
    - - - L1Data common.Hash -
    -
    - 23 - -
    - - - L1InfoTreeRoot common.Hash -
    -
    - 24 - -
    - - - } -
    -
    - 25 - -
    - - -
    -
    -
    - 26 - -
    - - - // NewL1InfoTreeRecursive creates a new empty L1InfoTreeRecursive -
    -
    - 27 - -
    - - - func NewL1InfoTreeRecursive(height uint8) (*L1InfoTreeRecursive, error) { -
    -
    - 28 - -
    - - - historic, err := NewL1InfoTree(height, nil) -
    -
    - 29 - -
    - - - if err != nil { -
    -
    - 30 - -
    - - - return nil, err -
    -
    - 31 - -
    - - - } -
    -
    - 32 - -
    - - -
    -
    -
    - 33 - -
    - - - mtr := &L1InfoTreeRecursive{ -
    -
    - 34 - -
    - - - historicL1InfoTree: historic, -
    -
    - 35 - -
    - - - currentLeaf: common.Hash{}, -
    -
    - 36 - -
    - - - } -
    -
    - 37 - -
    - - - return mtr, nil -
    -
    - 38 - -
    - - - } -
    -
    - 39 - -
    - - -
    -
    -
    - 40 - -
    - - - // NewL1InfoTreeRecursiveFromLeaves creates a new L1InfoTreeRecursive from leaves as they are -
    -
    - 41 - -
    - - - func NewL1InfoTreeRecursiveFromLeaves(height uint8, leaves [][32]byte) (*L1InfoTreeRecursive, error) { -
    -
    - 42 - -
    - - - mtr, err := NewL1InfoTreeRecursive(height) -
    -
    - 43 - -
    - - - if err != nil { -
    -
    - 44 - -
    - - - return nil, err -
    -
    - 45 - -
    - - - } -
    -
    - 46 - -
    - - -
    -
    -
    - 47 - -
    - - - for i, leaf := range leaves { -
    -
    - 48 - -
    - - - _, err := mtr.AddLeaf(uint32(i), leaf) -
    -
    - 49 - -
    - - - if err != nil { -
    -
    - 50 - -
    - - - return nil, err -
    -
    - 51 - -
    - - - } -
    -
    - 52 - -
    - - - mtr.currentLeaf = leaf -
    -
    - 53 - -
    - - - } -
    -
    - 54 - -
    - - - return mtr, nil -
    -
    - 55 - -
    - - - } -
    -
    - 56 - -
    - - -
    -
    -
    - 57 - -
    - - - // AddLeaf hashes the current historicL1InfoRoot + currentLeaf data into the new historicLeaf value, -
    -
    - 58 - -
    - - - // then adds it to the historicL1InfoTree and finally stores the new leaf as the currentLeaf -
    -
    - 59 - -
    - - - func (mt *L1InfoTreeRecursive) AddLeaf(index uint32, leaf [32]byte) (common.Hash, error) { -
    -
    - 60 - -
    - - - // adds the current l1InfoTreeRoot into the historic tree to generate -
    -
    - 61 - -
    - - - // the next historicL2InfoTreeRoot -
    -
    - 62 - -
    - - - l1InfoTreeRoot := mt.GetRoot() -
    -
    - 63 - -
    - - - _, err := mt.historicL1InfoTree.AddLeaf(index, l1InfoTreeRoot) -
    -
    - 64 - -
    - - - if err != nil { -
    -
    - 65 - -
    - - - return common.Hash{}, err -
    -
    - 66 - -
    - - - } -
    -
    - 67 - -
    - - -
    -
    -
    - 68 - -
    - - - mt.currentLeaf = leaf -
    -
    - 69 - -
    - - -
    -
    -
    - 70 - -
    - - - return mt.GetRoot(), nil -
    -
    - 71 - -
    - - - } -
    -
    - 72 - -
    - - -
    -
    -
    - 73 - -
    - - - // GetRoot returns the root of the L1InfoTreeRecursive -
    -
    - 74 - -
    - - - func (mt *L1InfoTreeRecursive) GetRoot() common.Hash { -
    -
    - 75 - -
    - - - // if the historicL1InfoTree is empty and the the current leaf is also empty -
    -
    - 76 - -
    - - - // returns the root as all zeros 0x0000...0000 -
    -
    - 77 - -
    - - - if mt.historicL1InfoTree.GetRoot().String() == emptyHistoricL1InfoTreeRoot && -
    -
    - 78 - -
    - - - mt.currentLeaf.Cmp(common.Hash{}) == 0 { -
    -
    - 79 - -
    - - - return common.Hash{} -
    -
    - 80 - -
    - - - } -
    -
    - 81 - -
    - - -
    -
    -
    - 82 - -
    - - - l1InfoTreeRoot := crypto.Keccak256Hash(mt.historicL1InfoTree.GetRoot().Bytes(), mt.currentLeaf[:]) -
    -
    - 83 - -
    - - - return l1InfoTreeRoot -
    -
    - 84 - -
    - - - } -
    -
    - 85 - -
    - - -
    -
    -
    - 86 - -
    - - - // GetHistoricRoot returns the root of the HistoricL1InfoTree -
    -
    - 87 - -
    - - - func (mt *L1InfoTreeRecursive) GetHistoricRoot() common.Hash { -
    -
    - 88 - -
    - - - return mt.historicL1InfoTree.GetRoot() -
    -
    - 89 - -
    - - - } -
    -
    - 90 - -
    - - -
    -
    -
    - 91 - -
    - - - // ComputeMerkleProof computes the Merkle proof from the leaves -
    -
    - 92 - -
    - - - func (mt *L1InfoTreeRecursive) ComputeMerkleProof(gerIndex uint32, leaves [][32]byte) ([][32]byte, common.Hash, error) { -
    -
    - 93 - -
    - - - return mt.historicL1InfoTree.ComputeMerkleProof(gerIndex, leaves) -
    -
    - 94 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,113 +0,0 @@
    -
    - 1 - -
    - - - package l1infotree_test -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "encoding/json" -
    -
    - 5 - -
    - - - "os" -
    -
    - 6 - -
    - - - "strconv" -
    -
    - 7 - -
    - - - "testing" -
    -
    - 8 - -
    - - -
    -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/l1infotree" -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 11 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 12 - -
    - - - "github.com/stretchr/testify/assert" -
    -
    - 13 - -
    - - - "github.com/stretchr/testify/require" -
    -
    - 14 - -
    - - - ) -
    -
    - 15 - -
    - - -
    -
    -
    - 16 - -
    - - - const ( -
    -
    - 17 - -
    - - - l1InfoRootRecursiveHeight = uint8(32) -
    -
    - 18 - -
    - - - emptyL1InfoTreeRecursiveRoot = "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757" -
    -
    - 19 - -
    - - - filenameTestData = "../test/vectors/src/merkle-tree/l1-info-tree-recursive/smt-full-output.json" -
    -
    - 20 - -
    - - - ) -
    -
    - 21 - -
    - - -
    -
    -
    - 22 - -
    - - - type vectorTestData struct { -
    -
    - 23 - -
    - - - GlobalExitRoot common.Hash `json:"globalExitRoot"` -
    -
    - 24 - -
    - - - BlockHash common.Hash `json:"blockHash"` -
    -
    - 25 - -
    - - - MinTimestamp string `json:"minTimestamp"` -
    -
    - 26 - -
    - - - SmtProof []common.Hash `json:"smtProof"` -
    -
    - 27 - -
    - - - Index uint32 `json:"index"` -
    -
    - 28 - -
    - - - PreviousIndex uint32 `json:"previousIndex"` -
    -
    - 29 - -
    - - - PreviousL1InfoTreeRoot common.Hash `json:"previousL1InfoTreeRoot"` -
    -
    - 30 - -
    - - - L1DataHash common.Hash `json:"l1DataHash"` -
    -
    - 31 - -
    - - - L1InfoTreeRoot common.Hash `json:"l1InfoTreeRoot"` -
    -
    - 32 - -
    - - - HistoricL1InfoRoot common.Hash `json:"historicL1InfoRoot"` -
    -
    - 33 - -
    - - - } -
    -
    - 34 - -
    - - -
    -
    -
    - 35 - -
    - - - func readData(t *testing.T) []vectorTestData { -
    -
    - 36 - -
    - - - data, err := os.ReadFile(filenameTestData) -
    -
    - 37 - -
    - - - require.NoError(t, err) -
    -
    - 38 - -
    - - - var mtTestVectors []vectorTestData -
    -
    - 39 - -
    - - - err = json.Unmarshal(data, &mtTestVectors) -
    -
    - 40 - -
    - - - require.NoError(t, err) -
    -
    - 41 - -
    - - - return mtTestVectors -
    -
    - 42 - -
    - - - } -
    -
    - 43 - -
    - - -
    -
    -
    - 44 - -
    - - - func TestEmptyL1InfoRootRecursive(t *testing.T) { -
    -
    - 45 - -
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight) -
    -
    - 46 - -
    - - - require.NoError(t, err) -
    -
    - 47 - -
    - - - require.NotNil(t, mtr) -
    -
    - 48 - -
    - - - root := mtr.GetRoot() -
    -
    - 49 - -
    - - - require.Equal(t, common.Hash{}.String(), root.String()) -
    -
    - 50 - -
    - - - } -
    -
    - 51 - -
    - - -
    -
    -
    - 52 - -
    - - - func TestEmptyHistoricL1InfoRootRecursive(t *testing.T) { -
    -
    - 53 - -
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight) -
    -
    - 54 - -
    - - - require.NoError(t, err) -
    -
    - 55 - -
    - - - require.NotNil(t, mtr) -
    -
    - 56 - -
    - - - root := mtr.GetHistoricRoot() -
    -
    - 57 - -
    - - - require.Equal(t, emptyL1InfoTreeRecursiveRoot, root.String()) -
    -
    - 58 - -
    - - - } -
    -
    - 59 - -
    - - -
    -
    -
    - 60 - -
    - - - func TestBuildTreeVectorData(t *testing.T) { -
    -
    - 61 - -
    - - - data := readData(t) -
    -
    - 62 - -
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight) -
    -
    - 63 - -
    - - - require.NoError(t, err) -
    -
    - 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) -
    -
    - 70 - -
    - - -
    -
    -
    - 71 - -
    - - - l1InfoTreeRoot, err := mtr.AddLeaf(testVector.Index-1, l1Data) -
    -
    - 72 - -
    - - - require.NoError(t, err) -
    -
    - 73 - -
    - - - assert.Equal(t, testVector.L1InfoTreeRoot.String(), l1InfoTreeRoot.String(), "l1InfoTreeRoot doesn't match leaf", testVector.Index) -
    -
    - 74 - -
    - - - assert.Equal(t, testVector.L1InfoTreeRoot.String(), mtr.GetRoot().String(), "l1InfoTreeRoot doesn't match leaf", testVector.Index) -
    -
    - 75 - -
    - - - assert.Equal(t, testVector.HistoricL1InfoRoot.String(), mtr.GetHistoricRoot().String(), "HistoricL1InfoTreeRoot doesn't match leaf", testVector.Index) -
    -
    - 76 - -
    - - - } -
    -
    - 77 - -
    - - - } -
    -
    - 78 - -
    - - -
    -
    -
    - 79 - -
    - - - func TestBuildTreeFromLeaves(t *testing.T) { -
    -
    - 80 - -
    - - - data := readData(t) -
    -
    - 81 - -
    - - -
    -
    -
    - 82 - -
    - - - leaves := [][32]byte{} -
    -
    - 83 - -
    - - - for _, testVector := range data { -
    -
    - 84 - -
    - - - leaves = append(leaves, testVector.L1DataHash) -
    -
    - 85 - -
    - - - } -
    -
    - 86 - -
    - - -
    -
    -
    - 87 - -
    - - - newMtr, err := l1infotree.NewL1InfoTreeRecursiveFromLeaves(l1InfoRootRecursiveHeight, leaves) -
    -
    - 88 - -
    - - - require.NoError(t, err) -
    -
    - 89 - -
    - - - assert.Equal(t, data[len(data)-1].L1InfoTreeRoot.String(), newMtr.GetRoot().String(), "L1InfoTreeRoot doesn't match leaf") -
    -
    - 90 - -
    - - - } -
    -
    - 91 - -
    - - -
    -
    -
    - 92 - -
    - - - func TestProofsTreeVectorData(t *testing.T) { -
    -
    - 93 - -
    - - - data := readData(t) -
    -
    - 94 - -
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight) -
    -
    - 95 - -
    - - - require.NoError(t, err) -
    -
    - 96 - -
    - - -
    -
    -
    - 97 - -
    - - - leaves := [][32]byte{} -
    -
    - 98 - -
    - - - for _, testVector := range data { -
    -
    - 99 - -
    - - - l1InfoTreeRoot, err := mtr.AddLeaf(testVector.Index-1, testVector.L1DataHash) -
    -
    - 100 - -
    - - - require.NoError(t, err) -
    -
    - 101 - -
    - - -
    -
    -
    - 102 - -
    - - - leaves = append(leaves, l1InfoTreeRoot) -
    -
    - 103 - -
    - - -
    -
    -
    - 104 - -
    - - - mp, _, err := mtr.ComputeMerkleProof(testVector.Index, leaves) -
    -
    - 105 - -
    - - - require.NoError(t, err) -
    -
    - 106 - -
    - - - for i, v := range mp { -
    -
    - 107 - -
    - - - c := common.Hash(v) -
    -
    - 108 - -
    - - - if c.String() != testVector.SmtProof[i].String() { -
    -
    - 109 - -
    - - - log.Info("MerkleProof: index ", testVector.Index, " mk:", i, " v:", c.String(), " expected:", testVector.SmtProof[i].String()) -
    -
    - 110 - -
    - - - } -
    -
    - 111 - -
    - - - } -
    -
    - 112 - -
    - - - } -
    -
    - 113 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/client.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -7,7 +7,6 @@
    -
    - 7 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 8 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/merkletree/hashdb" -
    -
    - 9 - -
    -   - "google.golang.org/grpc" -
    -
    - 10 - -
    - - - "google.golang.org/grpc/connectivity" -
    -
    - 11 - -
    -   - "google.golang.org/grpc/credentials/insecure" -
    -
    - 12 - -
    -   - ) -
    -
    - 13 - -
    -   -
    -
    -
    -
    @@ -15,37 +14,18 @@
    -
    - 15 - -
    -   - func NewMTDBServiceClient(ctx context.Context, c Config) (hashdb.HashDBServiceClient, *grpc.ClientConn, context.CancelFunc) { -
    -
    - 16 - -
    -   - opts := []grpc.DialOption{ -
    -
    - 17 - -
    -   - grpc.WithTransportCredentials(insecure.NewCredentials()), -
    -
    - - -
    -   -
    -
    -
    - 18 - -
    -   - } -
    -
    - 19 - -
    - - -
    -
    -
    - 20 - -
    - - - mtDBConn, err := grpc.NewClient(c.URI, opts...) -
    -
    - 21 - -
    - - - if err != nil { -
    -
    - 22 - -
    - - - log.Fatalf("fail to create grpc connection to merkletree: %v", err) -
    -
    - 23 - -
    - - - } -
    -
    - 24 - -
    - - -
    -
    -
    - 25 - -
    - - - log.Infof("trying to connect to merkletree: %v", c.URI) -
    -
    - 26 - -
    -   - const maxWaitSeconds = 120 -
    -
    - 27 - -
    -   - ctx, cancel := context.WithTimeout(ctx, maxWaitSeconds*time.Second) -
    -
    - 28 - -
    - - - mtDBConn.Connect() -
    -
    - 29 - -
    - - - err = waitForConnection(ctx, mtDBConn) -
    -
    - - -
    -   -
    -
    -
    - 30 - -
    -   - if err != nil { -
    -
    - 31 - -
    - - - log.Fatalf("fail to connect to merkletree: %v", err) -
    -
    - 32 - -
    -   - } -
    -
    - 33 - -
    -   - log.Infof("connected to merkletree") -
    -
    - 34 - -
    -   -
    -
    -
    - 35 - -
    -   - mtDBClient := hashdb.NewHashDBServiceClient(mtDBConn) -
    -
    - 36 - -
    -   - return mtDBClient, mtDBConn, cancel -
    -
    - 37 - -
    -   - } -
    -
    - 38 - -
    - - -
    -
    -
    - 39 - -
    - - - func waitForConnection(ctx context.Context, conn *grpc.ClientConn) error { -
    -
    - 40 - -
    - - - for { -
    -
    - 41 - -
    - - - select { -
    -
    - 42 - -
    - - - case <-ctx.Done(): -
    -
    - 43 - -
    - - - return ctx.Err() -
    -
    - 44 - -
    - - - case <-time.After(time.Second): -
    -
    - 45 - -
    - - - s := conn.GetState() -
    -
    - 46 - -
    - - - if s == connectivity.Ready { -
    -
    - 47 - -
    - - - return nil -
    -
    - 48 - -
    - - - } -
    -
    - 49 - -
    - - - } -
    -
    - 50 - -
    - - - } -
    -
    - 51 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 7 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 8 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/merkletree/hashdb" -
    -
    - 9 - -
    -   - "google.golang.org/grpc" -
    -
    - - -
    -   -
    -
    -
    - 10 - -
    -   - "google.golang.org/grpc/credentials/insecure" -
    -
    - 11 - -
    -   - ) -
    -
    - 12 - -
    -   -
    -
    -
    -
     
    -
    - 14 - -
    -   - func NewMTDBServiceClient(ctx context.Context, c Config) (hashdb.HashDBServiceClient, *grpc.ClientConn, context.CancelFunc) { -
    -
    - 15 - -
    -   - opts := []grpc.DialOption{ -
    -
    - 16 - -
    -   - grpc.WithTransportCredentials(insecure.NewCredentials()), -
    -
    - 17 - -
    - + - grpc.WithBlock(), -
    -
    - 18 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 19 - -
    -   - const maxWaitSeconds = 120 -
    -
    - 20 - -
    -   - ctx, cancel := context.WithTimeout(ctx, maxWaitSeconds*time.Second) -
    -
    - 21 - -
    - + -
    -
    -
    - 22 - -
    - + - log.Infof("trying to connect to merkletree: %v", c.URI) -
    -
    - 23 - -
    - + - mtDBConn, err := grpc.DialContext(ctx, c.URI, opts...) -
    -
    - 24 - -
    -   - if err != nil { -
    -
    - 25 - -
    - + - log.Fatalf("fail to dial: %v", err) -
    -
    - 26 - -
    -   - } -
    -
    - 27 - -
    -   - log.Infof("connected to merkletree") -
    -
    - 28 - -
    -   -
    -
    -
    - 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 - -
    - - - } -
    -
    - 99 - -
    -   -
    -
    -
    - 100 - -
    -   - // this code gets actual smart contract code from sc code storage -
    -
    - 101 - -
    -   - scCode, err := tree.getProgram(ctx, scalarToh4(k)) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 93 - -
    -   - } -
    -
    - 94 - -
    -   -
    -
    -
    - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 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) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 - -
    -   -
    -
    -
    - 77 - -
    -   - // ErrZeroL1GasPrice is returned if the L1 gas price is 0. -
    -
    - 78 - -
    -   - 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") -
    -
    - 85 - -
    - + -
    -
    -
    - 86 - -
    - + - // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy -
    -
    - 87 - -
    - + - ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy") -
    -
    - 88 - -
    -   - ) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -38,6 +38,7 @@
    -
    - 38 - -
    -   - MarkWIPTxsAsPending(ctx context.Context) error -
    -
    - 39 - -
    -   - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) -
    -
    - 40 - -
    -   - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) -
    -
    - - -
    -   -
    -
    -
    - 41 - -
    -   - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) -
    -
    - 42 - -
    -   - } -
    -
    - 43 - -
    -   -
    -
    -
    -
    @@ -48,3 +49,12 @@
    -
    - 48 - -
    -   - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) -
    -
    - 49 - -
    -   - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) -
    -
    - 50 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 38 - -
    -   - MarkWIPTxsAsPending(ctx context.Context) error -
    -
    - 39 - -
    -   - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) -
    -
    - 40 - -
    -   - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) -
    -
    - 41 - -
    - + - policy -
    -
    - 42 - -
    -   - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) -
    -
    - 43 - -
    -   - } -
    -
    - 44 - -
    -   -
    -
    -
    -
     
    -
    - 49 - -
    -   - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) -
    -
    - 50 - -
    -   - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) -
    -
    - 51 - -
    -   - } -
    -
    - 52 - -
    - + - type policy interface { -
    -
    - 53 - -
    - + - CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) -
    -
    - 54 - -
    - + - AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error -
    -
    - 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 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,202 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 -
    -
    - 59 - -
    - + - } -
    -
    - 60 - -
    - + -
    -
    -
    - 61 - -
    - + - // AddAddressesToPolicy adds addresses to the named policy -
    -
    - 62 - -
    - + - func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { -
    -
    - 63 - -
    - + - sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING" -
    -
    - 64 - -
    - + - tx, err := p.db.Begin(ctx) -
    -
    - 65 - -
    - + - if err != nil { -
    -
    - 66 - -
    - + - return err -
    -
    - 67 - -
    - + - } -
    -
    - 68 - -
    - + - defer func(tx pgx.Tx, ctx context.Context) { -
    -
    - 69 - -
    - + - _ = tx.Rollback(ctx) -
    -
    - 70 - -
    - + - }(tx, ctx) -
    -
    - 71 - -
    - + -
    -
    -
    - 72 - -
    - + - for _, a := range addresses { -
    -
    - 73 - -
    - + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) -
    -
    - 74 - -
    - + - if err != nil { -
    -
    - 75 - -
    - + - return err -
    -
    - 76 - -
    - + - } -
    -
    - 77 - -
    - + - } -
    -
    - 78 - -
    - + - err = tx.Commit(ctx) -
    -
    - 79 - -
    - + - if err != nil { -
    -
    - 80 - -
    - + - return nil -
    -
    - 81 - -
    - + - } -
    -
    - 82 - -
    - + - return nil -
    -
    - 83 - -
    - + - } -
    -
    - 84 - -
    - + -
    -
    -
    - 85 - -
    - + - // RemoveAddressesFromPolicy removes addresses from the named policy -
    -
    - 86 - -
    - + - func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { -
    -
    - 87 - -
    - + - sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2" -
    -
    - 88 - -
    - + - tx, err := p.db.Begin(ctx) -
    -
    - 89 - -
    - + - if err != nil { -
    -
    - 90 - -
    - + - return err -
    -
    - 91 - -
    - + - } -
    -
    - 92 - -
    - + - defer func(tx pgx.Tx, ctx context.Context) { -
    -
    - 93 - -
    - + - _ = tx.Rollback(ctx) -
    -
    - 94 - -
    - + - }(tx, ctx) -
    -
    - 95 - -
    - + -
    -
    -
    - 96 - -
    - + - for _, a := range addresses { -
    -
    - 97 - -
    - + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) -
    -
    - 98 - -
    - + - if err != nil { -
    -
    - 99 - -
    - + - return err -
    -
    - 100 - -
    - + - } -
    -
    - 101 - -
    - + - } -
    -
    - 102 - -
    - + - err = tx.Commit(ctx) -
    -
    - 103 - -
    - + - if err != nil { -
    -
    - 104 - -
    - + - return err -
    -
    - 105 - -
    - + - } -
    -
    - 106 - -
    - + - return nil -
    -
    - 107 - -
    - + - } -
    -
    - 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 - -
    - + - 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 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -93,6 +93,13 @@
    -
    - 93 - -
    -   - time.Sleep(cfg.IntervalToRefreshGasPrices.Duration) -
    -
    - 94 - -
    -   - } -
    -
    - 95 - -
    -   - }(&cfg, p) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 96 - -
    -   -
    -
    -
    - 97 - -
    -   - return p -
    -
    - 98 - -
    -   - } -
    -
    -
    @@ -239,7 +246,6 @@
    -
    - 239 - -
    -   - } -
    -
    - 240 - -
    -   -
    -
    -
    - 241 - -
    -   - poolTx := NewTransaction(tx, ip, isWIP) -
    -
    - 242 - -
    - - - poolTx.GasUsed = preExecutionResponse.txResponse.GasUsed -
    -
    - 243 - -
    -   - poolTx.ZKCounters = preExecutionResponse.usedZKCounters -
    -
    - 244 - -
    -   - poolTx.ReservedZKCounters = preExecutionResponse.reservedZKCounters -
    -
    - 245 - -
    -   -
    -
    -
    -
    @@ -687,7 +693,7 @@
    -
    - 687 - -
    -   -
    -
    -
    - 688 - -
    -   - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage -
    -
    - 689 - -
    -   - func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { -
    -
    - 690 - -
    - - - return p.effectiveGasPrice.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice) -
    -
    - 691 - -
    -   - } -
    -
    - 692 - -
    -   -
    -
    -
    - 693 - -
    -   - // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not -
    -
    -
    @@ -729,3 +735,8 @@
    -
    - 729 - -
    -   - } -
    -
    - 730 - -
    -   - return gas, nil -
    -
    - 731 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -   - } -
    -
    -
     
    -
    - 246 - -
    -   - } -
    -
    - 247 - -
    -   -
    -
    -
    - 248 - -
    -   - poolTx := NewTransaction(tx, ip, isWIP) -
    -
    - - -
    -   -
    -
    -
    - 249 - -
    -   - poolTx.ZKCounters = preExecutionResponse.usedZKCounters -
    -
    - 250 - -
    -   - poolTx.ReservedZKCounters = preExecutionResponse.reservedZKCounters -
    -
    - 251 - -
    -   -
    -
    -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1114,7 +1114,7 @@
    -
    - 1114 - -
    -   - stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, mtDBServerConfig) -
    -
    - 1115 - -
    -   - stateTree := merkletree.NewStateTree(stateDBClient) -
    -
    - 1116 - -
    -   -
    -
    -
    - 1117 - -
    - - - st := state.NewState(stCfg, stateDb, executorClient, stateTree, eventLog, nil, nil) -
    -
    - 1118 - -
    -   - return st -
    -
    - 1119 - -
    -   - } -
    -
    - 1120 - -
    -   -
    -
    -
    -
    @@ -2032,3 +2032,69 @@
    -
    - 2032 - -
    -   - require.NoError(t, err) -
    -
    - 2033 - -
    -   - return signedTx -
    -
    - 2034 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1114 - -
    -   - stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, mtDBServerConfig) -
    -
    - 1115 - -
    -   - stateTree := merkletree.NewStateTree(stateDBClient) -
    -
    - 1116 - -
    -   -
    -
    -
    - 1117 - -
    - + - st := state.NewState(stCfg, stateDb, executorClient, stateTree, eventLog, nil) -
    -
    - 1118 - -
    -   - return st -
    -
    - 1119 - -
    -   - } -
    -
    - 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 - -
    - + - require.NoError(t, err) -
    -
    - 2070 - -
    - + - require.Equal(t, int64(1), ctag.RowsAffected()) -
    -
    - 2071 - -
    - + - } -
    -
    - 2072 - -
    - + -
    -
    -
    - 2073 - -
    - + - // addr should not be denied by policy -
    -
    - 2074 - -
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { -
    -
    - 2075 - -
    - + - allow, err := p.CheckPolicy(ctx, policy, addr) -
    -
    - 2076 - -
    - + - require.NoError(t, err) -
    -
    - 2077 - -
    - + - require.False(t, allow) -
    -
    - 2078 - -
    - + - } -
    -
    - 2079 - -
    - + -
    -
    -
    - 2080 - -
    - + - // change policies to allow by acl -
    -
    - 2081 - -
    - + - ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true") -
    -
    - 2082 - -
    - + - require.NoError(t, err) -
    -
    - 2083 - -
    - + - require.Equal(t, int64(2), ctag.RowsAffected()) -
    -
    - 2084 - -
    - + -
    -
    -
    - 2085 - -
    - + - // addr is now allowed -
    -
    - 2086 - -
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { -
    -
    - 2087 - -
    - + - allow, err := p.CheckPolicy(ctx, policy, addr) -
    -
    - 2088 - -
    - + - require.NoError(t, err) -
    -
    - 2089 - -
    - + - require.True(t, allow) -
    -
    - 2090 - -
    - + - } -
    -
    - 2091 - -
    - + -
    -
    -
    - 2092 - -
    - + - // random addrs are now denied -
    -
    - 2093 - -
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { -
    -
    - 2094 - -
    - + - for _, a := range []common.Address{randAddr(), randAddr()} { -
    -
    - 2095 - -
    - + - allow, err := s.CheckPolicy(ctx, policy, a) -
    -
    - 2096 - -
    - + - require.NoError(t, err) -
    -
    - 2097 - -
    - + - require.False(t, allow) -
    -
    - 2098 - -
    - + - } -
    -
    - 2099 - -
    - + - } -
    -
    - 2100 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -10,9 +10,6 @@
    -
    - 10 - -
    -   - /// Processes a batch -
    -
    - 11 - -
    -   - rpc ProcessBatch(ProcessBatchRequest) returns (ProcessBatchResponse) {} -
    -
    - 12 - -
    -   - rpc ProcessBatchV2(ProcessBatchRequestV2) returns (ProcessBatchResponseV2) {} -
    -
    - 13 - -
    - - - rpc ProcessBatchV3(ProcessBatchRequestV3) returns (ProcessBatchResponseV3) {} -
    -
    - 14 - -
    - - - rpc ProcessBlobInnerV3(ProcessBlobInnerRequestV3) returns (ProcessBlobInnerResponseV3) {} -
    -
    - 15 - -
    - - - rpc ProcessStatelessBatchV2(ProcessStatelessBatchRequestV2) returns (ProcessBatchResponseV2) {} -
    -
    - 16 - -
    -   - rpc GetFlushStatus (google.protobuf.Empty) returns (GetFlushStatusResponse) {} -
    -
    - 17 - -
    -   - } -
    -
    - 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 - -
    - - -
    -
    -
    - 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; -
    -
    - 986 - -
    - - - // flag to skip writing the block info root in the state -
    -
    - 987 - -
    - - - uint32 skip_write_block_info_root = 15; -
    -
    - 988 - -
    - - - // 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; -
    -
    - 1048 - -
    - - - } -
    -
    - 1049 - -
    - - -
    -
    -
    - 1050 - -
    - - - message ForcedData { -
    -
    - 1051 - -
    - - - bytes global_exit_root = 1; -
    -
    - 1052 - -
    - - - bytes block_hash_l1 = 2; -
    -
    - 1053 - -
    - - - uint64 min_timestamp = 3; -
    -
    - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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; -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 296 - -
    -   - } -
    -
    - 297 - -
    -   -
    -
    -
    - 298 - -
    -   - message L1DataV2 { -
    -
    -
     
    -
    - 304 - -
    -   -
    -
    -
    - 305 - -
    -   - message DebugV2 { -
    -
    - 306 - -
    -   - uint64 gas_limit = 1; -
    -
    - 307 - -
    - + - bytes new_state_root = 2; -
    -
    - 308 - -
    -   - bytes new_acc_input_hash = 3; -
    -
    - 309 - -
    -   - bytes new_local_exit_root = 4; -
    -
    - 310 - -
    -   - uint64 new_batch_num = 5; -
    -
    -
     
    -
    - 343 - -
    -   - uint32 cnt_reserve_binaries = 30; -
    -
    - 344 - -
    -   - uint32 cnt_reserve_steps = 31; -
    -
    - 345 - -
    -   - 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 -
    -
    - 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; -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 878 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -251,15 +251,15 @@
    -
    - 251 - -
    -   - return false, nil -
    -
    - 252 - -
    -   - } -
    -
    - 253 - -
    -   -
    -
    -
    - 254 - -
    - - - // Check l1InfoRootIndex and GER matches -
    -
    - 255 - -
    - - - // We retrieve first the info of the last l1InfoTree event in the block -
    -
    - 256 - -
    -   - log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash) -
    -
    - 257 - -
    -   - blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber) -
    -
    - 258 - -
    -   - if err != nil { -
    -
    - 259 - -
    -   - return false, err -
    -
    - 260 - -
    -   - } -
    -
    - 261 - -
    -   -
    -
    -
    - 262 - -
    - - - // 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 -
    -
    - 263 - -
    -   - lastGER := state.ZeroHash -
    -
    - 264 - -
    -   - for _, block := range blocks { -
    -
    - 265 - -
    -   - blockEventsOrder := eventsOrder[block.BlockHash] -
    -
    -
    @@ -482,6 +482,7 @@
    -
    - 482 - -
    -   - SkipWriteBlockInfoRoot_V2: true, -
    -
    - 483 - -
    -   - SkipVerifyL1InfoRoot_V2: true, -
    -
    - 484 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - - -
    -   -
    -
    -
    - 485 - -
    -   - } -
    -
    - 486 - -
    -   -
    -
    -
    - 487 - -
    -   - txGasPrice := tx.GasPrice -
    -
    -
    @@ -528,7 +529,7 @@
    -
    - 528 - -
    -   - } -
    -
    - 529 - -
    -   - } -
    -
    - 530 - -
    -   -
    -
    -
    - 531 - -
    - - - egpPercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) -
    -
    - 532 - -
    -   - if err != nil { -
    -
    - 533 - -
    -   - if f.effectiveGasPrice.IsEnabled() { -
    -
    - 534 - -
    -   - return nil, err -
    -
    -
    @@ -644,7 +645,7 @@
    -
    - 644 - -
    -   -
    -
    -
    - 645 - -
    -   - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging -
    -
    - 646 - -
    -   - if !egpEnabled { -
    -
    - 647 - -
    - - - effectivePercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) -
    -
    - 648 - -
    -   - if err != nil { -
    -
    - 649 - -
    -   - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) -
    -
    - 650 - -
    -   - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 251 - -
    -   - return false, nil -
    -
    - 252 - -
    -   - } -
    -
    - 253 - -
    -   -
    -
    -
    - 254 - -
    - + - // 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 -
    -
    - 255 - -
    - + - // in the same block, the function checkL1InfoTreeUpdate retrieves only the last one and skips the others -
    -
    - 256 - -
    -   - log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash) -
    -
    - 257 - -
    -   - blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber) -
    -
    - 258 - -
    -   - if err != nil { -
    -
    - 259 - -
    -   - return false, err -
    -
    - 260 - -
    -   - } -
    -
    - 261 - -
    -   -
    -
    -
    - 262 - -
    - + - //Get L1InfoTree events of the L1 block where the l1InforRoot we need to check was synced -
    -
    - 263 - -
    -   - lastGER := state.ZeroHash -
    -
    - 264 - -
    -   - for _, block := range blocks { -
    -
    - 265 - -
    -   - blockEventsOrder := eventsOrder[block.BlockHash] -
    -
    -
     
    -
    - 482 - -
    -   - SkipWriteBlockInfoRoot_V2: true, -
    -
    - 483 - -
    -   - SkipVerifyL1InfoRoot_V2: true, -
    -
    - 484 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - 485 - -
    - + - ExecutionMode: executor.ExecutionMode0, -
    -
    - 486 - -
    -   - } -
    -
    - 487 - -
    -   -
    -
    -
    - 488 - -
    -   - txGasPrice := tx.GasPrice -
    -
    -
     
    -
    - 529 - -
    -   - } -
    -
    - 530 - -
    -   - } -
    -
    - 531 - -
    -   -
    -
    -
    - 532 - -
    - + - egpPercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) -
    -
    - 533 - -
    -   - if err != nil { -
    -
    - 534 - -
    -   - if f.effectiveGasPrice.IsEnabled() { -
    -
    - 535 - -
    -   - return nil, err -
    -
    -
     
    -
    - 645 - -
    -   -
    -
    -
    - 646 - -
    -   - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging -
    -
    - 647 - -
    -   - if !egpEnabled { -
    -
    - 648 - -
    - + - effectivePercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) -
    -
    - 649 - -
    -   - if err != nil { -
    -
    - 650 - -
    -   - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) -
    -
    - 651 - -
    -   - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -333,6 +334,7 @@
    -
    - 333 - -
    -   - ForkID: f.stateIntf.GetForkIDByBatchNumber(l2Block.batch.batchNumber), -
    -
    - 334 - -
    -   - SkipVerifyL1InfoRoot_V2: true, -
    -
    - 335 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - - -
    -   -
    -
    -
    - 336 - -
    -   - } -
    -
    - 337 - -
    -   - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ -
    -
    - 338 - -
    -   - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, -
    -
    -
    @@ -475,6 +477,9 @@
    -
    - 475 - -
    -   - return err -
    -
    - 476 - -
    -   - } -
    -
    - 477 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 478 - -
    -   - // Update txs status in the pool -
    -
    - 479 - -
    -   - for _, txResponse := range blockResponse.TransactionResponses { -
    -
    - 480 - -
    -   - // Change Tx status to selected -
    -
    -
    @@ -484,13 +489,19 @@
    -
    - 484 - -
    -   - } -
    -
    - 485 - -
    -   - } -
    -
    - 486 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 487 - -
    -   - // Send L2 block to data streamer -
    -
    - 488 - -
    - - - err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex()) -
    -
    - 489 - -
    -   - if err != nil { -
    -
    - 490 - -
    -   - //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? -
    -
    - 491 - -
    -   - log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) -
    -
    - 492 - -
    -   - } -
    -
    - 493 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 494 - -
    -   - for _, tx := range l2Block.transactions { -
    -
    - 495 - -
    -   - // Delete the tx from the pending list in the worker (addrQueue) -
    -
    - 496 - -
    -   - f.workerIntf.DeleteTxPendingToStore(tx.Hash, tx.From) -
    -
    -
    @@ -693,6 +704,7 @@
    -
    - 693 - -
    -   - SkipFirstChangeL2Block_V2: false, -
    -
    - 694 - -
    -   - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), -
    -
    - 695 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - - -
    -   -
    -
    -
    - 696 - -
    -   - } -
    -
    - 697 - -
    -   -
    -
    -
    - 698 - -
    -   - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 334 - -
    -   - ForkID: f.stateIntf.GetForkIDByBatchNumber(l2Block.batch.batchNumber), -
    -
    - 335 - -
    -   - SkipVerifyL1InfoRoot_V2: true, -
    -
    - 336 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - 337 - -
    - + - ExecutionMode: executor.ExecutionMode0, -
    -
    - 338 - -
    -   - } -
    -
    - 339 - -
    -   - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ -
    -
    - 340 - -
    -   - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, -
    -
    -
     
    -
    - 477 - -
    -   - return err -
    -
    - 478 - -
    -   - } -
    -
    - 479 - -
    -   -
    -
    -
    - 480 - -
    - + - //TODO: remove this Log -
    -
    - 481 - -
    - + - log.Infof("[ds-debug] l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum) -
    -
    - 482 - -
    - + -
    -
    -
    - 483 - -
    -   - // Update txs status in the pool -
    -
    - 484 - -
    -   - for _, txResponse := range blockResponse.TransactionResponses { -
    -
    - 485 - -
    -   - // Change Tx status to selected -
    -
    -
     
    -
    - 489 - -
    -   - } -
    -
    - 490 - -
    -   - } -
    -
    - 491 - -
    -   -
    -
    -
    - 492 - -
    - + - //TODO: remove this log -
    -
    - 493 - -
    - + - log.Infof("[ds-debug] l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum) -
    -
    - 494 - -
    - + -
    -
    -
    - 495 - -
    -   - // Send L2 block to data streamer -
    -
    - 496 - -
    - + - err = f.DSSendL2Block(l2Block.batch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex()) -
    -
    - 497 - -
    -   - if err != nil { -
    -
    - 498 - -
    -   - //TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer? -
    -
    - 499 - -
    -   - log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) -
    -
    - 500 - -
    -   - } -
    -
    - 501 - -
    -   -
    -
    -
    - 502 - -
    - + - //TODO: remove this log -
    -
    - 503 - -
    - + - log.Infof("[ds-debug] l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum) -
    -
    - 504 - -
    - + -
    -
    -
    - 505 - -
    -   - for _, tx := range l2Block.transactions { -
    -
    - 506 - -
    -   - // Delete the tx from the pending list in the worker (addrQueue) -
    -
    - 507 - -
    -   - f.workerIntf.DeleteTxPendingToStore(tx.Hash, tx.From) -
    -
    -
     
    -
    - 704 - -
    -   - SkipFirstChangeL2Block_V2: false, -
    -
    - 705 - -
    -   - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), -
    -
    - 706 - -
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - 707 - -
    - + - ExecutionMode: executor.ExecutionMode0, -
    -
    - 708 - -
    -   - } -
    -
    - 709 - -
    -   -
    -
    -
    - 710 - -
    -   - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -270,6 +270,8 @@
    -
    - 270 - -
    -   - case state.DSL2FullBlock: -
    -
    - 271 - -
    -   - l2Block := data -
    -
    - 272 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 273 - -
    -   - err = s.streamServer.StartAtomicOp() -
    -
    - 274 - -
    -   - if err != nil { -
    -
    - 275 - -
    -   - log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) -
    -
    -
    @@ -281,6 +283,8 @@
    -
    - 281 - -
    -   - Value: l2Block.L2BlockNumber, -
    -
    - 282 - -
    -   - } -
    -
    - 283 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 284 - -
    -   - _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) -
    -
    - 285 - -
    -   - if err != nil { -
    -
    - 286 - -
    -   - log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    -
    @@ -295,6 +299,8 @@
    -
    - 295 - -
    -   - Value: l2Block.L2BlockNumber - 1, -
    -
    - 296 - -
    -   - } -
    -
    - 297 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 298 - -
    -   - previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) -
    -
    - 299 - -
    -   - if err != nil { -
    -
    - 300 - -
    -   - log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) -
    -
    -
    @@ -317,12 +323,16 @@
    -
    - 317 - -
    -   - ChainID: uint32(chainID), -
    -
    - 318 - -
    -   - } -
    -
    - 319 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 320 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) -
    -
    - 321 - -
    -   - if err != nil { -
    -
    - 322 - -
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    - 323 - -
    -   - continue -
    -
    - 324 - -
    -   - } -
    -
    - 325 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 326 - -
    -   - for _, l2Transaction := range l2Block.Txs { -
    -
    - 327 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) -
    -
    - 328 - -
    -   - if err != nil { -
    -
    -
    @@ -337,18 +347,25 @@
    -
    - 337 - -
    -   - StateRoot: l2Block.StateRoot, -
    -
    - 338 - -
    -   - } -
    -
    - 339 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 340 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode()) -
    -
    - 341 - -
    -   - if err != nil { -
    -
    - 342 - -
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    - 343 - -
    -   - continue -
    -
    - 344 - -
    -   - } -
    -
    - 345 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -   - // Stream a bookmark -
    -
    - 353 - -
    -   - case state.DSBookMark: -
    -
    - 354 - -
    -   - bookmark := data -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 270 - -
    -   - case state.DSL2FullBlock: -
    -
    - 271 - -
    -   - l2Block := data -
    -
    - 272 - -
    -   -
    -
    -
    - 273 - -
    - + - //TODO: remove this log -
    -
    - 274 - -
    - + - log.Infof("[ds-debug] start atomic op for l2block %d", l2Block.L2BlockNumber) -
    -
    - 275 - -
    -   - err = s.streamServer.StartAtomicOp() -
    -
    - 276 - -
    -   - if err != nil { -
    -
    - 277 - -
    -   - log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) -
    -
    -
     
    -
    - 283 - -
    -   - Value: l2Block.L2BlockNumber, -
    -
    - 284 - -
    -   - } -
    -
    - 285 - -
    -   -
    -
    -
    - 286 - -
    - + - //TODO: remove this log -
    -
    - 287 - -
    - + - log.Infof("[ds-debug] add stream bookmark for l2block %d", l2Block.L2BlockNumber) -
    -
    - 288 - -
    -   - _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) -
    -
    - 289 - -
    -   - if err != nil { -
    -
    - 290 - -
    -   - log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    -
     
    -
    - 299 - -
    -   - Value: l2Block.L2BlockNumber - 1, -
    -
    - 300 - -
    -   - } -
    -
    - 301 - -
    -   -
    -
    -
    - 302 - -
    - + - //TODO: remove this log -
    -
    - 303 - -
    - + - log.Infof("[ds-debug] get previous l2block %d", l2Block.L2BlockNumber-1) -
    -
    - 304 - -
    -   - previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) -
    -
    - 305 - -
    -   - if err != nil { -
    -
    - 306 - -
    -   - log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) -
    -
    -
     
    -
    - 323 - -
    -   - ChainID: uint32(chainID), -
    -
    - 324 - -
    -   - } -
    -
    - 325 - -
    -   -
    -
    -
    - 326 - -
    - + - //TODO: remove this log -
    -
    - 327 - -
    - + - log.Infof("[ds-debug] add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber) -
    -
    - 328 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) -
    -
    - 329 - -
    -   - if err != nil { -
    -
    - 330 - -
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    - 331 - -
    -   - continue -
    -
    - 332 - -
    -   - } -
    -
    - 333 - -
    -   -
    -
    -
    - 334 - -
    - + - //TODO: remove this log -
    -
    - 335 - -
    - + - log.Infof("[ds-debug] adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber) -
    -
    - 336 - -
    -   - for _, l2Transaction := range l2Block.Txs { -
    -
    - 337 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) -
    -
    - 338 - -
    -   - if err != nil { -
    -
    -
     
    -
    - 347 - -
    -   - StateRoot: l2Block.StateRoot, -
    -
    - 348 - -
    -   - } -
    -
    - 349 - -
    -   -
    -
    -
    - 350 - -
    - + - //TODO: remove this log -
    -
    - 351 - -
    - + - log.Infof("[ds-debug] add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber) -
    -
    - 352 - -
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode()) -
    -
    - 353 - -
    -   - if err != nil { -
    -
    - 354 - -
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) -
    -
    - 355 - -
    -   - continue -
    -
    - 356 - -
    -   - } -
    -
    - 357 - -
    -   -
    -
    -
    - 358 - -
    - + - //TODO: remove this log -
    -
    - 359 - -
    - + - log.Infof("[ds-debug] commit atomic op for l2block %d", l2Block.L2BlockNumber) -
    -
    - 360 - -
    -   - err = s.streamServer.CommitAtomicOp() -
    -
    - 361 - -
    -   - if err != nil { -
    -
    - 362 - -
    -   - log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) -
    -
    - 363 - -
    -   - continue -
    -
    - 364 - -
    -   - } -
    -
    - 365 - -
    -   -
    -
    -
    - 366 - -
    - + - //TODO: remove this log -
    -
    - 367 - -
    - + - log.Infof("[ds-debug] l2block %d sent to datastream", l2Block.L2BlockNumber) -
    -
    - 368 - -
    - + -
    -
    -
    - 369 - -
    -   - // Stream a bookmark -
    -
    - 370 - -
    -   - case state.DSBookMark: -
    -
    - 371 - -
    -   - bookmark := data -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -41,4 +41,6 @@
    -
    - 41 - -
    -   - // gas offset: 100 -
    -
    - 42 - -
    -   - // final gas: 1100 -
    -
    - 43 - -
    -   - GasOffset uint64 `mapstructure:"GasOffset"` -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 44 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 41 - -
    -   - // gas offset: 100 -
    -
    - 42 - -
    -   - // final gas: 1100 -
    -
    - 43 - -
    -   - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -17,8 +17,8 @@
    -
    - 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) (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) -
    -
    - 22 - -
    -   - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) -
    -
    - 23 - -
    -   - GetLatestBatchNumber() (uint64, error) -
    -
    - 24 - -
    -   - } -
    -
    -
     
    -
    - 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 - -
    -   - } -
    -
    - 44 - -
    - + -
    -
    -
    - 45 - -
    - + - type dataAbilitier interface { -
    -
    - 46 - -
    - + - PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error) -
    -
    - 47 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -6,13 +6,11 @@
    -
    - 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 -
    -
    -
    @@ -208,7 +213,7 @@
    -
    - 208 - -
    -   - func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequence, error) { -
    -
    - 209 - -
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) -
    -
    - 210 - -
    -   - if err != nil { -
    -
    - 211 - -
    - - - return nil, fmt.Errorf("failed to get last virtual batch num, err: %w", err) -
    -
    - 212 - -
    -   - } -
    -
    - 213 - -
    -   - log.Debugf("last virtual batch number: %d", lastVirtualBatchNum) -
    -
    - 214 - -
    -   -
    -
    -
    -
    @@ -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 -
    -
    -
    @@ -234,14 +237,14 @@
    -
    - 234 - -
    -   - if err == state.ErrNotFound { -
    -
    - 235 - -
    -   - break -
    -
    - 236 - -
    -   - } -
    -
    - 237 - -
    - - - log.Debugf("failed to get batch by number %d, err: %w", currentBatchNumToSequence, err) -
    -
    - 238 - -
    -   - return nil, err -
    -
    - 239 - -
    -   - } -
    -
    - 240 - -
    -   -
    -
    -
    - 241 - -
    -   - // Check if batch is closed and checked (sequencer sanity check was successful) -
    -
    - 242 - -
    -   - isChecked, err := s.state.IsBatchChecked(ctx, currentBatchNumToSequence, nil) -
    -
    - 243 - -
    -   - if err != nil { -
    -
    - 244 - -
    - - - log.Debugf("failed to check if batch %d is closed and checked, err: %w", currentBatchNumToSequence, err) -
    -
    - 245 - -
    -   - return nil, err -
    -
    - 246 - -
    -   - } -
    -
    - 247 - -
    -   -
    -
    -
    -
    @@ -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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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" -
    -
    - - -
    -   -
    -
    -
    - 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 -
    -
    -
     
    -
    - 213 - -
    -   - func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequence, error) { -
    -
    - 214 - -
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) -
    -
    - 215 - -
    -   - if err != nil { -
    -
    - 216 - -
    - + - return nil, fmt.Errorf("failed to get last virtual batch num, err: %v", err) -
    -
    - 217 - -
    -   - } -
    -
    - 218 - -
    -   - log.Debugf("last virtual batch number: %d", lastVirtualBatchNum) -
    -
    - 219 - -
    -   -
    -
    -
    -
     
    -
    - 223 - -
    -   - sequences := []types.Sequence{} -
    -
    - 224 - -
    -   - // var estimatedGas uint64 -
    -
    - 225 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 -
    -
    -
     
    -
    - 237 - -
    -   - if err == state.ErrNotFound { -
    -
    - 238 - -
    -   - break -
    -
    - 239 - -
    -   - } -
    -
    - 240 - -
    - + - log.Debugf("failed to get batch by number %d, err: %v", currentBatchNumToSequence, err) -
    -
    - 241 - -
    -   - return nil, err -
    -
    - 242 - -
    -   - } -
    -
    - 243 - -
    -   -
    -
    -
    - 244 - -
    -   - // Check if batch is closed and checked (sequencer sanity check was successful) -
    -
    - 245 - -
    -   - isChecked, err := s.state.IsBatchChecked(ctx, currentBatchNumToSequence, nil) -
    -
    - 246 - -
    -   - if err != nil { -
    -
    - 247 - -
    - + - log.Debugf("failed to check if batch %d is closed and checked, err: %v", currentBatchNumToSequence, err) -
    -
    - 248 - -
    -   - return nil, err -
    -
    - 249 - -
    -   - } -
    -
    - 250 - -
    -   -
    -
    -
    -
     
    -
    - 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 - -
    - + - ) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 299 - -
    -   - return sequences, nil -
    -
    - 300 - -
    -   - } -
    -
    - 301 - -
    -   -
    -
    -
    -
     
    -
    - 326 - -
    -   - return nil, nil -
    -
    - 327 - -
    -   - } -
    -
    - 328 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 → .}/sonar-project.properties - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,15 +1,10 @@
    -
    - 1 - -
    - - - sonar.projectKey=0xPolygonHermez_zkevm-node -
    -
    - 2 - -
    - - - sonar.organization=0xpolygonhermez -
    -
    - 3 - -
    -   -
    -
    -
    - 4 - -
    -   - sonar.sources=. -
    -
    - 5 - -
    -   - sonar.exclusions=**/*_test.go -
    -
    - 6 - -
    - - - sonar.exclusions=**/mock_*.go, **/mock/** -
    -
    - 7 - -
    -   - -
    -
    - 8 - -
    -   - sonar.tests=. -
    -
    - 9 - -
    -   - sonar.test.inclusions=**/*_test.go -
    -
    - 10 - -
    - - - sonar.test.exclusions=**/mock_*.go, **/mock/** -
    -
    - 11 - -
    - - -
    -
    -
    - 12 - -
    -   - sonar.go.coverage.reportPaths=coverage.out -
    -
    - 13 - -
    - - - #sonar.coverageReportPaths=coverage.out -
    -
    - 14 - -
    - - - #onar.testExecutionReportPaths=report.json -
    -
    - 15 - -
    -   - sonar.go.tests.reportPaths=report.json -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - sonar.projectKey=zkevm-node -
    -
    - - -
    -   -
    -
    -
    - 2 - -
    -   -
    -
    -
    - 3 - -
    -   - sonar.sources=. -
    -
    - 4 - -
    -   - sonar.exclusions=**/*_test.go -
    -
    - 5 - -
    - + - sonar.exclusions=**/mock_*.go -
    -
    - 6 - -
    -   - -
    -
    - 7 - -
    -   - sonar.tests=. -
    -
    - 8 - -
    -   - sonar.test.inclusions=**/*_test.go -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 9 - -
    -   - sonar.go.coverage.reportPaths=coverage.out -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 10 - -
    -   - 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 -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import "time" -
    -
    - 4 - -
    - - -
    -
    -
    - 5 - -
    - - - // PendingBatch represents a batch pending to be executed -
    -
    - 6 - -
    - - - type PendingBatch struct { -
    -
    - 7 - -
    - - - BatchNumber uint64 -
    -
    - 8 - -
    - - - BlobInnerNum uint64 -
    -
    - 9 - -
    - - - CreatedAt time.Time -
    -
    - 10 - -
    - - - Processed bool -
    -
    - 11 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -33,6 +33,7 @@
    -
    - 33 - -
    -   - ForcedBlockHashL1 *common.Hash -
    -
    - 34 - -
    -   - SkipVerifyL1InfoRoot uint32 -
    -
    - 35 - -
    -   - GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB) -
    -
    - - -
    -   -
    -
    -
    - 36 - -
    -   - ClosingReason ClosingReason -
    -
    - 37 - -
    -   - } -
    -
    - 38 - -
    -   -
    -
    -
    -
    @@ -68,6 +69,7 @@
    -
    - 68 - -
    -   - ChainId: s.cfg.ChainID, -
    -
    - 69 - -
    -   - ForkId: request.ForkID, -
    -
    - 70 - -
    -   - ContextId: uuid.NewString(), -
    -
    - - -
    -   -
    -
    -
    - 71 - -
    -   - } -
    -
    - 72 - -
    -   -
    -
    -
    - 73 - -
    -   - if request.SkipFirstChangeL2Block_V2 { -
    -
    -
    @@ -130,6 +132,7 @@
    -
    - 130 - -
    -   - ForkId: forkId, -
    -
    - 131 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 132 - -
    -   - SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot, -
    -
    - - -
    -   -
    -
    -
    - 133 - -
    -   - } -
    -
    - 134 - -
    -   -
    -
    -
    - 135 - -
    -   - if forcedBlockHashL1 != nil { -
    -
    -
    @@ -168,7 +171,7 @@
    -
    - 168 - -
    -   - return nil, err -
    -
    - 169 - -
    -   - } else if processBatchResponse != nil && processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { -
    -
    - 170 - -
    -   - err = executor.ExecutorErr(processBatchResponse.Error) -
    -
    - 171 - -
    - - - s.eventLog.LogExecutorError(ctx, processBatchResponse.Error, processBatchRequest) -
    -
    - 172 - -
    -   - } -
    -
    - 173 - -
    -   -
    -
    -
    - 174 - -
    -   - return processBatchResponse, err -
    -
    -
    @@ -230,6 +233,7 @@
    -
    - 230 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 231 - -
    -   - SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot, -
    -
    - 232 - -
    -   - L1InfoRoot: processingCtx.L1InfoRoot.Bytes(), -
    -
    - - -
    -   -
    -
    -
    - 233 - -
    -   - } -
    -
    - 234 - -
    -   -
    -
    -
    - 235 - -
    -   - if processingCtx.ForcedBlockHashL1 != nil { -
    -
    -
    @@ -299,12 +303,12 @@
    -
    - 299 - -
    -   - log.Errorf("error executor ProcessBatchV2: %s", err.Error()) -
    -
    - 300 - -
    -   - log.Errorf("error executor ProcessBatchV2 response: %v", batchResponse) -
    -
    - 301 - -
    -   - } else { -
    -
    - 302 - -
    - - - batchResponseToString := processBatchResponseV2ToString(newBatchNum, batchResponse, elapsed) -
    -
    - 303 - -
    -   - if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { -
    -
    - 304 - -
    -   - err = executor.ExecutorErr(batchResponse.Error) -
    -
    - 305 - -
    -   - log.Warnf("executor batch %d response, executor error: %v", newBatchNum, err) -
    -
    - 306 - -
    -   - log.Warn(batchResponseToString) -
    -
    - 307 - -
    - - - s.eventLog.LogExecutorError(ctx, batchResponse.Error, batchRequest) -
    -
    - 308 - -
    -   - } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) { -
    -
    - 309 - -
    -   - err = executor.RomErr(batchResponse.ErrorRom) -
    -
    - 310 - -
    -   - log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err) -
    -
    -
    @@ -321,32 +325,32 @@
    -
    - 321 - -
    -   - return batchResponse, err -
    -
    - 322 - -
    -   - } -
    -
    - 323 - -
    -   -
    -
    -
    - 324 - -
    - - - func processBatchResponseV2ToString(batchNum uint64, batchResponse *executor.ProcessBatchResponseV2, executionTime time.Duration) string { -
    -
    - 325 - -
    -   - 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" -
    -
    - 326 - -
    -   - batchResponseLog = fmt.Sprintf(batchResponseLog, batchNum, executionTime, hex.EncodeToHex(batchResponse.NewStateRoot), hex.EncodeToHex(batchResponse.NewAccInputHash), hex.EncodeToHex(batchResponse.NewLocalExitRoot), -
    -
    - 327 - -
    -   - batchResponse.NewBatchNum, batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error) -
    -
    - 328 - -
    -   -
    -
    -
    - 329 - -
    -   - for blockIndex, block := range batchResponse.BlockResponses { -
    -
    - 330 - -
    -   - prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex) -
    -
    - 331 - -
    - - - batchResponseLog += blockResponseV2ToString(block, prefix) -
    -
    - 332 - -
    -   - } -
    -
    - 333 - -
    -   -
    -
    -
    - 334 - -
    -   - return batchResponseLog -
    -
    - 335 - -
    -   - } -
    -
    - 336 - -
    - - - func blockResponseV2ToString(blockResponse *executor.ProcessBlockResponseV2, prefix string) string { -
    -
    - 337 - -
    -   - blockResponseLog := prefix + "ParentHash: %v, Coinbase: %v, GasLimit: %v, BlockNumber: %v, Timestamp: %v, GlobalExitRoot: %v, BlockHashL1: %v, GasUsed: %v, BlockInfoRoot: %v, BlockHash: %v\n" -
    -
    - 338 - -
    -   - blockResponseLog = fmt.Sprintf(blockResponseLog, common.BytesToHash(blockResponse.ParentHash), blockResponse.Coinbase, blockResponse.GasLimit, blockResponse.BlockNumber, blockResponse.Timestamp, -
    -
    - 339 - -
    -   - common.BytesToHash(blockResponse.Ger), common.BytesToHash(blockResponse.BlockHashL1), blockResponse.GasUsed, common.BytesToHash(blockResponse.BlockInfoRoot), common.BytesToHash(blockResponse.BlockHash)) -
    -
    - 340 - -
    -   -
    -
    -
    - 341 - -
    -   - for txIndex, tx := range blockResponse.Responses { -
    -
    - 342 - -
    -   - prefix := " " + fmt.Sprintf("tx[%v]: ", txIndex) -
    -
    - 343 - -
    - - - blockResponseLog += transactionResponseV2ToString(tx, prefix) -
    -
    - 344 - -
    -   - } -
    -
    - 345 - -
    -   -
    -
    -
    - 346 - -
    -   - return blockResponseLog -
    -
    - 347 - -
    -   - } -
    -
    - 348 - -
    -   -
    -
    -
    - 349 - -
    - - - func transactionResponseV2ToString(txResponse *executor.ProcessTransactionResponseV2, prefix string) string { -
    -
    - 350 - -
    -   - txResponseLog := prefix + "TxHash: %v, TxHashL2: %v, Type: %v, StateRoot:%v, GasUsed: %v, GasLeft: %v, GasRefund: %v, Error: %v\n" -
    -
    - 351 - -
    -   - txResponseLog = fmt.Sprintf(txResponseLog, common.BytesToHash(txResponse.TxHash), common.BytesToHash(txResponse.TxHashL2), txResponse.Type, -
    -
    - 352 - -
    -   - common.BytesToHash(txResponse.StateRoot), txResponse.GasUsed, txResponse.GasLeft, txResponse.GasRefunded, txResponse.Error) -
    -
    -
    @@ -416,14 +420,3 @@
    -
    - 416 - -
    -   - ClosingReason: processingCtx.ClosingReason, -
    -
    - 417 - -
    -   - }, dbTx) -
    -
    - 418 - -
    -   - } -
    -
    - 419 - -
    - - -
    -
    -
    - 420 - -
    - - - // BuildChangeL2Block returns a changeL2Block tx to use in the BatchL2Data -
    -
    - 421 - -
    - - - func (p *State) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte { -
    -
    - 422 - -
    - - - l2block := ChangeL2BlockHeader{ -
    -
    - 423 - -
    - - - DeltaTimestamp: deltaTimestamp, -
    -
    - 424 - -
    - - - IndexL1InfoTree: l1InfoTreeIndex, -
    -
    - 425 - -
    - - - } -
    -
    - 426 - -
    - - - var data []byte -
    -
    - 427 - -
    - - - data = l2block.Encode(data) -
    -
    - 428 - -
    - - - return data -
    -
    - 429 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 33 - -
    -   - ForcedBlockHashL1 *common.Hash -
    -
    - 34 - -
    -   - SkipVerifyL1InfoRoot uint32 -
    -
    - 35 - -
    -   - GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB) -
    -
    - 36 - -
    - + - ExecutionMode uint64 -
    -
    - 37 - -
    -   - ClosingReason ClosingReason -
    -
    - 38 - -
    -   - } -
    -
    - 39 - -
    -   -
    -
    -
    -
     
    -
    - 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 { -
    -
    -
     
    -
    - 171 - -
    -   - return nil, err -
    -
    - 172 - -
    -   - } else if processBatchResponse != nil && processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { -
    -
    - 173 - -
    -   - err = executor.ExecutorErr(processBatchResponse.Error) -
    -
    - 174 - -
    - + - 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) { -
    -
    - 313 - -
    -   - err = executor.RomErr(batchResponse.ErrorRom) -
    -
    - 314 - -
    -   - log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err) -
    -
    -
     
    -
    - 325 - -
    -   - return batchResponse, err -
    -
    - 326 - -
    -   - } -
    -
    - 327 - -
    -   -
    -
    -
    - 328 - -
    - + - func processBatchResponseToString(batchNum uint64, batchResponse *executor.ProcessBatchResponseV2, executionTime time.Duration) string { -
    -
    - 329 - -
    -   - 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" -
    -
    - 330 - -
    -   - batchResponseLog = fmt.Sprintf(batchResponseLog, batchNum, executionTime, hex.EncodeToHex(batchResponse.NewStateRoot), hex.EncodeToHex(batchResponse.NewAccInputHash), hex.EncodeToHex(batchResponse.NewLocalExitRoot), -
    -
    - 331 - -
    -   - batchResponse.NewBatchNum, batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error) -
    -
    - 332 - -
    -   -
    -
    -
    - 333 - -
    -   - for blockIndex, block := range batchResponse.BlockResponses { -
    -
    - 334 - -
    -   - prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex) -
    -
    - 335 - -
    - + - batchResponseLog += blockResponseToString(block, prefix) -
    -
    - 336 - -
    -   - } -
    -
    - 337 - -
    -   -
    -
    -
    - 338 - -
    -   - return batchResponseLog -
    -
    - 339 - -
    -   - } -
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 44 - -
    -   - ctx := context.Background() -
    -
    - 45 - -
    -   - mockStorage := mocks.NewStorageMock(t) -
    -
    - 46 - -
    -   - mockExecutor := mocks.NewExecutorServiceClientMock(t) -
    -
    - 47 - -
    - + - testState := state.NewState(stateCfg, mockStorage, mockExecutor, 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 - -
    -   - ctx := context.Background() -
    -
    - 123 - -
    -   - mockStorage := mocks.NewStorageMock(t) -
    -
    - 124 - -
    -   - mockExecutor := mocks.NewExecutorServiceClientMock(t) -
    -
    - 125 - -
    - + - testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil) -
    -
    - 126 - -
    -   - mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil) -
    -
    - 127 - -
    -   - dbTx, err := testState.BeginStateTransaction(ctx) -
    -
    - 128 - -
    -   - require.NoError(t, err) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV3.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,137 +0,0 @@
    -
    - 1 - -
    - - - package state -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "fmt" -
    -
    - 6 - -
    - - - "time" -
    -
    - 7 - -
    - - -
    -
    -
    - 8 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/hex" -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state/metrics" -
    -
    - 11 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" -
    -
    - 12 - -
    - - - "github.com/google/uuid" -
    -
    - 13 - -
    - - - ) -
    -
    - 14 - -
    - - -
    -
    -
    - 15 - -
    - - - // ProcessBatchV3 processes a batch for forkID >= FEIJOA -
    -
    - 16 - -
    - - - func (s *State) ProcessBatchV3(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, error) { -
    -
    - 17 - -
    - - - updateMT := uint32(cFalse) -
    -
    - 18 - -
    - - - if updateMerkleTree { -
    -
    - 19 - -
    - - - updateMT = cTrue -
    -
    - 20 - -
    - - - } -
    -
    - 21 - -
    - - -
    -
    -
    - 22 - -
    - - - l1InfoTreeData := make(map[uint32]*executor.L1DataV3) -
    -
    - 23 - -
    - - -
    -
    -
    - 24 - -
    - - - for k, v := range request.L1InfoTreeData_V3 { -
    -
    - 25 - -
    - - - l1InfoTreeData[k] = &executor.L1DataV3{ -
    -
    - 26 - -
    - - - GlobalExitRoot: v.GlobalExitRoot.Bytes(), -
    -
    - 27 - -
    - - - BlockHashL1: v.BlockHashL1.Bytes(), -
    -
    - 28 - -
    - - - MinTimestamp: v.MinTimestamp, -
    -
    - 29 - -
    - - - SmtProofPreviousIndex: v.SmtProofPreviousIndex, -
    -
    - 30 - -
    - - - InitialHistoricRoot: v.InitialHistoricRoot.Bytes(), -
    -
    - 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 - -
    - - -
    -
    -
    - 71 - -
    - - - func (s *State) sendBatchRequestToExecutorV3(ctx context.Context, batchRequest *executor.ProcessBatchRequestV3, caller metrics.CallerLabel) (*executor.ProcessBatchResponseV3, error) { -
    -
    - 72 - -
    - - - if s.executorClient == nil { -
    -
    - 73 - -
    - - - return nil, ErrExecutorNil -
    -
    - 74 - -
    - - - } -
    -
    - 75 - -
    - - -
    -
    -
    - 76 - -
    - - - l1DataStr := "" -
    -
    - 77 - -
    - - - for i, l1Data := range batchRequest.L1InfoTreeData { -
    -
    - 78 - -
    - - - l1DataStr += fmt.Sprintf("[%d]{GlobalExitRoot: %v, BlockHashL1: %v, MinTimestamp: %v},", i, hex.EncodeToHex(l1Data.GlobalExitRoot), hex.EncodeToHex(l1Data.BlockHashL1), l1Data.MinTimestamp) -
    -
    - 79 - -
    - - - } -
    -
    - 80 - -
    - - - if l1DataStr != "" { -
    -
    - 81 - -
    - - - l1DataStr = l1DataStr[:len(l1DataStr)-1] -
    -
    - 82 - -
    - - - } -
    -
    - 83 - -
    - - -
    -
    -
    - 84 - -
    - - - // Log the batch request -
    -
    - 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" -
    -
    - 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) -
    -
    - 87 - -
    - - -
    -
    -
    - 88 - -
    - - - log.Debugf("executor batch request, %s", batchRequestLog) -
    -
    - 89 - -
    - - -
    -
    -
    - 90 - -
    - - - now := time.Now() -
    -
    - 91 - -
    - - - batchResponse, err := s.executorClient.ProcessBatchV3(ctx, batchRequest) -
    -
    - 92 - -
    - - - elapsed := time.Since(now) -
    -
    - 93 - -
    - - -
    -
    -
    - 94 - -
    - - - // workarroundDuplicatedBlock(res) -
    -
    - 95 - -
    - - - if caller != metrics.DiscardCallerLabel { -
    -
    - 96 - -
    - - - metrics.ExecutorProcessingTime(string(caller), elapsed) -
    -
    - 97 - -
    - - - } -
    -
    - 98 - -
    - - -
    -
    -
    - 99 - -
    - - - if err != nil { -
    -
    - 100 - -
    - - - log.Errorf("error executor ProcessBatchV3: %v", err) -
    -
    - 101 - -
    - - - log.Errorf("error executor ProcessBatchV3: %s", err.Error()) -
    -
    - 102 - -
    - - - log.Errorf("error executor ProcessBatchV3 response: %v", batchResponse) -
    -
    - 103 - -
    - - - } else { -
    -
    - 104 - -
    - - - batchResponseToString := processBatchResponseV3ToString(batchResponse, elapsed) -
    -
    - 105 - -
    - - - if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { -
    -
    - 106 - -
    - - - err = executor.ExecutorErr(batchResponse.Error) -
    -
    - 107 - -
    - - - log.Warnf("executor batch response, executor error: %v", err) -
    -
    - 108 - -
    - - - log.Warn(batchResponseToString) -
    -
    - 109 - -
    - - - s.eventLog.LogExecutorError(ctx, batchResponse.Error, batchRequest) -
    -
    - 110 - -
    - - - } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) { -
    -
    - 111 - -
    - - - err = executor.RomErr(batchResponse.ErrorRom) -
    -
    - 112 - -
    - - - log.Warnf("executor batch response, ROM OOC, error: %v", err) -
    -
    - 113 - -
    - - - log.Warn(batchResponseToString) -
    -
    - 114 - -
    - - - } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { -
    -
    - 115 - -
    - - - err = executor.RomErr(batchResponse.ErrorRom) -
    -
    - 116 - -
    - - - log.Warnf("executor batch response, ROM error: %v", err) -
    -
    - 117 - -
    - - - log.Warn(batchResponseToString) -
    -
    - 118 - -
    - - - } else { -
    -
    - 119 - -
    - - - log.Debug(batchResponseToString) -
    -
    - 120 - -
    - - - } -
    -
    - 121 - -
    - - - } -
    -
    - 122 - -
    - - -
    -
    -
    - 123 - -
    - - - return batchResponse, err -
    -
    - 124 - -
    - - - } -
    -
    - 125 - -
    - - -
    -
    -
    - 126 - -
    - - - func processBatchResponseV3ToString(batchResponse *executor.ProcessBatchResponseV3, executionTime time.Duration) string { -
    -
    - 127 - -
    - - - 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), -
    -
    - 129 - -
    - - - batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error) -
    -
    - 130 - -
    - - -
    -
    -
    - 131 - -
    - - - for blockIndex, block := range batchResponse.BlockResponses { -
    -
    - 132 - -
    - - - prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex) -
    -
    - 133 - -
    - - - batchResponseLog += blockResponseV2ToString(block, prefix) -
    -
    - 134 - -
    - - - } -
    -
    - 135 - -
    - - -
    -
    -
    - 136 - -
    - - - return batchResponseLog -
    -
    - 137 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_in.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,101 +0,0 @@
    -
    - 1 - -
    - - - package state -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "fmt" -
    -
    - 6 - -
    - - - "time" -
    -
    - 7 - -
    - - -
    -
    -
    - 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 - -
    - - -
    -
    -
    - 16 - -
    - - - const ( -
    -
    - 17 - -
    - - - // TypeCallData The data is stored on call data directly -
    -
    - 18 - -
    - - - TypeCallData BlobType = 0 -
    -
    - 19 - -
    - - - // TypeBlobTransaction The data is stored on a blob -
    -
    - 20 - -
    - - - TypeBlobTransaction BlobType = 1 -
    -
    - 21 - -
    - - - // TypeForcedBlob The data is a forced Blob -
    -
    - 22 - -
    - - - TypeForcedBlob BlobType = 2 -
    -
    - 23 - -
    - - - ) -
    -
    - 24 - -
    - - -
    -
    -
    - 25 - -
    - - - func (b BlobType) String() string { -
    -
    - 26 - -
    - - - switch b { -
    -
    - 27 - -
    - - - case TypeCallData: -
    -
    - 28 - -
    - - - return "call_data" -
    -
    - 29 - -
    - - - case TypeBlobTransaction: -
    -
    - 30 - -
    - - - return "blob" -
    -
    - 31 - -
    - - - case TypeForcedBlob: -
    -
    - 32 - -
    - - - return "forced" -
    -
    - 33 - -
    - - - default: -
    -
    - 34 - -
    - - - return "Unknown" -
    -
    - 35 - -
    - - - } -
    -
    - 36 - -
    - - - } -
    -
    - 37 - -
    - - -
    -
    -
    - 38 - -
    - - - // BlobBlobTypeParams is the data for a SequenceBlob stored as a Blob -
    -
    - 39 - -
    - - - type BlobBlobTypeParams struct { -
    -
    - 40 - -
    - - - BlobIndex uint64 -
    -
    - 41 - -
    - - - Z []byte -
    -
    - 42 - -
    - - - Y []byte -
    -
    - 43 - -
    - - - Commitment kzg4844.Commitment -
    -
    - 44 - -
    - - - Proof kzg4844.Proof -
    -
    - 45 - -
    - - - } -
    -
    - 46 - -
    - - -
    -
    -
    - 47 - -
    - - - // BlobInner struct -
    -
    - 48 - -
    - - - type BlobInner struct { -
    -
    - 49 - -
    - - - BlobSequenceIndex uint64 // Index of the blobSequence in DB (is a internal number) -
    -
    - 50 - -
    - - - BlobInnerNum uint64 // Incremental value, starts from 1 -
    -
    - 51 - -
    - - - Type BlobType // Type of the blob -
    -
    - 52 - -
    - - - MaxSequenceTimestamp time.Time // it comes from SequenceBlobs call to contract -
    -
    - 53 - -
    - - - ZkGasLimit uint64 // it comes from SequenceBlobs call to contract -
    -
    - 54 - -
    - - - L1InfoLeafIndex uint32 // it comes from SequenceBlobs call to contract -
    -
    - 55 - -
    - - - L1InfoTreeRoot common.Hash // obtained from the L1InfoTree -
    -
    - 56 - -
    - - - BlobDataHash common.Hash // Hash of the data -
    -
    - 57 - -
    - - - BlobBlobTypeParams *BlobBlobTypeParams // Field only valid if BlobType == BlobTransaction -
    -
    - 58 - -
    - - - //HowManyBatches uint64 // Number of batches in the blob -
    -
    - 59 - -
    - - - //FirstBatchNumber uint64 // First batch number of the blob -
    -
    - 60 - -
    - - - //LastBatchNumber uint64 // Last batch number of the blob -
    -
    - 61 - -
    - - - // We don't need blockNumber because is in BlobSequence -
    -
    - 62 - -
    - - - //BlockNumber uint64 -
    -
    - 63 - -
    - - - //PreviousL1InfoTreeIndex uint32 // ?? we need that? -
    -
    - 64 - -
    - - - //PreviousL1InfoTreeRoot common.Hash // ?? we need that? -
    -
    - 65 - -
    - - - } -
    -
    - 66 - -
    - - -
    -
    -
    - 67 - -
    - - - func (b *BlobInner) String() string { -
    -
    - 68 - -
    - - - res := fmt.Sprintf("BlobInner{BlobSequenceIndex:%d, BlobInnerNum:%d, Type:%s, MaxSequenceTimestamp:%s, ZkGasLimit:%d, L1InfoLeafIndex:%d, L1InfoTreeRoot:%s, BlobDataHash:%s", -
    -
    - 69 - -
    - - - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_request.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,81 +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 - -
    - - - // ProcessBlobInnerProcessRequest is the request to process a blob -
    -
    - 9 - -
    - - - // you must use the builder to create the request -
    -
    - 10 - -
    - - - type ProcessBlobInnerProcessRequest struct { -
    -
    - 11 - -
    - - - oldBlobStateRoot common.Hash -
    -
    - 12 - -
    - - - oldBlobAccInputHash common.Hash -
    -
    - 13 - -
    - - - oldNumBlob uint64 -
    -
    - 14 - -
    - - - oldStateRoot common.Hash -
    -
    - 15 - -
    - - - forkId uint64 -
    -
    - 16 - -
    - - - lastL1InfoTreeIndex uint32 -
    -
    - 17 - -
    - - - lastL1InfoTreeRoot common.Hash -
    -
    - 18 - -
    - - - timestampLimit uint64 -
    -
    - 19 - -
    - - - coinbase common.Address -
    -
    - 20 - -
    - - - zkGasLimit uint64 -
    -
    - 21 - -
    - - - blobType BlobType -
    -
    - 22 - -
    - - - } -
    -
    - 23 - -
    - - -
    -
    -
    - 24 - -
    - - - // NewProcessBlobInnerProcessRequest creates a new ProcessBlobInnerProcessRequest -
    -
    - 25 - -
    - - - func NewProcessBlobInnerProcessRequest(forkid uint64, blob *BlobInner, -
    -
    - 26 - -
    - - - previousSequence *BlobSequence, -
    -
    - 27 - -
    - - - currentSequence BlobSequence) (*ProcessBlobInnerProcessRequest, error) { -
    -
    - 28 - -
    - - - res := &ProcessBlobInnerProcessRequest{ -
    -
    - 29 - -
    - - - forkId: forkid, -
    -
    - 30 - -
    - - - blobType: blob.Type, -
    -
    - 31 - -
    - - - oldBlobStateRoot: ZeroHash, // Is always zero! -
    -
    - 32 - -
    - - - } -
    -
    - 33 - -
    - - - if previousSequence == nil { -
    -
    - 34 - -
    - - - res.setAsFirstBlob() -
    -
    - 35 - -
    - - - } else { -
    -
    - 36 - -
    - - - res.setPreviousSequence(*previousSequence) -
    -
    - 37 - -
    - - - } -
    -
    - 38 - -
    - - - res.setBlob(blob) -
    -
    - 39 - -
    - - - res.setCurrentSequence(currentSequence) -
    -
    - 40 - -
    - - - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_response.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,114 +0,0 @@
    -
    - 1 - -
    - - - package state -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "fmt" -
    -
    - 5 - -
    - - -
    -
    -
    - 6 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 7 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" -
    -
    - 8 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 9 - -
    - - - "github.com/ethereum/go-ethereum/crypto" -
    -
    - 10 - -
    - - - ) -
    -
    - 11 - -
    - - -
    -
    -
    - 12 - -
    - - - // ProcessBlobInnerResponse is the response of the process of a blob -
    -
    - 13 - -
    - - - // the fields are private, so you need the function to access the data -
    -
    - 14 - -
    - - - // To get the outcome of the execution you must use GetSuccesfulData() it will return a nil if the execution was not successful -
    -
    - 15 - -
    - - - // This is for forcing by interface don't access to results fields is it have an error -
    -
    - 16 - -
    - - - type ProcessBlobInnerResponse struct { -
    -
    - 17 - -
    - - - succesfulData ProcessBlobInnerResponseSuccesful // Here is the outcome of the execution -
    -
    - 18 - -
    - - - isInvalid bool // Is a variable of the ROM -
    -
    - 19 - -
    - - - generalError error -
    -
    - 20 - -
    - - - romBlobError error -
    -
    - 21 - -
    - - - executorVersion string // Version of the executor e.g. "v7.0.0" -
    -
    - 22 - -
    - - - errorDebugLog string // This is debug.ErrorLog that is a debug string with context data of error -
    -
    - 23 - -
    - - - } -
    -
    - 24 - -
    - - -
    -
    -
    - 25 - -
    - - - // ProcessBlobInnerResponseSuccesful is the data after a successful call to ProcessBlobInner -
    -
    - 26 - -
    - - - type ProcessBlobInnerResponseSuccesful struct { -
    -
    - 27 - -
    - - - newBlobStateRoot common.Hash -
    -
    - 28 - -
    - - - newBlobAccInputHash common.Hash -
    -
    - 29 - -
    - - - newNumBlob uint64 -
    -
    - 30 - -
    - - - finalAccBatchHashData common.Hash -
    -
    - 31 - -
    - - - batchData [][]byte -
    -
    - 32 - -
    - - - } -
    -
    - 33 - -
    - - -
    -
    -
    - 34 - -
    - - - func (p *ProcessBlobInnerResponseSuccesful) String() string { -
    -
    - 35 - -
    - - - res := fmt.Sprintf("newBlobStateRoot: %s newBlobAccInputHash:%s newNumBlob:%d\n", p.newBlobStateRoot.String(), p.newBlobAccInputHash.String(), p.newNumBlob) -
    -
    - 36 - -
    - - - res += fmt.Sprintf("finalAccBatchHashData: %s\n", p.finalAccBatchHashData.String()) -
    -
    - 37 - -
    - - - res += fmt.Sprintf("HowManyBatches: %d\n", p.HowManyBatches()) -
    -
    - 38 - -
    - - - for i := 0; i < p.HowManyBatches(); i++ { -
    -
    - 39 - -
    - - - res += fmt.Sprintf(" Batch %d: Hash:%s\n", i, p.GetBatchHash(i).String()) -
    -
    - 40 - -
    - - - } -
    -
    - 41 - -
    - - - return res -
    -
    - 42 - -
    - - - } -
    -
    - 43 - -
    - - -
    -
    -
    - 44 - -
    - - - func (p *ProcessBlobInnerResponse) String() string { -
    -
    - 45 - -
    - - - res := fmt.Sprintf("isInvalid: %t\n", p.isInvalid) -
    -
    - 46 - -
    - - - if p.generalError != nil { -
    -
    - 47 - -
    - - - res += fmt.Sprintf("generalError: %s\n", p.generalError.Error()) -
    -
    - 48 - -
    - - - } -
    -
    - 49 - -
    - - - if p.romBlobError != nil { -
    -
    - 50 - -
    - - - res += fmt.Sprintf("romBlobError: %s\n", p.romBlobError.Error()) -
    -
    - 51 - -
    - - - } -
    -
    - 52 - -
    - - - if p.IsSuccessfulExecution() { -
    -
    - 53 - -
    - - - res += p.succesfulData.String() -
    -
    - 54 - -
    - - - } -
    -
    - 55 - -
    - - - return res -
    -
    - 56 - -
    - - - } -
    -
    - 57 - -
    - - -
    -
    -
    - 58 - -
    - - - // GetUnifiedError returns the combinations of errors of the execution -
    -
    - 59 - -
    - - - func (p *ProcessBlobInnerResponse) GetUnifiedError() error { -
    -
    - 60 - -
    - - - if p.IsSuccessfulExecution() { -
    -
    - 61 - -
    - - - return nil -
    -
    - 62 - -
    - - - } -
    -
    - 63 - -
    - - - return fmt.Errorf("ProcessBlobInnerV3 fails:version:%s isInvalid: %t general:%w romBlob:%w errorLog:%s", -
    -
    - 64 - -
    - - - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_sequences.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,69 +0,0 @@
    -
    - 1 - -
    - - - package state -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "errors" -
    -
    - 6 - -
    - - - "fmt" -
    -
    - 7 - -
    - - - "time" -
    -
    - 8 - -
    - - -
    -
    -
    - 9 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 10 - -
    - - - "github.com/jackc/pgx/v4" -
    -
    - 11 - -
    - - - ) -
    -
    - 12 - -
    - - -
    -
    -
    - 13 - -
    - - - var ( -
    -
    - 14 - -
    - - - // ErrBlobSequenceIndex is returned when the blob sequence index is not correct -
    -
    - 15 - -
    - - - ErrBlobSequenceIndex = errors.New("blob sequence index is not correct") -
    -
    - 16 - -
    - - - // ErrBlobSequenceTime is returned when the blob sequence time is not correct -
    -
    - 17 - -
    - - - ErrBlobSequenceTime = errors.New("blob sequence time is not correct") -
    -
    - 18 - -
    - - - ) -
    -
    - 19 - -
    - - -
    -
    -
    - 20 - -
    - - - // BlobSequence represents a blob sequence. -
    -
    - 21 - -
    - - - type BlobSequence struct { -
    -
    - 22 - -
    - - - BlobSequenceIndex uint64 -
    -
    - 23 - -
    - - - L2Coinbase common.Address -
    -
    - 24 - -
    - - - FinalAccInputHash common.Hash -
    -
    - 25 - -
    - - - FirstBlobSequenced uint64 // Is calculated from previous blob sequence -
    -
    - 26 - -
    - - - LastBlobSequenced uint64 // That comes from the event -
    -
    - 27 - -
    - - - CreateAt time.Time // time of the L1block -
    -
    - 28 - -
    - - - ReceivedAt time.Time // time when the blob sequence is received (typically Now()) -
    -
    - 29 - -
    - - - BlockNumber uint64 // L1BlockNumber where appears this event -
    -
    - 30 - -
    - - - } -
    -
    - 31 - -
    - - -
    -
    -
    - 32 - -
    - - - // AddBlobSequence adds a new blob sequence to the state. -
    -
    - 33 - -
    - - - // it override pgstorage.AddBlobSequence to add sanity checks -
    -
    - 34 - -
    - - - func (s *State) AddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error { -
    -
    - 35 - -
    - - - err := s.sanityCheckAddBlobSequence(ctx, blobSequence, dbTx) -
    -
    - 36 - -
    - - - if err != nil { -
    -
    - 37 - -
    - - - return err -
    -
    - 38 - -
    - - - } -
    -
    - 39 - -
    - - - return s.storage.AddBlobSequence(ctx, blobSequence, dbTx) -
    -
    - 40 - -
    - - - } -
    -
    - 41 - -
    - - -
    -
    -
    - 42 - -
    - - - func (s *State) sanityCheckAddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error { -
    -
    - 43 - -
    - - - previousBlobSequence, err := s.GetLastBlobSequence(ctx, dbTx) -
    -
    - 44 - -
    - - - if err != nil { -
    -
    - 45 - -
    - - - return err -
    -
    - 46 - -
    - - - } -
    -
    - 47 - -
    - - - if previousBlobSequence == nil { -
    -
    - 48 - -
    - - - // Is the first one -
    -
    - 49 - -
    - - - if blobSequence.BlobSequenceIndex != 1 { -
    -
    - 50 - -
    - - - return fmt.Errorf("TThe firstBlobSequence index must be 1, not %d. Err: %w", blobSequence.BlobSequenceIndex, ErrBlobSequenceIndex) -
    -
    - 51 - -
    - - - } -
    -
    - 52 - -
    - - - return nil -
    -
    - 53 - -
    - - - } -
    -
    - 54 - -
    - - - // The index must be the previous index + 1 -
    -
    - 55 - -
    - - - if previousBlobSequence.BlobSequenceIndex+1 != blobSequence.BlobSequenceIndex { -
    -
    - 56 - -
    - - - return fmt.Errorf("last_index_on_db:%d try_to_insert:%d. Err: %w", -
    -
    - 57 - -
    - - - previousBlobSequence.BlobSequenceIndex, -
    -
    - 58 - -
    - - - blobSequence.BlobSequenceIndex, -
    -
    - 59 - -
    - - - ErrBlobSequenceIndex) -
    -
    - 60 - -
    - - - } -
    -
    - 61 - -
    - - - // The new blob must be newer than the previous one -
    -
    - 62 - -
    - - - if previousBlobSequence.CreateAt.After(blobSequence.CreateAt) { -
    -
    - 63 - -
    - - - return fmt.Errorf("last_create_at_on_db:%d try_to_insert:%d. Err: %w", -
    -
    - 64 - -
    - - - previousBlobSequence.CreateAt.Unix(), -
    -
    - 65 - -
    - - - blobSequence.CreateAt.Unix(), -
    -
    - 66 - -
    - - - ErrBlobSequenceTime) -
    -
    - 67 - -
    - - - } -
    -
    - 68 - -
    - - - return nil -
    -
    - 69 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/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), -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 80 - -
    -   - Coinbase common.Address // 20 bytes -
    -
    - 81 - -
    -   - ForkID uint16 // 2 bytes -
    -
    - 82 - -
    -   - ChainID uint32 // 4 bytes -
    -
    - 83 - -
    - + -
    -
    -
    - 84 - -
    -   - } -
    -
    - 85 - -
    -   -
    -
    -
    - 86 - -
    -   - // Encode returns the encoded DSL2BlockStart as a byte slice -
    -
    -
     
    -
    - 111 - -
    -   - b.Coinbase = common.BytesToAddress(data[96:116]) -
    -
    - 112 - -
    -   - b.ForkID = binary.BigEndian.Uint16(data[116:118]) -
    -
    - 113 - -
    -   - b.ChainID = binary.BigEndian.Uint32(data[118:122]) -
    -
    - 114 - -
    - + -
    -
    -
    - 115 - -
    -   - return b -
    -
    - 116 - -
    -   - } -
    -
    - 117 - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,44 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - package state -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "errors" -
    -
    - 5 - -
    - + - "math/big" -
    -
    - 6 - -
    - + - ) -
    -
    - 7 - -
    - + -
    -
    -
    - 8 - -
    - + - const ( -
    -
    - 9 - -
    - + - // MaxEffectivePercentage is the maximum value that can be used as effective percentage -
    -
    - 10 - -
    - + - MaxEffectivePercentage = uint8(255) -
    -
    - 11 - -
    - + - ) -
    -
    - 12 - -
    - + -
    -
    -
    - 13 - -
    - + - var ( -
    -
    - 14 - -
    - + - // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero -
    -
    - 15 - -
    - + - ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") -
    -
    - 16 - -
    - + -
    -
    -
    - 17 - -
    - + - // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero -
    -
    - 18 - -
    - + - ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") -
    -
    - 19 - -
    - + - ) -
    -
    - 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 { -
    -
    - 28 - -
    - + - return 0, ErrEffectiveGasPriceEmpty -
    -
    - 29 - -
    - + - } -
    -
    - 30 - -
    - + -
    -
    -
    - 31 - -
    - + - if gasPrice.Cmp(effectiveGasPrice) <= 0 { -
    -
    - 32 - -
    - + - return MaxEffectivePercentage, nil -
    -
    - 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 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/encoding_batch_v2.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -2,13 +2,7 @@
    -
    - 2 - -
    -   - This file provide functions to work with ETROG batches: -
    -
    - 3 - -
    -   - - EncodeBatchV2 (equivalent to EncodeTransactions) -
    -
    - 4 - -
    -   - - DecodeBatchV2 (equivalent to DecodeTxs) -
    -
    - 5 - -
    - - - - DecodeForcedBatchV2 -
    -
    - 6 - -
    - - -
    -
    -
    - 7 - -
    - - - Also provide a builder class to create batches (BatchV2Encoder): -
    -
    - 8 - -
    - - - This method doesnt check anything, so is more flexible but you need to know what you are doing -
    -
    - 9 - -
    - - - - `builder := NewBatchV2Encoder()` : Create a new `BatchV2Encoder`` -
    -
    - 10 - -
    - - - - You can call to `AddBlockHeader` or `AddTransaction` to add a block header or a transaction as you wish -
    -
    - 11 - -
    - - - - You can call to `GetResult` to get the batch data -
    -
    - 12 - -
    -   -
    -
    -
    - 13 - -
    -   -
    -
    -
    - 14 - -
    -   - // batch data format: -
    -
    -
    @@ -33,25 +27,11 @@
    -
    - 33 - -
    -   - // 0x00 | 32 | V -
    -
    - 34 - -
    -   - // 0x00 | 1 | efficiencyPercentage -
    -
    - 35 - -
    -   - // Repeat Transaction -
    -
    - 36 - -
    - - - // -
    -
    - 37 - -
    - - - // Usage: -
    -
    - 38 - -
    - - - // There are 2 ways of use this module, direct calls or a builder class: -
    -
    - 39 - -
    - - - // 1) Direct calls: -
    -
    - 40 - -
    - - - // - EncodeBatchV2: Encode a batch of transactions -
    -
    - 41 - -
    - - - // - DecodeBatchV2: Decode a batch of transactions -
    -
    - 42 - -
    - - - // -
    -
    - 43 - -
    - - - // 2) Builder class: -
    -
    - 44 - -
    - - - // This method doesnt check anything, so is more flexible but you need to know what you are doing -
    -
    - 45 - -
    - - - // - builder := NewBatchV2Encoder(): Create a new BatchV2Encoder -
    -
    - 46 - -
    - - - // - You can call to `AddBlockHeader` or `AddTransaction` to add a block header or a transaction as you wish -
    -
    - 47 - -
    - - - // - You can call to `GetResult` to get the batch data -
    -
    - 48 - -
    - - -
    -
    -
    - 49 - -
    -   - */ -
    -
    - 50 - -
    -   -
    -
    -
    - 51 - -
    -   - package state -
    -
    - 52 - -
    -   -
    -
    -
    - 53 - -
    -   - import ( -
    -
    - 54 - -
    - - - "encoding/binary" -
    -
    - 55 - -
    -   - "errors" -
    -
    - 56 - -
    -   - "fmt" -
    -
    - 57 - -
    -   - "strconv" -
    -
    -
    @@ -62,16 +42,11 @@
    -
    - 62 - -
    -   - "github.com/ethereum/go-ethereum/rlp" -
    -
    - 63 - -
    -   - ) -
    -
    - 64 - -
    -   -
    -
    -
    - 65 - -
    - - - // ChangeL2BlockHeader is the header of a L2 block. -
    -
    - 66 - -
    - - - type ChangeL2BlockHeader struct { -
    -
    - 67 - -
    - - - DeltaTimestamp uint32 -
    -
    - 68 - -
    - - - IndexL1InfoTree uint32 -
    -
    - 69 - -
    - - - } -
    -
    - 70 - -
    - - -
    -
    -
    - 71 - -
    -   - // L2BlockRaw is the raw representation of a L2 block. -
    -
    - 72 - -
    -   - type L2BlockRaw struct { -
    -
    - 73 - -
    - - - ChangeL2BlockHeader -
    -
    - 74 - -
    - - - Transactions []L2TxRaw -
    -
    - - -
    -   -
    -
    -
    - 75 - -
    -   - } -
    -
    - 76 - -
    -   -
    -
    -
    - 77 - -
    -   - // BatchRawV2 is the representation of a batch of transactions. -
    -
    -
    @@ -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 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 @@
    -
    - 274 - -
    -   - func decodeBlockHeader(txsData []byte, pos int) (int, *L2BlockRaw, error) { -
    -
    - 275 - -
    -   - var err error -
    -
    - 276 - -
    -   - currentBlock := &L2BlockRaw{} -
    -
    - 277 - -
    - - - pos, currentBlock.DeltaTimestamp, err = decodeUint32(txsData, pos) -
    -
    - 278 - -
    -   - if err != nil { -
    -
    - 279 - -
    -   - return 0, nil, fmt.Errorf("can't get deltaTimestamp: %w", err) -
    -
    - 280 - -
    -   - } -
    -
    - 281 - -
    - - - pos, currentBlock.IndexL1InfoTree, err = decodeUint32(txsData, pos) -
    -
    - 282 - -
    -   - if err != nil { -
    -
    - 283 - -
    -   - return 0, nil, fmt.Errorf("can't get leafIndex: %w", err) -
    -
    - 284 - -
    -   - } -
    -
    -
    @@ -286,8 +227,7 @@
    -
    - 286 - -
    -   - return pos, currentBlock, nil -
    -
    - 287 - -
    -   - } -
    -
    - 288 - -
    -   -
    -
    -
    - 289 - -
    - - - // DecodeTxRLP decodes a transaction from a byte slice. -
    -
    - 290 - -
    - - - func DecodeTxRLP(txsData []byte, offset int) (int, *L2TxRaw, error) { -
    -
    - 291 - -
    -   - var err error -
    -
    - 292 - -
    -   - length, err := decodeRLPListLengthFromOffset(txsData, offset) -
    -
    - 293 - -
    -   - if err != nil { -
    -
    -
    @@ -325,6 +265,13 @@
    -
    - 325 - -
    -   - return int(endPos), l2Tx, err -
    -
    - 326 - -
    -   - } -
    -
    - 327 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 328 - -
    -   - // It returns the length of data from the param offset -
    -
    - 329 - -
    -   - // ex: -
    -
    - 330 - -
    -   - // 0xc0 -> empty data -> 1 byte because it include the 0xc0 -
    -
    -
    @@ -355,16 +302,3 @@
    -
    - 355 - -
    -   - } -
    -
    - 356 - -
    -   - return length + headerByteLength, nil -
    -
    - 357 - -
    -   - } -
    -
    - 358 - -
    - - -
    -
    -
    - 359 - -
    - - - func encodeUint32(value uint32) []byte { -
    -
    - 360 - -
    - - - data := make([]byte, sizeUInt32) -
    -
    - 361 - -
    - - - binary.BigEndian.PutUint32(data, value) -
    -
    - 362 - -
    - - - return data -
    -
    - 363 - -
    - - - } -
    -
    - 364 - -
    - - -
    -
    -
    - 365 - -
    - - - func decodeUint32(txsData []byte, pos int) (int, uint32, error) { -
    -
    - 366 - -
    - - - if len(txsData)-pos < sizeUInt32 { -
    -
    - 367 - -
    - - - return 0, 0, fmt.Errorf("can't get u32 because not enough data: %w", ErrInvalidBatchV2) -
    -
    - 368 - -
    - - - } -
    -
    - 369 - -
    - - - return pos + sizeUInt32, binary.BigEndian.Uint32(txsData[pos : pos+sizeUInt32]), nil -
    -
    - 370 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 2 - -
    -   - This file provide functions to work with ETROG batches: -
    -
    - 3 - -
    -   - - EncodeBatchV2 (equivalent to EncodeTransactions) -
    -
    - 4 - -
    -   - - DecodeBatchV2 (equivalent to DecodeTxs) -
    -
    - 5 - -
    - + - - DecodeForcedBatchV2) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 6 - -
    -   -
    -
    -
    - 7 - -
    -   -
    -
    -
    - 8 - -
    -   - // batch data format: -
    -
    -
     
    -
    - 27 - -
    -   - // 0x00 | 32 | V -
    -
    - 28 - -
    -   - // 0x00 | 1 | efficiencyPercentage -
    -
    - 29 - -
    -   - // Repeat Transaction -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 30 - -
    -   - */ -
    -
    - 31 - -
    -   -
    -
    -
    - 32 - -
    -   - package state -
    -
    - 33 - -
    -   -
    -
    -
    - 34 - -
    -   - import ( -
    -
    - - -
    -   -
    -
    -
    - 35 - -
    -   - "errors" -
    -
    - 36 - -
    -   - "fmt" -
    -
    - 37 - -
    -   - "strconv" -
    -
    -
     
    -
    - 42 - -
    -   - "github.com/ethereum/go-ethereum/rlp" -
    -
    - 43 - -
    -   - ) -
    -
    - 44 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 45 - -
    -   - // L2BlockRaw is the raw representation of a L2 block. -
    -
    - 46 - -
    -   - type L2BlockRaw struct { -
    -
    - 47 - -
    - + - DeltaTimestamp uint32 -
    -
    - 48 - -
    - + - IndexL1InfoTree uint32 -
    -
    - 49 - -
    - + - Transactions []L2TxRaw -
    -
    - 50 - -
    -   - } -
    -
    - 51 - -
    -   -
    -
    -
    - 52 - -
    -   - // BatchRawV2 is the representation of a batch of transactions. -
    -
    -
     
    -
    - 61 - -
    -   -
    -
    -
    - 62 - -
    -   - // L2TxRaw is the raw representation of a L2 transaction inside a L2 block. -
    -
    - 63 - -
    -   - type L2TxRaw struct { -
    -
    - 64 - -
    - + - Tx types.Transaction -
    -
    - 65 - -
    - + - EfficiencyPercentage uint8 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 66 - -
    -   - } -
    -
    - 67 - -
    -   -
    -
    -
    - 68 - -
    -   - const ( -
    -
    - 69 - -
    -   - changeL2Block = uint8(0x0b) -
    -
    - - -
    -   -
    -
    -
    - 70 - -
    -   - ) -
    -
    - 71 - -
    -   -
    -
    -
    - 72 - -
    -   - var ( -
    -
    -
     
    -
    - 92 - -
    -   -
    -
    -
    - 93 - -
    -   - // EncodeBatchV2 encodes a batch of transactions into a byte slice. -
    -
    - 94 - -
    -   - func EncodeBatchV2(batch *BatchRawV2) ([]byte, error) { -
    -
    - 95 - -
    - + - var err error -
    -
    - 96 - -
    - + - var batchData []byte -
    -
    - 97 - -
    -   - if batch == nil { -
    -
    - 98 - -
    -   - return nil, fmt.Errorf("batch is nil: %w", ErrInvalidBatchV2) -
    -
    - 99 - -
    -   - } -
    -
    - 100 - -
    - + - blocks := batch.Blocks -
    -
    - 101 - -
    - + - if len(blocks) == 0 { -
    -
    - 102 - -
    -   - return nil, fmt.Errorf("a batch need minimum a L2Block: %w", ErrInvalidBatchV2) -
    -
    - 103 - -
    -   - } -
    -
    - 104 - -
    - + - for _, block := range blocks { -
    -
    - 105 - -
    - + - batchData, err = EncodeBlockHeaderV2(batchData, block) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 106 - -
    -   - if err != nil { -
    -
    - 107 - -
    - + - return nil, fmt.Errorf("can't encode block header: %w", err) -
    -
    - 108 - -
    -   - } -
    -
    - 109 - -
    - + - for _, tx := range block.Transactions { -
    -
    - 110 - -
    - + - batchData, err = encodeTxRLP(batchData, tx) -
    -
    - 111 - -
    - + - if err != nil { -
    -
    - 112 - -
    - + - return nil, fmt.Errorf("can't encode tx: %w", err) -
    -
    - 113 - -
    - + - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -17,10 +17,8 @@
    -
    - 17 - -
    -   - FORKID_ETROG = 7 -
    -
    - 18 - -
    -   - // FORKID_ELDERBERRY is the fork id 8 -
    -
    - 19 - -
    -   - FORKID_ELDERBERRY = 8 -
    -
    - 20 - -
    - - - // FORKID_ELDERBERRY_2 is the fork id 9 -
    -
    - 21 - -
    - - - FORKID_ELDERBERRY_2 = 9 -
    -
    - 22 - -
    - - - // FORKID_FEIJOA is the fork id 10 -
    -
    - 23 - -
    - - - FORKID_FEIJOA = 10 -
    -
    - 24 - -
    -   - ) -
    -
    - 25 - -
    -   -
    -
    -
    - 26 - -
    -   - // ForkIDInterval is a fork id interval -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 17 - -
    -   - FORKID_ETROG = 7 -
    -
    - 18 - -
    -   - // FORKID_ELDERBERRY is the fork id 8 -
    -
    - 19 - -
    -   - FORKID_ELDERBERRY = 8 -
    -
    - 20 - -
    - + - // FORKID_9 is the fork id 9 -
    -
    - 21 - -
    - + - FORKID_9 = 9 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 22 - -
    -   - ) -
    -
    - 23 - -
    -   -
    -
    -
    - 24 - -
    -   - // ForkIDInterval is a fork id interval -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -19,8 +19,10 @@
    -
    - 19 - -
    -   -
    -
    -
    - 20 - -
    -   - // Genesis contains the information to populate state on creation -
    -
    - 21 - -
    -   - type Genesis struct { -
    -
    - 22 - -
    - - - // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 -
    -
    - 23 - -
    - - - BlockNumber uint64 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 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 - -
    -   - 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 - -
    -   - // Root hash of the genesis block -
    -
    - 27 - -
    -   - 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 @@
    -
    - 18 - -
    -   - double = 2 -
    -
    - 19 - -
    -   - ether155V = 27 -
    -
    - 20 - -
    -   - etherPre155V = 35 -
    -
    - 21 - -
    - - - // MaxEffectivePercentage is the maximum value that can be used as effective percentage -
    -
    - 22 - -
    - - - MaxEffectivePercentage = uint8(255) -
    -
    - 23 - -
    -   - // Decoding constants -
    -
    - 24 - -
    -   - headerByteLength uint64 = 1 -
    -
    - 25 - -
    -   - sLength uint64 = 32 -
    -
    -
    @@ -39,7 +37,7 @@
    -
    - 39 - -
    -   - var batchL2Data []byte -
    -
    - 40 - -
    -   -
    -
    -
    - 41 - -
    -   - for i, tx := range txs { -
    -
    - 42 - -
    - - - txData, err := prepareRLPTxData(tx) -
    -
    - 43 - -
    -   - if err != nil { -
    -
    - 44 - -
    -   - return nil, err -
    -
    - 45 - -
    -   - } -
    -
    -
    @@ -57,7 +55,7 @@
    -
    - 57 - -
    -   - return batchL2Data, nil -
    -
    - 58 - -
    -   - } -
    -
    - 59 - -
    -   -
    -
    -
    - 60 - -
    - - - func prepareRLPTxData(tx types.Transaction) ([]byte, error) { -
    -
    - 61 - -
    -   - v, r, s := tx.RawSignatureValues() -
    -
    - 62 - -
    -   - sign := 1 - (v.Uint64() & 1) -
    -
    - 63 - -
    -   -
    -
    -
    -
    @@ -99,7 +97,7 @@
    -
    - 99 - -
    -   - var batchL2Data []byte -
    -
    - 100 - -
    -   -
    -
    -
    - 101 - -
    -   - for _, tx := range txs { -
    -
    - 102 - -
    - - - txData, err := prepareRLPTxData(tx) -
    -
    - 103 - -
    -   - if err != nil { -
    -
    - 104 - -
    -   - return nil, err -
    -
    - 105 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 18 - -
    -   - double = 2 -
    -
    - 19 - -
    -   - ether155V = 27 -
    -
    - 20 - -
    -   - etherPre155V = 35 -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 21 - -
    -   - // Decoding constants -
    -
    - 22 - -
    -   - headerByteLength uint64 = 1 -
    -
    - 23 - -
    -   - sLength uint64 = 32 -
    -
    -
     
    -
    - 37 - -
    -   - var batchL2Data []byte -
    -
    - 38 - -
    -   -
    -
    -
    - 39 - -
    -   - for i, tx := range txs { -
    -
    - 40 - -
    - + - txData, err := prepareRPLTxData(tx) -
    -
    - 41 - -
    -   - if err != nil { -
    -
    - 42 - -
    -   - return nil, err -
    -
    - 43 - -
    -   - } -
    -
    -
     
    -
    - 55 - -
    -   - return batchL2Data, nil -
    -
    - 56 - -
    -   - } -
    -
    - 57 - -
    -   -
    -
    -
    - 58 - -
    - + - func prepareRPLTxData(tx types.Transaction) ([]byte, error) { -
    -
    - 59 - -
    -   - v, r, s := tx.RawSignatureValues() -
    -
    - 60 - -
    -   - sign := 1 - (v.Uint64() & 1) -
    -
    - 61 - -
    -   -
    -
    -
    -
     
    -
    - 97 - -
    -   - var batchL2Data []byte -
    -
    - 98 - -
    -   -
    -
    -
    - 99 - -
    -   - for _, tx := range txs { -
    -
    - 100 - -
    - + - txData, err := prepareRPLTxData(tx) -
    -
    - 101 - -
    -   - if err != nil { -
    -
    - 102 - -
    -   - return nil, err -
    -
    - 103 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -103,14 +103,14 @@
    -
    - 103 - -
    -   - GetSequences(ctx context.Context, lastVerifiedBatchNumber uint64, dbTx pgx.Tx) ([]Sequence, error) -
    -
    - 104 - -
    -   - GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*Batch, error) -
    -
    - 105 - -
    -   - CheckProofContainsCompleteSequences(ctx context.Context, proof *Proof, dbTx pgx.Tx) (bool, error) -
    -
    - 106 - -
    - - - GetProofReadyForFinal(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*Proof, error) -
    -
    - 107 - -
    - - - GetBatchProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*Proof, *Proof, error) -
    -
    - 108 - -
    - - - AddBatchProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error -
    -
    - 109 - -
    - - - UpdateBatchProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error -
    -
    - 110 - -
    - - - DeleteBatchProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error -
    -
    - 111 - -
    - - - CleanupBatchProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error -
    -
    - 112 - -
    - - - CleanupLockedBatchProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) -
    -
    - 113 - -
    - - - DeleteUngeneratedBatchProofs(ctx context.Context, dbTx pgx.Tx) error -
    -
    - 114 - -
    -   - GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*Batch, error) -
    -
    - 115 - -
    -   - GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) -
    -
    - 116 - -
    -   - UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error -
    -
    -
    @@ -145,6 +145,7 @@
    -
    - 145 - -
    -   - GetForkIDByBlockNumber(blockNumber uint64) uint64 -
    -
    - 146 - -
    -   - GetForkIDByBatchNumber(batchNumber uint64) uint64 -
    -
    - 147 - -
    -   - GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) -
    -
    - - -
    -   -
    -
    -
    - 148 - -
    -   - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) -
    -
    - 149 - -
    -   - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) -
    -
    - 150 - -
    -   - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) -
    -
    -
    @@ -152,6 +153,9 @@
    -
    - 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 - -
    -   - GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) -
    -
    - 156 - -
    -   - GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error) -
    -
    - 157 - -
    -   - GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) -
    -
    -
    @@ -162,20 +166,5 @@
    -
    - 162 - -
    -   - GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error) -
    -
    - 163 - -
    -   - GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error) -
    -
    - 164 - -
    -   - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) -
    -
    - 165 - -
    - - - AddL1InfoTreeRecursiveRootToExitRoot(ctx context.Context, exitRoot *L1InfoTreeRecursiveExitRootStorageEntry, dbTx pgx.Tx) error -
    -
    - 166 - -
    - - - GetAllL1InfoTreeRecursiveRootEntries(ctx context.Context, dbTx pgx.Tx) ([]L1InfoTreeRecursiveExitRootStorageEntry, error) -
    -
    - 167 - -
    - - - GetLatestL1InfoTreeRecursiveRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (L1InfoTreeRecursiveExitRootStorageEntry, error) -
    -
    - 168 - -
    - - - GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) -
    -
    - 169 - -
    - - -
    -
    -
    - 170 - -
    - - - storeblobsequences -
    -
    - 171 - -
    - - - storeblobinner -
    -
    - 172 - -
    - - - } -
    -
    - 173 - -
    - - -
    -
    -
    - 174 - -
    - - - type storeblobsequences interface { -
    -
    - 175 - -
    - - - AddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error -
    -
    - 176 - -
    - - - GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*BlobSequence, error) -
    -
    - 177 - -
    - - - } -
    -
    - 178 - -
    - - -
    -
    -
    - 179 - -
    - - - type storeblobinner interface { -
    -
    - 180 - -
    - - - AddBlobInner(ctx context.Context, blobInner *BlobInner, dbTx pgx.Tx) error -
    -
    - 181 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 103 - -
    -   - GetSequences(ctx context.Context, lastVerifiedBatchNumber uint64, dbTx pgx.Tx) ([]Sequence, error) -
    -
    - 104 - -
    -   - GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*Batch, error) -
    -
    - 105 - -
    -   - CheckProofContainsCompleteSequences(ctx context.Context, proof *Proof, dbTx pgx.Tx) (bool, error) -
    -
    - 106 - -
    - + - GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*Proof, error) -
    -
    - 107 - -
    - + - GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*Proof, *Proof, error) -
    -
    - 108 - -
    - + - AddGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error -
    -
    - 109 - -
    - + - UpdateGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error -
    -
    - 110 - -
    - + - DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error -
    -
    - 111 - -
    - + - CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error -
    -
    - 112 - -
    - + - CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) -
    -
    - 113 - -
    - + - DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error -
    -
    - 114 - -
    -   - GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*Batch, error) -
    -
    - 115 - -
    -   - GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) -
    -
    - 116 - -
    -   - UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error -
    -
    -
     
    -
    - 145 - -
    -   - GetForkIDByBlockNumber(blockNumber uint64) uint64 -
    -
    - 146 - -
    -   - GetForkIDByBatchNumber(batchNumber uint64) uint64 -
    -
    - 147 - -
    -   - GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) -
    -
    - 148 - -
    - + - BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte -
    -
    - 149 - -
    -   - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) -
    -
    - 150 - -
    -   - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) -
    -
    - 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) -
    -
    - 156 - -
    - + - GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) -
    -
    - 157 - -
    - + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) -
    -
    - 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) -
    -
    - 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 - -
    - + - UpdateBatchTimestamp(ctx context.Context, batchNumber uint64, timestamp time.Time, dbTx pgx.Tx) error -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 170 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/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 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/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) -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -241819,70 +12672,15 @@

    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" -
    -
    -
    @@ -797,7 +798,7 @@
    -
    - 797 - -
    -   - b.batch_num > $1 AND b.batch_num = v.batch_num AND -
    -
    - 798 - -
    -   - v.block_num <= $2 AND -
    -
    - 799 - -
    -   - NOT EXISTS ( -
    -
    - 800 - -
    - - - SELECT p.batch_num FROM state.batch_proof p -
    -
    - 801 - -
    -   - WHERE v.batch_num >= p.batch_num AND v.batch_num <= p.batch_num_final -
    -
    - 802 - -
    -   - ) -
    -
    - 803 - -
    -   - ORDER BY b.batch_num ASC LIMIT 1 -
    -
    -
    @@ -974,6 +975,25 @@
    -
    - 974 - -
    -   - return blockNum, nil -
    -
    - 975 - -
    -   - } -
    -
    - 976 - -
    -   -
    +
    +
    +   +
    - 977 - -
    -   - // GetRawBatchTimestamps returns the timestamp of the batch with the given number. -
    -
    - 978 - -
    -   - // it returns batch_num.tstamp and virtual_batch.batch_timestamp -
    -
    - 979 - -
    -   - func (p *PostgresStorage) GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) { -
    -
    -
    @@ -1072,3 +1092,11 @@
    -
    - 1072 + + -
    +
    +
     
    - 1073 - -
    -   - return batches, nil -
    -
    - 1074 - -
    -   - } -
    -
    @@ -241963,588 +12761,56 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 2 + + -
    +
    +
     
    - 3 - -
    -   - import ( -
    -
    - 4 - -
    -   - "context" -
    -
    - 5 - -
    - + - "encoding/binary" -
    -
    - 6 - -
    -   - "encoding/json" -
    -
    - 7 - -
    -   - "errors" -
    -
    - 8 - -
    -   - "fmt" -
    -
    -
     
    -
    - 798 - -
    -   - b.batch_num > $1 AND b.batch_num = v.batch_num AND -
    -
    - 799 - -
    -   - v.block_num <= $2 AND -
    -
    - 800 - -
    -   - NOT EXISTS ( -
    -
    - 801 - -
    - + - SELECT p.batch_num FROM state.proof p -
    -
    - 802 - -
    -   - WHERE v.batch_num >= p.batch_num AND v.batch_num <= p.batch_num_final -
    -
    - 803 - -
    -   - ) -
    -
    - 804 - -
    -   - ORDER BY b.batch_num ASC LIMIT 1 -
    -
    -
     
    -
    - 975 - -
    -   - return blockNum, nil -
    -
    - 976 - -
    -   - } -
    -
    - 977 + + -
    +
    +
     
    - 978 - -
    - + - // BuildChangeL2Block returns a changeL2Block tx to use in the BatchL2Data -
    -
    - 979 - -
    - + - func (p *PostgresStorage) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte { -
    -
    - 980 - -
    - + - changeL2BlockMark := []byte{0x0B} -
    -
    - 981 - -
    - + - changeL2Block := []byte{} -
    -
    - 982 - -
    - + -
    -
    -
    - 983 - -
    - + - // changeL2Block transaction mark -
    -
    - 984 - -
    - + - changeL2Block = append(changeL2Block, changeL2BlockMark...) -
    -
    - 985 - -
    - + - // changeL2Block deltaTimeStamp -
    -
    - 986 - -
    - + - deltaTimestampBytes := make([]byte, 4) //nolint:gomnd -
    -
    - 987 - -
    - + - binary.BigEndian.PutUint32(deltaTimestampBytes, deltaTimestamp) -
    -
    - 988 - -
    - + - changeL2Block = append(changeL2Block, deltaTimestampBytes...) -
    -
    - 989 - -
    - + - // changeL2Block l1InfoTreeIndexBytes -
    -
    - 990 - -
    - + - l1InfoTreeIndexBytes := make([]byte, 4) //nolint:gomnd -
    -
    - 991 - -
    - + - binary.BigEndian.PutUint32(l1InfoTreeIndexBytes, l1InfoTreeIndex) -
    -
    - 992 - -
    - + - changeL2Block = append(changeL2Block, l1InfoTreeIndexBytes...) -
    -
    - 993 - -
    - + -
    -
    -
    - 994 - -
    - + - return changeL2Block -
    -
    - 995 - -
    - + - } -
    -
    - 996 - -
    - + -
    -
    -
    - 997 - -
    -   - // GetRawBatchTimestamps returns the timestamp of the batch with the given number. -
    -
    - 998 - -
    -   - // it returns batch_num.tstamp and virtual_batch.batch_timestamp -
    -
    - 999 - -
    -   - func (p *PostgresStorage) GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) { -
    -
    -
     
    -
    - 1092 + + -
    +
    +
     
    - 1093 + + -
    +
    +
      - return batches, nil +
    - 1094 + + -
    +
    +
      - } -
    -
    - 1095 - -
    - +
    - 1096 - -
    - + - // UpdateBatchTimestamp updates the timestamp of the state.batch with the given number. -
    -
    - 1097 - -
    - + - func (p *PostgresStorage) UpdateBatchTimestamp(ctx context.Context, batchNumber uint64, timestamp time.Time, dbTx pgx.Tx) error { -
    -
    - 1098 - -
    - + - const sql = "UPDATE state.batch SET timestamp = $1 WHERE batch_num = $2" -
    -
    - 1099 - -
    - + - e := p.getExecQuerier(dbTx) -
    -
    - 1100 - -
    - + - _, err := e.Exec(ctx, sql, timestamp.UTC(), batchNumber) -
    -
    - 1101 - -
    - + - return err -
    -
    - 1102 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch_pending.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - -
    -
    @@ -1 +0,0 @@
    -
    - 1 - -
    - - - package pgstatestorage -
    -
    -
    -
    -
    -
    - - - - - - - -
    -
     
    -
    @@ -242555,459 +12821,56 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_inner_in.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,41 +0,0 @@
    -
    - 1 - -
    - - - package pgstatestorage -
    -
    - 2 + + -
    - - +
    +
    +  
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "time" -
    -
    - 6 + + -
    - - +
    +
    +  
    - 7 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 8 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 9 - -
    - - - "github.com/jackc/pgx/v4" -
    -
    - 10 - -
    - - - ) -
    -
    - 11 + + -
    - - +
    +
    +  
    - 12 - -
    - - - 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" -
    -
    - 13 - -
    - - - const blobInnerFieldsTypeBlob = "blob_type_index,blob_type_z, blob_type_y,blob_type_commitment,blob_type_proof" -
    -
    - 14 + + -
    - - +
    +
    +  
    - 15 - -
    - - - func (p *PostgresStorage) AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error { -
    -
    - 16 - -
    - - - sql := "INSERT INTO state.blob_inner_in (" + blobInnerFields -
    -
    - 17 - -
    - - - if blobInner.Type == state.TypeBlobTransaction { -
    -
    - 18 - -
    - - - sql += "," + blobInnerFieldsTypeBlob -
    -
    - 19 - -
    - - - } -
    -
    - 20 - -
    - - - sql += ") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9" -
    -
    - 21 - -
    - - - if blobInner.Type == state.TypeBlobTransaction { -
    -
    - 22 - -
    - - - sql += ",$10,$11,$12,$13,$14" -
    -
    - 23 - -
    - - - } -
    -
    - 24 - -
    - - - sql += ")" -
    -
    - 25 - -
    - - - e := p.getExecQuerier(dbTx) -
    -
    - 26 - -
    - - - arguments := []interface{}{blobInner.BlobSequenceIndex, blobInner.BlobInnerNum, blobInner.Type.String(), blobInner.MaxSequenceTimestamp, blobInner.ZkGasLimit, blobInner.L1InfoLeafIndex, blobInner.L1InfoTreeRoot.String(), blobInner.BlobDataHash.String(), time.Now()} -
    -
    - 27 - -
    - - - if blobInner.Type == state.TypeBlobTransaction { -
    -
    - 28 - -
    - - - commitment, err := blobInner.BlobBlobTypeParams.Commitment.MarshalText() -
    -
    - 29 - -
    - - - if err != nil { -
    -
    - 30 - -
    - - - return err -
    -
    - 31 - -
    - - - } -
    -
    - 32 - -
    - - - proof, err := blobInner.BlobBlobTypeParams.Proof.MarshalText() -
    -
    - 33 - -
    - - - if err != nil { -
    -
    - 34 - -
    - - - return err -
    -
    - 35 - -
    - - - } -
    -
    - 36 - -
    - - - arguments = append(arguments, blobInner.BlobBlobTypeParams.BlobIndex, common.Bytes2Hex(blobInner.BlobBlobTypeParams.Z), common.Bytes2Hex(blobInner.BlobBlobTypeParams.Y), commitment, proof) -
    -
    - 37 - -
    - - - } -
    -
    - 38 - -
    - - - _, err := e.Exec(ctx, sql, arguments...) -
    -
    - 39 - -
    - - - return err -
    -
    - 40 + + -
    - - +
    +
    +  
    - 41 - -
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - -
    -
     
    -
    @@ -243418,528 +13281,445 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_sequences.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,48 +0,0 @@
    -
    - 1 - -
    - - - package pgstatestorage -
    -
    - 2 + + -
    - - +
    +
    +  
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "errors" -
    -
    - 6 + + -
    - - - "time" +
    +
    +   +
    - 7 + + -
    - - +
    +
    +  
    - 8 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    +   +
    - 9 + + -
    - - - "github.com/ethereum/go-ethereum/common" +
    +
    +   +
    - 10 + + -
    - - - "github.com/jackc/pgx/v4" +
    +
    +   +
    - 11 + + -
    - - - ) +
    +
    +   +
    - 12 + + -
    - - +
    +
    +  
    - 13 + + -
    - - - // AddBlobSequence adds a new blob sequence to the state. +
    +
    +   +
    - 14 + + -
    - - - // TODO: Add support to ReceivedAt +
    +
    +   +
    - 15 + + -
    - - - func (p *PostgresStorage) AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error { +
    +
    +   +
    - 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)" +
    +
    +   +
    - 17 + + -
    - - +
    +
    +  
    - 18 + + -
    - - - e := p.getExecQuerier(dbTx) +
    +
    +   +
    - 19 + + -
    - - - _, err := e.Exec(ctx, addBlobSequenceSQL, blobSequence.BlobSequenceIndex, blobSequence.BlockNumber, blobSequence.L2Coinbase.String(), blobSequence.FinalAccInputHash.String(), blobSequence.FirstBlobSequenced, blobSequence.LastBlobSequenced, blobSequence.CreateAt) +
    +
    +   +
    - 20 + + -
    - - - return err +
    +
    +   +
    - 21 + + -
    - - - } +
    +
    +   +
    - 22 + + -
    - - +
    +
    +  
    - 23 + + -
    - - - // GetLastBlobSequence returns the last blob sequence stored in the state. +
    +
    +   +
    - 24 + + -
    - - - // TODO: Add support to ReceivedAt +
    +
    +   +
    - 25 + + -
    - - - func (p *PostgresStorage) GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error) { +
    +
    +   +
    - 26 + + -
    - - - var ( +
    +
    +   +
    - 27 + + -
    - - - coinbase string +
    +
    +   +
    - 28 + + -
    - - - finalAccInputHash string +
    +
    +   +
    - 29 + + -
    - - - createAt time.Time +
    +
    +   +
    - 30 + + -
    - - - blobSequence state.BlobSequence +
    +
    +   +
    - 31 + + -
    - - - ) +
    +
    +   +
    - 32 + + -
    - - - 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" +
    +
    +   +
    - 33 + + -
    - - +
    +
    +  
    - 34 + + -
    - - - q := p.getExecQuerier(dbTx) +
    +
    +   +
    - 35 + + -
    - - +
    +
    +  
    - 36 + + -
    - - - err := q.QueryRow(ctx, getLastBlobSequenceSQL).Scan(&blobSequence.BlobSequenceIndex, &coinbase, &finalAccInputHash, &blobSequence.FirstBlobSequenced, &blobSequence.LastBlobSequenced, &createAt) +
    +
    +   +
    - 37 + + -
    - - - if errors.Is(err, pgx.ErrNoRows) { +
    +
    +   +
    - 38 + + -
    - - - // If none on database return a nil object +
    +
    +   +
    - 39 + + -
    - - - return nil, nil +
    +
    +   +
    - 40 + + -
    - - - } +
    +
    +   +
    - 41 + + -
    - - - if err != nil { +
    +
    +   +
    - 42 + + -
    - - - return nil, err +
    +
    +   +
    - 43 + + -
    - - - } +
    +
    +   +
    - 44 + + -
    - - - blobSequence.L2Coinbase = common.HexToAddress(coinbase) +
    +
    +   +
    - 45 + + -
    - - - blobSequence.FinalAccInputHash = common.HexToHash(finalAccInputHash) +
    +
    +   +
    - 46 + + -
    - - - blobSequence.CreateAt = createAt +
    +
    +   +
    - 47 + + -
    - - - return &blobSequence, nil +
    +
    +   +
    - 48 - -
    - - - } -
    +
    +
    -
    + +
    +   +
    -
    -
    - - - - - + + +
    -
     
    @@ -244201,2623 +13981,3132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    +
    + 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",
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_external_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -17,7 +17,7 @@
    - 17 + + 68 +
    -   - panic(err) + + + Action: describe,
    - 18 + + 69 +
    -   - } + + + Flags: append(policyActionFlags, &noHeaderFlag),
    - 19 + + 70 +
    -   - pgStateStorage = pgstatestorage.NewPostgresStorage(state.Config{}, stateDb) + + + }, {
    - 20 + + 71 +
    - - - testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil, nil) + + + Name: "remove",
    - 21 + + 72 +
    -   -
    + + + Usage: "Remove address(es) from a policy exclusion list",
    - 22 + + 73 +
    -   - for i := 1; i <= 6; i++ { + + + Action: removeAcl,
    - 23 + + 74 +
    -   - err = testState.AddForkID(ctx, state.ForkIDInterval{ForkId: uint64(i), BlockNumber: uint64(i * 100), FromBatchNumber: uint64(i * 10), ToBatchNumber: uint64(i*10) + 9}, nil) + + + Flags: append(policyActionFlags, &csvFlag),
    -
    @@ -76,13 +76,13 @@
    +
    + 75 + +
    + + + }, { +
    + 76 +
    -   - panic(err) + + + Name: "update",
    + 77 +
    -   - } + + + Usage: "Update the default action for a policy",
    + 78 +
    -   - pgStateStorage = pgstatestorage.NewPostgresStorage(stateCfg, stateDb) + + + Action: updatePolicy,
    + 79 +
    - - - testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil, nil) + + + Flags: append(policyActionFlags, &allowFlag, &denyFlag),
    + 80 +
    - - - st := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, nil, nil, nil) + + + },
    + 81 +
    -   -
    + + + },
    + 82 +
    -   - avoidMemoryStateCfg := stateCfg + + + }
    + 83 +
    -   - avoidMemoryStateCfg.AvoidForkIDInMemory = true + + +
    + 84 +
    -   - pgStateStorageAvoidMemory := pgstatestorage.NewPostgresStorage(avoidMemoryStateCfg, stateDb) + + + func updatePolicy(cli *cli.Context) error {
    + 85 +
    - - - stAvoidMemory := state.NewState(avoidMemoryStateCfg, pgStateStorageAvoidMemory, executorClient, stateTree, nil, nil, nil) + + + _, db, err := configAndStorage(cli)
    + 86 +
    -   -
    + + + if err != nil {
    + 87 +
    -   - // persist forkID intervals + + + return err
    + 88 +
    -   - forkIdIntervals := []state.ForkIDInterval{} + + + }
    -
    + + + 89 + + +
    + + + policy, err := resolvePolicy(cli)
    -
    -
    - - - - - - - - - + + + - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
    -
     
    - 17 + + 90 +
    -   - panic(err) + + + if err != nil {
    - 18 + + 91 +
    -   + + + return err +
    +
    + 92 + +
    + + }
    - 19 + + 93 +
    -   - pgStateStorage = pgstatestorage.NewPostgresStorage(state.Config{}, stateDb) + + +
    - 20 + + 94 +
    + - testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil) + allow := cli.Bool(allowFlag.Name)
    - 21 + + 95 +
    -   -
    + + + deny := cli.Bool(denyFlag.Name)
    - 22 + + 96 +
    -   - for i := 1; i <= 6; i++ { + + +
    - 23 + + 97 +
    -   - err = testState.AddForkID(ctx, state.ForkIDInterval{ForkId: uint64(i), BlockNumber: uint64(i * 100), FromBatchNumber: uint64(i * 10), ToBatchNumber: uint64(i*10) + 9}, nil) + + + // exactly one must be set
    -
     
    +
    + 98 + +
    + + + if (allow && deny) || (!allow && !deny) { +
    - 76 + + 99 +
    -   - panic(err) + + + return errors.New("supply one policy action [--allow or --deny]")
    - 77 + + 100 +
    -   + + }
    - 78 + + 101 +
    -   - pgStateStorage = pgstatestorage.NewPostgresStorage(stateCfg, stateDb) + + +
    - 79 + + 102 +
    + - testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil) + var setting bool
    - 80 + + 103 +
    + - st := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, nil, nil) + if allow {
    - 81 + + 104 +
    -   + + + setting = true +
    +
    + 105 + +
    + + + } else if deny { +
    +
    + 106 + +
    + + + setting = false +
    +
    + 107 + +
    + + + } +
    +
    + 108 + +
    + +
    - 82 + + 109 +
    -   - avoidMemoryStateCfg := stateCfg + + + err = db.UpdatePolicy(context.Background(), policy, setting)
    - 83 + + 110 +
    -   - avoidMemoryStateCfg.AvoidForkIDInMemory = true + + + if err != nil {
    - 84 + + 111 +
    -   - pgStateStorageAvoidMemory := pgstatestorage.NewPostgresStorage(avoidMemoryStateCfg, stateDb) + + + return err
    - 85 + + 112 +
    + - stAvoidMemory := state.NewState(avoidMemoryStateCfg, pgStateStorageAvoidMemory, executorClient, stateTree, nil, nil) + }
    - 86 + + 113 +
    -   -
    + + + return nil
    - 87 + + 114 +
    -   - // persist forkID intervals + + + }
    - 88 + + 115 +
    -   - forkIdIntervals := []state.ForkIDInterval{} + + +
    -
    + + + 116 + + +
    + + + func addAcl(cli *cli.Context) error {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -93,7 +93,7 @@
    - 93 + + 117 +
    -   - } + + + _, db, err := configAndStorage(cli)
    - 94 + + 118 +
    -   - storage := NewPostgresStorage(cfg, nil) + + + if err != nil {
    - 95 + + 119 +
    -   - // Create a new State instance with test data + + + return err
    - 96 + + 120 +
    - - - state := state.NewState(cfg, storage, nil, nil, nil, nil, nil) + + + }
    - 97 + + 121 +
    -   -
    + + + policy, addresses, err := requirePolicyAndAddresses(cli)
    - 98 + + 122 +
    -   - // Call the function being tested + + + if err != nil {
    - 99 + + 123 +
    -   - actual := state.GetForkIDByBlockNumber(tc.blockNumber) + + + return err
    -
    + + + 124 + + +
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 93 + + 125 +
    -   - } + + + err = db.AddAddressesToPolicy(context.Background(), policy, addresses)
    - 94 + + 126 +
    -   - storage := NewPostgresStorage(cfg, nil) + + + if err != nil {
    - 95 + + 127 +
    -   - // Create a new State instance with test data + + + return err
    - 96 + + 128 +
    + - state := state.NewState(cfg, storage, nil, nil, nil, nil) + }
    - 97 + + 129 +
    -   -
    + + + return nil
    - 98 + + 130 +
    -   - // Call the function being tested + + + }
    - 99 + + 131 +
    -   - actual := state.GetForkIDByBlockNumber(tc.blockNumber) + + +
    -
    + + + 132 + + +
    + + + func removeAcl(cli *cli.Context) error {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -3,48 +3,33 @@
    - 3 + + 133 +
    -   - import ( + + + _, db, err := configAndStorage(cli)
    - 4 + + 134 +
    -   - "context" + + + if err != nil {
    - 5 + + 135 +
    -   - "errors" + + + return err
    - 6 + + 136 +
    - - - "fmt" + + + }
    - 7 + + 137 +
    -   -
    + + + policy, addresses, err := requirePolicyAndAddresses(cli)
    - 8 + + 138 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state" + + + if err != nil {
    - 9 + + 139 +
    -   - "github.com/ethereum/go-ethereum/common" + + + return err
    - 10 + + 140 +
    -   - "github.com/jackc/pgx/v4" + + + }
    - 11 + + 141 + +
    + + + err = db.RemoveAddressesFromPolicy(context.Background(), policy, addresses) +
    +
    + 142 +
    -   - ) + + + if err != nil {
    - 12 + + 143 +
    -   -
    + + + return err
    - 13 + + 144 +
    - - - const ( + + + }
    - 14 + + 145 +
    - - - l1InfoTreeIndexFieldName = "l1_info_tree_index" + + + return nil
    - 15 + + 146 +
    - - - ) + + + }
    - 16 + + 147 +
    - - + +
    - 17 + + 148 +
    -   - // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error + + + func clearAcl(cli *cli.Context) error {
    - 18 + + 149 +
    -   - func (p *PostgresStorage) AddL1InfoRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx) error { + + + _, db, err := configAndStorage(cli)
    - 19 + + 150 +
    - - - return p.addL1InfoRootToExitRootVx(ctx, exitRoot, dbTx, l1InfoTreeIndexFieldName) + + + if err != nil {
    - 20 + + 151 +
    - - - } + + + return err
    - 21 + + 152 +
    - - -
    + + + }
    - 22 + + 153 +
    - - - func (p *PostgresStorage) addL1InfoRootToExitRootVx(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx, indexFieldName string) error { + + + policy, err := resolvePolicy(cli)
    - 23 + + 154 +
    -   - const addGlobalExitRootSQL = ` + + + if err != nil {
    - 24 + + 155 +
    - - - INSERT INTO state.exit_root(block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s) + + + return err
    - 25 + + 156 +
    -   - VALUES ($1, $2, $3, $4, $5, $6, $7, $8); + + + }
    - 26 + + 157 +
    -   - ` + + + err = db.ClearPolicy(context.Background(), policy)
    - 27 + + 158 +
    - - - sql := fmt.Sprintf(addGlobalExitRootSQL, indexFieldName) + + + if err != nil {
    - 28 + + 159 +
    -   - e := p.getExecQuerier(dbTx) + + + return err
    - 29 + + 160 +
    - - - _, err := e.Exec(ctx, sql, + + + }
    - 30 + + 161 +
    -   - exitRoot.BlockNumber, exitRoot.Timestamp, exitRoot.MainnetExitRoot, exitRoot.RollupExitRoot, + + + return nil
    - 31 + + 162 +
    -   - exitRoot.GlobalExitRoot.GlobalExitRoot, exitRoot.PreviousBlockHash, exitRoot.L1InfoTreeRoot, exitRoot.L1InfoTreeIndex) + + + }
    - 32 + + 163 +
    -   - return err + + +
    - 33 + + 164 +
    -   - } + + + func describe(cli *cli.Context) error {
    - 34 + + 165 +
    -   -
    + + + showHeader := !cli.Bool(noHeaderFlag.Name)
    - 35 + + 166 +
    -   - func (p *PostgresStorage) GetAllL1InfoRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + + + if cli.IsSet(policyFlag.Name) {
    - 36 + + 167 +
    - - - return p.GetAllL1InfoRootEntriesVx(ctx, dbTx, l1InfoTreeIndexFieldName) + + + return describePolicy(cli, showHeader)
    - 37 + + 168 +
    - - - } + + + }
    - 38 + + 169 +
    - - -
    + + + return describePolicies(cli, showHeader)
    - 39 + + 170 +
    - - - func (p *PostgresStorage) GetAllL1InfoRootEntriesVx(ctx context.Context, dbTx pgx.Tx, indexFieldName string) ([]state.L1InfoTreeExitRootStorageEntry, error) { + + + }
    - 40 + + 171 +
    - - - const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s + + +
    - 41 + + 172 +
    -   - FROM state.exit_root + + + func describePolicy(cli *cli.Context, showHeader bool) error {
    - 42 + + 173 +
    - - - WHERE %s IS NOT NULL + + + _, db, err := configAndStorage(cli)
    - 43 + + 174 +
    - - - ORDER BY %s` + + + if err != nil {
    - 44 + + 175 +
    -   -
    + + + return err
    - 45 + + 176 +
    - - - sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName) + + + }
    - 46 + + 177 +
    -   - e := p.getExecQuerier(dbTx) + + +
    - 47 + + 178 +
    - - - rows, err := e.Query(ctx, sql) + + + policyName, err := resolvePolicy(cli)
    - 48 + + 179 +
    -   + + if err != nil {
    - 49 + + 180 +
    -   - return nil, err + + + return err
    - 50 + + 181 +
    -   + + }
    -
    @@ -65,22 +50,15 @@
    +
    + 182 + +
    + + +
    +
    - 65 + + 183 +
    -   -
    + + + if showHeader {
    - 66 + + 184 +
    -   - // GetLatestL1InfoRoot is used to get the latest L1InfoRoot + + + policy, err := db.DescribePolicy(context.Background(), policyName)
    - 67 + + 185 +
    -   - func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error) { + + + if err != nil {
    - 68 + + 186 +
    - - - return p.GetLatestL1InfoRootVx(ctx, maxBlockNumber, nil, l1InfoTreeIndexFieldName) + + + return err
    - 69 + + 187 +
    - - - } + + + }
    - 70 + + 188 +
    - - -
    + + + fmt.Printf("%s: %s\n", "Policy", policy.Name)
    - 71 + + 189 +
    - - - // GetLatestL1InfoRoot is used to get the latest L1InfoRoot + + + fmt.Printf("%s: %s\n", "Action", policy.Desc())
    - 72 + + 190 +
    - - - func (p *PostgresStorage) GetLatestL1InfoRootVx(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) { + + + }
    - 73 + + 191 +
    - - - const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s + + + query, err := resolveAddresses(cli, false)
    - 74 + + 192 +
    -   - FROM state.exit_root + + + if err != nil {
    - 75 + + 193 +
    - - - WHERE %s IS NOT NULL AND block_num <= $1 + + + return nil
    - 76 + + 194 +
    - - - ORDER BY %s DESC LIMIT 1` + + + }
    - 77 + + 195 +
    - - -
    + + + list, err := db.ListAcl(context.Background(), policyName, query)
    - 78 + + 196 +
    - - - sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName) + + + if err != nil {
    - 79 + + 197 +
    -   -
    + + + return err
    - 80 + + 198 +
    -   - entry := state.L1InfoTreeExitRootStorageEntry{} + + + }
    - 81 + + 199 +
    -   + +
    - 82 + + 200 +
    - - - e := p.getExecQuerier(dbTx) + + + if showHeader {
    - 83 + + 201 +
    - - - err := e.QueryRow(ctx, sql, maxBlockNumber).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, + + + fmt.Println("Addresses:")
    - 84 + + 202 +
    -   - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) + + + }
    - 85 + + 203 +
    -   -
    + + + for _, address := range list {
    - 86 + + 204 +
    -   - if !errors.Is(err, pgx.ErrNoRows) { + + + fmt.Println(address.Hex())
    -
    @@ -90,16 +68,11 @@
    +
    + 205 + +
    + + + } +
    - 90 + + 206 +
    -   - return entry, nil + + + return nil
    - 91 + + 207 +
    -   + + }
    - 92 + + 208 +
    -   - func (p *PostgresStorage) GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) { + + +
    - 93 + + 209 +
    - - - return p.GetLatestIndexVx(ctx, dbTx, l1InfoTreeIndexFieldName) + + + func describePolicies(cli *cli.Context, showHeader bool) error {
    - 94 + + 210 +
    - - - } + + + _, db, err := configAndStorage(cli)
    - 95 + + 211 +
    - - - func (p *PostgresStorage) GetLatestIndexVx(ctx context.Context, dbTx pgx.Tx, indexFieldName string) (uint32, error) { + + + if err != nil {
    - 96 + + 212 +
    - - - const getLatestIndexSQL = `SELECT max(%s) as %s FROM state.exit_root + + + return err
    - 97 + + 213 +
    - - - WHERE %s IS NOT NULL` + + + }
    - 98 + + 214 +
    - - - sql := fmt.Sprintf(getLatestIndexSQL, indexFieldName, indexFieldName, indexFieldName) + + + list, err := db.DescribePolicies(context.Background())
    - 99 + + 215 +
    - - -
    + + + if err != nil {
    - 100 + + 216 +
    -   - var l1InfoTreeIndex *uint32 + + + return err
    - 101 + + 217 +
    -   - e := p.getExecQuerier(dbTx) + + + }
    - 102 + + 218 +
    - - - err := e.QueryRow(ctx, sql).Scan(&l1InfoTreeIndex) + + +
    - 103 + + 219 +
    -   - if err != nil { + + + if showHeader {
    - 104 + + 220 +
    -   - return 0, err + + + fmt.Printf("%7s: %s\n", "Policy", "Action")
    - 105 + + 221 +
    -   + + }
    -
    @@ -110,17 +83,13 @@
    +
    + 222 + +
    + + + for _, p := range list { +
    - 110 + + 223 +
    -   - } + + + fmt.Printf("%7s: %s\n", p.Name, p.Desc())
    - 111 + + 224 +
    -   -
    + + + }
    - 112 + + 225 +
    -   - func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) { + + +
    - 113 + + 226 +
    - - - return p.GetL1InfoRootLeafByL1InfoRootVx(ctx, l1InfoRoot, dbTx, l1InfoTreeIndexFieldName) + + + return nil
    - 114 + + 227 +
    - - + + }
    - 115 + + 228 +
    - - + +
    - 116 + + 229 +
    - - - func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRootVx(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) { + + + func configAndStorage(cli *cli.Context) (*config.Config, *pgpoolstorage.PostgresPoolStorage, error) {
    - 117 + + 230 +
    - - - const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s + + + c, err := config.Load(cli, false)
    - 118 + + 231 +
    -   - FROM state.exit_root + + + if err != nil {
    - 119 + + 232 +
    - - - WHERE %s IS NOT NULL AND l1_info_root=$1` + + + return nil, nil, err
    - 120 + + 233 +
    - - - sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName) + + + }
    - 121 + + 234 +
    -   - var entry state.L1InfoTreeExitRootStorageEntry + + + setupLog(c.Log)
    - 122 + + 235 +
    -   - e := p.getExecQuerier(dbTx) + + +
    - 123 + + 236 +
    - - - err := e.QueryRow(ctx, sql, l1InfoRoot).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, + + + db, err := pgpoolstorage.NewPostgresPoolStorage(c.Pool.DB)
    - 124 + + 237 +
    -   - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) + + + if err != nil {
    - 125 + + 238 +
    -   - if !errors.Is(err, pgx.ErrNoRows) { + + + return nil, nil, err
    - 126 + + 239 +
    -   - return entry, err + + + }
    -
    @@ -129,17 +98,13 @@
    +
    + 240 + +
    + + + return c, db, nil +
    - 129 + + 241 +
    -   + + }
    - 130 + + 242 +
    -   + +
    - 131 + + 243 +
    -   - func (p *PostgresStorage) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) { + + + func requirePolicyAndAddresses(cli *cli.Context) (pool.PolicyName, []common.Address, error) {
    - 132 + + 244 +
    - - - return p.GetL1InfoRootLeafByIndexVx(ctx, l1InfoTreeIndex, dbTx, l1InfoTreeIndexFieldName) + + + policy, err := resolvePolicy(cli)
    - 133 + + 245 +
    - - - } + + + if err != nil {
    - 134 + + 246 +
    - - -
    + + + return "", nil, err
    - 135 + + 247 +
    - - - func (p *PostgresStorage) GetL1InfoRootLeafByIndexVx(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) { + + + }
    - 136 + + 248 +
    - - - const getL1InfoRootByIndexSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s + + + addresses, err := resolveAddresses(cli, true)
    - 137 + + 249 +
    -   - FROM state.exit_root + + + if err != nil {
    - 138 + + 250 +
    - - - WHERE %s = $1` + + + return "", nil, err
    - 139 + + 251 +
    - - - sql := fmt.Sprintf(getL1InfoRootByIndexSQL, indexFieldName, indexFieldName) + + + }
    - 140 + + 252 +
    -   - var entry state.L1InfoTreeExitRootStorageEntry + + + return policy, addresses, nil +
    +
    + 253 + +
    + + + }
    - 141 + + 254 +
    -   - e := p.getExecQuerier(dbTx) + + +
    - 142 + + 255 +
    - - - err := e.QueryRow(ctx, sql, l1InfoTreeIndex).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, + + + func resolvePolicy(cli *cli.Context) (pool.PolicyName, error) {
    - 143 + + 256 +
    -   - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) + + + policy := cli.String(policyFlag.Name)
    - 144 + + 257 +
    -   - if !errors.Is(err, pgx.ErrNoRows) { + + + if policy == "" {
    - 145 + + 258 +
    -   - return entry, err + + + return "", nil
    -
    @@ -148,18 +113,14 @@
    +
    + 259 + +
    + + + } +
    - 148 + + 260 +
    -   - } + + + if !pool.IsPolicy(policy) {
    - 149 + + 261 +
    -   -
    + + + return "", fmt.Errorf("invalid policy name: %s", policy)
    - 150 + + 262 +
    -   - func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + + + }
    - 151 + + 263 +
    - - - return p.GetLeavesByL1InfoRootVx(ctx, l1InfoRoot, dbTx, l1InfoTreeIndexFieldName) + + + return pool.PolicyName(policy), nil
    - 152 + + 264 +
    - - + + }
    - 153 + + 265 +
    - - + +
    - 154 + + 266 +
    - - - func (p *PostgresStorage) GetLeavesByL1InfoRootVx(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx, indexFieldName string) ([]state.L1InfoTreeExitRootStorageEntry, error) { + + + func resolveAddresses(cli *cli.Context, failIfEmpty bool) ([]common.Address, error) {
    - 155 + + 267 +
    -   - // TODO: Optimize this query + + + var set = make(map[common.Address]struct{})
    - 156 + + 268 +
    - - - const getLeavesByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s + + + if cli.IsSet("csv") {
    - 157 + + 269 +
    -   - FROM state.exit_root + + + file := cli.String(csvFlag.Name)
    - 158 + + 270 +
    - - - WHERE %s IS NOT NULL AND %s <= (SELECT %s FROM state.exit_root WHERE l1_info_root=$1) + + + fd, err := os.Open(file)
    - 159 + + 271 +
    - - - ORDER BY %s ASC` + + + if err != nil {
    - 160 + + 272 +
    - - - sql := fmt.Sprintf(getLeavesByL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName, indexFieldName, indexFieldName) + + + return nil, err
    - 161 + + 273 +
    -   - e := p.getExecQuerier(dbTx) + + + }
    - 162 + + 274 +
    - - - rows, err := e.Query(ctx, sql, l1InfoRoot) + + + defer func(fd *os.File) {
    - 163 + + 275 +
    -   - if err != nil { + + + _ = fd.Close()
    - 164 + + 276 +
    -   - return nil, err + + + }(fd)
    - 165 + + 277 +
    -   - } -
    -
    -
    + + +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    - 3 + + 278 +
    -   - import ( + + + fileReader := csv.NewReader(fd)
    - 4 + + 279 +
    -   - "context" + + + records, err := fileReader.ReadAll()
    - 5 + + 280 +
    -   - "errors" + + +
    - + + 281 -
    -   -
    +
    +
    + + + if err != nil {
    - 6 + + 282 +
    -   -
    + + + return nil, err
    - 7 + + 283 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state" + + + }
    - 8 + + 284 +
    -   - "github.com/ethereum/go-ethereum/common" + + + for _, row := range records {
    - 9 + + 285 +
    -   - "github.com/jackc/pgx/v4" + + + for _, cell := range row {
    - 10 + + 286 +
    -   - ) + + + hex := strings.TrimSpace(cell)
    - 11 + + 287 +
    -   -
    + + + set[common.HexToAddress(hex)] = struct{}{}
    - + + 288 -
    -   -
    +
    +
    + + + }
    - + + 289 -
    -   -
    +
    +
    + + + }
    - + + 290 -
    -   -
    +
    +
    + + + }
    - + + 291 -
    -   +
    +
    + +
    - 12 + + 292 +
    -   - // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error + + + for _, a := range cli.Args().Slice() {
    - 13 + + 293 +
    -   - func (p *PostgresStorage) AddL1InfoRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx) error { + + + a = strings.TrimSpace(a)
    - + + 294 -
    -   -
    +
    +
    + + + a = strings.Trim(a, ",|")
    - + + 295 -
    -   -
    +
    +
    + + + if !strings.HasPrefix(a, "0x") {
    - + + 296 -
    -   -
    +
    +
    + + + a = "0x" + a
    - + + 297 -
    -   -
    +
    +
    + + + }
    - 14 + + 298 +
    -   - const addGlobalExitRootSQL = ` + + + set[common.HexToAddress(a)] = struct{}{}
    - 15 + + 299 +
    + - 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 + + 300 +
    -   - VALUES ($1, $2, $3, $4, $5, $6, $7, $8); + + + var ret []common.Address
    - 17 + + 301 +
    -   - ` + + + for a := range set {
    - + + 302 -
    -   -
    +
    +
    + + + ret = append(ret, a)
    - 18 + + 303 +
    -   - e := p.getExecQuerier(dbTx) + + + }
    - 19 + + 304 +
    + - _, err := e.Exec(ctx, addGlobalExitRootSQL, + if failIfEmpty && len(ret) == 0 {
    - 20 + + 305 +
    -   - exitRoot.BlockNumber, exitRoot.Timestamp, exitRoot.MainnetExitRoot, exitRoot.RollupExitRoot, + + + return nil, errors.New("no addresses given")
    - 21 + + 306 +
    -   - exitRoot.GlobalExitRoot.GlobalExitRoot, exitRoot.PreviousBlockHash, exitRoot.L1InfoTreeRoot, exitRoot.L1InfoTreeIndex) + + + }
    - 22 + + 307 +
    -   - return err + + + return ret, nil
    - 23 + + 308 +
    -   + + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - @@ -246866,58 +17145,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + - + + - - + + + - - - - - - - - + - - - - - - - - - - @@ -247131,103 +17410,83 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - @@ -247316,108 +17575,83 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247461,138 +17695,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247636,128 +17865,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247801,636 +18025,558 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -2,6 +2,7 @@
    +
    - 24 + 2
    @@ -246827,32 +17116,22 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 25 + 3
      - func (p *PostgresStorage) GetAllL1InfoRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + import (
    - 26 + + 4 +
    - + - 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 -
    -
    - - -
      -
    + "context"
    - + + 5 -
    +
    +
      -
    + "errors"
    - + + 6 -
    +
    +
      -
    + "fmt"
    - 27 + 7
      - FROM state.exit_root + "net"
    - 28 + +
    @@ -108,19 +113,27 @@
    +
    + 108 +
    - + - WHERE l1_info_tree_index IS NOT NULL +   + log.Fatal(err)
    - 29 + + 109 +
    - + - ORDER BY l1_info_tree_index` +   + }
    - 30 + 110
    @@ -246925,6 +17209,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 111 + +
    + - + etherman, err := newEtherman(*c) +
    +
    @@ -246937,105 +17231,100 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 31 + 112
      - e := p.getExecQuerier(dbTx) + if err != nil {
    - 32 + + 113 +
    - + - rows, err := e.Query(ctx, getL1InfoRootSQL) +   + log.Fatal(err)
    - 33 + 114
      - if err != nil { + }
    - 34 + + 115 +
    -   - return nil, err + - +
    - 35 + + 116 +
    -   - } + - + // READ CHAIN ID FROM POE SC
    -
     
    +
    + 117 + +
    + - + l2ChainID, err := etherman.GetL2ChainID() +
    - 50 + 118
      -
    + if err != nil {
    - 51 + 119
      - // GetLatestL1InfoRoot is used to get the latest L1InfoRoot + log.Fatal(err)
    - 52 + 120
      - func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error) { + }
    - 53 + + 121 +
    - + - 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 -
    -
    - - -
     
    @@ -247082,32 +17371,22 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 54 + 122
      - FROM state.exit_root -
    -
    - 55 - -
    - + - WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1 + st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false)
    - 56 + + 123 +
    - + - ORDER BY l1_info_tree_index DESC LIMIT 1` +   +
    - 57 + + -
    +
    +
     
    - 58 + + -
    +
    +
      - entry := state.L1InfoTreeExitRootStorageEntry{} +
    - 59 + + -
    +
    +
     
    - 60 - -
    - + - e := p.getExecQuerier(nil) -
    -
    - 61 - -
    - + - err := e.QueryRow(ctx, getL1InfoRootSQL, maxBlockNumber).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, -
    -
    - 62 + 124
      - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) + c.Aggregator.ChainID = l2ChainID
    - 63 + 125
      -
    + c.Sequencer.StreamServer.ChainID = l2ChainID
    - 64 + 126
      - if !errors.Is(err, pgx.ErrNoRows) { + log.Infof("Chain ID read from POE SC = %v", l2ChainID)
    -
     
    +
    @@ -277,8 +290,86 @@
    - 68 + 277
      - return entry, nil + }
    - 69 + 278
    @@ -247237,32 +17496,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 70 + 279
      - func (p *PostgresStorage) GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) { +
    - 71 + + 280 +
    - + - const getLatestIndexSQL = `SELECT max(l1_info_tree_index) as l1_info_tree_index FROM state.exit_root + - + func newEtherman(c config.Config) (*etherman.Client, error) {
    - 72 + + 281 +
    - + - WHERE l1_info_tree_index IS NOT NULL` + - + return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config)
    - 73 + + -
    +
    +
      - var l1InfoTreeIndex *uint32 +
    - 74 + + -
    +
    +
      - e := p.getExecQuerier(dbTx) -
    -
    - 75 - -
    - + - err := e.QueryRow(ctx, getLatestIndexSQL).Scan(&l1InfoTreeIndex) +
    - 76 + + -
    +
    +
      - if err != nil { +
    - 77 + + -
    +
    +
      - return 0, err +
    - 78 + + -
    +
    +
      - } +
    -
     
    -
    - 83 + + -
    +
    +
      - } +
    - 84 + + -
    +
    +
     
    - 85 + + -
    +
    +
      - func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) { -
    -
    - 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 +
    - 87 + + -
    +
    +
      - FROM state.exit_root +
    - 88 + + -
    - + - WHERE l1_info_tree_index IS NOT NULL AND l1_info_root=$1` +
    +
    +   +
    - 89 + + -
    - + +
    +
    +  
    - 90 + + -
    +
    +
      - var entry state.L1InfoTreeExitRootStorageEntry +
    - 91 + + -
    +
    +
      - e := p.getExecQuerier(dbTx) +
    - 92 + + -
    - + - err := e.QueryRow(ctx, getL1InfoRootSQL, l1InfoRoot).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, +
    +
    +   +
    - 93 + + -
    +
    +
      - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) +
    - 94 + + -
    +
    +
      - if !errors.Is(err, pgx.ErrNoRows) { +
    - 95 + + -
    +
    +
      - return entry, err +
    -
     
    -
    - 98 + + -
    +
    +
      - } +
    - 99 + + -
    +
    +
     
    - 100 + + -
    +
    +
      - func (p *PostgresStorage) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) { +
    - 101 + + -
    - + - 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 +
    +
    +   +
    - 102 + + -
    +
    +
      - FROM state.exit_root +
    - 103 + + -
    - + - WHERE l1_info_tree_index = $1` +
    +
    +   +
    - 104 + + -
    - + +
    +
    +  
    - 105 + + -
    +
    +
      - var entry state.L1InfoTreeExitRootStorageEntry +
    - 106 + + -
    +
    +
      - e := p.getExecQuerier(dbTx) +
    - 107 + + -
    - + - err := e.QueryRow(ctx, getL1InfoRootByIndexSQL, l1InfoTreeIndex).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot, +
    +
    +   +
    - 108 + + -
    +
    +
      - &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex) +
    - 109 + + -
    +
    +
      - if !errors.Is(err, pgx.ErrNoRows) { +
    - 110 + + -
    +
    +
      - return entry, err +
    -
     
    -
    - 113 + + -
    +
    +
      - } +
    - 114 + + -
    +
    +
     
    - 115 + + -
    +
    +
      - func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { +
    - 116 + + -
    +
    +
      - // TODO: Optimize this query +
    - 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 +
    +
    +   +
    - 118 + + -
    +
    +
      - FROM state.exit_root +
    - 119 + + -
    - + - 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) +
    +
    +   +
    - 120 + + -
    - + - ORDER BY l1_info_tree_index ASC` +
    +
    +   +
    - 121 + + -
    - + +
    +
    +  
    - 122 + + -
    +
    +
      - e := p.getExecQuerier(dbTx) +
    - 123 + + -
    - + - rows, err := e.Query(ctx, getLeafsByL1InfoRootSQL, l1InfoRoot) +
    +
    +   +
    - 124 + + -
    +
    +
      - if err != nil { +
    - 125 + + -
    +
    +
      - return nil, err +
    - 126 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree_recursive.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - -
    -
    @@ -1,46 +0,0 @@
    - 1 + + -
    - - - package pgstatestorage +
    +
    +   +
    - 2 + + -
    - - +
    +
    +  
    - 3 + + -
    - - - import ( +
    +
    +   +
    - 4 + + -
    - - - "context" +
    +
    +   +
    - 5 + + -
    - - +
    +
    +  
    - 6 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    +   +
    - 7 + + -
    - - - "github.com/jackc/pgx/v4" +
    +
    +   +
    - 8 + + -
    - - - ) +
    +
    +   +
    - 9 + + -
    - - +
    +
    +  
    - 10 + + -
    - - - const ( +
    +
    +   +
    - 11 + + -
    - - - l1InfoTreeRecursiveIndexFieldName = "l1_info_tree_recursive_index" +
    +
    +   +
    - 12 + + -
    - - - ) +
    +
    +   +
    - 13 + + -
    - - +
    +
    +  
    - 14 + + -
    - - - // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error +
    +
    +   +
    - 15 + + -
    - - - func (p *PostgresStorage) AddL1InfoTreeRecursiveRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeRecursiveExitRootStorageEntry, dbTx pgx.Tx) error { +
    +
    +   +
    - 16 + + -
    - - - exitRootOld := state.L1InfoTreeExitRootStorageEntry(*exitRoot) +
    +
    +   +
    - 17 + + -
    - - - return p.addL1InfoRootToExitRootVx(ctx, &exitRootOld, dbTx, l1InfoTreeRecursiveIndexFieldName) +
    +
    +   +
    - 18 + + 282 +
    - - +   }
    - 19 + + 283 +
    - - +  
    - 20 + + 284 +
    - - - func (p *PostgresStorage) GetAllL1InfoTreeRecursiveRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeRecursiveExitRootStorageEntry, error) { +   + func newL2EthClient(url string) (*ethclient.Client, error) {
    - 21 - -
    - - - res, err := p.GetAllL1InfoRootEntriesVx(ctx, dbTx, l1InfoTreeRecursiveIndexFieldName) -
    +
    +
    @@ -321,7 +412,7 @@
    - 22 + + 321 +
    - - - if err != nil { +   + // If synchronizer are using sequential mode, we only need one etherman client
    - 23 + + 322 +
    - - - return nil, err +   + if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode {
    - 24 + + 323 +
    - - - } +   + for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ {
    - 25 + + 324 +
    - - var entries []state.L1InfoTreeRecursiveExitRootStorageEntry + eth, err := newEtherman(cfg)
    - 26 + + 325 +
    - - - for _, entry := range res { +   + if err != nil {
    - 27 + + 326 +
    - - - entries = append(entries, state.L1InfoTreeRecursiveExitRootStorageEntry(entry)) +   + log.Fatal(err)
    - 28 + + 327 +
    - - - } +   + }
    - 29 - -
    - - - return entries, nil -
    +
    +
    @@ -426,12 +517,12 @@
    - 30 + + 426 +
    - - +   }
    - 31 + + 427 +
    - - +  
    - 32 + + 428 +
    - - - func (p *PostgresStorage) GetLatestL1InfoTreeRecursiveRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (state.L1InfoTreeRecursiveExitRootStorageEntry, error) { +   + func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender {
    - 33 + + 429 +
    - - res, err := p.GetLatestL1InfoRootVx(ctx, maxBlockNumber, dbTx, l1InfoTreeRecursiveIndexFieldName) + etherman, err := newEtherman(cfg)
    - 34 + + 430 +
    - - +   if err != nil {
    - 35 + + 431 +
    - - - return state.L1InfoTreeRecursiveExitRootStorageEntry{}, err +   + log.Fatal(err)
    - 36 + + 432 +
    - - +   }
    - 37 + + 433 +
    - - - return state.L1InfoTreeRecursiveExitRootStorageEntry(res), nil +   +
    - 38 + + 434 +
    - - } + auth, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password)
    - 39 + + 435 +
    - - -
    +   + if err != nil {
    - 40 + + 436 +
    - - - func (p *PostgresStorage) GetLatestL1InfoTreeRecursiveIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) { +   + log.Fatal(err)
    - 41 + + 437 +
    - - - return p.GetLatestIndexVx(ctx, dbTx, l1InfoTreeRecursiveIndexFieldName) +   + }
    - 42 - -
    - - - } -
    +
    +
    @@ -441,7 +532,12 @@
    - 43 + + 441 +
    - - +  
    - 44 - -
    - - - func (p *PostgresStorage) GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) { -
    -
    - 45 + + 442 +
    - - - return p.GetL1InfoRootLeafByIndexVx(ctx, l1InfoTreeIndex, dbTx, l1InfoTreeIndexFieldName) +   + ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st)
    - 46 + + 443 +
    - - - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - @@ -248484,83 +18630,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - @@ -248724,207 +18865,173 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - - -
     
    - + + 444 -
    -   -
    +
    +
    + - + seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog)
    - + + 445 -
    +
    +
      -
    + if err != nil {
    - + + 446 -
    +
    +
      -
    + log.Fatal(err)
    - + + 447 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -450,7 +546,23 @@
    - + + 450 -
    +
    +
      -
    + }
    - + + 451 -
    +
    +
     
    - + + 452 -
    +
    +
      -
    + func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) {
    - + + 453 -
    -   -
    +
    +
    + - + agg, err := aggregator.New(c, st, ethTxManager, etherman)
    - + + 454 -
    +
    +
      -
    + if err != nil {
    - + + 455 -
    +
    +
      -
    + log.Fatal(err)
    - + + 456 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -520,14 +632,14 @@
    - + + 520 -
    +
    +
      -
    + }
    - + + 521 -
    +
    +
      -
    + log.Infof("Starting L1InfoRoot: %v", l1inforoot.String())
    - + + 522 -
    +
    +
     
    - + + 523 -
    -   -
    +
    +
    + - + forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.BlockNumber)
    - + + 524 -
    +
    +
      -
    + if err != nil {
    - + + 525 -
    +
    +
      -
    + log.Fatal("error getting forkIDs. Error: ", err)
    - + + 526 -
    +
    +
      -
    + }
    - + + 527 -
    +
    +
      -
    + st.UpdateForkIDIntervalsInMemory(forkIDIntervals)
    - + + 528 -
    +
    +
     
    - + + 529 -
    +
    +
      -
    + currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId
    - - -
    -   -
    -
    +
    + 530
    -
    + +
    + - + log.Infof("Fork ID read from POE SC = %v", forkIDIntervals[len(forkIDIntervals)-1].ForkId)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go - RENAMED - -
    -
    -
    -
    - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - @@ -249213,63 +19310,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - @@ -249373,203 +19470,212 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + +
    -
    @@ -355,3 +355,87 @@
    - 355 + 531
      - } +
    - 356 + 532
      - return nativeBlockHashes, nil + return st, currentForkID
    - 357 + 533
    @@ -248933,203 +19040,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    +
    +
    @@ -543,13 +655,13 @@
    - + + 543 -
    +
    +
      -
    + }
    - + + 544 -
    +
    +
     
    - + + 545 -
    +
    +
      -
    + func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client {
    - + + 546 -
    -   -
    +
    +
    + - + etherman, err := newEtherman(cfg)
    - + + 547 -
    +
    +
      -
    + if err != nil {
    - + + 548 -
    +
    +
      -
    + log.Fatal(err)
    - + + 549 -
    +
    +
      -
    + }
    - + + 550 -
    +
    +
     
    - + + 551 -
    +
    +
      -
    + for _, privateKey := range cfg.EthTxManager.PrivateKeys {
    - + + 552 -
    -   -
    +
    +
    + - + _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password)
    - + + 553 -
    +
    +
      -
    + if err != nil {
    - + + 554 -
    +
    +
      -
    + log.Fatal(err)
    - + + 555 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -681,14 +793,32 @@
    - + + 681 -
    +
    +
      -
    + }
    - + + 682 -
    +
    +
      -
    + forkIDIntervals = forkIntervals
    - + + 683 -
    +
    +
      -
    + } else {
    - + + 684 -
    -   -
    +
    +
    + - + log.Debug("Getting initial forkID")
    - + + 685 -
    -   -
    +
    +
    + - + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, genesisBlockNumber)
    - + + 686 -
    +
    +
      -
    + if err != nil {
    - + + 687 -
    +
    +
      -
    + return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err)
    - + + 688 -
    +
    +
      -
    + } else if len(forkIntervals) == 0 {
    - + + 689 -
    +
    +
      -
    + return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...")
    - + + 690 -
    +
    +
      -
    + }
    - + + 691 -
    +
    +
      -
    + forkIDIntervals = forkIntervals
    - + + 692 -
    +
    +
      -
    + }
    - + + 693 -
    +
    +
      -
    + }
    - + + 694 -
    +
    +
      -
    + return forkIDIntervals, nil
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - @@ -249593,202 +19699,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - + + 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)
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - -
     
    - 355 + 290
    @@ -249798,67 +19895,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 356 + 291
      - return nativeBlockHashes, nil + }
    - 357 + 292
      - } -
    -
    - 358 - -
    - +
    - 359 - -
    - + - // GetBatchL2DataByNumber returns the batch L2 data of the given batch number. -
    -
    - 360 + + 293 +
    + - func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) { + func newEtherman(c config.Config, st *state.State) (*etherman.Client, error) {
    - 361 + + 294 +
    + - batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx) + ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil)
    - 362 + 295
    @@ -249868,7 +19945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 363 + 296
    @@ -249878,7 +19955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 364 + 297
    @@ -249888,37 +19965,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 365 + 298
    + - data, ok := batchData[batchNumber] + da, err := newDataAvailability(c, st, ethman, false)
    - 366 + 299
    + - if !ok { + if err != nil {
    - 367 + 300
    + - return nil, state.ErrNotFound + return nil, err
    - 368 + 301
    @@ -249928,17 +20005,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 369 + 302
    + - return data, nil + return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da, st)
    - 370 + 303
    @@ -249948,7 +20025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 371 + 304
    @@ -249958,297 +20035,297 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 372 + 305
    + - // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables. + func newDataAvailability(c config.Config, st *state.State, etherman *etherman.Client, isSequenceSender bool) (*dataavailability.DataAvailability, error) {
    - 373 + 306
    + - func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { + var (
    - 374 + 307
    + - const sql = "SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1)" + trustedSequencerURL string
    - 375 + 308
    + - return p.getBatchData(ctx, sql, batchNumbers, dbTx) + dataSourcePriority []dataavailability.DataSourcePriority
    - 376 + 309
    + - } + err error
    - 377 + 310
    + -
    + )
    - 378 + 311
    + - // GetForcedBatchDataByNumbers returns the forced batch data of the given batch numbers + if !c.IsTrustedSequencer {
    - 379 + 312
    + - func (p *PostgresStorage) GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { + if c.Synchronizer.TrustedSequencerURL != "" {
    - 380 + 313
    + - 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)" + trustedSequencerURL = c.Synchronizer.TrustedSequencerURL
    - 381 + 314
    + - return p.getBatchData(ctx, sql, batchNumbers, dbTx) + } else {
    - 382 + 315
    + - } + log.Debug("getting trusted sequencer URL from smc")
    - 383 + 316
    + -
    + trustedSequencerURL, err = etherman.GetTrustedSequencerURL()
    - 384 + 317
    + - func (p *PostgresStorage) getBatchData(ctx context.Context, sql string, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { + if err != nil {
    - 385 + 318
    + - q := p.getExecQuerier(dbTx) + return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err)
    - 386 + 319
    + - rows, err := q.Query(ctx, sql, batchNumbers) + }
    - 387 + 320
    + - if errors.Is(err, pgx.ErrNoRows) { + }
    - 388 + 321
    + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) + log.Debug("trustedSequencerURL ", trustedSequencerURL)
    - 389 + 322
    + - } else if err != nil { + }
    - 390 + 323
    + - return nil, err + zkEVMClient := client.NewClient(trustedSequencerURL)
    - 391 + 324
    + - } +
    - 392 + 325
    + - defer rows.Close() + dataSourcePriority = c.Synchronizer.L2Synchronization.DataSourcePriority
    - 393 + 326
    + -
    + if len(dataSourcePriority) == 0 {
    - 394 + 327
    + - batchL2DataMap, err := readBatchDataResults(rows, batchNumbers) + dataSourcePriority = dataavailability.DefaultPriority
    - 395 + 328
    + - if err != nil { + }
    - 396 + 329
    + - return nil, err +
    - 397 + 330
    + - } + // Backend specific config
    - 398 + 331
    + -
    + daProtocolName, err := etherman.GetDAProtocolName()
    - 399 + 332
    + - if len(batchL2DataMap) == 0 { + if err != nil {
    - 400 + 333
    + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) + return nil, fmt.Errorf("error getting data availability protocol name: %v", err)
    - 401 + 334
    @@ -250258,317 +20335,307 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 402 - -
    - + -
    -
    -
    - 403 + 335
    + - return batchL2DataMap, nil + var daBackend dataavailability.DABackender
    - 404 + 336
    + - } + switch daProtocolName {
    - 405 + 337
    + -
    + case string(dataavailability.DataAvailabilityCommittee):
    - 406 + 338
    + - // GetBatchL2DataByNumbersFromBackup returns the batch L2 data of the given batch number from the backup table + var (
    - 407 + 339
    + - func (p *PostgresStorage) GetBatchL2DataByNumbersFromBackup(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { + pk *ecdsa.PrivateKey
    - 408 + 340
    + - getBatchL2DataByBatchNumber := ` + err error
    - 409 + 341
    + - SELECT batch_num, data FROM state.batch_data_backup + )
    - 410 + 342
    + - WHERE batch_num = ANY($1) + if isSequenceSender {
    - 411 + 343
    + - ORDER BY created_at DESC + _, pk, err = etherman.LoadAuthFromKeyStore(c.SequenceSender.PrivateKey.Path, c.SequenceSender.PrivateKey.Password)
    - 412 + 344
    + - ` + if err != nil {
    - 413 + 345
    + - q := p.getExecQuerier(dbTx) + return nil, err
    - 414 + 346
    + - rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers) + }
    - 415 + 347
    + - if errors.Is(err, pgx.ErrNoRows) { + }
    - 416 + 348
    + - return nil, state.ErrNotFound + dacAddr, err := etherman.GetDAProtocolAddr()
    - 417 + 349
    + - } else if err != nil { + if err != nil {
    - 418 + 350
    + - return nil, err + return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err)
    - 419 + 351
    + - } + }
    - 420 + 352
    + - defer rows.Close() +
    - 421 + 353
    + -
    + daBackend, err = datacommittee.New(
    - 422 + 354
    + - return readBatchDataResults(rows, batchNumbers) + c.Etherman.URL,
    - 423 + 355
    + - } + dacAddr,
    - 424 + 356
    + -
    + pk,
    - 425 + 357
    + - // readBatchDataResults retrieves batch data from the provided result set + dataCommitteeClient.NewFactory(),
    - 426 + 358
    + - func readBatchDataResults(results pgx.Rows, batchNumbers []uint64) (map[uint64][]byte, error) { + )
    - 427 + 359
    + - batchL2DataMap := make(map[uint64][]byte, len(batchNumbers)) + if err != nil {
    - 428 + 360
    + - for results.Next() { + return nil, err
    - 429 + 361
    + - var ( + }
    - 430 + 362
    + - batchNum uint64 + default:
    - 431 + 363
    + - batchL2Data []byte + return nil, fmt.Errorf("unexpected / unsupported DA protocol: %s", daProtocolName)
    - 432 + 364
    + - ) + }
    - 433 + 365
    @@ -250578,196 +20645,197 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 434 + 366
    + - if err := results.Scan(&batchNum, &batchL2Data); err != nil { + return dataavailability.New(
    - 435 + 367
    + - return nil, err + c.IsTrustedSequencer,
    - 436 + 368
    + - } + daBackend,
    - 437 + 369
    + - batchL2DataMap[batchNum] = batchL2Data + st,
    - 438 + 370
    + - } + zkEVMClient,
    - 439 + 371
    + -
    + dataSourcePriority,
    - 440 + 372
    + - return batchL2DataMap, nil + )
    - 441 + + 373 +
    - + +   }
    -
    + + + 374 + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - RENAMED - -
    -
    -
    -
    - - - + + + + + - - - - - - - - - + - + + + + + - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    + 375 + +
    +   + func newL2EthClient(url string) (*ethclient.Client, error) { +
    +
    -
    @@ -110,11 +110,7 @@
    +
     
    - 110 + 412
      - if err != nil { + // If synchronizer are using sequential mode, we only need one etherman client
    - 111 + 413
      - panic(err) + if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode {
    - 112 + 414
      - } + for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ {
    - 113 + + 415 +
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(32) + + + eth, err := newEtherman(cfg, st)
    - 114 + + 416 +
    - - - if err != nil { +   + if err != nil {
    - 115 + + 417 +
    - - - panic(err) +   + log.Fatal(err)
    - 116 + + 418 +
    - - - } +   + }
    - 117 + +
     
    +
    + 517 +
    - - - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, eventLog, mt, mtr) +   + }
    - 118 + 518
    @@ -250777,127 +20845,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 119 + 519
      - result := m.Run() + func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender { +
    +
    + 520 + +
    + + + etherman, err := newEtherman(cfg, st)
    - 120 + 521
      -
    + if err != nil {
    -
    @@ -463,7 +459,7 @@
    -
    - 463 + 522
      - batchNumber := uint64(42) + log.Fatal(err)
    - 464 + 523
      - _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num,wip) VALUES ($1, FALSE), ($2, FALSE), ($3, FALSE)", batchNumber, batchNumber+1, batchNumber+2) + }
    - 465 + 524
      - require.NoError(err) +
    - 466 + + 525 +
    - - - 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)" + + + auth, _, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password)
    - 467 + 526
      - // proof with `generating_since` older than interval + if err != nil {
    - 468 + 527
      - now := time.Now().Round(time.Microsecond) + log.Fatal(err)
    - 469 + 528
      - oneHourAgo := now.Add(-time.Hour).Round(time.Microsecond) + }
    -
    @@ -500,10 +496,10 @@
    +
     
    - 500 + 532
      - _, err = testState.Exec(ctx, addGeneratedProofSQL, olderNotGenProof.BatchNumber, olderNotGenProof.BatchNumberFinal, olderNotGenProof.Proof, olderNotGenProof.ProofID, olderNotGenProof.InputProver, olderNotGenProof.Prover, olderNotGenProof.ProverID, olderNotGenProof.GeneratingSince, oneHourAgo, oneHourAgo) +
    - 501 + 533
      - require.NoError(err) + ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st)
    - 502 + 534
    @@ -250906,393 +20979,418 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 503 + + 535 +
    - - - _, err = testState.CleanupLockedBatchProofs(ctx, "1m", nil) + + + da, err := newDataAvailability(cfg, st, etherman, true)
    - 504 + + 536 +
    -   -
    + + + if err != nil {
    - 505 + + 537 +
    -   - require.NoError(err) + + + log.Fatal(err)
    - 506 + + 538 +
    - - - 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") + + + } +
    +
    + 539 + +
    + + +
    +
    +
    + 540 + +
    + + + seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog, da)
    - 507 + 541
      - require.NoError(err) + if err != nil {
    - 508 + 542
      - proofs := make([]state.Proof, 0, len(rows.RawValues())) + log.Fatal(err)
    - 509 + 543
      - for rows.Next() { + }
    -
    @@ -885,11 +881,7 @@
    +
     
    - 885 + 546
      - if err != nil { + }
    - 886 + 547
      - panic(err) +
    - 887 + 548
      - } + func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) {
    - 888 + + 549 +
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(32) + + + var (
    - 889 + + 550 +
    - - - if err != nil { + + + aggCli *agglayerClient.Client
    - 890 + + 551 +
    - - - panic(err) + + + pk *ecdsa.PrivateKey
    - 891 + + 552 +
    - - - } + + + err error
    - 892 + + 553 +
    - - - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr) + + + )
    - 893 + + 554 +
    -   + +
    - 894 + + 555 +
    -   - dbTx, err := testState.BeginStateTransaction(ctx) + + + if c.SettlementBackend == aggregator.AggLayer {
    - 895 + + 556 +
    -   - require.NoError(t, err) + + + aggCli = agglayerClient.New(c.AggLayerURL)
    -
    @@ -1086,11 +1078,7 @@
    +
    + 557 + +
    + + +
    +
    - 1086 + + 558 +
    -   - if err != nil { + + + // Load private key
    - 1087 + + 559 +
    -   - panic(err) + + + pk, err = config.NewKeyFromKeystore(c.SequencerPrivateKey)
    - 1088 + + 560 +
    -   - } + + + if err != nil {
    - 1089 + + 561 +
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(32) + + + log.Fatal(err)
    - 1090 + + 562 +
    - - - if err != nil { + + + }
    - 1091 + + 563 +
    - - - panic(err) + + + }
    - 1092 + + 564 +
    - - - } + + +
    - 1093 + + 565 +
    - - - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr) + + + agg, err := aggregator.New(c, st, ethTxManager, etherman, aggCli, pk)
    - 1094 + 566
      -
    + if err != nil {
    - 1095 + 567
      - dbTx, err := testState.BeginStateTransaction(ctx) + log.Fatal(err)
    - 1096 + 568
      - require.NoError(t, err) + }
    -
    @@ -1268,11 +1256,7 @@
    +
     
    - 1268 + 632
      - if err != nil { + }
    - 1269 + 633
      - panic(err) + log.Infof("Starting L1InfoRoot: %v", l1inforoot.String())
    - 1270 + 634
      - } +
    - 1271 + + 635 +
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(32) + + + forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.RollupBlockNumber)
    - 1272 + + 636 +
    - - +   if err != nil {
    - 1273 + + 637 +
    - - - panic(err) +   + log.Fatal("error getting forkIDs. Error: ", err)
    - 1274 + + 638 +
    - - +   }
    - 1275 + + 639 +
    - - - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr) +   + st.UpdateForkIDIntervalsInMemory(forkIDIntervals)
    - 1276 + 640
    @@ -251302,42 +21400,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1277 + 641
      - dbTx, err := testState.BeginStateTransaction(ctx) + currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId +
    +
    + 642 + +
    + + + log.Infof("Fork ID read from POE SC = %v", currentForkID)
    - 1278 + 643
      - require.NoError(t, err) +
    -
    @@ -1387,6 +1371,108 @@
    -
    - 1387 + 644
      - require.NoError(t, dbTx.Commit(ctx)) + return st, currentForkID
    - 1388 + 645
    @@ -251345,465 +21448,494 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    +
     
    +
    - 1389 + 655
      -
    + }
    - + + 656 -
    +
    +
     
    - + + 657 -
    +
    +
      -
    + func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client {
    - + + 658 -
    -   -
    +
    +
    + + + etherman, err := newEtherman(cfg, st)
    - + + 659 -
    +
    +
      -
    + if err != nil {
    - + + 660 -
    +
    +
      -
    + log.Fatal(err)
    - + + 661 -
    +
    +
      -
    + }
    - + + 662 -
    +
    +
     
    - + + 663 -
    +
    +
      -
    + for _, privateKey := range cfg.EthTxManager.PrivateKeys {
    - + + 664 -
    -   -
    +
    +
    + + + _, _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password)
    - + + 665 -
    +
    +
      -
    + if err != nil {
    - + + 666 -
    +
    +
      -
    + log.Fatal(err)
    - + + 667 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 793 -
    +
    +
      -
    + }
    - + + 794 -
    +
    +
      -
    + forkIDIntervals = forkIntervals
    - + + 795 -
    +
    +
      -
    + } else {
    - + + 796 -
    -   -
    +
    +
    + + + log.Debug("Getting all forkIDs")
    - + + 797 -
    -   +
    +
    + +
    - + + 798 -
    -   -
    +
    +
    + + + // Get last L1 block number
    - + + 799 -
    -   -
    +
    +
    + + + bn, err := etherman.GetLatestBlockNumber(ctx)
    - + + 800 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 801 -
    -   -
    +
    +
    + + + return []state.ForkIDInterval{}, fmt.Errorf("error getting latest block number. Error: %v", err)
    - + + 802 -
    -   -
    +
    +
    + + + }
    - + + 803 -
    -   +
    +
    + +
    - + + 804 -
    -   -
    +
    +
    + + + // Get all forkIDs since genesis
    - + + 805 -
    -   -
    +
    +
    + + + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, bn)
    - + + 806 -
    +
    +
      -
    + if err != nil {
    - + + 807 -
    +
    +
      -
    + return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err)
    - + + 808 -
    +
    +
      -
    + } else if len(forkIntervals) == 0 {
    - + + 809 -
    +
    +
      -
    + return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...")
    - + + 810 -
    +
    +
      -
    + }
    - + + 811 -
    +
    +
      -
    + forkIDIntervals = forkIntervals
    - + + 812 -
    -   +
    +
    + +
    - + + 813 -
    -   -
    +
    +
    + + + log.Debugf("Retrieved %d forkIDs", len(forkIDIntervals))
    - + + 814 -
    -   +
    +
    + +
    - + + 815 -
    -   -
    +
    +
    + + + log.Debug("Adding forkIDs to db and memory")
    - + + 816 -
    -   -
    +
    +
    + + + for _, forkID := range forkIDIntervals {
    - + + 817 -
    -   -
    +
    +
    + + + err = st.AddForkIDInterval(ctx, forkID, nil)
    - + + 818 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 819 -
    -   -
    +
    +
    + + + log.Fatal("error adding forkID to db. Error: ", err)
    - + + 820 -
    -   -
    +
    +
    + + + }
    - + + 821 -
    -   -
    +
    +
    + + + }
    - + + 822 -
    +
    +
      -
    + }
    - + + 823 -
    +
    +
      -
    + }
    - + + 824 -
    +
    +
      -
    + return forkIDIntervals, nil +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/set_data_availability_protocol.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - @@ -252511,2432 +22598,2480 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + +
    +
    @@ -0,0 +1,68 @@
    @@ -252376,68 +22508,23 @@

    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) +
    - 1591 + + -
    +
    +
      - } +
    - 1592 + + -
    +
    +
     
    - 1593 - -
    -   - func TestGetLastGER(t *testing.T) { +
    +
    - - +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1664,49 +1757,6 @@
    +
     
    - 1664 + + 1 +
    -   - ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) + + + package main
    - 1665 + + 2 +
    -   - require.NoError(t, err) + + +
    - 1666 + + 3 +
    -   - require.Equal(t, common.HexToHash("0x2").String(), ger.String()) + + + import (
    - 1667 + + 4 +
    - - -
    + + + "github.com/0xPolygonHermez/zkevm-node/config"
    - 1668 + + 5 +
    - - - } + + + "github.com/0xPolygonHermez/zkevm-node/log"
    - 1669 + + 6 +
    - - -
    + + + "github.com/ethereum/go-ethereum/common"
    - 1670 + + 7 +
    - - - func TestAddBlobSequence(t *testing.T) { + + + "github.com/urfave/cli/v2"
    - 1671 + + 8 +
    - - - initOrResetDB() + + + )
    - 1672 + + 9 +
    - - - ctx := context.Background() + + +
    - 1673 + + 10 +
    - - - dbTx, err := testState.BeginStateTransaction(ctx) + + + const flagDAAddress = "data-availability-address"
    - 1674 + + 11 +
    - - - require.NoError(t, err) + + +
    - 1675 + + 12 +
    - - - defer func() { require.NoError(t, dbTx.Commit(ctx)) }() + + + var setDataAvailabilityProtocolFlags = []cli.Flag{
    - 1676 + + 13 +
    - - -
    + + + &cli.StringFlag{
    - 1677 + + 14 +
    - - - block := state.NewBlock(100) + + + Name: flagDAAddress,
    - 1678 + + 15 +
    - - - err = testState.AddBlock(ctx, block, dbTx) + + + Aliases: []string{"da-addr"},
    - 1679 + + 16 +
    - - - require.NoError(t, err) + + + Usage: "address of the new data availibility protocol",
    - 1680 + + 17 +
    - - -
    + + + Required: true,
    - 1681 + + 18 +
    - - - blobSeq := state.BlobSequence{ + + + },
    - 1682 + + 19 +
    - - - BlobSequenceIndex: 1, + + + &cli.StringFlag{
    - 1683 + + 20 +
    - - - BlockNumber: 100, + + + Name: config.FlagKeyStorePath,
    - 1684 + + 21 +
    - - - } + + + Aliases: []string{"ksp"},
    - 1685 + + 22 +
    - - - err = testState.AddBlobSequence(ctx, &blobSeq, dbTx) + + + Usage: "the path of the key store file containing the private key of the account going to set new data availability protocol",
    - 1686 + + 23 +
    - - - require.NoError(t, err) + + + Required: true,
    - 1687 + + 24 +
    - - - } + + + },
    - 1688 + + 25 +
    - - -
    + + + &cli.StringFlag{
    - 1689 + + 26 +
    - - - func TestStoreBlobInner(t *testing.T) { + + + Name: config.FlagPassword,
    - 1690 + + 27 +
    - - - initOrResetDB() + + + Aliases: []string{"pw"},
    - 1691 + + 28 +
    - - - ctx := context.Background() + + + Usage: "the password do decrypt the key store file",
    - 1692 + + 29 +
    - - - dbTx, err := testState.BeginStateTransaction(ctx) + + + Required: true,
    - 1693 + + 30 +
    - - - require.NoError(t, err) + + + },
    - 1694 + + 31 +
    - - - defer func() { require.NoError(t, dbTx.Commit(ctx)) }() + + + &configFileFlag,
    - 1695 + + 32 +
    - - - block := state.NewBlock(100) + + + &networkFlag,
    - 1696 + + 33 +
    - - - err = testState.AddBlock(ctx, block, dbTx) + + + &customNetworkFlag,
    - 1697 + + 34 +
    - - - require.NoError(t, err) + + + }
    - 1698 + + 35 +
    - - + +
    - 1699 - -
    - - - blobSeq := state.BlobSequence{ -
    -
    - 1700 + + 36 +
    - - - BlobSequenceIndex: 1, + + + func setDataAvailabilityProtocol(ctx *cli.Context) error {
    - 1701 + + 37 +
    - - - BlockNumber: 100, + + + c, err := config.Load(ctx, true)
    - 1702 + + 38 +
    - - - } + + + if err != nil {
    - 1703 + + 39 +
    - - - err = testState.AddBlobSequence(ctx, &blobSeq, dbTx) + + + return err
    - 1704 + + 40 +
    - - - require.NoError(t, err) + + + }
    - 1705 + + 41 +
    - - - blobInner := state.BlobInner{ + + +
    - 1706 + + 42 +
    - - - BlobSequenceIndex: 1, + + + setupLog(c.Log)
    - 1707 + + 43 +
    - - - } + + +
    - 1708 + + 44 +
    - - - err = testState.AddBlobInner(ctx, &blobInner, dbTx) + + + daAddress := common.HexToAddress(ctx.String(flagDAAddress))
    - 1709 + + 45 +
    - - - require.NoError(t, err) + + + addrKeyStorePath := ctx.String(config.FlagKeyStorePath)
    - 1710 + + 46 +
    -   - } + + + addrPassword := ctx.String(config.FlagPassword)
    - 1711 + + 47 +
    -   + +
    - 1712 - -
    -   - func TestGetFirstUncheckedBlock(t *testing.T) { -
    +
    + 48
    -
    + +
    + + + etherman, err := newEtherman(*c, nil)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + + + +
    -
     
    - 110 + + 49 +
    -   + + if err != nil {
    - 111 + + 50 +
    -   - panic(err) + + + log.Fatal(err)
    - 112 + + 51 +
    -   - } + + + return err
    - 113 + + 52 +
    + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, eventLog, mt) + }
    - + + 53 -
    -   +
    +
    + +
    - + + 54 -
    -   -
    +
    +
    + + + auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword)
    - + + 55 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 56 -
    -   -
    +
    +
    + + + log.Fatal(err)
    - 114 + + 57 +
    -   -
    + + + return err
    - 115 + + 58 +
    -   - result := m.Run() + + + }
    - 116 + + 59 +
    -   + +
    -
     
    +
    + 60 + +
    + + + tx, err := etherman.SetDataAvailabilityProtocol(auth.From, daAddress) +
    - 459 + + 61 +
    -   - batchNumber := uint64(42) + + + if err != nil {
    - 460 + + 62 +
    -   - _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num,wip) VALUES ($1, FALSE), ($2, FALSE), ($3, FALSE)", batchNumber, batchNumber+1, batchNumber+2) + + + return err
    - 461 + + 63 +
    -   - require.NoError(err) + + + }
    - 462 + + 64 +
    + - 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 + + 65 +
    -   - // proof with `generating_since` older than interval + + + log.Infof("Transaction to set new data availability protocol sent. Hash: %s", tx.Hash())
    - 464 + + 66 +
    -   - now := time.Now().Round(time.Microsecond) + + +
    - 465 + + 67 +
    -   - oneHourAgo := now.Add(-time.Hour).Round(time.Microsecond) + + + return nil
    + 68 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/cardonagenesis.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -1,109 +0,0 @@
    - 496 + + 1 +
    -   - _, err = testState.Exec(ctx, addGeneratedProofSQL, olderNotGenProof.BatchNumber, olderNotGenProof.BatchNumberFinal, olderNotGenProof.Proof, olderNotGenProof.ProofID, olderNotGenProof.InputProver, olderNotGenProof.Prover, olderNotGenProof.ProverID, olderNotGenProof.GeneratingSince, oneHourAgo, oneHourAgo) + - + package config
    - 497 + + 2 +
    -   - require.NoError(err) + - +
    - 498 + + 3 +
    -   -
    + - + // CardonaNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup
    - 499 + + 4 +
    - + - _, err = testState.CleanupLockedProofs(ctx, "1m", nil) + - + const CardonaNetworkConfigJSON = `
    - 500 + + 5 +
    -   -
    + - + {
    - 501 + + 6 +
    -   - require.NoError(err) + - + "l1Config": {
    - 502 + + 7 +
    - + - 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") + - + "polygonZkEVMAddress": "0xA13Ddb14437A8F34897131367ad3ca78416d6bCa",
    - 503 + + 8 +
    -   - require.NoError(err) + - + "polygonZkEVMBridgeAddress": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
    - 504 + + 9 +
    -   - proofs := make([]state.Proof, 0, len(rows.RawValues())) + - + "polygonZkEVMGlobalExitRootAddress": "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF",
    - 505 + + 10 +
    -   - for rows.Next() { + - + "polTokenAddress": "0x6a7c3F4B0651d6DA389AD1d11D962ea458cDCA70",
    -
     
    -
    - 881 + + 11 +
    -   - if err != nil { + - + "polygonRollupManagerAddress": "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff",
    - 882 + + 12 +
    -   - panic(err) + - + "chainId": 11155111
    - 883 + + 13 +
    -   - } + - + },
    - 884 + + 14 +
    - + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) + - + "genesisBlockNumber": 4789190,
    - + + 15 -
    -   -
    +
    +
    + - + "root": "0x91dfcdeb628dfdc51f3a2ee38cb17c78581e4e7ff91bcc2e327d24a9dfa46982",
    - + + 16 -
    -   -
    +
    +
    + - + "genesis": [
    - + + 17 -
    -   -
    +
    +
    + - + {
    - + + 18 -
    -   -
    +
    +
    + - + "contractName": "PolygonZkEVMDeployer",
    - 885 + + 19 +
    -   -
    + - + "balance": "0",
    - 886 + + 20 +
    -   - dbTx, err := testState.BeginStateTransaction(ctx) + - + "nonce": "4",
    - 887 + + 21 +
    -   - require.NoError(t, err) + - + "address": "0x36810012486fc134D0679c07f85fe5ba5A087D8C",
    -
     
    +
    + 22 + +
    + - + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033", +
    - 1078 + + 23 +
    -   - if err != nil { + - + "storage": {
    - 1079 + + 24 +
    -   - panic(err) + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000ff6250d0e86a2465b0c1bf8e36409503d6a26963"
    - 1080 + + 25 +
    -   - } + - + }
    - 1081 + + 26 +
    - + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) + - + },
    - + + 27 -
    -   -
    +
    +
    + - + {
    - + + 28 -
    -   -
    +
    +
    + - + "contractName": "ProxyAdmin",
    - + + 29 -
    -   -
    +
    +
    + - + "balance": "0",
    - + + 30 -
    -   -
    +
    +
    + - + "nonce": "1",
    - 1082 + + 31 +
    -   -
    + - + "address": "0x85cEB41028B1a5ED2b88E395145344837308b251",
    - 1083 + + 32 +
    -   - dbTx, err := testState.BeginStateTransaction(ctx) + - + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033",
    - 1084 + + 33 +
    -   - require.NoError(t, err) + - + "storage": {
    -
     
    +
    + 34 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000dbc6981a11fc2b000c635bfa7c47676b25c87d39" +
    - 1256 + + 35 +
    -   - if err != nil { + - + }
    - 1257 + + 36 +
    -   - panic(err) + - + },
    - 1258 + + 37 +
    -   - } + - + {
    - 1259 + + 38 +
    - + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) + - + "contractName": "PolygonZkEVMBridge implementation",
    - + + 39 -
    -   -
    +
    +
    + - + "balance": "0",
    - + + 40 -
    -   -
    +
    +
    + - + "nonce": "1",
    - + + 41 -
    -   -
    +
    +
    + - + "address": "0x8BD36ca1A55e389335004872aA3C3Be0969D3aA7",
    - + + 42 -
    -   -
    +
    +
    + - + "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033"
    - 1260 + + 43 +
    -   -
    + - + },
    - 1261 + + 44 +
    -   - dbTx, err := testState.BeginStateTransaction(ctx) + - + {
    - 1262 + + 45 +
    -   - require.NoError(t, err) + - + "contractName": "PolygonZkEVMBridge proxy",
    -
     
    +
    + 46 + +
    + - + "balance": "200000000000000000000000000", +
    - 1371 + + 47 +
    -   - require.NoError(t, dbTx.Commit(ctx)) + - + "nonce": "1",
    - 1372 + + 48 +
    -   - } + - + "address": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
    - 1373 + + 49 +
    -   -
    + - + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033",
    - 1374 + + 50 +
    - + - func TestGetBatchL2DataByNumber(t *testing.T) { + - + "storage": {
    - 1375 + + 51 +
    - + - // Init database instance + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1376 + + 52 +
    - + - initOrResetDB() + - + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1377 + + 53 +
    - + - ctx := context.Background() + - + "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100",
    - 1378 + + 54 +
    - + - tx, err := testState.BeginStateTransaction(ctx) + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251",
    - 1379 + + 55 +
    - + - require.NoError(t, err) + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000008bd36ca1a55e389335004872aa3c3be0969d3aa7"
    - 1380 + + 56 +
    - + - defer func() { require.NoError(t, tx.Commit(ctx)) }() + - + }
    - 1381 + + 57 +
    - + -
    + - + },
    - 1382 + + 58 +
    - + - // empty case + - + {
    - 1383 + + 59 +
    - + - var batchNum uint64 = 4 + - + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation",
    - 1384 + + 60 +
    - + - const ( + - + "balance": "0",
    - 1385 + + 61 +
    - + - openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)" + - + "nonce": "1",
    - 1386 + + 62 +
    - + - resetBatchesSQL = "DELETE FROM state.batch" + - + "address": "0x282a631D9F3Ef04Bf1A44B4C9e8bDC8EB278917f",
    - 1387 + + 63 +
    - + - ) + - + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed58281565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed582161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033"
    - 1388 + + 64 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil) + - + },
    - 1389 + + 65 +
    - + - require.NoError(t, err) + - + {
    - 1390 + + 66 +
    - + - data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy",
    - 1391 + + 67 +
    - + - require.NoError(t, err) + - + "balance": "0",
    - 1392 + + 68 +
    - + - assert.Nil(t, data) + - + "nonce": "1",
    - 1393 + + 69 +
    - + -
    + - + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa",
    - 1394 + + 70 +
    - + - // not empty case + - + "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033",
    - 1395 + + 71 +
    - + - expectedData := []byte("foo bar") + - + "storage": {
    - 1396 + + 72 +
    - + - batchNum = 5 + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251",
    - 1397 + + 73 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000282a631d9f3ef04bf1a44b4c9e8bdc8eb278917f"
    - 1398 + + 74 +
    - + - require.NoError(t, err) + - + }
    - 1399 + + 75 +
    - + - actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + },
    - 1400 + + 76 +
    - + - require.NoError(t, err) + - + {
    - 1401 + + 77 +
    - + - assert.Equal(t, expectedData, actualData) + - + "contractName": "PolygonZkEVMTimelock",
    - 1402 + + 78 +
    - + -
    + - + "balance": "0",
    - 1403 + + 79 +
    - + - multiGet := []uint64{uint64(4), uint64(5), uint64(6)} + - + "nonce": "1",
    - 1404 + + 80 +
    - + - allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx) + - + "address": "0xdbC6981a11fc2B000c635bFA7C47676b25C87D39",
    - 1405 + + 81 +
    - + - require.NoError(t, err) + - + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033",
    - 1406 + + 82 +
    - + - require.Equal(t, expectedData, allData[uint64(5)]) + - + "storage": {
    - 1407 + + 83 +
    - + -
    + - + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10",
    - 1408 + + 84 +
    - + - // Force backup + - + "0xf587dde6f8846415188f807710a3304f72092565918b30307d60efdc8014f20b": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1409 + + 85 +
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) + - + "0x07020fe9de9b8274d1e6cc0668a6f6344a870f35e5a847590c8069dfa85ac78f": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1410 + + 86 +
    - + - require.NoError(t, err) + - + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 1411 + + 87 +
    - + -
    + - + "0xc8e266e0814671642b74f3807affd27009fcc23f713ea92d1743e0ee0c1e7603": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1412 + + 88 +
    - + - // Get batch 4 from backup + - + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 1413 + + 89 +
    - + - batchNum = 4 + - + "0x9b3efc411c5f69533db363941e091f6f3af8b7e306525413577a56d27e5dbe73": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1414 + + 90 +
    - + - data, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 1415 + + 91 +
    - + - require.NoError(t, err) + - + "0xa2001bdd6a5944149e83176d089ee9a8246bd56aecf38fe4d6c66f5fbac18675": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 1416 + + 92 +
    - + - assert.Nil(t, data) + - + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5"
    - 1417 + + 93 +
    - + -
    + - + }
    - 1418 + + 94 +
    - + - // Get batch 5 from backup + - + },
    - 1419 + + 95 +
    - + - batchNum = 5 + - + {
    - 1420 + + 96 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + "accountName": "keyless Deployer",
    - 1421 + + 97 +
    - + - require.NoError(t, err) + - + "balance": "0",
    - 1422 + + 98 +
    - + - assert.Equal(t, expectedData, actualData) + - + "nonce": "1",
    - 1423 + + 99 +
    - + -
    + - + "address": "0x1754175c450BEbB9B6E14dEe542649c0402A25d2"
    - 1424 + + 100 +
    - + - // Update batch 5 and get it from backup + - + },
    - 1425 + + 101 +
    - + - expectedData = []byte("new foo bar") + - + {
    - 1426 + + 102 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) + - + "accountName": "deployer",
    - 1427 + + 103 +
    - + - require.NoError(t, err) + - + "balance": "100000000000000000000000",
    - 1428 + + 104 +
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) + - + "nonce": "8",
    - 1429 + + 105 +
    - + - require.NoError(t, err) + - + "address": "0xff6250d0E86A2465B0C1bF8e36409503d6a26963"
    - 1430 + + 106 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + }
    - 1431 + + 107 +
    - + - require.NoError(t, err) + - + ]
    - 1432 + + 108 +
    - + - assert.Equal(t, expectedData, actualData) + - + }
    - 1433 + + 109 +
    - + - } + - + ` +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -255370,33 +25505,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -255406,12 +25541,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/proof.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - @@ -256028,359 +25988,532 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
     
    - 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) { +
    -
    @@ -25,9 +25,9 @@
    -
    - 25 - -
    -   - return exists, nil -
    -
    - 26 - -
    -   - } -
    +
    @@ -2,6 +2,8 @@
    - 27 + 2
    @@ -255458,444 +25573,289 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 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 + 3
      - p.batch_num_final, + import (
    -
    @@ -39,7 +39,7 @@
    -
    - 39 + 4
      - p.generating_since, + "bytes"
    - 40 + + -
    +
    +
      - p.created_at, +
    - 41 + + -
    +
    +
      - p.updated_at -
    -
    - 42 - -
    - - - FROM state.batch_proof p +
    - 43 + 5
      - WHERE batch_num = $1 AND generating_since IS NULL AND + "path/filepath"
    - 44 + 6
      - EXISTS (SELECT 1 FROM state.sequences s1 WHERE s1.from_batch_num = p.batch_num) AND + "strings"
    - 45 + 7
      - EXISTS (SELECT 1 FROM state.sequences s2 WHERE s2.to_batch_num = p.batch_num_final) +
    -
    @@ -48,7 +48,7 @@
    +
    @@ -21,6 +24,7 @@
    - 48 + 21
      - var proof *state.Proof = &state.Proof{} + "github.com/0xPolygonHermez/zkevm-node/state"
    - 49 + 22
      -
    + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
    - 50 + 23
      - e := p.getExecQuerier(dbTx) + "github.com/0xPolygonHermez/zkevm-node/synchronizer"
    - 51 + + -
    - - - row := e.QueryRow(ctx, getProofReadyForFinalSQL, lastVerfiedBatchNumber+1) +
    +
    +   +
    - 52 + 24
      - err := row.Scan(&proof.BatchNumber, &proof.BatchNumberFinal, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover, &proof.ProverID, &proof.GeneratingSince, &proof.CreatedAt, &proof.UpdatedAt) + "github.com/mitchellh/mapstructure"
    - 53 + 25
      -
    + "github.com/spf13/viper"
    - 54 + 26
      - if errors.Is(err, pgx.ErrNoRows) { + "github.com/urfave/cli/v2"
    -
    @@ -60,15 +60,15 @@
    +
    @@ -31,7 +35,7 @@
    - 60 + 31
      - return proof, err + FlagYes = "yes"
    - 61 + 32
      - } + // FlagCfg is the flag for cfg.
    - 62 + 33
      -
    -
    -
    - 63 - -
    - - - // GetBatchProofsToAggregate return the next 2 batch proofs that it are possible to aggregate + FlagCfg = "cfg"
    - 64 + 34
    - - 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{} + // FlagNetwork is the flag for the network name. Valid values: ["testnet", "mainnet", "cardona", "custom"].
    - 68 + 35
      - ) + FlagNetwork = "network"
    - 69 + 36
      -
    + // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
    - 70 + 37
      - // TODO: add comments to explain the query + FlagCustomNetwork = "custom-network-file"
    - 71 - -
    - - - const getBatchProofsToAggregateSQL = ` -
    +
    +
    @@ -183,3 +187,19 @@
    - 72 + 183
      - SELECT + }
    - 73 + 184
      - p1.batch_num as p1_batch_num, + return cfg, nil
    - 74 + 185
      - 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 +
    +
    +
    +
    +
    + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - + + 2 -
    +
    +
     
    - + + 3 -
    +
    +
    +   + import ( +
    +
    + 4 + +
    +   + "bytes" +
    +
    + 5 + +
    + + + "crypto/ecdsa" +
    +
    + 6 + +
    + + + "os" +
    +
    + 7 + +
    +   + "path/filepath" +
    +
    + 8 + +
    +   + "strings" +
    +
    + 9 + +
     
    +
     
    +
    - 97 + 24
      - ORDER BY p1.batch_num ASC + "github.com/0xPolygonHermez/zkevm-node/state"
    - 98 + 25 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" +
    +
    + 26
      - LIMIT 1 + "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"
    +
     
    +
    - 99 + 35
      - ` + FlagYes = "yes"
    - 100 + 36
      -
    + // FlagCfg is the flag for cfg.
    - 101 + 37
      - e := p.getExecQuerier(dbTx) + FlagCfg = "cfg"
    - 102 + + 38 +
    - - - row := e.QueryRow(ctx, getBatchProofsToAggregateSQL) + + + // FlagNetwork is the flag for the network name. Valid values: ["custom"].
    - 103 + 39
      - err := row.Scan( + FlagNetwork = "network"
    - 104 + 40
      - &proof1.BatchNumber, &proof1.BatchNumberFinal, &proof1.Proof, &proof1.ProofID, &proof1.InputProver, &proof1.Prover, &proof1.ProverID, &proof1.GeneratingSince, &proof1.CreatedAt, &proof1.UpdatedAt, + // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
    - 105 + 41
      - &proof2.BatchNumber, &proof2.BatchNumberFinal, &proof2.Proof, &proof2.ProofID, &proof2.InputProver, &proof2.Prover, &proof2.ProverID, &proof2.GeneratingSince, &proof2.CreatedAt, &proof2.UpdatedAt) + FlagCustomNetwork = "custom-network-file"
    -
    @@ -113,47 +128,50 @@
    +
     
    - 113 + 187
      - return proof1, proof2, err + }
    - 114 + 188
      - } + return cfg, nil
    - 115 + 189
      + } +
    +
    + 190 + +
    + +
    - 116 + + 191 +
    - - - // AddBatchProof adds a batch proof to the storage + + + // NewKeyFromKeystore creates a private key from a keystore file
    - 117 + + 192 +
    - - - func (p *PostgresStorage) AddBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { + + + func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error) {
    - 118 + + 193 +
    - - - 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)" + + + if cfg.Path == "" && cfg.Password == "" {
    - 119 + + 194 +
    -   - e := p.getExecQuerier(dbTx) + + + return nil, nil
    - 120 + + 195 +
    -   - now := time.Now().UTC().Round(time.Microsecond) + + + }
    - 121 + + 196 +
    - - - _, err := e.Exec(ctx, addBatchProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now, now) + + + keystoreEncrypted, err := os.ReadFile(filepath.Clean(cfg.Path))
    - 122 + + 197 +
    -   - return err + + + if err != nil {
    - 123 + + 198 +
    -   - } + + + return nil, err
    - 124 + + 199 +
    -   -
    + + + }
    - 125 + + 200 +
    - - - // UpdateBatchProof updates a batch proof in the storage + + + key, err := keystore.DecryptKey(keystoreEncrypted, cfg.Password)
    - 126 + + 201 +
    - - - func (p *PostgresStorage) UpdateBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { + + + if err != nil {
    - 127 + + 202 +
    - - - 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" + + + return nil, err
    - 128 + + 203 +
    -   - e := p.getExecQuerier(dbTx) + + + }
    - 129 + + 204 +
    -   - now := time.Now().UTC().Round(time.Microsecond) + + + return key.PrivateKey, nil
    - 130 + + 205 +
    - - - _, err := e.Exec(ctx, addBatchProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now) + + + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -256395,162 +26528,162 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - - - - - - + - - - - @@ -256564,427 +26697,393 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + - - - - - - - - - - - - - - - - -
    +
    @@ -65,6 +66,10 @@
    - 131 + 65
      - return err + expectedValue: true,
    - 132 + 66
      - } + },
    - 133 + 67
      -
    + {
    - 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" +
    +
    +   +
    - 137 + 68
      - e := p.getExecQuerier(dbTx) + path: "Synchronizer.L1BlockCheck.Enabled",
    - 138 + + 69 +
    - - - _, err := e.Exec(ctx, deleteBatchProofSQL, batchNumber, batchNumberFinal) +   + expectedValue: true,
    - 139 + 70
      - return err + },
    +
    @@ -76,7 +81,6 @@
    +
    - 140 + 76
      - } + path: "Synchronizer.L2Synchronization.Enabled",
    - 141 + 77
      -
    + expectedValue: true,
    - 142 + + 78 +
    - - - // CleanupBatchProofs deletes from the storage the batch proofs up to the specified batch number included. +   + },
    - 143 + + 79 +
    - - func (p *PostgresStorage) CleanupBatchProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error { +
    - 144 + + 80 +
    - - - const deleteBatchProofSQL = "DELETE FROM state.batch_proof WHERE batch_num_final <= $1" +   + {
    - + + 81 -
    +
    +
      -
    + path: "Sequencer.DeletePoolTxsL1BlockConfirmations",
    - 145 + 82
      - e := p.getExecQuerier(dbTx) + expectedValue: uint64(100),
    - 146 - -
    - - - _, err := e.Exec(ctx, deleteBatchProofSQL, batchNumber) -
    +
    +
    @@ -198,6 +202,10 @@
    - 147 + 198
      - return err + expectedValue: uint64(80000),
    - 148 + 199
      - } + },
    - 149 + 200
      -
    + {
    - 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 + 201
      - if err != nil { + path: "SequenceSender.SequenceL1BlockConfirmations",
    - 154 + 202
      - return 0, err + expectedValue: uint64(32),
    - 155 + 203
      - } + },
    - 156 - -
    - - - sql := fmt.Sprintf("DELETE FROM state.batch_proof WHERE generating_since < (NOW() - interval '%s')", interval) -
    +
    +
    @@ -207,19 +215,19 @@
    - 157 + 207
      - e := p.getExecQuerier(dbTx) + },
    - 158 + 208
      - ct, err := e.Exec(ctx, sql) + {
    - 159 + 209
      - if err != nil { + path: "NetworkConfig.L1Config.L1ChainID",
    -
    @@ -162,9 +180,10 @@
    -
    - 162 + + 210 +
    -   - return ct.RowsAffected(), nil + - + expectedValue: uint64(5),
    - 163 + 211
      - } + },
    - 164 + 212
      -
    + {
    - 165 + + 213 +
    - - - // DeleteUngeneratedBatchProofs deletes ungenerated proofs. This method is meant to be use during aggregator boot-up sequence +   + path: "NetworkConfig.L1Config.ZkEVMAddr",
    - 166 + 214
    - - func (p *PostgresStorage) DeleteUngeneratedBatchProofs(ctx context.Context, dbTx pgx.Tx) error { + expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"),
    - 167 + + 215 +
    - - - const deleteUngeneratedProofsSQL = "DELETE FROM state.batch_proof WHERE generating_since IS NOT NULL" -
    -
    - - -
      -
    + },
    - 168 + 216
      - e := p.getExecQuerier(dbTx) + {
    - 169 + 217
      - _, err := e.Exec(ctx, deleteUngeneratedProofsSQL) + path: "NetworkConfig.L1Config.PolAddr",
    - 170 + + 218 +
    -   - return err -
    -
    -
    + - + expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"),
    -
    -
    - - - - - - - - - - - - - - - + + + - - + + + - + + +
    -
     
    - 25 + 219
      - return exists, nil + },
    - 26 + 220
      - } + {
    - 27 + 221
      -
    -
    -
    - 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) { + path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr",
    - 30 + + 222 +
    - + - const getProofReadyToVerifySQL = ` + - + expectedValue: common.HexToAddress("0x4d9427DCA0406358445bC0a8F88C26b704004f74"),
    - 31 + 223
      - SELECT + },
    - 32 + 224
      - p.batch_num, + {
    - 33 + 225
      - p.batch_num_final, + path: "Etherman.MultiGasProvider",
    -
     
    +
    @@ -579,7 +587,8 @@
    - 39 + 579
      - p.generating_since, + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
    - 40 + 580
      - p.created_at, +
    - 41 + 581
      - p.updated_at + flagSet := flag.NewFlagSet("", flag.PanicOnError)
    - 42 + + 582 +
    - + - FROM state.proof p + - + flagSet.String(config.FlagNetwork, "testnet", "") +
    +
    + + +
    +   +
    - 43 + 583
      - WHERE batch_num = $1 AND generating_since IS NULL AND + ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
    - 44 + 584
      - EXISTS (SELECT 1 FROM state.sequences s1 WHERE s1.from_batch_num = p.batch_num) AND + cfg, err := config.Load(ctx, true)
    - 45 + 585
      - EXISTS (SELECT 1 FROM state.sequences s2 WHERE s2.to_batch_num = p.batch_num_final) + if err != nil {
    -
     
    +
    @@ -617,7 +626,8 @@
    - 48 + 617
      - var proof *state.Proof = &state.Proof{} + }()
    - 49 + 618
      -
    + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
    - 50 + 619
      - e := p.getExecQuerier(dbTx) + flagSet := flag.NewFlagSet("", flag.PanicOnError)
    - 51 + + 620 +
    - + - row := e.QueryRow(ctx, getProofReadyToVerifySQL, lastVerfiedBatchNumber+1) + - + flagSet.String(config.FlagNetwork, "testnet", "") +
    +
    + + +
    +   +
    - 52 + 621
      - err := row.Scan(&proof.BatchNumber, &proof.BatchNumberFinal, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover, &proof.ProverID, &proof.GeneratingSince, &proof.CreatedAt, &proof.UpdatedAt) + ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
    - 53 + 622
    @@ -256994,167 +27093,201 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 54 + 623
      - if errors.Is(err, pgx.ErrNoRows) { + os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c")
    +
    +
    +
    +
    + + + - - - - + + + + + + + + + - - @@ -257164,312 +27297,297 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - + + + @@ -257479,502 +27597,605 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + - - - - + + + + + + + + +
     
    - 60 + 66
      - return proof, err + expectedValue: true,
    - 61 + 67
      - } + },
    - 62 + 68
      -
    + {
    - 63 + + 69 +
    + - // GetProofsToAggregate return the next to proof that it is possible to aggregate + path: "Synchronizer.L2Synchronization.DataSourcePriority",
    - 64 + + 70 + +
    + + + expectedValue: []dataavailability.DataSourcePriority{"local", "trusted", "external"}, +
    +
    + 71 + +
    + + + }, +
    +
    + 72 +
    + - func (p *PostgresStorage) GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) { + {
    - 65 + 73
      - var ( + path: "Synchronizer.L1BlockCheck.Enabled",
    - 66 + 74
      - proof1 *state.Proof = &state.Proof{} + expectedValue: true,
    - 67 + 75
      - proof2 *state.Proof = &state.Proof{} + },
    +
     
    +
    - 68 + 81
      - ) + path: "Synchronizer.L2Synchronization.Enabled",
    - 69 + 82
      -
    + expectedValue: true,
    - 70 + 83
      - // TODO: add comments to explain the query + },
    - 71 + + -
    - + - const getProofsToAggregateSQL = ` +
    +
    +   +
    - 72 + 84
      - SELECT + {
    - 73 + 85
      - p1.batch_num as p1_batch_num, + path: "Sequencer.DeletePoolTxsL1BlockConfirmations",
    - 74 + 86
      - p1.batch_num_final as p1_batch_num_final, + expectedValue: uint64(100),
    - 90 + 202
      - p2.generating_since as p2_generating_since, + expectedValue: uint64(80000),
    - 91 + 203
      - p2.created_at as p2_created_at, + },
    - 92 + 204
      - p2.updated_at as p2_updated_at -
    -
    - 93 - -
    - + - FROM state.proof p1 INNER JOIN state.proof p2 ON p1.batch_num_final = p2.batch_num - 1 -
    -
    - 94 - -
    - + - WHERE p1.generating_since IS NULL AND p2.generating_since IS NULL AND -
    -
    - 95 - -
    - + - p1.proof IS NOT NULL AND p2.proof IS NOT NULL AND + {
    - 96 + + 205 +
    + - ( + path: "SequenceSender.MaxBatchesForL1",
    - 97 + 206
    + - EXISTS ( + expectedValue: uint64(300),
    - 98 + 207
    + - SELECT 1 FROM state.sequences s + },
    - 99 + 208
    + - WHERE p1.batch_num >= s.from_batch_num AND p1.batch_num <= s.to_batch_num AND + {
    - 100 + + 209 +
    - + - p1.batch_num_final >= s.from_batch_num AND p1.batch_num_final <= s.to_batch_num AND +   + path: "SequenceSender.SequenceL1BlockConfirmations",
    - 101 + + 210 +
    - + - p2.batch_num >= s.from_batch_num AND p2.batch_num <= s.to_batch_num AND +   + expectedValue: uint64(32),
    - 102 + + 211 +
    - + - p2.batch_num_final >= s.from_batch_num AND p2.batch_num_final <= s.to_batch_num +   + },
    - 103 + +
     
    +
    + 215 +
    - + - ) +   + },
    - 104 + + 216 +
    - + - OR +   + {
    - 105 + + 217 +
    - + - ( +   + path: "NetworkConfig.L1Config.L1ChainID",
    - 106 + + 218 +
    + - EXISTS ( SELECT 1 FROM state.sequences s WHERE p1.batch_num = s.from_batch_num) AND + expectedValue: uint64(1337),
    - 107 + + 219 +
    - + - EXISTS ( SELECT 1 FROM state.sequences s WHERE p1.batch_num_final = s.to_batch_num) AND +   + },
    - 108 + + 220 +
    - + - EXISTS ( SELECT 1 FROM state.sequences s WHERE p2.batch_num = s.from_batch_num) AND +   + {
    - 109 + + 221 +
    - + - EXISTS ( SELECT 1 FROM state.sequences s WHERE p2.batch_num_final = s.to_batch_num) +   + path: "NetworkConfig.L1Config.ZkEVMAddr",
    - 110 + + 222 +
    + - ) + expectedValue: common.HexToAddress("0x8dAF17A20c9DBA35f005b6324F493785D239719d"),
    - 111 + + 223 +
    - + - ) +   + },
    - 112 + 224
      - ORDER BY p1.batch_num ASC + {
    - 113 + 225
      - LIMIT 1 + path: "NetworkConfig.L1Config.PolAddr", +
    +
    + 226 + +
    + + + expectedValue: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"),
    - 114 + 227
      - ` + },
    - 115 + 228
      -
    + {
    - 116 + 229
      - e := p.getExecQuerier(dbTx) + path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr",
    - 117 + 230
    + - row := e.QueryRow(ctx, getProofsToAggregateSQL) + expectedValue: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
    - 118 + 231
      - err := row.Scan( + },
    - 119 + 232
      - &proof1.BatchNumber, &proof1.BatchNumberFinal, &proof1.Proof, &proof1.ProofID, &proof1.InputProver, &proof1.Prover, &proof1.ProverID, &proof1.GeneratingSince, &proof1.CreatedAt, &proof1.UpdatedAt, + {
    - 120 + 233
      - &proof2.BatchNumber, &proof2.BatchNumberFinal, &proof2.Proof, &proof2.ProofID, &proof2.InputProver, &proof2.Prover, &proof2.ProverID, &proof2.GeneratingSince, &proof2.CreatedAt, &proof2.UpdatedAt) + path: "Etherman.MultiGasProvider",
    - 128 + 587
      - return proof1, proof2, err + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
    - 129 + 588
      - } +
    - 130 + 589
      -
    + flagSet := flag.NewFlagSet("", flag.PanicOnError)
    - 131 + 590
    + - // AddGeneratedProof adds a generated proof to the storage + flagSet.String(config.FlagNetwork, "custom", "")
    - 132 + + 591 +
    + - func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { + flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "")
    - 133 + + 592 +
    - + - 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)" +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
    - 134 + 593
      - e := p.getExecQuerier(dbTx) + cfg, err := config.Load(ctx, true)
    - 135 + 594
      - now := time.Now().UTC().Round(time.Microsecond) + if err != nil {
    - 136 - -
    - + - _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now, now) -
    +
    +
     
    - 137 + 626
      - return err + }()
    - 138 + 627
      - } + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
    - 139 + 628
      -
    + flagSet := flag.NewFlagSet("", flag.PanicOnError)
    - 140 + 629
    + - // UpdateGeneratedProof updates a generated proof in the storage + flagSet.String(config.FlagNetwork, "custom", "")
    - 141 + + 630 +
    + - func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { + flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "")
    - 142 + + 631 +
    - + - 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" +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil) +
    +
    + 632 + +
    +   +
    +
    +
    + 633 + +
    +   + os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c") +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - + - + + - - - - - - + + + - - + + + + + + - - - - - - - - - - + + +
    +
    @@ -133,6 +133,7 @@
    +
    + 133 + +
    +   + AcceptEmptyClosedBatches = false
    - 143 + 134
      - e := p.getExecQuerier(dbTx) + ReprocessFullBatchOnClose = false
    - 144 + 135
      - now := time.Now().UTC().Round(time.Microsecond) + CheckLastL2BlockHashOnCloseBatch = true
    - 145 + + -
    - + - _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now) +
    +
    +   +
    - 146 + 136
      - return err +
    - 147 + 137
      - } + [Sequencer]
    - 148 + 138
      -
    + DeletePoolTxsL1BlockConfirmations = 100
    - 149 + +
    @@ -175,6 +176,7 @@
    +
    + 175 +
    - + - // DeleteGeneratedProofs deletes from the storage the generated proofs falling +   + L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
    - 150 + + 176 +
    - + - // inside the batch numbers range. +   + PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
    - 151 + + 177 +
    - + - func (p *PostgresStorage) DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error { +   + GasOffset = 80000
    - 152 + + + +
    +   +
    +
    +
    + 178 +
    - + - const deleteGeneratedProofSQL = "DELETE FROM state.proof WHERE batch_num >= $1 AND batch_num_final <= $2" +   +
    - 153 + 179
      - e := p.getExecQuerier(dbTx) + [Aggregator]
    - 154 + + 180 +
    - + - _, err := e.Exec(ctx, deleteGeneratedProofSQL, batchNumber, batchNumberFinal) +   + Host = "0.0.0.0"
    +
    @@ -189,6 +191,10 @@
    +
    - 155 + 189
      - return err + GasOffset = 0
    - 156 + 190
      - } + UpgradeEtrogBatchNumber = 0
    - 157 + 191
    +   + BatchProofL1BlockConfirmations = 2 +
    +
    + + +
     
    - 158 + + -
    - + - // CleanupGeneratedProofs deletes from the storage the generated proofs up to +
    +
    +   +
    - 159 + + -
    - + - // the specified batch number included. +
    +
    +   +
    - 160 + + -
    - + - func (p *PostgresStorage) CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error { +
    +
    +   +
    - 161 + + 192 +
    - + - const deleteGeneratedProofSQL = "DELETE FROM state.proof WHERE batch_num_final <= $1" +   +
    - 162 + 193
      - e := p.getExecQuerier(dbTx) + [L2GasPriceSuggester]
    - 163 + + 194 +
    - + - _, err := e.Exec(ctx, deleteGeneratedProofSQL, batchNumber) +   + Type = "follower" +
    +
    +
    +
    +
    + + + + + - - - - - - + + + - - @@ -257984,102 +28205,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -258089,12 +28310,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/transaction.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/mainnetgenesis.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 164 + 133
      - return err + AcceptEmptyClosedBatches = false
    - 165 + 134
      - } + ReprocessFullBatchOnClose = false
    - 166 + 135
      -
    + CheckLastL2BlockHashOnCloseBatch = true
    - 167 + + 136 +
    + - // CleanupLockedProofs deletes from the storage the proofs locked in generating + DataSourcePriority = ["local","trusted","external"]
    - 168 + + 137 +
    - + - // state for more than the provided threshold. +   +
    - 169 + + 138 +
    - + - func (p *PostgresStorage) CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) { +   + [Sequencer]
    - 170 + 139
      - interval, err := toPostgresInterval(duration) + DeletePoolTxsL1BlockConfirmations = 100
    +
     
    +
    - 171 + 176
      - if err != nil { + L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
    - 172 + 177
      - return 0, err + PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
    - 173 + 178
      - } + GasOffset = 80000
    - 174 + + 179 +
    + - sql := fmt.Sprintf("DELETE FROM state.proof WHERE generating_since < (NOW() - interval '%s')", interval) + MaxBatchesForL1 = 300
    - 175 + 180
      - e := p.getExecQuerier(dbTx) +
    - 176 + 181
      - ct, err := e.Exec(ctx, sql) + [Aggregator]
    - 177 + 182
      - if err != nil { + Host = "0.0.0.0"
    - 180 + 191
      - return ct.RowsAffected(), nil + GasOffset = 0
    - 181 + 192
      - } + UpgradeEtrogBatchNumber = 0
    - 182 + 193
      -
    + BatchProofL1BlockConfirmations = 2
    - 183 + + 194 +
    + - // DeleteUngeneratedProofs deletes ungenerated proofs. + SettlementBackend = "agglayer"
    - 184 + + 195 +
    + - // This method is meant to be use during aggregator boot-up sequence + AggLayerTxTimeout = "5m"
    - 185 + + 196 +
    + - func (p *PostgresStorage) DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error { + AggLayerURL = "http://zkevm-agglayer"
    - 186 + 197
    + - const deleteUngeneratedProofsSQL = "DELETE FROM state.proof WHERE generating_since IS NOT NULL" + SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
    - 187 + 198
      - e := p.getExecQuerier(dbTx) +
    - 188 + 199
      - _, err := e.Exec(ctx, deleteUngeneratedProofsSQL) + [L2GasPriceSuggester]
    - 189 + 200
      - return err + Type = "follower"
    -
    @@ -63,16 +63,13 @@
    +
    @@ -1,108 +0,0 @@
    - 63 + + 1 +
    -   - } else if err != nil { + - + package config
    - 64 + + 2 +
    -   - return nil, err + - +
    - 65 + + 3 +
    -   - } + - + // MainnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup
    - 66 + 4
    - -
    + const MainnetNetworkConfigJSON = `
    - 67 + 5
    - - defer rows.Close() + {
    - 68 + 6
    - -
    + "l1Config" : {
    - 69 + + 7 +
    -   - hashes := make([]common.Hash, 0, len(rows.RawValues())) + - + "chainId": 1,
    - 70 + + 8 +
    -   - for rows.Next() { + - + "polygonZkEVMAddress": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987",
    - 71 + + 9 +
    -   - var hash string + - + "polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
    - 72 + + 10 +
    - - if err := rows.Scan(&hash); err != nil { + "polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6",
    - + + 11 -
    -   -
    +
    +
    + - + "polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb"
    - 73 + + 12 +
    -   - return nil, err + - + },
    - 74 + + 13 +
    -   - } + - + "root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9",
    - 75 + 14
    - -
    + "genesisBlockNumber": 16896721,
    - 76 + + 15 +
    -   - hashes = append(hashes, common.HexToHash(hash)) + - + "genesis": [
    - 77 + + 16 +
    -   - } + - + {
    - 78 + + 17 +
    -   -
    + - + "contractName": "PolygonZkEVMDeployer",
    -
    @@ -111,16 +108,13 @@
    +
    + 18 + +
    + - + "balance": "0", +
    - 111 + + 19 +
    -   - } else if err != nil { + - + "nonce": "4",
    - 112 + + 20 +
    -   - return nil, err + - + "address": "0xCB19eDdE626906eB1EE52357a27F62dd519608C2",
    - 113 + + 21 +
    -   - } + - + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033",
    - 114 + 22
    - -
    + "storage": {
    - 115 + 23
    - - defer rows.Close() + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000004c1665d6651ecefa59b9b3041951608468b18891"
    - 116 + 24
    - -
    + }
    - 117 + + 25 +
    -   - hashes := make([]common.Hash, 0, len(rows.RawValues())) + - + },
    - 118 + + 26 +
    -   - for rows.Next() { + - + {
    - 119 + + 27 +
    -   - var hash string + - + "contractName": "ProxyAdmin",
    - 120 + + 28 +
    - - if err := rows.Scan(&hash); err != nil { + "balance": "0",
    - + + 29 -
    -   -
    +
    +
    + - + "nonce": "1",
    - 121 + + 30 +
    -   - return nil, err + - + "address": "0x0F99738B2Fc14D77308337f3e2596b63aE7BCC4A",
    - 122 + + 31 +
    -   - } + - + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033",
    - 123 + 32
    - -
    + "storage": {
    - 124 + + 33 +
    -   - hashes = append(hashes, common.HexToHash(hash)) + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000bba0935fa93eb23de7990b47f0d96a8f75766d13"
    - 125 + + 34 +
    -   - } + - + }
    - 126 + + 35 +
    -   -
    + - + },
    -
    + + + 36 + + +
    + - + {
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
    -
     
    - 63 + + 37 +
    -   - } else if err != nil { + - + "contractName": "PolygonZkEVMBridge implementation",
    - 64 + + 38 +
    -   - return nil, err + - + "balance": "0",
    - 65 + + 39 +
    -   - } + - + "nonce": "1",
    - + + 40 -
    -   -
    +
    +
    + - + "address": "0x5ac4182A1dd41AeEf465E40B82fd326BF66AB82C",
    - + + 41 -
    -   -
    +
    +
    + - + "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033"
    - + + 42 -
    -   -
    +
    +
    + - + },
    - 66 + + 43 +
    -   - hashes := make([]common.Hash, 0, len(rows.RawValues())) + - + {
    - 67 + + 44 +
    -   - for rows.Next() { + - + "contractName": "PolygonZkEVMBridge proxy",
    - 68 + + 45 +
    -   - var hash string + - + "balance": "200000000000000000000000000",
    - 69 + + 46 +
    - + - err := rows.Scan(&hash) + - + "nonce": "1",
    - 70 + + 47 +
    - + - if err != nil { + - + "address": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe",
    - 71 + + 48 +
    -   - return nil, err + - + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033",
    - 72 + + 49 +
    -   - } + - + "storage": {
    - + + 50 -
    -   -
    +
    +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 73 + + 51 +
    -   - hashes = append(hashes, common.HexToHash(hash)) + - + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 74 + + 52 +
    -   - } + - + "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100",
    - 75 + + 53 +
    -   -
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a",
    -
     
    +
    + 54 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000005ac4182a1dd41aeef465e40b82fd326bf66ab82c" +
    - 108 + + 55 +
    -   - } else if err != nil { + - + }
    - 109 + + 56 +
    -   - return nil, err + - + },
    - 110 + + 57 +
    -   - } + - + {
    - + + 58 -
    -   -
    +
    +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation",
    - + + 59 -
    -   -
    +
    +
    + - + "balance": "0",
    - + + 60 -
    -   -
    +
    +
    + - + "nonce": "1",
    - 111 + + 61 +
    -   - hashes := make([]common.Hash, 0, len(rows.RawValues())) + - + "address": "0x0200143Fa295EE4dffEF22eE2616c2E008D81688",
    - 112 + + 62 +
    -   - for rows.Next() { + - + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033"
    - 113 + + 63 +
    -   - var hash string + - + },
    - 114 + + 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 +
    - + - err := rows.Scan(&hash) + - + "balance": "0",
    - 115 + + 78 +
    - + - if err != nil { + - + "nonce": "1",
    - 116 + + 79 +
    -   - return nil, err + - + "address": "0xBBa0935Fa93Eb23de7990b47F0D96a8f75766d13",
    - 117 + + 80 +
    -   - } + - + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033",
    - + + 81 -
    -   -
    +
    +
    + - + "storage": {
    - 118 + + 82 +
    -   - hashes = append(hashes, common.HexToHash(hash)) + - + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x00000000000000000000000000000000000000000000000000000000000d2f00",
    - 119 + + 83 +
    -   - } + - + "0x33d4aa03df3f12c4f615b40676f67fdafecd3edb5a9c0ca2a47a923dae33a023": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 120 + + 84 +
    -   -
    -
    -
    -
    + - + "0x9fa2d8034dbcb437bee38d61fbd100910e1342ffc07f128aa1b8e6790b7f3f68": "0x0000000000000000000000000000000000000000000000000000000000000001",
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -14,7 +14,6 @@
    - 14 + + 85 +
    -   - // - VerifiedBatches + - + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 15 + + 86 +
    -   - // - Entries in exit_root table + - + "0x531a7c25761aa4b0f2310edca9bb25e1e3ceb49ad4b0422aec866b3ce7567c87": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 16 + + 87 +
    -   - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) + - + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 17 + 88
    - -
    + "0xedbedc78c4240c7613622a35de050b48bd6c6d9a31b3d485b68fbbed54a4802d": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 18 + + 89 +
    -   - if err != nil { + - + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
    - 19 + + 90 +
    -   - log.Error("error resetting L1BlockNumber. Error: ", err) + - + "0x76616448da8d124a07383c26a6b2433b3259de946aa40f51524ec96ee05e871a": "0x0000000000000000000000000000000000000000000000000000000000000001",
    - 20 + + 91 +
    -   - return err + - + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5"
    -
    @@ -30,5 +29,4 @@
    -
    - 30 + + 92 +
    -   - // is going to be a commit or a rollback. So is going to be rebuild on the next + - + }
    - 31 + + 93 +
    -   - // request that needs it. + - + },
    - 32 + + 94 +
    -   - s.l1InfoTree = nil + - + {
    - 33 + 95
    - - s.l1InfoTreeRecursive = nil + "accountName": "keyless Deployer",
    - 34 + + 96 +
    -   - } -
    -
    -
    + - + "balance": "0",
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259113,21 +29417,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 14 + + 97 +
    -   - // - VerifiedBatches + - + "nonce": "1",
    - 15 + + 98 +
    -   - // - Entries in exit_root table + - + "address": "0x9d90066e7478496e2284E54c3548106bb4F90E50"
    - 16 + + 99 +
    -   - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) + - + },
    - + + 100 -
    -   -
    +
    +
    + - + {
    - 17 + + 101 +
    -   - if err != nil { + - + "accountName": "deployer",
    - 18 + + 102 +
    -   - log.Error("error resetting L1BlockNumber. Error: ", err) + - + "balance": "0",
    - 19 + + 103 +
    -   - return err + - + "nonce": "8",
    -
     
    -
    - 29 + + 104 +
    -   - // is going to be a commit or a rollback. So is going to be rebuild on the next + - + "address": "0x4c1665d6651ecEfa59B9B3041951608468b18891"
    - 30 + + 105 +
    -   - // request that needs it. + - + }
    - 31 + + 106 +
    -   - s.l1InfoTree = nil + - + ]
    - + + 107 -
    -   -
    +
    +
    + - + }
    - 32 + + 108 +
    -   - } + - + `
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go - RENAMED - -
    -
    @@ -259135,74 +29424,64 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259338,457 +29617,323 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -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 + + -
    +
    +
     
    @@ -259278,53 +29557,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 - -
    - - - } -
    +
    +
    -
    + +
    +   +
    -
    -
    - - - - - - - - - - - @@ -259802,203 +29947,203 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -260012,68 +30157,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -260137,23 +30277,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -260167,68 +30307,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -260378,12 +30513,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/errors.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    - 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 + + -
    +
    +
      - } +
    -
    @@ -20,13 +20,6 @@
    +
    @@ -25,17 +25,16 @@
    - 20 + 25
      - ErrROMUnknown = fmt.Errorf("unknown ROM error") +
    - 21 + 26
      - // ErrCodeROMUnknown indicates an unknown ROM error + type network string
    - 22 + 27
      - ErrCodeROMUnknown = RomError(math.MaxInt32) -
    -
    - 23 - -
    - -
    - 24 - -
    - - - // ErrROMBlobUnspecified indicates an unspecified ROM blob error -
    -
    - 25 - -
    - - - ErrROMBlobUnspecified = fmt.Errorf("unspecified ROM blob error") -
    -
    - 26 - -
    - - - // ErrROMBlobUnknown indicates an unknown ROM blob error -
    -
    - 27 + 28
    - - ErrROMBlobUnknown = fmt.Errorf("unknown ROM blob error") + const mainnet network = "mainnet"
    - 28 + 29
    - - // ErrCodeROMBlobUnknown indicates an unknown ROM blob error + const testnet network = "testnet"
    - 29 + 30
    - - ErrCodeROMBlobUnknown = RomBlobError(math.MaxInt32) + const cardona network = "cardona"
    - 30 + 31
      - ) + const custom network = "custom"
    - 31 + 32
    @@ -260522,1427 +30617,1070 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 32 + 33
      - // RomErr returns an instance of error related to the ExecutorError + // GenesisFromJSON is the config file for network_custom
    -
    @@ -103,9 +96,6 @@
    -
    - 103 + 34
      - return runtime.ErrInvalidTxChangeL2BlockLimitTimestamp + type GenesisFromJSON struct {
    - 104 + 35
      - case RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP: + // L1: root hash of the genesis block
    - 105 + 36
      - return runtime.ErrInvalidTxChangeL2BlockMinTimestamp -
    -
    - 106 - -
    - - - // Start of V3 errors + Root string `json:"root"`
    - 107 + + 37 +
    - - case RomError_ROM_ERROR_INVALID_L1_INFO_TREE_INDEX: + // L1: block number of the genesis block
    - 108 + + 38 +
    - - return runtime.ErrInvalidL1InfoTreeIndex -
    -
    - 109 - -
    -   - } -
    -
    - 110 - -
    -   - return ErrROMUnknown -
    -
    - 111 - -
    -   - } -
    -
    -
    @@ -182,8 +172,6 @@
    -
    - 182 - -
    -   - return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP + GenesisBlockNum uint64 `json:"genesisBlockNumber"`
    - 183 + + -
    +
    +
      - case runtime.ErrInvalidTxChangeL2BlockMinTimestamp: +
    - 184 + + -
    +
    +
      - return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP -
    -
    - 185 - -
    - - - case runtime.ErrInvalidL1InfoTreeIndex: -
    -
    - 186 - -
    - - - return RomError_ROM_ERROR_INVALID_L1_INFO_TREE_INDEX +
    - 187 + 39
      - } + // L2: List of states contracts used to populate merkle tree at initial state
    - 188 + 40
      - return ErrCodeROMUnknown + Genesis []genesisAccountFromJSON `json:"genesis"`
    - 189 + 41
      - } + // L1: configuration of the network
    -
    @@ -468,49 +456,7 @@
    +
    @@ -60,12 +59,6 @@
    - 468 + 60
      - return runtime.ErrExecutorErrorInvalidUpdateMerkleTree + func (cfg *Config) loadNetworkConfig(ctx *cli.Context) {
    - 469 + 61
      - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR: + var networkJSON string
    - 470 + 62
      - return runtime.ErrExecutorErrorSMMainInvalidTxStatusError -
    -
    - 471 - -
    - - - // Start of V3 errors -
    -
    - 472 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT: -
    -
    - 473 - -
    - - - return runtime.ErrExecutorErrorInvalidPreviousL1InfoTreeRoot -
    -
    - 474 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA: -
    -
    - 475 - -
    - - - return runtime.ErrExecutorErrorInvalidForcedHashData -
    -
    - 476 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT: -
    -
    - 477 - -
    - - - return runtime.ErrExecutorErrorInvalidForcedDataGlobalExitRoot -
    -
    - 478 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1: -
    -
    - 479 - -
    - - - return runtime.ErrExecutorErrorInvalidForcedDataBlockHashL1 -
    -
    - 480 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT: -
    -
    - 481 - -
    - - - return runtime.ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot -
    -
    - 482 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT: -
    -
    - 483 - -
    - - - return runtime.ErrExecutorErrorInvalidOldBlobStateRoot -
    -
    - 484 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH: -
    -
    - 485 - -
    - - - return runtime.ErrExecutorErrorInvalidOldBlobAccInputHash -
    -
    - 486 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT: -
    -
    - 487 - -
    - - - return runtime.ErrExecutorErrorInvalidLastL1InfoTreeRoot -
    -
    - 488 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT: -
    -
    - 489 - -
    - - - return runtime.ErrExecutorErrorInvalidNewBlobStateRoot -
    -
    - 490 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH: -
    -
    - 491 - -
    - - - return runtime.ErrExecutorErrorInvalidNewBlobAccInputHash -
    -
    - 492 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_BLOB_DATA: -
    -
    - 493 - -
    - - - return runtime.ErrExecutorErrorInvalidBlobData -
    -
    - 494 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT: -
    -
    - 495 - -
    - - - return runtime.ErrExecutorErrorInvalidZKGasLimit -
    -
    - 496 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Z: -
    -
    - 497 - -
    - - - return runtime.ErrExecutorErrorInvalidPointZ -
    -
    - 498 - -
    - - - case ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Y: -
    -
    - 499 - -
    - - - return runtime.ErrExecutorErrorInvalidPointY + switch ctx.String(FlagNetwork) {
    - 500 + 63
    - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH: + case string(mainnet):
    - 501 + 64
    - - return runtime.ErrExecutorErrorSMMainPointZMismatch + networkJSON = MainnetNetworkConfigJSON
    - 502 + 65
    - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH: + case string(testnet):
    - 503 + 66
    - - return runtime.ErrExecutorErrorSMMainBlobL2HashDataMismatch + networkJSON = TestnetNetworkConfigJSON
    - 504 + 67
    - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_BATCH_HASH_DATA_MISMATCH: + case string(cardona):
    - 505 + 68
    - - return runtime.ErrExecutorErrorSMMainBatchHashDataMismatch + networkJSON = CardonaNetworkConfigJSON
    - 506 + + 69 +
    - - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_BLOB_TYPE: +   + case string(custom):
    - 507 + + 70 +
    - - - return runtime.ErrExecutorErrorSMMainInvalidBlobType +   + var err error
    - 508 + + 71 +
    - - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_UNRESTORED_SAVED_CONTEXT: +   + cfgPath := ctx.String(FlagCustomNetwork)
    - 509 - -
    - - - return runtime.ErrExecutorErrorSMMainUnrestoredSavedContext -
    +
    +
    @@ -74,7 +67,7 @@
    - 510 + + 74 +
    - - - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX: +   + panic(err.Error())
    - 511 + + 75 +
    - - - return runtime.ErrExecutorErrorSMMainInvalidMemoryCtx +   + }
    - 512 + 76
      - } + default:
    - 513 + + 77 +
    - -
    + log.Fatalf("unsupported --network value. Must be one of: [%s, %s, %s]", mainnet, testnet, cardona, custom)
    - 514 + 78
      - return ErrExecutorUnknown + }
    - 515 + 79
      - } + config, err := LoadGenesisFromJSONString(networkJSON)
    - 516 + 80
      -
    + if err != nil {
    -
    @@ -752,96 +698,7 @@
    +
    @@ -122,9 +115,10 @@
    - 752 + 122
      - return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE +
    - 753 + 123
      - case runtime.ErrExecutorErrorSMMainInvalidTxStatusError: + cfg.L1Config = cfgJSON.L1Config
    - 754 + 124
      - return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR -
    -
    - 755 - -
    - - - // Start of V3 errors -
    -
    - 756 - -
    - - - case runtime.ErrExecutorErrorInvalidPreviousL1InfoTreeRoot: -
    -
    - 757 - -
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT + cfg.Genesis = state.Genesis{
    - 758 + + 125 +
    - - case runtime.ErrExecutorErrorInvalidForcedHashData: + BlockNumber: cfgJSON.GenesisBlockNum,
    - 759 + + 126 +
    - - return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA + Root: common.HexToHash(cfgJSON.Root),
    - 760 + + 127 +
    - - case runtime.ErrExecutorErrorInvalidForcedDataGlobalExitRoot: + Actions: []*state.GenesisAction{},
    - 761 + + -
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT +
    +
    +   +
    - 762 + + 128 +
    - - - case runtime.ErrExecutorErrorInvalidForcedDataBlockHashL1: +   + }
    - 763 + + 129 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1 +   +
    - 764 + + 130 +
    - - - case runtime.ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot: +   + for _, account := range cfgJSON.Genesis {
    - 765 - -
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 766 + + 25 +
    - - - case runtime.ErrExecutorErrorInvalidOldBlobStateRoot: +   +
    - 767 + + 26 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT +   + type network string
    - 768 + + 27 +
    - - - case runtime.ErrExecutorErrorInvalidOldBlobAccInputHash: +   +
    - 769 + + -
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH +
    +
    +   +
    - 770 + + -
    - - - case runtime.ErrExecutorErrorInvalidLastL1InfoTreeRoot: +
    +
    +   +
    - 771 + + -
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT +
    +
    +   +
    - 772 + + 28 +
    - - - case runtime.ErrExecutorErrorInvalidNewBlobStateRoot: +   + const custom network = "custom"
    - 773 + + 29 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT +   +
    - 774 + + 30 +
    - - - case runtime.ErrExecutorErrorInvalidNewBlobAccInputHash: +   + // GenesisFromJSON is the config file for network_custom
    - 775 + + 31 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH +   + type GenesisFromJSON struct {
    - 776 + + 32 +
    - - - case runtime.ErrExecutorErrorInvalidBlobData: +   + // L1: root hash of the genesis block
    - 777 + + 33 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_BLOB_DATA +   + Root string `json:"root"`
    - 778 + + 34 +
    - - - case runtime.ErrExecutorErrorInvalidZKGasLimit: + + + // L1: block number in which the rollup was created
    - 779 + + 35 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT + + + RollupCreationBlockNum uint64 `json:"rollupCreationBlockNumber"`
    - 780 + + 36 +
    - - - case runtime.ErrExecutorErrorInvalidPointZ: + + + // L1: block number in which the rollup manager was created
    - 781 + + 37 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Z + + + RollupManagerCreationBlockNum uint64 `json:"rollupManagerCreationBlockNumber"`
    - 782 + + 38 +
    - - - case runtime.ErrExecutorErrorInvalidPointY: +   + // L2: List of states contracts used to populate merkle tree at initial state
    - 783 + + 39 +
    - - - return ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Y +   + Genesis []genesisAccountFromJSON `json:"genesis"`
    - 784 + + 40 +
    - - - case runtime.ErrExecutorErrorSMMainPointZMismatch: +   + // L1: configuration of the network
    - 785 + +
     
    +
    + 59 +
    - - - return ExecutorError_EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH +   + func (cfg *Config) loadNetworkConfig(ctx *cli.Context) {
    - 786 + + 60 +
    - - - case runtime.ErrExecutorErrorSMMainBlobL2HashDataMismatch: +   + var networkJSON string
    - 787 + + 61 +
    - - - return ExecutorError_EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH +   + switch ctx.String(FlagNetwork) {
    - 788 + + -
    - - - case runtime.ErrExecutorErrorSMMainBatchHashDataMismatch: +
    +
    +   +
    - 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 + + 62 +
    - - - case runtime.ErrExecutorErrorSMMainInvalidMemoryCtx: +   + case string(custom):
    - 795 + + 63 +
    - - - return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX +   + var err error
    - 796 + 64
      - } + cfgPath := ctx.String(FlagCustomNetwork)
    +
     
    +
    - 797 + 67
      -
    + panic(err.Error())
    - 798 + 68
      - return ErrCodeExecutorUnknown + }
    - 799 + 69
      - } + default:
    - 800 + + 70 +
    - - -
    + + + log.Fatalf("unsupported --network value. Must be %s", custom)
    - 801 + + 71 +
    - - - // RomBlobErr returns an instance of error related to the ExecutorError +   + }
    - 802 + + 72 +
    - - - func RomBlobErr(errorCode RomBlobError) error { +   + config, err := LoadGenesisFromJSONString(networkJSON)
    - 803 + + 73 +
    - - - switch errorCode { +   + if err != nil {
    - 804 + +
     
    +
    + 115 +
    - - - case RomBlobError_ROM_BLOB_ERROR_UNSPECIFIED: +   +
    - 805 + + 116 +
    - - - return ErrROMBlobUnspecified +   + cfg.L1Config = cfgJSON.L1Config
    - 806 + + 117 +
    - - - case RomBlobError_ROM_BLOB_ERROR_NO_ERROR: +   + cfg.Genesis = state.Genesis{
    - 807 + + 118 +
    - - - return nil + + + RollupBlockNumber: cfgJSON.RollupCreationBlockNum,
    - 808 + + 119 +
    - - - case RomBlobError_ROM_BLOB_ERROR_INVALID_PARSING: + + + RollupManagerBlockNumber: cfgJSON.RollupManagerCreationBlockNum,
    - 809 + + 120 +
    - - - return runtime.ErrROMBlobInvalidParsing + + + Root: common.HexToHash(cfgJSON.Root),
    - 810 + + 121 +
    - - - case RomBlobError_ROM_BLOB_ERROR_INVALID_MSB_BYTE: + + + Actions: []*state.GenesisAction{},
    - 811 + + 122 +
    - - - return runtime.ErrROMBlobInvalidMSBByte +   + }
    - 812 + + 123 +
    - - - case RomBlobError_ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT: +   +
    - 813 + + 124 +
    - - - return runtime.ErrROMBlobInvalidZKGasLimit +   + for _, account := range cfgJSON.Genesis { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - + + + - - - - @@ -262186,32 +31944,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + @@ -262286,32 +32094,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -262321,92 +32129,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - @@ -262416,923 +32214,1216 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + + + +
    +
    @@ -14,18 +13,6 @@
    - 814 + + 14 +
    - - - case RomBlobError_ROM_BLOB_ERROR_INVALID_BLOB_TYPE: +   + "github.com/urfave/cli/v2"
    - 815 + + 15 +
    - - - return runtime.ErrROMBlobInvalidBlobType +   + )
    - 816 + + 16 +
    - - - case RomBlobError_ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE: +   +
    - 817 + 17
    - - return runtime.ErrROMBlobInvalidCompressionType + func TestCardona(t *testing.T) {
    - 818 + 18
    - - case RomBlobError_ROM_BLOB_ERROR_INVALID_FORCED_BATCHES: + cfg := Config{}
    - 819 + 19
    - - return runtime.ErrROMBlobInvalidForcedBatches + fs := flag.NewFlagSet("", flag.ExitOnError)
    - 820 + 20
    - - case RomBlobError_ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN: + fs.String(FlagNetwork, string(cardona), string(cardona))
    - 821 + 21
    - - return runtime.ErrROMBlobInvalidTotalBodyLen + err := fs.Set(FlagNetwork, string(cardona))
    - 822 + 22
    - - } + require.NoError(t, err)
    - 823 + 23
    - - return ErrROMBlobUnknown + app := cli.NewApp()
    - 824 + 24
    - - } + ctx := cli.NewContext(app, fs, nil)
    - 825 + 25
    @@ -261952,222 +31690,242 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 826 + 26
    - - // RomBlobErrorCode returns the error code for a given error + log.Info("flag=", ctx.String(FlagNetwork))
    - 827 + 27
    - - func RomBlobErrorCode(err error) RomBlobError { + cfg.loadNetworkConfig(ctx)
    - 828 + 28
    - - switch err { + }
    - 829 + + 29 +
    - - - case nil: +   + func TestLoadCustomNetworkConfig(t *testing.T) {
    - 830 + + 30 +
    - - - return RomBlobError_ROM_BLOB_ERROR_NO_ERROR +   + tcs := []struct {
    - 831 + + 31 +
    - - - case runtime.ErrROMBlobInvalidParsing: +   + description string
    - 832 + +
    @@ -37,7 +24,8 @@
    +
    + 37 +
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_PARSING +   + description: "happy path",
    - 833 + + 38 +
    - - - case runtime.ErrROMBlobInvalidMSBByte: +   + inputConfigStr: `{
    - 834 + + 39 +
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_MSB_BYTE +   + "root": "0xBEEF",
    - 835 + + 40 +
    - - case runtime.ErrROMBlobInvalidZKGasLimit: + "genesisBlockNumber": 69,
    - 836 + + -
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT +
    +
    +   +
    - 837 + + 41 +
    - - - case runtime.ErrROMBlobInvalidBlobType: +   + "l1Config" : {
    - 838 + + 42 +
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_BLOB_TYPE +   + "chainId": 420,
    - 839 + + 43 +
    - - - case runtime.ErrROMBlobInvalidCompressionType: +   + "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4",
    - 840 + +
    @@ -89,8 +77,9 @@
    +
    + 89 +
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE +   + GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
    - 841 + + 90 +
    - - - case runtime.ErrROMBlobInvalidForcedBatches: +   + },
    - 842 + + 91 +
    - - - return RomBlobError_ROM_BLOB_ERROR_INVALID_FORCED_BATCHES +   + Genesis: state.Genesis{
    - 843 + + 92 +
    - - case runtime.ErrROMBlobInvalidTotalBodyLen: + Root: common.HexToHash("0xBEEF"),
    - 844 + + 93 +
    - - return RomBlobError_ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN + BlockNumber: 69,
    - 845 + + + +
    +   +
    +
    +
    + 94 +
    - - - } +   + Actions: []*state.GenesisAction{
    - 846 + + 95 +
    - - - return ErrCodeROMBlobUnknown +   + {
    - 847 + + 96 +
    - - - } +   + Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4",
    - 20 + 13
      - ErrROMUnknown = fmt.Errorf("unknown ROM error") + "github.com/urfave/cli/v2"
    - 21 + 14
      - // ErrCodeROMUnknown indicates an unknown ROM error + )
    - 22 + 15
      - ErrCodeROMUnknown = RomError(math.MaxInt32) +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 23 + 16
      - ) + func TestLoadCustomNetworkConfig(t *testing.T) {
    - 24 + 17
      -
    + tcs := []struct {
    - 25 + 18
      - // RomErr returns an instance of error related to the ExecutorError + description string
    - 96 + 24
      - return runtime.ErrInvalidTxChangeL2BlockLimitTimestamp + description: "happy path",
    - 97 + 25
      - case RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP: + inputConfigStr: `{
    - 98 + 26
      - return runtime.ErrInvalidTxChangeL2BlockMinTimestamp -
    -
    - - -
    -   -
    + "root": "0xBEEF",
    - + + 27 -
    -   -
    +
    +
    + + + "rollupCreationBlockNumber": 69,
    - + + 28 -
    -   -
    +
    +
    + + + "rollupManagerCreationBlockNumber": 60,
    - 99 + 29
      - } + "l1Config" : {
    - 100 + 30
      - return ErrROMUnknown + "chainId": 420,
    - 101 + 31
      - } + "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4",
    - 172 + 77
      - return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP + GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
    - 173 + 78
      - case runtime.ErrInvalidTxChangeL2BlockMinTimestamp: + },
    - 174 + 79
      - return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP + Genesis: state.Genesis{
    - + + 80 -
    -   -
    +
    +
    + + + Root: common.HexToHash("0xBEEF"),
    - + + 81 -
    -   -
    +
    +
    + + + RollupBlockNumber: 69, +
    +
    + 82 + +
    + + + RollupManagerBlockNumber: 60,
    - 175 + 83
      - } + Actions: []*state.GenesisAction{
    - 176 + 84
      - return ErrCodeROMUnknown + {
    - 177 + 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",
    -
     
    -
    - 456 + + 27 +
    -   - return runtime.ErrExecutorErrorInvalidUpdateMerkleTree + - + "balance": "0",
    - 457 + + 28 +
    -   - case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR: + - + "nonce": "1",
    - 458 + + 29 +
    -   - return runtime.ErrExecutorErrorSMMainInvalidTxStatusError + - + "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",
    - 459 + + 71 +
    -   - } + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000077fc57b154fcf8320df2c2e6c044aa50141c023b"
    - + + 72 -
    -   -
    +
    +
    + - + }
    - 460 + + 73 +
    -   - return ErrExecutorUnknown + - + },
    - 461 + + 74 +
    -   - } + - + {
    - 462 + + 75 +
    -   -
    + - + "contractName": "PolygonZkEVMTimelock",
    -
     
    -
    - 698 + + 76 +
    -   - return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE + - + "balance": "0",
    - 699 + + 77 +
    -   - case runtime.ErrExecutorErrorSMMainInvalidTxStatusError: + - + "nonce": "1",
    - 700 + + 78 +
    -   - return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR + - + "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 -
    -   -
    +
    +
    + - + `
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - -
    +
     
    @@ -263434,46 +33525,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 701 - -
    -   - } -
    -
    - 702 - -
    -   -
    -
    -
    - 703 - -
    -   - return ErrCodeExecutorUnknown -
    -
    - 704 - -
    -   - } -
    -
    @@ -263954,1193 +34005,1157 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    -
    -
    - - {/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"` -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 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 + + -
    +
    +
      - // 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"` +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/runtime.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -83,11 +83,6 @@
    -
    - 83 + + -
    +
    +
      - // ErrInvalidTxChangeL2BlockMinTimestamp indicates that the change l2 block transaction has trigger an error while executing +
    - 84 + + -
    +
    +
      - ErrInvalidTxChangeL2BlockMinTimestamp = errors.New("indicates that the change l2 block transaction has trigger an error while executing (min timestamp)") +
    - 85 + + -
    +
    +
     
    - 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 + + -
    - - +
    +
    +  
    - 332 + + -
    - - - // ErrExecutorErrorInvalidPreviousL1InfoTreeRoot indicates that the input parameter previous_l1_info_tree_root is invalid +
    +
    +   +
    - 333 + + -
    - - - ErrExecutorErrorInvalidPreviousL1InfoTreeRoot = errors.New("previous_l1_info_tree_root is invalid") +
    +
    +   +
    - 334 + + -
    - - - // ErrExecutorErrorInvalidForcedHashData indicates that the input parameter forced_hash_data is invalid +
    +
    +   +
    - 335 + + -
    - - - ErrExecutorErrorInvalidForcedHashData = errors.New("forced_hash_data is invalid") +
    +
    +   +
    - 336 + + -
    - - - // ErrExecutorErrorInvalidForcedDataGlobalExitRoot indicates that the input parameter forced_data.global_exit_root is invalid +
    +
    +   +
    - 337 + + -
    - - - ErrExecutorErrorInvalidForcedDataGlobalExitRoot = errors.New("forced_data.global_exit_root is invalid") +
    +
    +   +
    - 338 - -
    - - - // ErrExecutorErrorInvalidForcedDataBlockHashL1 indicates that the input parameter forced_data.block_hash_l1 is invalid +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/types/duration.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -38,3 +38,13 @@
    - 339 + + 38 +
    - - - ErrExecutorErrorInvalidForcedDataBlockHashL1 = errors.New("forced_data.block_hash_l1 is invalid") +   + },
    - 340 + + 39 +
    - - - // ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot indicates that the input parameter L1 Data initiali_historic_root is invalid +   + }
    - 341 + + 40 +
    - - - ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot = errors.New("L1 Data initiali_historic_root is invalid") +   + }
    - 342 + + -
    - - - // ErrExecutorErrorInvalidOldBlobStateRoot indicates that the input parameter old_blob_state_root is invalid +
    +
    +   +
    - 343 + + -
    - - - ErrExecutorErrorInvalidOldBlobStateRoot = errors.New("old_blob_state_root is invalid") +
    +
    +   +
    - 344 + + -
    - - - // ErrExecutorErrorInvalidOldBlobAccInputHash indicates that the input parameter old_blob_acc_input_hash is invalid +
    +
    +   +
    - 345 + + -
    - - - ErrExecutorErrorInvalidOldBlobAccInputHash = errors.New("old_blob_acc_input_hash is invalid") +
    +
    +   +
    - 346 + + -
    - - - // ErrExecutorErrorInvalidLastL1InfoTreeRoot indicates that the input parameter last_l1_info_tree_root is invalid +
    +
    +   +
    - 347 + + -
    - - - ErrExecutorErrorInvalidLastL1InfoTreeRoot = errors.New("last_l1_info_tree_root is invalid") +
    +
    +   +
    - 348 + + -
    - - - // ErrExecutorErrorInvalidNewBlobStateRoot indicates that the input parameter new_blob_state_root is invalid +
    +
    +   +
    - 349 + + -
    - - - ErrExecutorErrorInvalidNewBlobStateRoot = errors.New("new_blob_state_root is invalid") +
    +
    +   +
    - 350 + + -
    - - - // ErrExecutorErrorInvalidNewBlobAccInputHash indicates that the input parameter new_blob_acc_input_hash is invalid +
    +
    +   +
    - 351 + + -
    - - - ErrExecutorErrorInvalidNewBlobAccInputHash = errors.New("new_blob_acc_input_hash is invalid") +
    +
    +   +
    - 352 - -
    - - - // ErrExecutorErrorInvalidBlobData indicates that the input parameter blob_data is invalid +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - 353 + + 38 +
    - - - ErrExecutorErrorInvalidBlobData = errors.New("blob_data is invalid") +   + },
    - 354 + + 39 +
    - - - // ErrExecutorErrorInvalidZKGasLimit indicates that the input parameter zk_gas_limit is invalid +   + }
    - 355 + + 40 +
    - - - ErrExecutorErrorInvalidZKGasLimit = errors.New("zk_gas_limit is invalid") +   + }
    - 356 + + 41 +
    - - - // ErrExecutorErrorInvalidPointZ indicates that the input parameter point_z is invalid + + +
    - 357 + + 42 +
    - - - ErrExecutorErrorInvalidPointZ = errors.New("point_z is invalid") + + + // MarshalJSON marshalls time duration into text.
    - 358 + + 43 +
    - - - // ErrExecutorErrorInvalidPointY indicates that the input parameter point_y is invalid + + + func (d Duration) MarshalJSON() ([]byte, error) {
    - 359 + + 44 +
    - - - ErrExecutorErrorInvalidPointY = errors.New("point_y is invalid") + + + return []byte(`"` + d.String() + `"`), nil
    - 360 + + 45 +
    - - - // ErrExecutorErrorSMMainPointZMismatch indicates that the input parameter point_z is different from the one calculated by the executor + + + }
    - 361 + + 46 +
    - - - ErrExecutorErrorSMMainPointZMismatch = errors.New("point_z mismatch") + + +
    - 362 + + 47 +
    - - - // ErrExecutorErrorSMMainBlobL2HashDataMismatch indicates that the input parameter blob L2 data hash is different from the one calculated by the executor + + + // MarshalText marshalls time duration into text.
    - 363 + + 48 +
    - - - ErrExecutorErrorSMMainBlobL2HashDataMismatch = errors.New("blob L2 hash data mismatch") + + + func (d *Duration) MarshalText() ([]byte, error) {
    - 364 + + 49 +
    - - - // ErrExecutorErrorSMMainBatchHashDataMismatch indicates that the input parameter batch data hash is different from the one calculated by the executor + + + return []byte(d.String()), nil
    - 365 + + 50 +
    - - - ErrExecutorErrorSMMainBatchHashDataMismatch = errors.New("batch hash data mismatch") + + + }
    - 366 - -
    - - - // ErrExecutorErrorSMMainInvalidBlobType indicates that the input parameter blob type is invalid +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/config.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -0,0 +1,9 @@
    - 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 + + 1 +
    - - - ErrROMBlobInvalidParsing = errors.New("error while parsing the blob data") + + + package dataavailability
    - 378 + + 2 +
    - - - // ErrROMBlobInvalidMSBByte indicates that the MSB on one field element is different than zero (only for blob_type = 1) + + +
    - 379 + + 3 +
    - - - ErrROMBlobInvalidMSBByte = errors.New("MSB on one field element is different than zero") + + + // DABackendType is the data availability protocol for the CDK
    - 380 + + 4 +
    - - - // ErrROMBlobInvalidZKGasLimit not enough zk_gas_limit supplied to pay for batches proofs + + + type DABackendType string
    - 381 + + 5 +
    - - - ErrROMBlobInvalidZKGasLimit = errors.New("not enough zk_gas_limit supplied to pay for batches proofs") + + +
    - 382 + + 6 +
    - - - // ErrROMBlobInvalidBlobType blob_type not supported + + + const (
    - 383 + + 7 +
    - - - ErrROMBlobInvalidBlobType = errors.New("blob_type not supported") + + + // DataAvailabilityCommittee is the DAC protocol backend
    - 384 + + 8 +
    - - - // ErrROMBlobInvalidCompressionType compression type not supported + + + DataAvailabilityCommittee DABackendType = "DataAvailabilityCommittee"
    - 385 + + 9 +
    - - - ErrROMBlobInvalidCompressionType = errors.New("compression type not supported") + + + )
    - 386 - -
    - - - // ErrROMBlobInvalidForcedBatches fblobtype = 2 and numBatches > 1 +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - -
    +
    @@ -0,0 +1,183 @@
    - 387 + + -
    - - - ErrROMBlobInvalidForcedBatches = errors.New("fblobtype = 2 and numBatches > 1") +
    +
    +   +
    - 388 + + -
    - - - // ErrROMBlobInvalidTotalBodyLen totalBodyLen != blobDataLen - 1 (byte compression) - 4 (bytes totalBodyLen) +
    +
    +   +
    - 389 + + -
    - - - ErrROMBlobInvalidTotalBodyLen = errors.New("totalBodyLen != blobDataLen - 1 (byte compression) - 4 (bytes totalBodyLen)") +
    +
    +   +
    - 390 + + -
    - - +
    +
    +  
    - 391 + + -
    +
    +
      - // GRPC ERRORS +
    - 392 + + -
    +
    +
      - // =========== +
    - 393 + + -
    +
    +
     
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 83 + + -
    +
    +
      - // ErrInvalidTxChangeL2BlockMinTimestamp indicates that the change l2 block transaction has trigger an error while executing +
    - 84 + + -
    +
    +
      - ErrInvalidTxChangeL2BlockMinTimestamp = errors.New("indicates that the change l2 block transaction has trigger an error while executing (min timestamp)") +
    - 85 + + -
    +
    +
     
    @@ -265196,66 +35211,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 86 + + -
    +
    +
      - // EXECUTOR ERRORS +
    - 87 + + -
    +
    +
      - // =============== +
    - 88 + + -
    +
    +
     
    -
     
    -
    - 322 + + -
    +
    +
      - // ErrExecutorErrorSMMainInvalidTxStatusError indicates that the TX has an invalid status-error combination +
    - 323 + + -
    +
    +
      - ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("tx has an invalid status-error combination") +
    - 324 + + -
    +
    +
     
    @@ -265871,401 +35881,363 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 325 + + -
    +
    +
      - // GRPC ERRORS +
    - 326 + + -
    +
    +
      - // =========== +
    - 327 + + -
    +
    +
     
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -32,18 +32,17 @@
    - 32 + + -
    +
    +
      - type State struct { +
    - 33 + + -
    +
    +
      - cfg Config +
    - 34 + + -
    +
    +
      - storage +
    - 35 + + -
    - - - executorClient executor.ExecutorServiceClient +
    +
    +   +
    - 36 + + -
    - - - tree *merkletree.StateTree +
    +
    +   +
    - 37 + + -
    - - - eventLog *event.EventLog +
    +
    +   +
    - 38 + + -
    - - - l1InfoTree *l1infotree.L1InfoTree +
    +
    +   +
    - 39 + + -
    - - - l1InfoTreeRecursive *l1infotree.L1InfoTreeRecursive +
    +
    +   +
    - 40 + + -
    +
    +
     
    - 41 + + -
    +
    +
      - newL2BlockEvents chan NewL2BlockEvent +
    - 42 + + -
    +
    +
      - newL2BlockEventHandlers []NewL2BlockEventHandler +
    - 43 + + -
    +
    +
      - } +
    - 44 + + -
    +
    +
     
    - 45 + + -
    +
    +
      - // NewState creates a new State +
    - 46 + + -
    - - - func NewState(cfg Config, storage storage, executorClient executor.ExecutorServiceClient, stateTree *merkletree.StateTree, eventLog *event.EventLog, mt *l1infotree.L1InfoTree, mtr *l1infotree.L1InfoTreeRecursive) *State { +
    +
    +   +
    - 47 + + -
    +
    +
      - var once sync.Once +
    - 48 + + -
    +
    +
      - once.Do(func() { +
    - 49 + + -
    +
    +
      - metrics.Register() +
    -
    @@ -58,7 +57,6 @@
    -
    - 58 + + -
    +
    +
      - newL2BlockEvents: make(chan NewL2BlockEvent, newL2BlockEventBufferSize), +
    - 59 + + -
    +
    +
      - newL2BlockEventHandlers: []NewL2BlockEventHandler{}, +
    - 60 + + -
    +
    +
      - l1InfoTree: mt, +
    - 61 + + -
    - - - l1InfoTreeRecursive: mtr, +
    +
    +   +
    - 62 + + -
    +
    +
      - } +
    - 63 + + -
    +
    +
     
    - 64 + + -
    +
    +
      - return state -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - @@ -266279,138 +36251,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -266424,580 +36391,503 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
     
    - 32 + + -
    +
    +
      - type State struct { +
    - 33 + + -
    +
    +
      - cfg Config +
    - 34 + + -
    +
    +
      - storage +
    - 35 + + -
    - + - executorClient executor.ExecutorServiceClient +
    +
    +   +
    - 36 + + -
    - + - tree *merkletree.StateTree +
    +
    +   +
    - 37 + + -
    - + - eventLog *event.EventLog +
    +
    +   +
    - 38 + + -
    - + - l1InfoTree *l1infotree.L1InfoTree +
    +
    +   +
    - 39 + + -
    +
    +
     
    - 40 + + -
    +
    +
      - newL2BlockEvents chan NewL2BlockEvent +
    - 41 + + -
    +
    +
      - newL2BlockEventHandlers []NewL2BlockEventHandler +
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
     
    - 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 - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - @@ -267015,824 +36905,778 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - + + + + + + + + + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -53,7 +53,7 @@
    - 53 + + -
    +
    +
      - panic(err) +
    - 54 + + -
    +
    +
      - } +
    - 55 + + -
    +
    +
     
    - 56 + + -
    - - - zkProverURI := testutils.GetEnv("ZKPROVER_URI", "localhost") +
    +
    +   +
    - 57 + + -
    +
    +
     
    - 58 + + -
    +
    +
      - executorServerConfig := executor.Config{URI: fmt.Sprintf("%s:50071", zkProverURI), MaxGRPCMessageSize: 100000000} +
    - 59 + + -
    +
    +
      - ExecutorClient, executorClientConn, executorCancel = executor.NewExecutorClient(ctx, executorServerConfig) +
    -
    @@ -76,11 +76,7 @@
    +
    + + +
    +   +
    +
    - 76 + + -
    +
    +
      - if err != nil { +
    - 77 + + -
    +
    +
      - panic(err) +
    - 78 + + -
    +
    +
      - } +
    - 79 + + -
    - - - mtr, err := l1infotree.NewL1InfoTreeRecursive(32) +
    +
    +   +
    - 80 + + -
    - - - if err != nil { +
    +
    +   +
    - 81 + + -
    - - - panic(err) +
    +
    +   +
    - 82 + + -
    - - - } +
    +
    +   +
    - 83 + + -
    - - - return state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), ExecutorClient, stateTree, eventLog, mt, mtr) +
    +
    +   +
    - 84 + + -
    +
    +
      - } +
    - 85 + + -
    +
    +
     
    - 86 + + -
    +
    +
      - func InitOrResetDB(cfg db.Config) { +
    - 53 + + 1 +
    -   - panic(err) + + + package dataavailability
    - 54 + + 2 +
    -   - } + + +
    - 55 + + 3 +
    -   -
    + + + import (
    - 56 + + 4 +
    + - zkProverURI := testutils.GetEnv("ZKPROVER_URI", "zkevm-prover") + "context"
    - 57 + + 5 +
    -   + + + "errors" +
    +
    + 6 + +
    + + + "fmt" +
    +
    + 7 + +
    + + + "math/big" +
    +
    + 8 + +
    + +
    - 58 + + 9 +
    -   - executorServerConfig := executor.Config{URI: fmt.Sprintf("%s:50071", zkProverURI), MaxGRPCMessageSize: 100000000} + + + "github.com/0xPolygonHermez/zkevm-node/etherman/types"
    - 59 + + 10 +
    -   - ExecutorClient, executorClientConn, executorCancel = executor.NewExecutorClient(ctx, executorServerConfig) + + + jsontypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    -
     
    +
    + 11 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    - 76 + + 12 +
    -   - if err != nil { + + + "github.com/ethereum/go-ethereum/common"
    - 77 + + 13 +
    -   - panic(err) + + + "github.com/ethereum/go-ethereum/crypto"
    - 78 + + 14 +
    -   - } + + + )
    - 79 + + 15 +
    + - return state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), ExecutorClient, stateTree, eventLog, mt) +
    - + + 16 -
    -   -
    +
    +
    + + + const (
    - + + 17 -
    -   -
    +
    +
    + + + unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s"
    - + + 18 -
    -   -
    +
    +
    + + + failedDataRetrievalTemplate = "failed to retrieve local data for batches %v: %s"
    - + + 19 -
    -   -
    +
    +
    + + + invalidBatchRetrievalArgs = "invalid L2 batch data retrieval arguments, %d != %d"
    - 80 + + 20 +
    -   - } + + + )
    - 81 + + 21 +
    -   + +
    - 82 + + 22 +
    -   - func InitOrResetDB(cfg db.Config) { + + + // DataSourcePriority defines where data is retrieved from
    -
    + + + 23 + + +
    + + + type DataSourcePriority string
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_etrog/etrog_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -98,11 +98,9 @@
    - 98 + + 24 +
    -   - if len(txs) > 0 { + + +
    - 99 + + 25 +
    -   - // Generate batchdata from the txs in the test and compared with the vector + + + const (
    - 100 + + 26 +
    -   - l2block := state.L2BlockRaw{ + + + // Local indicates data stored in this nodes DB
    - 101 + + 27 +
    - - - ChangeL2BlockHeader: state.ChangeL2BlockHeader{ + + + Local DataSourcePriority = "local"
    - 102 + + 28 +
    - - - DeltaTimestamp: uint32(timestampLimit.Uint64()), + + + // Trusted indicates data stored in the Trusted Sequencer
    - 103 + + 29 +
    - - - IndexL1InfoTree: testCase.Txs[0].IndexL1InfoTree, + + + Trusted DataSourcePriority = "trusted"
    - 104 + + 30 +
    - - - }, + + + // External indicates data stored in the Data Availability layer
    - 105 + + 31 +
    - - - Transactions: txs, + + + External DataSourcePriority = "external"
    - 106 + + 32 +
    -   - } + + + )
    - 107 + + 33 +
    -   + +
    - 108 + + 34 +
    -   - batch := state.BatchRawV2{ -
    -
    -
    + + + // DefaultPriority is the default order in which data is retrieved
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 98 + + 35 +
    -   - if len(txs) > 0 { + + + var DefaultPriority = []DataSourcePriority{Local, Trusted, External}
    - 99 + + 36 +
    -   - // Generate batchdata from the txs in the test and compared with the vector + + +
    - 100 + + 37 +
    -   - l2block := state.L2BlockRaw{ + + + // DataAvailability implements an abstract data availability integration
    - 101 + + 38 +
    + - DeltaTimestamp: uint32(timestampLimit.Uint64()), + type DataAvailability struct {
    - 102 + + 39 +
    + - IndexL1InfoTree: testCase.Txs[0].IndexL1InfoTree, + isTrustedSequencer bool
    - 103 + + 40 +
    + - Transactions: txs, + state stateInterface
    - + + 41 -
    -   -
    +
    +
    + + + zkEVMClient ZKEVMClientTrustedBatchesGetter
    - + + 42 -
    -   -
    +
    +
    + + + backend DABackender
    - 104 + + 43 +
    -   - } + + + dataSourcePriority []DataSourcePriority
    - 105 + + 44 +
    -   -
    + + + ctx context.Context
    - 106 + + 45 +
    -   - batch := state.BatchRawV2{ -
    -
    -
    + + + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -78,7 +78,15 @@
    - 78 + + 46 +
    -   - var effectivePercentage []uint8 + + +
    - 79 + + 47 +
    -   - for i := 0; i <= count; i++ { + + + // New creates a DataAvailability instance
    - 80 + + 48 +
    -   - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) + + + func New(
    - 81 + + 49 +
    - - - effectivePercentage = append(effectivePercentage, MaxEffectivePercentage) + + + isTrustedSequencer bool,
    - + + 50 -
    -   -
    +
    +
    + + + backend DABackender,
    - + + 51 -
    -   -
    +
    +
    + + + state stateInterface,
    - + + 52 -
    -   -
    +
    +
    + + + zkEVMClient ZKEVMClientTrustedBatchesGetter,
    - + + 53 -
    -   -
    +
    +
    + + + priority []DataSourcePriority,
    - + + 54 -
    -   -
    +
    +
    + + + ) (*DataAvailability, error) {
    - + + 55 -
    -   -
    +
    +
    + + + da := &DataAvailability{
    - + + 56 -
    -   -
    +
    +
    + + + isTrustedSequencer: isTrustedSequencer,
    - + + 57 -
    -   -
    +
    +
    + + + backend: backend,
    - 82 + + 58 +
    -   - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + + + state: state,
    - 83 + + 59 +
    -   - } + + + zkEVMClient: zkEVMClient,
    - 84 + + 60 +
    -   -
    + + + ctx: context.Background(),
    -
    @@ -307,7 +315,7 @@
    -
    - 307 + + 61 +
    -   - return nil, err + + + dataSourcePriority: priority,
    - 308 + + 62 +
    -   - } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + }
    - 309 + + 63 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + if len(da.dataSourcePriority) == 0 {
    - 310 + + 64 +
    - - - s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2) + + + da.dataSourcePriority = DefaultPriority
    - 311 + + 65 +
    -   - return nil, err + + + }
    - 312 + + 66 +
    -   - } + + + err := da.backend.Init()
    - 313 + + 67 +
    -   -
    -
    -
    -
    + + + return da, err
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 78 + + 68 +
    -   - var effectivePercentage []uint8 + + + }
    - 79 + + 69 +
    -   - for i := 0; i <= count; i++ { + + +
    - 80 + + 70 +
    -   - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) + + + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
    - 81 + + 71 +
    + - txGasPrice := tx.GasPrice() + // as expected by the contract
    - 82 + 72
    + - effectiveGasPrice := receipt.EffectiveGasPrice + func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) {
    - 83 + 73
    + - egpPercentage, err := CalculateEffectiveGasPricePercentage(txGasPrice, effectiveGasPrice) + batchesData := [][]byte{}
    - 84 + 74
    + - if errors.Is(err, ErrEffectiveGasPriceEmpty) { + for _, batch := range sequences {
    - 85 + 75
    + - egpPercentage = MaxEffectivePercentage + // Do not send to the DA backend data that will be stored to L1
    - 86 + 76
    + - } else if err != nil { + if batch.ForcedBatchTimestamp == 0 {
    - 87 + 77
    + - return nil, err + batchesData = append(batchesData, batch.BatchL2Data)
    - 88 + 78
    @@ -267842,1110 +37686,1052 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 89 + 79
    + - effectivePercentage = append(effectivePercentage, egpPercentage) + }
    - 90 + + 80 +
    -   - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + + + return d.backend.PostSequence(ctx, batchesData)
    - 91 + + 81 +
    -   - } + + + }
    - 92 + + 82 +
    -   + +
    -
     
    -
    - 315 + + 83 +
    -   - return nil, err + + + // GetBatchL2Data tries to return the data from a batch, in the following priorities. batchNums should not include forced batches.
    - 316 + + 84 +
    -   - } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + // 1. From local DB
    - 317 + + 85 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + // 2. From Trusted Sequencer (if not self)
    - 318 + + 86 +
    + - s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) + // 3. From DA backend
    - 319 + + 87 +
    -   - return nil, err + + + func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
    - 320 + + 88 +
    -   - } + + + if len(batchNums) != len(batchHashes) {
    - 321 + + 89 +
    -   -
    -
    -
    -
    + + + return nil, fmt.Errorf(invalidBatchRetrievalArgs, len(batchNums), len(batchHashes))
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -244,6 +244,7 @@
    - 244 + + 90 +
    -   - imStateRoots := make([]common.Hash, 0, numTxs) + + + }
    - 245 + + 91 +
    -   - var receipt *types.Receipt + + +
    - 246 + + 92 +
    -   -
    + + + for _, p := range d.dataSourcePriority {
    - + + 93 -
    -   -
    +
    +
    + + + switch p {
    - 247 + + 94 +
    -   - for i, txResponse := range l2Block.TransactionResponses { + + + case Local:
    - 248 + + 95 +
    -   - // if the transaction has an intrinsic invalid tx error it means + + + localData, err := d.state.GetBatchL2DataByNumbers(d.ctx, batchNums, nil)
    - 249 + + 96 +
    -   - // the transaction has not changed the state, so we don't store it + + + if err != nil {
    -
    @@ -263,9 +264,10 @@
    -
    - 263 + + 97 +
    -   -
    + + + return nil, err
    - 264 + + 98 +
    -   - storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData) + + + }
    - 265 + + 99 +
    -   + +
    - 266 + + 100 +
    - - - receipt = GenerateReceipt(header.Number, txResponse, uint(i), forkID) + + + data, err := checkBatches(batchNums, batchHashes, localData)
    - 267 + + 101 +
    -   - receipts = append(receipts, receipt) + + + if err != nil {
    - 268 + + 102 +
    -   - imStateRoots = append(imStateRoots, txResp.StateRoot) + + + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error())
    - + + 103 -
    -   -
    +
    +
    + + + } else {
    - 269 + + 104 +
    -   - } + + + return data, nil
    - 270 + + 105 +
    -   -
    + + + }
    - 271 + + 106 +
    -   - // Create block to be able to calculate its hash + + + case Trusted:
    -
    @@ -536,6 +538,7 @@
    -
    - 536 + + 107 +
    -   - TimestampLimit: l2Block.Time(), + + + if !d.isTrustedSequencer {
    - 537 + + 108 +
    -   - SkipFirstChangeL2Block: cFalse, + + + data, err := d.rpcData(batchNums, batchHashes, d.zkEVMClient.BatchesByNumbers)
    - 538 + + 109 +
    -   - SkipWriteBlockInfoRoot: cTrue, + + + if err != nil {
    - + + 110 -
    -   -
    +
    +
    + + + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error())
    - 539 + + 111 +
    -   - } + + + } else {
    - 540 + + 112 +
    -   - if noZKEVMCounters { + + + return data, nil
    - 541 + + 113 +
    -   - processBatchRequestV2.NoCounters = cTrue + + + }
    -
    @@ -600,7 +603,7 @@
    +
    + 114 + +
    + + + } +
    - 600 + + 115 +
    -   -
    + + + case External:
    - 601 + + 116 +
    -   - if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage)
    - 602 + + 117 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + default:
    - 603 + + 118 +
    - - - s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2) + + + log.Warnf("invalid data retrieval priority: %s", p)
    - 604 + + 119 +
    -   - return nil, err + + + }
    - 605 + + 120 +
    -   + + }
    - 606 + + 121 +
    -   + +
    -
    @@ -1014,6 +1017,7 @@
    -
    - 1014 + + 122 +
    -   - TimestampLimit: uint64(time.Now().Unix()), + + + return nil, errors.New("failed to retrieve l2 batch data")
    - 1015 + + 123 +
    -   - SkipFirstChangeL2Block: cTrue, + + + }
    - 1016 + + 124 +
    -   - SkipWriteBlockInfoRoot: cTrue, + + +
    - + + 125 -
    -   -
    +
    +
    + + + func checkBatches(batchNumbers []uint64, expectedHashes []common.Hash, batchData map[uint64][]byte) ([][]byte, error) {
    - 1017 + + 126 +
    -   - } + + + if len(batchNumbers) != len(expectedHashes) {
    - 1018 + + 127 +
    -   -
    + + + return nil, fmt.Errorf("invalid batch parameters")
    - 1019 + + 128 +
    -   - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + + + }
    -
    @@ -1040,7 +1044,7 @@
    -
    - 1040 + + 129 +
    -   - } + + + result := make([][]byte, len(batchNumbers))
    - 1041 + + 130 +
    -   - if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + for i := 0; i < len(batchNumbers); i++ {
    - 1042 + + 131 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + batchNumber := batchNumbers[i]
    - 1043 + + 132 +
    - - - s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2) + + + expectedHash := expectedHashes[i]
    - 1044 + + 133 +
    -   - return false, false, gasUsed, nil, err + + + bd, ok := batchData[batchNumber]
    - 1045 + + 134 +
    -   - } + + + if !ok {
    - 1046 + + 135 +
    -   - if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { + + + return nil, fmt.Errorf("missing batch data: [%d] %s", batchNumber, expectedHash.Hex())
    -
    + + + 136 + + +
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - @@ -268955,12 +38741,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 244 + + 137 +
    -   - imStateRoots := make([]common.Hash, 0, numTxs) + + + actualHash := crypto.Keccak256Hash(bd)
    - 245 + + 138 +
    -   - var receipt *types.Receipt + + + if actualHash != expectedHash {
    - 246 + + 139 +
    -   -
    + + + err := fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash)
    - 247 + 140
    + - txIndex := 0 + log.Warnf("wrong local data for hash: %s", err.Error())
    - 248 + + 141 +
    -   - for i, txResponse := range l2Block.TransactionResponses { + + + return nil, err
    - 249 + + 142 +
    -   - // if the transaction has an intrinsic invalid tx error it means + + + }
    - 250 + + 143 +
    -   - // the transaction has not changed the state, so we don't store it + + + result[i] = bd
    -
     
    +
    + 144 + +
    + + + } +
    - 264 + + 145 +
    -   -
    + + + return result, nil
    - 265 + + 146 +
    -   - storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData) + + + }
    - 266 + + 147 +
    -   + +
    - 267 + + 148 +
    + - receipt = GenerateReceipt(header.Number, txResponse, uint(txIndex), forkID) + type rpcBatchDataFunc func(ctx context.Context, numbers []*big.Int) ([]*jsontypes.BatchData, error)
    - 268 + + 149 +
    -   - receipts = append(receipts, receipt) + + +
    - 269 + + 150 +
    -   - imStateRoots = append(imStateRoots, txResp.StateRoot) + + + // rpcData retrieves batch data from rpcBatchDataFunc, returns an error unless all are found and correct
    - 270 + 151
    + - txIndex++ + func (d *DataAvailability) rpcData(batchNums []uint64, expectedHashes []common.Hash, rpcFunc rpcBatchDataFunc) ([][]byte, error) {
    - 271 + + 152 +
    -   - } + + + if len(batchNums) != len(expectedHashes) {
    - 272 + + 153 +
    -   -
    + + + return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d",
    - 273 + + 154 +
    -   - // Create block to be able to calculate its hash + + + len(batchNums), len(expectedHashes))
    -
     
    -
    - 538 + + 155 +
    -   - TimestampLimit: l2Block.Time(), + + + }
    - 539 + + 156 +
    -   - SkipFirstChangeL2Block: cFalse, + + + nums := make([]*big.Int, 0, len(batchNums))
    - 540 + + 157 +
    -   - SkipWriteBlockInfoRoot: cTrue, + + + for _, n := range batchNums {
    - 541 + 158
    + - ExecutionMode: executor.ExecutionMode0, + nums = append(nums, new(big.Int).SetUint64(n))
    - 542 + + 159 +
    -   + + }
    - 543 + + 160 +
    -   - if noZKEVMCounters { + + + batchData, err := rpcFunc(d.ctx, nums)
    - 544 + + 161 +
    -   - processBatchRequestV2.NoCounters = cTrue + + + if err != nil {
    -
     
    -
    - 603 + + 162 +
    -   -
    + + + return nil, err
    - 604 + + 163 +
    -   - if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + }
    - 605 + + 164 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + if len(batchData) != len(batchNums) {
    - 606 + + 165 +
    + - s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) + return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData))
    - 607 + + 166 +
    -   - return nil, err + + + }
    - 608 + + 167 +
    -   - } + + + result := make(map[uint64][]byte)
    - 609 + + 168 +
    -   -
    + + + for i := 0; i < len(batchNums); i++ {
    -
     
    -
    - 1017 + + 169 +
    -   - TimestampLimit: uint64(time.Now().Unix()), + + + number := batchNums[i]
    - 1018 + + 170 +
    -   - SkipFirstChangeL2Block: cTrue, + + + batch := batchData[i]
    - 1019 + + 171 +
    -   - SkipWriteBlockInfoRoot: cTrue, + + + expectedTransactionsHash := expectedHashes[i]
    - 1020 + 172
    + - ExecutionMode: executor.ExecutionMode0, + actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data)
    - 1021 + + 173 +
    -   - } + + + if expectedTransactionsHash != actualTransactionsHash {
    - 1022 + + 174 +
    -   -
    + + + return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash)
    - 1023 + + 175 +
    -   - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + + + }
    -
     
    +
    + 176 + +
    + + + result[number] = batch.BatchL2Data +
    - 1044 + + 177 +
    -   + + }
    - 1045 + + 178 +
    -   - if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + + + checked, err := checkBatches(batchNums, expectedHashes, result)
    - 1046 + + 179 +
    -   - err = executor.ExecutorErr(processBatchResponseV2.Error) + + + if err != nil {
    - 1047 + + 180 +
    + - s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) + return nil, err
    - 1048 + + 181 +
    -   - return false, false, gasUsed, nil, err + + + }
    - 1049 + + 182 +
    -   - } + + + return checked, nil
    - 1050 + + 183 +
    -   - if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { + + + }
    -
    @@ -15,25 +15,23 @@
    +
    @@ -0,0 +1,309 @@
    - 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 + + -
    - - +
    +
    +  
    - 56 + + -
    +
    +
      - // ProcessBatchResponse represents the response of a batch process. +
    - 57 + + -
    +
    +
      - type ProcessBatchResponse struct { +
    - 58 + + -
    +
    +
      - NewStateRoot common.Hash +
    -
    @@ -62,25 +51,21 @@
    +
    + + +
    +   +
    +
    - 62 + + -
    +
    +
      - UsedZkCounters ZKCounters +
    - 63 + + -
    +
    +
      - ReservedZkCounters ZKCounters +
    - 64 + + -
    +
    +
      - // TransactionResponses_V1 []*ProcessTransactionResponse +
    - 65 + + -
    - - - BlockResponses []*ProcessBlockResponse +
    +
    +   +
    - 66 + + -
    - - - ExecutorError error +
    +
    +   +
    - 67 + + -
    - - - ReadWriteAddresses map[common.Address]*InfoReadWrite +
    +
    +   +
    - 68 + + -
    - - - IsRomLevelError bool +
    +
    +   +
    - 69 + + -
    - - - IsExecutorLevelError bool +
    +
    +   +
    - 70 + + -
    - - - IsRomOOCError bool +
    +
    +   +
    - 71 + + -
    - - - FlushID uint64 +
    +
    +   +
    - 72 + + -
    - - - StoredFlushID uint64 +
    +
    +   +
    - 73 + + -
    - - - ProverID string +
    +
    +   +
    - 74 + + -
    - - - GasUsed_V2 uint64 +
    +
    +   +
    - 75 + + -
    - - - SMTKeys_V2 []merkletree.Key +
    +
    +   +
    - 76 + + -
    - - - ProgramKeys_V2 []merkletree.Key +
    +
    +   +
    - 77 + + -
    - - - ForkID uint64 +
    +
    +   +
    - 78 + + -
    - - - InvalidBatch_V2 bool +
    +
    +   +
    - 79 + + -
    - - - 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 +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -269872,66 +39684,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -270282,483 +40104,421 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
     
    - 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 + + -
    - + - OldStateRoot common.Hash +
    +
    +   +
    - 23 + + -
    - + - OldAccInputHash common.Hash +
    +
    +   +
    - 24 + + -
    - + - Transactions []byte +
    +
    +   +
    - 25 + + -
    - + - Coinbase common.Address +
    +
    +   +
    - 26 + + -
    - + - ForcedBlockHashL1 common.Hash +
    +
    +   +
    - 27 + + -
    - + - Timestamp_V1 time.Time +
    +
    +   +
    - 28 + + -
    - + - TimestampLimit_V2 uint64 +
    +
    +   +
    - 29 + + -
    - + - Caller metrics.CallerLabel +
    +
    +   +
    - 30 + + -
    - + - SkipFirstChangeL2Block_V2 bool +
    +
    +   +
    - 31 + + -
    - + - SkipWriteBlockInfoRoot_V2 bool +
    +
    +   +
    - 32 + + -
    - + - SkipVerifyL1InfoRoot_V2 bool +
    +
    +   +
    - 33 + + -
    - + - ForkID uint64 +
    +
    +   +
    - 34 + + -
    - + - ExecutionMode uint64 +
    +
    +   +
    - 35 + + -
    +
    +
      - } +
    - 36 + + -
    +
    +
     
    - 37 + + -
    +
    +
      - // L1DataV2 represents the L1InfoTree data used in ProcessRequest.L1InfoTreeData_V2 parameter +
    -
     
    +
    + + +
    +   +
    +
    - 42 + + -
    +
    +
      - SmtProof [][]byte +
    - 43 + + -
    +
    +
      - } +
    - 44 + + -
    +
    +
     
    @@ -270027,218 +39844,223 @@

    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 +
    +
    +   +
    - 69 + + -
    +
    +
      - } +
    - 70 + + -
    +
    +
     
    - 71 + + -
    +
    +
      - // ProcessBlockResponse represents the response of a block +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_initial_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -19,9 +19,9 @@
    - 19 + + -
    +
    +
      - // NewProcessorL1InitialSequenceBatchesElderberry returns instance of a processor for InitialSequenceBatchesOrder +
    - 20 + + -
    +
    +
      - func NewProcessorL1InitialSequenceBatchesElderberry(previousProcessor actions.L1EventProcessor) *ProcessorL1InitialSequenceBatchesElderberry { +
    - 21 + + -
    +
    +
      - return &ProcessorL1InitialSequenceBatchesElderberry{ +
    - 22 + + -
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1InitialSequenceBatchesElderberry]( +
    +
    +   +
    - 23 + + -
    - - - []etherman.EventOrder{etherman.InitialSequenceBatchesOrder}, +
    +
    +   +
    - 24 + + -
    - - - actions.ForksIdOnlyElderberry), +
    +
    +   +
    - 25 + + -
    +
    +
      - previousProcessor: previousProcessor, +
    - 26 + + -
    +
    +
      - } +
    - 27 + + -
    +
    +
      - } +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 19 + + -
    +
    +
      - // NewProcessorL1InitialSequenceBatchesElderberry returns instance of a processor for InitialSequenceBatchesOrder +
    - 20 + + -
    +
    +
      - func NewProcessorL1InitialSequenceBatchesElderberry(previousProcessor actions.L1EventProcessor) *ProcessorL1InitialSequenceBatchesElderberry { +
    - 21 + + -
    +
    +
      - return &ProcessorL1InitialSequenceBatchesElderberry{ +
    - 22 + + -
    - + - ProcessorBase: actions.ProcessorBase[ProcessorL1InitialSequenceBatchesElderberry]{ +
    +
    +   +
    - 23 + + -
    - + - SupportedEvent: []etherman.EventOrder{etherman.InitialSequenceBatchesOrder}, +
    +
    +   +
    - 24 + + -
    - + - SupportedForkdIds: &actions.ForksIdOnlyElderberry}, +
    +
    +   +
    - 25 + + -
    +
    +
      - previousProcessor: previousProcessor, +
    - 26 + + -
    +
    +
      - } +
    - 27 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -270814,567 +40574,553 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -3,7 +3,6 @@
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "context" +
    - 5 + + -
    +
    +
      - "errors" +
    - 6 + + -
    - - - "fmt" +
    +
    +   +
    - 7 + + -
    +
    +
      - "time" +
    - 8 + + -
    +
    +
     
    - 9 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/etherman" +
    -
    @@ -40,9 +39,9 @@
    -
    - 40 + + -
    +
    +
      - // NewProcessorL1SequenceBatchesElderberry returns instance of a processor for SequenceBatchesOrder +
    - 41 + + -
    +
    +
      - func NewProcessorL1SequenceBatchesElderberry(previousProcessor PreviousProcessor, state StateL1SequenceBatchesElderberry) *ProcessorL1SequenceBatchesElderberry { +
    - 42 + + -
    +
    +
      - return &ProcessorL1SequenceBatchesElderberry{ +
    - 43 + + -
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1SequenceBatchesElderberry]( +
    +
    +   +
    - 44 + + -
    - - - []etherman.EventOrder{etherman.SequenceBatchesOrder}, +
    +
    +   +
    - 45 + + -
    - - - actions.ForksIdOnlyElderberry), +
    +
    +   +
    - 46 + + -
    +
    +
      - previousProcessor: previousProcessor, +
    - 47 + + -
    +
    +
      - state: state, +
    - 48 + + -
    +
    +
      - } +
    -
    @@ -60,58 +59,12 @@
    -
    - 60 + + -
    +
    +
     
    - 61 + + -
    +
    +
      - sbatch := l1Block.SequencedBatches[order.Pos][0] +
    - 62 + + -
    +
    +
     
    @@ -270774,33 +40534,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 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 + + -
    - - - // We known that the MaxSequenceTimestamp is the same for all the batches so we can use the first one +
    +
    +   +
    - 73 + + -
    - - - err = g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0), dbTx) +
    +
    +   +
    - 74 + + -
    - - - // The last L2block timestamp must match MaxSequenceTimestamp +
    +
    +   +
    - 75 + + -
    - - - if err != nil { +
    +
    +   +
    - 76 + + -
    - - - return err +
    +
    +   +
    - 77 + + -
    - - - } +
    +
    +   +
    - 78 + + -
    - - - // It checks the timestamp of the last L2 block, but it's just log an error instead of refusing the event +
    +
    +   +
    - 79 + + -
    - - - _ = g.sanityCheckTstampLastL2Block(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp, dbTx) +
    +
    +   +
    - 80 + + -
    - - - return nil +
    +
    +   +
    - 81 + + -
    - - - } +
    +
    +   +
    - 82 + + -
    - - +
    +
    +  
    - 83 + + -
    - - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckExpectedSequence(initialBatchNumber uint64, dbTx pgx.Tx) error { +
    +
    +   +
    - 84 + + -
    - - - // We need to check that the sequence match +
    +
    +   +
    - 85 + + -
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) +
    +
    +   +
    - 86 + + -
    - - - if err != nil { +
    +
    +   +
    - 87 + + -
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +
    +
    +   +
    - 88 + + -
    - - - return err +
    +
    +   +
    - 89 + + -
    - - - } +
    +
    +   +
    - 90 + + -
    - - - if lastVirtualBatchNum != initialBatchNumber { +
    +
    +   +
    - 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) +
    +
    +   +
    - 92 + + -
    - - - 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 + + -
    - - - } +
    +
    +   +
    - 94 + + -
    - - - return nil +
    +
    +   +
    - 95 + + -
    - - - } +
    +
    +   +
    - 96 + + -
    +
    +
     
    - 97 + + -
    - - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckTstampLastL2Block(timeLimit uint64, dbTx pgx.Tx) error { +
    +
    +   +
    - 98 + + -
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) +
    +
    +   +
    - 99 + + -
    - - - if err != nil { +
    +
    +   +
    - 100 + + -
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +
    +
    +   +
    - 101 + + -
    - - - return err +
    +
    +   +
    - 102 + + -
    - - - } +
    +
    +   +
    - 103 + + -
    - - - lastL2Block, err := g.state.GetLastL2BlockByBatchNumber(context.Background(), lastVirtualBatchNum, dbTx) +
    +
    +   +
    - 104 + + -
    - - - if err != nil { +
    +
    +   +
    - 105 + + -
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +
    +
    +   +
    - 106 + + -
    - - - return err +
    +
    +   +
    - 107 + + -
    - - - } +
    +
    +   +
    - 108 + + -
    - - - if lastL2Block == nil { +
    +
    +   +
    - 109 + + -
    - - - //TODO: find the previous batch until we find a L2 block to check the timestamp +
    +
    +   +
    - 110 + + -
    - - - return nil +
    +
    +   +
    - 111 + + -
    - - - } +
    +
    +   +
    - 112 + + -
    - - - if uint64(lastL2Block.ReceivedAt.Unix()) > timeLimit { +
    +
    +   +
    - 113 + + -
    - - - 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()) +
    +
    +   +
    - 114 + + -
    - - - return fmt.Errorf("wrong timestamp of last L2 block timestamp with L1 event timestamp") +
    +
    +   +
    - 115 + + -
    - - - } +
    +
    +   +
    - 116 + + -
    - - - return nil +
    +
    +   +
    - 117 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -271388,223 +41134,213 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -271898,23 +41634,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -272108,13 +41844,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -272122,21 +41858,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "context" +
    - 5 + + -
    +
    +
      - "errors" +
    - 6 + + -
    +
    +
      - "time" +
    - 7 + + -
    +
    +
     
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/etherman" +
    -
     
    -
    - 39 + + -
    +
    +
      - // NewProcessorL1SequenceBatchesElderberry returns instance of a processor for SequenceBatchesOrder +
    - 40 + + -
    +
    +
      - func NewProcessorL1SequenceBatchesElderberry(previousProcessor PreviousProcessor, state StateL1SequenceBatchesElderberry) *ProcessorL1SequenceBatchesElderberry { +
    - 41 + + -
    +
    +
      - return &ProcessorL1SequenceBatchesElderberry{ +
    - 42 + + -
    - + - ProcessorBase: actions.ProcessorBase[ProcessorL1SequenceBatchesElderberry]{ +
    +
    +   +
    - 43 + + -
    - + - SupportedEvent: []etherman.EventOrder{etherman.SequenceBatchesOrder}, +
    +
    +   +
    - 44 + + -
    - + - SupportedForkdIds: &actions.ForksIdOnlyElderberry}, +
    +
    +   +
    - 45 + + -
    +
    +
      - previousProcessor: previousProcessor, +
    - 46 + + -
    +
    +
      - state: state, +
    - 47 + + -
    +
    +
      - } +
    -
     
    -
    - 59 + + -
    +
    +
     
    - 60 + + -
    +
    +
      - sbatch := l1Block.SequencedBatches[order.Pos][0] +
    - 61 + + -
    +
    +
     
    - 62 + + -
    - + - executionTime := l1Block.ReceivedAt +
    +
    +   +
    - 63 + + -
    +
    +
      - 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 + + -
    +
    +
      - } +
    - 68 + + -
    +
    +
     
    - 69 + + -
    - + - return g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, executionTime, dbTx) +
    +
    +   +
    - 70 + + -
    +
    +
      - } +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update.go - RENAMED - -
    -
    @@ -272144,2109 +41865,2681 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - -
    -
    @@ -24,9 +24,9 @@
    +
     
    + + 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 +
    -   - // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder + + +
    +
    +
    + 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 {
    - 25 + + 81 +
    -   - func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeInterface) *ProcessorL1InfoTreeUpdate { + + + d.committeeMembers = committee.Members
    - 26 + + 82 +
    -   - return &ProcessorL1InfoTreeUpdate{ + + + if len(committee.Members) > 0 {
    - 27 + + 83 +
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate]( + + + selectedCommitteeMember = rand.Intn(len(committee.Members)) //nolint:gosec
    - 28 + + 84 +
    - - - []etherman.EventOrder{etherman.L1InfoTreeOrder}, + + + }
    - 29 + + 85 +
    - - - actions.ForksIdToElderberry), + + + }
    - 30 + + 86 +
    -   - state: state} + + + d.selectedCommitteeMember = selectedCommitteeMember
    - 31 + + 87 +
    -   - } + + + return nil
    - 32 + + 88 +
    -   -
    -
    -
    -
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 24 + + 89 +
    -   - // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder + + +
    - 25 + + 90 +
    -   - func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeInterface) *ProcessorL1InfoTreeUpdate { + + + // GetSequence gets backend data one hash at a time. This should be optimized on the DAC side to get them all at once.
    - 26 + + 91 +
    -   - return &ProcessorL1InfoTreeUpdate{ + + + func (d *DataCommitteeBackend) GetSequence(ctx context.Context, hashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
    - 27 + + 92 +
    + - ProcessorBase: actions.ProcessorBase[ProcessorL1InfoTreeUpdate]{ + // TODO: optimize this on the DAC side by implementing a multi batch retrieve api
    - 28 + + 93 +
    + - SupportedEvent: []etherman.EventOrder{etherman.L1InfoTreeOrder}, + var batchData [][]byte
    - 29 + + 94 +
    + - SupportedForkdIds: &actions.ForksIdAll}, + for _, h := range hashes {
    - 30 + + 95 +
    -   - state: state} + + + data, err := d.GetBatchL2Data(h)
    - 31 + + 96 +
    -   - } + + + if err != nil {
    - 32 + + 97 +
    -   -
    -
    -
    -
    + + + return nil, err
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -45,7 +45,7 @@
    - 45 + + 98 +
    -   - if err != nil { + + + }
    - 46 + + 99 +
    -   - panic(err) + + + batchData = append(batchData, data)
    - 47 + + 100 +
    -   + + }
    - 48 + + 101 +
    - - - testState := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), nil, nil, nil, mt, nil) + + + return batchData, nil
    - 49 + + 102 +
    -   -
    + + + }
    - 50 + + 103 +
    -   - sut := NewProcessorL1InfoTreeUpdate(testState) + + +
    - 51 + + 104 +
    -   - l1infotree := etherman.GlobalExitRoot{ -
    -
    -
    + + + // GetBatchL2Data returns the data from the DAC. It checks that it matches with the expected hash
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 45 + + 105 +
    -   - if err != nil { + + + func (d *DataCommitteeBackend) GetBatchL2Data(hash common.Hash) ([]byte, error) {
    - 46 + + 106 +
    -   - panic(err) + + + intialMember := d.selectedCommitteeMember
    - 47 + + 107 +
    -   - } + + + found := false
    - 48 + + 108 +
    + - testState := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), nil, nil, nil, mt) + for !found && intialMember != -1 {
    - 49 + + 109 +
    -   -
    + + + member := d.committeeMembers[d.selectedCommitteeMember]
    - 50 + + 110 +
    -   - sut := NewProcessorL1InfoTreeUpdate(testState) + + + log.Infof("trying to get data from %s at %s", member.Addr.Hex(), member.URL)
    - 51 + + 111 +
    -   - l1infotree := etherman.GlobalExitRoot{ -
    -
    -
    + + + c := d.dataCommitteeClientFactory.New(member.URL)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -32,6 +32,7 @@
    - 32 + + 112 +
    -   - AddVirtualBatch(ctx context.Context, virtualBatch *state.VirtualBatch, dbTx pgx.Tx) error + + + data, err := c.GetOffChainData(d.ctx, hash)
    - 33 + + 113 +
    -   - AddTrustedReorg(ctx context.Context, trustedReorg *state.TrustedReorg, dbTx pgx.Tx) error + + + if err != nil {
    - 34 + + 114 +
    -   - GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error) + + + log.Warnf(
    - + + 115 -
    -   -
    +
    +
    + + + "error getting data from DAC node %s at %s: %s",
    - 35 + + 116 +
    -   - } + + + member.Addr.Hex(), member.URL, err,
    - 36 + + 117 +
    -   -
    + + + )
    - 37 + + 118 +
    -   - type syncProcessSequenceBatchesInterface interface { + + + d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers)
    -
    @@ -55,9 +56,9 @@
    -
    - 55 + + 119 +
    -   - timeProvider syncCommon.TimeProvider, + + + if d.selectedCommitteeMember == intialMember {
    - 56 + + 120 +
    -   - halter syncinterfaces.CriticalErrorHandler) *ProcessorL1SequenceBatchesEtrog { + + + break
    - 57 + + 121 +
    -   - return &ProcessorL1SequenceBatchesEtrog{ + + + }
    - 58 + + 122 +
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1SequenceBatchesEtrog]( + + + continue
    - 59 + + 123 +
    - - - []etherman.EventOrder{etherman.SequenceBatchesOrder, etherman.InitialSequenceBatchesOrder}, + + + }
    - 60 + + 124 +
    - - - actions.ForksIdOnlyEtrog), + + + actualTransactionsHash := crypto.Keccak256Hash(data)
    - 61 + + 125 +
    -   - state: state, + + + if actualTransactionsHash != hash {
    - 62 + + 126 +
    -   - sync: sync, + + + unexpectedHash := fmt.Errorf(
    - 63 + + 127 +
    -   - timeProvider: timeProvider, + + + unexpectedHashTemplate, hash, actualTransactionsHash,
    -
    @@ -158,7 +159,7 @@
    -
    - 158 + + 128 +
    -   - SkipVerifyL1InfoRoot: 1, + + + )
    - 159 + + 129 +
    -   - ClosingReason: state.SyncL1EventSequencedForcedBatchClosingReason, + + + log.Warnf(
    - 160 + + 130 +
    -   - } + + + "error getting data from DAC node %s at %s: %s",
    - 161 + + 131 +
    - - - } else if sbatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp > 0 && sbatch.BatchNumber == 1 { + + + member.Addr.Hex(), member.URL, unexpectedHash,
    - 162 + + 132 +
    -   - log.Debug("Processing initial batch") + + + )
    - 163 + + 133 +
    -   - batch.GlobalExitRoot = sbatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot + + + d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers)
    - 164 + + 134 +
    -   - var fBHL1 common.Hash = sbatch.PolygonRollupBaseEtrogBatchData.ForcedBlockHashL1 + + + if d.selectedCommitteeMember == intialMember {
    -
    @@ -251,6 +252,17 @@
    -
    - 251 + + 135 +
    -   - return err + + + break
    - 252 + + 136 +
    -   + + }
    - 253 + + 137 +
    -   - } else { -
    -
    - - -
    -   -
    + + + 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 {
    - 254 + + 148 +
    -   - // Reprocess batch to compare the stateRoot with tBatch.StateRoot and get accInputHash + + + addr common.Address
    - 255 + + 149 +
    -   - batchRespose, err := p.state.ExecuteBatchV2(ctx, batch, processCtx.L1InfoRoot, leaves, *processCtx.Timestamp, false, processCtx.SkipVerifyL1InfoRoot, processCtx.ForcedBlockHashL1, dbTx) + + + signature []byte
    - 256 + + 150 +
    -   - if err != nil { -
    -
    -
    + + + err error
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 32 + + 151 +
    -   - AddVirtualBatch(ctx context.Context, virtualBatch *state.VirtualBatch, dbTx pgx.Tx) error + + + }
    - 33 + + 152 +
    -   - AddTrustedReorg(ctx context.Context, trustedReorg *state.TrustedReorg, dbTx pgx.Tx) error + + +
    - 34 + + 153 +
    -   - GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error) + + + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
    - 35 + 154
    + - UpdateBatchTimestamp(ctx context.Context, batchNumber uint64, timestamp time.Time, dbTx pgx.Tx) error + // as expected by the contract
    - 36 + + 155 +
    -   - } + + + func (s *DataCommitteeBackend) PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) {
    - 37 + + 156 +
    -   -
    + + + // Get current committee
    - 38 + + 157 +
    -   - type syncProcessSequenceBatchesInterface interface { + + + committee, err := s.getCurrentDataCommittee()
    -
     
    -
    - 56 + + 158 +
    -   - timeProvider syncCommon.TimeProvider, + + + if err != nil {
    - 57 + + 159 +
    -   - halter syncinterfaces.CriticalErrorHandler) *ProcessorL1SequenceBatchesEtrog { + + + return nil, err
    - 58 + + 160 +
    -   - return &ProcessorL1SequenceBatchesEtrog{ + + + }
    - 59 + + 161 +
    + - ProcessorBase: actions.ProcessorBase[ProcessorL1SequenceBatchesEtrog]{ +
    - 60 + + 162 +
    + - SupportedEvent: []etherman.EventOrder{etherman.SequenceBatchesOrder, etherman.InitialSequenceBatchesOrder}, + // Authenticate as trusted sequencer by signing the sequences
    - 61 + + 163 +
    + - SupportedForkdIds: &actions.ForksIdOnlyEtrog}, + sequence := daTypes.Sequence{}
    - 62 + + 164 +
    -   - state: state, + + + for _, seq := range batchesData {
    - 63 + + 165 +
    -   - sync: sync, + + + sequence = append(sequence, seq)
    - 64 + + 166 +
    -   - timeProvider: timeProvider, + + + }
    -
     
    -
    - 159 + + 167 +
    -   - SkipVerifyL1InfoRoot: 1, + + + signedSequence, err := sequence.Sign(s.privKey)
    - 160 + + 168 +
    -   - ClosingReason: state.SyncL1EventSequencedForcedBatchClosingReason, + + + if err != nil {
    - 161 + + 169 +
    -   - } + + + return nil, err
    - 162 + + 170 +
    + - } else if sbatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp > 0 && sbatch.BatchNumber == 1 { // This is the initial batch (injected) + }
    - 163 + + 171 +
    -   - log.Debug("Processing initial batch") + + +
    - 164 + + 172 +
    -   - batch.GlobalExitRoot = sbatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot + + + // Request signatures to all members in parallel
    - 165 + + 173 +
    -   - var fBHL1 common.Hash = sbatch.PolygonRollupBaseEtrogBatchData.ForcedBlockHashL1 + + + ch := make(chan signatureMsg, len(committee.Members))
    -
     
    -
    - 252 + + 174 +
    -   - return err + + + signatureCtx, cancelSignatureCollection := context.WithCancel(ctx)
    - 253 + + 175 +
    -   - } + + + for _, member := range committee.Members {
    - 254 + + 176 +
    -   - } else { + + + go requestSignatureFromMember(signatureCtx, *signedSequence, member, ch)
    - 255 + 177
    + - // Batch already exists + }
    - 256 + 178
    + - // We update the timestamp of the batch to match the timestamp +
    - 257 + 179
    + - err := p.state.UpdateBatchTimestamp(ctx, batch.BatchNumber, *processCtx.Timestamp, dbTx) + // Collect signatures
    - 258 + 180
    + - if err != nil { + msgs := []signatureMsg{}
    - 259 + 181
    + - log.Errorf("error updating batch timestamp %s. BatchNumber: %d, BlockNumber: %d, error: %v", processCtx.Timestamp, batch.BatchNumber, blockNumber, err) + var (
    - 260 + 182
    + - rollbackErr := dbTx.Rollback(ctx) + collectedSignatures uint64
    - 261 + 183
    + - if rollbackErr != nil { + failedToCollect uint64
    - 262 + 184
    + - log.Errorf("error rolling back state because error updating batch timestamp. BatchNumber: %d, BlockNumber: %d, rollbackErr: %s, error : %v", batch.BatchNumber, blockNumber, rollbackErr.Error(), err) + )
    - 263 + 185
    + - return rollbackErr + for collectedSignatures < committee.RequiredSignatures {
    - 264 + 186
    + - } + msg := <-ch
    - 265 + 187
    + - } + if msg.err != nil {
    - 266 + + 188 +
    -   - // Reprocess batch to compare the stateRoot with tBatch.StateRoot and get accInputHash + + + log.Errorf("error when trying to get signature from %s: %s", msg.addr, msg.err)
    - 267 + + 189 +
    -   - batchRespose, err := p.state.ExecuteBatchV2(ctx, batch, processCtx.L1InfoRoot, leaves, *processCtx.Timestamp, false, processCtx.SkipVerifyL1InfoRoot, processCtx.ForcedBlockHashL1, dbTx) + + + failedToCollect++
    - 268 + + 190 +
    -   - if err != nil { -
    -
    -
    + + + if len(committee.Members)-int(failedToCollect) < int(committee.RequiredSignatures) {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -101,9 +101,12 @@
    - 101 + + 191 +
    -   - expectationsPreExecution(t, mocks, ctx, batch, nil) + + + cancelSignatureCollection()
    - 102 + + 192 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + return nil, errors.New("too many members failed to send their signature")
    - 103 + + 193 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + }
    - + + 194 -
    -   -
    +
    +
    + + + } else {
    - 104 + + 195 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + log.Infof("received signature from %s", msg.addr)
    - 105 + + 196 +
    -   - expectationsAddSequencedBatch(t, mocks, ctx, executionResponse) + + + collectedSignatures++
    - + + 197 -
    -   -
    +
    +
    + + + }
    - 106 + + 198 +
    -   - err := sut.Process(ctx, etherman.Order{Pos: 1}, l1Block, mocks.DbTx) + + + msgs = append(msgs, msg)
    - + + 199 -
    -   -
    +
    +
    + + + }
    - 107 + + 200 +
    -   - require.NoError(t, err) + + +
    - 108 + + 201 +
    -   - } + + + // Stop requesting as soon as we have N valid signatures
    - 109 + + 202 +
    -   -
    + + + cancelSignatureCollection()
    -
    @@ -117,9 +120,12 @@
    -
    - 117 + + 203 +
    -   - expectationsPreExecution(t, mocks, ctx, batch, nil) + + +
    - 118 + + 204 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + return buildSignaturesAndAddrs(signatureMsgs(msgs), committee.Members), nil
    - 119 + + 205 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + }
    - + + 206 -
    -   +
    +
    + +
    - 120 + + 207 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + func requestSignatureFromMember(ctx context.Context, signedSequence daTypes.SignedSequence, member DataCommitteeMember, ch chan signatureMsg) {
    - 121 + + 208 +
    -   - expectationsAddSequencedBatch(t, mocks, ctx, executionResponse) -
    -
    - - -
    -   -
    + + + // request
    - 122 + + 209 +
    -   - err := sut.Process(ctx, etherman.Order{Pos: 1}, l1Block, mocks.DbTx) + + + c := client.New(member.URL)
    - + + 210 -
    -   -
    +
    +
    + + + log.Infof("sending request to sign the sequence to %s at %s", member.Addr.Hex(), member.URL)
    - 123 + + 211 +
    -   - require.NoError(t, err) + + + signature, err := c.SignSequence(signedSequence)
    - 124 + + 212 +
    -   - } + + + if err != nil {
    - 125 + + 213 +
    -   -
    + + + ch <- signatureMsg{
    -
    @@ -139,6 +145,7 @@
    -
    - 139 + + 214 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + addr: member.Addr,
    - 140 + + 215 +
    -   - executionResponse.NewStateRoot = common.HexToHash(hashExamplesValues[2]).Bytes() + + + err: err,
    - 141 + + 216 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + }
    - + + 217 -
    -   -
    +
    +
    + + + return
    - 142 + + 218 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + }
    - 143 + + 219 +
    -   - mocks.Synchronizer.EXPECT().IsTrustedSequencer().Return(false) + + + // verify returned signature
    - 144 + + 220 +
    -   - mocks.State.EXPECT().AddTrustedReorg(ctx, mock.Anything, mocks.DbTx).Return(nil) + + + signedSequence.Signature = signature
    -
    @@ -177,6 +184,7 @@
    -
    - 177 + + 221 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + signer, err := signedSequence.Signer()
    - 178 + + 222 +
    -   - executionResponse.NewStateRoot = common.HexToHash(hashExamplesValues[2]).Bytes() + + + if err != nil {
    - 179 + + 223 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + ch <- signatureMsg{
    - + + 224 -
    -   -
    +
    +
    + + + addr: member.Addr,
    - 180 + + 225 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + err: err,
    - 181 + + 226 +
    -   - mocks.Synchronizer.EXPECT().IsTrustedSequencer().Return(true) + + + }
    - 182 + + 227 +
    -   -
    + + + return
    -
    @@ -268,7 +276,7 @@
    -
    - 268 + + 228 +
    -   - TxHash: state.HashByteArray(batch.BatchL2Data), + + + }
    - 269 + + 229 +
    -   - Coinbase: batch.Coinbase, + + + if signer != member.Addr {
    - 270 + + 230 +
    -   - SequencerAddr: common.HexToAddress(addrExampleValues[0]), + + + ch <- signatureMsg{
    - 271 + + 231 +
    - - - PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + addr: member.Addr,
    - 272 + + 232 +
    -   - Transactions: []byte{}, + + + err: fmt.Errorf("invalid signer. Expected %s, actual %s", member.Addr.Hex(), signer.Hex()),
    - 273 + + 233 +
    -   - ForcedTimestamp: uint64(forcedTimestamp.Unix()), + + + }
    - 274 + + 234 +
    -   - ForcedGlobalExitRoot: forcedGlobalExitRoot, + + + return
    -
    @@ -284,7 +292,7 @@
    -
    - 284 + + 235 +
    -   - TxHash: state.HashByteArray(batch.BatchL2Data), + + + }
    - 285 + + 236 +
    -   - Coinbase: batch.Coinbase, + + + ch <- signatureMsg{
    - 286 + + 237 +
    -   - SequencerAddr: common.HexToAddress(addrExampleValues[0]), + + + addr: member.Addr,
    - 287 + + 238 +
    - - - PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + signature: signature,
    - 288 + + 239 +
    -   - Transactions: []byte{}, + + + }
    - 289 + + 240 +
    -   - }, + + + }
    - 290 + + 241 +
    -   - } + + +
    -
    @@ -295,7 +303,7 @@
    -
    - 295 + + 242 +
    -   - func newComposedL1Block(mocks *mocksEtrogProcessorL1, forcedBatch *etherman.SequencedBatch, l1InfoRoot common.Hash) *etherman.Block { + + + func buildSignaturesAndAddrs(sigs signatureMsgs, members []DataCommitteeMember) []byte {
    - 296 + + 243 +
    -   - l1Block := etherman.Block{ + + + const (
    - 297 + + 244 +
    -   - BlockNumber: 123, + + + sigLen = 65
    - 298 + + 245 +
    - - - ReceivedAt: mocks.TimeProvider.Now(), + + + addrLen = 20
    - 299 + + 246 +
    -   - SequencedBatches: [][]etherman.SequencedBatch{}, + + + )
    - 300 + + 247 +
    -   - } + + + res := make([]byte, 0, len(sigs)*sigLen+len(members)*addrLen)
    - 301 + + 248 +
    -   - l1Block.SequencedBatches = append(l1Block.SequencedBatches, []etherman.SequencedBatch{}) -
    -
    -
    + + + sort.Sort(sigs)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - @@ -274686,12 +44964,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_update_etrog_sequence.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee_test.go RENAMED
    - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 101 + + 249 +
    -   - expectationsPreExecution(t, mocks, ctx, batch, nil) + + + for _, msg := range sigs {
    - 102 + + 250 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + log.Debugf("adding signature %s from %s", common.Bytes2Hex(msg.signature), msg.addr.Hex())
    - 103 + + 251 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + res = append(res, msg.signature...)
    - 104 + 252
    + - mocks.State.EXPECT().UpdateBatchTimestamp(ctx, batch.BatchNumber, l1Block.ReceivedAt, mocks.DbTx).Return(nil) + }
    - 105 + + 253 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + for _, member := range members {
    - 106 + + 254 +
    -   - expectationsAddSequencedBatch(t, mocks, ctx, executionResponse) + + + log.Debugf("adding addr %s", common.Bytes2Hex(member.Addr.Bytes()))
    - 107 + 255
    + -
    + res = append(res, member.Addr.Bytes()...)
    - 108 + + 256 +
    -   - err := sut.Process(ctx, etherman.Order{Pos: 1}, l1Block, mocks.DbTx) + + + }
    - 109 + 257
    + -
    + log.Debugf("full res %s", common.Bytes2Hex(res))
    - 110 + + 258 +
    -   - require.NoError(t, err) + + + return res
    - 111 + + 259 +
    -   + + }
    - 112 + + 260 +
    -   + +
    -
     
    +
    + 261 + +
    + + + type signatureMsgs []signatureMsg +
    - 120 + + 262 +
    -   - expectationsPreExecution(t, mocks, ctx, batch, nil) + + +
    - 121 + + 263 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + func (s signatureMsgs) Len() int { return len(s) }
    - 122 + + 264 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + func (s signatureMsgs) Less(i, j int) bool {
    - 123 + 265
    + - mocks.State.EXPECT().UpdateBatchTimestamp(ctx, batch.BatchNumber, l1Block.ReceivedAt, mocks.DbTx).Return(nil) + return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex())
    - 124 + + 266 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + }
    - 125 + + 267 +
    -   - expectationsAddSequencedBatch(t, mocks, ctx, executionResponse) + + + func (s signatureMsgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
    - 126 + 268
    @@ -274255,428 +44548,413 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 127 + + 269 +
    -   - err := sut.Process(ctx, etherman.Order{Pos: 1}, l1Block, mocks.DbTx) + + + // getCurrentDataCommittee return the currently registered data committee
    - 128 + 270
    + -
    + func (d *DataCommitteeBackend) getCurrentDataCommittee() (*DataCommittee, error) {
    - 129 + + 271 +
    -   - require.NoError(t, err) + + + addrsHash, err := d.dataCommitteeContract.CommitteeHash(&bind.CallOpts{Pending: false})
    - 130 + + 272 +
    -   - } + + + if err != nil {
    - 131 + + 273 +
    -   -
    + + + return nil, fmt.Errorf("error getting CommitteeHash from L1 SC: %w", err)
    -
     
    -
    - 145 + + 274 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + }
    - 146 + + 275 +
    -   - executionResponse.NewStateRoot = common.HexToHash(hashExamplesValues[2]).Bytes() + + + reqSign, err := d.dataCommitteeContract.RequiredAmountOfSignatures(&bind.CallOpts{Pending: false})
    - 147 + + 276 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + + if err != nil {
    - 148 + 277
    + - mocks.State.EXPECT().UpdateBatchTimestamp(ctx, batch.BatchNumber, l1Block.ReceivedAt, mocks.DbTx).Return(nil) + return nil, fmt.Errorf("error getting RequiredAmountOfSignatures from L1 SC: %w", err)
    - 149 + + 278 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + }
    - 150 + + 279 +
    -   - mocks.Synchronizer.EXPECT().IsTrustedSequencer().Return(false) + + + members, err := d.getCurrentDataCommitteeMembers()
    - 151 + + 280 +
    -   - mocks.State.EXPECT().AddTrustedReorg(ctx, mock.Anything, mocks.DbTx).Return(nil) + + + if err != nil {
    -
     
    -
    - 184 + + 281 +
    -   - executionResponse := newProcessBatchResponseV2(batch) + + + return nil, err
    - 185 + + 282 +
    -   - executionResponse.NewStateRoot = common.HexToHash(hashExamplesValues[2]).Bytes() + + + }
    - 186 + + 283 +
    -   - expectationsForExecution(t, mocks, ctx, l1Block.SequencedBatches[1][0], l1Block.ReceivedAt, executionResponse) + + +
    - 187 + 284
    + - mocks.State.EXPECT().UpdateBatchTimestamp(ctx, batch.BatchNumber, l1Block.ReceivedAt, mocks.DbTx).Return(nil) + return &DataCommittee{
    - 188 + + 285 +
    -   - mocks.State.EXPECT().AddAccumulatedInputHash(ctx, executionResponse.NewBatchNum, common.BytesToHash(executionResponse.NewAccInputHash), mocks.DbTx).Return(nil) + + + AddressesHash: common.Hash(addrsHash),
    - 189 + + 286 +
    -   - mocks.Synchronizer.EXPECT().IsTrustedSequencer().Return(true) + + + RequiredSignatures: reqSign.Uint64(),
    - 190 + + 287 +
    -   -
    + + + Members: members,
    -
     
    -
    - 276 + + 288 +
    -   - TxHash: state.HashByteArray(batch.BatchL2Data), + + + }, nil
    - 277 + + 289 +
    -   - Coinbase: batch.Coinbase, + + + }
    - 278 + + 290 +
    -   - SequencerAddr: common.HexToAddress(addrExampleValues[0]), + + +
    - 279 + + 291 +
    + - PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{ + // getCurrentDataCommitteeMembers return the currently registered data committee members
    - 280 + + 292 +
    -   - Transactions: []byte{}, + + + func (d *DataCommitteeBackend) getCurrentDataCommitteeMembers() ([]DataCommitteeMember, error) {
    - 281 + + 293 +
    -   - ForcedTimestamp: uint64(forcedTimestamp.Unix()), + + + nMembers, err := d.dataCommitteeContract.GetAmountOfMembers(&bind.CallOpts{Pending: false})
    - 282 + + 294 +
    -   - ForcedGlobalExitRoot: forcedGlobalExitRoot, + + + if err != nil {
    -
     
    -
    - 292 + + 295 +
    -   - TxHash: state.HashByteArray(batch.BatchL2Data), + + + return nil, fmt.Errorf("error getting GetAmountOfMembers from L1 SC: %w", err)
    - 293 + + 296 +
    -   - Coinbase: batch.Coinbase, + + + }
    - 294 + + 297 +
    -   - SequencerAddr: common.HexToAddress(addrExampleValues[0]), + + + members := make([]DataCommitteeMember, 0, nMembers.Int64())
    - 295 + + 298 +
    + - PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{ + for i := int64(0); i < nMembers.Int64(); i++ {
    - 296 + + 299 +
    -   - Transactions: []byte{}, + + + member, err := d.dataCommitteeContract.Members(&bind.CallOpts{Pending: false}, big.NewInt(i))
    - 297 + + 300 +
    -   - }, + + + if err != nil {
    - 298 + + 301 +
    -   - } + + + return nil, fmt.Errorf("error getting Members %d from L1 SC: %w", i, err)
    -
     
    +
    + 302 + +
    + + + } +
    + 303 +
    -   - func newComposedL1Block(mocks *mocksEtrogProcessorL1, forcedBatch *etherman.SequencedBatch, l1InfoRoot common.Hash) *etherman.Block { + + + members = append(members, DataCommitteeMember{
    + 304 +
    -   - l1Block := etherman.Block{ + + + Addr: member.Addr,
    + 305 +
    -   - BlockNumber: 123, + + + URL: member.Url,
    + 306 +
    + - ReceivedAt: time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC), + })
    + 307 +
    -   - SequencedBatches: [][]etherman.SequencedBatch{}, + + + }
    + 308 +
    -   - } + + + return members, nil
    + 309 +
    -   - l1Block.SequencedBatches = append(l1Block.SequencedBatches, []etherman.SequencedBatch{}) + + + }
    -
    @@ -38,9 +38,9 @@
    +
    @@ -0,0 +1,131 @@
    - 38 + + -
    +
    +
      - sync syncProcessUpdateEtrogSequenceInterface, +
    - 39 + + -
    +
    +
      - timeProvider syncCommon.TimeProvider) *ProcessorL1UpdateEtrogSequence { +
    - 40 + + -
    +
    +
      - return &ProcessorL1UpdateEtrogSequence{ +
    - 41 + + -
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1UpdateEtrogSequence]( +
    +
    +   +
    - 42 + + -
    - - - []etherman.EventOrder{etherman.UpdateEtrogSequenceOrder}, +
    +
    +   +
    - 43 + + -
    - - - actions.ForksIdOnlyEtrog), +
    +
    +   +
    - 44 + + -
    +
    +
      - state: state, +
    - 45 + + -
    +
    +
      - sync: sync, +
    - 46 + + -
    +
    +
      - timeProvider: timeProvider, +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 38 + + -
    +
    +
      - sync syncProcessUpdateEtrogSequenceInterface, +
    - 39 + + -
    +
    +
      - timeProvider syncCommon.TimeProvider) *ProcessorL1UpdateEtrogSequence { +
    - 40 + + -
    +
    +
      - return &ProcessorL1UpdateEtrogSequence{ +
    - 41 + + -
    - + - ProcessorBase: actions.ProcessorBase[ProcessorL1UpdateEtrogSequence]{ +
    +
    +   +
    - 42 + + -
    - + - SupportedEvent: []etherman.EventOrder{etherman.UpdateEtrogSequenceOrder}, +
    +
    +   +
    - 43 + + -
    - + - SupportedForkdIds: &actions.ForksIdOnlyEtrog}, +
    +
    +   +
    - 44 + + -
    +
    +
      - state: state, +
    - 45 + + -
    +
    +
      - sync: sync, +
    - 46 + + -
    +
    +
      - timeProvider: timeProvider, +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_info_tree_update.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - -
    -
    @@ -1,54 +0,0 @@
    - 1 + + -
    - - - package feijoa +
    +
    +   +
    - 2 + + -
    - - +
    +
    +  
    - 3 + + -
    - - - import ( +
    +
    +   +
    - 4 + + -
    - - - "context" +
    +
    +   +
    - 5 + + -
    - - +
    +
    +  
    - 6 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" +
    +
    +   +
    - 7 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    +   +
    - 8 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    +   +
    - 9 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions" +
    +
    +   +
    - 10 + + -
    - - - "github.com/jackc/pgx/v4" +
    +
    +   +
    - 11 + + -
    - - - ) +
    +
    +   +
    - 12 + + -
    - - +
    +
    +  
    - 13 + + -
    - - - // stateProcessorL1InfoTreeInterface interface required from state +
    +
    +   +
    - 14 + + -
    - - - type stateProcessorL1InfoTreeRecursiveInterface interface { +
    +
    +   +
    - 15 + + -
    - - - AddL1InfoTreeRecursiveLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error) +
    +
    +   +
    - 16 + + -
    - - - } +
    +
    +   +
    - 17 + + -
    - - +
    +
    +  
    - 18 + + -
    - - - // ProcessorL1InfoTreeUpdate implements L1EventProcessor for GlobalExitRootsOrder +
    +
    +   +
    - 19 + + -
    - - - type ProcessorL1InfoTreeUpdate struct { +
    +
    +   +
    - 20 + + -
    - - - actions.ProcessorBase[ProcessorL1InfoTreeUpdate] +
    +
    +   +
    - 21 + + -
    - - - state stateProcessorL1InfoTreeRecursiveInterface +
    +
    +   +
    - 22 + + -
    - - - } +
    +
    +   +
    - 23 + + -
    - - +
    +
    +  
    - 24 + + -
    - - - // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder +
    +
    +   +
    - 25 + + -
    - - - func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeRecursiveInterface) *ProcessorL1InfoTreeUpdate { +
    +
    +   +
    - 26 + + -
    - - - return &ProcessorL1InfoTreeUpdate{ +
    +
    +   +
    - 27 + + -
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate]( +
    +
    +   +
    - 28 + + -
    - - - []etherman.EventOrder{etherman.L1InfoTreeOrder}, +
    +
    +   +
    - 29 + + -
    - - - actions.ForksIdOnlyFeijoa), +
    +
    +   +
    - 30 + + -
    - - - state: state} +
    +
    +   +
    - 31 + + -
    - - - } +
    +
    +   +
    - 32 + + -
    - - +
    +
    +  
    - 33 + + -
    - - - // Process process event +
    +
    +   +
    - 34 + + -
    - - - func (p *ProcessorL1InfoTreeUpdate) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error { +
    +
    +   +
    - 35 + + -
    - - - l1InfoTree := l1Block.L1InfoTree[order.Pos] +
    +
    +   +
    - 36 + + -
    - - - ger := state.GlobalExitRoot{ +
    +
    +   +
    - 37 + + -
    - - - BlockNumber: l1InfoTree.BlockNumber, +
    +
    +   +
    - 38 + + -
    - - - MainnetExitRoot: l1InfoTree.MainnetExitRoot, +
    +
    +   +
    - 39 + + -
    - - - RollupExitRoot: l1InfoTree.RollupExitRoot, +
    +
    +   +
    - 40 + + -
    - - - GlobalExitRoot: l1InfoTree.GlobalExitRoot, +
    +
    +   +
    - 41 + + -
    - - - Timestamp: l1InfoTree.Timestamp, +
    +
    +   +
    - 42 + + -
    - - - } +
    +
    +   +
    - 43 + + -
    - - - l1IntoTreeLeaf := state.L1InfoTreeLeaf{ +
    +
    +   +
    - 44 + + -
    - - - GlobalExitRoot: ger, +
    +
    +   +
    - 45 + + -
    - - - PreviousBlockHash: l1InfoTree.PreviousBlockHash, +
    +
    +   +
    - 46 + + -
    - - - } +
    +
    +   +
    - 47 + + -
    - - - entry, err := p.state.AddL1InfoTreeRecursiveLeaf(ctx, &l1IntoTreeLeaf, dbTx) +
    +
    +   +
    - 48 + + -
    - - - if err != nil { +
    +
    +   +
    - 49 + + -
    - - - log.Errorf("error storing the l1InfoTree(feijoa). BlockNumber: %d, error: %v", l1Block.BlockNumber, err) +
    +
    +   +
    - 50 + + -
    - - - return err +
    +
    +   +
    - 51 + + -
    - - - } +
    +
    +   +
    - 52 + + -
    - - - log.Infof("L1InfoTree(feijoa) stored. BlockNumber: %d,GER:%s L1InfoTreeIndex: %d L1InfoRoot:%s", l1Block.BlockNumber, entry.GlobalExitRoot.GlobalExitRoot, entry.L1InfoTreeIndex, entry.L1InfoTreeRoot) +
    +
    +   +
    - 53 + + -
    - - - return nil +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 54 + + -
    - - - } +
    +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    - - - - -
    -
     
    @@ -276030,21 +46301,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs.go - RENAMED - -
    -
    @@ -276052,2281 +46308,2589 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + +
    -
    @@ -1,189 +0,0 @@
    +
     
    + 1 +
    - - - package feijoa + + + package datacommittee
    + 2 +
    - - + +
    + 3 +
    - - + + import (
    + 4 +
    - - - "context" + + + "math/big"
    + 5 +
    - - - "errors" + + + "testing"
    + 6 +
    - - - "time" + + +
    + 7 +
    - - -
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee"
    + 8 +
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" + + + "github.com/0xPolygonHermez/zkevm-node/log"
    + 9 +
    - - - "github.com/0xPolygonHermez/zkevm-node/log" + + + "github.com/ethereum/go-ethereum/accounts/abi/bind"
    + 10 +
    - - - "github.com/0xPolygonHermez/zkevm-node/state" + + + "github.com/ethereum/go-ethereum/common"
    + 11 +
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions" + + + "github.com/ethereum/go-ethereum/core"
    + 12 +
    - - - commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + + + "github.com/ethereum/go-ethereum/crypto"
    + 13 +
    - - - "github.com/ethereum/go-ethereum/common" + + + "github.com/ethereum/go-ethereum/ethclient/simulated"
    + 14 +
    - - - "github.com/jackc/pgx/v4" + + + "github.com/stretchr/testify/assert"
    + 15 +
    - - - ) + + + "github.com/stretchr/testify/require"
    + 16 +
    - - -
    + + + )
    + 17 +
    - - - // stateProcessorSequenceBlobsInterface interface required from state + + +
    + 18 +
    - - - type stateProcessorSequenceBlobsInterface interface { + + + func TestUpdateDataCommitteeEvent(t *testing.T) {
    + 19 +
    - - - AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error + + + // Set up testing environment
    + 20 +
    - - - GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error) + + + dac, ethBackend, auth, da := newTestingEnv(t)
    + 21 +
    - - - AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error + + +
    + 22 +
    - - - GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) + + + // Update the committee
    + 23 +
    - - - } + + + requiredAmountOfSignatures := big.NewInt(2)
    + 24 +
    - - -
    + + + URLs := []string{"1", "2", "3"}
    + 25 +
    - - - type stateBlobInnerProcessor interface { + + + addrs := []common.Address{
    + 26 +
    - - - ProcessBlobInner(ctx context.Context, request state.ProcessBlobInnerProcessRequest, data []byte) (*state.ProcessBlobInnerResponse, error) + + + common.HexToAddress("0x1"),
    + 27 +
    - - - } + + + common.HexToAddress("0x2"),
    + 28 +
    - - -
    + + + common.HexToAddress("0x3"),
    + 29 +
    - - - // ProcessorSequenceBlobs processor for SequenceBlobs + + + }
    + 30 +
    - - - type ProcessorSequenceBlobs struct { + + + addrsBytes := []byte{}
    + 31 +
    - - - actions.ProcessorBase[ProcessorL1InfoTreeUpdate] + + + for _, addr := range addrs {
    + 32 +
    - - - state stateProcessorSequenceBlobsInterface + + + addrsBytes = append(addrsBytes, addr.Bytes()...)
    + 33 +
    - - - stateBlobInnerProcessor stateBlobInnerProcessor + + + }
    + 34 +
    - - - timeProvider commonsync.TimeProvider + + + _, err := da.SetupCommittee(auth, requiredAmountOfSignatures, URLs, addrsBytes)
    + 35 +
    - - - } + + + require.NoError(t, err)
    + 36 +
    - - -
    + + + ethBackend.Commit()
    + 37 +
    - - - // NewProcessorSequenceBlobs new processor for SequenceBlobs + + +
    + 38 +
    - - - func NewProcessorSequenceBlobs(state stateProcessorSequenceBlobsInterface, stateBlobInnerProcessor stateBlobInnerProcessor, timeProvider commonsync.TimeProvider) *ProcessorSequenceBlobs { + + + // Assert the committee update
    + 39 +
    - - - if timeProvider == nil { + + + actualSetup, err := dac.getCurrentDataCommittee()
    + 40 +
    - - - timeProvider = &commonsync.DefaultTimeProvider{} + + + require.NoError(t, err)
    + 41 +
    - - - } + + + expectedMembers := []DataCommitteeMember{}
    + 42 +
    - - - return &ProcessorSequenceBlobs{ + + + expectedSetup := DataCommittee{
    + 43 +
    - - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate]( + + + RequiredSignatures: uint64(len(URLs) - 1),
    + 44 +
    - - - []etherman.EventOrder{etherman.SequenceBlobsOrder}, + + + AddressesHash: crypto.Keccak256Hash(addrsBytes),
    + 45 +
    - - - actions.ForksIdOnlyFeijoa), + + + }
    + 46 +
    - - - state: state, + + + for i, url := range URLs {
    + 47 +
    - - - stateBlobInnerProcessor: stateBlobInnerProcessor, + + + expectedMembers = append(expectedMembers, DataCommitteeMember{
    + 48 +
    - - - timeProvider: timeProvider, + + + URL: url,
    + 49 +
    - - - } + + + Addr: addrs[i],
    + 50 +
    - - - } + + + })
    + 51 +
    - - -
    + + + }
    + 52 +
    - - - // Process process event + + + expectedSetup.Members = expectedMembers
    + 53 +
    - - - // - Store BlobSequence + + + assert.Equal(t, expectedSetup, *actualSetup)
    + 54 +
    - - - // - Split BlobInner into Batches (executor) + + + }
    + 55 +
    - - - // - Store BlobInner + + +
    + 56 +
    - - - func (p *ProcessorSequenceBlobs) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error { + + + func init() {
    + 57 +
    - - - seqBlobs := &l1Block.SequenceBlobs[order.Pos] + + + log.Init(log.Config{
    + 58 +
    - - - previousBlobSequence, newBlobSequence, err := p.doBlobSequence(ctx, seqBlobs, l1Block, dbTx) + + + Level: "debug",
    + 59 +
    - - - if err != nil { + + + Outputs: []string{"stderr"},
    + 60 +
    - - - return err + + + })
    + 61 +
    - - - } + + + }
    + 62 +
    - - + +
    + 63 +
    - - - for idx := range seqBlobs.Blobs { + + + // This function prepare the blockchain, the wallet with funds and deploy the smc
    + 64 +
    - - - blobNum := newBlobSequence.FirstBlobSequenced + uint64(idx) + + + func newTestingEnv(t *testing.T) (
    + 65 +
    - - - log.Infof("Blob %d: blobNum:%d", idx, blobNum) + + + dac *DataCommitteeBackend,
    + 66 +
    - - - err := p.doBlobInner(ctx, blobNum, &seqBlobs.Blobs[idx], newBlobSequence, previousBlobSequence, dbTx) + + + ethBackend *simulated.Backend,
    + 67 +
    - - - if err != nil { + + + auth *bind.TransactOpts,
    + 68 +
    - - - return err + + + da *polygondatacommittee.Polygondatacommittee,
    + 69 +
    - - - } + + + ) {
    + 70 +
    - - - } + + + t.Helper()
    + 71 +
    - - - return nil + + + privateKey, err := crypto.GenerateKey()
    + 72 +
    - - - } + + + if err != nil {
    + 73 +
    - - - func (p *ProcessorSequenceBlobs) doBlobInner(ctx context.Context, blobNum uint64, blob *etherman.SequenceBlob, newBlobSequence, previousBlobSequence *state.BlobSequence, dbTx pgx.Tx) error { + + + log.Fatal(err)
    + 74 +
    - - - // TODO: We have to choose which tree depending on ForkID? + + + }
    + 75 +
    - - - leaf, err := p.state.GetL1InfoRecursiveRootLeafByIndex(ctx, blob.Params.L1InfoLeafIndex, dbTx) + + + auth, err = bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1337))
    + 76 +
    - - + + if err != nil {
    + 77 +
    - - - return err + + + log.Fatal(err)
    + 78 +
    - - + + }
    + 79 +
    - - -
    + + + dac, ethBackend, da, err = newSimulatedDacman(t, auth)
    + 80 +
    - - - stateBlob, err := p.convertToStateBlobInner(blob, blobNum, newBlobSequence.BlobSequenceIndex, leaf.L1InfoTreeRoot) + + + if err != nil {
    + 81 +
    - - - if err != nil { + + + log.Fatal(err)
    + 82 +
    - - - log.Errorf("Error converting blob to state: %v", err) + + + }
    + 83 +
    - - - return err + + + return dac, ethBackend, auth, da
    + 84 +
    - - - } + + + }
    + 85 +
    - - + +
    + 86 +
    - - - processRequest, err := state.NewProcessBlobInnerProcessRequest(uint64(actions.ForkIDFeijoa), stateBlob, previousBlobSequence, *newBlobSequence) + + + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    + 87 +
    - - - if err != nil { + + + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    + 88 +
    - - - return err + + + func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) (
    + 89 +
    - - - } + + + dacman *DataCommitteeBackend,
    + 90 +
    - - - log.Infof("storing Blob %d: BlobInner: %v", blobNum, stateBlob) + + + ethBackend *simulated.Backend,
    + 91 +
    - - - err = p.state.AddBlobInner(ctx, stateBlob, dbTx) + + + da *polygondatacommittee.Polygondatacommittee,
    + 92 +
    - - - if err != nil { + + + err error,
    + 93 +
    - - - log.Errorf("Error storing blobInner to state: %v", err) + + + ) {
    + 94 +
    - - - return err + + + t.Helper()
    + 95 +
    - - - } + + + if auth == nil {
    + 96 +
    - - - response, err := p.stateBlobInnerProcessor.ProcessBlobInner(ctx, *processRequest, blob.Data) + + + // read only client
    + 97 +
    - - - if err != nil { + + + return &DataCommitteeBackend{}, nil, nil, nil
    + 98 +
    - - - return err + + + }
    + 99 +
    - - - } + + + // 10000000 ETH in wei
    + 100 +
    - - - if response == nil { + + + 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 + +
    + + + }
    - 101 + + 125 +
    - - - return errors.New("response is nil") + + + client.Commit()
    - 102 + + 126 +
    - - - } + + +
    - 103 + + 127 +
    - - - log.Infof("Blob %d: response: %v", blobNum, response) + + + c := &DataCommitteeBackend{
    - 104 + + 128 +
    - - - if response.IsSuccessfulExecution() { + + + dataCommitteeContract: da,
    - 105 + + 129 +
    - - - // We need to store the batches + + + }
    - 106 + + 130 +
    - - - outcomeData := response.GetSuccesfulData() + + + return c, client, da, nil
    - 107 + + 131 +
    - - - for idx := 0; idx < outcomeData.HowManyBatches(); idx++ { + + + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,60 @@
    +
    - 108 + + -
    - - - log.Infof("storing Blob %d: Batch %d: Hash:%s", blobNum, idx, outcomeData.GetBatchHash(idx).String()) +
    +
    +   +
    - 109 + + -
    - - - // TODO: Store batch +
    +
    +   +
    - 110 + + -
    - - - } +
    +
    +   +
    - 111 + + -
    - - - } else { +
    +
    +   +
    - 112 + + -
    - - - err := response.GetUnifiedError() +
    +
    +   +
    - 113 + + -
    - - - log.Errorf("Blob %d: response is not successful: Err: %s", blobNum, err.Error()) +
    +
    +   +
    - 114 + + -
    - - - return err +
    +
    +   +
    - 115 + + -
    - - - } +
    +
    +   +
    - 116 + + -
    - - +
    +
    +  
    - 117 + + -
    - - - return nil +
    +
    +   +
    - 118 + + -
    - - - } +
    +
    +   +
    - 119 + + -
    - - +
    +
    +  
    - 120 + + -
    - - - // returns previousBlobSequence and new one +
    +
    +   +
    - 121 + + -
    - - - func (p *ProcessorSequenceBlobs) doBlobSequence(ctx context.Context, +
    +
    +   +
    - 122 + + -
    - - - incommingSequenceBlobs *etherman.SequenceBlobs, l1Block *etherman.Block, dbTx pgx.Tx) (*state.BlobSequence, *state.BlobSequence, error) { +
    +
    +   +
    - 123 + + -
    - - - previousBlobSequence, err := p.state.GetLastBlobSequence(ctx, dbTx) +
    +
    +   +
    - 124 + + -
    - - - if err != nil { +
    +
    +   +
    - 125 + + -
    - - - return nil, nil, err +
    +
    +   +
    - 126 + + -
    - - - } +
    +
    +   +
    - 127 + + -
    - - - blobSequenceIndex := p.calculateBlobSequenceIndex(previousBlobSequence) +
    +
    +   +
    - 128 + + -
    - - - newBlobSequence := p.convertToStateBlobSequence(incommingSequenceBlobs, blobSequenceIndex, l1Block.ReceivedAt, p.timeProvider.Now(), l1Block.BlockNumber) +
    +
    +   +
    - 129 + + -
    - - - log.Infof("storing BlobSequence: %v", newBlobSequence) +
    +
    +   +
    - 130 + + -
    - - - err = p.state.AddBlobSequence(ctx, newBlobSequence, dbTx) +
    +
    +   +
    - 131 + + -
    - - - if err != nil { +
    +
    +   +
    - 132 + + -
    - - - return nil, nil, err +
    +
    +   +
    - 133 + + -
    - - - } +
    +
    +   +
    - 134 + + -
    - - - return previousBlobSequence, newBlobSequence, nil +
    +
    +   +
    - 135 + + -
    - - - } +
    +
    +   +
    - 136 + + -
    - - +
    +
    +  
    - 137 + + -
    - - - func (p *ProcessorSequenceBlobs) calculateBlobSequenceIndex(previousBlobSequence *state.BlobSequence) uint64 { +
    +
    +   +
    - 138 + + -
    - - - nextIndex := uint64(1) +
    +
    +   +
    - 139 + + -
    - - - if previousBlobSequence != nil { +
    +
    +   +
    - 140 + + -
    - - - nextIndex = previousBlobSequence.BlobSequenceIndex + 1 +
    +
    +   +
    - 141 + + -
    - - - } +
    +
    +   +
    - 142 + + -
    - - - return nextIndex +
    +
    +   +
    - 143 + + -
    - - - } +
    +
    +   +
    - 144 + + -
    - - +
    +
    +  
    - 145 + + -
    - - - func (p *ProcessorSequenceBlobs) convertToStateBlobInner(blobInner *etherman.SequenceBlob, blobInnerNum uint64, blobSequenceIndex uint64, l1InfoTreeRoot common.Hash) (*state.BlobInner, error) { +
    +
    +   +
    - 146 + + -
    - - - res := &state.BlobInner{ +
    +
    +   +
    - 147 + + -
    - - - BlobSequenceIndex: blobSequenceIndex, +
    +
    +   +
    - 148 + + -
    - - - BlobInnerNum: blobInnerNum, // ho trect del previousBlobSequence +
    +
    +   +
    - 149 + + -
    - - - Type: p.convertBlobType(blobInner.Type), +
    +
    +   +
    - 150 + + -
    - - - MaxSequenceTimestamp: time.Unix(int64(blobInner.Params.MaxSequenceTimestamp), 0), +
    +
    +   +
    - 151 + + -
    - - - ZkGasLimit: blobInner.Params.ZkGasLimit, +
    +
    +   +
    - 152 + + -
    - - - L1InfoLeafIndex: blobInner.Params.L1InfoLeafIndex, +
    +
    +   +
    - 153 + + -
    - - - L1InfoTreeRoot: l1InfoTreeRoot, +
    +
    +   +
    - 154 + + -
    - - - } +
    +
    +   +
    - 155 + + -
    - - - if res.Type == state.TypeBlobTransaction { +
    +
    +   +
    - 156 + + -
    - - - if blobInner.BlobBlobTypeParams == nil { +
    +
    +   +
    - 157 + + -
    - - - return nil, errors.New("BlobBlobTypeParams from etherman is required for BlobTransaction") +
    +
    +   +
    - 158 + + -
    - - - } +
    +
    +   +
    - 159 + + -
    - - - res.BlobBlobTypeParams = &state.BlobBlobTypeParams{ +
    +
    +   +
    - 160 + + -
    - - - BlobIndex: blobInner.BlobBlobTypeParams.BlobIndex.Uint64(), +
    +
    +   +
    - 161 + + -
    - - - Z: blobInner.BlobBlobTypeParams.Z, +
    +
    +   +
    - 162 + + -
    - - - Y: blobInner.BlobBlobTypeParams.Y, +
    +
    +   +
    - 163 + + -
    - - - Commitment: blobInner.BlobBlobTypeParams.Commitment, +
    +
    +   +
    - 164 + + -
    - - - Proof: blobInner.BlobBlobTypeParams.Proof, +
    +
    +   +
    - 165 + + -
    - - - } +
    +
    +   +
    - 166 + + -
    - - - } +
    +
    +   +
    - 167 + + -
    - - - return res, nil +
    +
    +   +
    +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 168 + + 1 +
    - - - } + + + package dataavailability
    - 169 + + 2 +
    - - + +
    - 170 + + 3 +
    - - - func (p *ProcessorSequenceBlobs) convertBlobType(value etherman.BlobType) state.BlobType { + + + import (
    - 171 + + 4 +
    - - - return state.BlobType(value) + + + "context"
    - 172 + + 5 +
    - - - } + + + "math/big"
    - 173 + + 6 +
    - - + +
    - 174 + + 7 +
    - - - func (p *ProcessorSequenceBlobs) convertToStateBlobSequence(etherSeqBlobs *etherman.SequenceBlobs, + + + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    - 175 + + 8 +
    - - - nextIndex uint64, + + + "github.com/0xPolygonHermez/zkevm-node/state"
    - 176 + + 9 +
    - - - createAt time.Time, + + + "github.com/ethereum/go-ethereum/common"
    - 177 + + 10 +
    - - - receviedAt time.Time, + + + "github.com/jackc/pgx/v4"
    - 178 + + 11 +
    - - - l1BlockNumber uint64) *state.BlobSequence { + + + )
    - 179 + + 12 +
    - - - return &state.BlobSequence{ + + +
    - 180 + + 13 +
    - - - BlobSequenceIndex: nextIndex, + + + // DABackender is an interface for components that store and retrieve batch data
    - 181 + + 14 +
    - - - L2Coinbase: etherSeqBlobs.L2Coinbase, + + + type DABackender interface {
    - 182 + + 15 +
    - - - FirstBlobSequenced: etherSeqBlobs.EventData.LastBlobSequenced - uint64(len(etherSeqBlobs.Blobs)), + + + SequenceRetriever
    - 183 + + 16 +
    - - - LastBlobSequenced: etherSeqBlobs.EventData.LastBlobSequenced, + + + SequenceSender
    - 184 + + 17 +
    - - - FinalAccInputHash: etherSeqBlobs.FinalAccInputHash, + + + // Init initializes the DABackend
    - 185 + + 18 +
    - - - CreateAt: createAt, + + + Init() error
    - 186 + + 19 +
    - - - ReceivedAt: receviedAt, + + + }
    - 187 + + 20 +
    - - - BlockNumber: l1BlockNumber, + + +
    - 188 + + 21 +
    - - - } + + + // SequenceSender is used to send provided sequence of batches
    - 189 + + 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 @@
    @@ -278528,205 +49092,248 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - + + 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/validium-001.sql + RENAMED + +
    +
    +
    +
    + + + + + + + +
    +
    @@ -0,0 +1,32 @@
    @@ -279048,335 +49655,368 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    +
     
    +
    - + + 1 -
    -   -
    +
    +
    + + + -- +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 @@
    @@ -279853,21 +50493,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs_test.go - RENAMED - -
    -
    @@ -279875,1041 +50500,1462 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -1,102 +0,0 @@
    +
     
    + 1 +
    - - - package feijoa_test + + + PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/"
    + 2 +
    - - -
    + + + diff -ruN \
    + 3 +
    - - - import ( + + + -I ".*github.com\/0x.*" \
    + 4 +
    - - - "context" + + + -x "*mock*" -x ".git" \
    + 5 +
    - - - "os" + + + -x ".github" \
    + 6 +
    - - - "testing" + + + -x ".gitignore" \
    + 7 +
    - - -
    + + + -x ".vscode" \
    + 8 +
    - - - "github.com/0xPolygonHermez/zkevm-node/db" + + + -x "ci" \
    + 9 +
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" + + + -x "environments" \
    + 10 +
    - - - "github.com/0xPolygonHermez/zkevm-node/log" + + + -x "*.md" \
    + 11 +
    - - - "github.com/0xPolygonHermez/zkevm-node/state" + + + -x "*.html" \
    + 12 +
    - - - "github.com/0xPolygonHermez/zkevm-node/state/pgstatestorage" + + + -x "*.html" \
    + 13 +
    - - - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" + + + -x "*.json" \
    + 14 +
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/feijoa" + + + -x "*.toml" \
    + 15 +
    - - - "github.com/0xPolygonHermez/zkevm-node/test/dbutils" + + + -x "*.abi" \
    + 16 +
    - - - "github.com/ethereum/go-ethereum/common" + + + -x "*.bin" \
    + 17 +
    - - - "github.com/jackc/pgconn" + + + -x "*.pb.go" \
    + 18 +
    - - - "github.com/jackc/pgx/v4" + + + -x "smartcontracts" \
    + 19 +
    - - - "github.com/stretchr/testify/require" + + + -x "go.sum" \
    + 20 +
    - - - ) + + + -x "mock*.go" \
    + 21 +
    - - -
    + + + -x "*venv*" \
    + 22 +
    - - - // This test is a exploratory test used to develop. It use a sequencedBlob on Sepolia + + + -x "/dist/" \
    + 23 +
    - - - // It need Database, a prover >7.x and L1 client + + + -x "/test/e2e/keystore" \
    + 24 +
    - - - // TODO: Remove this test or convert to a test than can be executed + + + -x "/test/vectors/src/**/*md" \
    + 25 +
    - - - func TestProcessASequenceBlobUsingCallDataFromSepolia(t *testing.T) { + + + -x "/test/vectors/src/**/*js" \
    + 26 +
    - - - l1url := os.Getenv("ZKEVM_NODE_ETHERMAN_URL") + + + -x "/test/vectors/src/**/*sol" \
    + 27 +
    - - - consensusl1url := os.Getenv("ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL") + + + -x "/test/vectors/src/**/*sh" \
    + 28 +
    - - - if l1url == "" || consensusl1url == "" { + + + -x "/test/vectors/src/package.json" \
    + 29 +
    - - - // You can set un vscode editing setings.json + + + -x "/test/contracts/bin/**/*.bin" \
    + 30 +
    - - - // "go.testEnvVars": { + + + -x "/test/contracts/bin/**/*.abi" \
    + 31 +
    - - - // "ZKEVM_NODE_ETHERMAN_URL": "url1", + + + -x "/tools/datastreamer/*.bin" \
    + 32 +
    - - - // "ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL": "url2", + + + -x "/test/datastreamer/*.db/*" \
    + 33 +
    - - - //} + + + -x "/test/*.bin" \
    + 34 +
    - - - t.Skip("ZKEVM_NODE_ETHERMAN_URL or ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL not set") + + + -x "/test/*.db/*" \
    + 35 +
    - - - } + + + -x "**/.DS_Store" \
    + 36 +
    - - - cfg := etherman.Config{ + + + -x ".vscode" \
    + 37 +
    - - - URL: l1url, + + + -x ".idea/" \
    + 38 +
    - - - ConsensusL1URL: consensusl1url, + + + -x ".env" \
    + 39 +
    - - - } + + + -x "out.dat" \
    + 40 +
    - - - l1Config := etherman.L1Config{ + + + -x "cmd/__debug_bin" \
    + 41 +
    - - - L1ChainID: 11155111, + + + -x ".venv" \
    + 42 +
    - - - //ZkEVMAddr: common.HexToAddress("0x31A6ae85297DD0EeBD66D7556941c33Bd41d565C"), + + + -x "*metrics.txt" \
    + 43 +
    - - - //ZkEVMAddr: common.HexToAddress("0xD23C761025306cF5038D74FEEb077Cf66DE134DA"), + + + -x "coverage.out" \
    + 44 +
    - - - ZkEVMAddr: common.HexToAddress("0x5e5880098741d1fbd38eaaac51c4215f80f92d27"), + + + -x "*datastream.db*" \
    + 45 +
    - - - RollupManagerAddr: common.HexToAddress("0x9fB0B4A5d4d60aaCfa8DC20B8DF5528Ab26848d3"), + + + ${PATH_TO_ZKEVM_NODE_REPO} . | \
    + 46 +
    - - - GlobalExitRootManagerAddr: common.HexToAddress("0x76216E45Bdd20022eEcC07999e50228d7829534B"), + + + 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 @@
    - 48 + + 14 +
    - - - eth, err := etherman.NewClient(cfg, l1Config) +   + # CONTAINER FOR RUNNING BINARY
    - 49 + + 15 +
    - - - require.NoError(t, err) +   + FROM alpine:3.18
    - 50 + + 16 +
    - - - ctx := context.Background() +   + COPY --from=build /src/dist/zkevm-node /app/zkevm-node
    - 51 + 17
    - - //toBlock := uint64(5611933) + COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
    - 52 + + 18 +
    - - - //toBlock := uint64(5704000) +   + RUN apk update && apk add postgresql15-client
    - 53 + + 19 +
    - - - toBlock := uint64(5760696) +   + EXPOSE 8123
    - 54 + + 20 +
    - - - blocks, orders, err := eth.GetRollupInfoByBlockRange(ctx, toBlock, &toBlock) +   + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +
    +
    +
    +
    +
    +
    + + + + + + + + - - - - + + + + + + + + + + + + + + +
    +
     
    +
    + 14 + +
    +   + # CONTAINER FOR RUNNING BINARY
    - 55 + + 15 +
    - - - require.NoError(t, err) +   + FROM alpine:3.18
    - 56 + + 16 +
    - - - require.Equal(t, 1, len(blocks)) +   + 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 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 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 @@
    - 57 + + 3 +
    - - - require.Equal(t, 1, len(orders)) +   + import (
    - 58 + + 4 +
    - - -
    +   + "bytes"
    - 59 + + 5 +
    - - - realState := createRealState(t) +   + "context"
    - 60 + + -
    - - - err = addBlock(ctx, &blocks[0], realState, nil) +
    +
    +   +
    - 61 + + 6 +
    - - - if err != nil { +   + "encoding/json"
    - 62 + + 7 +
    - - - log.Error(err) +   + "errors"
    - 63 + + 8 +
    - - - } +   + "fmt"
    - 64 - -
    - - - sut := feijoa.NewProcessorSequenceBlobs(realState, realState, nil) -
    +
    +
    @@ -106,6 +109,11 @@
    - 65 + + 106 +
    - - - err = sut.Process(ctx, orders[blocks[0].BlockHash][0], &blocks[0], nil) +   + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
    - 66 + + 107 +
    - - - require.NoError(t, err) +   + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
    - 67 + + 108 +
    - - - } +   +
    - 68 + + -
    - - +
    +
    +  
    - 69 + + -
    - - - const UniqueViolationErr = "23505" +
    +
    +   +
    - 70 + + -
    - - +
    +
    +  
    - 71 + + -
    - - - func addBlock(ctx context.Context, block *etherman.Block, storage *state.State, dbTx pgx.Tx) error { +
    +
    +   +
    - 72 + + -
    - - - b := state.Block{ +
    +
    +   +
    - 73 + + 109 +
    - - - BlockNumber: block.BlockNumber, +   + // ErrNotFound is used when the object is not found
    - 74 + + 110 +
    - - - BlockHash: block.BlockHash, +   + ErrNotFound = errors.New("not found")
    - 75 + + 111 +
    - - - ParentHash: block.ParentHash, +   + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    - 76 - -
    - - - ReceivedAt: block.ReceivedAt, -
    +
    +
    @@ -189,6 +197,7 @@
    - 77 + + 189 +
    - - - } +   + GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
    - 78 + + 190 +
    - - - // Add block information +   + OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
    - 79 + + 191 +
    - - - err := storage.AddBlock(ctx, &b, dbTx) +   + Pol *pol.Pol
    - 80 + + -
    - - +
    +
    +  
    - 81 - -
    - - - if pgerr, ok := err.(*pgconn.PgError); ok && pgerr.Code == UniqueViolationErr { -
    -
    - 82 + + 192 +
    - - - return nil +   + SCAddresses []common.Address
    - 83 + + 193 +
    - - - } +   +
    - 84 + + 194 +
    - - - return err +   + RollupID uint32
    - 85 - -
    - - - } -
    +
    +
    @@ -198,10 +207,13 @@
    - 86 + + 198 +
    - - -
    +   + l1Cfg L1Config
    - 87 + + 199 +
    - - - func createRealState(t *testing.T) *state.State { +   + cfg Config
    - 88 + + 200 +
    - - - stateDBCfg := dbutils.NewStateConfigFromEnv() +   + auth map[common.Address]bind.TransactOpts // empty in case of read-only client
    - 89 + + -
    - - - stateCfg := state.Config{} +
    +
    +   +
    - 90 + + -
    - - - err := db.RunMigrationsUp(stateDBCfg, db.StateMigrationName) +
    +
    +   +
    - 91 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    - 92 + + 201 +
    - - - stateSqlDB, err := db.NewSQLDB(stateDBCfg) +   + }
    - 93 + + 202 +
    - - - stateDb := pgstatestorage.NewPostgresStorage(stateCfg, stateSqlDB) +   +
    - 94 + + 203 +
    - - - executorConfig := executor.Config{ +   + // NewClient creates a new etherman.
    - 95 + + 204 +
    - - URI: "localhost:50071", + func NewClient(cfg Config, l1Config L1Config) (*Client, error) {
    - 96 + + 205 +
    - - - MaxGRPCMessageSize: 1024 * 1024 * 1024, +   + // Connect to ethereum node
    - 97 + + 206 +
    - - - } +   + ethClient, err := ethclient.Dial(cfg.URL)
    - 98 + + 207 +
    - - - executorClient, _, _ := executor.NewExecutorClient(context.TODO(), executorConfig) +   + if err != nil {
    - 99 - -
    - - - require.NoError(t, err) -
    +
    +
    @@ -244,6 +256,14 @@
    - 100 + + 244 +
    - - -
    +   + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - 101 + + 245 +
    - - - return state.NewState(stateCfg, stateDb, executorClient, nil, nil, nil, nil) +   + return nil, err
    - 102 + + 246 +
    - - - } -
    -
    -
    +   + }
    -
    -
    - - - - - - - - - - - - + - + + - - - - @@ -281062,63 +52113,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -281142,53 +52198,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - @@ -281202,63 +52258,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -281312,757 +52373,898 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    @@ -280992,63 +52038,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 247 -
    +
    +
      -
    + var scAddresses []common.Address
    - + + 248 -
    +
    +
      -
    + scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
    - + + 249 -
    +
    +
     
    - + +
    @@ -274,6 +294,7 @@
    -
    +
    + 274 + +
      -
    + RollupManager: rollupManager,
    - + + 275 -
    +
    +
      -
    + Pol: pol,
    - + + 276 -
    +
    +
      -
    + GlobalExitRootManager: globalExitRoot,
    - + + 277 -
    +
    +
      -
    + OldGlobalExitRootManager: oldGlobalExitRoot,
    - + + 278 -
    +
    +
      -
    + SCAddresses: scAddresses,
    - + + 279 -
    +
    +
      -
    + RollupID: rollupID,
    - + +
    @@ -284,11 +305,14 @@
    -
    +
    + 284 + +
      -
    + l1Cfg: l1Config,
    - + + 285 -
    +
    +
      -
    + cfg: cfg,
    - + + 286 -
    +
    +
      -
    + 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)) +
    +
    + 704 + +
    + - + if err != nil { +
    +
    + 705 + +
    + - + return err +
    +
    + 706 + +
    + - + } +
    +
    + 707 + +
    + - + fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash) +
    +
    + 708 + +
    + - + if err != nil { +
    +
    + 709 + +
    + - + return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err) +
    +
    + 710 + +
    + - + } +
    +
    + 711 + +
    + -
    - + + 712 + +
    + - + log.Info("update Etrog transaction sequence...") +
    +
    + 713 + +
    + - + sequence := UpdateEtrogSequence{ +
    +
    + 714 -
    -   -
    +
    +
    + - + BatchNumber: updateEtrogSequence.NumBatch,
    - + + 715 -
    -   -
    +
    +
    + - + SequencerAddr: updateEtrogSequence.Sequencer,
    - + + 716 -
    -   -
    +
    +
    + - + TxHash: vLog.TxHash,
    - + + 717 -
    -   -
    +
    +
    + - + Nonce: msg.Nonce,
    - + + 718 -
    -   -
    +
    +
    + - + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 719 -
    -   -
    +
    +
    + - + Transactions: updateEtrogSequence.Transactions,
    - + + 720 -
    -   -
    +
    +
    + - + ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot,
    - + + 721 -
    -   -
    +
    +
    + - + ForcedTimestamp: fullBlock.Time(),
    - + + 722 -
    -   -
    +
    +
    + - + ForcedBlockHashL1: fullBlock.ParentHash(),
    - + + 723 -
    -   -
    +
    +
    + - + },
    - + + 724 -
    -   -
    +
    +
    + - + }
    - + + 725 -
    -   +
    +
    + -
    - + + 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)
    - + + 728 -
    -   -
    +
    +
    + - + block.UpdateEtrogSequence = sequence
    - + + 729 -
    -   -
    +
    +
    + - + *blocks = append(*blocks, block)
    - + + 730 -
    -   -
    +
    +
    + - + } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber {
    - + + 731 -
    -   -
    +
    +
    + - + (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence
    - + + 732 -
    -   -
    +
    +
    + - + } else {
    - + + 733 -
    -   -
    +
    +
    + - + log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber)
    - + + 734 -
    -   -
    +
    +
    + - + return fmt.Errorf("error processing UpdateEtrogSequence event")
    - + + 735 -
    -   -
    +
    +
    + - + }
    - + + 736 -
    -   -
    +
    +
    + - + or := Order{
    - + + 737 -
    -   -
    +
    +
    + - + Name: UpdateEtrogSequenceOrder,
    - + + 738 -
    -   -
    +
    +
    + - + Pos: 0,
    - + + 739 -
    -   -
    +
    +
    + - + }
    - + + 740 -
    -   -
    +
    +
    + - + (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or)
    - + + 741 -
    -   -
    +
    +
    + - + return nil
    - + + 742 -
    +
    +
      -
    + }
    - + + 743 -
    +
    +
     
    - + + 744 -
    +
    +
      -
    + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + +
    @@ -937,14 +913,14 @@
    -
    +
    + 937 + +
      -
    + }
    - + + 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) {
    - + + 941 -
    +
    +
      -
    + opts, err := etherMan.getAuthByAddress(sender)
    - + + 942 -
    +
    +
      -
    + if err == ErrNotFound {
    - + + 943 -
    +
    +
      -
    + return nil, ErrPrivateKeyNotFound
    - + + 944 -
    +
    +
      -
    + }
    - + + 945 -
    +
    +
      -
    + opts.NoSend = true
    - + + 946 -
    +
    +
     
    - + + 947 -
    -   -
    +
    +
    + - + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - + + 948 -
    +
    +
      -
    + if err != nil {
    - + + 949 -
    +
    +
      -
    + return nil, err
    - + + 950 -
    +
    +
      -
    + }
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - -
    -
    @@ -12,41 +12,21 @@
    +
    @@ -953,7 +929,7 @@
    - 12 + 953
      - ForkIDEtrog = ForkIdType(7) //nolint:gomnd + }
    - 13 + 954
      - // ForkIDElderberry is the forkId for Elderberry +
    - 14 + 955
      - ForkIDElderberry = ForkIdType(8) //nolint:gomnd -
    -
    - 15 - -
    - - - // ForkIDElderberry2 is the forkId for Elderberry2 + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - 16 + 956
    - - ForkIDElderberry2 = ForkIdType(9) //nolint:gomnd + func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) {
    - 17 + + 957 +
    - - - // ForkIDFeijoa is the forkId for Feijoa +   + opts, err := etherMan.getAuthByAddress(sender)
    - 18 + + 958 +
    - - - ForkIDFeijoa = ForkIdType(10) //nolint:gomnd +   + if err == ErrNotFound {
    - 19 + 959
      - ) + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    +
    @@ -964,7 +940,7 @@
    +
    - 20 + 964
      -
    + opts.GasLimit = uint64(1)
    - 21 + 965
      - var ( + opts.GasPrice = big.NewInt(1)
    - 22 + 966
    @@ -282071,377 +53273,328 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 23 + + 967 +
    - - /// ************** ALL ***************/// + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - 24 + + 968 +
    - - -
    +   + if err != nil {
    - 25 + 969
      - // ForksIdAll support all forkIds + return nil, nil, err
    - 26 + 970
      - ForksIdAll = []ForkIdType{WildcardForkId} + }
    +
    @@ -972,15 +948,15 @@
    +
    - 27 + 972
      -
    + return tx.To(), tx.Data(), nil
    - 28 + + 973 +
    - - - /// ************** SINGLE ***************/// +   + }
    - 29 + + 974 +
    - - +  
    - 30 - -
    - - - // ForksIdOnlyFeijoa support only etrog forkId -
    -
    - 31 + + 975 +
    - - ForksIdOnlyFeijoa = []ForkIdType{ForkIDFeijoa} + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
    - 32 + + 976 +
    - -
    + var batches []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 33 + 977
      - // ForksIdOnlyElderberry support only elderberry forkId -
    -
    - 34 - -
    - - - ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry, ForkIDElderberry2} + for _, seq := range sequences {
    - 35 + 978
      -
    + var ger common.Hash
    - 36 + 979
      - // ForksIdOnlyEtrog support only etrog forkId + if seq.ForcedBatchTimestamp > 0 {
    - 37 + 980
      - ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog} + ger = seq.GlobalExitRoot
    - 38 + 981
      -
    + }
    - 39 + + 982 +
    - - /// ************** MULTIPLE ***************/// + batch := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 40 + + 983 +
    - -
    + Transactions: seq.BatchL2Data,
    - 41 + 984
      - // ForksIdToIncaberry support all forkIds till incaberry + ForcedGlobalExitRoot: ger,
    - 42 + 985
      - ForksIdToIncaberry = []ForkIdType{1, 2, 3, 4, 5, ForkIDIncaberry} -
    -
    - 43 - -
    - - -
    + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - 44 + + 986 +
    - - - // ForksIdToEtrog support all forkIds till etrog +   + ForcedBlockHashL1: seq.PrevBlockHash,
    - 45 - -
    - - - ForksIdToEtrog = append(ForksIdToIncaberry, ForksIdOnlyEtrog...) -
    +
    +
    @@ -989,7 +965,7 @@
    - 46 + + 989 +
    - - -
    +   + batches = append(batches, batch)
    - 47 + + 990 +
    - - - // ForksIdToElderberry support all forkIds till elderberry +   + }
    - 48 + + 991 +
    - - - ForksIdToElderberry = append(ForksIdToEtrog, ForksIdOnlyElderberry...) +   +
    - 49 + + 992 +
    - -
    + tx, err := etherMan.ZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - 50 + + 993 +
    - - - // ForksIdToFeijoa support all forkIds till feijoa +   + if err != nil {
    - 51 + + 994 +
    - - - ForksIdToFeijoa = append(ForksIdToElderberry, ForksIdOnlyFeijoa...) +   + log.Debugf("Batches to send: %+v", batches)
    - 52 + 995
      - ) + log.Debug("l2CoinBase: ", l2Coinbase)
    -
    -
    -
    -
    - - - + - - - - - - - @@ -282456,52 +53609,52 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -282516,72 +53669,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + - + + - - - - - - @@ -282596,57 +53754,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - @@ -282785,1068 +53938,818 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - -
    -
     
    +
    @@ -1208,13 +1184,15 @@
    - 12 + 1208
      - ForkIDEtrog = ForkIdType(7) //nolint:gomnd + if sb.NumBatch != 1 {
    - 13 + 1209
      - // ForkIDElderberry is the forkId for Elderberry + methodId := tx.Data()[:4]
    - 14 + 1210
      - ForkIDElderberry = ForkIdType(8) //nolint:gomnd + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - 15 + + 1211 +
    - + - // ForkID9 is the forkId for 9 + - + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) {
    - 16 + + 1212 +
    - + - ForkID9 = ForkIdType(9) //nolint:gomnd -
    -
    - - -
    -   -
    + - + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 17 + 1213
      - ) + if err != nil {
    - 18 + 1214
      -
    + return fmt.Errorf("error decoding the sequences (etrog): %v", err)
    - 19 + 1215
      - var ( + }
    - 20 + + 1216 +
    -   -
    + - + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) {
    - + + 1217 -
    -   -
    +
    +
    + - + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 21 + 1218
      - // ForksIdAll support all forkIds + if err != nil {
    - 22 + 1219
      - ForksIdAll = []ForkIdType{WildcardForkId} + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 23 + 1220
      -
    + }
    - + +
    @@ -1300,7 +1278,8 @@
    -
    +
    + 1300 + +
      -
    + return nil
    - + + 1301 -
    +
    +
      -
    + }
    - + + 1302 -
    +
    +
     
    - + + 1303 -
    -   -
    +
    +
    + - + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 24 + 1304
      - // ForksIdOnlyElderberry support only elderberry forkId + // Extract coded txs.
    - 25 + + 1305 +
    - + - ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry, ForkID9} +   + // Load contract ABI
    - 26 + 1306
      -
    + smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    +
    @@ -1308,6 +1287,25 @@
    +
    - 27 + 1308
      - // ForksIdOnlyEtrog support only etrog forkId + return nil, err
    - 28 + 1309
      - ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog} + }
    - 29 + 1310
    @@ -282675,23 +53838,13 @@

    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 + 1311
      - state: state} + // Recover Method from signature and ABI
    - 30 + 1312
      - } + method, err := smcAbi.MethodById(txData[:4])
    - 31 + 1313
      -
    + if err != nil {
    -
    -
    -
    -
    - - - + - - - - - - - - - - -
    -
     
    +
    @@ -1319,87 +1317,216 @@
    - 23 + 1319
      - // NewProcessL1ForcedBatches returns instance of a processor for ForcedBatchesOrder + if err != nil {
    - 24 + 1320
      - func NewProcessL1ForcedBatches(state stateProcessL1ForcedBatchesInterface) *ProcessL1ForcedBatches { + return nil, err
    - 25 + 1321
      - return &ProcessL1ForcedBatches{ -
    -
    - 26 - -
    - + - ProcessorBase: actions.ProcessorBase[ProcessL1ForcedBatches]{ -
    -
    - 27 - -
    - + - SupportedEvent: []etherman.EventOrder{etherman.ForcedBatchesOrder}, + }
    - 28 + + 1322 +
    - + - SupportedForkdIds: &actions.ForksIdAll}, + - + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 29 + 1323
      - state: state} + bytedata, err := json.Marshal(data[0])
    - 30 + 1324
      - } + if err != nil {
    - 31 + 1325
      -
    -
    -
    -
    + return nil, err
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -36,9 +36,10 @@
    - 36 + 1326
      - // NewProcessorForkId returns instance of a processor for ForkIDsOrder + }
    - 37 + + 1327 +
    -   - func NewProcessorForkId(state stateProcessorForkIdInterface, sync syncProcessorForkIdInterface) *ProcessorForkId { + - + err = json.Unmarshal(bytedata, &sequences)
    - 38 + + 1328 +
    -   - return &ProcessorForkId{ + - + if err != nil {
    - 39 + + 1329 +
    - - ProcessorBase: *actions.NewProcessorBase[ProcessorForkId]( + return nil, err
    - 40 + + 1330 +
    - - []etherman.EventOrder{etherman.ForkIDsOrder}, + }
    - 41 + + 1331 +
    - - actions.ForksIdAll), + maxSequenceTimestamp := data[1].(uint64)
    - + + 1332 -
    -   -
    +
    +
    + - + initSequencedBatchNumber := data[2].(uint64)
    - 42 + + 1333 +
    -   - state: state, + - + coinbase := (data[3]).(common.Address)
    - 43 + + 1334 +
    -   - sync: sync} + - + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 44 + 1335
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 36 + + 1336 +
    -   - // NewProcessorForkId returns instance of a processor for ForkIDsOrder + - + for i, seq := range sequences {
    - 37 + + 1337 +
    -   - func NewProcessorForkId(state stateProcessorForkIdInterface, sync syncProcessorForkIdInterface) *ProcessorForkId { + - + elderberry := SequencedBatchElderberryData{
    - 38 + + 1338 +
    -   - return &ProcessorForkId{ + - + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 39 + + 1339 +
    - + - ProcessorBase: actions.ProcessorBase[ProcessorForkId]{ + - + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 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 + 1340
      - return &ProcessorL1GlobalExitRoot{ + }
    - 27 + 1341
    - - ProcessorBase: *actions.NewProcessorBase[ProcessorL1GlobalExitRoot]( + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 28 + 1342
    - - []etherman.EventOrder{etherman.GlobalExitRootsOrder}, + s := seq
    - 29 + 1343
    - - actions.ForksIdToIncaberry), -
    -
    - 30 - -
    -   - state: state} + sequencedBatches[i] = SequencedBatch{
    - 31 + + 1344 +
    -   - } + - + BatchNumber: bn,
    - 32 + + 1345 +
    -   -
    -
    -
    -
    + - + L1InfoRoot: &l1InfoRoot,
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 24 + + 1346 +
    -   - // NewProcessorL1GlobalExitRoot new processor for GlobalExitRootsOrder + - + SequencerAddr: sequencer,
    - 25 + + 1347 +
    -   - func NewProcessorL1GlobalExitRoot(state stateProcessorL1GlobalExitRootInterface) *ProcessorL1GlobalExitRoot { + - + TxHash: txHash,
    - 26 + + 1348 +
    -   - return &ProcessorL1GlobalExitRoot{ + - + Nonce: nonce,
    - 27 + + 1349 +
    - + - ProcessorBase: actions.ProcessorBase[ProcessorL1GlobalExitRoot]{ + - + Coinbase: coinbase,
    - 28 + + 1350 +
    - + - SupportedEvent: []etherman.EventOrder{etherman.GlobalExitRootsOrder}, + - + PolygonRollupBaseEtrogBatchData: &s,
    - 29 + + 1351 +
    - + - SupportedForkdIds: &actions.ForksIdToIncaberry}, + - + SequencedBatchElderberryData: &elderberry,
    - 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 + 1352
      - // 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 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -283860,738 +54763,618 @@

    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 + 1353
      - // SupportedEvents returns the supported events in the struct + }
    - 35 + 1354
      - func (p *ProcessorBase[T]) SupportedEvents() []etherman.EventOrder { +
    - 36 + 1355
    - - return p.supportedEvent + return sequencedBatches, nil
    - 37 + 1356
    @@ -284601,7 +55384,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 38 + 1357
    @@ -284611,136 +55394,172 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 39 + 1358
    - - // SupportedForkIds returns the supported forkIds in the struct or the default till incaberry forkId + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 40 + + 1359 +
    -   - func (p *ProcessorBase[T]) SupportedForkIds() []ForkIdType { + - + // Extract coded txs.
    - 41 + 1360
    - - if len(p.supportedForkIds) != 0 { + // Load contract ABI
    - 42 + 1361
    - - return p.supportedForkIds + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 43 + 1362
      - } + if err != nil {
    - 44 + 1363
      - // returns none + return nil, err
    - 45 + 1364
      - return []ForkIdType{} + }
    -
    + + + 1365 + + +
    + - +
    -
    -
    - - - - - - - - - - - - - @@ -284844,43 +55663,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 9 + + 1366 +
    -   - // ProcessorBase is the base struct for all the processors, if reduces the boilerplate + - + // Recover Method from signature and ABI
    - 10 + + 1367 +
    -   - // implementing the Name, SupportedEvents and SupportedForkIds functions + - + method, err := smcAbi.MethodById(txData[:4])
    - 11 + 1368
      - type ProcessorBase[T any] struct { + if err != nil {
    - 12 + + 1369 +
    - + - SupportedEvent []etherman.EventOrder +   + return nil, err
    - 13 + + 1370 +
    - + - SupportedForkdIds *[]ForkIdType +   + }
    - 14 - -
    -   - } -
    -
    - 15 + + -
    +
    +
     
    - 16 - -
    -   - // Name returns the name of the struct T -
    -
    -
     
    -
    - 23 + 1371
    @@ -284889,377 +55683,224 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 24 + + 1372 +
    -   - // SupportedEvents returns the supported events in the struct + - + // Unpack method inputs
    - 25 + + 1373 +
    -   - func (p *ProcessorBase[T]) SupportedEvents() []etherman.EventOrder { + - + data, err := method.Inputs.Unpack(txData[4:])
    - 26 + + 1374 +
    - + - return p.SupportedEvent + - + if err != nil {
    - 27 + + 1375 +
    -   - } + - + return nil, err
    - 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 + 1376
      - 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 + + 1377 +
    - - import ( + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 4 + + 1378 +
    - - "context" + bytedata, err := json.Marshal(data[0])
    - 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 + + 1379 +
    - - - const ( +   + if err != nil {
    - 14 + + 1380 +
    - - - StoreL1Blocks ProcessBlockRangeL1BlocksMode = true +   + return nil, err
    - 15 + + 1381 +
    - - - NoStoreL1Blocks ProcessBlockRangeL1BlocksMode = false +   + }
    - 16 + + 1382 +
    - - ) + err = json.Unmarshal(bytedata, &sequences)
    - 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 - -
    - - - } -
    +
    +
    -
    -
    -
    -
    - - - - - - - -
    -
     
    +
    +
    +   +
    +
    @@ -285471,118 +56112,254 @@

    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 + 1383
      -
    + if err != nil {
    - 21 + 1384
      - EthermanGetLatestBatchNumber + return nil, err
    - 22 + 1385
      - GetFinalizedBlockNumber(ctx context.Context) (uint64, error) + } +
    +
    + 1386 + +
    + - + coinbase := (data[1]).(common.Address) +
    +
    + 1387 + +
    + - + sequencedBatches := make([]SequencedBatch, len(sequences)) +
    +
    + 1388 + +
    + - + for i, seq := range sequences { +
    +
    + 1389 + +
    + - + bn := lastBatchNumber - uint64(len(sequences)-(i+1)) +
    +
    + 1390 + +
    + - + s := seq +
    +
    + 1391 + +
    + - + sequencedBatches[i] = SequencedBatch{ +
    +
    + 1392 + +
    + - + BatchNumber: bn, +
    +
    + 1393 + +
    + - + L1InfoRoot: &l1InfoRoot, +
    +
    + 1394 + +
    + - + SequencerAddr: sequencer, +
    +
    + 1395 + +
    + - + TxHash: txHash,
    - 23 + 1396 + +
    + - + Nonce: nonce, +
    +
    + 1397 + +
    + - + Coinbase: coinbase, +
    +
    + 1398
    - - EthermanPreRollup + PolygonRollupBaseEtrogBatchData: &s,
    - 24 + 1399
      - } + }
    - 25 + 1400
      + } +
    +
    + 1401 + +
    + -
    + 1402 + +
    + - + return sequencedBatches, nil +
    +
    - 26 + 1403
      - type EthermanGetLatestBatchNumber interface { + }
    - 27 + 1404
      - GetLatestBatchNumber() (uint64, error) +
    - 28 + 1405 + +
    +   + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { +
    +
    +
    @@ -1882,15 +2009,15 @@
    +
    + 1882
    @@ -285591,72 +56368,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 29 + + 1883 +
    - - +  
    - 30 + + 1884 +
    - - - type EthermanPreRollup interface { +   + // LoadAuthFromKeyStore loads an authorization from a key store file
    - 31 + + 1885 +
    - - GetL1BlockUpgradeLxLy(ctx context.Context, genesisBlock uint64) (uint64, error) + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) {
    - 32 + + 1886 +
    - - GetRollupInfoByBlockRangePreviousRollupGenesis(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error) + auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 33 + + 1887 + +
    +   + if err != nil { +
    +
    + 1888 +
    - - } + return nil, err
    -
    + + + 1889 + + +
    +   + }
    -
    -
    - - - - - - - + + + - - - - - - - - - - - - -
    -
     
    - 20 + 1890
    @@ -285666,37 +56449,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 21 + 1891
      - EthermanGetLatestBatchNumber + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 22 + 1892
      - GetFinalizedBlockNumber(ctx context.Context) (uint64, error) + etherMan.auth[auth.From] = auth
    - + + 1893 -
    -   -
    +
    +
    + - + return &auth, nil
    - 23 + 1894
    @@ -285706,7 +56489,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 24 + 1895
    @@ -285716,266 +56499,363 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 25 + 1896
      - type EthermanGetLatestBatchNumber interface { + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    +
    @@ -1911,20 +2038,20 @@
    +
    - 26 + 1911
      - GetLatestBatchNumber() (uint64, error) + }
    - 27 + 1912
      - } +
    - + + 1913 -
    +
    +
      -
    + // newAuthFromKeystore an authorization instance from a keystore file
    - + + 1914 -
    -   -
    +
    +
    + - + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) {
    - + + 1915 -
    +
    +
      -
    + log.Infof("reading key from: %v", path)
    - + + 1916 -
    +
    +
      -
    + key, err := newKeyFromKeystore(path, password)
    - + + 1917 -
    +
    +
      -
    + if err != nil {
    -
    + + + 1918 + + +
    + - + return bind.TransactOpts{}, err
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/l1_event_processor_manager.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + - + + - - - - - - -
    -
    @@ -1,14 +0,0 @@
    - 1 + + 1919 +
    - - - package syncinterfaces +   + }
    - 2 + + 1920 +
    - - -
    +   + if key == nil {
    - 3 + + 1921 +
    - - import ( + return bind.TransactOpts{}, nil
    - 4 + + 1922 +
    - - - "context" +   + }
    - 5 + + 1923 +
    - - -
    +   + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    - 6 + + 1924 +
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" +   + if err != nil {
    - 7 + + 1925 +
    - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions" + return bind.TransactOpts{}, err
    - 8 + + 1926 +
    - - - "github.com/jackc/pgx/v4" +   + }
    - 9 + + 1927 +
    - - ) + return *auth, nil
    - 10 + + 1928 +
    - - +   + } +
    +
    + 1929 + +
    +  
    - 11 + + 1930 +
    - - - type L1EventProcessorManager interface { +   + // getAuthByAddress tries to get an authorization from the authorizations map
    - 12 + +
    @@ -1952,3 +2079,28 @@
    +
    + 1952 +
    - - - Process(ctx context.Context, forkId actions.ForkIdType, order etherman.Order, block *etherman.Block, dbTx pgx.Tx) error +   +
    - 13 + + 1953 +
    - - - Get(forkId actions.ForkIdType, event etherman.EventOrder) actions.L1EventProcessor +   + return *auth, nil
    - 14 + + 1954 +
    - - +   }
    -
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    -
    -
    - - - - -
    -
     
    @@ -286122,21 +57002,6 @@

    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 - -
    -
    @@ -286144,480 +57009,621 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - + + + - - - - -
    -
    @@ -21,13 +21,6 @@
    +
     
    - 21 + 3
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + import (
    - 22 + 4
      - } + "bytes"
    - 23 + 5
      -
    + "context"
    - 24 + + 6 +
    - - - type StateLastBlockGetter interface { + + + "crypto/ecdsa"
    - 25 + + 7 +
    - - - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error) +   + "encoding/json"
    - 26 + + 8 +
    - - - } +   + "errors"
    - 27 + + 9 +
    - - +   + "fmt" +
    +
    +
     
    +
    + 109 + +
    +   + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry +
    +
    + 110 + +
    +   + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address) +
    +
    + 111 + +
    +  
    - 28 + + 112 +
    - - - type StateBlobSequencer interface { + + + // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog
    - 29 + + 113 +
    - - - } + + + methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)
    - 30 + + 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 + +
    + +
    - 31 + 117
      - // StateFullInterface gathers the methods required to interact with the state. + // ErrNotFound is used when the object is not found
    - 32 + 118
      - type StateFullInterface interface { + ErrNotFound = errors.New("not found")
    - 33 + 119
      - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error) + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    -
    @@ -73,7 +66,6 @@
    +
     
    - 73 + 197
      - GetForkIDByBlockNumber(blockNumber uint64) uint64 + GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
    - 74 + 198
      - GetStoredFlushID(ctx context.Context) (uint64, string, error) + OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
    - 75 + 199
      - AddL1InfoTreeLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error) + Pol *pol.Pol
    - 76 + + 200 +
    - - - AddL1InfoTreeRecursiveLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error) + + + DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol
    - 77 + 201
      - StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error + SCAddresses []common.Address
    - 78 + 202
      - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) +
    - 79 + 203
      - UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error + RollupID uint32
    -
    @@ -84,11 +76,7 @@
    +
     
    - 84 + 207
      - UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error + l1Cfg L1Config
    - 85 + 208
      - GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + cfg Config
    - 86 + 209
      - GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error) + auth map[common.Address]bind.TransactOpts // empty in case of read-only client
    - 87 + + 210 +
    - - - GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error) + + +
    - 88 + + 211 +
    - - - AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error + + + da dataavailability.BatchDataProvider
    - 89 + + 212 +
    - - - GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) + + + state stateProvider
    - 90 + + 213 +
    - - - ProcessBlobInner(ctx context.Context, request state.ProcessBlobInnerProcessRequest, data []byte) (*state.ProcessBlobInnerResponse, error) +   + }
    - 91 + + 214 +
    - - - AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error +   +
    - 92 + 215
      - GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) + // NewClient creates a new etherman. +
    +
    + 216 + +
    + + + func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider, st stateProvider) (*Client, error) {
    - 93 + 217
      - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) + // Connect to ethereum node
    - + + 218 -
    +
    +
      -
    + ethClient, err := ethclient.Dial(cfg.URL)
    - 94 + 219
      - } + if err != nil {
    -
    -
    -
    -
    - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - + + - - - - - - @@ -286627,341 +57633,313 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - + - + + - - - - -
     
    - 21 + 256
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - 22 + 257
      - } + return nil, err
    - 23 + 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 -
    +
    +
     
    - + +
     
    -
    +
    + 294 + +
      -
    + RollupManager: rollupManager,
    - + + 295 -
    +
    +
      -
    + Pol: pol,
    - + + 296 -
    +
    +
      -
    + GlobalExitRootManager: globalExitRoot,
    - + + 297 -
    -   -
    +
    +
    + + + DAProtocol: dap,
    - 24 + 298
      - // StateFullInterface gathers the methods required to interact with the state. + OldGlobalExitRootManager: oldGlobalExitRoot,
    - 25 + 299
      - type StateFullInterface interface { + SCAddresses: scAddresses,
    - 26 + 300
      - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error) + RollupID: rollupID,
    - 66 + 305
      - GetForkIDByBlockNumber(blockNumber uint64) uint64 + l1Cfg: l1Config,
    - 67 + 306
      - GetStoredFlushID(ctx context.Context) (uint64, string, error) + cfg: cfg,
    - 68 + 307
      - AddL1InfoTreeLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error) + auth: map[common.Address]bind.TransactOpts{},
    - + + 308 -
    -   -
    +
    +
    + + + da: da,
    - 69 + + 309 +
    -   - StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error + + + state: st,
    - 70 + 310
      - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) + }, nil
    - 71 + 311
      - UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error + }
    -
     
    -
    - 76 + 312
      - UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error +
    - 77 + 313
      - GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + // VerifyGenBlockNumber verifies if the genesis Block Number is valid
    - 78 + 314
      - GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error) + func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
    - + + 315 -
    -   -
    +
    +
    + + + // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block
    - + + 316 -
    +
    +
      -
    + start := time.Now()
    - + + 317 -
    +
    +
      -
    + log.Info("Verifying genesis blockNumber: ", genBlockNumber)
    - + + 318 -
    +
    +
      -
    + // Filter query
    - + +
     
    -
    +
    + 368 + +
      -
    + log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
    - 79 + 369
      - GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) + start := time.Now()
    - 80 + 370
      - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) + var logs []types.Log
    - 81 + 371
    + - UpdateBatchTimestamp(ctx context.Context, batchNumber uint64, timestamp time.Time, dbTx pgx.Tx) error +
    - 82 + + 372 +
    -   - } + + + if lastL1BlockSynced < genBlockNumber {
    -
    + + + 373 + + +
    + + + lastL1BlockSynced = genBlockNumber
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/sync_pre_rollup_syncer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - -
    -
    @@ -1,10 +0,0 @@
    - 1 + + 374 +
    - - - package syncinterfaces + + + }
    - 2 + + 375 +
    - - + +
    - 3 + + 376 +
    - - - import ( +   + log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
    - 4 + + 377 +
    - - - "context" +   + for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
    - 5 + + 378 +
    - - - ) +   + final := i + etherMan.cfg.ForkIDChunkSize
    - 6 + +
     
    +
    + 713 +
    - - -
    +   + return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
    - 7 + + 714 +
    - - - // SyncPreRollupSyncer is the interface for synchronizing pre genesis rollup events +   + }
    - 8 + + 715 +
    - - - type SyncPreRollupSyncer interface { +   +
    - 9 + + 716 +
    - - - SynchronizePreGenesisRollupEvents(ctx context.Context) error + + + func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error {
    - 10 + + 717 +
    - - - } -
    -
    -
    + + + return errors.New("upgrading validiums to etrog not supported")
    -
    -
    - - - - - - - -
    -
     
    @@ -287063,435 +58041,154 @@

    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 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -287505,68 +58202,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -287580,155 +58272,111 @@

    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 + + -
    +
    +
     
    @@ -287794,382 +58442,358 @@

    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 + 718
      - chIncommingRollupInfo chan L1SyncMessage + }
    - 41 + 719
      - ctx context.Context +
    - 42 + 720
      - statistics l1RollupInfoConsumerStatistics + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    -
    @@ -47,7 +53,7 @@
    +
     
    - 47 + 913
      -
    + }
    - 48 + 914
      - // NewL1RollupInfoConsumer creates a new l1RollupInfoConsumer +
    - 49 + 915
      - func NewL1RollupInfoConsumer(cfg ConfigConsumer, + // EstimateGasSequenceBatches estimates gas for sending batches
    - 50 + + 916 +
    - - - synchronizer syncinterfaces.BlockRangeProcessor, ch chan L1SyncMessage) *l1RollupInfoConsumer { + + + func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 51 + 917
      - if cfg.AceptableInacctivityTime < minAcceptableTimeWaitingForNewRollupInfoData { + opts, err := etherMan.getAuthByAddress(sender)
    - 52 + 918
      - log.Warnf("consumer: the AceptableInacctivityTime is too low (%s) minimum recommended %s", cfg.AceptableInacctivityTime, minAcceptableTimeWaitingForNewRollupInfoData) + if err == ErrNotFound {
    - 53 + 919
      - } + return nil, ErrPrivateKeyNotFound
    -
    @@ -231,7 +237,7 @@
    -
    - 231 + 920
      - return nil, nil + }
    - 232 + 921
      - } + opts.NoSend = true
    - 233 + 922
      - b := convertL1BlockToEthBlock(lb) +
    - 234 + + 923 +
    - - - err := l.synchronizer.ProcessBlockRange(l.ctx, []etherman.Block{b}, order) + + + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 235 + 924
      - if err != nil { + if err != nil {
    - 236 + 925
      - log.Error("consumer: Error processing last block of range: ", rollupInfo.blockRange, " err:", err) + return nil, err
    - 237 + 926
      - return nil, err + }
    -
    @@ -243,7 +249,7 @@
    +
     
    - 243 + 929
      - tmpStateBlock := convertEthmanBlockToStateBlock(&blocks[len(blocks)-1]) + }
    - 244 + 930
      - lastEthBlockSynced = &tmpStateBlock +
    - 245 + 931
      - logBlocks(blocks) + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - 246 + + 932 +
    - - - err := l.synchronizer.ProcessBlockRange(l.ctx, blocks, order) + + + 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) {
    - 247 + 933
      - if err != nil { + opts, err := etherMan.getAuthByAddress(sender)
    - 248 + 934
      - log.Info("consumer: Error processing block range: ", rollupInfo.blockRange, " err:", err) + if err == ErrNotFound {
    - 249 + 935
      - return nil, err + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    -
    -
    -
    -
    - - - + @@ -288179,17 +58803,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -288344,72 +58958,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -288419,266 +59033,257 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + + + - - -
     
    - 11 + 940
      - "github.com/0xPolygonHermez/zkevm-node/log" + opts.GasLimit = uint64(1)
    - 12 + 941
      - "github.com/0xPolygonHermez/zkevm-node/state" + opts.GasPrice = big.NewInt(1)
    - 13 + 942
      - syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    - 14 + 943
    + - "github.com/ethereum/go-ethereum/common" + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 15 + 944
      - types "github.com/ethereum/go-ethereum/core/types" + if err != nil {
    - 16 + 945
      - ) + return nil, nil, err
    - 17 + 946
      -
    + }
    - 33 + 948
      - AceptableInacctivityTime time.Duration + return tx.To(), tx.Data(), nil
    - 34 + 949
    @@ -288199,7 +58823,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 35 + 950
    @@ -288208,133 +58832,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 36 - -
    - + - // synchronizerProcessBlockRangeInterface is the interface with synchronizer -
    -
    - 37 + + 951 +
    + - // to execute blocks. This interface is used to mock the synchronizer in the tests + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 38 + + 952 +
    + - type synchronizerProcessBlockRangeInterface interface { + var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - 39 + + 953 +
    - + - ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error +   + for _, seq := range sequences {
    - 40 + + 954 +
    - + - } +   + var ger common.Hash
    - 41 + + 955 +
    - + -
    +   + if seq.ForcedBatchTimestamp > 0 {
    - 42 + 956
      - // l1RollupInfoConsumer is the object that process the rollup info data incomming from channel chIncommingRollupInfo + ger = seq.GlobalExitRoot
    - 43 + 957
      - type l1RollupInfoConsumer struct { + }
    - 44 + + 958 +
    -   - mutex sync.Mutex + + + batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - 45 + 959
    + - synchronizer synchronizerProcessBlockRangeInterface + TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data),
    - 46 + 960
      - chIncommingRollupInfo chan L1SyncMessage + ForcedGlobalExitRoot: ger,
    - 47 + 961
      - ctx context.Context + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - 48 + 962
      - statistics l1RollupInfoConsumerStatistics + ForcedBlockHashL1: seq.PrevBlockHash,
    - 53 + 965
      -
    + batches = append(batches, batch)
    - 54 + 966
      - // NewL1RollupInfoConsumer creates a new l1RollupInfoConsumer + }
    - 55 + 967
      - func NewL1RollupInfoConsumer(cfg ConfigConsumer, +
    - 56 + 968
    + - synchronizer synchronizerProcessBlockRangeInterface, ch chan L1SyncMessage) *l1RollupInfoConsumer { + tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 57 + 969
      - if cfg.AceptableInacctivityTime < minAcceptableTimeWaitingForNewRollupInfoData { + if err != nil {
    - 58 + 970
      - log.Warnf("consumer: the AceptableInacctivityTime is too low (%s) minimum recommended %s", cfg.AceptableInacctivityTime, minAcceptableTimeWaitingForNewRollupInfoData) + log.Debugf("Batches to send: %+v", batches)
    - 59 + 971
      - } + log.Debug("l2CoinBase: ", l2Coinbase)
    - 237 + 1184
      - return nil, nil + if sb.NumBatch != 1 {
    - 238 + 1185
      - } + methodId := tx.Data()[:4]
    - 239 + 1186
      - b := convertL1BlockToEthBlock(lb) + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - 240 + 1187
    + - err := l.synchronizer.ProcessBlockRange([]etherman.Block{b}, order) + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) ||
    - 241 + + 1188 +
    -   - if err != nil { + + + bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) {
    - 242 + + 1189 +
    -   - log.Error("consumer: Error processing last block of range: ", rollupInfo.blockRange, " err:", err) + + + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 243 + 1190
      - return nil, err + if err != nil {
    -
     
    -
    - 249 + 1191
      - tmpStateBlock := convertEthmanBlockToStateBlock(&blocks[len(blocks)-1]) + return fmt.Errorf("error decoding the sequences (etrog): %v", err)
    - 250 + 1192
      - lastEthBlockSynced = &tmpStateBlock + }
    - 251 + + 1193 +
    -   - logBlocks(blocks) + + + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) ||
    - 252 + 1194
    + - err := l.synchronizer.ProcessBlockRange(blocks, order) + bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) { +
    +
    + 1195 + +
    + + + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 253 + 1196
      - if err != nil { + if err != nil {
    - 254 + 1197
      - log.Info("consumer: Error processing block range: ", rollupInfo.blockRange, " err:", err) + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 255 + 1198
      - 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 + 1278
      -
    + return nil
    - 18 + 1279
      - type consumerTestData struct { + }
    - 19 + 1280
      - sut *l1RollupInfoConsumer +
    - 20 + + 1281 +
    - - - syncMock *mock_syncinterfaces.BlockRangeProcessor + + + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, +
    +
    + 1282 + +
    + + + l1InfoRoot common.Hash, da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - 21 + 1283
      - ch chan L1SyncMessage + // Extract coded txs.
    - 22 + 1284
      - } + // Load contract ABI
    - 23 + 1285
      -
    + smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    -
    @@ -55,7 +54,7 @@
    +
     
    - 55 + 1287
      - lastBlockOfRange: types.NewBlock(&types.Header{Number: big.NewInt(123)}, nil, nil, nil, nil), + return nil, err
    - 56 + 1288
    @@ -288688,2516 +59293,2447 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 57 + 1289
      - data.syncMock. +
    - 58 + + 1290 +
    - - - On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything). + + + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st)
    - 59 + + 1291 +
    -   - Return(errors.New("error")). + + + }
    - 60 + + 1292 +
    -   - Once() + + +
    - 61 + + 1293 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
    -
    @@ -107,7 +106,7 @@
    +
    + 1294 + +
    + + + da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) { +
    - 107 + + 1295 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + // Extract coded txs.
    - 108 + + 1296 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200) + + + // Load contract ABI
    - 109 + + 1297 +
    -   - data.syncMock. + + + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - 110 + + 1298 +
    - - - On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything). + + + if err != nil {
    - 111 + + 1299 +
    -   - Return(nil). + + + return nil, err
    - 112 + + 1300 +
    -   - Once() + + + }
    - 113 + + 1301 +
    -   - err := data.sut.Start(ctxTimeout, nil) + + +
    -
    @@ -134,7 +133,7 @@
    +
    + 1302 + +
    + + + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st) +
    - 134 + + 1303 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + }
    - 135 + + 1304 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(300) + + +
    - 136 + + 1305 +
    -   - data.syncMock. + + + // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches
    - 137 + + 1306 +
    - - - On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything). + + + 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) {
    - 138 + 1309
      - Return(nil). + // Recover Method from signature and ABI
    - 139 + 1310
      - Once() + method, err := smcAbi.MethodById(txData[:4])
    - 140 + 1311
      - err := data.sut.Start(ctxTimeout, nil) + if err != nil {
    -
    @@ -163,7 +162,7 @@
    +
     
    - 163 + 1317
      - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + if err != nil {
    - 164 + 1318
      - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200) + return nil, err
    - 165 + 1319
      - data.syncMock. + }
    - 166 + + -
    - - - On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything). +
    +
    +   +
    - 167 + 1320
      - Return(nil). + bytedata, err := json.Marshal(data[0])
    - 168 + 1321
      - Once() + if err != nil {
    - 169 + 1322
      - err := data.sut.Start(ctxTimeout, nil) + return nil, err
    -
    @@ -192,7 +191,7 @@
    -
    - 192 + 1323
      - 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 + 1324
      - func setupConsumerTest(t *testing.T) consumerTestData { +
    - 210 + + 1325 +
    - - - syncMock := mock_syncinterfaces.NewBlockRangeProcessor(t) + + + var (
    - 211 + + 1326 +
    -   - ch := make(chan L1SyncMessage, 10) + + + maxSequenceTimestamp uint64
    - 212 + + 1327 +
    -   -
    + + + initSequencedBatchNumber uint64
    - 213 + + 1328 +
    -   - cfg := ConfigConsumer{ + + + coinbase common.Address
    -
    + + + 1329 + + +
    + + + )
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
     
    - 16 + + 1330 +
    -   + +
    - 17 + + 1331 +
    -   - type consumerTestData struct { + + + switch method.Name {
    - 18 + + 1332 +
    -   - sut *l1RollupInfoConsumer + + + case "sequenceBatches":
    - 19 + + 1333 +
    + - syncMock *synchronizerProcessBlockRangeInterfaceMock + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 20 + + 1334 +
    -   - ch chan L1SyncMessage + + + err := json.Unmarshal(bytedata, &sequences)
    - 21 + + 1335 +
    -   - } + + + if err != nil {
    - 22 + + 1336 +
    -   -
    + + + return nil, err
    -
     
    -
    - 54 + 1337
      - lastBlockOfRange: types.NewBlock(&types.Header{Number: big.NewInt(123)}, nil, nil, nil, nil), + }
    - 55 + + 1338 +
    -   - } + + +
    - 56 + + 1339 +
    -   - data.syncMock. + + + switch forkID {
    - 57 + 1340
    + - On("ProcessBlockRange", mock.Anything, mock.Anything). + case state.FORKID_ETROG:
    - 58 + + 1341 +
    -   - Return(errors.New("error")). + + + coinbase = data[1].(common.Address)
    - 59 + + 1342 +
    -   - Once() + + +
    - 60 + + 1343 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + case state.FORKID_ELDERBERRY:
    -
     
    -
    - 106 + + 1344 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + maxSequenceTimestamp = data[1].(uint64)
    - 107 + + 1345 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200) + + + initSequencedBatchNumber = data[2].(uint64)
    - 108 + + 1346 +
    -   - data.syncMock. + + + coinbase = data[3].(common.Address)
    - 109 + 1347
    + - On("ProcessBlockRange", mock.Anything, mock.Anything). + }
    - 110 + + 1348 +
    -   - Return(nil). + + +
    - 111 + + 1349 +
    -   - Once() + + + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 112 + + 1350 +
    -   - err := data.sut.Start(ctxTimeout, nil) + + + for i, seq := range sequences {
    -
     
    +
    + 1351 + +
    + + + bn := lastBatchNumber - uint64(len(sequences)-(i+1)) +
    - 133 + + 1352 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + s := seq
    - 134 + + 1353 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(300) + + + batch := SequencedBatch{
    - 135 + + 1354 +
    -   - data.syncMock. + + + BatchNumber: bn,
    - 136 + + 1355 +
    + - On("ProcessBlockRange", mock.Anything, mock.Anything). + L1InfoRoot: &l1InfoRoot,
    - 137 + + 1356 +
    -   - Return(nil). + + + SequencerAddr: sequencer,
    - 138 + + 1357 +
    -   - Once() + + + TxHash: txHash,
    - 139 + + 1358 +
    -   - err := data.sut.Start(ctxTimeout, nil) + + + Nonce: nonce,
    -
     
    +
    + 1359 + +
    + + + Coinbase: coinbase, +
    - 162 + + 1360 +
    -   - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + + + PolygonRollupBaseEtrogBatchData: &s,
    - 163 + + 1361 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200) + + + }
    - 164 + + 1362 +
    -   - data.syncMock. + + + if forkID >= state.FORKID_ELDERBERRY {
    - 165 + + 1363 +
    + - On("ProcessBlockRange", mock.Anything, mock.Anything). + batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{
    - 166 + + 1364 +
    -   - Return(nil). + + + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 167 + + 1365 +
    -   - Once() + + + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 168 + + 1366 +
    -   - err := data.sut.Start(ctxTimeout, nil) + + + }
    -
     
    +
    + 1367 + +
    + + + } +
    - 191 + + 1368 +
    -   - responseRollupInfoByBlockRange.blockRange.toBlock = 400 + + + sequencedBatches[i] = batch
    - 192 + 1369
      - data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange) + }
    - 193 + + 1370 +
    -   - data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200) + + +
    - 194 + + 1371 +
    + - data.syncMock.EXPECT().ProcessBlockRange(mock.Anything, mock.Anything).Return(nil).Times(1) + return sequencedBatches, nil
    - 195 + + 1372 +
    -   - err := data.sut.Start(ctxTimeout, nil) + + + case "sequenceBatchesValidium":
    - 196 + + 1373 +
    -   - require.NoError(t, err) + + + var (
    - 197 + + 1374 +
    -   - } + + + sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    -
     
    +
    + 1375 + +
    + + + dataAvailabilityMsg []byte +
    - 206 + + 1376 +
    -   - } + + + )
    - 207 + + 1377 +
    -   -
    + + + err := json.Unmarshal(bytedata, &sequencesValidium)
    - 208 + + 1378 +
    -   - func setupConsumerTest(t *testing.T) consumerTestData { + + + if err != nil {
    - 209 + + 1379 +
    + - syncMock := newSynchronizerProcessBlockRangeInterfaceMock(t) + return nil, err
    - 210 + + 1380 +
    -   - ch := make(chan L1SyncMessage, 10) + + + }
    - 211 + + 1381 +
    -   + +
    - 212 + + 1382 +
    -   - cfg := ConfigConsumer{ -
    -
    -
    + + + switch forkID {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -31,7 +31,7 @@
    - 31 + + 1383 +
    -   - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + + + case state.FORKID_ETROG:
    - 32 + + 1384 +
    -   - } + + + coinbase = data[1].(common.Address)
    - 33 + + 1385 +
    -   -
    + + + dataAvailabilityMsg = data[2].([]byte)
    - 34 + + 1386 +
    - - - ethermanClient, err := etherman.NewClient(cfg, l1Config) + + +
    - 35 + + 1387 +
    -   - require.NoError(t, err) + + + case state.FORKID_ELDERBERRY:
    - 36 + + 1388 +
    -   - worker := newWorker(ethermanClient) + + + maxSequenceTimestamp = data[1].(uint64)
    - 37 + + 1389 +
    -   - ch := make(chan responseRollupInfoByBlockRange) -
    -
    -
    + + + initSequencedBatchNumber = data[2].(uint64)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 31 + + 1390 +
    -   - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + + + coinbase = data[3].(common.Address)
    - 32 + + 1391 +
    -   - } + + + dataAvailabilityMsg = data[4].([]byte)
    - 33 + + 1392 +
    -   -
    + + + }
    - 34 + + 1393 +
    + - ethermanClient, err := etherman.NewClient(cfg, l1Config, nil, nil) +
    - 35 + + 1394 +
    -   - require.NoError(t, err) + + + // Pair the batch number, hash, and if it is forced. This will allow
    - 36 + + 1395 +
    -   - worker := newWorker(ethermanClient) + + + // retrieval from different sources, and keep them in original order.
    - 37 + + 1396 +
    -   - ch := make(chan responseRollupInfoByBlockRange) -
    -
    -
    + + + var batchInfos []batchInfo
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -218,6 +219,12 @@
    - 218 + + 1397 +
    -   - log.Errorf("%s error batchResultSanityCheck. Error: %s", data.DebugPrefix, err.Error()) + + + for i, d := range sequencesValidium {
    - 219 + + 1398 +
    -   - return nil, err + + + bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1))
    - 220 + + 1399 +
    -   - } + + + forced := d.ForcedTimestamp > 0
    - + + 1400 -
    -   -
    +
    +
    + + + h := d.TransactionsHash
    - + + 1401 -
    -   -
    +
    +
    + + + batchInfos = append(batchInfos, batchInfo{num: bn, hash: h, isForced: forced})
    - + + 1402 -
    -   -
    +
    +
    + + + }
    - + + 1403 -
    -   +
    +
    + +
    - + + 1404 -
    -   -
    +
    +
    + + + batchData, err := retrieveBatchData(da, st, batchInfos, dataAvailabilityMsg)
    - + + 1405 -
    -   -
    +
    +
    + + + if err != nil {
    - 221 + + 1406 +
    -   -
    + + + return nil, err
    - 222 + + 1407 +
    -   - if data.BatchMustBeClosed { + + + }
    - 223 + + 1408 +
    -   - log.Debugf("%s Closing batch", data.DebugPrefix) + + +
    -
    @@ -226,13 +233,6 @@
    -
    - 226 + + 1409 +
    -   - log.Errorf("%s error closing batch. Error: ", data.DebugPrefix, err) + + + sequencedBatches := make([]SequencedBatch, len(sequencesValidium))
    - 227 + + 1410 +
    -   - return nil, err + + + for i, info := range batchInfos {
    - 228 + + 1411 +
    -   - } + + + bn := info.num
    - 229 + + 1412 +
    - - - } else { + + + s := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 230 + + 1413 +
    - - - log.Debugf("%s updateWIPBatch", data.DebugPrefix) + + + Transactions: batchData[i],
    - 231 + + 1414 +
    - - - err = b.updateWIPBatch(ctx, data, processBatchResp.NewStateRoot, dbTx) + + + ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot,
    - 232 + + 1415 +
    - - - if err != nil { + + + ForcedTimestamp: sequencesValidium[i].ForcedTimestamp,
    - 233 + + 1416 +
    - - - log.Errorf("%s error updateWIPBatch. Error: ", data.DebugPrefix, err) + + + ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1,
    - 234 + + 1417 +
    - - - return nil, err + + + }
    - 235 + + 1418 +
    - - - } + + + batch := SequencedBatch{
    - 236 + + 1419 +
    -   - } + + + BatchNumber: bn,
    - 237 + + 1420 +
    -   -
    + + + L1InfoRoot: &l1InfoRoot,
    - 238 + + 1421 +
    -   - updatedBatch := *data.StateBatch + + + SequencerAddr: sequencer,
    -
    @@ -429,6 +429,7 @@
    -
    - 429 + + 1422 +
    -   - Transactions: data.TrustedBatch.BatchL2Data, + + + TxHash: txHash,
    - 430 + + 1423 +
    -   - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), + + + Nonce: nonce,
    - 431 + + 1424 +
    -   - SkipVerifyL1InfoRoot_V2: true, + + + Coinbase: coinbase,
    - + + 1425 -
    -   -
    +
    +
    + + + PolygonRollupBaseEtrogBatchData: &s,
    - 432 + + 1426 +
    -   - } + + + }
    - 433 + + 1427 +
    -   - return request + + + if forkID >= state.FORKID_ELDERBERRY {
    - 434 + + 1428 +
    -   - } -
    -
    -
    + + + elderberry := &SequencedBatchElderberryData{
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - -
    -
     
    - 219 + + 1429 +
    -   - log.Errorf("%s error batchResultSanityCheck. Error: %s", data.DebugPrefix, err.Error()) + + + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 220 + + 1430 +
    -   - return nil, err + + + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 221 + + 1431 +
    -   - } + + + }
    - 222 + 1432
    + - log.Debugf("%s updateWIPBatch ", data.DebugPrefix) + batch.SequencedBatchElderberryData = elderberry
    - 223 + 1433
    + - err = b.updateWIPBatch(ctx, data, processBatchResp.NewStateRoot, dbTx) + }
    - 224 + 1434
    + - if err != nil { + sequencedBatches[i] = batch
    - 225 + 1435
    + - log.Errorf("%s error updateWIPBatch. Error: ", data.DebugPrefix, err) + }
    - 226 + 1436
    + - return nil, err +
    - 227 + 1437
    + - } + return sequencedBatches, nil
    - 228 + 1438
      -
    + }
    - 229 + 1439
      - if data.BatchMustBeClosed { +
    - 230 + + 1440 +
    -   - log.Debugf("%s Closing batch", data.DebugPrefix) + + + return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName)
    -
     
    -
    - 233 + 1441
      - log.Errorf("%s error closing batch. Error: ", data.DebugPrefix, err) + }
    - 234 + 1442
      - return nil, err +
    - 235 + + 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)
    - 236 + 1451
      - } + if err != nil {
    - 237 + 1452
      -
    + return nil, err
    - 238 + 1453
      - updatedBatch := *data.StateBatch + }
    -
     
    +
    + 1454 + +
    + + + forcedData, err := getForcedBatchData(st, batchInfos) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    - 429 + 1455
      - Transactions: data.TrustedBatch.BatchL2Data, + if err != nil {
    - 430 + 1456
      - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), + return nil, err
    - 431 + 1457
      - SkipVerifyL1InfoRoot_V2: true, + }
    - 432 + 1458
    + - ExecutionMode: executor.ExecutionMode1, + data := make([][]byte, len(batchInfos))
    - 433 + + 1459 +
    -   - } + + + for i, info := range batchInfos {
    - 434 + + 1460 +
    -   - return request + + + bn := info.num
    - 435 + + 1461 +
    -   - } + + + if info.isForced {
    -
    + + + 1462 + + +
    + + + data[i] = forcedData[bn]
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -291231,33 +61767,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -291272,511 +61808,482 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -89,6 +89,74 @@
    - 89 + + 1463 +
    -   - require.Equal(t, false, res.ClearCache) + + + } else {
    - 90 + + 1464 +
    -   - } + + + data[i] = validiumData[bn]
    - 91 + + 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 -
    -   +
    +
    + +
    - + + 1483 -
    -   -
    +
    +
    + + + batchL2Data, err := da.GetBatchL2Data(batchNums, batchHashes, daMessage)
    - + + 1484 -
    +
    +
      -
    + if err != nil {
    - + + 1485 -
    +
    +
      -
    + return nil, err
    - + + 1486 -
    +
    +
      -
    + }
    - + + 1487 -
    -   +
    +
    + +
    - + + 1488 -
    -   -
    +
    +
    + + + if len(batchL2Data) != len(batchNums) {
    - + + 1489 -
    -   -
    +
    +
    + + + return nil,
    - + + 1490 -
    -   -
    +
    +
    + + + fmt.Errorf("failed to retrieve all batch data. Expected %d, got %d", len(batchNums), len(batchL2Data))
    - + + 1491 -
    -   -
    +
    +
    + + + }
    - + + 1492 -
    -   +
    +
    + +
    - + + 1493 -
    -   -
    +
    +
    + + + data := make(map[uint64][]byte)
    - + + 1494 -
    -   -
    +
    +
    + + + for i, bn := range batchNums {
    - + + 1495 -
    -   -
    +
    +
    + + + data[bn] = batchL2Data[i]
    - + + 1496 -
    -   -
    +
    +
    + + + }
    - + + 1497 -
    -   +
    +
    + +
    - + + 1498 -
    -   -
    +
    +
    + + + return data, nil
    - + + 1499 -
    -   -
    +
    +
    + + + }
    - + + 1500 -
    -   +
    +
    + +
    - + + 1501 -
    -   -
    +
    +
    + + + func getForcedBatchData(st stateProvider, batchInfos []batchInfo) (map[uint64][]byte, error) {
    - + + 1502 -
    -   -
    +
    +
    + + + var batchNums []uint64
    - + + 1503 -
    -   -
    +
    +
    + + + var batchHashes []common.Hash
    - + + 1504 -
    -   -
    +
    +
    + + + for _, info := range batchInfos {
    - + + 1505 -
    -   -
    +
    +
    + + + if info.isForced {
    - + + 1506 -
    -   -
    +
    +
    + + + batchNums = append(batchNums, info.num)
    - + + 1507 -
    -   -
    +
    +
    + + + batchHashes = append(batchHashes, info.hash)
    - + + 1508 -
    -   -
    +
    +
    + + + }
    - + + 1509 -
    -   -
    +
    +
    + + + }
    - + + 1510 -
    -   -
    +
    +
    + + + if len(batchNums) == 0 {
    - + + 1511 -
    -   -
    +
    +
    + + + return nil, nil
    - + + 1512 -
    -   -
    +
    +
    + + + }
    - + + 1513 -
    -   -
    +
    +
    + + + data, err := st.GetForcedBatchDataByNumbers(context.Background(), batchNums, nil)
    - + + 1514 -
    +
    +
      -
    + if err != nil {
    - + + 1515 -
    +
    +
      -
    + return nil, err
    - + + 1516 -
    +
    +
      -
    + }
    - + + 1517 -
    -   +
    +
    + +
    - + + 1518 -
    -   -
    +
    +
    + + + for i, bn := range batchNums {
    - + + 1519 -
    -   -
    +
    +
    + + + expectedHash := batchHashes[i]
    - + + 1520 -
    -   -
    +
    +
    + + + d, ok := data[bn]
    - + + 1521 -
    -   -
    +
    +
    + + + if !ok {
    - + + 1522 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("missing forced batch data for number %d", bn)
    - + + 1523 -
    -   -
    +
    +
    + + + }
    - + + 1524 -
    -   -
    +
    +
    + + + actualHash := crypto.Keccak256Hash(d)
    - + + 1525 -
    -   -
    +
    +
    + + + if actualHash != expectedHash {
    - + + 1526 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("got wrong hash for forced batch data number %d", bn)
    - + + 1527 -
    +
    +
      -
    + }
    - + + 1528 -
    +
    +
      -
    + }
    - + + 1529 -
    -   -
    +
    +
    + + + return data, nil
    - 92 + 1530
      - func newTestData(t *testing.T) testDataForBathExecutor { + }
    - 93 + 1531
      - stateMock := mock_l2_sync_etrog.NewStateInterface(t) +
    - 94 + 1532
      - syncMock := mock_syncinterfaces.NewSynchronizerFlushIDManager(t) + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - + +
     
    - 89 + 2009
      - require.Equal(t, false, res.ClearCache) + }
    - 90 + 2010
      - } +
    - 91 + 2011
      -
    -
    -
    - 92 - -
    - + - // This test check that if you process incrementally a batch that need to be close -
    -
    - 93 - -
    - + - // the GER is update because we call UpdateWIPBatch + // LoadAuthFromKeyStore loads an authorization from a key store file
    - 94 + + 2012 +
    + - // NOTE: CloseBatch() doesnt update GER + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 95 + + 2013 +
    + - func TestIncrementalProcessUpdateBatchL2DataAndGER(t *testing.T) { + auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 96 + + 2014 +
    - + - // Arrange +   + if err != nil {
    - 97 + + 2015 +
    + - stateMock := mock_l2_sync_etrog.NewStateInterface(t) + return nil, nil, err
    - 98 + + 2016 +
    - + - syncMock := mock_syncinterfaces.NewSynchronizerFlushIDManager(t) +   + }
    - 99 + + 2017 +
    - + +  
    - 100 + + 2018 +
    - + - sut := SyncTrustedBatchExecutorForEtrog{ +   + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 101 + + 2019 +
    - + - state: stateMock, +   + etherMan.auth[auth.From] = auth
    - 102 + + 2020 +
    + - sync: syncMock, + return &auth, pk, nil
    - 103 + + 2021 +
    - + - } +   + }
    - 104 + + 2022 +
    - + - ctx := context.Background() +   +
    - 105 + + 2023 +
    - + -
    +   + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    - 106 - -
    - + - stateBatchL2Data, _ := hex.DecodeString(codedL2BlockHeader + codedRLP2Txs1) -
    +
    +
     
    - 107 + + 2038 +
    - + - trustedBatchL2Data, _ := hex.DecodeString(codedL2BlockHeader + codedRLP2Txs1 + codedL2BlockHeader + codedRLP2Txs1) +   + }
    - 108 + + 2039 +
    - + - expectedStateRoot := common.HexToHash("0x723e5c4c7ee7890e1e66c2e391d553ee792d2204ecb4fe921830f12f8dcd1a92") +   +
    - 109 + + 2040 +
    - + - //deltaBatchL2Data := []byte{4} +   + // newAuthFromKeystore an authorization instance from a keystore file
    - 110 + + 2041 +
    + - batchNumber := uint64(123) + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 111 + + 2042 +
    - + - data := l2_shared.ProcessData{ +   + log.Infof("reading key from: %v", path)
    - 112 + + 2043 +
    - + - BatchNumber: batchNumber, +   + key, err := newKeyFromKeystore(path, password)
    - 113 + + 2044 +
    - + - OldStateRoot: common.Hash{}, +   + if err != nil {
    - 114 + + 2045 +
    + - BatchMustBeClosed: true, + return bind.TransactOpts{}, nil, err
    - 115 + + 2046 +
    - + - TrustedBatch: &types.Batch{ +   + }
    - 116 + + 2047 +
    - + - Number: 123, +   + if key == nil {
    - 117 + + 2048 +
    + - BatchL2Data: trustedBatchL2Data, + return bind.TransactOpts{}, nil, nil
    - 118 + + 2049 +
    - + - StateRoot: expectedStateRoot, +   + }
    - 119 + + 2050 +
    - + - Closed: true, +   + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    - 120 + + 2051 +
    - + - }, +   + if err != nil {
    - 121 + + 2052 +
    + - StateBatch: &state.Batch{ + return bind.TransactOpts{}, nil, err
    - 122 + + 2053 +
    - + - BatchNumber: batchNumber, +   + }
    - 123 + + 2054 +
    + - BatchL2Data: stateBatchL2Data, + return *auth, key.PrivateKey, nil
    - 124 + + 2055 +
    - + - GlobalExitRoot: common.HexToHash("0x9c8fa7ce2e197f9f1b3c30de9f93de3c1cb290e6c118a18446f47a9e1364c3ab"), +   + }
    - 125 + + 2056 +
    - + - }, +   +
    - 126 + + 2057 +
    - + - } +   + // getAuthByAddress tries to get an authorization from the authorizations map
    - 127 + +
     
    +
    + 2079 +
    - + - expectedUpdate := state.ProcessingReceipt{ +   +
    - 128 + + 2080 +
    - + - BatchNumber: 123, +   + return *auth, nil
    - 129 + + 2081 +
    - + - StateRoot: expectedStateRoot, +   + }
    - 130 + 2082
    + - LocalExitRoot: data.TrustedBatch.LocalExitRoot, +
    - 131 + 2083
    + - GlobalExitRoot: data.TrustedBatch.GlobalExitRoot, + // GetDAProtocolAddr returns the address of the data availability protocol
    - 132 + 2084
    + - AccInputHash: data.TrustedBatch.AccInputHash, + func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) {
    - 133 + 2085
    + - BatchL2Data: trustedBatchL2Data, + return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
    - 134 + 2086
    + - } + }
    - 135 + 2087
    @@ -291786,331 +62293,346 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 136 + 2088
    + - stateMock.EXPECT().UpdateWIPBatch(ctx, expectedUpdate, mock.Anything).Return(nil).Once() + // GetDAProtocolName returns the name of the data availability protocol
    - 137 + 2089
    + - stateMock.EXPECT().GetL1InfoTreeDataFromBatchL2Data(ctx, mock.Anything, mock.Anything).Return(map[uint32]state.L1DataV2{}, expectedStateRoot, common.Hash{}, nil).Once() + func (etherMan *Client) GetDAProtocolName() (string, error) {
    - 138 + 2090
    + - stateMock.EXPECT().GetForkIDByBatchNumber(batchNumber).Return(uint64(7)).Once() + return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false})
    - 139 + 2091
    + -
    + }
    - 140 + 2092
    + - processBatchResp := &state.ProcessBatchResponse{ +
    - 141 + 2093
    + - NewStateRoot: expectedStateRoot, + // SetDataAvailabilityProtocol sets the address for the new data availability protocol
    - 142 + 2094
    + - } + func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) {
    - 143 + 2095
    + - stateMock.EXPECT().ProcessBatchV2(ctx, mock.Anything, true).Return(processBatchResp, "", nil).Once() + auth, err := etherMan.getAuthByAddress(from)
    - 144 + 2096
    + -
    + if err != nil {
    - 145 + 2097
    + - syncMock.EXPECT().PendingFlushID(mock.Anything, mock.Anything).Once() + return nil, err
    - 146 + 2098
    + - syncMock.EXPECT().CheckFlushID(mock.Anything).Return(nil).Maybe() + }
    - 147 + 2099
    + - expectedUpdateClosed := expectedUpdate +
    - 148 + 2100
    + - expectedUpdateClosed.GlobalExitRoot = common.Hash{} + return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress)
    - 149 + 2101
    + - expectedUpdateClosed.ClosingReason = state.SyncL2TrustedBatchClosingReason + }
    - 150 + 2102
    + - stateMock.EXPECT().CloseBatch(ctx, expectedUpdateClosed, mock.Anything).Return(nil).Once() +
    - 151 + 2103
    + - // Act + // GetRollupId returns the rollup id
    - 152 + 2104
    + - res, err := sut.IncrementalProcess(ctx, &data, nil) + func (etherMan *Client) GetRollupId() uint32 {
    - 153 + 2105
    + - // Assert + return etherMan.RollupID
    - 154 + 2106
    + - log.Info(res) + }
    - 155 - -
    - + - require.NoError(t, err) +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - -
    +
    @@ -38,7 +38,7 @@
    - 156 + + 38 +
    - + - require.Equal(t, trustedBatchL2Data, res.UpdateBatch.BatchL2Data) +   + }
    - 157 + + 39 +
    - + - require.Equal(t, false, res.ClearCache) +   +
    - 158 + + 40 +
    - + - } +   + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - 159 + + 41 +
    - + -
    + - + func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) {
    - 160 + 42
      - func newTestData(t *testing.T) testDataForBathExecutor { + privateKey, err := crypto.GenerateKey()
    - 161 + 43
      - stateMock := mock_l2_sync_etrog.NewStateInterface(t) + if err != nil {
    - 162 + 44
      - syncMock := mock_syncinterfaces.NewSynchronizerFlushIDManager(t) + log.Fatal(err)
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - RENAMED - -
    -
    -
    -
    - - - + + + + + + + @@ -292125,2899 +62647,3051 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -196,6 +196,7 @@
    +
    @@ -47,7 +47,9 @@
    - 196 + 47
      - OldAccInputHash: batches[1].AccInputHash, + if err != nil {
    - 197 + 48
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), + log.Fatal(err)
    - 198 + 49
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), + } +
    +
    + 50 + +
    + - + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth) +
    +
    + + +
    +   +
    - 199 + 51
      - } + if err != nil {
    - 200 + 52
      - // check if batch needs to be synchronized + log.Fatal(err)
    - 201 + 53
      - if batches[0] != nil { + }
    -
    -
    -
    -
    - - - + - - - - -
    -
     
    +
    @@ -55,12 +57,12 @@
    - 196 + 55
      - OldAccInputHash: batches[1].AccInputHash, + if err != nil {
    - 197 + 56
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), + log.Fatal(err)
    - 198 + 57
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), + }
    - 199 + + 58 +
    - + - ExecutionMode: executor.ExecutionMode1, + - + return ethman, ethBackend, auth, polAddr, br
    - 200 + 59
      - } + }
    - 201 + 60
      - // check if batch needs to be synchronized +
    - 202 + 61
      - if batches[0] != nil { + func TestGEREvent(t *testing.T) {
    -
    + + + 62 + + +
    +   + // Set up testing environment
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_block_range_process.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - + + + - - + + + - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
    @@ -1,166 +0,0 @@
    - 1 + + 63 +
    - - package synchronizer + etherman, ethBackend, auth, _, br := newTestingEnv()
    - 2 + + 64 +
    - - +  
    - 3 + + 65 +
    - - - import ( +   + // Read currentBlock
    - 4 + + 66 +
    - - - "context" +   + ctx := context.Background()
    - 5 + +
    @@ -82,14 +84,14 @@
    +
    + 82 +
    - - - "errors" +   + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 6 + + 83 +
    - - -
    +   + require.NoError(t, err)
    - 7 + + 84 +
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" +   + t.Logf("Blocks: %+v", blocks)
    - 8 + + 85 +
    - - "github.com/0xPolygonHermez/zkevm-node/log" + assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber)
    - 9 + + 86 +
    - - - "github.com/0xPolygonHermez/zkevm-node/state" +   + assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
    - 10 + + 87 +
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions" +   + assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
    - 11 + + 88 +
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +   + }
    - 12 + + 89 +
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" +   +
    - 13 + + 90 +
    - - - "github.com/ethereum/go-ethereum/common" +   + func TestForcedBatchEvent(t *testing.T) {
    - 14 + + 91 +
    - - - "github.com/jackc/pgx/v4" +   + // Set up testing environment
    - 15 + + 92 +
    - - ) + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 16 + + 93 +
    - - +  
    - 17 + + 94 +
    - - - type stateBlockRangeProcessor interface { +   + // Read currentBlock
    - 18 + + 95 +
    - - - BeginStateTransaction(ctx context.Context) (pgx.Tx, error) +   + ctx := context.Background()
    - 19 + +
    @@ -114,8 +116,8 @@
    +
    + 114 +
    - - - AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error +   + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 20 + + 115 +
    - - - GetForkIDByBatchNumber(batchNumber uint64) uint64 +   + require.NoError(t, err)
    - 21 + + 116 +
    - - - GetForkIDByBlockNumber(blockNumber uint64) uint64 +   + t.Logf("Blocks: %+v", blocks)
    - 22 + + 117 +
    - - } + assert.Equal(t, uint64(8), blocks[0].BlockNumber)
    - 23 + + 118 +
    - -
    + assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber)
    - 24 + + 119 +
    - - - type ethermanI interface { +   + assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
    - 25 + + 120 +
    - - - GetFinalizedBlockNumber(ctx context.Context) (uint64, error) +   + assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
    - 26 + + 121 +
    - - - } +   + assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
    - 27 + +
    @@ -125,7 +127,7 @@
    +
    + 125 +
    - - +  
    - 28 + + 126 +
    - - - // BlockRangeProcess is the struct that process the block range that implements syncinterfaces.BlockRangeProcessor +   + func TestSequencedBatchesEvent(t *testing.T) {
    - 29 + + 127 +
    - - - type BlockRangeProcess struct { +   + // Set up testing environment
    - 30 + + 128 +
    - - state stateBlockRangeProcessor + etherman, ethBackend, auth, _, br := newTestingEnv()
    - 31 + + 129 +
    - - - etherMan ethermanI +   +
    - 32 + + 130 +
    - - - l1EventProcessors syncinterfaces.L1EventProcessorManager +   + // Read currentBlock
    - 33 + + 131 +
    - - - flushIdManager syncinterfaces.SynchronizerFlushIDManager +   + ctx := context.Background()
    - 34 + +
    @@ -156,13 +158,19 @@
    +
    + 156 +
    - - - } +   + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
    - 35 + + 157 +
    - - -
    +   + require.NoError(t, err)
    - 36 + + 158 +
    - - - // NewBlockRangeProcessLegacy creates a new BlockRangeProcess +   + t.Log("Blocks: ", blocks)
    - 37 + + 159 +
    - - func NewBlockRangeProcessLegacy( + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 38 + + 160 +
    - - state stateBlockRangeProcessor, + sequences = append(sequences, polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 39 + + 161 +
    - - etherMan ethermanI, + Transactions: common.Hex2Bytes(rawTxs),
    - 40 + + 162 +
    - - l1EventProcessors syncinterfaces.L1EventProcessorManager, + }, polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 41 + + 163 +
    - - flushIdManager syncinterfaces.SynchronizerFlushIDManager, + Transactions: common.Hex2Bytes(rawTxs),
    - 42 + + -
    - - - ) *BlockRangeProcess { +
    +
    +   +
    - 43 + + 164 +
    - - - return &BlockRangeProcess{ +   + })
    - 44 + + 165 +
    - - state: state, + _, err = etherman.ZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From)
    - 45 + + -
    - - - etherMan: etherMan, +
    +
    +   +
    - 46 + + -
    - - - l1EventProcessors: l1EventProcessors, +
    +
    +   +
    - 47 + + -
    - - - flushIdManager: flushIdManager, +
    +
    +   +
    - 48 + + -
    - - - } +
    +
    +   +
    - 49 + + + +
    +   +
    +
    +
    + 166 +
    - - - } +   + require.NoError(t, err)
    - 50 + + 167 +
    - - +  
    - 51 + + 168 +
    - - - // ProcessBlockRangeSingleDbTx process the L1 events and stores the information in the db reusing same DbTx +   + // Mine the tx in a block
    - 52 + +
    @@ -188,7 +196,7 @@
    +
    + 188 +
    - - - func (s *BlockRangeProcess) ProcessBlockRangeSingleDbTx(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order, storeBlocks syncinterfaces.ProcessBlockRangeL1BlocksMode, dbTx pgx.Tx) error { +   +
    - 53 + + 189 +
    - - - return s.internalProcessBlockRange(ctx, blocks, order, storeBlocks, &dbTx) +   + func TestVerifyBatchEvent(t *testing.T) {
    - 54 + + 190 +
    - - - } +   + // Set up testing environment
    - 55 + + 191 +
    - -
    + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 56 + + 192 +
    - - - // ProcessBlockRange process the L1 events and stores the information in the db +   +
    - 57 + + 193 +
    - - - func (s *BlockRangeProcess) ProcessBlockRange(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { +   + // Read currentBlock
    - 58 + + 194 +
    - - - return s.internalProcessBlockRange(ctx, blocks, order, syncinterfaces.StoreL1Blocks, nil) +   + ctx := context.Background()
    - 59 + +
    @@ -197,12 +205,13 @@
    +
    + 197 +
    - - - } +   + require.NoError(t, err)
    - 60 + + 198 +
    - - +  
    - 61 + + 199 +
    - - - // ProcessBlockRange process the L1 events and stores the information in the db +   + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - 62 + + 200 +
    - - func (s *BlockRangeProcess) internalProcessBlockRange(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order, storeBlocks syncinterfaces.ProcessBlockRangeL1BlocksMode, dbTxExt *pgx.Tx) error { + tx := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 63 + + 201 +
    - - // Check the latest finalized block in L1 + Transactions: common.Hex2Bytes(rawTxs),
    - 64 + + 202 +
    - - - finalizedBlockNumber, err := s.etherMan.GetFinalizedBlockNumber(ctx) +   + }
    - 65 + + 203 +
    - - if err != nil { + //TODO: Fix params
    - 66 + + 204 +
    - - log.Errorf("error getting finalized block number in L1. Error: %v", err) + _, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From)
    - 67 + + 205 +
    - - - return err +   + require.NoError(t, err)
    - 68 + + + +
    +   +
    +
    +
    + 206 +
    - - - } +   +
    - 69 + + 207 + +
    +   + // Mine the tx in a block +
    +
    + 208 +
    - - - // New info has to be included into the db using the state +   + ethBackend.Commit()
    - 70 + +
    @@ -220,7 +229,7 @@
    +
    + 220 +
    - - - for i := range blocks { +   + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 71 + + 221 +
    - - - // Begin db transaction +   + require.NoError(t, err)
    - 72 + + 222 +
    - - - var dbTx pgx.Tx +   + t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
    - 73 + + 223 +
    - - var err error + assert.Equal(t, uint64(9), blocks[1].BlockNumber)
    - 74 + + 224 +
    - - - if dbTxExt == nil { +   + assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
    - 75 + + 225 +
    - - - log.Debugf("Starting dbTx for BlockNumber:%d", blocks[i].BlockNumber) +   + assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
    - 76 + + 226 +
    - - - dbTx, err = s.state.BeginStateTransaction(ctx) +   + assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
    - 77 + +
    @@ -232,7 +241,7 @@
    +
    + 232 +
    - - - if err != nil { +   +
    - 78 + + 233 +
    - - - return err +   + func TestSequenceForceBatchesEvent(t *testing.T) {
    - 79 + + 234 +
    - - - } +   + // Set up testing environment
    - 80 + + 235 +
    - - } else { + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 81 + + 236 +
    - - - dbTx = *dbTxExt +   +
    - 82 + + 237 +
    - - - } +   + // Read currentBlock
    - 83 + + 238 +
    - - - // Process event received from l1 +   + ctx := context.Background()
    - 84 + +
    @@ -283,7 +292,7 @@
    +
    + 283 +
    - - - err = s.processBlock(ctx, blocks, i, dbTx, order, storeBlocks, finalizedBlockNumber) +   + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 85 + + 284 +
    - - - if err != nil { +   + require.NoError(t, err)
    - 86 + + 285 +
    - - - if dbTxExt == nil { +   + t.Logf("Blocks: %+v", blocks)
    - 87 + + 286 +
    - - // Rollback db transaction + assert.Equal(t, uint64(12), blocks[1].BlockNumber)
    - 88 + + 287 +
    - - - rollbackErr := dbTx.Rollback(ctx) +   + assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
    - 89 + + 288 +
    - - - if rollbackErr != nil { +   + assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
    - 90 + + 289 +
    - - - if !errors.Is(rollbackErr, pgx.ErrTxClosed) { +   + assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
    - 91 + +
    @@ -293,7 +302,7 @@
    +
    + 293 +
    - - - log.Errorf("error rolling back state. RollbackErr: %s, Error : %v", rollbackErr.Error(), err) +   +
    - 92 + + 294 +
    - - - return rollbackErr +   + func TestSendSequences(t *testing.T) {
    - 93 + + 295 +
    - - - } else { +   + // Set up testing environment
    - 94 + + 296 +
    - - log.Warnf("error rolling back state because is already closed. RollbackErr: %s, Error : %v", rollbackErr.Error(), err) + etherman, ethBackend, auth, _, br := newTestingEnv()
    - 95 + + 297 +
    - - - return err +   +
    - 96 + + 298 +
    - - - } +   + // Read currentBlock
    - 97 + + 299 +
    - - - } +   + ctx := context.Background()
    - 98 + +
    @@ -315,10 +324,12 @@
    +
    + 315 +
    - - - return err +   + BatchL2Data: batchL2Data,
    - 99 + + 316 +
    - - - } +   + LastL2BLockTimestamp: time.Now().Unix(),
    - 100 + + 317 +
    - - - return err +   + }
    - 101 + + -
    - - - } +
    +
    +   +
    - 102 + + 318 +
    - - - if dbTxExt == nil { +   + lastL2BlockTStamp := tx1.Time().Unix()
    - 103 + + 319 +
    - - // Commit db transaction + // TODO: fix params
    - 104 + 320
    - - err = dbTx.Commit(ctx) + tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From)
    - 105 + + 321 +
    - - - if err != nil { +   + require.NoError(t, err)
    - 106 + + -
    - - - log.Errorf("error committing state. BlockNumber: %d, Error: %v", blocks[i].BlockNumber, err) +
    +
    +   +
    - 107 + + -
    - - - } +
    +
    +   +
    - 108 + + 322 +
    - - - } +   + log.Debug("TX: ", tx.Hash())
    - 109 + + 323 +
    - - - } +   + ethBackend.Commit()
    - 110 + + 324 +
    - - - return nil +   +
    - 111 + +
    @@ -341,7 +352,7 @@
    +
    + 341 +
    - - - } +   +
    - 112 + + 342 +
    - - -
    +   + func TestGasPrice(t *testing.T) {
    - 113 + + 343 +
    - - - 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 { +   + // Set up testing environment
    - 114 + + 344 +
    - - var err error + etherman, _, _, _, _ := newTestingEnv()
    - 115 + + 345 +
    - - - if storeBlock == syncinterfaces.StoreL1Blocks { +   + etherscanM := new(etherscanMock)
    - 116 + + 346 +
    - - - b := state.Block{ +   + ethGasStationM := new(ethGasStationMock)
    - 117 + + 347 +
    - - - BlockNumber: blocks[i].BlockNumber, +   + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 118 + +
    @@ -360,14 +371,14 @@
    +
    + 360 +
    - - - BlockHash: blocks[i].BlockHash, +   +
    - 119 + + 361 +
    - - - ParentHash: blocks[i].ParentHash, +   + func TestErrorEthGasStationPrice(t *testing.T) {
    - 120 + + 362 +
    - - - ReceivedAt: blocks[i].ReceivedAt, +   + // Set up testing environment
    - 121 + + 363 +
    - - } + etherman, _, _, _, _ := newTestingEnv()
    - 122 + + 364 +
    - - - if blocks[i].BlockNumber <= finalizedBlockNumber { +   + ethGasStationM := new(ethGasStationMock)
    - 123 + + 365 +
    - - - b.Checked = true +   + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
    - 124 + + 366 +
    - - - } +   + ctx := context.Background()
    - 125 + + 367 +
    - - - err = s.state.AddBlock(ctx, &b, dbTx) +   +
    - 126 + + 368 +
    - - - if err != nil { +   + ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
    - 127 + + 369 +
    - - - log.Errorf("error adding block to db. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err) +   + gp := etherman.GetL1GasPrice(ctx)
    - 128 + + 370 +
    - - return err + assert.Equal(t, big.NewInt(1392695906), gp)
    - 129 + + 371 +
    - - - } +   +
    - 130 + + 372 +
    - - - } else { +   + etherscanM := new(etherscanMock)
    - 131 + + 373 +
    - - - log.Debugf("Skip storing block BlockNumber:%d", blocks[i].BlockNumber) +   + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 132 + +
    @@ -379,7 +390,7 @@
    +
    + 379 +
    - - - } +   +
    - 133 + + 380 +
    - - - for _, element := range order[blocks[i].BlockHash] { +   + func TestErrorEtherScanPrice(t *testing.T) {
    - 134 + + 381 +
    - - - err := s.processElement(ctx, element, blocks, i, dbTx) +   + // Set up testing environment
    - 135 + + 382 +
    - - if err != nil { + etherman, _, _, _, _ := newTestingEnv()
    - 136 + + 383 +
    - - - return err +   + etherscanM := new(etherscanMock)
    - 137 + + 384 +
    - - - } +   + ethGasStationM := new(ethGasStationMock)
    - 138 + + 385 +
    - - - } +   + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 139 + +
    @@ -393,7 +404,7 @@
    +
    + 393 +
    - - - log.Debug("Checking FlushID to commit L1 data to db") +   +
    - 140 + + 394 +
    - - - err = s.flushIdManager.CheckFlushID(dbTx) +   + func TestGetForks(t *testing.T) {
    - 141 + + 395 +
    - - - if err != nil { +   + // Set up testing environment
    - 142 + + 396 +
    - - log.Errorf("error checking flushID. BlockNumber: %d, Error: %v", blocks[i].BlockNumber, err) + etherman, _, _, _, _ := newTestingEnv()
    - 143 + + 397 +
    - - - return err +   + ctx := context.Background()
    - 144 + + 398 +
    - - - } +   + forks, err := etherman.GetForks(ctx, 0, 132)
    - 145 + + 399 +
    - - - return nil +   + require.NoError(t, err) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - -
    +
     
    - 146 + + 38 +
    - - +   }
    - 147 + + 39 +
    - - +  
    - 148 + + 40 +
    - - - func (s *BlockRangeProcess) processElement(ctx context.Context, element etherman.Order, blocks []etherman.Block, i int, dbTx pgx.Tx) error { +   + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - 149 + + 41 +
    - - - batchSequence := l1event_orders.GetSequenceFromL1EventOrder(element.Name, &blocks[i], element.Pos) + + + func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock, st *stateMock) {
    - 150 + + 42 +
    - - - var forkId uint64 +   + privateKey, err := crypto.GenerateKey()
    - 151 + + 43 +
    - - - if batchSequence != nil { +   + if err != nil {
    - 152 + + 44 +
    - - - forkId = s.state.GetForkIDByBatchNumber(batchSequence.FromBatchNumber) +   + log.Fatal(err)
    - 153 + +
     
    +
    + 47 +
    - - - log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) +   + if err != nil {
    - 154 + + 48 +
    - - - } else { +   + log.Fatal(err)
    - 155 + + 49 +
    - - - forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) +   + }
    - 156 + + 50 +
    - - - log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, "forkId: ", forkId) + + + da = newDaMock(t)
    - 157 + + 51 +
    - - - } + + + st = newStateMock(t)
    - 158 + + 52 +
    - - - forkIdTyped := actions.ForkIdType(forkId) + + + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da, st)
    - 159 + + 53 +
    - - -
    +   + if err != nil {
    - 160 + + 54 +
    - - - err := s.l1EventProcessors.Process(ctx, forkIdTyped, element, &blocks[i], dbTx) +   + log.Fatal(err)
    - 161 + + 55 +
    - - - if err != nil { +   + }
    - 162 + +
     
    +
    + 57 +
    - - - log.Error("error l1EventProcessors.Process: ", err) +   + if err != nil {
    - 163 + + 58 +
    - - - return err +   + log.Fatal(err)
    - 164 + + 59 +
    - - +   }
    - 165 + + 60 +
    - - - return nil + + + return ethman, ethBackend, auth, polAddr, br, da, st
    - 166 + + 61 +
    - - +   }
    -
    -
    -
    -
    - - - - - - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - @@ -295031,414 +65705,463 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
     
    -
    - + + 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 @@
    @@ -295605,21 +66328,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - RENAMED - -
    -
    @@ -295627,1566 +66335,1488 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -79,8 +79,6 @@
    +
     
    - 79 + + 1 +
    -   - syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor + + + package etherman
    - 80 + + 2 +
    -   - halter syncinterfaces.CriticalErrorHandler + + +
    - 81 + + 3 +
    -   - asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator + + + import (
    - 82 + + 4 +
    - - - blockRangeProcessor syncinterfaces.BlockRangeProcessor + + + "context"
    - 83 + + 5 +
    - - - syncPreRollup syncinterfaces.SyncPreRollupSyncer + + +
    - 84 + + 6 +
    -   - } + + + "github.com/ethereum/go-ethereum/common"
    - 85 + + 7 +
    -   -
    + + + "github.com/jackc/pgx/v4"
    - 86 + + 8 +
    -   - // NewSynchronizer creates and initializes an instance of Synchronizer + + + )
    -
    @@ -168,9 +166,9 @@
    -
    - 168 + + 9 +
    -   + +
    - 169 + + 10 +
    -   - syncTrustedStateEtrog := l2_shared.NewTrustedBatchesRetrieve(executor, zkEVMClient, res.state, *sync, *l2_shared.NewTrustedStateManager(syncCommon.DefaultTimeProvider{}, timeOfLiveBatchOnCache)) + + + type dataAvailabilityProvider interface {
    - 170 + + 11 +
    -   - res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{ + + + GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
    - 171 + + 12 +
    - - - uint64(state.FORKID_ETROG): syncTrustedStateEtrog, + + + }
    - 172 + + 13 +
    - - - uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog, + + +
    - 173 + + 14 +
    - - - uint64(state.FORKID_ELDERBERRY_2): syncTrustedStateEtrog, + + + type stateProvider interface {
    - 174 + + 15 +
    -   - }, res.state) + + + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 175 + + 16 +
    -   - } + + + }
    - 176 - -
    -   - var l1checkerL2Blocks *actions.CheckL2BlockHash +
    +
    - - +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + +
    -
    @@ -185,7 +183,7 @@
    +
    @@ -23,7 +24,7 @@
    - 185 + 23
      - log.Errorf("error getting last L2Block number from state. Error: %v", err) +
    - 186 + 24
      - return nil, err + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - 187 + 25
      - } + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - 188 + 26
    - - l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberModulus) + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *polygonzkevmbridge.Polygonzkevmbridge, error) {
    - 189 + 27
      - if err != nil { + if auth == nil {
    - 190 + 28
      - log.Error("error creating new instance of checkL2BlockHash. Error: ", err) + // read only client
    - 191 + 29
      - return nil, err + return &Client{}, nil, common.Address{}, nil, nil
    -
    @@ -196,8 +194,6 @@
    +
    @@ -37,8 +38,26 @@
    - 196 + 37
      - } + },
    - 197 + 38
      -
    + }
    - 198 + 39
      - 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) + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - 201 + + -
    +
    +
      - switch cfg.L1SynchronizationMode { +
    - 202 + 40
      - case ParallelMode: + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 203 + 41
      - 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 + + 42 +
    - - - log.Info("State is empty, verifying genesis block") +   + // Deploy contracts
    - 298 + + 43 +
    - - - valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber) +   + const polDecimalPlaces = 18
    - 299 + + 44 +
    - - - if err != nil { +   + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - 300 - -
    - - - log.Error("error checking genesis block number. Error: ", err) -
    +
    +
    @@ -102,7 +121,7 @@
    - 301 + + 102 +
    - - - return nil, err +   + log.Error("error: ", err)
    - 302 + + 103 +
    - - - } else if !valid { +   + return nil, nil, common.Address{}, nil, err
    - 303 + + 104 +
    - - - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +   + }
    - 304 + + 105 +
    - - return nil, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") + br, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
    - 305 + + 106 +
    - - - } +   + if err != nil {
    - 306 + + 107 +
    - - - // Sync pre genesis rollup events +   + log.Error("error: ", err)
    - 307 + + 108 +
    - - - s.syncPreRollup.(*SyncPreRollup).GenesisBlockNumber = s.genesis.BlockNumber +   + return nil, nil, common.Address{}, nil, err
    - 308 + +
    @@ -182,6 +201,11 @@
    +
    + 182 +
    - - - err = s.syncPreRollup.SynchronizePreGenesisRollupEvents(s.ctx) +   + return nil, nil, common.Address{}, nil, err
    - 309 + + 183 +
    - - - if err != nil { +   + }
    - 310 + + 184 +
    - - - 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 + + 185 +
    - - - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err) +   + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - 317 + + 186 +
    - - - return nil, err +   + if err != nil {
    - 318 + + 187 +
    - - - } +   + log.Error("error: ", err)
    - 319 + +
    @@ -199,6 +223,8 @@
    +
    + 199 +
    - - - lastEthBlockSynced := &state.Block{ +   + SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
    - 320 + + 200 +
    - - - BlockNumber: header.Number.Uint64(), +   + auth: map[common.Address]bind.TransactOpts{},
    - 321 + + 201 +
    - - - BlockHash: header.Hash(), +   + cfg: cfg,
    - 322 + + -
    - - - ParentHash: header.ParentHash, +
    +
    +   +
    - 323 + + -
    - - - ReceivedAt: time.Unix(int64(header.Time), 0), +
    +
    +   +
    - 324 + + 202 +
    - - +   }
    - 325 + + 203 +
    - - - dbTx, err := s.state.BeginStateTransaction(s.ctx) +   + err = c.AddOrReplaceAuth(*auth)
    - 326 + + 204 +
    - - +   if err != nil {
    - 327 - -
    - - - log.Errorf("error creating db transaction to get latest block. Error: %v", err) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + + +
    +
     
    - 328 + + 24 +
    - - - return nil, err +   +
    - 329 + + 25 +
    - - - } +   + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - 330 + + 26 +
    - - - genesisRoot, err := s.state.SetGenesis(s.ctx, *lastEthBlockSynced, s.genesis, stateMetrics.SynchronizerCallerLabel, dbTx) +   + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - 331 + + 27 +
    - - - if err != nil { + + + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider, st stateProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) {
    - 332 + + 28 +
    - - - log.Error("error setting genesis: ", err) +   + if auth == nil {
    - 333 + + 29 +
    - - - return nil, rollback(s.ctx, dbTx, err) +   + // read only client
    - 334 + + 30 +
    - - - } +   + return &Client{}, nil, common.Address{}, nil, nil
    - 335 - -
    - - - err = s.RequestAndProcessRollupGenesisBlock(dbTx, lastEthBlockSynced) -
    +
    +
     
    - 336 + + 38 +
    - - - if err != nil { +   + },
    - 337 + + 39 +
    - - - log.Error("error processing Rollup genesis block: ", err) +   + }
    - 338 + + 40 +
    - - - return nil, rollback(s.ctx, dbTx, err) +   + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - 339 + + 41 +
    - - - } + + + // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 340 + + 42 +
    - - -
    +   + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 341 + + 43 +
    - - - if genesisRoot != s.genesis.Root { +   +
    - 342 + + 44 +
    - - - log.Errorf("Calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String()) + + + // DAC Setup
    - 343 + + 45 +
    - - - return nil, rollback(s.ctx, dbTx, err) + + + daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
    - 344 + + 46 +
    - - - } + + + if err != nil {
    - 345 + + 47 +
    - - - // Waiting for the flushID to be stored + + + return nil, nil, common.Address{}, nil, err
    - 346 + + 48 +
    - - - err = s.checkFlushID(dbTx) + + + }
    - 347 + + 49 +
    - - - if err != nil { + + + client.Commit()
    - 348 + + 50 +
    - - - log.Error("error checking genesis flushID: ", err) + + + _, err = da.Initialize(auth)
    - 349 + + 51 +
    - - - return nil, rollback(s.ctx, dbTx, err) + + + if err != nil {
    - 350 + + 52 +
    - - - } + + + return nil, nil, common.Address{}, nil, err
    - 351 + + 53 +
    - - - if err := dbTx.Commit(s.ctx); err != nil { + + + }
    - 352 + + 54 +
    - - - log.Errorf("error genesis committing dbTx, err: %v", err) + + + client.Commit()
    - 353 + + 55 +
    - - - return nil, rollback(s.ctx, dbTx, err) + + + _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
    - 354 + + 56 +
    - - - } + + + if err != nil {
    - 355 + + 57 +
    - - - log.Info("Genesis root matches! Stored genesis blocks.") + + + return nil, nil, common.Address{}, nil, err
    - 356 + + 58 +
    - - - return lastEthBlockSynced, nil + + + }
    - 357 + + 59 +
    - - - } + + + client.Commit()
    - 358 + + 60 +
    - - + +
    - 359 + 61
      - // Sync function will read the last state synced and will continue from that point. + // Deploy contracts
    - 360 + 62
      - // Sync() will read blockchain events to detect rollup updates + const polDecimalPlaces = 18
    - 361 + + 63 +
    - - - // 1. Check if genesisProcess is done +   + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - 362 - -
    - - - // 2. If not, process genesis -
    +
    +
     
    - 363 + + 121 +
    - - - // 2.1 -There are blocks previous to the genesis block? -> go on with process of InfoRootTree +   + log.Error("error: ", err)
    - 364 + + 122 +
    - - - // 2.2 -There are no blocks previous to the genesis block? -> get ETROG Upgrade block and start there to process of InfoRootTree +   + return nil, nil, common.Address{}, nil, err
    - 365 + + 123 +
    - - - // 3. Setup genesis data +   + }
    - 366 + + 124 +
    - - - // 4. Start sync as usual + + + br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
    - 367 + 125
      - func (s *ClientSynchronizer) Sync() error { + if err != nil {
    - 368 + 126
      - startInitialization := time.Now() + log.Error("error: ", err)
    - 369 + 127
      - // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block + return nil, nil, common.Address{}, nil, err
    -
    @@ -378,19 +291,92 @@
    +
     
    - 378 + 201
      - log.Errorf("error creating db transaction to get latest block. Error: %v", err) + return nil, nil, common.Address{}, nil, err
    - 379 + 202
      - return err + }
    - 380 + 203
      - } +
    - 381 + + 204 +
    - - - genesisDone, lastEthBlockSynced, err := s.isGenesisProcessed(s.ctx, dbTx) + + + _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr)
    - 382 + + 205 +
    -   + + if err != nil {
    - 383 + + 206 +
    - - - log.Errorf("error checking if genesis is processed. Error: %v", err) + + + log.Error("error: ", err)
    - 384 + + 207 +
    - - - return err + + + return nil, nil, common.Address{}, nil, err
    - 385 + + 208 +
    - - - } + + + }
    - 386 + + 209 +
    - - - if !genesisDone { +   + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - 387 + + 210 +
    - - - lastEthBlockSynced, err = s.processGenesis() +   + if err != nil {
    - 388 + + 211 +
    - - - if err != nil { +   + log.Error("error: ", err)
    - 389 - -
    - - - log.Errorf("error processing genesis. Error: %v", err) -
    +
    +
     
    - + + 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 → .}/event/event.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -297220,163 +67850,196 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -42,6 +42,9 @@
    - + + 42 -
    +
    +
      -
    + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - + + 43 -
    +
    +
      -
    + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - + + 44 -
    +
    +
      -
    + EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
    - + + 45 -
    +
    +
      -
    + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - + + 46 -
    +
    +
      -
    + EventID_NodeOOC EventID = "NODE OOC"
    - + + 47 -
    +
    +
      -
    + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - + + 42 -
    +
    +
      -
    + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - + + 43 -
    +
    +
      -
    + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - + + 44 -
    +
    +
      -
    + 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 -
    -   +
    +
    + +
    - + + 48 -
    +
    +
      -
    + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - + + 49 -
    +
    +
      -
    + EventID_NodeOOC EventID = "NODE OOC"
    - + + 50 -
    +
    +
      -
    + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -297409,374 +68072,432 @@

    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 -
    +
    +
      -
    + 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 + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -297790,422 +68511,432 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + - - - - - - + + +
    +
    @@ -22,9 +22,9 @@
    - + + 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.17.0
    - + + 26 -
    +
    +
      -
    + github.com/stretchr/testify v1.8.4
    - + + 27 -
    -   -
    +
    +
    + - + github.com/umbracle/ethgo v0.1.3
    - + + 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,7 +45,7 @@
    -
    +
    + 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.10.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,12 +63,12 @@
    -
    +
    + 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.1.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.6.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,6 +101,7 @@
    -
    +
    + 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/karrick/godirwalk v1.17.0 // indirect
    - + + 105 -
    +
    +
      -
    + github.com/kevinburke/ssh_config v1.2.0 // indirect
    - + + 106 -
    +
    +
      -
    + github.com/klauspost/compress v1.17.0 // indirect
    +
    @@ -116,6 +117,7 @@
    +
    - 390 + 116
      - return err + github.com/mattn/go-isatty v0.0.20 // indirect
    - 391 + 117
      - } + github.com/mattn/go-runewidth v0.0.13 // indirect
    - 392 + 118
      - } + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
    - 393 + + -
    - - +
    +
    +  
    - 394 + 119
      - initBatchNumber, err := s.state.GetLastBatchNumber(s.ctx, dbTx) + github.com/mitchellh/pointerstructure v1.2.0 // indirect
    - 395 + 120
      - if err != nil { + github.com/mmcloughlin/addchain v0.4.0 // indirect
    - 396 + 121
      - log.Error("error getting latest batchNumber synced. Error: ", err) + github.com/olekukonko/tablewriter v0.0.5 // indirect
    -
    @@ -622,7 +608,7 @@
    +
    @@ -128,14 +130,14 @@
    - 622 + 128
      -
    + github.com/rogpeppe/go-internal v1.11.0 // indirect
    - 623 + 129
      - for { + github.com/rs/cors v1.7.0 // indirect
    - 624 + 130
      - if toBlock > lastKnownBlock.Uint64() { + github.com/russross/blackfriday/v2 v2.1.0 // indirect
    - 625 + 131
    - - log.Debug("Setting toBlock to the lastKnownBlock: ", lastKnownBlock) + github.com/sagikazarmark/locafero v0.3.0 // indirect
    - 626 + 132
      - toBlock = lastKnownBlock.Uint64() + github.com/sagikazarmark/slog-shim v0.1.0 // indirect
    - 627 + 133
      - } + github.com/sergi/go-diff v1.2.0 // indirect
    - 628 + 134
      - if fromBlock > toBlock { + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
    -
    @@ -690,7 +676,7 @@
    -
    - 690 + 135
      - } + github.com/sirupsen/logrus v1.9.0 // indirect
    - 691 + 136
      -
    + github.com/skeema/knownhosts v1.2.1 // indirect
    - 692 + 137
      - start = time.Now() + github.com/sourcegraph/conc v0.3.0 // indirect
    - 693 + 138
    - - err = s.blockRangeProcessor.ProcessBlockRange(s.ctx, blocks, order) + github.com/spf13/cast v1.5.1 // indirect
    - 694 + 139
      - metrics.ProcessL1DataTime(time.Since(start)) + github.com/spf13/pflag v1.0.5 // indirect
    - 695 + 140
      - if err != nil { + github.com/status-im/keycard-go v0.2.0 // indirect
    - 696 + 141
      - return lastEthBlockSynced, err + github.com/stretchr/objx v0.5.0 // indirect
    +
    +
    +
    +
    + + + - - + + + - - -
    -
    @@ -1013,7 +999,7 @@
    +
     
    - 1013 + 22
      - log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) + github.com/prometheus/common v0.45.0
    - 1014 + 23
      -
    + github.com/rubenv/sql-migrate v1.6.1
    - 1015 + 24
      - // Compare hashes + github.com/spf13/afero v1.11.0
    - 1016 + + 25 +
    - - - if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.BlockNumber { + + + github.com/spf13/viper v1.18.2
    - 1017 + 26
      - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) + github.com/stretchr/testify v1.8.4 +
    +
    + 27 + +
    + + + github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0
    - 1018 + 28
      - log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) + github.com/urfave/cli/v2 v2.26.0
    - 1019 + 29
      - log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) -
    -
    -
    + go.uber.org/zap v1.26.0
    -
    -
    - - - - - + + + - - - - @@ -298215,92 +68946,122 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + @@ -298310,72 +69071,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -298385,82 +69146,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - @@ -298470,138 +69221,172 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + + + - - - - + + +
    -
     
    - 79 + 30
      - syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor + golang.org/x/crypto v0.18.0
    +
     
    +
    - 80 + 45
      - halter syncinterfaces.CriticalErrorHandler + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
    - 81 + 46
      - asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator + 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
    - 82 + 49
      - } + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
    - 83 + 50
      -
    + github.com/buger/jsonparser v1.1.1 // indirect
    - 84 + 51
      - // NewSynchronizer creates and initializes an instance of Synchronizer + github.com/cespare/xxhash/v2 v2.2.0 // indirect
    - 166 + 63
      -
    + github.com/cyphar/filepath-securejoin v0.2.4 // indirect
    - 167 + 64
      - syncTrustedStateEtrog := l2_shared.NewTrustedBatchesRetrieve(executor, zkEVMClient, res.state, *sync, *l2_shared.NewTrustedStateManager(syncCommon.DefaultTimeProvider{}, timeOfLiveBatchOnCache)) + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
    - 168 + 65
      - res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{ + github.com/deckarep/golang-set/v2 v2.1.0 // indirect
    - 169 + 66
    + - uint64(state.FORKID_ETROG): syncTrustedStateEtrog, + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
    - 170 + + 67 +
    - + - uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog, +   + 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
    - 171 + 71
    + - uint64(state.FORKID_9): syncTrustedStateEtrog, + github.com/fsnotify/fsnotify v1.7.0 // indirect
    - 172 + 72
      - }, res.state) + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
    - 173 + 73
      - } + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
    - 174 + 74
      - var l1checkerL2Blocks *actions.CheckL2BlockHash + github.com/getsentry/sentry-go v0.18.0 // indirect
    - 183 + 101
      - log.Errorf("error getting last L2Block number from state. Error: %v", err) + github.com/jackc/puddle v1.3.0 // indirect
    - 184 + 102
      - return nil, err + github.com/jackpal/go-nat-pmp v1.0.2 // indirect
    - 185 + 103
      - } + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    - 186 + + 104 +
    + - l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) + github.com/jmoiron/sqlx v1.2.0 // indirect
    - 187 + 105
      - if err != nil { + github.com/karrick/godirwalk v1.17.0 // indirect
    - 188 + 106
      - log.Error("error creating new instance of checkL2BlockHash. Error: ", err) + github.com/kevinburke/ssh_config v1.2.0 // indirect
    - 189 + 107
      - return nil, err + github.com/klauspost/compress v1.17.0 // indirect
    - 194 + 117
      - } + github.com/mattn/go-isatty v0.0.20 // indirect
    - 195 + 118
      -
    + github.com/mattn/go-runewidth v0.0.13 // indirect
    - 196 + 119
      - res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks) -
    -
    - - -
    -   -
    + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
    - + + 120 -
    -   -
    +
    +
    + + + github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect
    - 197 + 121
      - switch cfg.L1SynchronizationMode { + github.com/mitchellh/pointerstructure v1.2.0 // indirect
    - 198 + 122
      - case ParallelMode: + github.com/mmcloughlin/addchain v0.4.0 // indirect
    - 199 + 123
      - log.Info("L1SynchronizationMode is parallel") + github.com/olekukonko/tablewriter v0.0.5 // indirect
    - 228 + 130
      - ApplyAfterNumRollupReceived: cfg.L1ParallelSynchronization.PerformanceWarning.ApplyAfterNumRollupReceived, + github.com/rogpeppe/go-internal v1.11.0 // indirect
    - 229 + 131
      - AceptableInacctivityTime: cfg.L1ParallelSynchronization.PerformanceWarning.AceptableInacctivityTime.Duration, + github.com/rs/cors v1.7.0 // indirect
    - 230 + 132
      - } + github.com/russross/blackfriday/v2 v2.1.0 // indirect
    - 231 + 133
    + - L1DataProcessor := l1_parallel_sync.NewL1RollupInfoConsumer(cfgConsumer, sync, chIncommingRollupInfo) + github.com/sagikazarmark/locafero v0.4.0 // indirect
    - 232 + 134
      -
    + github.com/sagikazarmark/slog-shim v0.1.0 // indirect
    - 233 + 135
      - cfgProducer := l1_parallel_sync.ConfigProducer{ + github.com/sergi/go-diff v1.2.0 // indirect
    - 234 + 136
      - SyncChunkSize: cfg.SyncChunkSize, + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
    -
     
    -
    - 275 + 137
      - return err + github.com/sirupsen/logrus v1.9.0 // indirect
    - 276 + 138
      - } + github.com/skeema/knownhosts v1.2.1 // indirect
    - 277 + 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 +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml + RENAMED + +
    +
    +
    +
    + + + + + - - - - @@ -299424,193 +70209,112 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + +
    +
    @@ -0,0 +1,84 @@
    @@ -299344,23 +70129,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 +
    +
    - - +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -300620,12 +71089,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
     
    - 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 + + 1 +
    + - if err != nil { + # .goreleaser-cdk.yaml
    - 300 + + 2 +
    + - log.Error("error checking genesis block number. Error: ", err) + project_name: cdk-validium-node
    - 301 + + 3 +
    + - return rollback(s.ctx, dbTx, err) +
    - 302 + + 4 +
    + - } else if !valid { + release:
    - 303 + 5
    + - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") + disable: false
    - 304 + 6
    + - 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")) + draft: true
    - 305 + 7
    + - } + prerelease: auto
    - 306 + 8
    @@ -299620,287 +70324,287 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 307 + 9
    + - // Sync events from RollupManager that happen before rollup creation + before:
    - 308 + 10
    + - log.Info("synchronizing events from RollupManager that happen before rollup creation") + hooks:
    - 309 + 11
    + - for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize { + - go mod download
    - 310 + 12
    + - toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1) + - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
    - 311 + 13
    + - blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock) + - packr2
    - 312 + 14
    + - if err != nil { +
    - 313 + 15
    + - log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err) + builds:
    - 314 + 16
    + - rollbackErr := dbTx.Rollback(s.ctx) + - main: ./cmd/
    - 315 + 17
    + - if rollbackErr != nil { + binary: zkevm-node
    - 316 + 18
    + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) + goos:
    - 317 + 19
    + - return rollbackErr + - linux
    - 318 + 20
    + - } + - darwin
    - 319 + 21
    + - return err + goarch:
    - 320 + 22
    + - } + - amd64
    - 321 + 23
    + - err = s.ProcessBlockRange(blocks, order) + - arm64
    - 322 + 24
    + - if err != nil { + env:
    - 323 + 25
    + - log.Error("error processing blocks before the genesis: ", err) + - CGO_ENABLED=0
    - 324 + 26
    + - rollbackErr := dbTx.Rollback(s.ctx) + ldflags:
    - 325 + 27
    + - if rollbackErr != nil { + - -s -w
    - 326 + 28
    + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) + - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }}
    - 327 + 29
    + - return rollbackErr + - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }}
    - 328 + 30
    + - } + - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }}
    - 329 + 31
    + - return err + - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }}
    - 330 + 32
    + - } +
    - 331 + 33
    + - if toBlock == s.genesis.RollupBlockNumber-1 { + archives:
    - 332 + 34
    + - break + - files:
    - 333 + 35
    + - } + - LICENSE
    - 334 + 36
    + - } + - README.md
    - 335 + 37
    @@ -299910,707 +70614,472 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 336 + 38
    + - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber)) + dockers:
    - 337 + 39
    + - if err != nil { + - image_templates:
    - 338 + 40
    + - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err) + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
    - 339 + 41
    + - return rollback(s.ctx, dbTx, err) + dockerfile: Dockerfile.release
    - 340 + 42
    + - } + use: buildx
    - 341 + 43
    + - log.Info("synchronizing rollup creation block") + goos: linux
    - 342 + 44
    + - lastEthBlockSynced = &state.Block{ + goarch: amd64
    - 343 + 45
    + - BlockNumber: header.Number.Uint64(), + build_flag_templates:
    - 344 + 46
    + - BlockHash: header.Hash(), + - --platform=linux/amd64
    - 345 + 47
    + - ParentHash: header.ParentHash, + - --label=org.opencontainers.image.title={{ .ProjectName }}
    - 346 + 48
    + - ReceivedAt: time.Unix(int64(header.Time), 0), + - --label=org.opencontainers.image.description={{ .ProjectName }}
    - 347 + 49
    + - } + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
    - 348 + 50
    + - genesisRoot, err := s.state.SetGenesis(s.ctx, *lastEthBlockSynced, s.genesis, stateMetrics.SynchronizerCallerLabel, dbTx) + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
    - 349 + 51
    + - if err != nil { + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }}
    - 350 + 52
    + - log.Error("error setting genesis: ", err) + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
    - 351 + 53
    + - return rollback(s.ctx, dbTx, err) + - --label=org.opencontainers.image.revision={{ .FullCommit }}
    - 352 + 54
    + - } + skip_push: false
    - 353 + 55
    + - err = s.RequestAndProcessRollupGenesisBlock(dbTx, lastEthBlockSynced) +
    - 354 + 56
    + - if err != nil { + - image_templates:
    - 355 + 57
    + - log.Error("error processing Rollup genesis block: ", err) + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
    - 356 + 58
    + - return rollback(s.ctx, dbTx, err) + dockerfile: Dockerfile.release
    - 357 + 59
    + - } + use: buildx
    - 358 + 60
    + -
    + goos: linux
    - 359 + 61
    + - if genesisRoot != s.genesis.Root { + goarch: arm64
    - 360 + 62
    + - log.Errorf("Calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String()) + build_flag_templates:
    - 361 + 63
    + - return rollback(s.ctx, dbTx, fmt.Errorf("calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String())) + - --platform=linux/arm64
    - 362 + 64
    + - } + - --label=org.opencontainers.image.title={{ .ProjectName }}
    - 363 + 65
    + - // Waiting for the flushID to be stored + - --label=org.opencontainers.image.description={{ .ProjectName }}
    - 364 + 66
    + - err = s.checkFlushID(dbTx) + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
    - 365 + 67
    + - if err != nil { + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
    - 366 + 68
    + - log.Error("error checking genesis flushID: ", err) + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }}
    - 367 + 69
    + - return rollback(s.ctx, dbTx, err) + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
    - 368 + 70
    + - } + - --label=org.opencontainers.image.revision={{ .FullCommit }}
    - 369 + 71
    + - log.Debug("Genesis root matches!") + skip_push: false
    - 370 + 72
    + - } else { +
    - 371 + 73
    + - log.Error("unexpected error getting the latest ethereum block. Error: ", err) + docker_manifests:
    - 372 + 74
    + - rollbackErr := dbTx.Rollback(s.ctx) + - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}
    - 373 + 75
    + - if rollbackErr != nil { + image_templates:
    - 374 + 76
    + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
    - 375 + 77
    + - return rollbackErr + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
    - 376 + 78
    + - } -
    -
    - 377 - -
    -   - return err -
    -
    - 378 - -
    -   - } -
    -
    - 379 - -
    -   - } -
    -
    - - -
    -   -
    -
    -
    - 380 - -
    -   - initBatchNumber, err := s.state.GetLastBatchNumber(s.ctx, dbTx) -
    -
    - 381 - -
    -   - if err != nil { -
    -
    - 382 - -
    -   - log.Error("error getting latest batchNumber synced. Error: ", err) -
    -
    -
     
    -
    - 608 - -
    -   -
    -
    -
    - 609 - -
    -   - for { -
    -
    - 610 - -
    -   - if toBlock > lastKnownBlock.Uint64() { + skip_push: false
    - 611 + + 79 +
    + - log.Debug("Setting toBlock to the lastKnownBlock") -
    -
    - 612 - -
    -   - toBlock = lastKnownBlock.Uint64() -
    -
    - 613 - -
    -   - } -
    -
    - 614 - -
    -   - if fromBlock > toBlock { -
    -
    -
     
    -
    - 676 - -
    -   - } -
    -
    - 677 - -
    -  
    - 678 - -
    -   - start = time.Now() -
    -
    - 679 + + 80 +
    + - err = s.ProcessBlockRange(blocks, order) -
    -
    - 680 - -
    -   - metrics.ProcessL1DataTime(time.Since(start)) -
    -
    - 681 - -
    -   - if err != nil { -
    -
    - 682 - -
    -   - return lastEthBlockSynced, err -
    -
    -
     
    -
    - 999 - -
    -   - log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) -
    -
    - 1000 - -
    -   -
    -
    -
    - 1001 - -
    -   - // Compare hashes + - name_template: 0xpolygon/{{ .ProjectName }}:latest
    - 1002 + + 81 +
    + - if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupBlockNumber { + image_templates:
    - 1003 + + 82 +
    -   - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
    - 1004 + + 83 +
    -   - log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
    - 1005 + + 84 +
    -   - log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) + + + skip_push: false
    -
    @@ -1,122 +0,0 @@
    -
    - 1 - -
    - - - package synchronizer -
    -
    - 2 - -
    - - -
    -
    -
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    +
    @@ -58,6 +58,46 @@
    - 5 + + 58 +
    - - - "errors" +   + return result, nil
    - 6 + + 59 +
    - - - "time" +   + }
    - 7 + + 60 +
    - - +  
    - 8 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 10 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 11 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" -
    -
    - 12 - -
    - - - "github.com/jackc/pgx/v4" -
    -
    - 13 - -
    - - - ) -
    -
    - 14 + + -
    - - +
    +
    +  
    - 15 - -
    - - - const ( -
    -
    - 16 + + -
    - - - pregenesisSyncLogPrefix = "sync pregenesis:" +
    +
    +   +
    - 17 - -
    - - - ) +
    + + +
    +   +
    - 18 + + -
    - - +
    +
    +  
    - 19 + + -
    - - - // SyncPreRollup is the struct for synchronizing pre genesis rollup events. +
    +
    +   +
    - 20 + + -
    - - - // Implements: syncinterfaces.SyncPreRollupSyncer +
    +
    +   +
    - 21 + + -
    - - - type SyncPreRollup struct { +
    +
    +   +
    - 22 + + -
    - - - etherman syncinterfaces.EthermanPreRollup +
    +
    +   +
    - 23 + + -
    - - - state syncinterfaces.StateLastBlockGetter +
    +
    +   +
    - 24 + + -
    - - - blockRangeProcessor syncinterfaces.BlockRangeProcessor +
    +
    +   +
    - 25 + + -
    - - - SyncChunkSize uint64 +
    +
    +   +
    - 26 + + -
    - - - GenesisBlockNumber uint64 +
    +
    +   +
    - 27 + + -
    - - - } +
    +
    +   +
    - 28 + + -
    - - +
    +
    +  
    - 29 + + -
    - - - // NewSyncPreRollup creates a new SyncPreRollup +
    +
    +   +
    - 30 + + -
    - - - func NewSyncPreRollup( +
    +
    +   +
    - 31 + + -
    - - - etherman syncinterfaces.EthermanPreRollup, +
    +
    +   +
    - 32 + + -
    - - - state syncinterfaces.StateLastBlockGetter, +
    +
    +   +
    - 33 + + -
    - - - blockRangeProcessor syncinterfaces.BlockRangeProcessor, +
    +
    +   +
    - 34 + + -
    - - - syncChunkSize uint64, +
    +
    +   +
    - 35 + + -
    - - - genesisBlockNumber uint64, +
    +
    +   +
    - 36 + + -
    - - - ) *SyncPreRollup { +
    +
    +   +
    - 37 + + -
    - - - return &SyncPreRollup{ +
    +
    +   +
    - 38 + + -
    - - - etherman: etherman, +
    +
    +   +
    - 39 + + -
    - - - state: state, +
    +
    +   +
    - 40 + + -
    - - - blockRangeProcessor: blockRangeProcessor, +
    +
    +   +
    - 41 + + -
    - - - SyncChunkSize: syncChunkSize, +
    +
    +   +
    - 42 + + -
    - - - GenesisBlockNumber: genesisBlockNumber, +
    +
    +   +
    - 43 + + -
    - - - } +
    +
    +   +
    - 44 + + -
    - - - } +
    +
    +   +
    - 45 + + -
    - - +
    +
    +  
    - 46 + + -
    - - - // SynchronizePreGenesisRollupEvents sync pre-rollup events +
    +
    +   +
    - 47 + + -
    - - - func (s *SyncPreRollup) SynchronizePreGenesisRollupEvents(ctx context.Context) error { +
    +
    +   +
    - 48 + + -
    - - - // Sync events from RollupManager that happen before rollup creation +
    +
    +   +
    - 49 + + -
    - - - log.Info(pregenesisSyncLogPrefix + "synchronizing events from RollupManager that happen before rollup creation") +
    +
    +   +
    - 50 + + -
    - - - needToUpdate, fromBlock, err := s.getStartingL1Block(ctx, nil) +
    +
    +   +
    - 51 + + -
    - - - if err != nil { +
    +
    +   +
    - 52 + + -
    - - - log.Errorf(pregenesisSyncLogPrefix+"error getting starting L1 block. Error: %v", err) +
    +
    +   +
    - 53 + + -
    - - - return err +
    +
    +   +
    - 54 + + -
    - - - } +
    +
    +   +
    - 55 + + 61 +
    - - - if needToUpdate { +   + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    - 56 + + 62 +
    - - - return s.ProcessL1InfoRootEvents(ctx, fromBlock, s.GenesisBlockNumber-1, s.SyncChunkSize) +   + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    - 57 + + 63 +
    - - - } else { +   + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    + 58 +
    - - - log.Infof(pregenesisSyncLogPrefix+"No need to process blocks before the genesis block %d", s.GenesisBlockNumber) +   + return result, nil
    + 59 +
    - - - return nil +   + }
    + 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 +
    - - - // getStartingL1Block find if need to update and if yes the starting point: + + + func (c *Client) BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    + 64 +
    - - - // bool -> need to process blocks + + + return c.batchesByNumbers(ctx, numbers, "zkevm_getBatchDataByNumbers")
    + 65 +
    - - - // uint64 -> first block to synchronize + + + }
    + 66 +
    - - - // error -> error + + +
    + 67 +
    - - - // 1. First try to get last block on DB, if there are could be fully synced or pending blocks + + + // ForcedBatchesByNumbers returns forced batches data.
    + 68 +
    - - - // 2. If DB is empty the LxLy upgrade block as starting point + + + func (c *Client) ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    + 69 +
    - - - func (s *SyncPreRollup) getStartingL1Block(ctx context.Context, dbTx pgx.Tx) (bool, uint64, error) { + + + return c.batchesByNumbers(ctx, numbers, "zkevm_getForcedBatchDataByNumbers")
    + 70 +
    - - - lastBlock, err := s.state.GetLastBlock(ctx, dbTx) + + + }
    + 71 +
    - - - if err != nil && errors.Is(err, state.ErrStateNotSynchronized) { + + +
    + 72 +
    - - - // No block on DB + + + // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
    + 73 +
    - - - upgradeLxLyBlockNumber, err := s.etherman.GetL1BlockUpgradeLxLy(ctx, s.GenesisBlockNumber) + + + // known batch is returned as a list.
    + 74 +
    - - - if err != nil && errors.Is(err, etherman.ErrNotFound) { + + + func (c *Client) batchesByNumbers(_ context.Context, numbers []*big.Int, method string) ([]*types.BatchData, error) {
    + 75 +
    - - - log.Infof(pregenesisSyncLogPrefix+"LxLy upgrade not detected before genesis block %d, it'll be sync as usual. Nothing to do yet", s.GenesisBlockNumber) + + + batchNumbers := make([]types.BatchNumber, 0, len(numbers))
    + 76 +
    - - - return false, 0, nil + + + for _, n := range numbers {
    + 77 +
    - - - } else if err != nil { + + + batchNumbers = append(batchNumbers, types.BatchNumber(n.Int64()))
    + 78 +
    - - - log.Errorf(pregenesisSyncLogPrefix+"error getting LxLy upgrade block. Error: %v", err) + + + }
    + 79 +
    - - - return false, 0, err + + + if len(batchNumbers) == 0 {
    + 80 +
    - - - } + + + batchNumbers = append(batchNumbers, types.LatestBatchNumber)
    + 81 +
    - - - log.Infof(pregenesisSyncLogPrefix+"No block on DB, starting from LxLy upgrade block %d", upgradeLxLyBlockNumber) + + + }
    + 82 +
    - - - return true, upgradeLxLyBlockNumber, nil + + +
    + 83 +
    - - - } else if err != nil { + + + response, err := JSONRPCCall(c.url, method, &types.BatchFilter{Numbers: batchNumbers})
    + 84 +
    - - - log.Errorf("Error getting last Block on DB err:%v", err) + + + if err != nil {
    + 85 +
    - - - return false, 0, err + + + return nil, err
    + 86 +
    - - + + }
    + 87 +
    - - - if lastBlock.BlockNumber >= s.GenesisBlockNumber-1 { + + +
    + 88 +
    - - - log.Warnf(pregenesisSyncLogPrefix+"Last block processed is %d, which is greater or equal than the previous genesis block %d", lastBlock, s.GenesisBlockNumber) + + + if response.Error != nil {
    + 89 +
    - - - return false, 0, nil + + + return nil, response.Error.RPCError()
    + 90 +
    - - + + }
    + 91 +
    - - - log.Infof(pregenesisSyncLogPrefix+"Continue processing pre-genesis blocks, last block processed on DB is %d", lastBlock.BlockNumber) + + +
    + 92 +
    - - - return true, lastBlock.BlockNumber, nil + + + var result *types.BatchDataResult
    + 93 +
    - - - } + + + err = json.Unmarshal(response.Result, &result)
    + 94 +
    - - -
    + + + if err != nil {
    + 95 +
    - - - // ProcessL1InfoRootEvents processes the L1InfoRoot events for a range for L1 blocks + + + return nil, err
    + 96 +
    - - - func (s *SyncPreRollup) ProcessL1InfoRootEvents(ctx context.Context, fromBlock uint64, toBlock uint64, syncChunkSize uint64) error { + + + }
    + 97 +
    - - - startTime := time.Now() + + +
    + 98 +
    - - - log.Info(pregenesisSyncLogPrefix + "synchronizing L1InfoRoot events") + + + return result.Data, nil
    + 99 +
    - - - log.Infof(pregenesisSyncLogPrefix+"Starting syncing pre genesis LxLy events from block %d to block %d (total %d blocks)", + + + }
    + 100 +
    - - - fromBlock, toBlock, toBlock-fromBlock+1) + + +
    + 101 +
    - - - for i := fromBlock; true; i += syncChunkSize { +   + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    + 102 +
    - - - toBlockReq := min(i+syncChunkSize-1, toBlock) +   + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    + 103 +
    - - - percent := float32(toBlockReq-fromBlock+1) * 100.0 / float32(toBlock-fromBlock+1) // nolint:gomnd +   + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + + + + + + + - - - - + + +
    +
    @@ -927,6 +927,9 @@
    - 104 + + 927 +
    - - - log.Infof(pregenesisSyncLogPrefix+"sync L1InfoTree events from %d to %d percent:%3.1f %% pending_blocks:%d", i, toBlockReq, percent, toBlock-toBlockReq) +   + if e.cfg.SequencerNodeURI != "" {
    - 105 + + 928 +
    - - - blocks, order, err := s.etherman.GetRollupInfoByBlockRangePreviousRollupGenesis(ctx, i, &toBlockReq) +   + return e.relayTxToSequencerNode(input)
    - 106 + + 929 +
    - - - if err != nil { +   + } else {
    - 107 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 930 +
    - - - log.Error(pregenesisSyncLogPrefix+"error getting rollupInfoByBlockRange before rollup genesis: ", err) +   + ip := ""
    - 108 + + 931 +
    - - - return err +   + ips := httpRequest.Header.Get("X-Forwarded-For")
    - 109 + + 932 +
    - - +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + +
    +
     
    +
    + 927 + +
    +   + if e.cfg.SequencerNodeURI != "" { +
    +
    + 928 + +
    +   + return e.relayTxToSequencerNode(input) +
    +
    + 929 + +
    +   + } else { +
    +
    + 930 + +
    + + + if err := checkPolicy(context.Background(), e.pool, input); err != nil { +
    +
    + 931 + +
    + + + return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false) +
    +
    + 932 + +
    + + }
    - 110 + + 933 +
    - - - err = s.blockRangeProcessor.ProcessBlockRange(ctx, blocks, order) +   + ip := ""
    - 111 + + 934 +
    - - - if err != nil { +   + ips := httpRequest.Header.Get("X-Forwarded-For") +
    +
    + 935 + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - -
    +
    @@ -6,6 +6,7 @@
    - 112 + + 6 +
    - - - log.Error(pregenesisSyncLogPrefix+"error processing blocks before the genesis: ", err) +   + "errors"
    - 113 + + 7 +
    - - - return err +   + "fmt"
    - 114 + + 8 +
    - - - } +   + "math/big"
    - 115 + + -
    - - - if toBlockReq == toBlock { +
    +
    +   +
    - 116 + + 9 +
    - - - break +   + "sync"
    - 117 + + 10 +
    - - - } +   + "testing"
    - 118 + + 11 +
    - - - } +   + "time"
    - 119 - -
    - - - elapsedTime := time.Since(startTime) -
    +
    +
    @@ -4574,3 +4575,237 @@
    - 120 + + 4574 +
    - - - log.Infof(pregenesisSyncLogPrefix+"sync L1InfoTree finish: from %d to %d total_block %d done in %s", fromBlock, toBlock, toBlock-fromBlock+1, &elapsedTime) +   + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 121 + + 4575 +
    - - - return nil +   + assert.ElementsMatch(t, []int{16}, results[5])
    - 122 + + 4576 +
    - - +   }
    -
    -
    -
    -
    - - - - - - - -
    -
     
    -
    @@ -303096,938 +73622,235 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,89 +0,0 @@
    -
    - 1 - -
    - - - package synchronizer -
    -
    - 2 + + -
    - - +
    +
    +  
    - 3 - -
    - - - import ( -
    -
    - 4 - -
    - - - "context" -
    -
    - 5 - -
    - - - "testing" -
    -
    - 6 + + -
    - - +
    +
    +  
    - 7 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/etherman" -
    -
    - 8 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 9 - -
    - - - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 10 - -
    - - - mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" -
    -
    - 11 - -
    - - - "github.com/ethereum/go-ethereum/common" -
    -
    - 12 - -
    - - - "github.com/stretchr/testify/mock" -
    -
    - 13 - -
    - - - "github.com/stretchr/testify/require" -
    -
    - 14 - -
    - - - ) -
    -
    - 15 + + -
    - - +
    +
    +  
    - 16 - -
    - - - func TestSyncPreRollupProcessL1InfoRootEventsAskForAllBlocks(t *testing.T) { -
    -
    - 17 - -
    - - - mockProcessor := mock_syncinterfaces.NewBlockRangeProcessor(t) -
    -
    - 18 - -
    - - - mockEtherman := mock_syncinterfaces.NewEthermanFullInterface(t) -
    -
    - 19 - -
    - - - sync := &SyncPreRollup{ -
    -
    - 20 - -
    - - - etherman: mockEtherman, -
    -
    - 21 - -
    - - - blockRangeProcessor: mockProcessor, -
    -
    - 22 - -
    - - - SyncChunkSize: 10, -
    -
    - 23 - -
    - - - GenesisBlockNumber: 1234, -
    -
    - 24 - -
    - - - } -
    -
    - 25 + + -
    - - +
    +
    +  
    - 26 - -
    - - - ctx := context.Background() -
    -
    - 27 - -
    - - - fromBlock := uint64(1) -
    -
    - 28 - -
    - - - toBlock := uint64(31) -
    -
    - 29 - -
    - - - syncChunkSize := uint64(10) -
    -
    - 30 - -
    - - - previousBlockNumber := uint64(1) -
    -
    - 31 - -
    - - - for _, i := range []uint64{10, 20, 30, 31} { -
    -
    - 32 - -
    - - - // Mocking the call to GetRollupInfoByBlockRangePreviousRollupGenesis -
    -
    - 33 - -
    - - - v := i -
    -
    - 34 - -
    - - - mockEtherman.EXPECT().GetRollupInfoByBlockRangePreviousRollupGenesis(ctx, previousBlockNumber, &v). -
    -
    - 35 - -
    - - - Return(getRollupTest()).Once() -
    -
    - 36 - -
    - - - previousBlockNumber = i + 1 -
    -
    - 37 - -
    - - - } -
    -
    - 38 + + -
    - - +
    +
    +  
    - 39 - -
    - - - mockProcessor.EXPECT().ProcessBlockRange(ctx, mock.Anything, mock.Anything).Return(nil).Maybe() -
    -
    - 40 - -
    - - - err := sync.ProcessL1InfoRootEvents(ctx, fromBlock, toBlock, syncChunkSize) -
    -
    - 41 - -
    - - - require.NoError(t, err) -
    -
    - 42 - -
    - - - } -
    -
    - 43 + + -
    - - +
    +
    +  
    - 44 - -
    - - - func getRollupTest() ([]etherman.Block, map[common.Hash][]etherman.Order, error) { -
    -
    - 45 - -
    - - - return nil, nil, nil -
    -
    - 46 - -
    - - - } -
    -
    - 47 + + -
    - - +
    +
    +  
    - 48 - -
    - - - func TestSyncPreRollupGetStartingL1Block(t *testing.T) { -
    -
    - 49 - -
    - - - mockState := mock_syncinterfaces.NewStateFullInterface(t) -
    -
    - 50 - -
    - - - mockEtherman := mock_syncinterfaces.NewEthermanFullInterface(t) -
    -
    - 51 - -
    - - - sync := &SyncPreRollup{ -
    -
    - 52 - -
    - - - state: mockState, -
    -
    - 53 - -
    - - - etherman: mockEtherman, -
    -
    - 54 - -
    - - - GenesisBlockNumber: 1234, -
    -
    - 55 - -
    - - - } -
    -
    - 56 + + -
    - - +
    +
    +  
    - 57 - -
    - - - ctx := context.Background() -
    -
    - 58 + + -
    - - +
    +
    +  
    - 59 - -
    - - - for idx, testCase := range []struct { -
    -
    - 60 - -
    - - - name string -
    -
    - 61 - -
    - - - upgradeLxLyBlockNumber uint64 -
    -
    - 62 - -
    - - - blockNumber uint64 -
    -
    - 63 - -
    - - - expectedError bool -
    -
    - 64 - -
    - - - expectedNeedToUpdate bool -
    -
    - 65 - -
    - - - expectedBlockNumber uint64 -
    -
    - 66 - -
    - - - }{ -
    -
    - 67 - -
    - - - {name: "mid block", upgradeLxLyBlockNumber: 1000, blockNumber: 1001, expectedError: false, expectedNeedToUpdate: true, expectedBlockNumber: 1001}, -
    -
    - 68 - -
    - - - {name: "pre block", upgradeLxLyBlockNumber: 1000, blockNumber: 999, expectedError: false, expectedNeedToUpdate: true, expectedBlockNumber: 999}, -
    -
    - 69 - -
    - - - {name: "same genesis", upgradeLxLyBlockNumber: 1000, blockNumber: sync.GenesisBlockNumber, expectedError: false, expectedNeedToUpdate: false}, -
    -
    - 70 - -
    - - - {name: "genesis-1", upgradeLxLyBlockNumber: 1000, blockNumber: 1233, expectedError: false, expectedNeedToUpdate: false}, -
    -
    - 71 - -
    - - - } { -
    -
    - 72 - -
    - - - log.Info("Running test case ", idx+1) -
    -
    - 73 - -
    - - - block := state.Block{ -
    -
    - 74 - -
    - - - BlockNumber: testCase.blockNumber, -
    -
    - 75 - -
    - - - } -
    -
    - 76 + + -
    - - - mockEtherman.EXPECT().GetL1BlockUpgradeLxLy(ctx, sync.GenesisBlockNumber).Return(testCase.upgradeLxLyBlockNumber, nil).Maybe() +
    +
    +   +
    - 77 + + -
    - - - mockState.EXPECT().GetLastBlock(ctx, mock.Anything).Return(&block, nil).Once() +
    +
    +   +
    - 78 + + -
    - - - needToUpdate, blockNumber, err := sync.getStartingL1Block(ctx, nil) +
    +
    +   +
    - 79 + + -
    - - - if testCase.expectedError { +
    +
    +   +
    - 80 + + -
    - - - require.Error(t, err, testCase.name) +
    +
    +   +
    - 81 + + -
    - - - } else { +
    +
    +   +
    - 82 + + -
    - - - require.NoError(t, err, testCase.name) +
    +
    +   +
    - 83 + + -
    - - - require.Equal(t, testCase.expectedNeedToUpdate, needToUpdate, testCase.name) +
    +
    +   +
    - 84 + + -
    - - - if needToUpdate { +
    +
    +   +
    - 85 + + -
    - - - require.Equal(t, testCase.blockNumber, blockNumber, testCase.name) +
    +
    +   +
    - 86 + + -
    - - - } +
    +
    +   +
    - 87 + + -
    - - - } +
    +
    +   +
    - 88 + + -
    - - - } +
    +
    +   +
    - 89 - -
    - - - } -
    +
    +
    -
    + +
    +   +
    -
    -
    - - - - -
    -
     
    @@ -304924,21 +74747,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - RENAMED - -
    -
    @@ -304946,2650 +74754,2731 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - + + + + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -31,7 +31,6 @@
    +
     
    - 31 + 6
      - ETROG_MODE_FLAG = true + "errors"
    - 32 + 7
      - RETRIEVE_BATCH_FROM_DB_FLAG = true + "fmt"
    - 33 + 8
      - RETRIEVE_BATCH_FROM_CACHE_FLAG = false + "math/big"
    - 34 + + 9 +
    - - - PROCESS_BATCH_SELECTOR_ENABLED = false + + + "strings"
    - 35 + 10
      - ) + "sync"
    - 36 + 11
      -
    + "testing"
    - 37 + 12
      - type mocks struct { + "time"
    -
    @@ -123,7 +122,7 @@
    +
     
    - 123 + 4575
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 124 + 4576
      - func TestForcedBatchEtrog(t *testing.T) { + assert.ElementsMatch(t, []int{16}, results[5])
    - 125 + 4577
      - genesis := state.Genesis{ + }
    - 126 + + 4578 +
    - - - BlockNumber: uint64(0), + + +
    - 127 + + 4579 +
    -   - } + + + func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) {
    - 128 + + 4580 +
    -   - cfg := Config{ + + + // Set up the sender
    - 129 + + 4581 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    -
    @@ -170,7 +169,6 @@
    +
    + 4582 + +
    + + + require.NoError(t, err) +
    - 170 + + 4583 +
    -   - On("GetForkIDByBatchNumber", mock.Anything). + + + allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1))
    - 171 + + 4584 +
    -   - Return(uint64(7), nil). + + + require.NoError(t, err)
    - 172 + + 4585 +
    -   - Maybe() + + +
    - 173 + + 4586 +
    - - -
    + + + disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    - 174 + + 4587 +
    -   - m.State. + + + require.NoError(t, err)
    - 175 + + 4588 +
    -   - On("GetLastBlock", ctx, m.DbTx). + + + disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1))
    - 176 + + 4589 +
    -   - Return(lastBlock0, nil). + + + require.NoError(t, err)
    -
    @@ -226,7 +224,7 @@
    +
    + 4590 + +
    + + + require.NotNil(t, disallowed) +
    - 226 + + 4591 +
    -   - Coinbase: common.HexToAddress("0x222"), + + +
    - 227 + + 4592 +
    -   - SequencerAddr: common.HexToAddress("0x00"), + + + allowedContract := common.HexToAddress("0x1")
    - 228 + + 4593 +
    -   - TxHash: common.HexToHash("0x333"), + + + disallowedContract := common.HexToAddress("0x2")
    - 229 + + 4594 +
    - - - PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ + + +
    - 230 + + 4595 +
    -   - Transactions: []byte{}, + + + senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy")
    - 231 + + 4596 +
    -   - 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}, + + + contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy")
    - 232 + + 4597 +
    -   - ForcedTimestamp: uint64(t.Unix()), + + + deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy")
    -
    @@ -370,6 +368,8 @@
    +
    + 4598 + +
    + + +
    +
    - 370 + + 4599 +
    -   - Return(nil). + + + cfg := getSequencerDefaultConfig()
    - 371 + + 4600 +
    -   - Once() + + + s, m, _ := newMockedServerWithCustomConfig(t, cfg)
    - 372 + + 4601 +
    -   -
    + + + defer s.Stop()
    - + + 4602 -
    -   +
    +
    + +
    - + + 4603 -
    -   -
    +
    +
    + + + type testCase struct {
    - 373 + + 4604 +
    -   - m.State. + + + Name string
    - 374 + + 4605 +
    -   - On("AddAccumulatedInputHash", ctx, sequencedBatch.BatchNumber, common.Hash{}, m.DbTx). + + + Input string
    - 375 + + 4606 +
    -   - Return(nil). + + + ExpectedResult *common.Hash
    -
    @@ -397,7 +397,7 @@
    +
    + 4607 + +
    + + + ExpectedError types.Error +
    - 397 + + 4608 +
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + + + Prepare func(t *testing.T, tc *testCase)
    - 398 + + 4609 +
    -   - func TestSequenceForcedBatchIncaberry(t *testing.T) { + + + SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase)
    - 399 + + 4610 +
    -   - genesis := state.Genesis{ + + + }
    - 400 + + 4611 +
    - - - BlockNumber: uint64(0), + + +
    - 401 + + 4612 +
    -   - } + + + testCases := []testCase{
    - 402 + + 4613 +
    -   - cfg := Config{ + + + {
    - 403 + + 4614 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + Name: "Sender & contract on allow list, accepted",
    -
    @@ -490,7 +490,7 @@
    +
    + 4615 + +
    + + + Prepare: func(t *testing.T, tc *testCase) { +
    - 490 + + 4616 +
    -   - BatchNumber: uint64(2), + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 491 + + 4617 +
    -   - Coinbase: common.HexToAddress("0x222"), + + +
    - 492 + + 4618 +
    -   - TxHash: common.HexToHash("0x333"), + + + signedTx, err := allowed.Signer(allowed.From, tx)
    - 493 + + 4619 +
    - - - PolygonRollupBaseEtrogBatchData: etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + require.NoError(t, err)
    - 494 + + 4620 +
    -   - Transactions: []byte{}, + + +
    - 495 + + 4621 +
    -   - 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}, + + + txBinary, err := signedTx.MarshalBinary()
    - 496 + + 4622 +
    -   - ForcedTimestamp: 1000, //ForcedBatch + + + require.NoError(t, err)
    -
    @@ -659,7 +659,7 @@
    +
    + 4623 + +
    + + +
    +
    - 659 + + 4624 +
    -   + + + rawTx := hex.EncodeToHex(txBinary) +
    +
    + 4625 + +
    + + + require.NoError(t, err) +
    +
    + 4626 + +
    + +
    - 660 + + 4627 +
    -   - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { + + + tc.Input = rawTx
    - 661 + + 4628 +
    -   - genesis := state.Genesis{ + + + expectedHash := signedTx.Hash()
    - 662 + + 4629 +
    - - - BlockNumber: uint64(123456), + + + tc.ExpectedResult = &expectedHash
    - 663 + + 4630 +
    -   - } + + + tc.ExpectedError = nil
    - 664 + + 4631 +
    -   - cfg := Config{ + + + },
    - 665 + + 4632 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    -
    @@ -761,11 +761,9 @@
    +
    + 4633 + +
    + + + m.Pool. +
    - 761 + + 4634 +
    -   - transactions := []types.TransactionOrHash{} + + + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - 762 + + 4635 +
    -   - for nBlock := 0; nBlock < howManyBlocks; nBlock++ { + + + Return(nil).
    - 763 + + 4636 +
    -   - block := state.L2BlockRaw{ + + + Once()
    - 764 + + 4637 +
    - - - ChangeL2BlockHeader: state.ChangeL2BlockHeader{ + + + m.Pool.
    - 765 + + 4638 +
    - - - DeltaTimestamp: 123, + + + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - 766 + + 4639 +
    - - - IndexL1InfoTree: 456, + + + Return(true, nil).
    - 767 + + 4640 +
    - - + + + Once() +
    +
    + 4641 + +
    + + + m.Pool. +
    +
    + 4642 + +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, allowed.From). +
    +
    + 4643 + +
    + + + Return(true, nil). +
    +
    + 4644 + +
    + + + Once() +
    +
    + 4645 + +
    + + },
    - 768 + + 4646 +
    - - - Transactions: []state.L2TxRaw{}, + + + },
    - 769 + + 4647 +
    -   - } + + + {
    - 770 + + 4648 +
    -   - for i := 0; i < howManyTx; i++ { + + + Name: "Contract not on allow list, rejected",
    - 771 + + 4649 +
    -   - tx := createTransaction(uint64(i + 1)) + + + Prepare: func(t *testing.T, tc *testCase) {
    -
    @@ -925,7 +923,7 @@
    +
    + 4650 + +
    + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +
    - 925 + + 4651 +
    -   + +
    - 926 + + 4652 +
    -   - func TestReorg(t *testing.T) { + + + signedTx, err := allowed.Signer(allowed.From, tx)
    - 927 + + 4653 +
    -   - genesis := state.Genesis{ + + + require.NoError(t, err)
    - 928 + + 4654 +
    - - - BlockNumber: uint64(0), + + +
    - 929 + + 4655 +
    -   - } + + + txBinary, err := signedTx.MarshalBinary()
    - 930 + + 4656 +
    -   - cfg := Config{ + + + require.NoError(t, err)
    - 931 + + 4657 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + +
    -
    @@ -1245,7 +1243,7 @@
    +
    + 4658 + +
    + + + rawTx := hex.EncodeToHex(txBinary) +
    - 1245 + + 4659 +
    -   -
    + + + require.NoError(t, err)
    - 1246 + + 4660 +
    -   - func TestLatestSyncedBlockEmpty(t *testing.T) { + + +
    - 1247 + + 4661 +
    -   - genesis := state.Genesis{ + + + tc.Input = rawTx
    - 1248 + + 4662 +
    - - - BlockNumber: uint64(0), + + + tc.ExpectedResult = nil
    - 1249 + + 4663 +
    -   - } + + + tc.ExpectedError = contractDenied
    - 1250 + + 4664 +
    -   - cfg := Config{ + + + },
    - 1251 + + 4665 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    -
    @@ -1459,7 +1457,7 @@
    +
    + 4666 + +
    + + + m.Pool. +
    - 1459 + + 4667 +
    -   -
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    - 1460 + + 4668 +
    -   - func TestRegularReorg(t *testing.T) { + + + Return(false, contractDenied).
    - 1461 + + 4669 +
    -   - genesis := state.Genesis{ + + + Once()
    - 1462 + + 4670 +
    - - - BlockNumber: uint64(0), + + + },
    - 1463 + + 4671 +
    -   - } + + + },
    - 1464 + + 4672 +
    -   - cfg := Config{ + + + {
    - 1465 + + 4673 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + Name: "Sender not on allow list, rejected",
    -
    @@ -1741,7 +1739,7 @@
    +
    + 4674 + +
    + + + Prepare: func(t *testing.T, tc *testCase) { +
    - 1741 + + 4675 +
    -   -
    + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 1742 + + 4676 +
    -   - func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { + + +
    - 1743 + + 4677 +
    -   - genesis := state.Genesis{ + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - 1744 + + 4678 +
    - - - BlockNumber: uint64(0), + + + require.NoError(t, err)
    - 1745 + + 4679 +
    -   - } + + +
    - 1746 + + 4680 +
    -   - cfg := Config{ + + + txBinary, err := signedTx.MarshalBinary()
    - 1747 + + 4681 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + require.NoError(t, err)
    -
    @@ -2017,13 +2015,16 @@
    -
    - 2017 + + 4682 +
    -   + +
    - 2018 + + 4683 +
    -   - func TestCallFromEmptyBlockAndReorg(t *testing.T) { + + + rawTx := hex.EncodeToHex(txBinary)
    - 2019 + + 4684 +
    -   - genesis := state.Genesis{ + + + require.NoError(t, err)
    - 2020 + + 4685 +
    - - - BlockNumber: uint64(0), + + +
    - 2021 + + 4686 +
    -   - } + + + tc.Input = rawTx
    - 2022 + + 4687 +
    -   - cfg := Config{ + + + tc.ExpectedResult = nil
    - 2023 + + 4688 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + tc.ExpectedError = senderDenied
    - 2024 + + 4689 +
    -   - SyncChunkSize: 3, + + + },
    - 2025 + + 4690 +
    -   - L1SynchronizationMode: SequentialMode, + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 2026 + + 4691 +
    -   - SyncBlockProtection: "latest", + + + m.Pool.
    - + + 4692 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - + + 4693 -
    -   -
    +
    +
    + + + Return(true, nil).
    - + + 4694 -
    -   -
    +
    +
    + + + Once()
    - 2027 + + 4695 +
    -   - } + + + m.Pool.
    - 2028 + + 4696 +
    -   -
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From).
    - 2029 + + 4697 +
    -   - m := mocks{ + + + Return(false, senderDenied).
    -
    @@ -2129,6 +2130,11 @@
    +
    + 4698 + +
    + + + Once() +
    - 2129 + + 4699 +
    -   - Return(ethHeader2bis, nil). + + + },
    - 2130 + + 4700 +
    -   - Once() + + + },
    - 2131 + + 4701 +
    -   -
    + + + {
    - + + 4702 -
    -   -
    +
    +
    + + + Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility
    - + + 4703 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 4704 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 4705 -
    -   +
    +
    + +
    - + + 4706 -
    -   -
    +
    +
    + + + txBinary, err := tx.MarshalBinary()
    - 2132 + + 4707 +
    -   - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + + + require.NoError(t, err)
    - 2133 + + 4708 +
    -   + +
    - 2134 + + 4709 +
    -   - ethermanBlock0 := etherman.Block{ -
    -
    -
    + + + rawTx := hex.EncodeToHex(txBinary)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + +
    -
     
    - 31 + + 4710 +
    -   - ETROG_MODE_FLAG = true + + + require.NoError(t, err)
    - 32 + + 4711 +
    -   - RETRIEVE_BATCH_FROM_DB_FLAG = true + + +
    - 33 + + 4712 +
    -   - RETRIEVE_BATCH_FROM_CACHE_FLAG = false + + + tc.Input = rawTx
    - + + 4713 -
    -   -
    +
    +
    + + + expectedHash := tx.Hash()
    - 34 + + 4714 +
    -   - ) + + + tc.ExpectedResult = &expectedHash
    - 35 + + 4715 +
    -   -
    + + + tc.ExpectedError = nil
    - 36 + + 4716 +
    -   - type mocks struct { + + + },
    -
     
    -
    - 122 + + 4717 +
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 123 + + 4718 +
    -   - func TestForcedBatchEtrog(t *testing.T) { + + + m.Pool.
    - 124 + + 4719 +
    -   - genesis := state.Genesis{ + + + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - 125 + + 4720 +
    + - RollupBlockNumber: uint64(123456), + Return(nil).
    - 126 + + 4721 +
    -   - } + + + Once()
    - 127 + + 4722 +
    -   - cfg := Config{ + + + // policy does not reject this case for backward compat
    - 128 + + 4723 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + },
    -
     
    -
    - 169 + + 4724 +
    -   - On("GetForkIDByBatchNumber", mock.Anything). + + + },
    - 170 + + 4725 +
    -   - Return(uint64(7), nil). + + + {
    - 171 + + 4726 +
    -   - Maybe() + + + Name: "Unsigned tx with disallowed contract, rejected",
    - + + 4727 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - 172 + + 4728 +
    -   - m.State. + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 173 + + 4729 +
    -   - On("GetLastBlock", ctx, m.DbTx). + + +
    - 174 + + 4730 +
    -   - Return(lastBlock0, nil). + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    -
     
    -
    - 224 + + 4731 +
    -   - Coinbase: common.HexToAddress("0x222"), + + + require.NoError(t, err)
    - 225 + + 4732 +
    -   - SequencerAddr: common.HexToAddress("0x00"), + + +
    - 226 + + 4733 +
    -   - TxHash: common.HexToHash("0x333"), + + + txBinary, err := signedTx.MarshalBinary()
    - 227 + + 4734 +
    + - PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{ + require.NoError(t, err)
    - 228 + + 4735 +
    -   - Transactions: []byte{}, + + +
    - 229 + + 4736 +
    -   - 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}, + + + rawTx := hex.EncodeToHex(txBinary)
    - 230 + + 4737 +
    -   - ForcedTimestamp: uint64(t.Unix()), + + + require.NoError(t, err)
    -
     
    -
    - 368 + + 4738 +
    -   - Return(nil). + + +
    - 369 + + 4739 +
    -   - Once() + + + tc.Input = rawTx
    - 370 + + 4740 +
    -   -
    + + + tc.ExpectedResult = nil
    - 371 + 4741
    + - m.State.EXPECT().UpdateBatchTimestamp(ctx, sequencedBatch.BatchNumber, fb[0].ForcedAt, m.DbTx).Return(nil) + tc.ExpectedError = contractDenied
    - 372 + 4742
    + -
    + },
    - 373 + + 4743 +
    -   - m.State. + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 374 + + 4744 +
    -   - On("AddAccumulatedInputHash", ctx, sequencedBatch.BatchNumber, common.Hash{}, m.DbTx). + + + m.Pool.
    - 375 + + 4745 +
    -   - Return(nil). + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    -
     
    -
    - 397 + + 4746 +
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + + + Return(false, contractDenied).
    - 398 + + 4747 +
    -   - func TestSequenceForcedBatchIncaberry(t *testing.T) { + + + Once()
    - 399 + + 4748 +
    -   - genesis := state.Genesis{ + + + },
    - 400 + + 4749 +
    + - RollupBlockNumber: uint64(123456), + },
    - 401 + + 4750 +
    -   - } + + + {
    - 402 + + 4751 +
    -   - cfg := Config{ + + + Name: "Send invalid tx input", // for backward compatibility
    - 403 + + 4752 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + Prepare: func(t *testing.T, tc *testCase) {
    -
     
    -
    - 490 + + 4753 +
    -   - BatchNumber: uint64(2), + + + tc.Input = "0x1234"
    - 491 + + 4754 +
    -   - Coinbase: common.HexToAddress("0x222"), + + + tc.ExpectedResult = nil
    - 492 + + 4755 +
    -   - TxHash: common.HexToHash("0x333"), + + + tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input")
    - 493 + + 4756 +
    + - PolygonRollupBaseEtrogBatchData: polygonzkevm.PolygonRollupBaseEtrogBatchData{ + },
    - 494 + + 4757 +
    -   - Transactions: []byte{}, + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {},
    - 495 + + 4758 +
    -   - 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}, + + + },
    - 496 + + 4759 +
    -   - ForcedTimestamp: 1000, //ForcedBatch + + + {
    -
     
    -
    - 659 + + 4760 +
    -   -
    + + + Name: "Sender not on deploy allow list, rejected",
    - 660 + + 4761 +
    -   - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { + + + Prepare: func(t *testing.T, tc *testCase) {
    - 661 + + 4762 +
    -   - genesis := state.Genesis{ + + + deployAddr := common.HexToAddress("0x0")
    - 662 + + 4763 +
    + - RollupBlockNumber: uint64(123456), + tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 663 + + 4764 +
    -   - } + + +
    - 664 + + 4765 +
    -   - cfg := Config{ + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - 665 + + 4766 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + require.NoError(t, err)
    -
     
    -
    - 761 + + 4767 +
    -   - transactions := []types.TransactionOrHash{} + + +
    - 762 + + 4768 +
    -   - for nBlock := 0; nBlock < howManyBlocks; nBlock++ { + + + txBinary, err := signedTx.MarshalBinary()
    - 763 + + 4769 +
    -   - block := state.L2BlockRaw{ + + + require.NoError(t, err)
    - 764 + + 4770 +
    + - DeltaTimestamp: 123, +
    - 765 + + 4771 +
    + - IndexL1InfoTree: 456, + rawTx := hex.EncodeToHex(txBinary)
    - 766 + + 4772 +
    + - Transactions: []state.L2TxRaw{}, + require.NoError(t, err)
    - + + 4773 -
    -   +
    +
    + +
    - + + 4774 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - 767 + + 4775 +
    -   - } + + + tc.ExpectedResult = nil
    - 768 + + 4776 +
    -   - for i := 0; i < howManyTx; i++ { + + + tc.ExpectedError = deployDenied
    - 769 + + 4777 +
    -   - tx := createTransaction(uint64(i + 1)) + + + },
    -
     
    -
    - 923 + + 4778 +
    -   -
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 924 + + 4779 +
    -   - func TestReorg(t *testing.T) { + + + m.Pool.
    - 925 + + 4780 +
    -   - genesis := state.Genesis{ + + + On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From).
    - 926 + + 4781 +
    + - RollupBlockNumber: uint64(0), + Return(false, nil).
    - 927 + + 4782 +
    -   - } + + + Once()
    - 928 + + 4783 +
    -   - cfg := Config{ + + + },
    - 929 + + 4784 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + },
    -
     
    +
    + 4785 + +
    + + + } +
    - 1243 + + 4786 +
    -   + +
    - 1244 + + 4787 +
    -   - func TestLatestSyncedBlockEmpty(t *testing.T) { + + + for _, testCase := range testCases {
    - 1245 + + 4788 +
    -   - genesis := state.Genesis{ + + + t.Run(testCase.Name, func(t *testing.T) {
    - 1246 + + 4789 +
    + - RollupBlockNumber: uint64(0), + tc := testCase
    - 1247 + + 4790 +
    -   - } + + + tc.Prepare(t, &tc)
    - 1248 + + 4791 +
    -   - cfg := Config{ + + + tc.SetupMocks(t, m, tc)
    - 1249 + + 4792 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + +
    -
     
    -
    - 1457 + + 4793 +
    -   -
    + + + res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input)
    - 1458 + + 4794 +
    -   - func TestRegularReorg(t *testing.T) { + + + require.NoError(t, err)
    - 1459 + + 4795 +
    -   - genesis := state.Genesis{ + + +
    - 1460 + + 4796 +
    + - RollupBlockNumber: uint64(0), + assert.Equal(t, float64(1), res.ID)
    - 1461 + + 4797 +
    -   - } + + + assert.Equal(t, "2.0", res.JSONRPC)
    - 1462 + + 4798 +
    -   - cfg := Config{ + + +
    - 1463 + + 4799 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + if res.Result != nil || tc.ExpectedResult != nil {
    -
     
    -
    - 1739 + + 4800 +
    -   -
    + + + var result common.Hash
    - 1740 + + 4801 +
    -   - func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { + + + err = json.Unmarshal(res.Result, &result)
    - 1741 + + 4802 +
    -   - genesis := state.Genesis{ + + + require.NoError(t, err)
    - 1742 + + 4803 +
    + - RollupBlockNumber: uint64(0), + assert.Equal(t, *tc.ExpectedResult, result)
    - 1743 + + 4804 +
    -   - } + + + }
    - 1744 + + 4805 +
    -   - cfg := Config{ + + + if res.Error != nil || tc.ExpectedError != nil {
    - 1745 + + 4806 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code)
    -
     
    +
    + 4807 + +
    + + + assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message) +
    - 2015 + + 4808 +
    -   -
    + + + }
    - 2016 + + 4809 +
    -   - func TestCallFromEmptyBlockAndReorg(t *testing.T) { + + + })
    - 2017 + + 4810 +
    -   - genesis := state.Genesis{ + + + }
    - 2018 + + 4811 +
    + - RollupBlockNumber: uint64(0), + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -195,6 +195,52 @@
    - 2019 + 195
      - } + return rpcBatch, nil
    - 2020 + 196
      - cfg := Config{ + }
    - 2021 + 197
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    - 2022 + + -
    +
    +
      - SyncChunkSize: 3, +
    - 2023 + + -
    +
    +
      - L1SynchronizationMode: SequentialMode, +
    - 2024 + + -
    +
    +
      - SyncBlockProtection: "latest", +
    - 2025 + + -
    - + - L1BlockCheck: L1BlockCheckConfig{ +
    +
    +   +
    - 2026 + + -
    - + - Enable: false, +
    +
    +   +
    - 2027 + + -
    - + - }, +
    +
    +   +
    - 2028 + + -
    +
    +
      - } +
    - 2029 + + -
    +
    +
     
    - 2030 + + -
    +
    +
      - m := mocks{ +
    -
     
    +
    + + +
    +   +
    +
    - 2130 + + -
    +
    +
      - Return(ethHeader2bis, nil). +
    - 2131 + + -
    +
    +
      - Once() +
    - 2132 + + -
    +
    +
     
    - 2133 + + -
    - + - // m.Etherman. +
    +
    +   +
    - 2134 + + -
    - + - // On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    +   +
    - 2135 + + -
    - + - // Return(ethBlock1, nil). +
    +
    +   +
    - 2136 + + -
    - + - // Once() +
    +
    +   +
    - 2137 + + -
    - + +
    +
    +  
    - 2138 + + -
    +
    +
      - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    - 2139 + + -
    +
    +
     
    - 2140 + + -
    +
    +
      - ethermanBlock0 := etherman.Block{ +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol - RENAMED - -
    -
    -
    -
    - - - - - + + + + + + + + +
    -
    @@ -0,0 +1,24 @@
    @@ -307831,6 +77720,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 198 + +
    +   + // GetFullBlockByNumber returns information about a block by block number +
    +
    + 199 + +
    +   + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { +
    +
    + 200 + +
    +   + ctx := context.Background() +
    +
    @@ -307845,109 +77764,149 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    + + + 195 + + +
    +   + return rpcBatch, nil +
    + + + + 196 + + +
    +   + } +
    + + + + 197 + + +
    +   +
    +
    + - 1 + 198
    + - // SPDX-License-Identifier: MIT + type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 2 + 199
    + - pragma solidity >=0.7.0 <0.9.0; +
    - 3 + 200
    + -
    + // GetBatchDataByNumbers returns L2 batch data by batch numbers.
    - 4 + 201
    + - contract customModExp { + func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    - 5 + 202
    + - bytes32 hashResult; + return z.getBatchData(filter, z.state.GetBatchL2DataByNumbers)
    - 6 + 203
    + - address retEcrecover; + }
    - 7 + 204
    + - bytes dataResult; +
    - 8 + 205
    + - uint256 dataRes; + // GetForcedBatchDataByNumbers returns forced batch data by batch numbers.
    - 9 + 206
    + -
    + func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    - 10 + 207
    + - bytes32[10] arrayStorage; + return z.getBatchData(filter, z.state.GetForcedBatchDataByNumbers)
    - 11 + 208 + + +
    + + + } +
    + + + + 209
    @@ -307957,27 +77916,107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 12 + 210
    + - function modExpGeneric(bytes memory input) public { + func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) (interface{}, types.Error) {
    - 13 + 211
    + - bytes32[10] memory output; + ctx := context.Background()
    - 14 + 212 + + +
    + + + batchNumbers := make([]uint64, 0, len(filter.Numbers)) +
    + + + + 213 + + +
    + + + for _, bn := range filter.Numbers { +
    + + + + 214 + + +
    + + + n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, nil) +
    + + + + 215 + + +
    + + + if rpcErr != nil { +
    + + + + 216 + + +
    + + + return nil, rpcErr +
    + + + + 217 + + +
    + + + } +
    + + + + 218 + + +
    + + + batchNumbers = append(batchNumbers, n) +
    + + + + 219 + + +
    + + + } +
    + + + + 220
    @@ -307987,47 +78026,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 15 + 221
    + - assembly { + batchesData, err := f(ctx, batchNumbers, nil)
    - 16 + 222
    + - let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140) + if errors.Is(err, state.ErrNotFound) {
    - 17 + 223
    + - sstore(0x00, success) + return nil, nil
    - 18 + 224
    + - } + } else if err != nil {
    - 19 + 225 + + +
    + + + return RPCErrorResponse(types.DefaultErrorCode, +
    + + + + 226 + + +
    + + + fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true) +
    + + + + 227 + + +
    + + + } +
    + + + + 228
    @@ -308037,47 +78106,137 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 20 + 229
    + - for (uint i = 0; i < 10; i++) { + ret := make([]*types.BatchData, 0, len(batchNumbers))
    - 21 + 230
    + - arrayStorage[i] = output[i]; + for _, n := range batchNumbers {
    - 22 + 231
    + - } + data := &types.BatchData{Number: types.ArgUint64(n)}
    - 23 + 232
    + - } + if b, ok := batchesData[n]; ok {
    - 24 + 233 + + +
    + + + data.BatchL2Data = b +
    + + + + 234 + + +
    + + + data.Empty = false +
    + + + + 235 + + +
    + + + } else { +
    + + + + 236 + + +
    + + + data.Empty = true +
    + + + + 237 + + +
    + + + } +
    + + + + 238 + + +
    + + + ret = append(ret, data) +
    + + + + 239 + + +
    + + + } +
    + + + + 240 + + +
    + + +
    +
    + + + + 241 + + +
    + + + return types.BatchDataResult{Data: ret}, nil +
    + + + + 242
    @@ -308085,6 +78244,46 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    + + + 243 + + +
    + + +
    +
    + + + + 244 + + +
    +   + // GetFullBlockByNumber returns information about a block by block number +
    + + + + 245 + + +
    +   + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { +
    + + + + 246 + + +
    +   + ctx := context.Background() +
    + @@ -308092,12 +78291,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 → .}/jsonrpc/endpoints_zkevm_test.go RENAMED