feat(l1 sync service): add flag for sync interval (#1241)

This commit is contained in:
Jonas Theis 2025-10-02 15:32:50 +08:00 committed by GitHub
parent 10b0905e5d
commit c5fcd99e5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 1 deletions

View file

@ -170,6 +170,7 @@ var (
utils.L1EndpointFlag, utils.L1EndpointFlag,
utils.L1ConfirmationsFlag, utils.L1ConfirmationsFlag,
utils.L1DeploymentBlockFlag, utils.L1DeploymentBlockFlag,
utils.L1SyncIntervalFlag,
utils.L1DisableMessageQueueV2Flag, utils.L1DisableMessageQueueV2Flag,
utils.CircuitCapacityCheckEnabledFlag, utils.CircuitCapacityCheckEnabledFlag,
utils.CircuitCapacityCheckWorkersFlag, utils.CircuitCapacityCheckWorkersFlag,

View file

@ -233,6 +233,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.L1EndpointFlag, utils.L1EndpointFlag,
utils.L1ConfirmationsFlag, utils.L1ConfirmationsFlag,
utils.L1DeploymentBlockFlag, utils.L1DeploymentBlockFlag,
utils.L1SyncIntervalFlag,
utils.L1DisableMessageQueueV2Flag, utils.L1DisableMessageQueueV2Flag,
utils.RollupVerifyEnabledFlag, utils.RollupVerifyEnabledFlag,
utils.DASyncEnabledFlag, utils.DASyncEnabledFlag,

View file

@ -853,6 +853,10 @@ var (
Name: "l1.sync.startblock", Name: "l1.sync.startblock",
Usage: "L1 block height to start syncing from. Should be set to the L1 message queue deployment block number.", 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{ L1DisableMessageQueueV2Flag = &cli.BoolFlag{
Name: "l1.disablemqv2", Name: "l1.disablemqv2",
Usage: "Disable L1 message queue v2", Usage: "Disable L1 message queue v2",
@ -1470,6 +1474,9 @@ func setL1(ctx *cli.Context, cfg *node.Config) {
if ctx.GlobalIsSet(L1DeploymentBlockFlag.Name) { if ctx.GlobalIsSet(L1DeploymentBlockFlag.Name) {
cfg.L1DeploymentBlock = ctx.GlobalUint64(L1DeploymentBlockFlag.Name) cfg.L1DeploymentBlock = ctx.GlobalUint64(L1DeploymentBlockFlag.Name)
} }
if ctx.GlobalIsSet(L1SyncIntervalFlag.Name) {
cfg.L1SyncInterval = ctx.GlobalDuration(L1SyncIntervalFlag.Name)
}
if ctx.GlobalIsSet(L1DisableMessageQueueV2Flag.Name) { if ctx.GlobalIsSet(L1DisableMessageQueueV2Flag.Name) {
cfg.L1DisableMessageQueueV2 = ctx.GlobalBool(L1DisableMessageQueueV2Flag.Name) cfg.L1DisableMessageQueueV2 = ctx.GlobalBool(L1DisableMessageQueueV2Flag.Name)
} }

View file

@ -25,6 +25,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
"time"
"github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto" "github.com/scroll-tech/go-ethereum/crypto"
@ -197,6 +198,8 @@ type Config struct {
L1Confirmations rpc.BlockNumber `toml:",omitempty"` L1Confirmations rpc.BlockNumber `toml:",omitempty"`
// L1 bridge deployment block number // L1 bridge deployment block number
L1DeploymentBlock uint64 `toml:",omitempty"` 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) // Explicitly disable L1 message queue V2 and only query from L1 message queue V1 (before EuclidV2)
L1DisableMessageQueueV2 bool `toml:",omitempty"` L1DisableMessageQueueV2 bool `toml:",omitempty"`
// Is daSyncingEnabled // Is daSyncingEnabled

View file

@ -100,12 +100,17 @@ func NewSyncService(ctx context.Context, genesisConfig *params.ChainConfig, node
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
pollInterval := nodeConfig.L1SyncInterval
if pollInterval == 0 {
pollInterval = DefaultPollInterval
}
service := SyncService{ service := SyncService{
ctx: ctx, ctx: ctx,
cancel: cancel, cancel: cancel,
client: client, client: client,
db: db, db: db,
pollInterval: DefaultPollInterval, pollInterval: pollInterval,
latestProcessedBlock: latestProcessedBlock, latestProcessedBlock: latestProcessedBlock,
} }