Skip to content

test_calldata_floor_binds_with_reservoir()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py::test_calldata_floor_binds_with_reservoir@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py::test_calldata_floor_binds_with_reservoir --fork Amsterdam

Bind the calldata floor while an over-cap reservoir funds state gas.

Large calldata makes the EIP-7976 floor the sender's bill, while an over-cap gas_limit puts the SSTORE-set state charge in the reservoir. The floor binds the receipt and the block's regular dimension alike, so the header gas_used is the floor (not the state dimension).

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
@pytest.mark.valid_from("EIP8037")
def test_calldata_floor_binds_with_reservoir(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Bind the calldata floor while an over-cap reservoir funds state gas.

    Large calldata makes the EIP-7976 floor the sender's bill, while an
    over-cap `gas_limit` puts the SSTORE-set state charge in the
    reservoir. The floor binds the receipt and the block's regular
    dimension alike, so the header gas_used is the floor (not the
    state dimension).
    """
    storage = Storage()
    code = Op.SSTORE(storage.store_next(1), 1, new_value=1)
    state_cost = code.state_cost(fork)
    regular_cost = code.regular_cost(fork)

    # Sized so the floor binds while block-regular stays under storage_set.
    calldata = b"\x00" * 5000
    floor = fork.transaction_data_floor_cost_calculator()(data=calldata)
    intrinsic = fork.transaction_intrinsic_cost_calculator()(
        calldata=calldata,
        return_cost_deducted_prior_execution=True,
    )
    tx_regular = intrinsic + regular_cost
    assert floor > tx_regular + state_cost, (
        "calldata floor must exceed the sender's pre-floor bill"
    )
    assert tx_regular < state_cost, (
        "block-regular must stay under the state dimension"
    )

    contract = pre.deploy_contract(code=code)

    tx = Transaction(
        to=contract,
        data=calldata,
        state_gas_reservoir=state_cost,
        sender=pre.fund_eoa(),
        expected_receipt=TransactionReceipt(cumulative_gas_used=floor),
    )
    state_test(
        pre=pre,
        post={contract: Account(storage=storage)},
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=floor),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.