Skip to content

Commit bb8f253

Browse files
authored
feat: parameterize sync service fetch block range (#1247)
* feat: parameterize sync service fetch block range * chore: auto version bump [bot] * fix type
1 parent 0697268 commit bb8f253

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ var (
171171
utils.L1ConfirmationsFlag,
172172
utils.L1DeploymentBlockFlag,
173173
utils.L1SyncIntervalFlag,
174+
utils.L1FetchBlockRangeFlag,
174175
utils.L1DisableMessageQueueV2Flag,
175176
utils.CircuitCapacityCheckEnabledFlag,
176177
utils.CircuitCapacityCheckWorkersFlag,

cmd/utils/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,10 @@ var (
857857
Name: "l1.sync.interval",
858858
Usage: "Poll interval for L1 message syncing (e.g., 2s, 10s, 1m)",
859859
}
860+
L1FetchBlockRangeFlag = cli.Int64Flag{
861+
Name: "l1.sync.fetchblockrange",
862+
Usage: "Block range for L1 message fetching in a single eth_getLogs query",
863+
}
860864
L1DisableMessageQueueV2Flag = &cli.BoolFlag{
861865
Name: "l1.disablemqv2",
862866
Usage: "Disable L1 message queue v2",
@@ -1477,6 +1481,9 @@ func setL1(ctx *cli.Context, cfg *node.Config) {
14771481
if ctx.GlobalIsSet(L1SyncIntervalFlag.Name) {
14781482
cfg.L1SyncInterval = ctx.GlobalDuration(L1SyncIntervalFlag.Name)
14791483
}
1484+
if ctx.GlobalIsSet(L1FetchBlockRangeFlag.Name) {
1485+
cfg.L1FetchBlockRange = ctx.GlobalUint64(L1FetchBlockRangeFlag.Name)
1486+
}
14801487
if ctx.GlobalIsSet(L1DisableMessageQueueV2Flag.Name) {
14811488
cfg.L1DisableMessageQueueV2 = ctx.GlobalBool(L1DisableMessageQueueV2Flag.Name)
14821489
}

node/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ type Config struct {
200200
L1DeploymentBlock uint64 `toml:",omitempty"`
201201
// Poll interval for L1 message syncing
202202
L1SyncInterval time.Duration `toml:",omitempty"`
203+
// Block range for L1 message fetching in a single eth_getLogs query
204+
L1FetchBlockRange uint64 `toml:",omitempty"`
203205
// Explicitly disable L1 message queue V2 and only query from L1 message queue V1 (before EuclidV2)
204206
L1DisableMessageQueueV2 bool `toml:",omitempty"`
205207
// Is daSyncingEnabled

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 9 // Minor version component of the current release
27-
VersionPatch = 5 // Patch version component of the current release
27+
VersionPatch = 6 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/sync_service/sync_service.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type SyncService struct {
5151
db ethdb.Database
5252
msgCountFeed event.Feed
5353
pollInterval time.Duration
54+
fetchBlockRange uint64
5455
latestProcessedBlock uint64
5556
scope event.SubscriptionScope
5657
stateMu sync.Mutex
@@ -105,12 +106,18 @@ func NewSyncService(ctx context.Context, genesisConfig *params.ChainConfig, node
105106
pollInterval = DefaultPollInterval
106107
}
107108

109+
fetchBlockRange := nodeConfig.L1FetchBlockRange
110+
if fetchBlockRange == 0 {
111+
fetchBlockRange = DefaultFetchBlockRange
112+
}
113+
108114
service := SyncService{
109115
ctx: ctx,
110116
cancel: cancel,
111117
client: client,
112118
db: db,
113119
pollInterval: pollInterval,
120+
fetchBlockRange: fetchBlockRange,
114121
latestProcessedBlock: latestProcessedBlock,
115122
}
116123

@@ -236,7 +243,7 @@ func (s *SyncService) fetchMessages() {
236243
numMsgsCollected := 0
237244

238245
// query in batches
239-
for from := s.latestProcessedBlock + 1; from <= latestConfirmed; from += DefaultFetchBlockRange {
246+
for from := s.latestProcessedBlock + 1; from <= latestConfirmed; from += s.fetchBlockRange {
240247
select {
241248
case <-s.ctx.Done():
242249
// flush pending writes to database
@@ -250,7 +257,7 @@ func (s *SyncService) fetchMessages() {
250257
default:
251258
}
252259

253-
to := from + DefaultFetchBlockRange - 1
260+
to := from + s.fetchBlockRange - 1
254261
if to > latestConfirmed {
255262
to = latestConfirmed
256263
}

0 commit comments

Comments
 (0)