Skip to content

Commit 3edb331

Browse files
authored
feat(rollup-verifier): make withdraw root check optional (#1182)
1 parent 0d72990 commit 3edb331

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 43 // Patch version component of the current release
27+
VersionPatch = 44 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/rollup_sync_service/rollup_sync_service.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,20 @@ func (s *RollupSyncService) getLocalChunksForBatch(chunkBlockRanges []*rawdb.Chu
394394
return nil, fmt.Errorf("failed to get block by number: %v", i)
395395
}
396396
txData := encoding.TxsToTxsData(block.Transactions())
397-
state, err := s.bc.StateAt(block.Root())
398-
if err != nil {
399-
return nil, fmt.Errorf("failed to get block state, block: %v, err: %w", block.Hash().Hex(), err)
400-
}
401-
withdrawRoot := withdrawtrie.ReadWTRSlot(rcfg.L2MessageQueueAddress, state)
402397
chunks[i].Blocks[j-cr.StartBlockNumber] = &encoding.Block{
403398
Header: block.Header(),
404399
Transactions: txData,
405-
WithdrawRoot: withdrawRoot,
406400
}
401+
402+
// read withdraw root, if available
403+
// note: historical state is not available on full nodes
404+
state, err := s.bc.StateAt(block.Root())
405+
if err != nil {
406+
log.Trace("State is not available, skipping withdraw trie validation", "blockNumber", block.NumberU64(), "blockHash", block.Hash().Hex(), "err", err)
407+
continue
408+
}
409+
withdrawRoot := withdrawtrie.ReadWTRSlot(rcfg.L2MessageQueueAddress, state)
410+
chunks[i].Blocks[j-cr.StartBlockNumber].WithdrawRoot = withdrawRoot
407411
}
408412
}
409413

@@ -574,7 +578,9 @@ func validateBatch(batchIndex uint64, event *l1.FinalizeBatchEvent, parentFinali
574578
os.Exit(1)
575579
}
576580

577-
if localWithdrawRoot != event.WithdrawRoot() {
581+
// note: this check is optional,
582+
// withdraw root correctness is already implied by state root correctness.
583+
if localWithdrawRoot != (common.Hash{}) && localWithdrawRoot != event.WithdrawRoot() {
578584
log.Error("Withdraw root mismatch", "batch index", event.BatchIndex().Uint64(), "start block", startBlock.Header.Number.Uint64(), "end block", endBlock.Header.Number.Uint64(), "parent batch hash", parentFinalizedBatchMeta.BatchHash.Hex(), "l1 finalized withdraw root", event.WithdrawRoot().Hex(), "l2 withdraw root", localWithdrawRoot.Hex())
579585
stack.Close()
580586
os.Exit(1)
@@ -603,7 +609,7 @@ func validateBatch(batchIndex uint64, event *l1.FinalizeBatchEvent, parentFinali
603609
BatchHash: localBatchHash,
604610
TotalL1MessagePopped: totalL1MessagePopped,
605611
StateRoot: localStateRoot,
606-
WithdrawRoot: localWithdrawRoot,
612+
WithdrawRoot: event.WithdrawRoot(),
607613
}
608614
return endBlock.Header.Number.Uint64(), finalizedBatchMeta, nil
609615
}

0 commit comments

Comments
 (0)