Test State Gas Set Code¶
Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py@ffe48572.
Generate fixtures for these test cases for Bogota with:
Test EIP-7702 SetCode authorization state gas under the EIP-2780 top-frame charge model.
Under EIP-2780 (Amsterdam) an authorization's intrinsic cost is only the
state-independent EXECUTION_PER_AUTH_BASE_COST; there is no intrinsic
auth state gas and there are no auth refunds. The state-dependent costs
are charged lazily at the top frame in set_delegation, keyed on each
authority's pre-transaction state:
NEW_ACCOUNT(state) +ACCOUNT_WRITE(execution) when the authority's account leaf does not exist pre-tx (it gets created); andAUTH_BASE(state) when a net-new delegation indicator is written -- the authority holds no delegation both before the transaction and at the point the authorization applies, and the authorization is not a clear.
For a value-free type-4 transaction whose recipient runs code code:
- the receipt
cumulative_gas_usedis the plain sumintrinsic_execution + top_frame_execution + top_frame_state + evm_execution + evm_state(no refund term); and - the header
gas_usedismax(block_execution, block_state)whereblock_execution = intrinsic_execution + top_frame_execution + evm_executionandblock_state = top_frame_state + evm_state.
Tests for [EIP-8037: State Creation Gas Cost Increase]
(https://eips.ethereum.org/EIPS/eip-8037); the valid_from("EIP8037")
markers resolve to Amsterdam, where EIP-2780 governs the charge model.
Test Functions Overview¶
| Name | Type | Cases (Bogota) | Description |
|---|---|---|---|
test_auth_and_execution_state_oog_boundary |
state_test | 2 | Verify the top-frame + execution state gas OOG boundary. |
test_auth_block_gas_accounting |
state_test | 6 | Verify block + receipt gas accounting against the per-authorization |
test_auth_sender_billing_after_failure |
state_test | 2 | Verify sender billing distinguishes new vs existing authority on a |
test_auth_state_gas_drawn_from_reservoir |
state_test | 2 | Verify the top-frame authorization charge is drawn from the state gas |
test_auth_state_gas_in_header_after_failure |
state_test | 6 | Verify the header gas_used when the top-level call fails after the |
test_auth_state_gas_persists_on_top_level_revert |
state_test | 1 | Verify the auth state gas stays consumed on a top-level REVERT, |
test_auth_with_calldata_and_access_list |
state_test | 1 | Test authorization combined with calldata and an access list. |
test_auth_with_multiple_sstores |
state_test | 1 | Test an authorization combined with multiple recipient SSTOREs. |
test_authorization_exact_state_gas_boundary |
blockchain_test | 2 | Test the intrinsic-gas boundary and the top-frame OOG behaviour. |
test_authorization_state_gas_scaling |
state_test | 2 | Test the top-frame authorization state gas scales with count. |
test_authorization_to_precompile_address |
state_test | 1 | Test an authorization targeting a precompile address applies. |
test_authorization_with_sstore |
state_test | 1 | Test SetCode authorization combined with a recipient SSTORE. |
test_duplicate_signer_authorizations |
state_test | 1 | Test two authorizations from the same signer with increasing nonces. |
test_existing_account_auth_header_gas_used |
state_test | 2 | Verify the header gas_used for existing-authority delegations. |
test_existing_account_no_refund |
state_test | 1 | An existing-authority delegation is charged the reduced top-frame |
test_existing_account_no_refund_with_sstore |
state_test | 1 | An existing-authority auth and a recipient SSTORE are both charged |
test_fresh_authority_and_sstores_full_state |
state_test | 1 | Test a fresh authority plus multiple SSTOREs pay the full state cost. |
test_invalid_auth_no_top_frame_charge |
state_test | 3 | Verify a rejected authorization incurs no top-frame charge. |
test_invalid_chain_id_auth_still_charges_intrinsic |
state_test | 1 | Test an invalid-chain-id authorization still pays the intrinsic base. |
test_invalid_nonce_auth_still_charges_intrinsic |
state_test | 1 | Test an invalid-nonce authorization still pays the intrinsic base. |
test_many_authorizations |
state_test | 1 | Test ten authorizations, each charged the top-frame AUTH_BASE. |
test_mixed_auths_header_gas_used |
state_test | 2 | Verify the header gas_used across a mix of existing and new |
test_mixed_new_and_existing_auths |
state_test | 1 | Test mixed new and existing account authorizations at the top frame. |
test_mixed_valid_and_invalid_auths |
state_test | 3 | Test mixed valid and invalid authorizations under the top-frame model. |
test_multi_tx_block_auth_and_sstore |
blockchain_test | 1 | Test a multi-transaction block combining a top-frame auth and an |
test_pre_delegated_authority_no_charge_after_failure |
state_test | 2 | Verify re-delegating an already-delegated authority carries no |
test_same_authority_increasing_nonce_net_once |
state_test | 1 | Verify the per-authority once invariant across valid auths. |
test_same_tx_clear_then_reset_pre_delegated |
state_test | 1 | Verify a clear-then-reset of a pre-delegated authority in one tx. |
test_same_tx_create_then_clear |
state_test | 1 | Verify a create-then-clear on one authority in a single transaction. |
test_self_sponsored_authorization |
state_test | 1 | Test a self-sponsored authorization where the sender is the authority. |
test_set_code_tx_below_total_intrinsic |
state_test | 3 | Reject a set_code tx one gas below the (now execution-only) intrinsic. |
test_top_level_halt_keeps_intrinsic_auth_state_gas |
state_test | 4 | Verify a top-level exceptional halt keeps the full authorization |