Skip to content

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 batch processing structures by removing explicit parent batch references, improving efficiency without affecting user-facing features.

@coderabbitai
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 internal variables; accessed parent batch hash directly from batch data instead of storing parent batch object.

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!
🐇✨


📜 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 f2fa1fb and 876fad0.

📒 Files selected for processing (1)
  • rollup/internal/controller/relayer/l2_relayer.go (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rollup/internal/controller/relayer/l2_relayer.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
✨ 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 colinlyguo and jonastheis 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-commenter commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.22%. Comparing base (4ee459a) to head (876fad0).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1673   +/-   ##
========================================
  Coverage    40.21%   40.22%           
========================================
  Files          232      231    -1     
  Lines        18391    18362   -29     
========================================
- Hits          7396     7386   -10     
+ Misses       10275    10258   -17     
+ Partials       720      718    -2     
Flag Coverage Δ
rollup 46.83% <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.

@yiweichi yiweichi merged commit b0943b1 into develop Jun 18, 2025
6 checks passed
@yiweichi yiweichi deleted the refactor-simplify-construct-batch-payload branch June 18, 2025 13:37
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.

5 participants