Skip to content

test_authorization_no_fallback()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_exact_balance_no_fallback.py::test_authorization_no_fallback@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_exact_balance_no_fallback.py::test_authorization_no_fallback --fork Amsterdam

Reject a 7702 set-code transaction whose gas_limit is one gas below the Amsterdam intrinsic.

EIP-8038 raises the per-authorization intrinsic (AUTH_PER_EMPTY_ACCOUNT). A client reusing the old per-auth constant would compute an intrinsic smaller by num_auths * auth_delta; the exact-balance sender leaves no slack for that fallback.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_exact_balance_no_fallback.py
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
@pytest.mark.inclusion_test
@EIPChecklist.GasCostChanges.Test.OutOfGas()
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "num_auths",
    [
        pytest.param(1, id="one_auth"),
        pytest.param(2, id="two_auths"),
    ],
)
def test_authorization_no_fallback(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    num_auths: int,
) -> None:
    """
    Reject a ``7702`` set-code transaction whose ``gas_limit`` is one
    gas below the Amsterdam intrinsic.

    EIP-8038 raises the per-authorization intrinsic
    (``AUTH_PER_EMPTY_ACCOUNT``). A client reusing the old per-auth
    constant would compute an intrinsic smaller by
    ``num_auths * auth_delta``; the exact-balance sender leaves no slack
    for that fallback.
    """
    new_costs = fork.gas_costs()
    old_costs = gas_costs_before_increase(
        fork, lambda c: (c.AUTH_PER_EMPTY_ACCOUNT,)
    )
    auth_delta = (
        new_costs.AUTH_PER_EMPTY_ACCOUNT - old_costs.AUTH_PER_EMPTY_ACCOUNT
    )
    fallback_delta = num_auths * auth_delta
    assert fallback_delta > 0

    target = pre.deploy_contract(code=b"")
    authorization_list = [
        AuthorizationTuple(
            address=target,
            nonce=0,
            signer=pre.fund_eoa(),
        )
        for _ in range(num_auths)
    ]

    intrinsic = fork.transaction_intrinsic_cost_calculator()(
        authorization_list_or_count=authorization_list,
        return_cost_deducted_prior_execution=True,
    )
    gas_limit = intrinsic - 1
    assert intrinsic - fallback_delta <= gas_limit < intrinsic

    # Set-code (type-4) txs require EIP-1559 fee fields. With
    # max_fee == max_priority and value 0, the upfront debit the
    # protocol reserves is exactly gas_limit * GAS_PRICE.
    sender = pre.fund_eoa(amount=gas_limit * GAS_PRICE)
    tx = Transaction(
        sender=sender,
        to=pre.fund_eoa(amount=0),
        authorization_list=authorization_list,
        gas_limit=gas_limit,
        max_fee_per_gas=GAS_PRICE,
        max_priority_fee_per_gas=GAS_PRICE,
        error=TransactionException.INTRINSIC_GAS_TOO_LOW,
    )

    state_test(pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.