Skip to content

Commit

Permalink
Add postStateRoot and withdrawRoot when rebuilding batch cache (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
FletcherMan authored Jul 11, 2024
1 parent 067ee26 commit b9554d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions node/core/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func (e *Executor) CalculateCapWithProposalBlock(currentBlockBytes []byte, curre
var l1TxHashes []common.Hash
var totalL1MessagePopped = parentBatchHeader.TotalL1MessagePopped
var lastHeightBeforeCurrentBatch uint64
var lastBlockStateRoot common.Hash
var lastBlockWithdrawRoot common.Hash
var l2TxNum int

for i, blockBz := range blocks {
Expand All @@ -119,6 +121,11 @@ func (e *Executor) CalculateCapWithProposalBlock(currentBlockBytes []byte, curre
lastHeightBeforeCurrentBatch = wBlock.Number - 1
}

if i == len(blocks)-1 {
lastBlockStateRoot = wBlock.StateRoot
lastBlockWithdrawRoot = wBlock.WithdrawTrieRoot
}

totalL1MessagePoppedBefore := totalL1MessagePopped
txsPayload, l1TxHashes, totalL1MessagePopped, skippedBitmap, l2TxNum, err = ParsingTxs(transactions[i], parentBatchHeader.TotalL1MessagePopped, totalL1MessagePoppedBefore, skippedBitmap)
if err != nil {
Expand Down Expand Up @@ -148,6 +155,8 @@ func (e *Executor) CalculateCapWithProposalBlock(currentBlockBytes []byte, curre
return false, 0, err
}
e.batchingCache.prevStateRoot = header.Root
e.batchingCache.postStateRoot = lastBlockStateRoot
e.batchingCache.withdrawRoot = lastBlockWithdrawRoot

// initialize latest batch index
e.metrics.BatchIndex.Set(float64(e.batchingCache.parentBatchHeader.BatchIndex))
Expand Down

0 comments on commit b9554d1

Please sign in to comment.