Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit df539db

Browse files
ToniRamirezMjbaylinaagnusmor
authored
fix aggregator l1 info tree (#3490) (#3491) (#3484) (#3495)
* fix aggregator l1 info tree (#3491) * fix aggregator l1 info tree * Fix case you want to proof a 0 (#3492) * Fix case you want to proof a 0 * init timestamp --------- Co-authored-by: Toni Ramírez <[email protected]> * force forkid 9 * update prover --------- Co-authored-by: Jordi Baylina <[email protected]> Co-authored-by: agnusmor <[email protected]> * fix debug trace receipt index (#3490) * conflicts * fix ooc * fix tx index calculation on receipt (#3488) * remove 3495 --------- Co-authored-by: Jordi Baylina <[email protected]> Co-authored-by: agnusmor <[email protected]>
1 parent bfaa130 commit df539db

File tree

7 files changed

+34
-21
lines changed

7 files changed

+34
-21
lines changed

aggregator/aggregator.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const (
3535

3636
ethTxManagerOwner = "aggregator"
3737
monitoredIDFormat = "proof-from-%v-to-%v"
38+
39+
forkId9 = uint64(9)
3840
)
3941

4042
type finalProofMsg struct {
@@ -182,7 +184,7 @@ func (a *Aggregator) Channel(stream prover.AggregatorService_ChannelServer) erro
182184
log.Info("Establishing stream connection with prover")
183185

184186
// Check if prover supports the required Fork ID
185-
if !prover.SupportsForkID(a.cfg.ForkId) {
187+
if !prover.SupportsForkID(forkId9) {
186188
err := errors.New("prover does not support required fork ID")
187189
log.Warn(FirstToUpper(err.Error()))
188190
return err
@@ -1032,9 +1034,13 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
10321034
for _, l2blockRaw := range batchRawData.Blocks {
10331035
_, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree]
10341036
if !contained && l2blockRaw.IndexL1InfoTree != 0 {
1035-
l1InfoTreeExitRootStorageEntry, err := a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
1036-
if err != nil {
1037-
return nil, err
1037+
l1InfoTreeExitRootStorageEntry := state.L1InfoTreeExitRootStorageEntry{}
1038+
l1InfoTreeExitRootStorageEntry.Timestamp = time.Unix(0, 0)
1039+
if l2blockRaw.IndexL1InfoTree <= leaves[len(leaves)-1].L1InfoTreeIndex {
1040+
l1InfoTreeExitRootStorageEntry, err = a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
1041+
if err != nil {
1042+
return nil, err
1043+
}
10381044
}
10391045

10401046
// Calculate smt proof
@@ -1087,7 +1093,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
10871093
OldAccInputHash: previousBatch.AccInputHash.Bytes(),
10881094
OldBatchNum: previousBatch.BatchNumber,
10891095
ChainId: a.cfg.ChainID,
1090-
ForkId: a.cfg.ForkId,
1096+
ForkId: forkId9,
10911097
BatchL2Data: batchToVerify.BatchL2Data,
10921098
L1InfoRoot: l1InfoRoot.Bytes(),
10931099
TimestampLimit: uint64(batchToVerify.Timestamp.Unix()),

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ services:
107107
zkevm-prover:
108108
container_name: zkevm-prover
109109
restart: unless-stopped
110-
image: hermeznetwork/zkevm-prover:v5.0.9
110+
image: hermeznetwork/zkevm-prover:v6.0.0
111111
depends_on:
112112
zkevm-state-db:
113113
condition: service_healthy

l1infotree/tree.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,13 @@ func (mt *L1InfoTree) ComputeMerkleProof(gerIndex uint32, leaves [][32]byte) ([]
8484
if len(leaves)%2 == 1 {
8585
leaves = append(leaves, mt.zeroHashes[h])
8686
}
87-
if index%2 == 1 { //If it is odd
88-
siblings = append(siblings, leaves[index-1])
89-
} else { // It is even
90-
if len(leaves) > 1 {
91-
if index >= uint32(len(leaves)) {
92-
// siblings = append(siblings, mt.zeroHashes[h])
93-
siblings = append(siblings, leaves[index-1])
94-
} else {
95-
siblings = append(siblings, leaves[index+1])
96-
}
87+
if index >= uint32(len(leaves)) {
88+
siblings = append(siblings, mt.zeroHashes[h])
89+
} else {
90+
if index%2 == 1 { //If it is odd
91+
siblings = append(siblings, leaves[index-1])
92+
} else { // It is even
93+
siblings = append(siblings, leaves[index+1])
9794
}
9895
}
9996
var (

state/batchV2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ func (s *State) sendBatchRequestToExecutorV2(ctx context.Context, batchRequest *
307307
log.Warn(batchResponseToString)
308308
s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest)
309309
} else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
310+
err = executor.RomErr(batchResponse.ErrorRom)
310311
log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
311312
log.Warn(batchResponseToString)
312313
} else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {

state/trace.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,22 @@ func (s *State) DebugTransaction(ctx context.Context, transactionHash common.Has
6161
}
6262
oldStateRoot = previousL2Block.Root()
6363

64+
count := 0
65+
for _, tx := range l2Block.Transactions() {
66+
checkReceipt, err := s.GetTransactionReceipt(ctx, tx.Hash(), dbTx)
67+
if err != nil {
68+
return nil, err
69+
}
70+
if checkReceipt.TransactionIndex < receipt.TransactionIndex {
71+
count++
72+
}
73+
}
74+
6475
// since the executor only stores the state roots by block, we need to
6576
// execute all the txs in the block until the tx we want to trace
6677
var txsToEncode []types.Transaction
6778
var effectivePercentage []uint8
68-
for i := 0; i <= int(receipt.TransactionIndex); i++ {
79+
for i := 0; i <= count; i++ {
6980
txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
7081
effectivePercentage = append(effectivePercentage, MaxEffectivePercentage)
7182
log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())

state/transaction.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,9 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P
252252
if executor.IsInvalidL2Block(executor.RomErrorCode(txResponse.RomError)) {
253253
continue
254254
}
255-
256255
txResp := *txResponse
257256
transactions = append(transactions, &txResp.Tx)
258257
txsL2Hash = append(txsL2Hash, txResp.TxHashL2_V2)
259-
260258
storeTxEGPData := StoreTxEGPData{EGPLog: nil, EffectivePercentage: uint8(txResponse.EffectivePercentage)}
261259
if txsEGPLog != nil {
262260
storeTxEGPData.EGPLog = txsEGPLog[i]

test/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ services:
513513

514514
zkevm-prover:
515515
container_name: zkevm-prover
516-
image: hermeznetwork/zkevm-prover:v5.0.9
516+
image: hermeznetwork/zkevm-prover:v6.0.0
517517
ports:
518518
- 50061:50061 # MT
519519
- 50071:50071 # Executor
@@ -602,7 +602,7 @@ services:
602602

603603
zkevm-permissionless-prover:
604604
container_name: zkevm-permissionless-prover
605-
image: hermeznetwork/zkevm-prover:v5.0.9
605+
image: hermeznetwork/zkevm-prover:v6.0.0
606606
ports:
607607
# - 50058:50058 # Prover
608608
- 50059:50052 # Mock prover

0 commit comments

Comments
 (0)