Skip to content

feat(rollup-verifier): make withdraw root check optional #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025

Conversation

Thegaram
Copy link

@Thegaram Thegaram commented May 9, 2025

1. Purpose or design rationale of this PR

Make withdraw trie root verification optional, so that rollup-verifier works on full nodes with pruned historical states.

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:

  • feat: A new feature

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

  • Chores

    • Updated the patch version number to 44.
  • Bug Fixes

    • Improved handling of missing withdraw root data during batch validation, allowing the process to continue even if local withdraw root information is unavailable.
    • Withdraw root validation is now optional and non-blocking, enhancing compatibility with nodes lacking historical state data.

@Thegaram Thegaram requested review from georgehao and colinlyguo May 9, 2025 14:35
Copy link

coderabbitai bot commented May 9, 2025

Walkthrough

The changes increment the patch version in the version constants and update the handling of withdraw root during rollup batch synchronization. Withdraw root retrieval is now optional, missing roots are tolerated, and finalized batch metadata uses the L1 event's withdraw root. No other logic or exported entity changes were made.

Changes

File(s) Change Summary
params/version.go Incremented VersionPatch constant from 43 to 44.
rollup/rollup_sync_service/rollup_sync_service.go Made withdraw root retrieval optional; missing roots no longer cause errors. Withdraw root check is now conditional, and finalized batch metadata uses L1 event's withdraw root. Clarified comments.

Sequence Diagram(s)

sequenceDiagram
    participant RollupSyncService
    participant LocalNode
    participant L1Event

    RollupSyncService->>LocalNode: Fetch block state for withdraw root
    alt State available
        LocalNode-->>RollupSyncService: Return withdraw root
        RollupSyncService->>RollupSyncService: Compare local withdraw root to L1 event (if not empty)
    else State unavailable
        LocalNode-->>RollupSyncService: No state (withdraw root missing)
        RollupSyncService->>RollupSyncService: Log trace, skip withdraw root check
    end
    RollupSyncService->>L1Event: Use L1 event's withdraw root for finalized batch metadata
Loading

Poem

Patch forty-four, a hop ahead,
Withdraw roots now gently tread.
If missing, we don’t raise a fuss,
Trusting L1 to guide us.
The sync rolls on, the code feels light—
A rabbit’s leap, all bugs in flight!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (3)
rollup/rollup_sync_service/rollup_sync_service.go (3)

401-410: Heavy per-block StateAt calls can hurt performance

StateAt reconstructs a full StateDB from the trie; executing it once per block in every chunk is O(n × state-root-lookup) and can become a CPU / IO bottleneck when finalising large bundles.

-            state, err := s.bc.StateAt(block.Root())
+            // PERF: We only need the withdraw root of the *end* block for
+            // validation.  Consider limiting the expensive StateAt call to the
+            // last block of the batch or caching results across iterations.
+            state, err := s.bc.StateAt(block.Root())

Even if you keep the current semantics, adding a TODO and a fast-path cache for identical block.Root() values would give an easy win.


403-409: Differentiate between “state pruned” and “unexpected error”

All StateAt errors are treated the same. A genuine DB corruption would be silently ignored just like a harmless “missing trie node”, making debugging hard.

Consider:

-            log.Trace("State is not available, skipping withdraw trie validation", ...
+            if errors.Is(err, core.MissingTrieNodeError) { // pseudo‐code
+                log.Trace("Historical state pruned – skipping withdraw-root check",
+                    "blockNumber", block.NumberU64(), "err", err)
+            } else {
+                log.Warn("State lookup failed – withdraw-root check skipped!",
+                    "blockNumber", block.NumberU64(), "err", err)
+            }

This keeps the relaxed behaviour for pruned nodes while surfacing unexpected failures.


581-584: Use a named zero hash for readability

Minor style nit: comparing to a literal common.Hash{} is harder to read than using a clearly named variable.

-        if localWithdrawRoot != (common.Hash{}) && localWithdrawRoot != event.WithdrawRoot() {
+        var zeroHash common.Hash
+        if localWithdrawRoot != zeroHash && localWithdrawRoot != event.WithdrawRoot() {

This also avoids allocating a new empty struct on every comparison.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d72990 and bed9135.

📒 Files selected for processing (2)
  • params/version.go (1 hunks)
  • rollup/rollup_sync_service/rollup_sync_service.go (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
rollup/rollup_sync_service/rollup_sync_service.go (2)
rollup/withdrawtrie/withdraw_trie.go (1)
  • ReadWTRSlot (16-18)
rollup/rcfg/config.go (1)
  • L2MessageQueueAddress (16-16)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
params/version.go (1)

27-29: LGTM – version bump only

Patch version increment to 44 looks correct and is consistent with the new feature flag. No additional action needed.

rollup/rollup_sync_service/rollup_sync_service.go (1)

612-613: Storing L1 withdraw root may surprise downstream consumers

finalizedBatchMeta.WithdrawRoot is now always taken from the L1 event, even when a local root was available and verified.
If any downstream logic expects the value to reflect the local chain (e.g., for auditing), this silent switch could be confusing.

Please double-check all readers of FinalizedBatchMeta.WithdrawRoot to ensure they do not rely on it containing the local value.

@Thegaram Thegaram merged commit 3edb331 into develop May 9, 2025
14 checks passed
@Thegaram Thegaram deleted the feat-make-withdraw-root-check-optional branch May 9, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants