Skip to content

test_auth_execution_intrinsic_magnitude()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_set_code_auth_gas.py::test_auth_execution_intrinsic_magnitude@8acae1b0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_set_code_auth_gas.py::test_auth_execution_intrinsic_magnitude --fork Amsterdam

Assert the EIP-8038 execution per-authorization intrinsic magnitude.

The execution intrinsic above the n=0 base must equal n * execution_per_auth plus the access-list delta (derived from the calculator itself so the calldata-floor contribution of the access-list bytes is accounted for).

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_set_code_auth_gas.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.parametrize("n", [1, 2, 3])
@pytest.mark.parametrize(
    "authority_exists",
    [
        pytest.param(False, id="new_authority"),
        pytest.param(True, id="existing_authority"),
    ],
)
@pytest.mark.parametrize(
    "authority_in_access_list",
    [
        pytest.param(False, id="empty_access_list"),
        pytest.param(True, id="access_list_contains_authority"),
    ],
)
def test_auth_execution_intrinsic_magnitude(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    fork: Fork,
    n: int,
    authority_exists: bool,
    authority_in_access_list: bool,
) -> None:
    """
    Assert the EIP-8038 *execution* per-authorization intrinsic magnitude.

    The execution intrinsic above the ``n=0`` base must equal
    ``n * execution_per_auth`` plus the access-list delta (derived from
    the calculator itself so the calldata-floor contribution of the
    access-list bytes is accounted for).
    """
    contract = pre.deploy_contract(code=Op.STOP)

    signers = [
        pre.fund_eoa() if authority_exists else pre.fund_eoa(amount=0)
        for _ in range(n)
    ]
    authorization_list = [
        AuthorizationTuple(address=contract, nonce=0, signer=signer)
        for signer in signers
    ]

    access_list: List[AccessList] | None = None
    if authority_in_access_list:
        access_list = [
            AccessList(address=signer, storage_keys=[]) for signer in signers
        ]

    base_execution = _execution_intrinsic(fork, n=0)
    execution = _execution_intrinsic(fork, n=n, access_list=access_list)

    # Access-list delta is derived from the calculator (it folds in the
    # calldata-floor cost of the access-list bytes), never hardcoded.
    access_list_delta = _execution_intrinsic(
        fork, n=0, access_list=access_list
    ) - _execution_intrinsic(fork, n=0)

    expected_per_auth = _execution_per_auth(fork)
    assert (
        execution - base_execution == n * expected_per_auth + access_list_delta
    )

    sender = pre.fund_eoa()
    tx = Transaction(
        to=contract,
        authorization_list=authorization_list,
        access_list=access_list,
        sender=sender,
    )

    post = {
        signer: Account(code=Spec7702.delegation_designation(contract))
        for signer in signers
    }
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 12 parametrized test cases across 1 fork.