Skip to content

Fjord: Add FastLZ compression into L1CostFunc#249

Merged
sebastianst merged 13 commits intoethereum-optimism:optimismfrom
base:flz-l1-cost-func
May 15, 2024
Merged

Fjord: Add FastLZ compression into L1CostFunc#249
sebastianst merged 13 commits intoethereum-optimism:optimismfrom
base:flz-l1-cost-func

Conversation

@mdehoog
Copy link
Contributor

@mdehoog mdehoog commented Feb 21, 2024

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 DataGas part of the L1CostFunc. Companion optimism PR is here: ethereum-optimism/optimism#9618

Tests

TODO

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.

@sebastianst sebastianst changed the title [Fjord] Add FastLZ compression into L1CostFunc Fjord: Add FastLZ compression into L1CostFunc Apr 9, 2024
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, thanks!

@sebastianst sebastianst marked this pull request as ready for review May 13, 2024 21:15
@sebastianst sebastianst requested a review from a team as a code owner May 13, 2024 21:15
@sebastianst sebastianst requested review from ajsutton and protolambda and removed request for a team May 13, 2024 21:15
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. FlzCompressLen is difficult to review in isolation, but the tests in the monorepo for it look good. Still looking into the differences with Brotli.

@danyalprout danyalprout force-pushed the flz-l1-cost-func branch 2 times, most recently from c8002af to ae09e9f Compare May 15, 2024 17:05
mdehoog and others added 3 commits May 15, 2024 20:18
Co-authored-by: Michael de Hoog <michael.dehoog@coinbase.com>
Co-authored-by: Yukai Tu <yukai.tu@coinbase.com>
Co-authored-by: Danyal Prout <danyal.prout@coinbase.com>
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.

5 participants