Skip to content

core: effectiveTip = GasPrice - BaseFee instead of GasFeeCap - BaseFee #31771

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhiqiangxu
Copy link
Contributor

In buyGas, GasPrice is used to conduct the gas cost.

However when computing effectiveTip, GasFeeCap is used instead.

In theory, GasFeeCap >= GasPrice, so it may happen that the tip fee is larger than it should be.

This PR tries to reduce such confusion by computing effectiveTip by GasPrice - BaseFee instead of GasFeeCap - BaseFee.

Note that for all tx types, GasFeeCap == GasPrice always holds, so there's no problem for tx. But it's still better to make it consistent .

@zhiqiangxu zhiqiangxu requested a review from rjl493456442 as a code owner May 6, 2025 16:34
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Seems fine to me.

@@ -532,7 +532,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {

effectiveTip := msg.GasPrice
if rules.IsLondon {
effectiveTip = new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)
effectiveTip = new(big.Int).Sub(msg.GasPrice, st.evm.Context.BaseFee)
if effectiveTip.Cmp(msg.GasTipCap) > 0 {
effectiveTip = msg.GasTipCap
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this clause even happen? GasPrice is the effective price paid. In case of EIP-1559, it is a computed value based on GasFeeCap and GasTipCap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what exactly you mean by "Can this clause even happen? ", this clause will happen when rules.IsLondon is true, guess you mean something else?

Copy link
Member

Choose a reason for hiding this comment

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

msg.GasPrice is computed based on GasFeeCap and GasTipCap in case of rules.IsLondon is true.

In this case, the msg.GasPrice is essentially the baseFee + effectiveTip, where the effectiveTip is already capped by the msg.GasTipCap. So the clause below is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the clause below is unnecessary, I was planning to remove it after this PR is merged. Do you want to remove it in this PR?

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.

4 participants