Skip to content

Test State Gas SELFDESTRUCT

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

Generate fixtures for these test cases for Amsterdam with:

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

Test SELFDESTRUCT state gas charging under EIP-8037.

SELFDESTRUCT charges new-account state gas of state gas when the beneficiary account does not exist AND the originating contract has a nonzero balance. No state gas is charged when the beneficiary already exists or the originator has zero balance.

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_create_selfdestruct_code_deposit_no_refund_header_check blockchain_test 1 Verify block header gas reflects the full account plus code-deposit
test_create_selfdestruct_no_refund_account_and_storage blockchain_test 6 Verify same tx CREATE+SELFDESTRUCT does not refund state gas.
test_create_selfdestruct_no_refund_code_deposit_state_gas blockchain_test 3 Verify same tx CREATE+SELFDESTRUCT does not refund code deposit
test_create_selfdestruct_sstore_restoration_refund blockchain_test 1 Verify SSTORE restoration still refunds its slot state gas when
test_create_tx_selfdestruct_initcode_state_gas blockchain_test 6 Verify a creation tx whose initcode SELFDESTRUCTs the new contract
test_selfdestruct_existing_beneficiary_no_state_gas state_test 1 Test SELFDESTRUCT to existing beneficiary charges no state gas.
test_selfdestruct_new_beneficiary_charges_state_gas state_test 1 Test SELFDESTRUCT to non-existent beneficiary charges state gas.
test_selfdestruct_new_beneficiary_header_gas_used blockchain_test 1 Verify block gas accounting for SELFDESTRUCT to new beneficiary.
test_selfdestruct_new_beneficiary_no_regular_account_creation_cost state_test 1 Verify SELFDESTRUCT to a new beneficiary does not charge a
test_selfdestruct_pre_existing_account_no_refund blockchain_test 1 Verify SELFDESTRUCT of a pre-existing account earns no refund.
test_selfdestruct_state_gas_from_reservoir state_test 1 Test SELFDESTRUCT state gas drawn from reservoir.
test_selfdestruct_to_self_in_create_tx state_test 1 Test SELFDESTRUCT to self in the transaction the contract was created.
test_selfdestruct_via_delegatecall_chain_no_refund blockchain_test 4 Verify SELFDESTRUCT in a nested DELEGATECALL/CALLCODE frame below
test_selfdestruct_zero_balance_no_state_gas state_test 1 Test SELFDESTRUCT with zero balance charges no state gas.