@@ -278,19 +278,6 @@ func (r *Layer2Relayer) initializeGenesis() error {
278
278
}
279
279
280
280
func (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
-
294
281
var calldata []byte
295
282
var packErr error
296
283
@@ -303,18 +290,19 @@ func (r *Layer2Relayer) commitGenesisBatch(batchHash string, batchHeader []byte,
303
290
log .Info ("Validium importGenesis" , "calldata" , common .Bytes2Hex (calldata ))
304
291
} else {
305
292
// 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
+
306
299
calldata , packErr = r .l1RollupABI .Pack ("importGenesisBatch" , batchHeader , stateRoot )
307
300
if packErr != nil {
308
301
return fmt .Errorf ("failed to pack rollup importGenesisBatch with batch header: %v and state root: %v. error: %v" , common .Bytes2Hex (batchHeader ), stateRoot , packErr )
309
302
}
310
303
log .Info ("Rollup importGenesis" , "calldata" , common .Bytes2Hex (calldata ), "stateRoot" , stateRoot )
311
304
}
312
305
313
- // Check generated calldata is not empty
314
- if len (calldata ) == 0 {
315
- return fmt .Errorf ("generated calldata is empty" )
316
- }
317
-
318
306
// submit genesis batch to L1 rollup contract
319
307
txHash , _ , err := r .commitSender .SendTransaction (batchHash , & r .cfg .RollupContractAddress , calldata , nil )
320
308
if err != nil {
@@ -492,12 +480,6 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
492
480
log .Info ("Forcing submission of batches due to timeout" , "batch index" , batchesToSubmit [0 ].Batch .Index , "first block created at" , oldestBlockTimestamp )
493
481
}
494
482
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
-
501
483
// We have at least 1 batch to commit
502
484
firstBatch := batchesToSubmit [0 ].Batch
503
485
lastBatch := batchesToSubmit [len (batchesToSubmit )- 1 ].Batch
@@ -527,9 +509,9 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
527
509
return
528
510
}
529
511
530
- err = r .sanityChecksCommitBatchCodecV7CalldataAndBlobs (calldata , blobs , batchesToSubmit , firstBatch , lastBatch )
512
+ err = r .sanityChecksCommitBatchCodecV7CalldataAndBlobs (calldata , blobs )
531
513
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 )
533
515
return
534
516
}
535
517
}
@@ -972,25 +954,6 @@ func (r *Layer2Relayer) handleL2RollupRelayerConfirmLoop(ctx context.Context) {
972
954
}
973
955
974
956
func (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
-
994
957
var maxBlockHeight uint64
995
958
var totalGasUsed uint64
996
959
blobs := make ([]* kzg4844.Blob , 0 , len (batchesToSubmit ))
@@ -1011,16 +974,6 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
1011
974
return nil , nil , 0 , 0 , fmt .Errorf ("failed to get blocks in range for batch %d: %w" , b .Batch .Index , err )
1012
975
}
1013
976
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
-
1024
977
batchBlocks = append (batchBlocks , blocks ... )
1025
978
1026
979
if c .EndBlockNumber > maxBlockHeight {
@@ -1037,16 +990,6 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
1037
990
Blocks : batchBlocks ,
1038
991
}
1039
992
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
-
1050
993
codec , err := encoding .CodecFromVersion (version )
1051
994
if err != nil {
1052
995
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
1057
1000
return nil , nil , 0 , 0 , fmt .Errorf ("failed to create DA batch: %w" , err )
1058
1001
}
1059
1002
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 ())
1066
1004
}
1067
1005
1068
1006
calldata , err := r .l1RollupABI .Pack ("commitBatches" , version , common .HexToHash (firstBatch .ParentBatchHash ), common .HexToHash (lastBatch .Hash ))
1069
1007
if err != nil {
1070
1008
return nil , nil , 0 , 0 , fmt .Errorf ("failed to pack commitBatches: %w" , err )
1071
1009
}
1072
-
1073
- if len (calldata ) == 0 {
1074
- return nil , nil , 0 , 0 , fmt .Errorf ("generated calldata is empty" )
1075
- }
1076
-
1077
1010
return calldata , blobs , maxBlockHeight , totalGasUsed , nil
1078
1011
}
1079
1012
1080
1013
func (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
-
1090
1014
// Check state root is not zero
1091
1015
stateRoot := common .HexToHash (batch .Batch .StateRoot )
1092
1016
if stateRoot == (common.Hash {}) {
@@ -1128,28 +1052,11 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
1128
1052
return nil , 0 , 0 , fmt .Errorf ("failed to pack commitBatch: %w" , err )
1129
1053
}
1130
1054
1131
- if len (calldata ) == 0 {
1132
- return nil , 0 , 0 , fmt .Errorf ("generated calldata is empty for batch %d" , batch .Batch .Index )
1133
- }
1134
-
1135
1055
log .Info ("Validium commitBatch" , "maxBlockHeight" , maxBlockHeight , "commitment" , commitment .Hex ())
1136
1056
return calldata , maxBlockHeight , totalGasUsed , nil
1137
1057
}
1138
1058
1139
1059
func (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
-
1153
1060
// Check state root is not zero
1154
1061
stateRoot := common .HexToHash (dbBatch .StateRoot )
1155
1062
if stateRoot == (common.Hash {}) {
@@ -1173,11 +1080,6 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
1173
1080
if packErr != nil {
1174
1081
return nil , fmt .Errorf ("failed to pack finalizeBundlePostEuclidV2 with proof: %w" , packErr )
1175
1082
}
1176
-
1177
- if len (calldata ) == 0 {
1178
- return nil , fmt .Errorf ("generated calldata with proof is empty" )
1179
- }
1180
-
1181
1083
return calldata , nil
1182
1084
}
1183
1085
@@ -1194,28 +1096,10 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
1194
1096
if packErr != nil {
1195
1097
return nil , fmt .Errorf ("failed to pack finalizeBundlePostEuclidV2NoProof: %w" , packErr )
1196
1098
}
1197
-
1198
- if len (calldata ) == 0 {
1199
- return nil , fmt .Errorf ("generated calldata without proof is empty" )
1200
- }
1201
-
1202
1099
return calldata , nil
1203
1100
}
1204
1101
1205
1102
func (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
-
1219
1103
// Check proof if present
1220
1104
if aggProof != nil && len (aggProof .Proof ()) == 0 {
1221
1105
return nil , fmt .Errorf ("aggregate proof is empty" )
@@ -1237,11 +1121,6 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadValidium(dbBatch *orm.Batc
1237
1121
if packErr != nil {
1238
1122
return nil , fmt .Errorf ("failed to pack validium finalizeBundle: %w" , packErr )
1239
1123
}
1240
-
1241
- if len (calldata ) == 0 {
1242
- return nil , fmt .Errorf ("generated calldata is empty for batch %d" , dbBatch .Index )
1243
- }
1244
-
1245
1124
return calldata , nil
1246
1125
}
1247
1126
0 commit comments