Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/bogota #3998 +/- ##
================================================
+ Coverage 95.37% 95.55% +0.18%
================================================
Files 677 677
Lines 41907 41907
Branches 3939 3939
================================================
+ Hits 39969 40046 +77
+ Misses 1359 1319 -40
+ Partials 579 542 -37
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: every old case against the case it reaches now, the pure cases on an independent EVM, a leading-zero address fill, a full-range fill, and spec mutants of try/catch rules against base.
There was a problem hiding this comment.
Looks good to me. Nothing is dropped, the pure refactors are pure, and the fixes are correct. Small findings below and inline, none blocking.
No case dropped: all 2,098 ported_from fillers are still referenced, and on Cancun the 543 old cases map to 557 new ones (3 byte-identical jumpi duplicates removed, jump_to_push 78 to 95). Arithmetic and bitwise targets are byte-identical apart from the two stated fixes, the stEIP150 gas values are unchanged in all 610 fork cases, and of 231 traced cases on Cancun to Osaka the 32 that differ all differ as the commits describe.
My agent ran the same checks as described in the #3997 review.
Main point: the legacy # Source: blocks left in three stEIP150 files, two of them misleading (495 blocks at base, 11 at head, no raw hex left). See the inline comments on test_eip2929.py line 340, test_eip2929_minus_ff.py line 151 and test_gas_cost_memory.py line 541.
Area: PR description
Priority: Minor
The PR body doesn't mention the three removed jumpi duplicates, the farChunk move from 0xB00000 to 0x200000, or the sdiv_neg1_minint and mm_5_1_0 fixes. They are only in the commit messages, which will not survive the squash merge. Could you add a line for each?
Area: clean-up
Priority: Minor
Same kind of clean-up the PR already does, left in the directories it touches. The first two would fit here, the rest could be a follow-up PR.
stEIP150singleCodeGasPrices:test_raw_balance_gas.py,test_raw_ext_code_size_gas.py,test_raw_ext_code_copy_gas.pyandtest_raw_ext_code_copy_memory_gas.pydiffer only in the measured opcode, so they could be one test parametrized on the opcode.- The three stEIP150 files this PR edits still have the docstring
Ori Pomerantz qbzzt1@gmail.and each carries its own copy ofif_then. vmIOandFlowOperations/test_loop_stacklimit.pystill has a DELEGATECALL dispatcher, and its post ({0: 0}on an empty slot) passes without the loop running.
Full list
- The docstrings are at
test_eip2929.py:321,test_eip2929_minus_ff.py:136andtest_gas_cost_memory.py:533. vmArithmeticTest/test_exp_power2.py,test_exp_power256.pyandtest_exp_power256_of256.pyare unrolled tables that a loop over the exponent could generate.test_two_ops.py(1,152 SSTOREs) is the same pattern.Ori Pomerantz qbzzt1@gmail.docstrings also remain invmArithmeticTest(test_arith.py,test_div_by_zero.py,test_exp_power*.py,test_fib.py,test_two_ops.py) andvmTests/test_random.py.stEIP150singleCodeGasPrices/test_eip2929_oog.pyhas 12# Source: lllcomments with filler addresses (0xACC7,0x06A5).vmTests/test_random.pyis still thed, g, vparametrization.
6cbfe88 to
bdb4ce2
Compare
|
@danceratopz this is ready for another review and finally get merged :) |
|
Ran spec mutants on base and head. The jump, mload OOG, return buffer and codecopy checks miss bugs, and env_info can't land in execute :(
Reviewed in 42m 05s |
danceratopz
left a comment
There was a problem hiding this comment.
Thanks Mario for the fixes since the last review!
I asked my agent to re-check the new head (case mapping, fixture comparison, traces), with the same method as on #3997, and no cases are dropped. Spencer's mutant findings are all fixed too.
Comments inline.
Merge the five per-opcode files into one test parametrized on topic count and memory-range scenario (46 cases, ids log<n>-<scenario>). Each case deploys only its own contract (sentinel in slot 0) and is called directly, replacing the 0xCCCC... DELEGATECALL dispatcher at fixed 0x1000+n addresses, so the test no longer needs pre_alloc_mutable or a custom Environment. Bug fixed: the old tests only checked the 0x600D completion sentinel and never asserted the emitted logs. The receipt now asserts address, topics (including CALLER and PC topics) and data of every log; OOG cases assert no logs and the untouched sentinel. Mutation check: appending a byte to the expected data fails 36/46 cases (the 10 OOG cases emit no log); offsetting the expected topics fails 30/46. Removed: - tests/ported_static/vmLogTest/test_log0.py - tests/ported_static/vmLogTest/test_log1.py - tests/ported_static/vmLogTest/test_log2.py - tests/ported_static/vmLogTest/test_log3.py - tests/ported_static/vmLogTest/test_log4.py
Merge the eleven 0xCCCC... dispatcher files plus the arithmetic NOT file into test_arithmetic.py, parametrized on the stored expression and its expected result (ids <family>-<old id>). Each case deploys only its own contract and is called directly, so pre_alloc_mutable, the hardcoded 0x1000+n addresses, the fixed sender key, Environment and the explicit gas limit are gone. Slot 0 is pre-set to a sentinel so the ~30 cases expecting 0 are no longer satisfied by an untouched contract. MUL stack underflow becomes its own test asserting the sentinel survives the exceptional halt. Bugs fixed: - sdiv[sdiv_neg1_minint] deployed its contract at 0x0110 instead of 0x1010, so the dispatcher called an empty account and the zero post was vacuous. - mulmod[mm_5_1_0] used data index 0x0d (a copy of mm_1_0_0), so the 0x100f contract (mulmod 5 1 0) never ran. Mutation check: calling an empty account instead of the case contract fails all 114 table cases, including both fixed ones. Removed: - tests/ported_static/vmArithmeticTest/test_add.py - tests/ported_static/vmArithmeticTest/test_addmod.py - tests/ported_static/vmArithmeticTest/test_div.py - tests/ported_static/vmArithmeticTest/test_exp.py - tests/ported_static/vmArithmeticTest/test_mod.py - tests/ported_static/vmArithmeticTest/test_mul.py - tests/ported_static/vmArithmeticTest/test_mulmod.py - tests/ported_static/vmArithmeticTest/test_not.py - tests/ported_static/vmArithmeticTest/test_sdiv.py - tests/ported_static/vmArithmeticTest/test_signextend.py - tests/ported_static/vmArithmeticTest/test_smod.py - tests/ported_static/vmArithmeticTest/test_sub.py
Merge the ten 0xCCCC... dispatcher files and test_byte.py into test_bitwise.py, parametrized on the stored expression and its expected result (ids <family>-<old id>). Each case deploys only its own contract and is called directly, so pre_alloc_mutable, the hardcoded 0x1000+n addresses, the fixed sender key, Environment and the explicit gas limit are gone. Slot 0 is pre-set to a sentinel so the 18 cases expecting 0 (and byte_all slot 0) are observable. The byte_asm raw code and byte_all loop become their own tests; byte_all stores BYTE(i, ...) for each index in straight-line code. Mutation check: calling an empty account instead of the case contract fails all 57 cases. Removed: - tests/ported_static/vmBitwiseLogicOperation/test_and.py - tests/ported_static/vmBitwiseLogicOperation/test_byte.py - tests/ported_static/vmBitwiseLogicOperation/test_eq.py - tests/ported_static/vmBitwiseLogicOperation/test_gt.py - tests/ported_static/vmBitwiseLogicOperation/test_iszero.py - tests/ported_static/vmBitwiseLogicOperation/test_lt.py - tests/ported_static/vmBitwiseLogicOperation/test_not.py - tests/ported_static/vmBitwiseLogicOperation/test_or.py - tests/ported_static/vmBitwiseLogicOperation/test_sgt.py - tests/ported_static/vmBitwiseLogicOperation/test_slt.py - tests/ported_static/vmBitwiseLogicOperation/test_xor.py
blockInfo, envInfo, sha3 and suicide no longer use hardcoded 0x1000+n case contracts behind a 0xCCCC... dispatcher, a fixed sender key, Environment overrides or explicit gas limits, so none needs pre_alloc_mutable. - block_info: call the case contract directly and derive each expectation from the Environment; only the PREVRANDAO case sets a non-default prev_randao (0x20000) so the read is not vacuous. - env_info: keep a caller contract (CALLER, CALLVALUE 0x10 and empty calldata are the subject) aimed at the case contract. CODECOPY and CODESIZE expectations derive from the case bytecode. - sha3: parametrize on (offset, size); expectations are keccak of the zeroed range, the five OOG cases expect the untouched sentinel. - suicide: keep a caller contract, send to a nonexistent account instead of 0xdead, and assert the victim (balance 0, code kept, or balance kept for the self-beneficiary) plus the beneficiary's balance change. The gas-derived sender balance (patched per fork) is dropped as fee bookkeeping. Slot 0 is pre-set to a sentinel in every case, so the 3 zero-result envInfo cases and the 5 OOG sha3 cases are no longer vacuous. Mutation checks: underfunding the envInfo caller fails all 10 cases; swapping the suicide beneficiaries fails the caller and myself cases.
Merge mload, mstore, mstore8 and msize into test_memory.py,
parametrized on (code, expected storage) with ids <family>-<old id>.
Each case deploys its own contract with the dispatcher's sentinel
(0x0BAD) in slot 0 and is called directly, replacing the 0xCCCC...
DELEGATECALL dispatcher at fixed 0x1000+n addresses, so neither file
needs pre_alloc_mutable or Environment. The tx keeps the original
2**24 gas limit because mloadOOG_2 (MLOAD at 7489573) only runs out of
gas under it.
Bugs fixed:
- msize and gas were valid_until("Prague"): farChunk needed ~254M gas
for MSTORE8 at 0xB00000 and gas stored the raw GAS value under an
80M tx. farChunk now writes at 0x200000 (~8.6M gas, same subject:
MSIZE rounds to whole words at high offsets), and both run on every
fork from Cancun.
- gas now derives the expected GAS reading from the intrinsic cost and
the prefix's gas_cost (with memory-expansion metadata) under an
explicit gas limit, instead of a raw 80M-tx snapshot.
Mutation checks: mis-stating the second MSTORE's memory size fails
gas1; expecting FAR_OFFSET + 64 fails farChunk; dropping the 2**24
limit fails mloadOOG_2 on Cancun and Prague.
Removed:
- tests/ported_static/vmIOandFlowOperations/test_mload.py
- tests/ported_static/vmIOandFlowOperations/test_mstore.py
- tests/ported_static/vmIOandFlowOperations/test_mstore8.py
- tests/ported_static/vmIOandFlowOperations/test_msize.py
Merge jump, jumpi and loopsConditionals into test_jump.py, parametrized on (code, expected storage) with ids <family>-<label> (repeated labels numbered). Cases deploy their own contract with the dispatcher's sentinel in slot 0 and are called directly, so the 0xCCCC... dispatcher, pre_alloc_mutable and Environment are gone. Three byte-identical duplicates (the JUMPI hyperspace case appears twice in jumpi and once in jump; not-jump-hyperspace twice in jumpi) are kept once. The two endless loops move to test_endless_loop with a bounded gas limit (intrinsic + 100k) instead of burning the full tx. Bug fixed in jump_to_push: the filler's tx data labels 0x01A..0x19A, 0x20A read hex as decimal, so PUSH26-PUSH31 never ran, no first-data-byte variant ever ran, the PUSH1 fail case called the nonexistent 0x1C, and the fail list was duplicated. The test now generates PUSHn for n in 1..32 jumping after the data (succeeds) or to the first/last data byte (fails), 95 cases. Mutation check: expecting success everywhere fails all 63 jump-into-data cases. Removed: - tests/ported_static/vmIOandFlowOperations/test_jumpi.py - tests/ported_static/vmIOandFlowOperations/test_loops_conditionals.py
codecopy, pc, pop, return and sstore_sload no longer deploy case contracts at fixed 0x1000+n addresses behind a 0xCCCC... dispatcher, so they need neither pre_alloc_mutable nor Environment. - codecopy, pc, pop, sstore_sload: call the case contract directly with sentinels in the slots the old posts expected to be zero or unchanged (the infinite-buffer and pop-underflow failures now assert the sentinel). codecopy expectations derive from bytes(code). - return: keep a DELEGATECALL caller (it reads the callee's return data) aimed at the case contract, forwarding all gas.
eip2929, eip2929_minus_ff and gas_cost_memory pinned 0xCA11, 0xCA1100CA11, 0xCA110100, 0xDE57 and 0xBA5E-family addresses because their measuring contracts are LLL `(if ...)` jump tables with constant destinations that assume those address push widths. The tables are now built by an `if_then` helper that derives each JUMPI/JUMP target from the code length (always PUSH2, as before), so the opcode sequence and every measured gas value are unchanged while the addresses are generated. The remaining self-describing literals, BALANCE(0xCA11) in eip2929 and SELFDESTRUCT(0xDE57) in minus_ff, now use the deployed addresses. pre_alloc_mutable, Environment and the hardcoded nonces are dropped. Checks: with the original addresses the rebuilt eip2929 contract is byte-identical to the ported one; pinning an address push to PUSH20 keeps all cases green (width independence), while shifting the derived jump target by one fails all 38 Osaka cases.
Co-authored-by: danceratopz <danceratopz@gmail.com>
Co-authored-by: danceratopz <danceratopz@gmail.com>
169f9fa to
8ef4407
Compare
|
@danceratopz applied both your comments, rebased, and also used #4091 helpers to simplify further. I'll merge once CI passes. Thanks! |
Description
Part of finalizing the
tests/ported_static/port. Files are disjoint from the otherfinalize-ported-static-*PRs, so each can be reviewed and merged independently.This PR rewrites the
VMTestsfamilies (vmArithmeticTest,vmBitwiseLogicOperation,vmIOandFlowOperations,vmLogTest,vmTests) andstEIP150singleCodeGasPricesas readable, fork-aware tests:0xCCCCDELEGATECALL dispatcher, thed, g, vparametrization,resolve_expect_post,# Source:blocks and pinned addresses are gone. Where a call is part of the subject (RETURN data, environment opcodes, SELFDESTRUCT, gas forwarding), a role-namedcallercontract replaces it.pytest.param, and expected values are derived from the parameters: a byte model of memory, an opcode semantics model,keccak256of the modelled range, and so on.Bytecode.gas_cost(fork), opcode metadata andCodeGasMeasure; hardcoded Cancun/Berlin/EIP-8038 deltas are removed.protected=fork.supports_protected_txs(), explicit CALL gas where pre-EIP-150 forwarding matters, per-fork opcode filtering (fork.valid_opcodes(),with_all_call_opcodes,with_all_create_opcodes), and fork predicates for behavioral differences (selfdestruct_deletes_existing_accounts(),selfdestruct_burns_balance(),header_prev_randao_required(), refunds viamax_refund_quotient()).tests/ported_static/helpers.py(Operands,Memory).0x0BAD, so a zero result or a code path that never runs cannot pass.Merges
vmArithmeticTest: per-opcode files intotest_arithmetic.py(one function per opcode, inputs via calldata);test_exp_power2/256/256_of256.pyintotest_exp_power.py, with the tables generated from a loop.vmBitwiseLogicOperation: per-opcode files intotest_bitwise.py.vmIOandFlowOperations:test_mload/mstore/mstore8/msize.pyintotest_memory.py;test_jumpi.py,test_loops_conditionals.pyandtest_jump_to_push.pyintotest_jump.py.vmLogTest:test_log0..4.pyintotest_log.py.stEIP150singleCodeGasPrices:test_raw_balance_gas,test_raw_ext_code_size_gas,test_raw_ext_code_copy_gasandtest_raw_ext_code_copy_memory_gasintotest_raw_account_access_gas.py;test_raw_call_gas_ask.pyintotest_raw_call_gas.py(the fillers differed only in the gas asked).All original
ported_fromfillers are still referenced.Bug fixes and vacuous tests
sdiv[sdiv_neg1_minint]deployed its contract at0x0110instead of0x1010, so the dispatcher called an empty account and its zero post was vacuous. It is nowtest_sdiv[neg1_neg_int_max].mulmod[mm_5_1_0]used data index0x0d(a copy ofmm_1_0_0), somulmod 5 1 0never ran. It is nowtest_mulmod[5_1_0].loop_stacklimit: the filler's dispatcher passed the transaction's value of 1, soloop_1020/loop_1021looped once and never reached the stack limit, and the post ({0: 0}on an untouched slot) passed without the loop running. The test now derives the counts fromfork.max_stack_height(): one loop peaks exactly at the limit and succeeds, the next overflows and fails, and the returned iteration counter is checked.divByZero: asserted 0 with no sentinel, so it passed even if nothing ran.random: only checked the sender nonce; it now checks the call result and the exact gas used.sha3: hashed only zeroed memory, so the offset never affected the result; memory is now pre-filled with a pattern.twoOps: added a negative operand so SMOD and SAR sign handling is exercised.suicide: themyselfpost passed even if the CALL failed; the CALL result and the receipt gas are now checked.Other changes from the fillers
farChunkwrites at0x200000instead of0xB00000: the original offset needs ~254M gas, above the Osaka transaction gas cap and the default block gas limit. The subject (MSIZE rounds to whole words at high offsets) is unchanged.eip2929_ooguses an exact / one-short gas budget pair fromgas_cost(fork)instead of the filler's fixed budgets (2000/22000/2500/1750); each old budget sits between the pre- and post-Berlin exact costs, so the "fails from Berlin" meaning is kept.test_raw_call_gasforwards the fillers' original 30000 again (the earlier port forwarded a derived amount), matching their0x752e/0x7e2acallee readings on Cancun.The
enhance-ported-testskill is updated to match: gas metadata is fork-aware, so it no longer sets a test's floor, and behavioral differences are derived from fork predicates rather than raisingvalid_from.Filled from Frontier through Bogota: 50732 passed, 72 frame-unconvertible (cases with an explicit gas limit or state-gas reservoir that frame budgets cannot express).
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