Skip to content

Test State Gas Pricing

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

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

Test the core EIP-8037 state gas pricing and charge mechanism.

cost_per_state_byte is a fixed parameter (CPSB = 1530) derived from a 150M reference block gas limit and a 120 GiB/year target state growth. The state gas cost of any operation is its byte footprint multiplied by CPSB.

The charge_state_gas() function draws from the state gas reservoir first, then spills into gas_left. If both pools are insufficient, the transaction runs out of gas.

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_auth_state_gas_scales_with_cpsb state_test 10 Test SetCode authorization state gas scales with block gas limit.
test_call_new_account_state_gas_scales_with_cpsb state_test 10 Test CALL value transfer to empty account scales with block gas limit.
test_calldata_floor_enforced_with_state_gas state_test 2 Test EIP-7623 calldata floor is enforced when EIP-8037 is active.
test_charge_draws_entirely_from_reservoir state_test 1 Test state gas is drawn entirely from the reservoir.
test_charge_oog_both_pools_insufficient state_test 1 Test OOG when both reservoir and gas_left are insufficient.
test_charge_spills_to_gas_left state_test 1 Test state gas spills from reservoir to gas_left.
test_create_state_gas_scales_with_cpsb state_test 10 Test CREATE new-account state gas scales with block gas limit.
test_intrinsic_regular_gas_exceeds_cap state_test 1 Reject a transaction whose intrinsic regular gas exceeds the cap.
test_intrinsic_regular_gas_exceeds_cap_with_floor_below_cap state_test 1 Reject when intrinsic regular gas exceeds the cap while the calldata
test_intrinsic_within_cap_gas_limit_above_cap state_test 1 Accept a transaction whose gas_limit exceeds the cap when both
test_pricing_at_various_gas_limits state_test 10 Test SSTORE succeeds at various block gas limits.
test_refund_cap_includes_state_gas state_test 1 Test the ⅕ refund cap includes state gas used from gas_left.
test_refund_with_reservoir_state_gas state_test 1 Test refund when state gas is drawn from reservoir.
test_selfdestruct_new_beneficiary_scales_with_cpsb state_test 10 Test SELFDESTRUCT to new beneficiary scales with block gas limit.
test_sstore_refund_scales_with_cpsb state_test 10 Test SSTORE restoration refund scales with block gas limit.