optimism icon indicating copy to clipboard operation
optimism copied to clipboard

feat: custom gas token

Open tynes opened this issue 1 year ago • 8 comments

Description

Implements the custom gas token spec found in https://github.com/ethereum-optimism/specs/pull/111 Includes the full feature set and extensive test coverage.

  • contracts-bedrock: custom gas token L1 contracts
  • contracts-bedrock: custom gas token L2 contracts
  • contracts-bedrock: custom gas token contracts
  • contracts-bedrock: custom gas token scripts
  • contracts-bedrock: custom gas token tests
  • op-bindings: update with custom gas token
  • op-chain-ops: fixup tests
  • contracts-bedrock: snapshots

tynes avatar Apr 12 '24 22:04 tynes

Codecov Report

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

Project coverage is 29.22%. Comparing base (53f0080) to head (c21302e). Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10143       +/-   ##
============================================
- Coverage    42.33%   29.22%   -13.11%     
============================================
  Files           73       31       -42     
  Lines         4845     2898     -1947     
  Branches       766      614      -152     
============================================
- Hits          2051      847     -1204     
+ Misses        2684     1976      -708     
+ Partials       110       75       -35     
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 Apr 12 '24 22:04 codecov[bot]

Looks really great on my first pass. Next week I'd like to re-review the spec and give a more security-focused review of the code and tests in this PR

mds1 avatar Apr 12 '24 23:04 mds1

@mds1 Needs versions such that they are -beta+custom-gas-token

tynes avatar Apr 13 '24 01:04 tynes

implemented comments here: https://github.com/ethereum-optimism/optimism/pull/10219

0xfuturistic avatar Apr 19 '24 01:04 0xfuturistic

Semgrep found 6 sol-style-return-arg-fmt findings:

Named return arguments to functions must be appended with an underscore (_)

Ignore this finding from sol-style-return-arg-fmt.

semgrep-app[bot] avatar Apr 23 '24 04:04 semgrep-app[bot]

@mds1 This branch has been rebased on top of your codesize checks and also includes all of the recent specs changes (IGasToken). I think this PR should be good to go at this point

tynes avatar Apr 23 '24 04:04 tynes

Walkthrough

Walkthrough

The recent updates aim to standardize the naming convention by replacing WETH9 with WETH, introduce custom gas token handling in contracts, and refine gas consumption benchmarks. These changes enhance operational efficiency, streamline gas payment processes, and improve transaction management on the blockchain.

Changes

File Path Change Summary
op-bindings/predeploys/addresses.go, op-e2e/bridge_test.go,
packages/.../scripts/Artifacts.s.sol, packages/.../scripts/L2Genesis.s.sol,
packages/.../libraries/Predeploys.sol
Renamed WETH9 to WETH for consistency.
op-chain-ops/genesis/config.go Added UseCustomGasToken and CustomGasTokenAddress with validation.
packages/contracts-bedrock/.gas-snapshot Updated gas consumption benchmarks for functions.
packages/.../invariant-docs/SystemConfig.md Updated line references in SystemConfig documentation.
packages/.../scripts/Deploy.s.sol Restructured initialization order, added custom gas token handling.
packages/.../src/L1/OptimismPortal.sol, packages/.../src/L2/L1Block.sol,
packages/.../src/L2/L2StandardBridge.sol, packages/.../src/universal/StandardBridge.sol
Enhanced custom gas token functionality, updated functions for ERC20 tokens.
packages/.../test/L1/OptimismPortal.t.sol, packages/.../test/L2/L1Block.t.sol,
packages/.../test/L2/L2CrossDomainMessenger.t.sol, packages/.../test/L2/L2StandardBridge.t.sol
Added new tests for custom gas token logic.
packages/.../test/kontrol/proofs/utils/DeploymentSummary.sol Adjusted hexadecimal values for contract addresses.

Recent Review Details

Configuration used: .coderabbit.yml Review profile: CHILL

Commits Files that changed from the base of the PR and between 25fef607d534b974d244d552a2c4e478af106fee and c21302e37641567179b78ab7b1049e968e1caddd.
Files selected for processing (2)
  • packages/contracts-bedrock/.gas-snapshot (1 hunks)
  • packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (11 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/contracts-bedrock/.gas-snapshot
Additional comments not posted (3)
packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (3)

156-200: Ensure consistent handling of _isCreation and _gasLimit in depositTransaction.

This change ensures that contract creation transactions correctly target the zero address, which is a standard requirement for such operations in Ethereum. Additionally, the handling of _gasLimit is now bounded within specified limits, enhancing the robustness of the function.


446-471: Correct event parameters in testFuzz_setGasPayingToken_succeeds.

This change corrects the event parameters to ensure they accurately reflect the action being tested, which is setting a new gas paying token. The previous parameters were not aligned with the expected values for this operation.


1531-1539: Ensure that no ETH value is sent when a custom gas token is used.

This modification ensures that the depositTransaction function does not accept ETH when a custom gas token is being used, aligning with the intended logic of handling different types of gas payments.


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 Apr 23 '24 23:04 coderabbitai[bot]

Once we are code frozen for the fault proofs upgrade, then we can consider this for merge

tynes avatar Apr 24 '24 00:04 tynes

This needs another rebase now

tynes avatar May 01 '24 17:05 tynes

I am rebasing right now to fix the conflicts with semver + kontrol

tynes avatar May 02 '24 17:05 tynes