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 #3491

Merged
merged 4 commits into from
Mar 25, 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 @@ -35,6 +35,8 @@ const (

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

forkId9 = uint64(9)
)

type finalProofMsg struct {
Expand Down Expand Up @@ -182,7 +184,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 @@ -1032,9 +1034,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 @@ -1087,7 +1093,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.9
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
4 changes: 2 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ services:

zkevm-prover:
container_name: zkevm-prover
image: hermeznetwork/zkevm-prover:v5.0.9
image: hermeznetwork/zkevm-prover:v6.0.0
ports:
- 50061:50061 # MT
- 50071:50071 # Executor
Expand Down Expand Up @@ -602,7 +602,7 @@ services:

zkevm-permissionless-prover:
container_name: zkevm-permissionless-prover
image: hermeznetwork/zkevm-prover:v5.0.9
image: hermeznetwork/zkevm-prover:v6.0.0
ports:
# - 50058:50058 # Prover
- 50059:50052 # Mock prover
Expand Down
Loading