@@ -290,6 +290,12 @@ func (r *Layer2Relayer) commitGenesisBatch(batchHash string, batchHeader []byte,
290290 log .Info ("Validium importGenesis" , "calldata" , common .Bytes2Hex (calldata ))
291291 } else {
292292 // rollup mode: pass batchHeader and stateRoot
293+
294+ // Check state root is not zero
295+ if stateRoot == (common.Hash {}) {
296+ return fmt .Errorf ("state root is zero" )
297+ }
298+
293299 calldata , packErr = r .l1RollupABI .Pack ("importGenesisBatch" , batchHeader , stateRoot )
294300 if packErr != nil {
295301 return fmt .Errorf ("failed to pack rollup importGenesisBatch with batch header: %v and state root: %v. error: %v" , common .Bytes2Hex (batchHeader ), stateRoot , packErr )
@@ -502,6 +508,11 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
502508 log .Error ("failed to construct normal payload" , "codecVersion" , codecVersion , "start index" , firstBatch .Index , "end index" , lastBatch .Index , "err" , err )
503509 return
504510 }
511+
512+ if err = r .sanityChecksCommitBatchCodecV7CalldataAndBlobs (calldata , blobs ); err != nil {
513+ log .Error ("Sanity check failed for calldata and blobs" , "codecVersion" , codecVersion , "start index" , firstBatch .Index , "end index" , lastBatch .Index , "err" , err )
514+ return
515+ }
505516 }
506517 default :
507518 log .Error ("unsupported codec version in ProcessPendingBatches" , "codecVersion" , codecVersion , "start index" , firstBatch , "end index" , lastBatch .Index )
@@ -999,6 +1010,18 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
9991010}
10001011
10011012func (r * Layer2Relayer ) constructCommitBatchPayloadValidium (batch * dbBatchWithChunks ) ([]byte , uint64 , uint64 , error ) {
1013+ // Check state root is not zero
1014+ stateRoot := common .HexToHash (batch .Batch .StateRoot )
1015+ if stateRoot == (common.Hash {}) {
1016+ return nil , 0 , 0 , fmt .Errorf ("batch %d state root is zero" , batch .Batch .Index )
1017+ }
1018+
1019+ // Check parent batch hash is not zero
1020+ parentBatchHash := common .HexToHash (batch .Batch .ParentBatchHash )
1021+ if parentBatchHash == (common.Hash {}) {
1022+ return nil , 0 , 0 , fmt .Errorf ("batch %d parent batch hash is zero" , batch .Batch .Index )
1023+ }
1024+
10021025 // Calculate metrics
10031026 var maxBlockHeight uint64
10041027 var totalGasUsed uint64
@@ -1018,6 +1041,7 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
10181041
10191042 lastChunk := batch .Chunks [len (batch .Chunks )- 1 ]
10201043 commitment := common .HexToHash (lastChunk .EndBlockHash )
1044+
10211045 version := encoding .CodecVersion (batch .Batch .CodecVersion )
10221046 calldata , err := r .validiumABI .Pack ("commitBatch" , version , common .HexToHash (batch .Batch .ParentBatchHash ), common .HexToHash (batch .Batch .StateRoot ), common .HexToHash (batch .Batch .WithdrawRoot ), commitment [:])
10231047 if err != nil {
@@ -1028,6 +1052,12 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
10281052}
10291053
10301054func (r * Layer2Relayer ) constructFinalizeBundlePayloadCodecV7 (dbBatch * orm.Batch , endChunk * orm.Chunk , aggProof * message.OpenVMBundleProof ) ([]byte , error ) {
1055+ // Check state root is not zero
1056+ stateRoot := common .HexToHash (dbBatch .StateRoot )
1057+ if stateRoot == (common.Hash {}) {
1058+ return nil , fmt .Errorf ("batch %d state root is zero" , dbBatch .Index )
1059+ }
1060+
10311061 if aggProof != nil { // finalizeBundle with proof.
10321062 calldata , packErr := r .l1RollupABI .Pack (
10331063 "finalizeBundlePostEuclidV2" ,
0 commit comments