Skip to content
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

feat(ctb): Enforce maximum L2 gas limit #10500

Merged
merged 2 commits into from May 13, 2024
Merged

Conversation

clabby
Copy link
Member

@clabby clabby commented May 10, 2024

Overview

Note

Blocked by ethereum-optimism/specs#186 being merged.

Enforces a maximum L2 gas limit within the SystemConfig. This change helps ensure that OP Stack chain governors keep the L2 block gas limit within a reasonable range in order to guarantee that the L2 blocks may be proven.

Constants

Name Value
MAX_GAS_LIMIT 200_000_000

Security Considerations

  • In the _setResourceConfig function, the new minimum gas limit is checked to be less than the current gasLimit. This value may never be larger than MAX_GAS_LIMIT, per the checks in _setGasLimit. This ensures that the minimumGasLimit <= maximumGasLimit

@clabby clabby requested a review from a team as a code owner May 10, 2024 22:39
@clabby clabby self-assigned this May 10, 2024
Copy link
Member Author

clabby commented May 10, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @clabby and the rest of your teammates on Graphite Graphite

Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (043ee4d) to head (348b165).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10500       +/-   ##
============================================
- Coverage    42.31%   29.22%   -13.09%     
============================================
  Files           73       31       -42     
  Lines         4838     2898     -1940     
  Branches       766      614      -152     
============================================
- Hits          2047      847     -1200     
+ Misses        2682     1976      -706     
+ Partials       109       75       -34     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-tests 40.27% <ø> (ø)

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

see 42 files with indirect coverage changes

@tynes
Copy link
Contributor

tynes commented May 10, 2024

when specs pr

@clabby clabby force-pushed the cl/ctb/sys-cfg-max-gas-limit branch from 55b0bc7 to 8c0574a Compare May 10, 2024 23:06
Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

Walkthrough

The changes across the SystemConfig components aim to enhance gas limit management by introducing an upper limit, updating versioning, improving testing for gas limit constraints, and adjusting contract addresses. These modifications strengthen gas limit handling, aligning with evolving operational needs and ensuring system reliability.

Changes

File Path Change Summary
packages/contracts-bedrock/invariant-docs/SystemConfig.md Added restriction on gas limit not exceeding upper bound alongside existing lower bound constraint.
packages/contracts-bedrock/src/L1/SystemConfig.sol
packages/contracts-bedrock/test/L1/SystemConfig.t.sol
Introduced MAX_GAS_LIMIT, updated version to "2.2.0," added maximumGasLimit function, enforced gas limit range, and added tests for gas limits.
packages/contracts-bedrock/test/invariants/SystemConfig.t.sol Renamed SystemConfig_GasLimitLowerBound_Invariant to SystemConfig_GasLimitBoundaries_Invariant, updated invariant_gasLimitBoundaries to check both bounds.
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummary.sol Updated systemConfigAddress and systemConfigProxyAddress constants affecting value storage.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between a451ca1 and 348b165.
Files ignored due to path filters (2)
  • packages/contracts-bedrock/semver-lock.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/abi/SystemConfig.json is excluded by !**/*.json
Files selected for processing (6)
  • packages/contracts-bedrock/invariant-docs/SystemConfig.md (1 hunks)
  • packages/contracts-bedrock/src/L1/SystemConfig.sol (4 hunks)
  • packages/contracts-bedrock/test/L1/SystemConfig.t.sol (2 hunks)
  • packages/contracts-bedrock/test/invariants/SystemConfig.t.sol (2 hunks)
  • packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummary.sol (2 hunks)
  • packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryCode.sol (1 hunks)
Files not summarized due to errors (1)
  • packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryCode.sol: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (4)
  • packages/contracts-bedrock/src/L1/SystemConfig.sol
  • packages/contracts-bedrock/test/L1/SystemConfig.t.sol
  • packages/contracts-bedrock/test/invariants/SystemConfig.t.sol
  • packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummary.sol
Additional comments not posted (1)
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryCode.sol (1)

44-44: Ensure the systemConfigCode constant reflects the updated MAX_GAS_LIMIT value of 200,000,000.

Verification successful

The search results confirm that the MAX_GAS_LIMIT is defined in packages/contracts-bedrock/src/L1/SystemConfig.sol with a value of 200,000,000, which matches the expected updated value mentioned in the review comment. This verifies that the systemConfigCode constant correctly reflects the updated MAX_GAS_LIMIT.

Final Response:

The MAX_GAS_LIMIT value in systemConfigCode correctly reflects the updated value of 200,000,000 as defined in packages/contracts-bedrock/src/L1/SystemConfig.sol.

  • Location: packages/contracts-bedrock/src/L1/SystemConfig.sol
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `systemConfigCode` constant reflects the new `MAX_GAS_LIMIT`.

# Test: Search for the `MAX_GAS_LIMIT` in the `systemConfigCode`. Expect: Value of 200,000,000.
rg "MAX_GAS_LIMIT" "packages/contracts-bedrock/contracts/SystemConfig.sol"

Length of output: 166



Script:

#!/bin/bash
# Description: Search for the `MAX_GAS_LIMIT` across all files to locate its definition or usage.

# Search for the string "MAX_GAS_LIMIT" across all files in the repository.
rg "MAX_GAS_LIMIT" -g "*.sol"

Length of output: 965


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@clabby clabby requested review from mds1 and removed request for smartcontracts May 10, 2024 23:06
@clabby clabby assigned mds1 and unassigned clabby May 10, 2024
Copy link
Contributor

@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: 2

@clabby clabby added the M-do-not-merge Meta: Do not merge label May 10, 2024
@clabby
Copy link
Member Author

clabby commented May 10, 2024

when specs pr

ethereum-optimism/specs#186

@clabby clabby force-pushed the cl/ctb/sys-cfg-max-gas-limit branch from 8c0574a to 0c717b1 Compare May 10, 2024 23:48
Copy link
Contributor

@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

packages/contracts-bedrock/invariant-docs/SystemConfig.md Outdated Show resolved Hide resolved
@clabby clabby force-pushed the cl/ctb/sys-cfg-max-gas-limit branch 2 times, most recently from 46217cf to d90f128 Compare May 11, 2024 00:02
Copy link
Contributor

@maurelian maurelian left a comment

Choose a reason for hiding this comment

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

Definitely need to fix that test typo with the suggested fix from @mds1, then LGTM.

Copy link
Contributor

@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

clabby and others added 2 commits May 13, 2024 10:14
Enforces a maximum L2 gas limit within the `SystemConfig`. This change
helps ensure that OP Stack chain governors keep the L2 block gas limit
within a reasonable range in order to guarantee that the L2 blocks may
be proven.

* In the `_setResourceConfig` function, the new minimum gas limit is
checked to be less than the current `gasLimit`. This value may never be
larger than `MAX_GAS_LIMIT`, per the checks in `_setGasLimit`. This
ensures that the `minimumGasLimit <= maximumGasLimit`
Co-authored-by: Matt Solomon <matt@mattsolomon.dev>
@clabby clabby force-pushed the cl/ctb/sys-cfg-max-gas-limit branch from a451ca1 to 348b165 Compare May 13, 2024 14:19
Copy link
Contributor

@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: 2

@clabby clabby removed the M-do-not-merge Meta: Do not merge label May 13, 2024
@clabby clabby added this pull request to the merge queue May 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 13, 2024
@clabby clabby added this pull request to the merge queue May 13, 2024
Merged via the queue into develop with commit 2c63288 May 13, 2024
72 checks passed
@clabby clabby deleted the cl/ctb/sys-cfg-max-gas-limit branch May 13, 2024 16:21
Inphi pushed a commit that referenced this pull request May 14, 2024
* feat(ctb): Enforce maximum L2 gas limit

Enforces a maximum L2 gas limit within the `SystemConfig`. This change
helps ensure that OP Stack chain governors keep the L2 block gas limit
within a reasonable range in order to guarantee that the L2 blocks may
be proven.

* In the `_setResourceConfig` function, the new minimum gas limit is
checked to be less than the current `gasLimit`. This value may never be
larger than `MAX_GAS_LIMIT`, per the checks in `_setGasLimit`. This
ensures that the `minimumGasLimit <= maximumGasLimit`

* Update SystemConfig.t.sol

Co-authored-by: Matt Solomon <matt@mattsolomon.dev>

---------

Co-authored-by: Matt Solomon <matt@mattsolomon.dev>
clabby added a commit that referenced this pull request May 14, 2024
* feat(ctb): Enforce maximum L2 gas limit

Enforces a maximum L2 gas limit within the `SystemConfig`. This change
helps ensure that OP Stack chain governors keep the L2 block gas limit
within a reasonable range in order to guarantee that the L2 blocks may
be proven.

* In the `_setResourceConfig` function, the new minimum gas limit is
checked to be less than the current `gasLimit`. This value may never be
larger than `MAX_GAS_LIMIT`, per the checks in `_setGasLimit`. This
ensures that the `minimumGasLimit <= maximumGasLimit`

* Update SystemConfig.t.sol

Co-authored-by: Matt Solomon <matt@mattsolomon.dev>

---------

Co-authored-by: Matt Solomon <matt@mattsolomon.dev>
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.

None yet

4 participants