Skip to content

Commit

Permalink
fix batch end local exit root
Browse files Browse the repository at this point in the history
we reading the batch end for the next batch rather than the current one.

updated utility to use the block number rather than +1 as this is how the witness uses it and we'd have serious problems if that didn't work as expected.
  • Loading branch information
hexoscott committed Sep 15, 2024
1 parent 4068aea commit 8f3886c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zk/datastream/server/data_stream_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func createBlockWithBatchCheckStreamEntriesProto(
}
// the genesis we insert fully, so we would have to skip closing it
if !shouldSkipBatchEndEntry {
localExitRoot, err := utils.GetBatchLocalExitRootFromSCStorageForLatestBlock(batchNumber, reader, tx)
localExitRoot, err := utils.GetBatchLocalExitRootFromSCStorageForLatestBlock(lastBatchNumber, reader, tx)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion zk/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func GetBatchLocalExitRootFromSCStorageForLatestBlock(batchNo uint64, db DbReade

func GetBatchLocalExitRootFromSCStorageByBlock(blockNumber uint64, db DbReader, tx kv.Tx) (libcommon.Hash, error) {
if blockNumber > 0 {
stateReader := state.NewPlainState(tx, blockNumber+1, systemcontracts.SystemContractCodeLookup["hermez"])
stateReader := state.NewPlainState(tx, blockNumber, systemcontracts.SystemContractCodeLookup["hermez"])
defer stateReader.Close()
rawLer, err := stateReader.ReadAccountStorage(state.GER_MANAGER_ADDRESS, 1, &state.GLOBAL_EXIT_ROOT_POS_1)
if err != nil {
Expand Down

0 comments on commit 8f3886c

Please sign in to comment.