Skip to content

test_self_set_code_cost()

Documentation for tests/prague/eip7702_set_code_tx/test_gas.py::test_self_set_code_cost@verkle@v0.0.6.

Generate fixtures for these test cases for Prague with:

Prague only:

fill -v tests/prague/eip7702_set_code_tx/test_gas.py::test_self_set_code_cost --fork=Prague --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Prague:

fill -v tests/prague/eip7702_set_code_tx/test_gas.py::test_self_set_code_cost --until=Prague

Test set to code account access cost when it delegates to itself.

Source code in tests/prague/eip7702_set_code_tx/test_gas.py
 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
1038
@pytest.mark.parametrize("pre_authorized", [True, False])
def test_self_set_code_cost(
    state_test: StateTestFiller,
    pre: Alloc,
    pre_authorized: bool,
):
    """
    Test set to code account access cost when it delegates to itself.
    """
    if pre_authorized:
        auth_signer = pre.fund_eoa(0, delegation="Self")
    else:
        auth_signer = pre.fund_eoa(0)

    slot_call_cost = 1

    OVERHEAD_COST = 3

    callee_code = CodeGasMeasure(
        code=Op.EXTCODESIZE(address=auth_signer),
        overhead_cost=OVERHEAD_COST,
        extra_stack_items=1,
        sstore_key=slot_call_cost,
    )

    callee_address = pre.deploy_contract(callee_code)
    callee_storage = Storage()
    callee_storage[slot_call_cost] = 200 if not pre_authorized else 2700

    tx = Transaction(
        gas_limit=1_000_000,
        to=callee_address,
        authorization_list=[
            AuthorizationTuple(
                address=auth_signer,
                nonce=0,
                signer=auth_signer,
            ),
        ]
        if not pre_authorized
        else None,
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            callee_address: Account(storage=callee_storage),
            auth_signer: Account(
                nonce=1,
                code=Spec.delegation_designation(auth_signer),
            ),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID pre_authorized
pre_authorized_True True
pre_authorized_False False
pre_authorized_True True
pre_authorized_False False