Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
aa4c3a7
fix(tests): merge vmLogTest LOG0-LOG4 files and assert the logs
marioevz Nov 6, 2026
6c3c0e5
fix(tests): merge vmArithmeticTest dispatcher files into one test
marioevz Nov 6, 2026
c0756a7
refactor(tests): merge vmBitwiseLogicOperation files into one test
marioevz Nov 6, 2026
adb5408
fix(tests): drop the 0xCCCC dispatcher from vmTests
marioevz Nov 6, 2026
1d7285a
fix(tests): merge vmIO memory files and restore msize/gas on Osaka+
marioevz Nov 6, 2026
3aa0f51
fix(tests): merge vmIO jump files and regenerate jump_to_push
marioevz Nov 6, 2026
594d057
refactor(tests): drop the 0xCCCC dispatcher from remaining vmIO tests
marioevz Nov 6, 2026
53ba687
refactor(tests): unpin addresses in stEIP150singleCodeGasPrices tests
marioevz Nov 6, 2026
8ca736c
fix(tests): check CALL result and gas used in vmTests suicide
marioevz Nov 17, 2026
4569166
fix(tests): skip vmTests block_info in execute mode
marioevz Nov 17, 2026
6166996
refactor(tests): drop duplicate sdiv case and tighten jump_to_push as…
marioevz Nov 17, 2026
f029ee4
refactor(tests): drop Source comments and author docstrings in stEIP150
marioevz Nov 17, 2026
1696caf
fix: Manual review
marioevz Nov 26, 2026
3e8ed25
fix: Review recommended additions and changes.
marioevz Nov 26, 2026
1e39bf8
fix: Remaining test_raw* files
marioevz Nov 26, 2026
4cb3d9f
fix: updated outdated SKILL.md
marioevz Nov 26, 2026
2215ba7
address review comments
marioevz Nov 27, 2026
edd5c45
chore(tests): Use #4091 helpers
marioevz Dec 2, 2026
8ef4407
Dan review comments
marioevz Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 48 additions & 22 deletions .agents/skills/enhance-ported-test/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,16 @@ under test.
EIP-8037 inflates the callee's state gas (e.g. a zero→non-zero SSTORE jumps to
~97920), that fixed budget no longer covers the callee and the subcall OOGs on
Amsterdam — a common reason a pure-behavior test fails there. Omit
the operand so it forwards everything. **Caveat:** forwarding all gas via
`Op.GAS` misbehaves on **pre-EIP-150 (Homestead)** — the sweep (step 11) fails
only there, so such tests floor at **TangerineWhistle**. Keep an explicit `gas`
operand *only* when the amount forwarded is the subject (an OOG-boundary test).
the operand so it forwards everything. **Caveat:** before EIP-150
(TangerineWhistle) a CALL charges its whole `gas` operand up front and does
not cap it, so `Op.GAS`, which is read before the CALL's own cost, asks for
more than is left and the caller runs out of gas. Don't raise the floor for
it: pass a named explicit operand that covers the callee on every fork and
leaves the caller enough to finish (e.g. `CALLEE_GAS = 0x10000`), and keep
`valid_from` at the behavior's real floor (step 11). Validated at Frontier on
`test_env_info`, `test_random`, `test_suicide`, `test_return` and
`test_loop_stacklimit`. Otherwise, keep an explicit `gas` operand only when
the amount forwarded is the subject (an OOG-boundary test).
**Budget vs. subject:** before dropping the operand, ask *why* the constant
has its value. A mid-sized constant (`0xEA60`) is a *budget* sized for the old
schedule — drop it. An absurd or boundary constant (`2**256 - 20`) is the
Expand Down Expand Up @@ -308,7 +314,7 @@ verifies anything. Improve coupling and observability:
forwarded gas is credited back). When reframing, it is easy to carry over
the headline assertion and silently drop the second. Diff the old post's
slots against the new one and re-express each dropped slot dynamically (or
justify its removal explicitly). Validated on `test_raw_call_gas_ask` (the
justify its removal explicitly). Validated on `test_raw_call_gas` (the
caller reports its remaining gas up the stack as a second return word).
- **Add a canary.** Write a distinctive non-zero sentinel to an extra slot as the
*final* step (e.g. `Op.SSTORE(0x2, 0xC0DE)`), and assert it. If creation
Expand Down Expand Up @@ -507,7 +513,9 @@ cost ~100k, so a fixed value is both fork-fragile and brittle. (Size the SSTORE
with a placeholder `new_value`: its cost depends only on the zero->non-zero
transition, not the magnitude — which also breaks the `forward_gas`/`new_value`
circularity.) Set `state_gas_reservoir=0` so the state gas is captured.
Validated on `test_raw_call_gas`.
Prefer the return-up-the-stack shape below when the callee only needs to
report its gas: it needs no callee SSTORE and so sidesteps the state-gas trap
entirely (`test_raw_call_gas` moved from this shape to that one).

**An expensive store after a callee that eats all forwarded gas — pre-write
the slot.** When a frame must SSTORE a result *after* a subcall that
Expand Down Expand Up @@ -640,9 +648,17 @@ expected_gas = forwarded + stipend - Op.GAS.gas_cost(fork)
where `stipend = fork.call_value_stipend()` for a value-bearing call (0
otherwise). **The `// 64` form is the trap:** `available - available // 64` and
`available * 63 // 64` differ by exactly 1 whenever `available % 64 != 0` (the
EVM uses the former). One parametrize over `(opcode, value, memory)` covers the
whole CALL/CALLCODE/DELEGATECALL family; floor **Berlin** (the call metadata).
Validated on `test_raw_call_gas_ask` (10 RawCall*GasAsk fillers).
EVM uses the former). Gate the cap on `fork.is_eip_enabled(150)`: before
Tangerine Whistle a CALL forwards exactly what it asks, so asking for more than
is available runs the caller out of gas — assert that outcome (every reported
slot stays 0) rather than raising the floor. Push the asked amount with a PUSH
instead of `GAS`, so the "asks less" and "asks more" arms differ only in the
operand value. If the fillers differ only in that ask (e.g. `RawCall*Gas`
vs `RawCall*GasAsk`), merge them into one test with a `gas_ask` parameter. One
parametrize over `(opcode, value, memory)` covers the whole
CALL/CALLCODE/DELEGATECALL/STATICCALL family (filtered per fork); floor
**Frontier**. Validated on `test_raw_call_gas` (20 RawCall* fillers, the
former `test_raw_call_gas_ask` merged in).

**Error paths charge execution gas only — assert `execution_cost(fork)`.** A
failed `CREATE`/`CALL` still charges its execution costs (base, memory,
Expand All @@ -655,7 +671,8 @@ forks `state_cost` is 0 so the two coincide — one expression, correct on every
fork. Drive a `CREATE` down the balance-failure path by funding the creator one
wei short of the transferred `value` (`balance = value - 1`); the created
address is then `Account.NONEXISTENT`. Validated end-to-end on
`test_raw_create_gas` (6 RawCreate*Gas fillers consolidated).
`test_raw_create_gas` (6 RawCreate*Gas fillers consolidated, every create
opcode via `with_all_create_opcodes`, floor Frontier).

### 11. Lower `valid_from` to extend coverage
The ported `valid_from` (often `Cancun`) is usually higher than necessary — lower
Expand All @@ -664,18 +681,27 @@ it to widen coverage. Find the true floor empirically: temporarily delete the
Frontier up); the earliest fork that *passes* is your floor. Set
`@pytest.mark.valid_from("<that fork>")` — the marker is mandatory, so this is a
lowering, never a true removal.
- **Gas tests floor at the EIP that introduced their metadata.** A test using
`address_warm` / cold-access metadata + `gas_cost(fork)` is only valid from
**Berlin (EIP-2929)**: earlier forks have no warm/cold distinction, so
`gas_cost` over-predicts by `cold − flat` (2600 − 700 = 1900) and every
pre-Berlin fork fails the measurement. Same shape elsewhere — EIP-3860
init-code metering floors at Shanghai, etc. The floor is whichever EIP the
test's behavior/metadata depends on, which the empirical sweep reveals directly.
- **Behavioral floors show up as non-gas mismatches in the sweep.** A CREATE
test asserting the created account has `nonce=1` floors at **SpuriousDragon
(EIP-161)** — earlier forks start contract nonces at 0, so Frontier/Homestead/
TangerineWhistle fail on the nonce, not the gas. Read *what* the sweep's
earliest-passing fork is gated on; it is not always a gas-schedule change.
- **Gas metadata does not set the floor — the framework is fork-aware.**
`gas_cost(fork)` already applies each fork's schedule to the metadata: before
Berlin, `address_warm` is ignored and the flat access cost is charged (e.g.
BALANCE costs 20 on Frontier and 700 on Istanbul, warm or cold); before
Shanghai, `init_code_size` adds no EIP-3860 word cost. So a test using
warm/cold or init-code metadata runs from Frontier unchanged. If a pre-EIP fork
fails the measurement, suspect the test (a missing metadata flag, a
hand-computed value) before raising the floor. Validated on
`test_raw_account_access_gas` and `test_raw_create_gas`.
- **Behavioral differences: derive them from the fork, don't floor on them.**
A sweep failing on a non-gas field (e.g. a created account's nonce, which is
0 before **SpuriousDragon (EIP-161)** and 1 from it on) points at a fork
behavior the expectation should follow: assert
`nonce=int(fork.is_eip_enabled(161))`, or use a fork predicate such as
`fork.selfdestruct_deletes_existing_accounts()`,
`fork.selfdestruct_burns_balance()` or `fork.header_prev_randao_required()`.
Raise the floor only when the scenario itself cannot exist on earlier forks
(e.g. the opcode under test is missing — filter it per fork with
`fork.valid_opcodes()` or a covariant marker instead, where only some cases
need it). Validated on `test_raw_create_gas`, `test_suicide` and
`test_block_info`.
- **EIP-155 protection is not a floor — leave `protected` unset.** The
fillers sign each legacy `Transaction` for the fork: one that leaves
`protected` unset goes unprotected on Frontier/Homestead/TangerineWhistle
Expand Down
46 changes: 46 additions & 0 deletions tests/ported_static/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Helpers shared by the ported static tests."""


class Memory:
"""Byte-level model of EVM memory, grown in 32-byte words."""

def __init__(self) -> None:
"""Start with empty memory."""
self.data = bytearray()

def expand(self, end: int) -> None:
"""Grow memory to cover `[0, end)`, rounded up to a word."""
size = (end + 31) // 32 * 32
if size > len(self.data):
self.data.extend(bytes(size - len(self.data)))

def store(self, offset: int, value: int) -> None:
"""Write `value` as a word at `offset`, like MSTORE."""
self.expand(offset + 32)
self.data[offset : offset + 32] = value.to_bytes(32, "big")

def store8(self, offset: int, value: int) -> None:
"""Write the low byte of `value` at `offset`, like MSTORE8."""
self.expand(offset + 1)
self.data[offset] = value & 0xFF

def load(self, offset: int) -> int:
"""Return the word at `offset`, expanding memory like MLOAD."""
self.expand(offset + 32)
return int.from_bytes(self.data[offset : offset + 32], "big")

def read(self, offset: int, size: int) -> bytes:
"""
Return the `size` bytes at `offset`, like a LOG or RETURN range.

An empty range does not expand memory, whatever its offset.
"""
if size == 0:
return b""
self.expand(offset + size)
return bytes(self.data[offset : offset + size])

@property
def size(self) -> int:
"""Return what MSIZE reports."""
return len(self.data)
Loading
Loading