Skip to content

Conversation

@yiweichi
Copy link
Member

@yiweichi yiweichi commented Oct 13, 2025

1. Purpose or design rationale of this PR

This PR parameterize sync service fetch block range, which required by DogeOS team to address the issue that the default 100 block range is too large in their case.

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Added a CLI and configuration option to control the block range used when fetching L1 messages, allowing adjustable batch sizes during sync.
    • Sync process now uses the configured range and falls back to sensible defaults when unset.
  • Chores

    • Bumped the patch version to reflect this update.

@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2025

Walkthrough

Adds a configurable L1 fetch block range: new CLI flag, config field, and SyncService support. Node startup parses the flag into config; SyncService reads the value (falls back to default) and uses it in fetchMessages batching. Also bumps VersionPatch to 6.

Changes

Cohort / File(s) Summary
CLI flag wiring
cmd/geth/main.go, cmd/utils/flags.go
Introduces utils.L1FetchBlockRangeFlag (l1.sync.fetchblockrange) and includes it in node startup flags; maps flag value into L1 config.
Node config struct
node/config.go
Adds L1FetchBlockRange uint64 (toml: omitempty) to Config.
Sync service range usage
rollup/sync_service/sync_service.go
Adds fetchBlockRange field; initializes from nodeConfig.L1FetchBlockRange or default; replaces constant with instance field in batching logic.
Version bump
params/version.go
Updates VersionPatch from 5 to 6.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User/Operator
  participant Geth as Geth (cmd/geth)
  participant Utils as utils.Flags
  participant Node as Node Config
  participant Sync as SyncService
  participant L1 as L1 RPC

  User->>Geth: start geth --l1.sync.fetchblockrange=N
  Geth->>Utils: Register & parse L1FetchBlockRangeFlag
  Utils-->>Node: set cfg.L1FetchBlockRange = N
  Geth->>Sync: New SyncService(cfg)
  alt cfg.L1FetchBlockRange == 0
    Sync->>Sync: fetchBlockRange = DefaultFetchBlockRange
  else
    Sync->>Sync: fetchBlockRange = cfg.L1FetchBlockRange
  end

  loop Fetch L1 messages (batched)
    Sync->>L1: eth_getLogs(from..to) using fetchBlockRange
    L1-->>Sync: logs
    Sync->>Sync: process & advance by fetchBlockRange
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • jonastheis
  • greged93
  • colinlyguo

Poem

I nibbled flags and configs fine,
A blocky range for logs to mine.
Hop-hop through batches, neat and tight,
From "from" to "to" in perfect byte.
Patch hops up—version six tonight. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title follows conventional commit formatting by starting with “feat:” and succinctly describes the core enhancement of parameterizing the sync service fetch block range, making it clear to reviewers what primary feature is introduced.
Description Check ✅ Passed The description fully adheres to the repository’s template by providing all four required sections: a clear rationale in section 1, confirmation of the conventional-commit PR type in section 2, updated versioning status in section 3, and a breaking-change declaration in section 4. Each section is properly labeled and populated, ensuring reviewers have the necessary context and checklist items completed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-parameterize-fetch-block-range

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 208f4f9 and a416e3c.

📒 Files selected for processing (1)
  • cmd/utils/flags.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/utils/flags.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0697268 and 208f4f9.

📒 Files selected for processing (5)
  • cmd/geth/main.go (1 hunks)
  • cmd/utils/flags.go (2 hunks)
  • node/config.go (1 hunks)
  • params/version.go (1 hunks)
  • rollup/sync_service/sync_service.go (4 hunks)
🔇 Additional comments (6)
node/config.go (1)

203-204: LGTM! Well-structured configuration field.

The new L1FetchBlockRange field is properly defined with a clear comment and appropriate type. The placement among other L1-related configuration fields is logical.

rollup/sync_service/sync_service.go (2)

109-112: Good defensive default handling.

The fallback to DefaultFetchBlockRange when the configured value is 0 ensures backward compatibility and prevents invalid configurations.


54-54: Verify fetch block range limits for production use.

The implementation correctly parameterizes the fetch block range, but consider validating bounds:

  • Many Ethereum RPC providers limit eth_getLogs to ~10,000 blocks
  • Very small values (e.g., 1-10 blocks) may cause excessive RPC calls
  • The DogeOS team requested this for smaller ranges, but ensure the chosen value is tested

Run this script to check if there are any existing limits or validations in the codebase:

Also applies to: 120-120, 246-246, 260-260

cmd/utils/flags.go (2)

860-863: LGTM! CLI flag properly defined.

The flag definition follows the established naming convention for L1 sync-related flags and includes clear usage documentation.


1484-1486: LGTM! Flag wiring is correct.

The flag is properly wired into the L1 configuration flow, consistent with other L1 flags in the same function.

cmd/geth/main.go (1)

174-174: LGTM! Flag correctly exposed in CLI.

The flag is properly added to the nodeFlags slice and placed logically with other L1-related configuration flags.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
rollup/sync_service/sync_service.go (1)

109-112: Consider adding validation for the fetch block range.

The initialization logic correctly implements the fallback to DefaultFetchBlockRange when nodeConfig.L1FetchBlockRange is zero. However, consider adding validation to ensure the value is within reasonable bounds.

While the current implementation is functional, you may want to add validation to prevent potential issues:

 	fetchBlockRange := nodeConfig.L1FetchBlockRange
 	if fetchBlockRange == 0 {
 		fetchBlockRange = DefaultFetchBlockRange
 	}
+	// Validate fetch range is reasonable to avoid eth_getLogs failures
+	if fetchBlockRange > 10000 {
+		log.Warn("L1 fetch block range is very large, may cause eth_getLogs to fail", "range", fetchBlockRange)
+	}

Additionally, adding a comment explaining the fallback logic would improve code clarity:

+	// Use configured fetch block range, or fall back to default if not set
 	fetchBlockRange := nodeConfig.L1FetchBlockRange
 	if fetchBlockRange == 0 {
 		fetchBlockRange = DefaultFetchBlockRange
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0697268 and 208f4f9.

📒 Files selected for processing (5)
  • cmd/geth/main.go (1 hunks)
  • cmd/utils/flags.go (2 hunks)
  • node/config.go (1 hunks)
  • params/version.go (1 hunks)
  • rollup/sync_service/sync_service.go (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/geth/main.go (1)
cmd/utils/flags.go (1)
  • L1FetchBlockRangeFlag (860-863)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
params/version.go (1)

27-27: LGTM! Version bump aligns with the new feature.

The patch version increment is appropriate for adding a configurable parameter. The change follows semantic versioning practices.

cmd/geth/main.go (1)

174-174: LGTM! Flag correctly positioned with other L1 configuration flags.

The addition of L1FetchBlockRangeFlag to the nodeFlags list is properly placed alongside other L1 sync configuration flags (L1SyncIntervalFlag, L1DisableMessageQueueV2Flag, etc.), maintaining logical grouping.

node/config.go (1)

203-204: LGTM! Config field properly defined and documented.

The L1FetchBlockRange field is correctly added with:

  • Clear naming that matches the CLI flag
  • Descriptive comment explaining its purpose
  • Appropriate toml:",omitempty" tag for optional configuration
  • Logical placement with other L1 sync configuration fields
cmd/utils/flags.go (2)

860-863: LGTM! CLI flag properly defined.

The L1FetchBlockRangeFlag is correctly configured with:

  • Appropriate type (cli.Uint64Flag) for block range values
  • Consistent naming convention (l1.sync.fetchblockrange)
  • Clear usage description

1484-1486: LGTM! Flag correctly wired to configuration.

The flag value is properly assigned to cfg.L1FetchBlockRange in the setL1 function, with appropriate checks for whether the flag is set. The zero value is intentionally used as a signal for the fallback to DefaultFetchBlockRange in the SyncService.

rollup/sync_service/sync_service.go (4)

54-54: LGTM! Field appropriately added to track configurable fetch range.

The fetchBlockRange field is correctly added to the SyncService struct to store the configured block range value. The field is unexported (internal use only) and has an appropriate type.


120-120: LGTM! Fetch block range correctly stored in service instance.

The configured fetchBlockRange value is properly assigned to the SyncService struct, making it available for use in the fetch loop.


246-246: LGTM! Loop increment correctly uses configurable fetch range.

The loop increment now uses s.fetchBlockRange instead of the hardcoded DefaultFetchBlockRange, properly implementing the configurable behavior while maintaining the existing loop logic.


260-260: LGTM! End block calculation correctly uses configurable fetch range.

The end block calculation now uses s.fetchBlockRange, ensuring consistency with the loop increment and properly implementing the configurable batch size.

@yiweichi yiweichi merged commit bb8f253 into develop Oct 14, 2025
14 checks passed
@yiweichi yiweichi deleted the feat-parameterize-fetch-block-range branch October 14, 2025 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants