Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix aggregator l1 info tree (#3490) (#3491) (#3484) (#3495) #3497

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (

ethTxManagerOwner = "aggregator"
monitoredIDFormat = "proof-from-%v-to-%v"

forkId9 = uint64(9)
)

type finalProofMsg struct {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions l1infotree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions state/batchV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 12 additions & 1 deletion state/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 0 additions & 2 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ services:

zkevm-prover:
container_name: zkevm-prover
platform: linux/amd64
image: hermeznetwork/zkevm-prover:v5.0.7
image: hermeznetwork/zkevm-prover:v6.0.0
ports:
- 50061:50061 # MT
- 50071:50071 # Executor
Expand Down Expand Up @@ -605,8 +604,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
Expand Down
Loading