Test State Gas SSTORE¶
Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py@a9abd46e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py --fork Amsterdam
Test SSTORE state gas charging under EIP-8037.
Zero-to-nonzero storage writes charge
STATE_BYTES_PER_STORAGE_SET * cost_per_state_byte of state gas.
Nonzero-to-nonzero writes charge no state gas. 0 to x to 0 restoration
in the same tx refunds state gas directly to state_gas_reservoir
(inline at x to 0) and the regular write-cost portion to
refund_counter.
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_sstore_clear_refund_reversal |
state_test | 1 | Test clearing a nonzero slot then un-clearing reverses the refund. |
test_sstore_multiple_slots |
state_test | 3 | Test multiple zero-to-nonzero SSTOREs each charge state gas. |
test_sstore_nonzero_to_nonzero |
state_test | 1 | Test SSTORE nonzero-to-nonzero charges no state gas. |
test_sstore_nonzero_to_zero |
state_test | 1 | Test SSTORE nonzero-to-zero charges no state gas. |
test_sstore_restoration_ancestor_revert |
state_test | 3 | Verify an ancestor REVERT does not inflate the caller's reservoir |
test_sstore_restoration_block_state_gas_zero |
blockchain_test | 2 | Verify 0 to x to 0 cycles contribute zero to block state gas. |
test_sstore_restoration_charge_in_ancestor |
state_test | 8 | Verify 0 to x to 0 refund when the 0 to x charge is in the parent |
test_sstore_restoration_charge_in_ancestor_intermediate_revert |
state_test | 2 | Verify a deferred refund applied in an intermediate frame still |
test_sstore_restoration_create_init_revert |
state_test | 2 | Verify a reverting CREATE sub-frame does not inflate the caller's |
test_sstore_restoration_create_init_success |
state_test | 2 | Verify 0 to x to 0 reservoir refund applies across CREATE init. |
test_sstore_restoration_cross_frame |
blockchain_test | 3 | Verify restoration refund across frames for CALL / CALLCODE / DELEGATECALL. |
test_sstore_restoration_intermediate_values |
blockchain_test | 1 | Verify restoration refund triggers for 0 to x to y to 0. |
test_sstore_restoration_mixed_with_genuine_sstore |
blockchain_test | 2 | Verify restoration cycles plus a genuine 0 to x SSTORE. |
test_sstore_restoration_nonzero_no_state_refund |
state_test | 1 | Test nonzero-to-nonzero-to-original restoration has no state gas refund. |
test_sstore_restoration_refund |
state_test | 1 | Test SSTORE zero-to-nonzero-to-zero restoration refunds state gas. |
test_sstore_restoration_refund_credits_local_reservoir |
state_test | 6 | Verify a same transaction SSTORE restoration refund credits the |
test_sstore_restoration_reservoir_replenished_inline |
blockchain_test | 1 | Verify the reservoir is replenished inline at x to 0. |
test_sstore_restoration_reservoir_spillover |
blockchain_test | 1 | Verify restoration refund when state gas spilled into gas_left. |
test_sstore_restoration_sub_frame_revert |
state_test | 3 | Verify a sub-frame REVERT does not inflate the caller's reservoir |
test_sstore_restoration_then_reset |
blockchain_test | 1 | Verify accounting across 0 to 1 to 0 to 1 (restore then re-set). |
test_sstore_state_gas_all_tx_types |
state_test | 5 | Test SSTORE state gas works across all transaction types. |
test_sstore_state_gas_drawn_from_reservoir |
state_test | 1 | Test SSTORE state gas drawn from reservoir before gas_left. |
test_sstore_stipend_check_excludes_reservoir |
state_test | 2 | Verify the SSTORE gas check uses gas_left only, not the reservoir. |
test_sstore_zero_to_nonzero |
state_test | 1 | Test SSTORE zero-to-nonzero charges state gas. |
test_sstore_zero_to_zero |
state_test | 1 | Test SSTORE zero-to-zero charges no state gas. |