Skip to content

Commit a1c4562

Browse files
jonastheiscolinlyguo
authored andcommitted
add configuration parameter maxChunksPerBatch for batch proposer
1 parent e27ab5a commit a1c4562

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

rollup/cmd/rollup_relayer/app/app.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func action(ctx *cli.Context) error {
8080
}
8181

8282
initGenesis := ctx.Bool(utils.ImportGenesisFlag.Name)
83+
84+
// sanity check config
85+
if cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch <= 0 {
86+
log.Crit("cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch must be greater than 0")
87+
}
88+
8389
l2relayer, err := relayer.NewLayer2Relayer(ctx.Context, l2client, db, cfg.L2Config.RelayerConfig, genesis.Config, initGenesis, relayer.ServiceTypeL2RollupRelayer, registry)
8490
if err != nil {
8591
log.Crit("failed to create l2 relayer", "config file", cfgFile, "error", err)

rollup/conf/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
"max_l1_commit_calldata_size_per_batch": 112345,
103103
"batch_timeout_sec": 300,
104104
"gas_cost_increase_multiplier": 1.2,
105-
"max_uncompressed_batch_bytes_size": 634880
105+
"max_uncompressed_batch_bytes_size": 634880,
106+
"max_chunks_per_batch": 12
106107
},
107108
"bundle_proposer_config": {
108109
"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 & 1 deletion
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,7 +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-
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)
257260

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

0 commit comments

Comments
 (0)