@@ -378,7 +378,7 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
378378// ProcessPendingBatches processes the pending batches by sending commitBatch transactions to layer 1.
379379func (r * Layer2Relayer ) ProcessPendingBatches () {
380380 // get pending batches from database in ascending order by their index.
381- dbBatches , err := r .batchOrm .GetFailedAndPendingBatches (r .ctx , r .cfg .SenderConfig . BatchSubmission .MaxBatches )
381+ dbBatches , err := r .batchOrm .GetFailedAndPendingBatches (r .ctx , r .cfg .BatchSubmission .MaxBatches )
382382 if err != nil {
383383 log .Error ("Failed to fetch pending L2 batches" , "err" , err )
384384 return
@@ -447,26 +447,26 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
447447 }
448448
449449 // if one of the batches is too old, we force submit all batches that we have so far in the next step
450- if r .cfg .SenderConfig . BatchSubmission .TimeoutSec > 0 && ! forceSubmit && time .Since (dbBatch .CreatedAt ) > time .Duration (r .cfg . SenderConfig .BatchSubmission .TimeoutSec )* time .Second {
450+ if r .cfg .BatchSubmission .TimeoutSec > 0 && ! forceSubmit && time .Since (dbBatch .CreatedAt ) > time .Duration (r .cfg .BatchSubmission .TimeoutSec )* time .Second {
451451 forceSubmit = true
452452 }
453453
454- if batchesToSubmitLen < r .cfg .SenderConfig . BatchSubmission .MaxBatches {
454+ if batchesToSubmitLen < r .cfg .BatchSubmission .MaxBatches {
455455 batchesToSubmit = append (batchesToSubmit , & dbBatchWithChunksAndParent {
456456 Batch : dbBatch ,
457457 Chunks : dbChunks ,
458458 ParentBatch : dbParentBatch ,
459459 })
460460 }
461461
462- if len (batchesToSubmit ) >= r .cfg .SenderConfig . BatchSubmission .MaxBatches {
462+ if len (batchesToSubmit ) >= r .cfg .BatchSubmission .MaxBatches {
463463 break
464464 }
465465 }
466466
467467 // we only submit batches if we have a timeout or if we have enough batches to submit
468- if ! forceSubmit && len (batchesToSubmit ) < r .cfg .SenderConfig . BatchSubmission .MinBatches {
469- log .Info ("Not enough batches to submit" , "count" , len (batchesToSubmit ), "minBatches" , r .cfg .SenderConfig . BatchSubmission .MinBatches , "maxBatches" , r .cfg . SenderConfig .BatchSubmission .MaxBatches )
468+ if ! forceSubmit && len (batchesToSubmit ) < r .cfg .BatchSubmission .MinBatches {
469+ log .Debug ("Not enough batches to submit" , "count" , len (batchesToSubmit ), "minBatches" , r .cfg .BatchSubmission .MinBatches , "maxBatches" , r .cfg .BatchSubmission .MaxBatches )
470470 return
471471 }
472472
@@ -486,7 +486,7 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
486486 codecVersion := encoding .CodecVersion (firstBatch .CodecVersion )
487487 switch codecVersion {
488488 case encoding .CodecV7 :
489- calldata , blobs , maxBlockHeight , totalGasUsed , err = r .constructCommitBatchPayloadCodecV7 (batchesToSubmit , lastBatch )
489+ calldata , blobs , maxBlockHeight , totalGasUsed , err = r .constructCommitBatchPayloadCodecV7 (batchesToSubmit , firstBatch , lastBatch )
490490 if err != nil {
491491 log .Error ("failed to construct constructCommitBatchPayloadCodecV7 payload for V7" , "codecVersion" , codecVersion , "start index" , firstBatch .Index , "end index" , lastBatch .Index , "err" , err )
492492 return
@@ -837,6 +837,7 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error
837837 hardForkName := encoding .GetHardforkName (r .chainCfg , firstChunk .StartBlockNumber , firstChunk .StartBlockTime )
838838
839839 var aggProof message.BundleProof
840+ withProof = false
840841 if withProof {
841842 aggProof , err = r .bundleOrm .GetVerifiedProofByHash (r .ctx , bundle .Hash , hardForkName )
842843 if err != nil {
@@ -1129,7 +1130,7 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV4(dbBatch *orm.Batch, d
11291130 return calldata , daBatch .Blob (), nil
11301131}
11311132
1132- func (r * Layer2Relayer ) constructCommitBatchPayloadCodecV7 (batchesToSubmit []* dbBatchWithChunksAndParent , lastBatch * orm.Batch ) ([]byte , []* kzg4844.Blob , uint64 , uint64 , error ) {
1133+ func (r * Layer2Relayer ) constructCommitBatchPayloadCodecV7 (batchesToSubmit []* dbBatchWithChunksAndParent , firstBatch , lastBatch * orm.Batch ) ([]byte , []* kzg4844.Blob , uint64 , uint64 , error ) {
11331134 var maxBlockHeight uint64
11341135 var totalGasUsed uint64
11351136 blobs := make ([]* kzg4844.Blob , 0 , len (batchesToSubmit ))
@@ -1179,8 +1180,7 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV7(batchesToSubmit []*db
11791180 blobs = append (blobs , daBatch .Blob ())
11801181 }
11811182
1182- // TODO: this needs to be updated once the contract interface is finalized
1183- calldata , err := r .l1RollupABI .Pack ("commitBatches" , version , common .HexToHash (lastBatch .Hash ))
1183+ calldata , err := r .l1RollupABI .Pack ("commitBatches" , version , common .HexToHash (firstBatch .ParentBatchHash ), common .HexToHash (lastBatch .Hash ))
11841184 if err != nil {
11851185 return nil , nil , 0 , 0 , fmt .Errorf ("failed to pack commitBatches: %w" , err )
11861186 }
@@ -1216,7 +1216,6 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV4(dbBatch *orm.Batch
12161216}
12171217
12181218func (r * Layer2Relayer ) constructFinalizeBundlePayloadCodecV7 (dbBatch * orm.Batch , endChunk * orm.Chunk , aggProof message.BundleProof ) ([]byte , error ) {
1219- // TODO: update this once the contract interface is finalized
12201219 if aggProof != nil { // finalizeBundle with proof.
12211220 calldata , packErr := r .l1RollupABI .Pack (
12221221 "finalizeBundlePostEuclidV2" ,
@@ -1234,15 +1233,14 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV7(dbBatch *orm.Batch
12341233
12351234 // finalizeBundle without proof.
12361235 calldata , packErr := r .l1RollupABI .Pack (
1237- "finalizeBundlePostEuclidV2 " ,
1236+ "finalizeBundlePostEuclidV2NoProof " ,
12381237 dbBatch .BatchHeader ,
12391238 new (big.Int ).SetUint64 (endChunk .TotalL1MessagesPoppedBefore + endChunk .TotalL1MessagesPoppedInChunk ),
12401239 common .HexToHash (dbBatch .StateRoot ),
12411240 common .HexToHash (dbBatch .WithdrawRoot ),
1242- []byte {}, // TODO: remove after renaming function in contract
12431241 )
12441242 if packErr != nil {
1245- return nil , fmt .Errorf ("failed to pack finalizeBundle : %w" , packErr )
1243+ return nil , fmt .Errorf ("failed to pack finalizeBundlePostEuclidV2NoProof : %w" , packErr )
12461244 }
12471245 return calldata , nil
12481246}
0 commit comments