Skip to content

Commit 10a5802

Browse files
committed
add max_uncompressed_batch_bytes_size
1 parent aa4e5db commit 10a5802

File tree

12 files changed

+81
-57
lines changed

12 files changed

+81
-57
lines changed

rollup/conf/config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@
9494
"propose_interval_milliseconds": 100,
9595
"max_block_num_per_chunk": 100,
9696
"max_l2_gas_per_chunk": 20000000,
97-
"chunk_timeout_sec": 300
97+
"chunk_timeout_sec": 300,
98+
"max_uncompressed_batch_bytes_size": 4000000
9899
},
99100
"batch_proposer_config": {
100101
"propose_interval_milliseconds": 1000,
101102
"batch_timeout_sec": 300,
102-
"max_chunks_per_batch": 45
103+
"max_chunks_per_batch": 45,
104+
"max_uncompressed_batch_bytes_size": 4000000
103105
},
104106
"bundle_proposer_config": {
105107
"max_batch_num_per_bundle": 20,

rollup/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/holiman/uint256 v1.3.2
1616
github.com/mitchellh/mapstructure v1.5.0
1717
github.com/prometheus/client_golang v1.16.0
18-
github.com/scroll-tech/da-codec v0.1.3-0.20250622220508-c89e7e5e42f9
18+
github.com/scroll-tech/da-codec v0.1.3-0.20250623141222-9e6ea1d439fa
1919
github.com/scroll-tech/go-ethereum v1.10.14-0.20250611141528-cf3d22ef8707
2020
github.com/smartystreets/goconvey v1.8.0
2121
github.com/spf13/viper v1.19.0

rollup/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
285285
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
286286
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
287287
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
288-
github.com/scroll-tech/da-codec v0.1.3-0.20250622220508-c89e7e5e42f9 h1:0TsRwqi159i8nMG0O6kgP7q8fF1/eygWTSrT1z5jiO8=
289-
github.com/scroll-tech/da-codec v0.1.3-0.20250622220508-c89e7e5e42f9/go.mod h1:T+370kLxwACnmWaq4rgtKGyLCd7QSE6iy0JLfCp1qj4=
288+
github.com/scroll-tech/da-codec v0.1.3-0.20250623141222-9e6ea1d439fa h1:IwobY81o8LeI1kV4WkbaYFh6oDtAfheFjUO/dapkNlE=
289+
github.com/scroll-tech/da-codec v0.1.3-0.20250623141222-9e6ea1d439fa/go.mod h1:T+370kLxwACnmWaq4rgtKGyLCd7QSE6iy0JLfCp1qj4=
290290
github.com/scroll-tech/go-ethereum v1.10.14-0.20250611141528-cf3d22ef8707 h1:rC6eEsAwSG1VzNT48fLM00rqwTGWPckiipmFC8D6D5o=
291291
github.com/scroll-tech/go-ethereum v1.10.14-0.20250611141528-cf3d22ef8707/go.mod h1:756YMENiSfx/5pCwKq3+uSTWjXuHTbiCB+TirJjsQT8=
292292
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=

rollup/internal/config/l2.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ type L2Config struct {
3030

3131
// ChunkProposerConfig loads chunk_proposer configuration items.
3232
type ChunkProposerConfig struct {
33-
ProposeIntervalMilliseconds uint64 `json:"propose_interval_milliseconds"`
34-
MaxBlockNumPerChunk uint64 `json:"max_block_num_per_chunk"`
35-
MaxL2GasPerChunk uint64 `json:"max_l2_gas_per_chunk"`
36-
ChunkTimeoutSec uint64 `json:"chunk_timeout_sec"`
33+
ProposeIntervalMilliseconds uint64 `json:"propose_interval_milliseconds"`
34+
MaxBlockNumPerChunk uint64 `json:"max_block_num_per_chunk"`
35+
MaxL2GasPerChunk uint64 `json:"max_l2_gas_per_chunk"`
36+
ChunkTimeoutSec uint64 `json:"chunk_timeout_sec"`
37+
MaxUncompressedBatchBytesSize uint64 `json:"max_uncompressed_batch_bytes_size"`
3738
}
3839

3940
// BatchProposerConfig loads batch_proposer configuration items.
4041
type BatchProposerConfig struct {
41-
ProposeIntervalMilliseconds uint64 `json:"propose_interval_milliseconds"`
42-
BatchTimeoutSec uint64 `json:"batch_timeout_sec"`
43-
MaxChunksPerBatch int `json:"max_chunks_per_batch"`
42+
ProposeIntervalMilliseconds uint64 `json:"propose_interval_milliseconds"`
43+
BatchTimeoutSec uint64 `json:"batch_timeout_sec"`
44+
MaxChunksPerBatch int `json:"max_chunks_per_batch"`
45+
MaxUncompressedBatchBytesSize uint64 `json:"max_uncompressed_batch_bytes_size"`
4446
}
4547

4648
// BundleProposerConfig loads bundle_proposer configuration items.

rollup/internal/controller/watcher/batch_proposer.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type BatchProposer struct {
5454

5555
// NewBatchProposer creates a new BatchProposer instance.
5656
func NewBatchProposer(ctx context.Context, cfg *config.BatchProposerConfig, minCodecVersion encoding.CodecVersion, chainCfg *params.ChainConfig, db *gorm.DB, reg prometheus.Registerer) *BatchProposer {
57-
log.Info("new batch proposer", "batchTimeoutSec", cfg.BatchTimeoutSec, "maxBlobSize", maxBlobSize)
57+
log.Info("new batch proposer", "batchTimeoutSec", cfg.BatchTimeoutSec, "maxBlobSize", maxBlobSize, "maxUncompressedBatchBytesSize", cfg.MaxUncompressedBatchBytesSize)
5858

5959
p := &BatchProposer{
6060
ctx: ctx,
@@ -294,16 +294,18 @@ func (p *BatchProposer) proposeBatch() error {
294294

295295
p.recordTimerBatchMetrics(metrics)
296296

297-
if metrics.L1CommitBlobSize > maxBlobSize {
297+
if metrics.L1CommitBlobSize > maxBlobSize || metrics.L1CommitUncompressedBatchBytesSize > p.cfg.MaxUncompressedBatchBytesSize {
298298
if i == 0 {
299299
// The first chunk exceeds hard limits, which indicates a bug in the chunk-proposer, manual fix is needed.
300-
return fmt.Errorf("the first chunk exceeds limits; start block number: %v, end block number: %v, limits: %+v, maxChunkNum: %v, maxBlobSize: %v",
301-
dbChunks[0].StartBlockNumber, dbChunks[0].EndBlockNumber, metrics, maxChunksThisBatch, maxBlobSize)
300+
return fmt.Errorf("the first chunk exceeds limits; start block number: %v, end block number: %v, limits: %+v, maxChunkNum: %v, maxBlobSize: %v, maxUncompressedBatchBytesSize: %v",
301+
dbChunks[0].StartBlockNumber, dbChunks[0].EndBlockNumber, metrics, maxChunksThisBatch, maxBlobSize, p.cfg.MaxUncompressedBatchBytesSize)
302302
}
303303

304304
log.Debug("breaking limit condition in batching",
305305
"l1CommitBlobSize", metrics.L1CommitBlobSize,
306-
"maxBlobSize", maxBlobSize)
306+
"maxBlobSize", maxBlobSize,
307+
"L1CommitUncompressedBatchBytesSize", metrics.L1CommitUncompressedBatchBytesSize,
308+
"maxUncompressedBatchBytesSize", p.cfg.MaxUncompressedBatchBytesSize)
307309

308310
lastChunk := batch.Chunks[len(batch.Chunks)-1]
309311
batch.Chunks = batch.Chunks[:len(batch.Chunks)-1]

rollup/internal/controller/watcher/batch_proposer_test.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ func testBatchProposerLimitsCodecV7(t *testing.T) {
7272
assert.NoError(t, err)
7373

7474
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
75-
MaxBlockNumPerChunk: 1,
76-
MaxL2GasPerChunk: 20000000,
77-
ChunkTimeoutSec: 300,
75+
MaxBlockNumPerChunk: 1,
76+
MaxL2GasPerChunk: 20000000,
77+
ChunkTimeoutSec: 300,
78+
MaxUncompressedBatchBytesSize: 4000000,
7879
}, encoding.CodecV7, &params.ChainConfig{
7980
LondonBlock: big.NewInt(0),
8081
BernoulliBlock: big.NewInt(0),
@@ -88,8 +89,9 @@ func testBatchProposerLimitsCodecV7(t *testing.T) {
8889
cp.TryProposeChunk() // chunk2 contains block2
8990

9091
bp := NewBatchProposer(context.Background(), &config.BatchProposerConfig{
91-
MaxChunksPerBatch: math.MaxInt32,
92-
BatchTimeoutSec: tt.batchTimeoutSec,
92+
MaxChunksPerBatch: math.MaxInt32,
93+
BatchTimeoutSec: tt.batchTimeoutSec,
94+
MaxUncompressedBatchBytesSize: 4000000,
9395
}, encoding.CodecV7, &params.ChainConfig{
9496
LondonBlock: big.NewInt(0),
9597
BernoulliBlock: big.NewInt(0),
@@ -152,9 +154,10 @@ func testBatchProposerBlobSizeLimitCodecV7(t *testing.T) {
152154
chainConfig := &params.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64), EuclidTime: new(uint64), EuclidV2Time: new(uint64)}
153155

154156
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
155-
MaxBlockNumPerChunk: math.MaxUint64,
156-
MaxL2GasPerChunk: math.MaxUint64,
157-
ChunkTimeoutSec: 0,
157+
MaxBlockNumPerChunk: math.MaxUint64,
158+
MaxL2GasPerChunk: math.MaxUint64,
159+
ChunkTimeoutSec: 0,
160+
MaxUncompressedBatchBytesSize: 4000000,
158161
}, encoding.CodecV7, chainConfig, db, nil)
159162

160163
blockHeight := uint64(0)
@@ -172,8 +175,9 @@ func testBatchProposerBlobSizeLimitCodecV7(t *testing.T) {
172175
}
173176

174177
bp := NewBatchProposer(context.Background(), &config.BatchProposerConfig{
175-
MaxChunksPerBatch: math.MaxInt32,
176-
BatchTimeoutSec: math.MaxUint32,
178+
MaxChunksPerBatch: math.MaxInt32,
179+
BatchTimeoutSec: math.MaxUint32,
180+
MaxUncompressedBatchBytesSize: 4000000,
177181
}, encoding.CodecV7, chainConfig, db, nil)
178182

179183
for i := 0; i < 2; i++ {
@@ -223,9 +227,10 @@ func testBatchProposerMaxChunkNumPerBatchLimitCodecV7(t *testing.T) {
223227
chainConfig := &params.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64), EuclidTime: new(uint64), EuclidV2Time: new(uint64)}
224228

225229
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
226-
MaxBlockNumPerChunk: math.MaxUint64,
227-
MaxL2GasPerChunk: math.MaxUint64,
228-
ChunkTimeoutSec: 0,
230+
MaxBlockNumPerChunk: math.MaxUint64,
231+
MaxL2GasPerChunk: math.MaxUint64,
232+
ChunkTimeoutSec: 0,
233+
MaxUncompressedBatchBytesSize: 4000000,
229234
}, encoding.CodecV7, chainConfig, db, nil)
230235

231236
block = readBlockFromJSON(t, "../../../testdata/blockTrace_03.json")
@@ -238,8 +243,9 @@ func testBatchProposerMaxChunkNumPerBatchLimitCodecV7(t *testing.T) {
238243
}
239244

240245
bp := NewBatchProposer(context.Background(), &config.BatchProposerConfig{
241-
MaxChunksPerBatch: 45,
242-
BatchTimeoutSec: math.MaxUint32,
246+
MaxChunksPerBatch: 45,
247+
BatchTimeoutSec: math.MaxUint32,
248+
MaxUncompressedBatchBytesSize: 4000000,
243249
}, encoding.CodecV7, chainConfig, db, nil)
244250
bp.TryProposeBatch()
245251

rollup/internal/controller/watcher/bundle_proposer_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,16 @@ func testBundleProposerLimitsCodecV7(t *testing.T) {
9393
chainConfig := &params.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64), EuclidTime: new(uint64), EuclidV2Time: new(uint64)}
9494

9595
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
96-
MaxBlockNumPerChunk: 1,
97-
MaxL2GasPerChunk: math.MaxUint64,
98-
ChunkTimeoutSec: math.MaxUint32,
96+
MaxBlockNumPerChunk: 1,
97+
MaxL2GasPerChunk: math.MaxUint64,
98+
ChunkTimeoutSec: math.MaxUint32,
99+
MaxUncompressedBatchBytesSize: 4000000,
99100
}, encoding.CodecV7, chainConfig, db, nil)
100101

101102
bap := NewBatchProposer(context.Background(), &config.BatchProposerConfig{
102-
MaxChunksPerBatch: math.MaxInt32,
103-
BatchTimeoutSec: 0,
103+
MaxChunksPerBatch: math.MaxInt32,
104+
BatchTimeoutSec: 0,
105+
MaxUncompressedBatchBytesSize: 4000000,
104106
}, encoding.CodecV7, chainConfig, db, nil)
105107

106108
cp.TryProposeChunk() // chunk1 contains block1

rollup/internal/controller/watcher/chunk_proposer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,19 @@ func (p *ChunkProposer) proposeChunk() error {
295295

296296
p.recordTimerChunkMetrics(metrics)
297297

298-
if metrics.L2Gas > p.cfg.MaxL2GasPerChunk || metrics.L1CommitBlobSize > maxBlobSize {
298+
if metrics.L2Gas > p.cfg.MaxL2GasPerChunk || metrics.L1CommitBlobSize > maxBlobSize || metrics.L1CommitUncompressedBatchBytesSize > p.cfg.MaxUncompressedBatchBytesSize {
299299
if i == 0 {
300300
// The first block exceeds hard limits, which indicates a bug in the sequencer, manual fix is needed.
301-
return fmt.Errorf("the first block exceeds limits; block number: %v, limits: %+v, maxBlobSize: %v", block.Header.Number, metrics, maxBlobSize)
301+
return fmt.Errorf("the first block exceeds limits; block number: %v, limits: %+v, maxBlobSize: %v, maxUncompressedBatchBytesSize: %v", block.Header.Number, metrics, maxBlobSize, p.cfg.MaxUncompressedBatchBytesSize)
302302
}
303303

304304
log.Debug("breaking limit condition in chunking",
305305
"l2Gas", metrics.L2Gas,
306306
"maxL2Gas", p.cfg.MaxL2GasPerChunk,
307307
"l1CommitBlobSize", metrics.L1CommitBlobSize,
308-
"maxBlobSize", maxBlobSize)
308+
"maxBlobSize", maxBlobSize,
309+
"L1CommitUncompressedBatchBytesSize", metrics.L1CommitUncompressedBatchBytesSize,
310+
"maxUncompressedBatchBytesSize", p.cfg.MaxUncompressedBatchBytesSize)
309311

310312
chunk.Blocks = chunk.Blocks[:len(chunk.Blocks)-1]
311313
chunk.PostL1MessageQueueHash = previousPostL1MessageQueueHash

rollup/internal/controller/watcher/chunk_proposer_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ func testChunkProposerLimitsCodecV7(t *testing.T) {
8484
assert.NoError(t, err)
8585

8686
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
87-
MaxBlockNumPerChunk: tt.maxBlockNum,
88-
MaxL2GasPerChunk: tt.maxL2Gas,
89-
ChunkTimeoutSec: tt.chunkTimeoutSec,
87+
MaxBlockNumPerChunk: tt.maxBlockNum,
88+
MaxL2GasPerChunk: tt.maxL2Gas,
89+
ChunkTimeoutSec: tt.chunkTimeoutSec,
90+
MaxUncompressedBatchBytesSize: 4000000,
9091
}, encoding.CodecV7, &params.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64), EuclidTime: new(uint64), EuclidV2Time: new(uint64)}, db, nil)
9192
cp.TryProposeChunk()
9293

@@ -128,9 +129,10 @@ func testChunkProposerBlobSizeLimitCodecV7(t *testing.T) {
128129
chainConfig := &params.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64), EuclidTime: new(uint64), EuclidV2Time: new(uint64)}
129130

130131
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
131-
MaxBlockNumPerChunk: 255,
132-
MaxL2GasPerChunk: math.MaxUint64,
133-
ChunkTimeoutSec: math.MaxUint32,
132+
MaxBlockNumPerChunk: 255,
133+
MaxL2GasPerChunk: math.MaxUint64,
134+
ChunkTimeoutSec: math.MaxUint32,
135+
MaxUncompressedBatchBytesSize: 4000000,
134136
}, encoding.CodecV7, chainConfig, db, nil)
135137

136138
for i := 0; i < 2; i++ {

rollup/internal/utils/utils.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ type ChunkMetrics struct {
1515
L2Gas uint64
1616
FirstBlockTimestamp uint64
1717

18-
L1CommitBlobSize uint64
18+
L1CommitBlobSize uint64
19+
L1CommitUncompressedBatchBytesSize uint64
1920

2021
// timing metrics
2122
EstimateBlobSizeTime time.Duration
@@ -41,7 +42,7 @@ func CalculateChunkMetrics(chunk *encoding.Chunk, codecVersion encoding.CodecVer
4142
}
4243

4344
metrics.EstimateBlobSizeTime, err = measureTime(func() error {
44-
_, metrics.L1CommitBlobSize, err = codec.EstimateChunkL1CommitBatchSizeAndBlobSize(chunk)
45+
metrics.L1CommitUncompressedBatchBytesSize, metrics.L1CommitBlobSize, err = codec.EstimateChunkL1CommitBatchSizeAndBlobSize(chunk)
4546
return err
4647
})
4748
if err != nil {
@@ -56,7 +57,8 @@ type BatchMetrics struct {
5657
NumChunks uint64
5758
FirstBlockTimestamp uint64
5859

59-
L1CommitBlobSize uint64
60+
L1CommitBlobSize uint64
61+
L1CommitUncompressedBatchBytesSize uint64
6062

6163
// timing metrics
6264
EstimateBlobSizeTime time.Duration
@@ -75,7 +77,7 @@ func CalculateBatchMetrics(batch *encoding.Batch, codecVersion encoding.CodecVer
7577
}
7678

7779
metrics.EstimateBlobSizeTime, err = measureTime(func() error {
78-
_, metrics.L1CommitBlobSize, err = codec.EstimateBatchL1CommitBatchSizeAndBlobSize(batch)
80+
metrics.L1CommitUncompressedBatchBytesSize, metrics.L1CommitBlobSize, err = codec.EstimateBatchL1CommitBatchSizeAndBlobSize(batch)
7981
return err
8082
})
8183
if err != nil {

rollup/proposer-tool-config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"chunk_proposer_config": {
55
"max_block_num_per_chunk": 100,
66
"max_l2_gas_per_chunk": 20000000,
7-
"chunk_timeout_sec": 72000000000
7+
"chunk_timeout_sec": 72000000000,
8+
"max_uncompressed_batch_bytes_size": 4000000
89
},
910
"batch_proposer_config": {
1011
"batch_timeout_sec": 72000000000,
11-
"max_chunks_per_batch": 45
12+
"max_chunks_per_batch": 45,
13+
"max_uncompressed_batch_bytes_size": 4000000
1214
},
1315
"bundle_proposer_config": {
1416
"max_batch_num_per_bundle": 45,

rollup/tests/rollup_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ func testCommitBatchAndFinalizeBundleCodecV7(t *testing.T) {
118118
}
119119

120120
cp := watcher.NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
121-
MaxBlockNumPerChunk: 100,
122-
MaxL2GasPerChunk: math.MaxUint64,
123-
ChunkTimeoutSec: 300,
121+
MaxBlockNumPerChunk: 100,
122+
MaxL2GasPerChunk: math.MaxUint64,
123+
ChunkTimeoutSec: 300,
124+
MaxUncompressedBatchBytesSize: 4000000,
124125
}, encoding.CodecV7, chainConfig, db, nil)
125126

126127
bap := watcher.NewBatchProposer(context.Background(), &config.BatchProposerConfig{
127-
MaxChunksPerBatch: math.MaxInt32,
128-
BatchTimeoutSec: 300,
128+
MaxChunksPerBatch: math.MaxInt32,
129+
BatchTimeoutSec: 300,
130+
MaxUncompressedBatchBytesSize: 4000000,
129131
}, encoding.CodecV7, chainConfig, db, nil)
130132

131133
bup := watcher.NewBundleProposer(context.Background(), &config.BundleProposerConfig{

0 commit comments

Comments
 (0)