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: Add FastLZ compression into L1CostFunc #9618

Merged
merged 14 commits into from
May 16, 2024

Conversation

mdehoog
Copy link
Contributor

@mdehoog mdehoog commented Feb 21, 2024

Reopening #8635, targeting Fjord rather than Ecotone.

Description
We found that the FastLZ algorithm is a pretty good estimate for the actual results we'd see from zlib compressing the batches we write to L1 (albeit with a different scalar as the compression ratios aren't quite as good). See https://github.com/roberto-bayardo/compression-analysis and this sheet.

This PR introduces a flzCompress call into the GasPriceOracle. Companion op-geth PR is here: ethereum-optimism/op-geth#249

Actual GPO update was split out into a new PR: #10534

See specs update here: ethereum-optimism/specs#25

Tests

Added tests comparing compression results from solidity + golang + a reference C implementation.

Additional context

The current naive L1Cost approach:

l1fee = ((0s in calldata) * 4 + (1s in calldata) * 16 + 188) * l1BaseFee * 0.684

works pretty well on average, but penalizes very compressible txs (e.g.), and undercharges incompressible txs (e.g.). This change makes the L1CostFunc much fairer compared to real-world L1 costs.

Copy link
Contributor

coderabbitai bot commented Feb 21, 2024

Walkthrough

Walkthrough

The update brings significant enhancements across various components. Key changes include adding a fuzz-golang workflow in CircleCI, renaming EcostoneScalars to EcotoneScalars in multiple files, introducing new test functions for the Fjord network upgrade, implementing FastLZ compression, and adjusting method signatures to use testing.TB instead of *testing.T.

Changes

File Change Summary
.circleci/config.yml Added fuzz-golang workflow for op-e2e.
op-chain-ops/cmd/ecotone-scalar/main.go
op-chain-ops/genesis/config.go
Replaced EcostoneScalars with EcotoneScalars.
op-e2e/Makefile Added fuzz target for fuzz testing.
op-e2e/actions/fjord_fork_test.go Introduced Fjord network upgrade transaction tests.
op-e2e/actions/l2_sequencer.go Added ActBuildL2ToFjord method.
op-e2e/external.go
op-e2e/external/config.go
Changed parameter types to testing.TB.
op-e2e/fastlz/fastlz.c
op-e2e/fastlz/fastlz.go
op-e2e/fastlz/fastlz.h
Introduced FastLZ compression library.
op-e2e/fastlz_test.go Added FastLZ compression fuzz tests.
op-e2e/op_geth.go
op-e2e/setup.go
Updated method signatures to use testing.TB.
op-e2e/system_test.go Enhanced TestFees with Fjord test cases.
op-node/rollup/derive/attributes.go Added Fjord activation block handling.
op-node/rollup/derive/fjord_upgrade_transactions.go Added Fjord network upgrade transaction handling.
op-node/rollup/driver/sequencer.go Added condition to skip Fjord activation block transactions.
op-node/rollup/types.go Added IsFjordActivationBlock method.
op-node/rollup/types_test.go Refactored upgrade tests into TestActivations.
op-service/eth/types.go
op-service/eth/types_test.go
Renamed and updated methods for EcotoneScalars.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between dc2d474 and fe398ca.
Files selected for processing (1)
  • op-e2e/fastlz_test.go (1 hunks)
Additional comments not posted (6)
op-e2e/fastlz_test.go (6)

79-85: Ensure all configuration offsets are correctly set.

Double-check that all L2Genesis offsets are correctly set to ensure the test environment is properly configured.


124-131: Ensure the state getter is correctly initialized.

Verify that the testStateGetter is correctly initialized with the appropriate values for baseFee, blobBaseFee, overhead, scalar, baseFeeScalar, and blobBaseFeeScalar.


145-177: Ensure the fuzzing logic correctly handles edge cases.

Double-check that the fuzzing logic correctly handles edge cases, such as very small or very large input data, to ensure comprehensive test coverage.


185-192: Ensure the contract ABI and bytecode are correctly set.

Double-check that the contract ABI and bytecode are correctly set to ensure the test environment is properly configured.


199-214: Ensure the fuzzing logic correctly handles edge cases.

Double-check that the fuzzing logic correctly handles edge cases, such as very small or very large input data, to ensure comprehensive test coverage.


222-234: Ensure the fuzzing logic correctly handles edge cases.

Double-check that the fuzzing logic correctly handles edge cases, such as very small or very large input data, to ensure comprehensive test coverage.


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

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 Stale and removed Stale labels Mar 13, 2024
@sebastianst sebastianst changed the title [Fjord] Add FastLZ compression into L1CostFunc Fjord: Add FastLZ compression into L1CostFunc Apr 5, 2024
Copy link
Contributor

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 Apr 25, 2024
@danyalprout danyalprout removed the Stale label Apr 26, 2024
@danyalprout danyalprout force-pushed the flz-l1-cost-func branch 8 times, most recently from 3f53d5c to 13b327d Compare April 30, 2024 15:59
@danyalprout danyalprout force-pushed the flz-l1-cost-func branch 2 times, most recently from 6413a3e to c537fb0 Compare May 2, 2024 10:55
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

Copy link
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

Generally looks good. One test uses unsafe Go & CGO and needs a fix for GC safety I believe. And a smart-contracts engineer should confirm the fjordGasPriceOracleCodeHash and test tx that is referenced in the fjord_fork_test.go are sufficient (I did check that first layer of the upgrade tx execution is a regular contract deployment, but not past that, and EVM bytecode can behave different depending on the simulation environment).

@sebastianst sebastianst enabled auto-merge May 16, 2024 14:07
@sebastianst sebastianst added this pull request to the merge queue May 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 16, 2024
@sebastianst sebastianst added this pull request to the merge queue May 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 16, 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: 3

@sebastianst sebastianst enabled auto-merge May 16, 2024 15:51
@sebastianst sebastianst added this pull request to the merge queue May 16, 2024
Merged via the queue into ethereum-optimism:develop with commit 9eb5f88 May 16, 2024
70 checks passed
rdovgan pushed a commit to rdovgan/optimism that referenced this pull request Jun 24, 2024
* Add FastLZ for better L1Cost estimation

Co-authored-by: Michael de Hoog <[email protected]>
Co-authored-by: Danyal Prout <[email protected]>
Co-authored-by: Yukai Tu <[email protected]>
Co-authored-by: angel-ding-cb <[email protected]>

* fix all the tests

* fix: upate GPO network transactions to match spec

* Update GPO contracts

* update to 1d model / add tests

* update allocs and test framework to support new fjord contracts

* add fuzz testing

* increase minimum estimation to 100 / update circleci for e2e fuzz tests

* use linear regression for l1 gas used

* Add differential fastlz fuzzing between solady/cgo fastlz/geth fastlz

* Review feedback

* Bump geth

* fix: ensure we don't gc the data during fastlz compression

* Replace common.Hex2Bytes with common.FromHex

---------

Co-authored-by: Danyal Prout <[email protected]>
Co-authored-by: Yukai Tu <[email protected]>
Co-authored-by: angel-ding-cb <[email protected]>
Co-authored-by: Danyal Prout <[email protected]>
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.

6 participants