Skip to content

core: fix pre-check for account balance under EIP-1559#23244

Merged
fjl merged 6 commits intoethereum:masterfrom
MariusVanDerWijden:ropsten-issue
Jul 22, 2021
Merged

core: fix pre-check for account balance under EIP-1559#23244
fjl merged 6 commits intoethereum:masterfrom
MariusVanDerWijden:ropsten-issue

Conversation

@MariusVanDerWijden
Copy link
Copy Markdown
Member

@MariusVanDerWijden MariusVanDerWijden commented Jul 21, 2021

We need to account for the value transacted in the buyGas() stage, since it would otherwise
mean our check would be

assert balance >= maxFeePerGas * gas

instead of

assert balance >= tx.value + maxFeePerGas * gas

Copy link
Copy Markdown
Contributor

@holiman holiman 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 @MariusVanDerWijden !

@holiman
Copy link
Copy Markdown
Contributor

holiman commented Jul 21, 2021

I added a repro-example, which can be used by other clients to verify the behaviour. cc @winsvega @MarekM25 .

@fjl fjl merged commit 97aacd9 into ethereum:master Jul 22, 2021
@fjl fjl added this to the 1.10.6 milestone Jul 22, 2021
@fjl fjl changed the title core: check that account has enough balance for value + gas * gasFeeCap core: fix pre-check for account balance under EIP-1559 Jul 22, 2021
Comment thread core/state_transition.go
if st.gasFeeCap != nil {
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
balanceCheck.Add(balanceCheck, st.value)
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.

Just FYI this change makes this comment stale

// 2. caller has enough balance to cover transaction fee(gaslimit * gasprice)

sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Jul 28, 2021
When processing a transaction with London fork rules, EIP-1559 mandates
checking that the sender must have sufficient balance to cover gas * gasFeeCap.

In the EIP's pseudocode, this check happens after the value transferred by the
transaction has already been deducted. However, in go-ethereum, the balance
has not yet been updated when the check happens, and therefore needs to be
added explicitly.

Co-authored-by: Martin Holst Swende <martin@swende.se>
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
When processing a transaction with London fork rules, EIP-1559 mandates
checking that the sender must have sufficient balance to cover gas * gasFeeCap.

In the EIP's pseudocode, this check happens after the value transferred by the
transaction has already been deducted. However, in go-ethereum, the balance
has not yet been updated when the check happens, and therefore needs to be
added explicitly.

Co-authored-by: Martin Holst Swende <martin@swende.se>
@MariusVanDerWijden MariusVanDerWijden deleted the ropsten-issue branch November 30, 2021 15:26
misterchenleiya pushed a commit to J1a-wei/go-ethereum that referenced this pull request Jun 26, 2023
When processing a transaction with London fork rules, EIP-1559 mandates
checking that the sender must have sufficient balance to cover gas * gasFeeCap.

In the EIP's pseudocode, this check happens after the value transferred by the
transaction has already been deducted. However, in go-ethereum, the balance
has not yet been updated when the check happens, and therefore needs to be
added explicitly.

Co-authored-by: Martin Holst Swende <martin@swende.se>
misterchenleiya pushed a commit to J1a-wei/go-ethereum that referenced this pull request Jun 26, 2023
core: fix pre-check for account balance under EIP-1559 (ethereum#23244)

See merge request dongwei/blockchain-go-ethereum!3
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