diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 4b408561e5..a092801d7d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -170,6 +170,7 @@ var ( utils.L1EndpointFlag, utils.L1ConfirmationsFlag, utils.L1DeploymentBlockFlag, + utils.L1SyncIntervalFlag, utils.L1DisableMessageQueueV2Flag, utils.CircuitCapacityCheckEnabledFlag, utils.CircuitCapacityCheckWorkersFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index fb20e2a4c4..5d622ca3c3 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -233,6 +233,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.L1EndpointFlag, utils.L1ConfirmationsFlag, utils.L1DeploymentBlockFlag, + utils.L1SyncIntervalFlag, utils.L1DisableMessageQueueV2Flag, utils.RollupVerifyEnabledFlag, utils.DASyncEnabledFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 99ac1417a9..1f56e491e3 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -853,6 +853,10 @@ var ( Name: "l1.sync.startblock", Usage: "L1 block height to start syncing from. Should be set to the L1 message queue deployment block number.", } + L1SyncIntervalFlag = cli.DurationFlag{ + Name: "l1.sync.interval", + Usage: "Poll interval for L1 message syncing (e.g., 2s, 10s, 1m)", + } L1DisableMessageQueueV2Flag = &cli.BoolFlag{ Name: "l1.disablemqv2", Usage: "Disable L1 message queue v2", @@ -1470,6 +1474,9 @@ func setL1(ctx *cli.Context, cfg *node.Config) { if ctx.GlobalIsSet(L1DeploymentBlockFlag.Name) { cfg.L1DeploymentBlock = ctx.GlobalUint64(L1DeploymentBlockFlag.Name) } + if ctx.GlobalIsSet(L1SyncIntervalFlag.Name) { + cfg.L1SyncInterval = ctx.GlobalDuration(L1SyncIntervalFlag.Name) + } if ctx.GlobalIsSet(L1DisableMessageQueueV2Flag.Name) { cfg.L1DisableMessageQueueV2 = ctx.GlobalBool(L1DisableMessageQueueV2Flag.Name) } diff --git a/node/config.go b/node/config.go index d721238968..27edd5122d 100644 --- a/node/config.go +++ b/node/config.go @@ -25,6 +25,7 @@ import ( "runtime" "strings" "sync" + "time" "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/crypto" @@ -197,6 +198,8 @@ type Config struct { L1Confirmations rpc.BlockNumber `toml:",omitempty"` // L1 bridge deployment block number L1DeploymentBlock uint64 `toml:",omitempty"` + // Poll interval for L1 message syncing + L1SyncInterval time.Duration `toml:",omitempty"` // Explicitly disable L1 message queue V2 and only query from L1 message queue V1 (before EuclidV2) L1DisableMessageQueueV2 bool `toml:",omitempty"` // Is daSyncingEnabled diff --git a/rollup/sync_service/sync_service.go b/rollup/sync_service/sync_service.go index a8edba793b..17ad6278d9 100644 --- a/rollup/sync_service/sync_service.go +++ b/rollup/sync_service/sync_service.go @@ -100,12 +100,17 @@ func NewSyncService(ctx context.Context, genesisConfig *params.ChainConfig, node ctx, cancel := context.WithCancel(ctx) + pollInterval := nodeConfig.L1SyncInterval + if pollInterval == 0 { + pollInterval = DefaultPollInterval + } + service := SyncService{ ctx: ctx, cancel: cancel, client: client, db: db, - pollInterval: DefaultPollInterval, + pollInterval: pollInterval, latestProcessedBlock: latestProcessedBlock, }