@@ -278,19 +278,6 @@ func (r *Layer2Relayer) initializeGenesis() error {
278278}
279279
280280func (r * Layer2Relayer ) commitGenesisBatch (batchHash string , batchHeader []byte , stateRoot common.Hash ) error {
281- // Basic sanity checks
282- if batchHash == "" {
283- return fmt .Errorf ("batch hash is empty" )
284- }
285-
286- if len (batchHeader ) == 0 {
287- return fmt .Errorf ("batch header is empty" )
288- }
289-
290- if stateRoot == (common.Hash {}) {
291- return fmt .Errorf ("state root is zero" )
292- }
293-
294281 var calldata []byte
295282 var packErr error
296283
@@ -303,18 +290,19 @@ func (r *Layer2Relayer) commitGenesisBatch(batchHash string, batchHeader []byte,
303290 log .Info ("Validium importGenesis" , "calldata" , common .Bytes2Hex (calldata ))
304291 } else {
305292 // 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+
306299 calldata , packErr = r .l1RollupABI .Pack ("importGenesisBatch" , batchHeader , stateRoot )
307300 if packErr != nil {
308301 return fmt .Errorf ("failed to pack rollup importGenesisBatch with batch header: %v and state root: %v. error: %v" , common .Bytes2Hex (batchHeader ), stateRoot , packErr )
309302 }
310303 log .Info ("Rollup importGenesis" , "calldata" , common .Bytes2Hex (calldata ), "stateRoot" , stateRoot )
311304 }
312305
313- // Check generated calldata is not empty
314- if len (calldata ) == 0 {
315- return fmt .Errorf ("generated calldata is empty" )
316- }
317-
318306 // submit genesis batch to L1 rollup contract
319307 txHash , _ , err := r .commitSender .SendTransaction (batchHash , & r .cfg .RollupContractAddress , calldata , nil )
320308 if err != nil {
@@ -492,12 +480,6 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
492480 log .Info ("Forcing submission of batches due to timeout" , "batch index" , batchesToSubmit [0 ].Batch .Index , "first block created at" , oldestBlockTimestamp )
493481 }
494482
495- // Sanity checks before constructing the transaction
496- if err := r .sanityChecksBeforeConstructingTransaction (batchesToSubmit ); err != nil {
497- log .Error ("Sanity checks failed before constructing transaction" , "batches count" , len (batchesToSubmit ), "first batch index" , batchesToSubmit [0 ].Batch .Index , "last batch index" , batchesToSubmit [len (batchesToSubmit )- 1 ].Batch .Index , "err" , err )
498- return
499- }
500-
501483 // We have at least 1 batch to commit
502484 firstBatch := batchesToSubmit [0 ].Batch
503485 lastBatch := batchesToSubmit [len (batchesToSubmit )- 1 ].Batch
@@ -527,9 +509,9 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
527509 return
528510 }
529511
530- err = r .sanityChecksCommitBatchCodecV7CalldataAndBlobs (calldata , blobs , batchesToSubmit , firstBatch , lastBatch )
512+ err = r .sanityChecksCommitBatchCodecV7CalldataAndBlobs (calldata , blobs )
531513 if err != nil {
532- log .Error ("Sanity check failed for calldata and blobs" , "err" , err )
514+ log .Error ("Sanity check failed for calldata and blobs" , "codecVersion" , codecVersion , "start index" , firstBatch . Index , "end index" , lastBatch . Index , " err" , err )
533515 return
534516 }
535517 }
@@ -972,25 +954,6 @@ func (r *Layer2Relayer) handleL2RollupRelayerConfirmLoop(ctx context.Context) {
972954}
973955
974956func (r * Layer2Relayer ) constructCommitBatchPayloadCodecV7 (batchesToSubmit []* dbBatchWithChunks , firstBatch , lastBatch * orm.Batch ) ([]byte , []* kzg4844.Blob , uint64 , uint64 , error ) {
975- // Basic sanity checks
976- if len (batchesToSubmit ) == 0 {
977- return nil , nil , 0 , 0 , fmt .Errorf ("no batches to submit" )
978- }
979- if firstBatch == nil {
980- return nil , nil , 0 , 0 , fmt .Errorf ("first batch is nil" )
981- }
982- if lastBatch == nil {
983- return nil , nil , 0 , 0 , fmt .Errorf ("last batch is nil" )
984- }
985-
986- // Check firstBatch and lastBatch match batchesToSubmit
987- if firstBatch .Index != batchesToSubmit [0 ].Batch .Index {
988- return nil , nil , 0 , 0 , fmt .Errorf ("first batch index mismatch: expected %d, got %d" , batchesToSubmit [0 ].Batch .Index , firstBatch .Index )
989- }
990- if lastBatch .Index != batchesToSubmit [len (batchesToSubmit )- 1 ].Batch .Index {
991- return nil , nil , 0 , 0 , fmt .Errorf ("last batch index mismatch: expected %d, got %d" , batchesToSubmit [len (batchesToSubmit )- 1 ].Batch .Index , lastBatch .Index )
992- }
993-
994957 var maxBlockHeight uint64
995958 var totalGasUsed uint64
996959 blobs := make ([]* kzg4844.Blob , 0 , len (batchesToSubmit ))
@@ -1011,16 +974,6 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
1011974 return nil , nil , 0 , 0 , fmt .Errorf ("failed to get blocks in range for batch %d: %w" , b .Batch .Index , err )
1012975 }
1013976
1014- if len (blocks ) == 0 {
1015- return nil , nil , 0 , 0 , fmt .Errorf ("batch %d chunk %d has no blocks in range [%d, %d]" , b .Batch .Index , c .Index , c .StartBlockNumber , c .EndBlockNumber )
1016- }
1017-
1018- // Check that we got the expected number of blocks
1019- expectedBlockCount := c .EndBlockNumber - c .StartBlockNumber + 1
1020- if uint64 (len (blocks )) != expectedBlockCount {
1021- return nil , nil , 0 , 0 , fmt .Errorf ("batch %d chunk %d expected %d blocks but got %d" , b .Batch .Index , c .Index , expectedBlockCount , len (blocks ))
1022- }
1023-
1024977 batchBlocks = append (batchBlocks , blocks ... )
1025978
1026979 if c .EndBlockNumber > maxBlockHeight {
@@ -1037,16 +990,6 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
1037990 Blocks : batchBlocks ,
1038991 }
1039992
1040- // Check encoding batch fields are not zero hashes
1041- if encodingBatch .ParentBatchHash == (common.Hash {}) {
1042- return nil , nil , 0 , 0 , fmt .Errorf ("batch %d parent batch hash is zero" , b .Batch .Index )
1043- }
1044-
1045- // Check L1 message queue hash consistency
1046- if err := r .validateMessageQueueConsistency (encodingBatch .Index , b .Chunks , encodingBatch .PrevL1MessageQueueHash , encodingBatch .PostL1MessageQueueHash ); err != nil {
1047- return nil , nil , 0 , 0 , err
1048- }
1049-
1050993 codec , err := encoding .CodecFromVersion (version )
1051994 if err != nil {
1052995 return nil , nil , 0 , 0 , fmt .Errorf ("failed to get codec from version %d, err: %w" , b .Batch .CodecVersion , err )
@@ -1057,36 +1000,17 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
10571000 return nil , nil , 0 , 0 , fmt .Errorf ("failed to create DA batch: %w" , err )
10581001 }
10591002
1060- blob := daBatch .Blob ()
1061- if blob == nil {
1062- return nil , nil , 0 , 0 , fmt .Errorf ("batch %d generated nil blob" , b .Batch .Index )
1063- }
1064-
1065- blobs = append (blobs , blob )
1003+ blobs = append (blobs , daBatch .Blob ())
10661004 }
10671005
10681006 calldata , err := r .l1RollupABI .Pack ("commitBatches" , version , common .HexToHash (firstBatch .ParentBatchHash ), common .HexToHash (lastBatch .Hash ))
10691007 if err != nil {
10701008 return nil , nil , 0 , 0 , fmt .Errorf ("failed to pack commitBatches: %w" , err )
10711009 }
1072-
1073- if len (calldata ) == 0 {
1074- return nil , nil , 0 , 0 , fmt .Errorf ("generated calldata is empty" )
1075- }
1076-
10771010 return calldata , blobs , maxBlockHeight , totalGasUsed , nil
10781011}
10791012
10801013func (r * Layer2Relayer ) constructCommitBatchPayloadValidium (batch * dbBatchWithChunks ) ([]byte , uint64 , uint64 , error ) {
1081- // Basic sanity checks
1082- if batch == nil || batch .Batch == nil {
1083- return nil , 0 , 0 , fmt .Errorf ("batch is nil" )
1084- }
1085-
1086- if len (batch .Chunks ) == 0 {
1087- return nil , 0 , 0 , fmt .Errorf ("batch %d has no chunks" , batch .Batch .Index )
1088- }
1089-
10901014 // Check state root is not zero
10911015 stateRoot := common .HexToHash (batch .Batch .StateRoot )
10921016 if stateRoot == (common.Hash {}) {
@@ -1128,28 +1052,11 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
11281052 return nil , 0 , 0 , fmt .Errorf ("failed to pack commitBatch: %w" , err )
11291053 }
11301054
1131- if len (calldata ) == 0 {
1132- return nil , 0 , 0 , fmt .Errorf ("generated calldata is empty for batch %d" , batch .Batch .Index )
1133- }
1134-
11351055 log .Info ("Validium commitBatch" , "maxBlockHeight" , maxBlockHeight , "commitment" , commitment .Hex ())
11361056 return calldata , maxBlockHeight , totalGasUsed , nil
11371057}
11381058
11391059func (r * Layer2Relayer ) constructFinalizeBundlePayloadCodecV7 (dbBatch * orm.Batch , endChunk * orm.Chunk , aggProof * message.OpenVMBundleProof ) ([]byte , error ) {
1140- // Basic sanity checks
1141- if dbBatch == nil {
1142- return nil , fmt .Errorf ("batch is nil" )
1143- }
1144- if endChunk == nil {
1145- return nil , fmt .Errorf ("end chunk is nil" )
1146- }
1147-
1148- // Check batch header
1149- if len (dbBatch .BatchHeader ) == 0 {
1150- return nil , fmt .Errorf ("batch %d header is empty" , dbBatch .Index )
1151- }
1152-
11531060 // Check state root is not zero
11541061 stateRoot := common .HexToHash (dbBatch .StateRoot )
11551062 if stateRoot == (common.Hash {}) {
@@ -1173,11 +1080,6 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
11731080 if packErr != nil {
11741081 return nil , fmt .Errorf ("failed to pack finalizeBundlePostEuclidV2 with proof: %w" , packErr )
11751082 }
1176-
1177- if len (calldata ) == 0 {
1178- return nil , fmt .Errorf ("generated calldata with proof is empty" )
1179- }
1180-
11811083 return calldata , nil
11821084 }
11831085
@@ -1194,28 +1096,10 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
11941096 if packErr != nil {
11951097 return nil , fmt .Errorf ("failed to pack finalizeBundlePostEuclidV2NoProof: %w" , packErr )
11961098 }
1197-
1198- if len (calldata ) == 0 {
1199- return nil , fmt .Errorf ("generated calldata without proof is empty" )
1200- }
1201-
12021099 return calldata , nil
12031100}
12041101
12051102func (r * Layer2Relayer ) constructFinalizeBundlePayloadValidium (dbBatch * orm.Batch , endChunk * orm.Chunk , aggProof * message.OpenVMBundleProof ) ([]byte , error ) {
1206- // Basic sanity checks
1207- if dbBatch == nil {
1208- return nil , fmt .Errorf ("batch is nil" )
1209- }
1210- if endChunk == nil {
1211- return nil , fmt .Errorf ("end chunk is nil" )
1212- }
1213-
1214- // Check batch header is not empty
1215- if len (dbBatch .BatchHeader ) == 0 {
1216- return nil , fmt .Errorf ("batch %d header is empty" , dbBatch .Index )
1217- }
1218-
12191103 // Check proof if present
12201104 if aggProof != nil && len (aggProof .Proof ()) == 0 {
12211105 return nil , fmt .Errorf ("aggregate proof is empty" )
@@ -1237,11 +1121,6 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadValidium(dbBatch *orm.Batc
12371121 if packErr != nil {
12381122 return nil , fmt .Errorf ("failed to pack validium finalizeBundle: %w" , packErr )
12391123 }
1240-
1241- if len (calldata ) == 0 {
1242- return nil , fmt .Errorf ("generated calldata is empty for batch %d" , dbBatch .Index )
1243- }
1244-
12451124 return calldata , nil
12461125}
12471126
0 commit comments