Skip to content

test_selfdestruct_account_write_at_transition()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_selfdestruct_account_write_at_transition@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_selfdestruct_account_write_at_transition --fork Amsterdam

SELFDESTRUCT gains an ACCOUNT_WRITE charge when it sends a positive balance to an empty account, which is a new EIP-8038 parameter. The constant transition is asserted from the derived schedules and a value-bearing SELFDESTRUCT to a fresh beneficiary is exercised in both blocks to prove it still runs.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
@EIPChecklist.GasCostChanges.Test.ForkTransition.Before()
@EIPChecklist.GasCostChanges.Test.ForkTransition.After()
def test_selfdestruct_account_write_at_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    ``SELFDESTRUCT`` gains an ``ACCOUNT_WRITE`` charge when it sends a
    positive balance to an empty account, which is a new EIP-8038
    parameter. The constant transition is
    asserted from the derived schedules and a value-bearing
    ``SELFDESTRUCT`` to a fresh beneficiary is exercised in both blocks
    to prove it still runs.
    """
    # Fresh empty beneficiaries so the positive-balance-to-empty branch
    # that adds ACCOUNT_WRITE is taken in each regime.
    beneficiary_before = pre.fund_eoa(amount=0)
    beneficiary_after = pre.fund_eoa(amount=0)

    suicidal_before = pre.deploy_contract(
        code=Op.SELFDESTRUCT(beneficiary_before),
        balance=1,
    )
    suicidal_after = pre.deploy_contract(
        code=Op.SELFDESTRUCT(beneficiary_after),
        balance=1,
    )

    blocks = transition_blocks(suicidal_before, suicidal_after, pre)

    post = {
        beneficiary_before: Account(balance=1),
        beneficiary_after: Account(balance=1),
    }
    blockchain_test(pre=pre, blocks=blocks, post=post)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.