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

core: avoid add l1Cost twice when GasFeeCap is nil #391

Merged
merged 2 commits into from
Oct 27, 2024

Conversation

zhiqiangxu
Copy link
Contributor

@zhiqiangxu zhiqiangxu commented Sep 27, 2024

The previous code will add l1Cost twice when GasFeeCap is nil, which is very confusing for readers.

This PR makes it less confusing.

@zhiqiangxu zhiqiangxu requested a review from a team as a code owner September 27, 2024 11:33
@zhiqiangxu
Copy link
Contributor Author

@protolambda could you take a look?

Copy link
Collaborator

@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.

I believe this change is correct & safe:

correctness: yes, it would be added twice to balanceCheck if balanceCheck was still set to the original msgval, and not using the gas-fee-cap. The move makes sense w.r.t. readability.

safety: msg.GasFeeCap is always set, there's never a case where it's actually nil. I can add a panic in an else where GasFeeCap == nil, and op-e2e system tests pass. And even things like the legacy tx type get the GasFeeCap by simply returning the full pre-eip1559 gas price. And the RPC code path seems to set GasFeeCap too.

If there is a legitimate case where GasFeeCap could have been nil then we want to avoid this, to not break behavior. That said, alternative execution clients implement this differently already, and if there was a problem we should have long seen the double balance-check difference by now (assuming a low enough balance dust-sweep tx on any op-stack chain occurred).

I would appreciate a sanity-check from a second reviewer here, since this is critical code. cc @ajsutton maybe.

@protolambda protolambda requested a review from ajsutton October 26, 2024 13:27
@zhiqiangxu
Copy link
Contributor Author

zhiqiangxu commented Oct 26, 2024

Quoted from here about GasFeeCap:

The case where it's nil doesn't happen in practice during block execution.

@ajsutton
Copy link
Contributor

Yeah I agree with that analysis, and the upstream PR adds weight to it as well.

@ajsutton ajsutton enabled auto-merge (squash) October 27, 2024 21:07
@ajsutton ajsutton merged commit c6b531b into ethereum-optimism:optimism Oct 27, 2024
4 of 5 checks passed
boyuan-chen pushed a commit to bobanetwork/op-geth that referenced this pull request Nov 12, 2024
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.

3 participants