optimism icon indicating copy to clipboard operation
optimism copied to clipboard

feat(ctb): Enforce maximum L2 gas limit

Open clabby opened this issue 9 months ago • 5 comments

Overview

[!NOTE] Blocked by https://github.com/ethereum-optimism/specs/pull/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 avatar May 10 '24 22:05 clabby

  • #10501 Graphite
  • #10500 Graphite 👈
  • develop

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

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

clabby avatar May 10 '24 22:05 clabby

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

codecov[bot] avatar May 10 '24 22:05 codecov[bot]

when specs pr

tynes avatar May 10 '24 22:05 tynes

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 a451ca14da2c72a8e6c7a52fd19e66026cd0eae7 and 348b165ac2a8a8f0c6c9f7d7d71a81791572981f.
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.

coderabbitai[bot] avatar May 10 '24 23:05 coderabbitai[bot]

when specs pr

https://github.com/ethereum-optimism/specs/pull/186

clabby avatar May 10 '24 23:05 clabby