@@ -277,6 +277,19 @@ func (r *Layer2Relayer) initializeGenesis() error {
277277}
278278
279279func (r * Layer2Relayer ) commitGenesisBatch (batchHash string , batchHeader []byte , stateRoot common.Hash ) error {
280+ // Basic sanity checks
281+ if batchHash == "" {
282+ return fmt .Errorf ("batch hash is empty" )
283+ }
284+
285+ if len (batchHeader ) == 0 {
286+ return fmt .Errorf ("batch header is empty" )
287+ }
288+
289+ if stateRoot == (common.Hash {}) {
290+ return fmt .Errorf ("state root is zero" )
291+ }
292+
280293 var calldata []byte
281294 var packErr error
282295
@@ -296,6 +309,11 @@ func (r *Layer2Relayer) commitGenesisBatch(batchHash string, batchHeader []byte,
296309 log .Info ("Rollup importGenesis" , "calldata" , common .Bytes2Hex (calldata ), "stateRoot" , stateRoot )
297310 }
298311
312+ // Check generated calldata is not empty
313+ if len (calldata ) == 0 {
314+ return fmt .Errorf ("generated calldata is empty" )
315+ }
316+
299317 // submit genesis batch to L1 rollup contract
300318 txHash , _ , err := r .commitSender .SendTransaction (batchHash , & r .cfg .RollupContractAddress , calldata , nil )
301319 if err != nil {
@@ -1083,6 +1101,12 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
10831101 return nil , 0 , 0 , fmt .Errorf ("batch %d has no chunks" , batch .Batch .Index )
10841102 }
10851103
1104+ // Check state root is not zero
1105+ stateRoot := common .HexToHash (batch .Batch .StateRoot )
1106+ if stateRoot == (common.Hash {}) {
1107+ return nil , 0 , 0 , fmt .Errorf ("batch %d state root is zero" , batch .Batch .Index )
1108+ }
1109+
10861110 // Calculate metrics
10871111 var maxBlockHeight uint64
10881112 var totalGasUsed uint64
@@ -1102,7 +1126,6 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
11021126
11031127 lastChunk := batch .Chunks [len (batch .Chunks )- 1 ]
11041128 commitment := common .HexToHash (lastChunk .EndBlockHash )
1105-
11061129 if commitment == (common.Hash {}) {
11071130 return nil , 0 , 0 , fmt .Errorf ("batch %d last chunk end block hash is zero, cannot create commitment" , batch .Batch .Index )
11081131 }
@@ -1141,6 +1164,12 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
11411164 return nil , fmt .Errorf ("batch %d header is empty" , dbBatch .Index )
11421165 }
11431166
1167+ // Check state root is not zero
1168+ stateRoot := common .HexToHash (dbBatch .StateRoot )
1169+ if stateRoot == (common.Hash {}) {
1170+ return nil , fmt .Errorf ("batch %d state root is zero" , dbBatch .Index )
1171+ }
1172+
11441173 // Check proof if present
11451174 if aggProof != nil && len (aggProof .Proof ()) == 0 {
11461175 return nil , fmt .Errorf ("aggregate proof is empty" )
@@ -1530,6 +1559,11 @@ func (r *Layer2Relayer) validateBatchFields(batch *dbBatchWithChunks, i int, all
15301559 return fmt .Errorf ("batch %d parent batch hash is zero" , batch .Batch .Index )
15311560 }
15321561
1562+ stateRoot := common .HexToHash (batch .Batch .StateRoot )
1563+ if stateRoot == (common.Hash {}) {
1564+ return fmt .Errorf ("batch %d state root is zero" , batch .Batch .Index )
1565+ }
1566+
15331567 return nil
15341568}
15351569
0 commit comments