Skip to content

Commit 121ce09

Browse files
committed
update config and adjust to new contract ABI
1 parent 0125dd6 commit 121ce09

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

rollup/cmd/rollup_relayer/app/app.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ func action(ctx *cli.Context) error {
8282
initGenesis := ctx.Bool(utils.ImportGenesisFlag.Name)
8383

8484
// sanity check config
85-
if cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MinBatches < 1 {
85+
if cfg.L2Config.RelayerConfig.BatchSubmission == nil {
86+
log.Crit("cfg.L2Config.RelayerConfig.BatchSubmission must not be nil")
87+
}
88+
if cfg.L2Config.RelayerConfig.BatchSubmission.MinBatches < 1 {
8689
log.Crit("cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MinBatches must be at least 1")
8790
}
88-
if cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MaxBatches < 1 {
91+
if cfg.L2Config.RelayerConfig.BatchSubmission.MaxBatches < 1 {
8992
log.Crit("cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MaxBatches must be at least 1")
9093
}
9194

rollup/conf/config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
"tx_type": "DynamicFeeTx",
5050
"check_pending_time": 1,
5151
"min_gas_tip": 100000000,
52-
"max_pending_blob_txs": 3,
53-
"batch_submission": {
54-
"min_batches": 1,
55-
"max_batches": 6,
56-
"timeout": 300
57-
}
52+
"max_pending_blob_txs": 3
53+
},
54+
"batch_submission": {
55+
"min_batches": 1,
56+
"max_batches": 6,
57+
"timeout": 300
5858
},
5959
"gas_oracle_config": {
6060
"min_gas_price": 0,

rollup/internal/config/relayer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ type SenderConfig struct {
2929
TxType string `json:"tx_type"`
3030
// The maximum number of pending blob-carrying transactions
3131
MaxPendingBlobTxs int64 `json:"max_pending_blob_txs"`
32-
33-
// Config for batch submission
34-
BatchSubmission *BatchSubmission `json:"batch_submission"`
3532
}
3633

3734
type BatchSubmission struct {
@@ -60,6 +57,8 @@ type RelayerConfig struct {
6057
GasPriceOracleContractAddress common.Address `json:"gas_price_oracle_contract_address"`
6158
// sender config
6259
SenderConfig *SenderConfig `json:"sender_config"`
60+
// Config for batch submission
61+
BatchSubmission *BatchSubmission `json:"batch_submission"`
6362
// gas oracle config
6463
GasOracleConfig *GasOracleConfig `json:"gas_oracle_config"`
6564
// ChainMonitor config of monitoring service

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
378378
// ProcessPendingBatches processes the pending batches by sending commitBatch transactions to layer 1.
379379
func (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

12181218
func (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

Comments
 (0)