feat(specs,tests): Implement EIP-2780#2175
feat(specs,tests): Implement EIP-2780#2175gurukamath wants to merge 24 commits intoethereum:eips/amsterdam/eip-2780from
Conversation
…#2175) * refactor(bal): absence validators -> BalAccountAbsentValues * feat: raise for empty lists on BAL absence checks * refactor: changes from comments on PR ethereum#2175
…#2175) * refactor(bal): absence validators -> BalAccountAbsentValues * feat: raise for empty lists on BAL absence checks * refactor: changes from comments on PR ethereum#2175
SamWilsn
left a comment
There was a problem hiding this comment.
Quick, incomplete review
|
There's a possibility this becomes a blocker for Devnet-3 since it's listed as requirement for https://eips.ethereum.org/EIPS/eip-8037 which is included. Spencer checked with Maria, and it seems like it's not a hard requirement but it might be a good idea to get this ready to merge. |
To my mind, this needs further clarity, especially when it comes to the EIP-7702 interactions. @jochem-brouwer has nicely summarised some of the open questions in this eth magicians thread |
|
Raised a PR on the EIPs repo to clarify some interactions with EIP-7702 and EIP-7928. See here We can proceed to write more tests specific to these cases once we agree on these points. |
3f816ea to
0d197cc
Compare
044f9b3 to
4c9e3e4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## eips/amsterdam/eip-2780 #2175 +/- ##
===========================================================
+ Coverage 86.01% 86.05% +0.03%
===========================================================
Files 599 599
Lines 36904 36993 +89
Branches 3771 3796 +25
===========================================================
+ Hits 31744 31833 +89
Misses 4551 4551
Partials 609 609
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Converting back to draft so I can re-base this on the latest |
aa8045c to
f04a782
Compare
|
@danceratopz This got a bit out of hand in terms of PR size. If this is too much, I'd be happy to split this up into the following 2 PRs.
Do let me know what you think |
SamWilsn
left a comment
There was a problem hiding this comment.
From the spec side, my review is complete.
Rename G_* gas cost references to match upstream GAS_* naming convention in GasCosts dataclass after rebase: - G_WARM_ACCOUNT_ACCESS -> GAS_WARM_ACCOUNT_ACCESS - G_NEW_ACCOUNT -> GAS_NEW_ACCOUNT - G_COLD_ACCOUNT_ACCESS -> GAS_COLD_ACCOUNT_ACCESS - G_AUTHORIZATION -> GAS_AUTH_PER_EMPTY_ACCOUNT - G_VERY_LOW -> GAS_VERY_LOW - G_CODE_DEPOSIT_BYTE -> GAS_CODE_DEPOSIT_PER_BYTE Also fix: - Merge duplicate Amsterdam gas_costs() methods in forks.py to preserve GAS_BLOCK_ACCESS_LIST_ITEM=2000 from EIP-7928 - Replace pre.empty_account() with Address(pre.fund_eoa(amount=0)) - Add address_has_code=False to BALANCE ops on non-existent accounts - Rename TX_BASE_COST -> GAS_TX_BASE in amsterdam/transactions.py
33a093e to
354ecc8
Compare
Address PR review feedback from SamWilsn: - Rename GAS_COLD_ACCOUNT_COST_NOCODE to GAS_COLD_ACCOUNT_COST_NO_CODE across spec, testing framework, and test files - Add docstrings to EIP-2780 gas constants in vm/gas.py
danceratopz
left a comment
There was a problem hiding this comment.
Hey @gurukamath, here's some initial feedback. I must admit, I need to go deeper and improve my understanding to do this justice in a second round. I haven't looked at the tests updated for interactions yet. Will come back to this.
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
8698153 to
1ae2024
Compare
That's a good idea, @gurukamath, I think splitting the older fork tests out would be a great idea to give more targeted reviews. |
danceratopz
left a comment
There was a problem hiding this comment.
Hey @gurukamath, here's something that stood out really quickly upon taking another look at these.
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_calls.py
Show resolved
Hide resolved
tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_move_to_precompiles.py
Show resolved
Hide resolved
danceratopz
left a comment
There was a problem hiding this comment.
Hey @gurukamath, here's a second round after reviewing tests/amsterdam/eip7928_block_level_access_lists/.
tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
Outdated
Show resolved
Hide resolved
tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
Outdated
Show resolved
Hide resolved
| @pytest.mark.parametrize( | ||
| "fails_at_extcodesize", | ||
| [True, False], | ||
| ids=["oog_at_extcodesize", "successful_extcodesize"], |
There was a problem hiding this comment.
I think "successful_extcodesize" as-is deviates from the original test's intent; it should be renamed to oog_phase2_at_extcodesize, in which case, how about?
| ids=["oog_phase1_at_extcodesize", "oog_phase2_at_extcodesize"], |
The question is do we need to add a new test case here "successful_extcodesize", or is it covered elsewhere?
There was a problem hiding this comment.
I did not include a case here since it is covered specifically in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_account_access_opcodes.py::test_account_access_opcode. The original idea was to keep the implementation (and tests) of EIP-7928 and EIP-2780 as independent as possible. Not sure how essential this separation is anymore after the debates we've been having about merging stuff to forks/amsterdam
| Op.PUSH20(target_contract) # Target contract address | ||
| + Op.EXTCODESIZE(address_warm=False) # Check code size (cold access) | ||
| + Op.EXTCODESIZE( | ||
| address_warm=False, address_has_code=False |
There was a problem hiding this comment.
We only have an Op.STOP, but unless this changes too, we should rename "successful_extcodesize" to "phase2_oog_at_extcodesize". We could consider adding a third successful case but I think the happy case is covered here https://github.com/gurukamath/execution-specs/blob/eip-2780/implement-eip-final/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py#L246.
| address_warm=False, address_has_code=False | |
| address_warm=False, address_has_code=True |
There was a problem hiding this comment.
I think the test ids are a bit misleading and might need to change. The test essentially looks at the target being in BAL vs target not being in BAL. Pre 2780 these two scenarios exactly coincide with Success vs OOG of the opcode. Post 2780, they don't. Which is also why there is a disconnect between the target having code and us using address_has_code=False.
danceratopz
left a comment
There was a problem hiding this comment.
I reviewed all other non-specific Amsterdam tests for hard-coded constants. Didn't add inline comments here, just Clauded these up.Each addresses a few missing hard-coded gas constants from a single fork (Cancun, Prague, Osaka). I still need to self-review them:
🗒️ Description
Implement EIP-2780 and some basic tests.
Note: This PR contains some testing framework changes which are not compatible with other Amsterdam tests. This PR however, does not focus on fixing those. Those should be fixed in a future PR.
As a result, the CI is not likely to pass for Amsterdam
🔗 Related Issues or PRs
issue #1940
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.Cute Animal Picture
TBD