Skip to content

Calculate fees correctly based on zero/non-zero bytes#540

Merged
gakonst merged 5 commits intomasterfrom
fix/fee-pricing
Apr 21, 2021
Merged

Calculate fees correctly based on zero/non-zero bytes#540
gakonst merged 5 commits intomasterfrom
fix/fee-pricing

Conversation

@gakonst
Copy link
Copy Markdown
Contributor

@gakonst gakonst commented Apr 21, 2021

Fixes #515.

Does not introduce nonCallDataL1GasOverhead since we do not have a standard way to estimate / calculate it yet and seems to be a micro optimization.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 21, 2021

🦋 Changeset detected

Latest commit: bed9dc6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/l2geth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Left some comments and questions

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Apr 21, 2021

Noting this for other reviewers: the correct spelling for the plural of "zero" is both "zeros" and "zeroes"

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Apr 21, 2021

Does not introduce nonCallDataL1GasOverhead since we do not have a standard way to estimate / calculate it yet and seems to be a micro optimization.

As long as we charge slightly more than the cost of submitting the batch + running the hardware, things should be fine. The profits will go towards funding public goods

@gakonst gakonst requested a review from tynes April 21, 2021 19:30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirming the implementation:

4 * zeroDataBytes is zeroesCost
16 * (nonZeroDataBytes + RollupBaseTxSize) is onesCost
Their sum (4 * zeroDataBytes + 16 * (nonZeroDataBytes + RollupBaseTxSize)) is dataCost
(4 * zeroDataBytes + 16 * (nonZeroDataBytes + RollupBaseTxSize)) * dataPrice is dataFee
executionPrice * gasUsed is executionFee
And finally,
(4 * zeroDataBytes + 16 * (nonZeroDataBytes + RollupBaseTxSize)) * dataPrice + executionPrice * gasUsed is fee

The math looks good to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this use the constants as well? Or intentionally covering the fact that the constants may change

Copy link
Copy Markdown
Contributor Author

@gakonst gakonst Apr 21, 2021

Choose a reason for hiding this comment

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

Yeah this was intentional to avoid regressions if anything else changes (e.g. the 96 once RLP is in)

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Looks good to me pending passing integration tests. Using the exact values in the integration tests is a double edged sword, especially if they were not calculated out of band

@tynes tynes added A-geth C-bug Category: bugs labels Apr 21, 2021
@gakonst
Copy link
Copy Markdown
Contributor Author

gakonst commented Apr 21, 2021

I agree but IMO we should try pinning down certain values as regression tests. If we see this becoming a pain in the future (I don't think it will) we can consider reverting, but IMO net good now. They were calculated by console.log'ing the value before running the assertion.

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Passing integration tests, good work @gakonst 🎉

@gakonst gakonst merged commit 76c4ceb into master Apr 21, 2021
@gakonst gakonst deleted the fix/fee-pricing branch April 21, 2021 20:33
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* test: pin down gas estimation for transfers

* fix(l2geth): charge fees differently for zero/non-zero bytes of data

* test: update estimated gas values

* chore: gofmt & changeset

* fix(l2geth): calculate zeros correctly
theochap pushed a commit that referenced this pull request Dec 10, 2025
* checkpoint

* checkpoint

* compiling + passing tests

* rename error

* lint

* fix test-utils feature

* add resets

* codecov

* clean

* update codecov rules

* upload test results

* nextest cfg
theochap pushed a commit that referenced this pull request Jan 15, 2026
<!--
Thank you for your Pull Request. Please provide a description above and
review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide:
https://github.com/alloy-rs/core/blob/main/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and
building the
documentation.
-->

<!-- ** Please select "Allow edits from maintainers" in the PR Options
** -->

## Motivation

on this page is bug - https://alloy-rs.github.io/op-alloy/starting.html 

![image](https://github.com/user-attachments/assets/de4bc17e-1e39-44d1-a050-424a6f43870a)


## Solution

due to this line
https://github.com/alloy-rs/op-alloy/blob/main/book/src/links.md?plain=1#L10
we need to do this change.
## PR Checklist

- [ ] Added Tests
- [ ] Added Documentation
- [ ] Breaking changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Category: bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account for zero vs non-zero calldata bytes for L2 gas estimation

2 participants