Skip to content

test_call_value_to_self_destructed_same_tx_account()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_value_to_self_destructed_same_tx_account@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_value_to_self_destructed_same_tx_account --fork Amsterdam

Smoke test for CALL with value to a same transaction selfdestructed account.

Confirms the happy path runs to completion. The account still has its CREATE nonce when the CALL runs, so it is neither empty nor nonexistent and the new account creation gate does not fire; end of the transaction destruction removes the account regardless and the value transferred is burned. Strict discrimination of the no charge behavior lives in test_call_value_to_self_destructed_header_gas_used.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
@pytest.mark.parametrize(
    "create_opcode",
    [
        pytest.param(Op.CREATE, id="create"),
        pytest.param(Op.CREATE2, id="create2"),
    ],
)
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.valid_from("EIP8037")
def test_call_value_to_self_destructed_same_tx_account(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    create_opcode: Op,
) -> None:
    """
    Smoke test for CALL with value to a same transaction
    selfdestructed account.

    Confirms the happy path runs to completion. The account still
    has its CREATE nonce when the CALL runs, so it is neither empty
    nor nonexistent and the new account creation gate does not fire;
    end of the transaction destruction removes the account regardless
    and the value transferred is burned. Strict discrimination of
    the no charge behavior lives in
    `test_call_value_to_self_destructed_header_gas_used`.
    """
    new_account_state_gas = fork.gas_costs().NEW_ACCOUNT
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    inner_code = Op.SELFDESTRUCT(Op.ADDRESS)
    mstore_value, size = init_code_at_high_bytes(inner_code)

    storage = Storage()
    orchestrator = pre.deploy_contract(
        code=(
            Op.MSTORE(0, mstore_value)
            + (
                Op.CREATE2(1, 0, size, 0)
                if create_opcode == Op.CREATE2
                else Op.CREATE(1, 0, size)
            )
            + Op.MSTORE(0x20, Op.DUP1)
            + Op.POP
            + Op.SSTORE(
                storage.store_next(1, "call_succeeds"),
                Op.CALL(gas=Op.GAS, address=Op.MLOAD(0x20), value=1),
            )
        ),
        balance=3,
    )

    tx = Transaction(
        to=orchestrator,
        state_gas_reservoir=new_account_state_gas + sstore_state_gas,
        sender=pre.fund_eoa(),
    )

    post = {orchestrator: Account(storage=storage)}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.