Skip to content

Commit c5fcd99

Browse files
authored
feat(l1 sync service): add flag for sync interval (#1241)
1 parent 10b0905 commit c5fcd99

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ var (
170170
utils.L1EndpointFlag,
171171
utils.L1ConfirmationsFlag,
172172
utils.L1DeploymentBlockFlag,
173+
utils.L1SyncIntervalFlag,
173174
utils.L1DisableMessageQueueV2Flag,
174175
utils.CircuitCapacityCheckEnabledFlag,
175176
utils.CircuitCapacityCheckWorkersFlag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
233233
utils.L1EndpointFlag,
234234
utils.L1ConfirmationsFlag,
235235
utils.L1DeploymentBlockFlag,
236+
utils.L1SyncIntervalFlag,
236237
utils.L1DisableMessageQueueV2Flag,
237238
utils.RollupVerifyEnabledFlag,
238239
utils.DASyncEnabledFlag,

cmd/utils/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,10 @@ var (
853853
Name: "l1.sync.startblock",
854854
Usage: "L1 block height to start syncing from. Should be set to the L1 message queue deployment block number.",
855855
}
856+
L1SyncIntervalFlag = cli.DurationFlag{
857+
Name: "l1.sync.interval",
858+
Usage: "Poll interval for L1 message syncing (e.g., 2s, 10s, 1m)",
859+
}
856860
L1DisableMessageQueueV2Flag = &cli.BoolFlag{
857861
Name: "l1.disablemqv2",
858862
Usage: "Disable L1 message queue v2",
@@ -1470,6 +1474,9 @@ func setL1(ctx *cli.Context, cfg *node.Config) {
14701474
if ctx.GlobalIsSet(L1DeploymentBlockFlag.Name) {
14711475
cfg.L1DeploymentBlock = ctx.GlobalUint64(L1DeploymentBlockFlag.Name)
14721476
}
1477+
if ctx.GlobalIsSet(L1SyncIntervalFlag.Name) {
1478+
cfg.L1SyncInterval = ctx.GlobalDuration(L1SyncIntervalFlag.Name)
1479+
}
14731480
if ctx.GlobalIsSet(L1DisableMessageQueueV2Flag.Name) {
14741481
cfg.L1DisableMessageQueueV2 = ctx.GlobalBool(L1DisableMessageQueueV2Flag.Name)
14751482
}

node/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"runtime"
2626
"strings"
2727
"sync"
28+
"time"
2829

2930
"github.com/scroll-tech/go-ethereum/common"
3031
"github.com/scroll-tech/go-ethereum/crypto"
@@ -197,6 +198,8 @@ type Config struct {
197198
L1Confirmations rpc.BlockNumber `toml:",omitempty"`
198199
// L1 bridge deployment block number
199200
L1DeploymentBlock uint64 `toml:",omitempty"`
201+
// Poll interval for L1 message syncing
202+
L1SyncInterval time.Duration `toml:",omitempty"`
200203
// Explicitly disable L1 message queue V2 and only query from L1 message queue V1 (before EuclidV2)
201204
L1DisableMessageQueueV2 bool `toml:",omitempty"`
202205
// Is daSyncingEnabled

rollup/sync_service/sync_service.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ func NewSyncService(ctx context.Context, genesisConfig *params.ChainConfig, node
100100

101101
ctx, cancel := context.WithCancel(ctx)
102102

103+
pollInterval := nodeConfig.L1SyncInterval
104+
if pollInterval == 0 {
105+
pollInterval = DefaultPollInterval
106+
}
107+
103108
service := SyncService{
104109
ctx: ctx,
105110
cancel: cancel,
106111
client: client,
107112
db: db,
108-
pollInterval: DefaultPollInterval,
113+
pollInterval: pollInterval,
109114
latestProcessedBlock: latestProcessedBlock,
110115
}
111116

0 commit comments

Comments
 (0)