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

fjord: Fastlz GasPriceOracle #10534

Merged
merged 2 commits into from
May 14, 2024

Conversation

danyalprout
Copy link
Contributor

Description

This PR adds support for improving the estimation of L1 fees by compressing the transaction with fastlz, then using a linear regression to estimate the final Brotli 10 compressed size.

Tests

  • Added unit testing for Solidity implementation
  • The Go PR includes fuzz testing for the implementations against a C based fastlz/op-geth cost functions.

@danyalprout danyalprout force-pushed the fastlz-contracts branch 3 times, most recently from 49c7f7f to ab64193 Compare May 14, 2024 09:41
@danyalprout danyalprout marked this pull request as ready for review May 14, 2024 11:35
@danyalprout danyalprout requested review from a team as code owners May 14, 2024 11:35
Copy link
Contributor

coderabbitai bot commented May 14, 2024

Walkthrough

Walkthrough

This update introduces the "Fjord" allocation mode alongside the existing "Ecotone" mode across various components. Changes include configuration file updates, initialization script modifications, smart contract enhancements, and test additions to incorporate the new allocation logic, time conditions, and fee calculations associated with the Fjord mode.

Changes

File Path Change Summary
.circleci/config.yml Added references to .devnet-allocs-l2-ecotone.json in jobs and execution steps.
bedrock-devnet/devnet/__init__.py
op-chain-ops/genesis/layer_two.go
Modified file operations in devnet_l2_allocs loop to include "-ecotone" suffix. Updated L2AllocsEcotone constant and added L2AllocsFjord constant.
op-e2e/config/init.go
op-e2e/op_geth.go
op-e2e/setup.go
Added logic for L2AllocsFjord mode in various functions for allocation mode determination.
packages/contracts-bedrock/src/L2/GasPriceOracle.sol Updated to version "1.3.0" with new constants and methods for Fjord mode cost estimation and fee calculation.
packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol Added multiple test functions related to Fjord mode in GasPriceOracle contract tests.
packages/contracts-bedrock/test/kontrol/proofs/utils/DeploymentSummaryFaultProofs.sol Updated constant addresses for mipsAddress and systemConfigAddress.

Possibly Related Issues


Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5219399 and 7aac2a0.
Files ignored due to path filters (1)
  • packages/contracts-bedrock/semver-lock.json is excluded by !**/*.json
Files selected for processing (2)
  • packages/contracts-bedrock/src/L2/GasPriceOracle.sol (5 hunks)
  • packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol (2 hunks)
Additional comments not posted (11)
packages/contracts-bedrock/src/L2/GasPriceOracle.sol (7)

32-42: New constants for Fjord upgrade are well-defined and documented.


47-49: The isFjord state variable is introduced to track the Fjord upgrade status.


55-57: The getL1Fee method correctly uses the isFjord state variable to determine the fee calculation method.


63-78: The getL1FeeUpperBound method is well-implemented and provides a gas-efficient way to estimate L1 transaction costs.


90-98: The setFjord method includes appropriate checks and is well-implemented.


163-171: The getL1GasUsed method correctly applies the Fjord linear regression for gas estimation.


223-242: The _fjordL1Cost and _fjordLinearRegression methods are well-documented and correctly implement the linear regression for fee estimation.

packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol (4)

112-117: The test_setFjord_withoutEcotone_reverts method correctly tests that Fjord cannot be activated without activating Ecotone.


213-233: The GasPriceOracleFjordActive_Test contract includes comprehensive tests for the Fjord upgrade.


287-306: The test_getL1FeeMinimumBound_succeeds method is well-implemented and verifies the correct fee calculation for the minimum bound.


308-331: The test_getL1FeeRegression_succeeds method is well-implemented and verifies the correct fee calculation using the linear regression.


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.

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

Out of diff range and nitpick comments (5)
bedrock-devnet/devnet/__init__.py (5)

Line range hint 7-7: Remove unused import calendar.

The calendar module is imported but not used in the code. Removing it will clean up the code.

-import calendar

Line range hint 12-12: Remove unused import gzip.

The gzip module is imported but not used in the code. Removing it will clean up the code.

-import gzip

Line range hint 18-18: Remove unused import devnet.log_setup.

The devnet.log_setup module is imported but not used in the code. Removing it will clean up the code.

-import devnet.log_setup

Line range hint 221-221: Avoid equality comparisons to False.

Use if not os.path.exists(l2_allocs_path): instead of if os.path.exists(l2_allocs_path) == False: for better readability.

-    if os.path.exists(l2_allocs_path) == False or DEVNET_FPAC == True:
+    if not os.path.exists(l2_allocs_path) or DEVNET_FPAC:

Line range hint 310-310: Remove unused variable e.

The variable e is assigned but never used. Removing it will clean up the code.

        except Exception as e:
-            raise RuntimeError(f"Error executing '{' '.join(command.args)}': {e}")
+            raise RuntimeError(f"Error executing '{' '.join(command.args)}'")

@tynes
Copy link
Contributor

tynes commented May 14, 2024

Just small nits, generally looks good to me

@tynes tynes enabled auto-merge May 14, 2024 13:06
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 (1)
packages/contracts-bedrock/src/L2/GasPriceOracle.sol (1)

29-31: Update the version constant to reflect the new version.

Ensure that the version number is updated consistently across all relevant documentation and deployment scripts.

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.

Still LGTM!

@tynes tynes added this pull request to the merge queue May 14, 2024
Merged via the queue into ethereum-optimism:develop with commit 52abfb5 May 14, 2024
69 checks passed
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

3 participants