Skip to content

Test State Gas Cross Frame Refund

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_cross_frame_refund.py@8acae1b0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_cross_frame_refund.py --fork Amsterdam

Test where a state gas refund lands when it is credited in a different frame than the spilled charge it undoes.

A state charge spilled from gas_left can be refunded in a child frame. The credit lands in the child's reservoir and merges upward as reservoir, which repays the parent's outstanding spill as the child merges, at any depth and through call and create opcodes alike. The repaid gas funds execution again, a later creation spills afresh, and settlement is unchanged because it sums both pools. The measured windows subtract gas_left readings with SUB, so a window repaid more than it cost reads below zero.

A same-frame control pins the pre-existing form of that last behavior: a local refill can already make the second of two GAS readings larger than the first. Merge-time repayment extends it across a frame boundary.

Tests for [EIP-8037: State Creation Gas Cost Increase] (https://eips.ethereum.org/EIPS/eip-8037).

Test Functions Overview

Name Type Cases (Amsterdam) Description
test_call_frame_credit_repays_spill_before_fixed_gas_probe state_test 4 Test a plain CALL credit repays the spill before a fixed-gas probe.
test_child_clear_repays_own_spill_first state_test 3 Test the cross-slot LIFO split of a cross-frame refund in a child.
test_child_clear_window_cost state_test 3 Test a successful clearing child repays a parent spill at the merge.
test_cross_frame_credit_funds_state_at_full_price state_test 1 Test the sender pays full price for state after a cross-frame refund.
test_cross_frame_credit_returns_at_settlement state_test 1 Test the cross-frame credit refunds the sender at settlement.
test_cross_frame_refund_after_delegation_spill state_test 1 Test a cross-frame refund after the sender's delegation spilled.
test_cross_frame_refund_repays_spill_at_a_call state_test 3 Test a call merging a refund repays the spill.
test_cross_frame_refund_repays_spill_at_a_create state_test 2 Test a create merging a refund repays the spill.
test_cross_frame_refund_repays_spill_at_merge state_test 4 Test a cross-frame refund repays the spill when the child merges.
test_cross_frame_refund_repays_spill_in_inner_frame state_test 2 Test the repayment lands at an inner frame's merge.
test_cross_frame_refund_with_reservoir_grant state_test 3 Test the receipt is the same however much reservoir was bought.
test_delegation_spill_window_cost state_test 1 Test the clearing call repays only the code's uncommitted spill.
test_fixed_gas_probe_after_clearing_frame state_test 2 Test a fixed-gas probe after a successful or reverted clear.
test_later_set_spills_after_repayment state_test 1 Test a later creation spills again once the credit is repaid.
test_repaid_credit_enters_next_call_forwarding_base state_test 1 Test repaid gas participates in the next call's 63/64 base.
test_repaid_credit_funds_execution state_test 1 Test the repaid credit funds execution work.
test_reservoir_grant_window_costs state_test 3 Test a reservoir grant determines repayment and a later spill.
test_same_frame_refund_increases_gas_left state_test 2 Test a same-frame refill can increase gas_left between reads.