diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index c709b98f61..70db280d97 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -32,6 +32,8 @@ const ( ethTxManagerOwner = "aggregator" monitoredIDFormat = "proof-from-%v-to-%v" + + forkId9 = uint64(9) ) type finalProofMsg struct { @@ -179,7 +181,7 @@ func (a *Aggregator) Channel(stream prover.AggregatorService_ChannelServer) erro log.Info("Establishing stream connection with prover") // Check if prover supports the required Fork ID - if !prover.SupportsForkID(a.cfg.ForkId) { + if !prover.SupportsForkID(forkId9) { err := errors.New("prover does not support required fork ID") log.Warn(FirstToUpper(err.Error())) return err @@ -365,9 +367,13 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state. for _, l2blockRaw := range batchRawData.Blocks { _, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree] if !contained && l2blockRaw.IndexL1InfoTree != 0 { - l1InfoTreeExitRootStorageEntry, err := a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil) - if err != nil { - return nil, err + l1InfoTreeExitRootStorageEntry := state.L1InfoTreeExitRootStorageEntry{} + l1InfoTreeExitRootStorageEntry.Timestamp = time.Unix(0, 0) + if l2blockRaw.IndexL1InfoTree <= leaves[len(leaves)-1].L1InfoTreeIndex { + l1InfoTreeExitRootStorageEntry, err = a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil) + if err != nil { + return nil, err + } } // Calculate smt proof @@ -420,7 +426,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state. OldAccInputHash: previousBatch.AccInputHash.Bytes(), OldBatchNum: previousBatch.BatchNumber, ChainId: a.cfg.ChainID, - ForkId: a.cfg.ForkId, + ForkId: forkId9, BatchL2Data: batchToVerify.BatchL2Data, L1InfoRoot: l1InfoRoot.Bytes(), TimestampLimit: uint64(batchToVerify.Timestamp.Unix()), diff --git a/docker-compose.yml b/docker-compose.yml index 1dd6e9f291..7ae42c26c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -107,7 +107,7 @@ services: zkevm-prover: container_name: zkevm-prover restart: unless-stopped - image: hermeznetwork/zkevm-prover:v5.0.7 + image: hermeznetwork/zkevm-prover:v6.0.0 depends_on: zkevm-state-db: condition: service_healthy diff --git a/l1infotree/tree.go b/l1infotree/tree.go index 5e356c164d..e0c19da6bf 100644 --- a/l1infotree/tree.go +++ b/l1infotree/tree.go @@ -84,16 +84,13 @@ func (mt *L1InfoTree) ComputeMerkleProof(gerIndex uint32, leaves [][32]byte) ([] if len(leaves)%2 == 1 { leaves = append(leaves, mt.zeroHashes[h]) } - if index%2 == 1 { //If it is odd - siblings = append(siblings, leaves[index-1]) - } else { // It is even - if len(leaves) > 1 { - if index >= uint32(len(leaves)) { - // siblings = append(siblings, mt.zeroHashes[h]) - siblings = append(siblings, leaves[index-1]) - } else { - siblings = append(siblings, leaves[index+1]) - } + if index >= uint32(len(leaves)) { + siblings = append(siblings, mt.zeroHashes[h]) + } else { + if index%2 == 1 { //If it is odd + siblings = append(siblings, leaves[index-1]) + } else { // It is even + siblings = append(siblings, leaves[index+1]) } } var ( diff --git a/state/batchV2.go b/state/batchV2.go index c730334012..731e0d9bda 100644 --- a/state/batchV2.go +++ b/state/batchV2.go @@ -306,6 +306,7 @@ func (s *State) sendBatchRequestToExecutorV2(ctx context.Context, batchRequest * log.Warn(batchResponseToString) s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest) } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) { + err = executor.RomErr(batchResponse.ErrorRom) log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err) log.Warn(batchResponseToString) } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { diff --git a/state/trace.go b/state/trace.go index 9fa6546fb6..0d835aa2d3 100644 --- a/state/trace.go +++ b/state/trace.go @@ -61,11 +61,22 @@ func (s *State) DebugTransaction(ctx context.Context, transactionHash common.Has } oldStateRoot = previousL2Block.Root() + count := 0 + for _, tx := range l2Block.Transactions() { + checkReceipt, err := s.GetTransactionReceipt(ctx, tx.Hash(), dbTx) + if err != nil { + return nil, err + } + if checkReceipt.TransactionIndex < receipt.TransactionIndex { + count++ + } + } + // since the executor only stores the state roots by block, we need to // execute all the txs in the block until the tx we want to trace var txsToEncode []types.Transaction var effectivePercentage []uint8 - for i := 0; i <= int(receipt.TransactionIndex); i++ { + for i := 0; i <= count; i++ { txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) effectivePercentage = append(effectivePercentage, MaxEffectivePercentage) log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) diff --git a/state/transaction.go b/state/transaction.go index a80a097bff..f530b4148c 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -252,11 +252,9 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P if executor.IsInvalidL2Block(executor.RomErrorCode(txResponse.RomError)) { continue } - txResp := *txResponse transactions = append(transactions, &txResp.Tx) txsL2Hash = append(txsL2Hash, txResp.TxHashL2_V2) - storeTxEGPData := StoreTxEGPData{EGPLog: nil, EffectivePercentage: uint8(txResponse.EffectivePercentage)} if txsEGPLog != nil { storeTxEGPData.EGPLog = txsEGPLog[i] diff --git a/test/docker-compose.yml b/test/docker-compose.yml index f15c810165..2448270e7a 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -513,8 +513,12 @@ services: zkevm-prover: container_name: zkevm-prover +<<<<<<< HEAD platform: linux/amd64 image: hermeznetwork/zkevm-prover:v5.0.7 +======= + image: hermeznetwork/zkevm-prover:v6.0.0 +>>>>>>> df539db1 (fix aggregator l1 info tree (#3490) (#3491) (#3484) (#3495)) ports: - 50061:50061 # MT - 50071:50071 # Executor @@ -605,8 +609,7 @@ services: zkevm-permissionless-prover: container_name: zkevm-permissionless-prover - platform: linux/amd64 - image: hermeznetwork/zkevm-prover:v5.0.7 + image: hermeznetwork/zkevm-prover:v6.0.0 ports: # - 50058:50058 # Prover - 50059:50052 # Mock prover