Test Value Moving With Tx Delegation¶
Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_with_tx_delegation.py@622620d8.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_with_tx_delegation.py --fork Amsterdam
Tests for EIP-2780 x EIP-7702 interaction.
A type-4 transaction's authorizations are processed at the top frame
(in set_delegation), where their state-dependent costs are charged.
Each authorization pays, on top of the state-independent
EXECUTION_PER_AUTH_BASE_COST charged in the intrinsic:
NEW_ACCOUNT(state) +ACCOUNT_WRITE(execution) when the authority's account leaf does not yet exist, andAUTH_BASE(state) when a net-new delegation indicator is written.
The intrinsic no longer over-charges and refunds; the costs are charged
exactly, keyed on each authority's pre-transaction state. Each
authorization carries that state as its creates_account /
writes_delegation annotations, and the top-frame calculators read
them off the same list that is handed to authorization_list.
When the authorization installs a delegation on tx.to,
set_delegation runs before the recipient top-frame check, so:
- the recipient's delegation-target access charge fires for the now-delegated recipient (warm or cold per the target's warmth); and
- the
NEW_ACCOUNTcharge a value transfer to an empty recipient would otherwise incur is suppressed --set_delegationhas made the recipient alive, and the per-authorizationNEW_ACCOUNTaccounts for the leaf instead.
A complementary set of scenarios installs the delegation on the sender (self-sponsored authorization), whose nonce must equal the sender's nonce after the transaction-side increment.
Test Functions Overview¶
| Name | Type | Cases (Amsterdam) | Description |
|---|---|---|---|
test_tx_installs_delegation_on_empty_recipient |
state_test | 2 | Scenario 2: tx.to is a non-existent (empty) account. The type-4 |
test_tx_installs_delegation_on_funded_recipient |
state_test | 2 | Scenario 1: tx.to is a funded EOA with no prior delegation. |
test_tx_installs_delegation_on_sender |
state_test | 4 | Self-sponsored type-4 transaction: the sender signs an |