ethereum / execution-specs

Specification for the Execution Layer. Tracking network upgrades.
Creative Commons Zero v1.0 Universal
832 stars 234 forks source link

Delete empty account at `BEACON_ROOTS_ADDRESS` #871

Closed gurukamath closed 7 months ago

gurukamath commented 8 months ago

What was wrong?

The current implementation of EIP-4788 did not delete the account at BEACON_ROOTS_ADDRESS if it is empty after being touched by the system message call. For example, in a case where the contract has not been deployed yet. EIP-4788 does not explicitly mention this deletion but it is implied post EIP-161

How was it fixed?

Delete the account at BEACON_ROOTS_ADDRESS if it is empty.

codecov-commenter commented 8 months ago

Codecov Report

Attention: 2112 lines in your changes are missing coverage. Please review.

Comparison is base (bf47143) 69.96% compared to head (4938522) 69.83%. Report is 25 commits behind head on forks/cancun.

Files Patch % Lines
src/ethereum/cancun/fork.py 0.00% 236 Missing :warning:
src/ethereum/cancun/vm/instructions/system.py 0.00% 207 Missing :warning:
src/ethereum/cancun/vm/instructions/__init__.py 0.00% 162 Missing :warning:
src/ethereum/cancun/vm/instructions/environment.py 0.00% 153 Missing :warning:
src/ethereum/cancun/state.py 0.00% 149 Missing :warning:
src/ethereum/cancun/vm/interpreter.py 0.00% 112 Missing :warning:
src/ethereum/cancun/vm/instructions/arithmetic.py 0.00% 109 Missing :warning:
src/ethereum/cancun/vm/instructions/stack.py 0.00% 98 Missing :warning:
src/ethereum/cancun/vm/gas.py 0.00% 97 Missing :warning:
src/ethereum/cancun/vm/__init__.py 0.00% 77 Missing :warning:
... and 35 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## forks/cancun #871 +/- ## ================================================ - Coverage 69.96% 69.83% -0.13% ================================================ Files 610 610 Lines 34295 34773 +478 ================================================ + Hits 23993 24283 +290 - Misses 10302 10490 +188 ``` | [Flag](https://app.codecov.io/gh/ethereum/execution-specs/pull/871/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/ethereum/execution-specs/pull/871/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `69.83% <12.69%> (-0.13%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

petertdavies commented 8 months ago

The question of whether BEACON_ROOTS_ADDRESS gets cleared is verifiably moot, because the account is not empty and cannot become empty. My recollection is that it was decided to remove the test from execution-spec-tests, rather than force everyone to implement this. If that's the case I don't see why we should be added code to the specs.

gurukamath commented 8 months ago

The question of whether BEACON_ROOTS_ADDRESS gets cleared is verifiably moot, because the account is not empty and cannot become empty. My recollection is that it was decided to remove the test from execution-spec-tests, rather than force everyone to implement this. If that's the case I don't see why we should be added code to the specs.

The way the ethereum/tests for cancun are currently filled, this account can end up being touched and empty. Will check with the team. @marioevz Any comments on this?

marioevz commented 7 months ago

Execution spec tests fix: https://github.com/ethereum/execution-spec-tests/pull/425

Still looking into ethereum/tests.

gurukamath commented 7 months ago

Opened issue for this to be fixed in the ethereum/tests repo

chfast commented 7 months ago

EIP-7523 fixes this because then the BEACON_ROOTS_ADDRESS cannot be empty in the pre-state.

winsvega commented 7 months ago

but can it be non existent? and if it is non existent then if no code exists at BEACON_ROOTS_ADDRESS, the call must fail silently meanin the current ethereum/tests are correct

chfast commented 7 months ago

Exactly. Most of the tests don't have the BEACON_ROOTS_ADDRESS code in the state and they work fine. The system call works as a call to a non-existent account.

winsvega commented 7 months ago

but then there is this option which is also legal - to just write storages without a silent call. it creates double reading. because writing storages directly is not a call so it does not fail.

I think it would be better if:

if there is no contract in the state. deploy contract to the state. make silent call / write storages if contrac alsready in the state verify it has nonce = 1, code = CODE