Skip to content

Commit d6674e8

Browse files
committed
add configuration parameter maxChunksPerBatch for batch proposer
1 parent 55b32e1 commit d6674e8

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

rollup/cmd/rollup_relayer/app/app.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ func action(ctx *cli.Context) error {
9191
if cfg.L2Config.RelayerConfig.BatchSubmission.MaxBatches < 1 {
9292
log.Crit("cfg.L2Config.RelayerConfig.SenderConfig.BatchSubmission.MaxBatches must be at least 1")
9393
}
94+
if cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch <= 0 {
95+
log.Crit("cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch must be greater than 0")
96+
}
9497

9598
l2relayer, err := relayer.NewLayer2Relayer(ctx.Context, l2client, db, cfg.L2Config.RelayerConfig, genesis.Config, initGenesis, relayer.ServiceTypeL2RollupRelayer, registry)
9699
if err != nil {

rollup/conf/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
"max_l1_commit_calldata_size_per_batch": 112345,
108108
"batch_timeout_sec": 300,
109109
"gas_cost_increase_multiplier": 1.2,
110-
"max_uncompressed_batch_bytes_size": 634880
110+
"max_uncompressed_batch_bytes_size": 634880,
111+
"max_chunks_per_batch": 12
111112
},
112113
"bundle_proposer_config": {
113114
"max_batch_num_per_bundle": 20,

rollup/internal/config/l2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type BatchProposerConfig struct {
4747
BatchTimeoutSec uint64 `json:"batch_timeout_sec"`
4848
GasCostIncreaseMultiplier float64 `json:"gas_cost_increase_multiplier"`
4949
MaxUncompressedBatchBytesSize uint64 `json:"max_uncompressed_batch_bytes_size"`
50+
MaxChunksPerBatch int `json:"max_chunks_per_batch"`
5051
}
5152

5253
// BundleProposerConfig loads bundle_proposer configuration items.

rollup/internal/controller/watcher/batch_proposer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type BatchProposer struct {
3232
batchTimeoutSec uint64
3333
gasCostIncreaseMultiplier float64
3434
maxUncompressedBatchBytesSize uint64
35+
maxChunksPerBatch int
3536

3637
minCodecVersion encoding.CodecVersion
3738
chainCfg *params.ChainConfig
@@ -78,6 +79,7 @@ func NewBatchProposer(ctx context.Context, cfg *config.BatchProposerConfig, minC
7879
batchTimeoutSec: cfg.BatchTimeoutSec,
7980
gasCostIncreaseMultiplier: cfg.GasCostIncreaseMultiplier,
8081
maxUncompressedBatchBytesSize: cfg.MaxUncompressedBatchBytesSize,
82+
maxChunksPerBatch: cfg.MaxChunksPerBatch,
8183
minCodecVersion: minCodecVersion,
8284
chainCfg: chainCfg,
8385

@@ -253,8 +255,8 @@ func (p *BatchProposer) proposeBatch() error {
253255
return fmt.Errorf("unsupported codec version: %v, expected at least %v", codec.Version(), p.minCodecVersion)
254256
}
255257

256-
// TODO: should we limit this here for performance reasons with a config parameter? CodecV7 in principle supports endless chunks and returns math.MaxInt here.
257-
maxChunksThisBatch := codec.MaxNumChunksPerBatch()
258+
// always take the minimum of the configured max chunks per batch and the codec's max chunks per batch
259+
maxChunksThisBatch := min(codec.MaxNumChunksPerBatch(), p.maxChunksPerBatch)
258260

259261
// select at most maxChunkNumPerBatch chunks
260262
dbChunks, err := p.chunkOrm.GetChunksGEIndex(p.ctx, firstUnbatchedChunkIndex, maxChunksThisBatch)

0 commit comments

Comments
 (0)