Skip to content

test_pointer_to_static()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_to_static@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_to_static --fork Amsterdam

Tx -> call -> pointer A -> static -> static violation.

Verify that static context is active when called under pointer.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
@pytest.mark.valid_from("Prague")
@pytest.mark.parametrize("sender_delegated", [True, False])
@pytest.mark.parametrize("sender_is_auth_signer", [True, False])
def test_pointer_to_static(
    state_test: StateTestFiller,
    pre: Alloc,
    sender_delegated: bool,
    sender_is_auth_signer: bool,
) -> None:
    """
    Tx -> call -> pointer A -> static -> static violation.

    Verify that static context is active when called under pointer.
    """
    env = Environment()
    storage: Storage = Storage()

    if sender_delegated:
        sender_delegation_target = pre.deploy_contract(Op.STOP)
        sender = pre.fund_eoa(delegation=sender_delegation_target)
    else:
        sender = pre.fund_eoa()

    if sender_is_auth_signer:
        pointer_a = sender
    else:
        pointer_a = pre.fund_eoa()

    contract_b = pre.deploy_contract(code=Op.SSTORE(0, 5))
    contract_a = pre.deploy_contract(
        code=Op.SSTORE(
            storage.store_next(0, "static_call"),
            Op.STATICCALL(
                gas=1_000_000,
                address=contract_b,
                args_size=32,
                ret_offset=1000,
                ret_size=32,
            ),
        )
        + Op.SSTORE(storage.store_next(1, "call_worked"), 1)
    )
    nonce = (
        2
        if sender_delegated and sender_is_auth_signer
        else 1
        if sender_is_auth_signer
        else 0
    )

    tx = Transaction(
        to=pointer_a,
        gas_limit=3_000_000,
        data=b"",
        value=0,
        sender=sender,
        authorization_list=[
            AuthorizationTuple(
                address=contract_a,
                nonce=nonce,
                signer=pointer_a,
            )
        ],
    )

    post = {
        pointer_a: Account(storage=storage),
        contract_b: Account(storage={0: 0}),
    }
    state_test(
        env=env,
        pre=pre,
        post=post,
        tx=tx,
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.