Skip to content

Commit 136312e

Browse files
committed
feat(tests): CREATE failure refunds account state gas to reservoir
Adds six tests in `test_state_gas_create.py` covering every failure branch in `generic_create` (silent failure, address collision, child revert, child exceptional halt, code deposit OOG) plus block level accounting with a mixed success and failure transaction: test_create_silent_failure_refunds_state_gas test_create_child_revert_refunds_state_gas test_create_child_halt_refunds_state_gas test_create_mixed_success_and_failure_block_accounting test_create_collision_refunds_state_gas test_create_code_deposit_oog_refunds_state_gas All six are strict discriminators of the spec change (24 out of 24 variants fail when the refund is reverted, all pass when applied). Tests that depend on a narrow gas window (child halt, collision, code deposit OOG) use a caller wrapper with tight gas tuning so the probe SSTORE can only succeed via the refunded reservoir. Tests that verify block header `gas_used` compute the expected value as `max(tx_regular, tx_state)` defensively from `factory_code.gas_cost(fork)` so the assertion stays correct if the underlying constants drift. Adds `init_code_at_high_bytes` helper to `spec.py` for placing short init code at the high bytes of a 32 byte memory slot, shared across the new tests. Removes `test_code_deposit_oog_reservoir_inflation_detection` because the new refund behavior intentionally inflates the parent reservoir on child failure, swamping the ordering signal that test relied on. Code deposit ordering remains covered by `test_create_oog_reservoir_inflation_detection`.
1 parent 2be49b2 commit 136312e

3 files changed

Lines changed: 443 additions & 78 deletions

File tree

tests/amsterdam/eip8037_state_creation_gas_cost_increase/spec.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
from dataclasses import dataclass
44

5+
from execution_testing.vm import Bytecode, Op
6+
7+
8+
def init_code_at_high_bytes(
9+
init_code: Op | Bytecode | bytes,
10+
) -> tuple[int, int]:
11+
"""Return (mstore_value, size) to place init_code at memory[0:size]."""
12+
code_bytes = bytes(init_code)
13+
size = len(code_bytes)
14+
return int.from_bytes(code_bytes, "big") << (256 - 8 * size), size
15+
516

617
@dataclass(frozen=True)
718
class ReferenceSpec:

0 commit comments

Comments
 (0)