Repository navigation
Conversation
The 123 stStaticCall chain fillers (callcall_00 ... callcodecallcode- callcode_111 with their _2, OOGE, OOGMBefore, OOGMAfter, SuicideEnd, SuicideMiddle and ABCB_RECURSIVE variants) are the stCallCodes chains with STATICCALL in them, each copied with CALLCODE or DELEGATECALL swapped in. They are folded into stCallCodes/test_call_chain.py as four tests parametrized on every chain of CALL, CALLCODE, DELEGATECALL and STATICCALL with at least one STATICCALL (2 and 3 levels): test_static_call_chain (leaf reads vs writes, with and without value), test_static_call_chain_out_of_gas (innermost frame, or its caller before/after its call), test_static_call_chain_self_destruct (end / middle) and test_static_recursive_call_chain. Frame.enter now handles STATICCALL. Below a STATICCALL the fillers' frames only wrote memory and dropped their calls' results, so their posts asserted the entry's CALL success and zeros. Now every frame returns how many frames below it returned, plus one for its own call's success, and the innermost CALLER, CALLVALUE and ADDRESS, and the top level stores them, so each static frame's outcome is observable. Non-static frames (reached through CALLCODE or DELEGATECALL above the first STATICCALL) also store their call's success, and every account's balance is asserted. The expected post is simulated from the chain: a write, a CALL with value or a SELFDESTRUCT in a static frame halts it; a SELFDESTRUCT in a non-static frame moves the balance to a fresh beneficiary. Mutation checks: ignoring the static flag in the simulation turns 141 of 264 Osaka plain/self-destruct cases red; allowing CALL with value in static frames turns 22 with_value cases red; swapping the returned CALLER and ADDRESS turns every non-CALLCODE leaf_reads case red. Bugs fixed by the collapse: - 21 files embedded each other's addresses (SELFDESTRUCT beneficiaries, forward deploy order, C -> B literal cycles), forcing pre_alloc_mutable. Chains are built innermost-first and the beneficiary is a fresh account. - static_callcallcall_000_OOGE d1: the top called the d0 chain, so the out-of-gas chain was dead and d1 == d0. - the 13 ABCB_RECURSIVE files had all-zero posts. The recursion is now bounded by a round count in calldata and A stores the returned frame count (2 + 2 * rounds). - duplicates (callcallcodecall_010_OOGMAfter == _2, callcodecallcodecall_110_OOGMAfter == _2) are now one case each. Dropped: the fillers' fixed per-call gas (e.g. 120020 for the EXTCODESIZE loop) and the stored GAS readings; only the call into the out-of-gas frame is bounded (400000), as in the non-static chains. Removed: - tests/ported_static/stStaticCall/test_static_callcall_00.py - tests/ported_static/stStaticCall/test_static_callcall_00_ooge.py - tests/ported_static/stStaticCall/test_static_callcall_00_ooge_1.py - tests/ported_static/stStaticCall/test_static_callcall_00_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcall_00_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcall_000.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_ooge.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcall_000_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcallcall_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_ooge.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_after_2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_after_3.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_001_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcallcallcode_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcallcode_01_2.py - tests/ported_static/stStaticCall/test_static_callcallcode_01_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcallcode_01_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcode_01_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_ooge.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_after_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_after_3.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_010_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcallcodecall_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_ooge.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_after_1.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_after_2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_011_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcallcodecallcode_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcodecall_10.py - tests/ported_static/stStaticCall/test_static_callcodecall_10_2.py - tests/ported_static/stStaticCall/test_static_callcodecall_10_ooge.py - tests/ported_static/stStaticCall/test_static_callcodecall_10_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcodecall_10_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcodecall_10_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_ooge.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_ooge2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_after_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_after_3.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_100_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcodecallcall_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_ooge.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_ooge_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_after_1.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_after_3.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_101_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcodecallcallcode_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_1102.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_ooge.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_ooge2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_after.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_after2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_after_2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_after_3.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_before.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_oogm_before2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_suicide_end.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_suicide_end2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_suicide_middle.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_110_suicide_middle2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_abcb_recursive.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecall_abcb_recursive2.py - tests/ported_static/stStaticCall/test_static_callcodecallcodecallcode_111_suicide_end.py - tests/ported_static/stStaticCall/test_static_calldelcode_01.py - tests/ported_static/stStaticCall/test_static_calldelcode_01_ooge.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/bogota #4001 +/- ##
=============================================
Coverage 95.10% 95.10%
=============================================
Files 673 673
Lines 40904 40904
Branches 3778 3778
=============================================
Hits 38903 38903
Misses 1393 1393
Partials 608 608
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:
|
spencer-tb
left a comment
There was a problem hiding this comment.
LGTM! AI Swarm Review, 3x rotation of 10 fresh agents, findings re-checked by fills, traces and spec mutants, small things inline :)
Checked: all 123 fillers mapped to a new case, every case on an independent EVM with seeded static-flag bugs, a full-range fill, a fill of the middle-frame sstore variant, and spec mutants of try/catch rules against base.
There was a problem hiding this comment.
Nice collapse. The existing call-chain cases are untouched, and the main gap (no fault or write in a middle static frame) is already in Spencer's inline comments, where I added the case count and a wider parametrization that fills green.
No filler dropped: all 123 moved into test_call_chain.py (308 in total), fork ranges are unchanged, and the 1,962 existing test_call_chain fixtures are byte-identical. The 198 old static cases per fork map to 507 new ones (88 exactly), and the 6 traced pairs on Cancun behave as intended. The legacy # Source: comments are fully gone (554 to 0) and there is no raw hex.
My agent ran the same checks as described in the #3997 review.
Area: readability
Priority: Minor
Two pairs next to the ones this PR collapses are still separate files and fit this PR:
stStaticCall/test_static_call_value_inherit.pyandtest_static_call_value_inherit_from_call.pynow run the same test (tx with value, STATICCALL, callee returns CALLVALUE, expect 0).stCallCodes/test_callcode_check_pc.pyandstStaticCall/test_static_callcode_check_pc.pydiffer only in CALL vs STATICCALL, the callee body and the hardcoded PC (37 vs 35). One test over the call opcodes with a computed PC would cover both, and fix thecallcodename (that file uses CALL).
Details and follow-up candidates
Checked at 1c04c86518; none of these files is touched by #4000, #4001 or #4005.
value_inheritpair: the only other differences are gas constants, balances andvalid_from("Byzantium")(from_call) vsvalid_from("Cancun"). Keep a Byzantium start if they merge. The originalfrom_callshape istest_static_call_chain[call_staticcall-leaf_reads-with_value].check_pcpair: both useaddress=Op.PUSH20[addr]only to keep the PC fixed.- Follow-up PR:
stStaticCall/test_static_call_recursive_bomb_log.pyand_log2.pydiffer only in the MSTORE value (a constant vsGAS) and a sender nonce check. - Follow-up PR:
stStaticCall/test_static_call_recursive_bomb1.pyand_bomb2.pydiffer only in POP vs SSTORE of the CALLCODE result and tx gas 20622100 vs 20622099. - Follow-up PR:
stCallCodes/test_call_oog_additional_gas_costs1.pyand2.pyare the CALL value 0 and value 1 pair; #4000 merges their STATICCALL counterparts but these stay separate, and their docstrings don't describe the test.
| @pytest.mark.parametrize( | ||
| "chain", static_call_chains(2) + static_call_chains(3) | ||
| ) |
There was a problem hiding this comment.
Could this take the same value parametrization as test_static_call_chain and pass value=value through? run_static_call_chain already supports it, and 13 old fault cases sent value through the chain, while now value only reaches chains where nothing fails or self-destructs. The out-of-gas test could get it too; fine to leave if you'd rather keep the case count down.
Details
Example old case: callcodecallcallcode_101_SuicideEnd2 sends tx value 1 through CALLCODE, CALL, CALLCODE with a self-destruct at the end. Today the out-of-gas, self-destruct and recursive tests always send 0. If Spencer's point on line 1526 is taken, the same rule (only chains with CALL or CALLCODE get with_value) would apply here.
@pytest.mark.parametrize("value", [0, 1], ids=["no_value", "with_value"])
...
run_static_call_chain(
state_test,
pre,
chain,
value=value,
fault="self_destruct",
fault_level=len(chain) - 1,
before_call=before_call,
)A top frame that halted after a failed first call left the same post as one that completed, so its outcome went unchecked.
Run a write or an out-of-gas fault in each non-top frame, before or after its call, so the OOGMAfter fillers' level 1 faults and their writes in static middle frames are covered.
Drop with_value from chains without CALL or CALLCODE, where it duplicated no_value, and send value through the self-destruct chains too.
Both fillers send a transaction with value to a contract that STATICCALLs a callee returning CALLVALUE and expect 0; keep the Byzantium start.
The CALL and STATICCALL fillers differed only in the opcode, the callee and the hardcoded PC; compute the PC from the code instead.
danceratopz
left a comment
There was a problem hiding this comment.
Thanks for the fixes since the last review, Mario. I asked my agent to re-check the new head (case mapping, fixture comparison and traces, using the same method as on #3997): every earlier point from Spencer and me is addressed and no cases are dropped.
One optional question is inline, on the fault test.
Open thread
One thread is still unresolved: value parametrization. The self-destruct test now sends value, thanks. The other half was value in the fault test, which is the inline question. Could you reply in that thread: either say it is done, or give a short reason why you would prefer to leave it (keeping the case count down is fine)?
| @pytest.mark.parametrize( | ||
| "chain, fault, fault_level, before_call", static_fault_positions() | ||
| ) |
There was a problem hiding this comment.
Should the fault test also run the with_value chains, like the self-destruct test now does? A few old out-of-gas cases sent value (for example callcodecallcall_100_OOGMBefore2 with tx value 1), and with value a frame that runs out of gas or writes after its CALL also has to undo the transfer, which the post balances check. This is the second half of the open value thread.
I asked my agent to try it by building static_fault_positions on static_value_chains: 658 cases per fork instead of 368, and all pass from Cancun through Bogota. Fine to leave if you'd rather keep the case count down.
Diff
diff --git a/tests/ported_static/stCallCodes/test_call_chain.py b/tests/ported_static/stCallCodes/test_call_chain.py
index f09c8626ff..093de2f505 100644
--- a/tests/ported_static/stCallCodes/test_call_chain.py
+++ b/tests/ported_static/stCallCodes/test_call_chain.py
@@ -1302,14 +1302,14 @@ def static_value_chains() -> list:
def static_fault_positions() -> list:
"""
- Return every two- and three-level static chain with a write or an
+ Return every chain of `static_value_chains` with a write or an
out-of-gas fault in each frame below the top, before or after its call,
as a pytest parameter. The innermost frame has no call, and a write
there is left to `test_static_call_chain`.
"""
positions = []
- for chain in static_call_chains(2) + static_call_chains(3):
- opcodes = chain.values[0]
+ for chain in static_value_chains():
+ opcodes, value = chain.values
for fault, level, before_call in product(
("sstore", "out_of_gas"),
range(1, len(opcodes) + 1),
@@ -1322,6 +1322,7 @@ def static_fault_positions() -> list:
positions.append(
pytest.param(
opcodes,
+ value,
fault,
level,
before_call,
@@ -1665,24 +1666,27 @@ def test_static_call_chain(
)
@pytest.mark.valid_from("Cancun")
@pytest.mark.parametrize(
- "chain, fault, fault_level, before_call", static_fault_positions()
+ "chain, value, fault, fault_level, before_call", static_fault_positions()
)
def test_static_call_chain_fault(
state_test: StateTestFiller,
pre: Alloc,
chain: tuple[Op, ...],
+ value: int,
fault: str,
fault_level: int,
before_call: bool,
) -> None:
"""
Call down a chain with a STATICCALL in it, where a frame below the top
- writes storage or runs out of gas, before or after its own call.
+ writes storage or runs out of gas, before or after its own call, with
+ and without value on the calls that carry one.
"""
run_static_call_chain(
state_test,
pre,
chain,
+ value=value,
fault=fault,
fault_level=fault_level,
before_call=before_call,
Description
Warning
This PR was AI-produced. I need to manually review it before marking it ready for review.
Part of finalizing the
tests/ported_static/port: cleanup to reduce pre-alloc groups and removepre_alloc_mutablewhere not needed. Files are disjoint from the otherfinalize-ported-static-*PRs, so each can be reviewed and merged independently.stStaticCall/stCallCodescall-chain files (CALL/CALLCODE/DELEGATECALL/STATICCALL combinations) into a single parametrizedtest_call_chain.pywith derived posts.pre_alloc_mutable.Filled on all forks through Bogota.
Related Issues or PRs
N/A.
Checklist
just static<type>(<area>): <description>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.Cute Animal Picture