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

EVM: non-empty "empty" account bugfixes #2383

Merged
merged 3 commits into from
Oct 26, 2022
Merged

Conversation

jochem-brouwer
Copy link
Member

@jochem-brouwer jochem-brouwer commented Oct 26, 2022

Thanks to @kchojn who found this bug. It was introduced by #2054

The PR fixes 4 bugs in our lib.

This is the situation:

EOA Account A has balance B, nonce 0, and (of course) no code and no storage.
Account A now sends a Tx to contract C and it forwards ALL balance upfront to pay for gas. (So, at this point, account A has 0 balance as it starts running the contract).

Now JS has 3 bugs in these situations:
Calling EXTCODEHASH on account A will put 0 on the stack, not the empty code hash, because we report that account is empty.
CALL will charge callNewAccount gas when we forward nonzero amount from the contract back into the account
SELFDESTRUCT will do the same if we selfdestruct nonzero value to account A.

@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #2383 (1cffeab) into master (a85081e) will decrease coverage by 5.19%.
The diff coverage is 91.66%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block ?
blockchain ?
client ?
common ?
devp2p 91.57% <ø> (?)
ethash ?
evm 79.50% <91.66%> (?)
rlp ∅ <ø> (∅)
statemanager ?
trie ?
tx ?
util ?
vm ?

Flags with carried forward coverage won't be shown. Click here to find out more.

@kchojn
Copy link
Contributor

kchojn commented Oct 26, 2022

Awesome, I am glad that you helped to solve the problem so quickly! it looks like there are no more problems with it, gj

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

LGTM

@jochem-brouwer jochem-brouwer merged commit 985f2aa into master Oct 26, 2022
@gitpoap-bot
Copy link

gitpoap-bot bot commented Oct 26, 2022

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2022 EthereumJS Contributor:

GitPOAP: 2022 EthereumJS Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@holgerd77 holgerd77 deleted the fix-mainnet-bug branch October 26, 2022 15:25
@qbzzt
Copy link

qbzzt commented Oct 30, 2022

Did you run https://github.com/ethereum/tests/blob/develop/src/GeneralStateTestsFiller/stExtCodeHash/extcodehashEmptyFiller.yml? It should have detected this bug because after EOA A sends its balance it should have a non-zero nonce.

Or was the problem that the balance sending tx didn't raise the nonce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants