Skip to content

test_eip_7702()

Documentation for tests/prague/eip7702_set_code_tx/test_eip_mainnet.py::test_eip_7702@e9958ed2.

Generate fixtures for these test cases for Osaka with:

fill -v tests/prague/eip7702_set_code_tx/test_eip_mainnet.py::test_eip_7702 --fork Osaka

Test the executing a simple SSTORE in a set-code transaction.

Source code in tests/prague/eip7702_set_code_tx/test_eip_mainnet.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def test_eip_7702(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """Test the executing a simple SSTORE in a set-code transaction."""
    storage = Storage()
    sender = pre.fund_eoa()
    auth_signer = sender

    tx_value = 1

    set_code = (
        Op.SSTORE(storage.store_next(sender), Op.ORIGIN)
        + Op.SSTORE(storage.store_next(sender), Op.CALLER)
        + Op.SSTORE(storage.store_next(tx_value), Op.CALLVALUE)
        + Op.STOP
    )
    set_code_to_address = pre.deploy_contract(
        set_code,
    )
    authorization_list = [
        AuthorizationTuple(
            address=set_code_to_address,
            nonce=1,
            signer=auth_signer,
        ),
    ]
    gas_costs = fork.gas_costs()
    intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator()
    intrinsic_gas_cost = intrinsic_gas_cost_calc(
        access_list=[],
        authorization_list_or_count=authorization_list,
    )
    execution_cost = (
        (gas_costs.G_COLD_SLOAD + gas_costs.G_STORAGE_SET) * 3
        + (gas_costs.G_VERY_LOW * 3)
        + (gas_costs.G_BASE * 3)
    )

    tx = Transaction(
        gas_limit=intrinsic_gas_cost + execution_cost,
        to=auth_signer,
        value=tx_value,
        authorization_list=authorization_list,
        sender=sender,
    )

    state_test(
        pre=pre,
        tx=tx,
        post={
            set_code_to_address: Account(
                storage=dict.fromkeys(storage, 0),
            ),
            auth_signer: Account(
                nonce=2,
                code=Spec.delegation_designation(set_code_to_address),
                storage=storage,
            ),
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test