Skip to content

feat(chunk proposer): add config parameter to limit chunk proposing by L2 gas #1622

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 8 commits into from
Mar 12, 2025

Conversation

jonastheis
Copy link
Contributor

@jonastheis jonastheis commented Mar 12, 2025

Purpose or design rationale of this PR

Add config parameter to limit chunk proposing by L2 gas

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

  • Chores

    • Updated the software version from v4.4.96 to v4.4.97.
  • New Features

    • Introduced a configurable parameter to cap Layer 2 gas usage per chunk.
    • Enhanced chunk processing by incorporating real-time tracking and metrics for Layer 2 gas consumption.
    • Expanded metrics aggregation to include overall Layer 2 gas usage details for improved observability.
    • Added validation checks for configuration parameters to ensure integrity during initialization.

@jonastheis jonastheis added the bump-version Bump the version tag for deployment label Mar 12, 2025
Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This update increments the software version from v4.4.96 to v4.4.97 in the version file and adds a new configuration field for maximum Layer 2 gas per chunk. The changes extend to the chunk proposer and utilities by introducing logic to monitor, record, and act upon Layer 2 gas usage during chunk proposals. The pull request also updates related logging and metrics functionalities.

Changes

File(s) Change Summary
common/version/version.go Updated version tag from "v4.4.96" to "v4.4.97".
rollup/internal/config/l2.go Added MaxL2GasPerChunk field to the ChunkProposerConfig struct.
rollup/internal/controller/watcher/chunk_proposer.go Added maxL2GasPerChunk and chunkL2Gas fields; updated constructor and methods (proposeChunk & recordAllChunkMetrics) with L2 gas logic.
rollup/internal/utils/utils.go Added L2Gas field to ChunkMetrics struct and updated CalculateChunkMetrics to accumulate L2 gas across blocks in a chunk.
rollup/internal/controller/watcher/batch_proposer_test.go Integrated MaxL2GasPerChunk into multiple test functions for chunk proposer configuration.
rollup/internal/controller/watcher/bundle_proposer_test.go Added MaxL2GasPerChunk parameter in testBundleProposerLimitsCodecV4 test function.
rollup/internal/controller/watcher/chunk_proposer_test.go Introduced maxL2Gas field in tests, affecting chunk proposer limit scenarios and ensuring consistent configuration across tests.
rollup/conf/config.json Added new configuration parameter "max_l2_gas_per_chunk": 20000000 in chunk_proposer_config.

Possibly related PRs

Suggested reviewers

  • colinlyguo
  • georgehao
  • Thegaram
  • 0xmountaintop

Poem

I'm a bunny with a joyful hop,
Code carrots made this update non-stop.
Version bumped and gas in check so bright,
Chunks now dance in metrics light.
With every leap, our code feels right!
🥕🐇 Happy coding, day and night!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.62.2)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package zstd: could not load export data: no export data for "github.com/scroll-tech/da-codec/encoding/zstd""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package zstd: could not load export data: no export data for "github.com/scroll-tech/da-codec/encoding/zstd""


📜 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 493c811 and 6a72d31.

📒 Files selected for processing (1)
  • common/version/version.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • common/version/version.go

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

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 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 (1)
rollup/internal/controller/watcher/batch_proposer_test.go (1)

210-210: Good use of numeric separator for readability

Using the numeric separator in 20_000_000 improves code readability for large constants.

Consider using the same formatting style (20_000_000) consistently across all test cases for better readability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3de8f61 and b74dd30.

📒 Files selected for processing (4)
  • rollup/cmd/rollup_relayer/app/app.go (1 hunks)
  • rollup/internal/controller/watcher/batch_proposer_test.go (4 hunks)
  • rollup/internal/controller/watcher/bundle_proposer_test.go (1 hunks)
  • rollup/internal/controller/watcher/chunk_proposer_test.go (13 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: tests
  • GitHub Check: tests
🔇 Additional comments (10)
rollup/internal/controller/watcher/bundle_proposer_test.go (1)

99-99: Parameter added correctly for MaxL2GasPerChunk

The addition of the MaxL2GasPerChunk parameter to the ChunkProposerConfig properly integrates the new L2 gas limit feature into the bundle proposer tests, with the value set to math.MaxUint64 which effectively means "no limit" for testing purposes.

rollup/internal/controller/watcher/batch_proposer_test.go (3)

114-114: Proper integration of L2 gas limit in batch proposer tests

The addition of the MaxL2GasPerChunk parameter with a reasonable limit of 20,000,000 is consistent with the PR objective to introduce a limit for L2 gas per chunk.


297-297: Parameter consistency in limit test cases

Setting MaxL2GasPerChunk to math.MaxUint64 in these tests ensures that the gas limit won't be a constraint in scenarios testing other limitations.


393-393: Consistent parameter values for related tests

Setting MaxL2GasPerChunk to math.MaxUint64 in the testBatchProposerMaxChunkNumPerBatchLimitCodecV4 test maintains consistent testing behavior across related test cases.

rollup/cmd/rollup_relayer/app/app.go (1)

97-99: Good defensive coding with parameter validation

The added validation check for MaxL2GasPerChunk ensures the application fails fast with a clear error message if the configuration is invalid. This follows the same pattern as other configuration validation in the file.

rollup/internal/controller/watcher/chunk_proposer_test.go (5)

24-24: New parameter for L2 gas limit properly added to test structure

Adding the maxL2Gas field to the test structure properly supports testing the new L2 gas limit feature.


67-76: Comprehensive test coverage for edge case

Good addition of a test case specifically for when MaxL2GasPerChunk is set to 0, ensuring the system behaves correctly when invalid configurations are provided.


134-147: Excellent test case for L2 gas limit behavior

The new test case "MaxL2GasPerChunkIsSecondBlock" with a specific limit of 1,153,000 provides targeted coverage for the scenario where the second block would exceed the L2 gas limit. The detailed comment explaining the test's purpose is particularly helpful.


198-198: Complete integration in NewChunkProposer initialization

The new parameter is properly passed from the test configuration to the NewChunkProposer function, ensuring the test cases will correctly validate the L2 gas limit behavior.


249-249: Consistent parameter usage in blob size limit tests

Setting MaxL2GasPerChunk to math.MaxUint64 in the blob size limit tests ensures that the blob size constraints are tested without interference from gas limits.

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/conf/config.json (1)

97-97: New L2 Gas Limit Parameter Addition

The new configuration parameter "max_l2_gas_per_chunk": 20000000 is clearly added under the "chunk_proposer_config" section. Its naming is consistent with other parameters in the section, and the provided value appears to be within an expected range. Please ensure that the unit of this value (likely in gas units) is well documented elsewhere in the codebase or accompanying documentation, so that future maintainers clearly understand its intended usage and limits.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b74dd30 and 493c811.

📒 Files selected for processing (1)
  • rollup/conf/config.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 58.82353% with 7 lines in your changes missing coverage. Please review.

Project coverage is 41.33%. Comparing base (228cba4) to head (493c811).

Files with missing lines Patch % Lines
rollup/internal/utils/utils.go 0.00% 4 Missing ⚠️
rollup/cmd/rollup_relayer/app/app.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1622      +/-   ##
===========================================
+ Coverage    41.32%   41.33%   +0.01%     
===========================================
  Files          222      222              
  Lines        18226    18243      +17     
===========================================
+ Hits          7531     7541      +10     
- Misses        9963     9970       +7     
  Partials       732      732              
Flag Coverage Δ
rollup 51.69% <58.82%> (+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.

colinlyguo
colinlyguo previously approved these changes Mar 12, 2025
Thegaram
Thegaram previously approved these changes Mar 12, 2025
@github-actions github-actions bot dismissed stale reviews from Thegaram and colinlyguo via 6a72d31 March 12, 2025 07:32
@jonastheis jonastheis merged commit fcfbc53 into develop Mar 12, 2025
1 check passed
@jonastheis jonastheis deleted the feat/limit-l2-gas-chunking branch March 12, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump-version Bump the version tag for deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants