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

contracts-bedrock: ecotone gas config support #10226

Merged
merged 29 commits into from May 20, 2024
Merged

Conversation

tynes
Copy link
Contributor

@tynes tynes commented Apr 19, 2024

Description

Updates the gas config on the SystemConfig to be ecotone first.
This resolves chain operator ux issues with setting the gas config,
rendering the additional tooling for calculating the encoded
scalar version obsolete. This version of the system config
is technically backwards compatible with pre-ecotone, but it
requires a follow up tx to call the old setGasConfig method.
The old gas config method was updated such that it cannot
be used to set ecotone style config to prevent footguns.
A new method setGasConfigEcotone should be used instead.

Copy link
Contributor

github-actions bot commented May 7, 2024

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label May 7, 2024
@tynes tynes added S-exempt-stale Status: Do not mark stale and removed Stale labels May 7, 2024
@tynes tynes marked this pull request as ready for review May 10, 2024 23:51
@tynes tynes requested a review from a team as a code owner May 10, 2024 23:51
@tynes tynes requested a review from maurelian May 10, 2024 23:51
@tynes tynes removed the S-exempt-stale Status: Do not mark stale label May 10, 2024
Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

Walkthrough

The recent updates involve significant changes across various files to transition away from deprecated fields GasPriceOracleOverhead and GasPriceOracleScalar towards GasPriceOracleBaseFeeScalar and GasPriceOracleBlobBaseFeeScalar. These changes impact configuration structs, validation logic, test cases, gas benchmarks, and deployment scripts.

Changes

Files Change Summary
op-chain-ops/genesis/config.go
op-chain-ops/upgrades/l1.go
Removed deprecated fields and related checks in DeployConfig and SystemConfig functions.
op-node/rollup/types.go
op-node/rollup/types_test.go
Eliminated ErrMissingOverhead error handling and related tests.
packages/contracts-bedrock/.gas-snapshot Updated gas benchmarks for various functions.
packages/contracts-bedrock/scripts/ChainAssertions.sol Adjusted comparison requirements for configuration parameters.
packages/contracts-bedrock/scripts/Deploy.s.sol
packages/contracts-bedrock/scripts/DeployConfig.s.sol
Replaced deprecated fields with new scalar values.
packages/contracts-bedrock/scripts/go-ffi/differential-testing.go Added encoding/decoding cases for scalar values.
op-e2e/actions/ecotone_fork_test.go
op-e2e/custom_gas_token_test.go
op-e2e/system_test.go
op-e2e/system_tob_test.go
Updated comparisons and variable names related to gas parameters.
packages/contracts-bedrock/test/L1/SystemConfig.t.sol Added new fields, assertions, and test functions related to scalar values.
packages/contracts-bedrock/src/L1/SystemConfig.sol Added deprecation notice and new declarations for scalar values.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2269ae0 and fe50b75.
Files selected for processing (1)
  • packages/contracts-bedrock/test/L1/SystemConfig.t.sol (11 hunks)
Additional comments not posted (3)
packages/contracts-bedrock/test/L1/SystemConfig.t.sol (3)

546-562: Validate encoding and decoding logic for new scalar values.

Ensure that the encoding and decoding logic for basefeeScalar and blobbasefeeScalar is correctly implemented and consistent across different parts of the contract.


55-60: Validate the default values for basefeeScalar and blobbasefeeScalar.

Ensure that the default values for basefeeScalar and blobbasefeeScalar are set correctly in the SystemConfig contract to match the expected defaults in the test environment.

Verification successful

The previous attempts to extract the initialize function from the SystemConfig contract did not yield the necessary details. To ensure we verify the default values for basefeeScalar and blobbasefeeScalar, we need to refine our approach.

Let's directly search for the basefeeScalar and blobbasefeeScalar within the SystemConfig contract to identify their default values.


The search results indicate that the default values for basefeeScalar and blobbasefeeScalar are set to 0 in the SystemConfig contract. This matches the expected defaults in the test environment.

  • basefeeScalar is set to 0.
  • blobbasefeeScalar is set to 0.

These values are consistent with the assertions in the test file.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the default values for `basefeeScalar` and `blobbasefeeScalar` are set correctly across different environments.

# Test: Search for the default values setting in the contract initialization.
rg --type solidity $'SystemConfig.initialize'

Length of output: 77



Script:

#!/bin/bash
# Description: Verify that the default values for `basefeeScalar` and `blobbasefeeScalar` are set correctly across different environments.

# Find all Solidity files and search for the `initialize` function within them.
fd -e sol -x rg 'initialize' {}

Length of output: 30928



Script:

#!/bin/bash
# Description: Verify the default values for `basefeeScalar` and `blobbasefeeScalar` in the `SystemConfig` contract.

# Find the `SystemConfig` contract file.
fd -e sol -x rg 'contract SystemConfig' {}

# Extract the initialization method from the `SystemConfig` contract.
fd -e sol -x rg -A 20 'function initialize' {}

Length of output: 41688



Script:

#!/bin/bash
# Description: Extract the `initialize` function from the `SystemConfig` contract to verify the default values for `basefeeScalar` and `blobbasefeeScalar`.

# Find the `SystemConfig` contract file.
fd -e sol -x rg 'contract SystemConfig' {}

# Extract the `initialize` function from the `SystemConfig` contract.
fd -e sol -x rg -A 20 'function initialize' {} | rg 'SystemConfig'

Length of output: 1599



Script:

#!/bin/bash
# Description: Extract the `initialize` function from the `SystemConfig` contract to verify the default values for `basefeeScalar` and `blobbasefeeScalar`.

# Find the `SystemConfig` contract file.
fd -e sol -x rg 'contract SystemConfig' {}

# Extract the `initialize` function from the `SystemConfig` contract.
fd -e sol -x rg -A 50 'function initialize' {} | rg 'SystemConfig'

Length of output: 2095



Script:

#!/bin/bash
# Description: Extract the `initialize` function from the `SystemConfig` contract to verify the default values for `basefeeScalar` and `blobbasefeeScalar`.

# Find the `SystemConfig` contract file.
fd -e sol -x rg 'contract SystemConfig' {}

# Extract the `initialize` function from the `SystemConfig` contract.
fd -e sol -x rg -A 50 'function initialize' {} | rg 'SystemConfig'

Length of output: 2095



Script:

#!/bin/bash
# Description: Verify the default values for `basefeeScalar` and `blobbasefeeScalar` in the `SystemConfig` contract.

# Find the `SystemConfig` contract file.
fd -e sol -x rg 'contract SystemConfig' {}

# Search for `basefeeScalar` and `blobbasefeeScalar` within the `SystemConfig` contract.
fd -e sol -x rg 'basefeeScalar' {}
fd -e sol -x rg 'blobbasefeeScalar' {}

Length of output: 6544


83-92: Check the initialization logic for basefeeScalar and blobbasefeeScalar.

Ensure that the initialization logic for basefeeScalar and blobbasefeeScalar is correctly implemented and consistent across different test environments.

Verification successful
#!/bin/bash
# Description: Extract the initialize function from SystemConfig.sol to verify the initialization logic for basefeeScalar and blobbasefeeScalar.

# Step 1: Extract the initialize function from SystemConfig.sol.
ast-grep --lang solidity --pattern $'function initialize($_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_

---

The `initialize` function in `SystemConfig.sol` correctly sets the values for `basefeeScalar` and `blobbasefeeScalar` using the `_setGasConfigEcotone` function. This confirms that the initialization logic for these scalar values is implemented.

- `basefeeScalar` and `blobbasefeeScalar` are initialized in the `initialize` function.
- The values are set using the `_setGasConfigEcotone` function.



</details>

<details>
<summary>Scripts Executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Description: Verify the initialization logic for new scalar values in different test environments.

# Test: Search for the initialization logic in the contract.
rg --type solidity $'SystemConfig.initialize'

Length of output: 77



Script:

#!/bin/bash
# Description: Verify the initialization logic for new scalar values in different test environments.

# Test: Search for the initialization logic in the contract.
rg --type sol $'function initialize'

Length of output: 65



Script:

#!/bin/bash
# Description: Verify the initialization logic for new scalar values in different test environments.

# Step 1: Find all Solidity files.
fd -e sol > sol_files.txt

# Step 2: Search for the `initialize` function within those files.
rg 'function initialize' $(cat sol_files.txt)

Length of output: 23070




Script:

#!/bin/bash
# Description: Extract the initialize function from SystemConfig.sol to verify the initialization logic for basefeeScalar and blobbasefeeScalar.

# Step 1: Extract the initialize function from SystemConfig.sol.
ast-grep --lang solidity --pattern $'function initialize($_) { $$$ }' packages/contracts-bedrock/src/L1/SystemConfig.sol

Length of output: 238



Script:

#!/bin/bash
# Description: Extract the initialize function from SystemConfig.sol to verify the initialization logic for basefeeScalar and blobbasefeeScalar.

# Step 1: Search for the initialize function in SystemConfig.sol.
rg 'function initialize' packages/contracts-bedrock/src/L1/SystemConfig.sol -A 50

Length of output: 2537


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.

@tynes
Copy link
Contributor Author

tynes commented May 10, 2024

@sebastianst I have addressed all open comments on this PR

Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

LGTM, a few non-blocking possible improvements and cleanups

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: 0

Out of diff range and nitpick comments (2)
packages/contracts-bedrock/src/L1/SystemConfig.sol (2)

88-88: Deprecated comment should be updated to reflect the new context.

Consider updating the comment to clarify that overhead is deprecated and should not be used in new configurations.


92-93: Clarify the usage of the most significant byte in scalar.

The comment could be expanded to explain how the most significant byte is used to determine the version. This will help maintainers understand the versioning mechanism better.

@maurelian
Copy link
Contributor

Seeing failures in the SystemConfig_Initialize_TestFail and SystemConfig_Initialize_Test suites, possible related to the conflict in differential-testing.go?

@tynes
Copy link
Contributor Author

tynes commented May 13, 2024

Seeing failures in the SystemConfig_Initialize_TestFail and SystemConfig_Initialize_Test suites, possible related to the conflict in differential-testing.go?

I have rebased

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

op-chain-ops/genesis/config.go Outdated Show resolved Hide resolved
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: 0

Out of diff range and nitpick comments (3)
packages/contracts-bedrock/src/L1/SystemConfig.sol (2)

93-93: Deprecated overhead should be clearly documented.

Consider adding a @deprecated tag in the comment for overhead to clearly indicate its deprecation status in the documentation.


97-98: Clarify versioning in scalar documentation.

The comment on scalar mentions versioning but does not explain how versions are determined. Consider expanding this comment to include details on how versions are encoded and decoded.

packages/contracts-bedrock/test/L1/SystemConfig.t.sol (1)

234-235: Use realistic values for basefee and blobbasefee scalars in tests.

Consider using more realistic values for basefeeScalar and blobbasefeeScalar in the cleanStorageAndInit function to better reflect production scenarios.

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: 3

Out of diff range and nitpick comments (8)
op-chain-ops/upgrades/l1.go (8)

Line range hint 2-2: Ensure consistent package naming conventions.

The package name upgrades is very generic. Consider renaming it to something more specific to its functionality, like contractUpgrades or l1Upgrades, to improve clarity and avoid potential conflicts.


Line range hint 10-10: Consider using a more descriptive variable name.

The variable method is used to represent the method name setBytes32. A more descriptive name like storageSetterMethod could improve readability and maintainability.


Line range hint 18-18: Consider handling potential nil pointer dereferences.

In the function L1, there is no null check for the parameters config and chainConfig before they are used. This could lead to runtime panics if nil is passed. Consider adding checks and returning an appropriate error if they are nil.


Line range hint 20-20: Optimize error handling for better clarity.

The error messages in the L1 function could be more descriptive. Instead of just stating the contract name, include more context about what specifically failed, such as the operation being performed.


Line range hint 22-22: Ensure error handling consistency.

The function L1CrossDomainMessenger and other similar functions do not handle errors consistently. Some errors are returned directly while others are wrapped with additional context. It's important to maintain consistency in how errors are handled and reported.


Line range hint 24-24: Avoid hard-coded values in production code.

The use of hard-coded addresses and values, such as in the storageSetterAddr, can lead to maintenance issues and less flexibility. Consider fetching these values from a configuration file or environment variables.


Line range hint 28-28: Ensure proper resource cleanup and error handling.

In the SystemConfig function, there is a potential resource leak where storageSetterABI is fetched but not used in some error paths. Ensure that all resources are properly released or handled in all code paths.


Line range hint 30-30: Consider adding more comprehensive logging.

The functions lack detailed logging which could help in debugging issues during the upgrade process. Consider adding detailed logs that capture key steps and variable values.

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (7ef1bcf) to head (fe50b75).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10226       +/-   ##
============================================
- Coverage    42.36%   29.22%   -13.15%     
============================================
  Files           73       31       -42     
  Lines         4836     2898     -1938     
  Branches       766      614      -152     
============================================
- Hits          2049      847     -1202     
+ Misses        2680     1976      -704     
+ Partials       107       75       -32     
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 Author

tynes commented May 20, 2024

I have addressed merge conflicts with a rebase

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: 0

Outside diff range and nitpick comments (1)
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryFaultProofs.sol (1)

Line range hint 248-403: Review the extensive use of vm.store for potential optimization.

The function recreateDeployment uses multiple vm.store calls with similar patterns. Consider refactoring to reduce redundancy and improve maintainability, possibly by creating helper functions or loops for repetitive tasks.

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

Outside diff range and nitpick comments (2)
packages/contracts-bedrock/test/L1/SystemConfig.t.sol (2)

34-42: Ensure consistent use of basefeeScalar and blobbasefeeScalar across all tests.

The setup function initializes basefeeScalar and blobbasefeeScalar which are used across various tests. It's crucial to ensure that these values are consistently used in all relevant test cases to maintain the integrity of the tests.


290-291: Review the use of default scalar values in resource configuration tests.

In the _initializeWithResourceConfig function, the use of default scalar values (_basefeeScalar: 0, _blobbasefeeScalar: 0) might not fully test the behavior under realistic configurations. Consider using more representative values to enhance the test's effectiveness.

@tynes tynes enabled auto-merge May 20, 2024 21:50
@tynes tynes added this pull request to the merge queue May 20, 2024
Merged via the queue into develop with commit 9300db9 May 20, 2024
72 checks passed
@tynes tynes deleted the feat/sys-config-ecotone branch May 20, 2024 22:33
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

5 participants