Skip to content

Commit

Permalink
ger writing fix for getBatchByNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Staykov committed Aug 28, 2024
1 parent 566d4e0 commit d6a02eb
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmd/rpcdaemon/commands/zkevm_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,20 +608,13 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
}

// global exit root of batch
batchGer, blockNumberForGer, err := hermezDb.GetLastBlockGlobalExitRoot(blockNo)
batchGer, _, err := hermezDb.GetLastBlockGlobalExitRoot(blockNo)
if err != nil {
return nil, err
}

gerBatchNumber, err := hermezDb.GetBatchNoByL2Block(blockNumberForGer)
if err != nil {
return nil, err
}
// only set ger if it was changed this batch and before forkid5
// otherwise set 0x0000...
if gerBatchNumber == batchNo || (forkId >= 5 && forkId < 6) {
batch.GlobalExitRoot = batchGer
}
batch.GlobalExitRoot = batchGer

// sequence
seq, err := hermezDb.GetSequenceByBatchNoOrHighest(batchNo)
if err != nil {
Expand Down Expand Up @@ -688,7 +681,7 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
// forkid exit roots logic
// if forkid < 12 then we should only set the exit roots if they have changed, otherwise 0x00..00
// if forkid >= 12 then we should always set the exit roots
if forkId < 12 {
if forkId < 12 && forkId >= 7 {
// get the previous batches exit roots
prevBatchNo := batchNo - 1
prevBatchHighestBlock, _, err := hermezDb.GetHighestBlockInBatch(prevBatchNo)
Expand Down

0 comments on commit d6a02eb

Please sign in to comment.