Skip to content

refactor(rollup-relayer): simplify construct commit batch payload #1673

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

yiweichi
Copy link
Member

@yiweichi yiweichi commented Jun 3, 2025

Purpose or design rationale of this PR

Describe your change. Make sure to answer these three questions: What does this PR do? Why does it do it? How does it do it?

Simplify logic when construct commit batch payload v7. no need to load parentBatch for ParentBatchHash.

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

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • Refactor
    • Simplified internal data structures for batch processing, removing explicit parent batch references from batch handling logic. No changes to user-facing functionality or workflows.

Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

This change refactors the batch data structure in the Layer2 relayer by removing the explicit parent batch reference from dbBatchWithChunksAndParent, replacing it with a simpler dbBatchWithChunks struct. Method signatures and internal logic are updated to use the new struct and directly reference the parent batch hash.

Changes

File(s) Change Summary
rollup/internal/controller/relayer/l2_relayer.go Removed dbBatchWithChunksAndParent struct; added dbBatchWithChunks; updated method signatures and logic to use new struct and access parent batch hash directly from batch data.

Suggested reviewers

  • georgehao
  • 0xmountaintop

Poem

A batch without a parent, now light as a breeze,
The relayer hops forward with elegant ease.
No more extra baggage, just chunks and a batch,
Simpler and cleaner—a perfect match!
With hashes in tow, it leaps down the lane,
Efficient and nimble, no need to explain!
🐇✨

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

@yiweichi yiweichi requested review from jonastheis and colinlyguo June 3, 2025 19:18
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/internal/controller/relayer/l2_relayer.go (1)

543-546: Define new dbBatchWithChunks struct
The newly introduced struct cleanly encapsulates the required fields (Batch and Chunks). Consider adding a short doc comment above this type to describe its purpose and relation to commit batch payload construction.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5204ad5 and f2fa1fb.

📒 Files selected for processing (1)
  • rollup/internal/controller/relayer/l2_relayer.go (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
rollup/internal/controller/relayer/l2_relayer.go (2)
rollup/internal/orm/batch.go (2)
  • Batch (22-72)
  • Batch (80-82)
rollup/internal/orm/chunk.go (2)
  • Chunk (20-64)
  • Chunk (72-74)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: tests
🔇 Additional comments (5)
rollup/internal/controller/relayer/l2_relayer.go (5)

380-380: Update batchesToSubmit type to the simplified struct
The slice declaration now uses the new dbBatchWithChunks type instead of the removed dbBatchWithChunksAndParent. This aligns with the refactoring objective of dropping the explicit parent batch object.


436-439: Append new struct without parent batch reference
The append call now constructs a dbBatchWithChunks instance (only Batch and Chunks) rather than the old struct that carried a ParentBatch. All downstream logic relies on Batch.ParentBatchHash, so removing the extra object is safe and simplifies the payload construction.


525-533: Adjust contextIDFromBatches to use simplified batch type
The method signature now accepts []*dbBatchWithChunks, matching the refactored struct. The implementation remains correct, building a context ID from each batch’s hash.


899-899: Update constructCommitBatchPayloadCodecV7 signature
The parameter list now takes []*dbBatchWithChunks instead of the deprecated struct. This change aligns with the refactoring to remove explicit parent-batch dependencies.


930-930: Use stored ParentBatchHash instead of parent object
Accessing b.Batch.ParentBatchHash directly here removes the need for a separate ParentBatch field. Ensure that every batch record in the DB has a valid parent_batch_hash set; otherwise, consider adding a guard to surface missing hashes early.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.86%. Comparing base (5204ad5) to head (f2fa1fb).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1673      +/-   ##
===========================================
- Coverage    40.87%   40.86%   -0.01%     
===========================================
  Files          225      225              
  Lines        18071    18070       -1     
===========================================
- Hits          7386     7385       -1     
  Misses        9968     9968              
  Partials       717      717              
Flag Coverage Δ
rollup 49.81% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants