@@ -394,16 +394,20 @@ func (s *RollupSyncService) getLocalChunksForBatch(chunkBlockRanges []*rawdb.Chu
394
394
return nil , fmt .Errorf ("failed to get block by number: %v" , i )
395
395
}
396
396
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 )
402
397
chunks [i ].Blocks [j - cr .StartBlockNumber ] = & encoding.Block {
403
398
Header : block .Header (),
404
399
Transactions : txData ,
405
- WithdrawRoot : withdrawRoot ,
406
400
}
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
407
411
}
408
412
}
409
413
@@ -574,7 +578,9 @@ func validateBatch(batchIndex uint64, event *l1.FinalizeBatchEvent, parentFinali
574
578
os .Exit (1 )
575
579
}
576
580
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 () {
578
584
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 ())
579
585
stack .Close ()
580
586
os .Exit (1 )
@@ -603,7 +609,7 @@ func validateBatch(batchIndex uint64, event *l1.FinalizeBatchEvent, parentFinali
603
609
BatchHash : localBatchHash ,
604
610
TotalL1MessagePopped : totalL1MessagePopped ,
605
611
StateRoot : localStateRoot ,
606
- WithdrawRoot : localWithdrawRoot ,
612
+ WithdrawRoot : event . WithdrawRoot () ,
607
613
}
608
614
return endBlock .Header .Number .Uint64 (), finalizedBatchMeta , nil
609
615
}
0 commit comments