feat(tests): probe EIP-161 emptiness after same-tx precompile touches - #3477
feat(tests): probe EIP-161 emptiness after same-tx precompile touches#3477spencer-tb wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #3477 +/- ##
===================================================
+ Coverage 93.90% 94.05% +0.14%
===================================================
Files 624 624
Lines 36905 36905
Branches 3326 3326
===================================================
+ Hits 34655 34710 +55
+ Misses 1569 1525 -44
+ Partials 681 670 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
35254c7 to
119c361
Compare
119c361 to
c9c388c
Compare
There was a problem hiding this comment.
Sorry had one thing locally that I pushed as it was an exploration and revealed a possible blip I think. Basically, the fixture carried no trace of the charge and a client that skips it after a touch would pass this test. I pushed a second value call that actually creates the precompile, so the charge is paid and stays paid, and the sender balance in the state root proves it.. with the precompile pre-funded as a control, the sender pays exactly NEW_ACCOUNT less.
Left some comments as well, nothing big. Looks good otherwise!
Please review my commit and lmk!
|
|
||
|
|
||
| ref_spec_161 = ReferenceSpec( | ||
| "EIPS/eip-161.md", "96523ef4d76ca440f73f0403ddb5c9cb3b24dcae" |
There was a problem hiding this comment.
This looks wrong?
| "EIPS/eip-161.md", "96523ef4d76ca440f73f0403ddb5c9cb3b24dcae" | |
| "EIPS/eip-161.md", "b746c239881f24996f0205855e44f9b2d3b92b6a" |
| return Op.POP(Op.CALL(gas=100_000, address=precompile)) | ||
| # The value exceeds the caller's balance, so the transfer fails | ||
| # after the target access is charged. | ||
| return Op.POP(Op.CALL(gas=100_000, address=precompile, value=2**100)) |
There was a problem hiding this comment.
nit: personal preference but also bc it could be a footgun... I'd prefer these to be if / elif for all cases and to raise on the else. Can be convinced otherwise though 😅
| ), | ||
| ) | ||
|
|
||
| blockchain_test( |
There was a problem hiding this comment.
nit: this can also be a state_test since just one tx 👀
Description
Stacked on #3480.
Add a touch-then-probe family for EIP-161 emptiness, covering erigontech/erigon#23670: a client that reads its own touch bookkeeping as proof of account existence skips new-account charges and diverges. A zero-value CALL to an absent precompile runs its code without creating the account, and nothing in the suite exercised that sequence before.
tests/spurious_dragon/eip161_state_trie_clearing/:test_extcodehash_after_precompile_touch(ConstantinopleFix+, all precompiles): EXTCODEHASH, EXTCODESIZE and BALANCE probes around a same-transaction touch, for absent and funded precompiles.test_call_new_account_charge_after_precompile_touchandtest_selfdestruct_beneficiary_charge_after_precompile_touch(SpuriousDragon+): measure the exact charge after a touch. The measured call forwards zero gas, so the callee runs only on the value stipend and always halts, keeping precompile costs out of the measurement. From Amsterdam the new-account charge is state gas and invisible to the GAS delta, so the expectation usesexecution_costand the state charge stays pinned through the sender balance in the state root.test_bal_insufficient_balance_call_to_touched_precompile(EIP-7928): RIPEMD-160 must appear in the BAL with empty changes when reached only by a value call that fails its balance check, the shape the fuzzer found.Related Issues or PRs
#3480
erigontech/erigon#23670
erigontech/erigon#23672
Checklist
just static<type>(<area>): <title>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.