Skip to content

test_calldata_floor_counts_toward_block_gas()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py::test_calldata_floor_counts_toward_block_gas@26332146.

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_counts_toward_block_gas --fork Amsterdam

Verify the calldata floor is charged to the block's execution gas.

With a STOP callee and large zero-byte calldata the floor exceeds the actual execution gas charge, so the transaction contributes the floor (not the pre-floor charge) to the header gas_used.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
@pytest.mark.valid_from("EIP8037")
def test_calldata_floor_counts_toward_block_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify the calldata floor is charged to the block's execution gas.

    With a STOP callee and large zero-byte calldata the floor exceeds
    the actual execution gas charge, so the transaction contributes the
    floor (not the pre-floor charge) to the header gas_used.
    """
    calldata = b"\x00" * 1024
    floor = fork.transaction_data_floor_cost_calculator()(data=calldata)
    charge = fork.transaction_intrinsic_cost_calculator()(
        calldata=calldata,
        return_cost_deducted_prior_execution=True,
    )
    assert charge < floor, "calldata floor must bind"

    contract = pre.deploy_contract(code=Op.STOP)

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.