Skip to content

Commit 4dfb500

Browse files
committed
fix: increase P2P pubsub max message size to match blob size limit
Move DefaultMaxBlobSize from block/internal/common to pkg/blobsize so the P2P layer can import it. Pass it to pubsub.WithMaxMessageSize when creating FloodSub, preventing fullnode desync when blocks exceed the default 1 MB libp2p limit.
1 parent 7344e09 commit 4dfb500

13 files changed

Lines changed: 94 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Fixed
13+
14+
- Increase P2P pubsub max message size to match `DefaultMaxBlobSize`, preventing fullnode desync on large blocks
15+
1216
### Changes
1317

1418
- Add max bytes contraints in simple solo sequnecer [#3312](https://github.com/evstack/ev-node/pull/3312)

apps/testapp/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ COPY . .
2929
WORKDIR /ev-node/apps/testapp
3030

3131
# 125829120 = 120 MB
32-
RUN go build -ldflags "-X github.com/evstack/ev-node/block/internal/common.defaultMaxBlobSizeStr=125829120" -o /go/bin/testapp .
32+
RUN go build -ldflags "-X github.com/evstack/ev-node/pkg/blobsize.defaultMaxBlobSizeStr=125829120" -o /go/bin/testapp .
3333

3434
## prep the final image.
3535
#

block/internal/common/consts.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
11
package common
2-
3-
import "strconv"
4-
5-
// defaultMaxBlobSizeStr holds the string representation of the default blob
6-
// size limit. Override at link time via:
7-
//
8-
// go build -ldflags "-X github.com/evstack/ev-node/block/internal/common.defaultMaxBlobSizeStr=125829120"
9-
var defaultMaxBlobSizeStr = "5242880" // 5 MB
10-
11-
// DefaultMaxBlobSize is the max blob size limit used for blob submission.
12-
var DefaultMaxBlobSize uint64
13-
14-
func init() {
15-
v, err := strconv.ParseUint(defaultMaxBlobSizeStr, 10, 64)
16-
if err != nil || v == 0 {
17-
DefaultMaxBlobSize = 5 * 1024 * 1024 // 5 MB fallback
18-
return
19-
}
20-
DefaultMaxBlobSize = v
21-
}

block/internal/da/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/celestiaorg/go-square/v3/share"
1313
"github.com/rs/zerolog"
1414

15-
"github.com/evstack/ev-node/block/internal/common"
15+
"github.com/evstack/ev-node/pkg/blobsize"
1616
blobrpc "github.com/evstack/ev-node/pkg/da/jsonrpc"
1717
datypes "github.com/evstack/ev-node/pkg/da/types"
1818
)
@@ -161,7 +161,7 @@ func (c *client) Submit(ctx context.Context, data [][]byte, _ float64, namespace
161161

162162
blobs := make([]*blobrpc.Blob, len(data))
163163
for i, raw := range data {
164-
if uint64(len(raw)) > common.DefaultMaxBlobSize {
164+
if uint64(len(raw)) > blobsize.DefaultMaxBlobSize {
165165
return datypes.ResultSubmit{
166166
BaseResult: datypes.BaseResult{
167167
Code: datypes.StatusTooBig,
@@ -559,7 +559,7 @@ func extractBlobData(resp *blobrpc.SubscriptionResponse) [][]byte {
559559
continue
560560
}
561561
data := blob.Data()
562-
if len(data) == 0 || uint64(len(data)) > common.DefaultMaxBlobSize {
562+
if len(data) == 0 || uint64(len(data)) > blobsize.DefaultMaxBlobSize {
563563
continue
564564
}
565565
blobs = append(blobs, data)

block/internal/executing/executor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/evstack/ev-node/block/internal/common"
2020
coreexecutor "github.com/evstack/ev-node/core/execution"
2121
coresequencer "github.com/evstack/ev-node/core/sequencer"
22+
"github.com/evstack/ev-node/pkg/blobsize"
2223
"github.com/evstack/ev-node/pkg/config"
2324
"github.com/evstack/ev-node/pkg/genesis"
2425
"github.com/evstack/ev-node/pkg/raft"
@@ -664,7 +665,7 @@ func (e *Executor) ProduceBlock(ctx context.Context) error {
664665
func (e *Executor) RetrieveBatch(ctx context.Context) (*BatchData, error) {
665666
req := coresequencer.GetNextBatchRequest{
666667
Id: []byte(e.genesis.ChainID),
667-
MaxBytes: common.DefaultMaxBlobSize,
668+
MaxBytes: blobsize.DefaultMaxBlobSize,
668669
LastBatchData: [][]byte{}, // Can be populated if needed for sequencer context
669670
}
670671

block/internal/submitting/batching_strategy_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
"github.com/stretchr/testify/assert"
88
"github.com/stretchr/testify/require"
99

10-
"github.com/evstack/ev-node/block/internal/common"
10+
"github.com/evstack/ev-node/pkg/blobsize"
1111
"github.com/evstack/ev-node/pkg/config"
1212
)
1313

1414
func TestImmediateStrategy(t *testing.T) {
1515
strategy := &ImmediateStrategy{}
16-
maxBlobSize := common.DefaultMaxBlobSize
16+
maxBlobSize := blobsize.DefaultMaxBlobSize
1717

1818
tests := []struct {
1919
name string
@@ -50,7 +50,7 @@ func TestImmediateStrategy(t *testing.T) {
5050
}
5151

5252
func TestSizeBasedStrategy(t *testing.T) {
53-
maxBlobSize := common.DefaultMaxBlobSize
53+
maxBlobSize := blobsize.DefaultMaxBlobSize
5454

5555
tests := []struct {
5656
name string
@@ -120,7 +120,7 @@ func TestSizeBasedStrategy(t *testing.T) {
120120

121121
func TestTimeBasedStrategy(t *testing.T) {
122122
maxDelay := 6 * time.Second
123-
maxBlobSize := common.DefaultMaxBlobSize
123+
maxBlobSize := blobsize.DefaultMaxBlobSize
124124

125125
tests := []struct {
126126
name string
@@ -174,7 +174,7 @@ func TestTimeBasedStrategy(t *testing.T) {
174174
}
175175

176176
func TestAdaptiveStrategy(t *testing.T) {
177-
maxBlobSize := common.DefaultMaxBlobSize
177+
maxBlobSize := blobsize.DefaultMaxBlobSize
178178
sizeThreshold := 0.8
179179
maxDelay := 6 * time.Second
180180

@@ -306,7 +306,7 @@ func TestNewBatchingStrategy(t *testing.T) {
306306
}
307307

308308
func TestBatchingStrategiesComparison(t *testing.T) {
309-
maxBlobSize := common.DefaultMaxBlobSize
309+
maxBlobSize := blobsize.DefaultMaxBlobSize
310310
pendingCount := uint64(10)
311311
totalSize := maxBlobSize / 2
312312
timeSinceLastSubmit := 3 * time.Second

block/internal/submitting/da_submitter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/evstack/ev-node/block/internal/cache"
1717
"github.com/evstack/ev-node/block/internal/common"
1818
"github.com/evstack/ev-node/block/internal/da"
19+
"github.com/evstack/ev-node/pkg/blobsize"
1920
"github.com/evstack/ev-node/pkg/config"
2021
pkgda "github.com/evstack/ev-node/pkg/da"
2122
datypes "github.com/evstack/ev-node/pkg/da/types"
@@ -50,7 +51,7 @@ func defaultRetryPolicy(maxAttempts int, maxDuration time.Duration) retryPolicy
5051
MaxAttempts: maxAttempts,
5152
MinBackoff: initialBackoff,
5253
MaxBackoff: maxDuration,
53-
MaxBlobBytes: common.DefaultMaxBlobSize,
54+
MaxBlobBytes: blobsize.DefaultMaxBlobSize,
5455
}
5556
}
5657

block/internal/submitting/submitter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/evstack/ev-node/block/internal/common"
1717
coreexecutor "github.com/evstack/ev-node/core/execution"
1818
coresequencer "github.com/evstack/ev-node/core/sequencer"
19+
"github.com/evstack/ev-node/pkg/blobsize"
1920
"github.com/evstack/ev-node/pkg/config"
2021
"github.com/evstack/ev-node/pkg/genesis"
2122
"github.com/evstack/ev-node/pkg/signer"
@@ -219,7 +220,7 @@ func (s *Submitter) daSubmissionLoop() {
219220
shouldSubmit := s.batchingStrategy.ShouldSubmit(
220221
uint64(len(headers)),
221222
totalSize,
222-
common.DefaultMaxBlobSize,
223+
blobsize.DefaultMaxBlobSize,
223224
timeSinceLastSubmit,
224225
)
225226

@@ -279,7 +280,7 @@ func (s *Submitter) daSubmissionLoop() {
279280
shouldSubmit := s.batchingStrategy.ShouldSubmit(
280281
uint64(len(signedDataList)),
281282
totalSize,
282-
common.DefaultMaxBlobSize,
283+
blobsize.DefaultMaxBlobSize,
283284
timeSinceLastSubmit,
284285
)
285286

block/internal/syncing/syncer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/evstack/ev-node/block/internal/common"
2121
"github.com/evstack/ev-node/block/internal/da"
2222
coreexecutor "github.com/evstack/ev-node/core/execution"
23+
"github.com/evstack/ev-node/pkg/blobsize"
2324
"github.com/evstack/ev-node/pkg/config"
2425
"github.com/evstack/ev-node/pkg/genesis"
2526
"github.com/evstack/ev-node/pkg/raft"
@@ -907,7 +908,7 @@ func (s *Syncer) gracePeriodForEpoch(epochStart, epochEnd uint64) uint64 {
907908
s.forcedInclusionMu.RUnlock()
908909

909910
avgBytes := totalBytes / heightCount
910-
threshold := uint64(math.Round(fullnessThreshold * float64(common.DefaultMaxBlobSize)))
911+
threshold := uint64(math.Round(fullnessThreshold * float64(blobsize.DefaultMaxBlobSize)))
911912

912913
var extra uint64
913914
if avgBytes > threshold {
@@ -991,7 +992,7 @@ func (s *Syncer) VerifyForcedInclusionTxs(ctx context.Context, daHeight uint64,
991992
}
992993

993994
// Skip intrinsically invalid txs so the sequencer isn't blamed for dropping them.
994-
filterStatuses, filterErr := s.exec.FilterTxs(ctx, event.Txs, common.DefaultMaxBlobSize, executionInfo.MaxGas, true)
995+
filterStatuses, filterErr := s.exec.FilterTxs(ctx, event.Txs, blobsize.DefaultMaxBlobSize, executionInfo.MaxGas, true)
995996
if filterErr != nil {
996997
return fmt.Errorf("failed to filter forced inclusion txs: %w", filterErr)
997998
}

block/internal/syncing/syncer_forced_inclusion_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/evstack/ev-node/block/internal/common"
1616
"github.com/evstack/ev-node/block/internal/da"
1717
"github.com/evstack/ev-node/core/execution"
18+
"github.com/evstack/ev-node/pkg/blobsize"
1819
"github.com/evstack/ev-node/pkg/config"
1920
datypes "github.com/evstack/ev-node/pkg/da/types"
2021
"github.com/evstack/ev-node/pkg/genesis"
@@ -480,7 +481,7 @@ func TestGracePeriodForEpoch_LightBlocks(t *testing.T) {
480481
func TestGracePeriodForEpoch_FullBlocks(t *testing.T) {
481482
s := &Syncer{daBlockBytes: make(map[uint64]uint64)}
482483
for h := uint64(0); h <= 4; h++ {
483-
s.daBlockBytes[h] = common.DefaultMaxBlobSize
484+
s.daBlockBytes[h] = blobsize.DefaultMaxBlobSize
484485
}
485486
grace := s.gracePeriodForEpoch(0, 4)
486487
require.GreaterOrEqual(t, grace, baseGracePeriodEpochs)
@@ -490,7 +491,7 @@ func TestGracePeriodForEpoch_FullBlocks(t *testing.T) {
490491
// avgBytes=1.6·M, threshold=0.8·M → extra=1 → grace=base+1.
491492
func TestGracePeriodForEpoch_ExtendedUnderHighCongestion(t *testing.T) {
492493
s := &Syncer{daBlockBytes: make(map[uint64]uint64)}
493-
congested := uint64(float64(common.DefaultMaxBlobSize) * 1.6)
494+
congested := uint64(float64(blobsize.DefaultMaxBlobSize) * 1.6)
494495
for h := uint64(0); h <= 2; h++ {
495496
s.daBlockBytes[h] = congested
496497
}
@@ -501,7 +502,7 @@ func TestGracePeriodForEpoch_ExtendedUnderHighCongestion(t *testing.T) {
501502
// TestGracePeriodForEpoch_CappedAtMax verifies the grace period never exceeds maxGracePeriodEpochs.
502503
func TestGracePeriodForEpoch_CappedAtMax(t *testing.T) {
503504
s := &Syncer{daBlockBytes: make(map[uint64]uint64)}
504-
huge := common.DefaultMaxBlobSize * 100
505+
huge := blobsize.DefaultMaxBlobSize * 100
505506
for h := uint64(0); h <= 4; h++ {
506507
s.daBlockBytes[h] = huge
507508
}
@@ -526,7 +527,7 @@ func TestVerifyForcedInclusionTxs_DynamicGrace_CongestedEpochGetsExtraTime(t *te
526527
mockFIEmpty(client, 2, 9)
527528

528529
// avgBytes = 1.6·M → extra=1 → gracePeriodForEpoch(0,1)=2 → graceBoundary=5.
529-
blockBytes := uint64(float64(common.DefaultMaxBlobSize) * 1.6)
530+
blockBytes := uint64(float64(blobsize.DefaultMaxBlobSize) * 1.6)
530531

531532
d0 := makeData("tchain", 1, 1)
532533
d0.Txs[0] = types.Tx(make([]byte, blockBytes))

0 commit comments

Comments
 (0)