Skip to content

test_intrinsic_gas_floor_boundary_with_authorizations()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_with_authorizations@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_with_authorizations --fork Amsterdam

Reject a type-4 transaction when gas_limit = intrinsic_gas - 1, where the intrinsic includes EXECUTION_PER_AUTH_BASE_COST per authorization.

EIP-2780 keeps only the state-independent per-authorization base cost in the intrinsic (the state-dependent remainder moved to the top frame). The calldata floor does not count authorization tuples, so the intrinsic -- which scales with the authorization count -- is the binding minimum. The transaction is rejected before set_delegation runs, so no authority is mutated.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
@pytest.mark.inclusion_test
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "authorization_count",
    [
        pytest.param(1, id="one_authorization"),
        pytest.param(2, id="two_authorizations"),
    ],
)
def test_intrinsic_gas_floor_boundary_with_authorizations(
    fork: Fork,
    pre: Alloc,
    state_test: StateTestFiller,
    authorization_count: int,
) -> None:
    """
    Reject a type-4 transaction when ``gas_limit = intrinsic_gas - 1``,
    where the intrinsic includes ``EXECUTION_PER_AUTH_BASE_COST`` per
    authorization.

    EIP-2780 keeps only the state-independent per-authorization base
    cost in the intrinsic (the state-dependent remainder moved to the
    top frame). The calldata floor does not count authorization tuples,
    so the intrinsic -- which scales with the authorization count -- is
    the binding minimum. The transaction is rejected before
    ``set_delegation`` runs, so no authority is mutated.
    """
    sender = pre.fund_eoa(10**18)
    target = pre.fund_eoa(amount=EOA_INITIAL_BALANCE)
    delegate_to = pre.deploy_contract(code=Op.STOP)

    authorization_list = [
        AuthorizationTuple(
            address=delegate_to,
            nonce=0,
            signer=pre.fund_eoa(),
        )
        for _ in range(authorization_count)
    ]

    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
        recipient_type=RecipientType.EOA,
        authorization_list_or_count=authorization_list,
        return_cost_deducted_prior_execution=True,
    )

    tx = Transaction(
        sender=sender,
        to=target,
        value=0,
        authorization_list=authorization_list,
        gas_limit=intrinsic_gas - 1,
        max_fee_per_gas=1_000_000_000,
        max_priority_fee_per_gas=1_000_000_000,
        error=TransactionException.INTRINSIC_GAS_TOO_LOW,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.