Skip to content

test_calldata_floor_binds_regardless_of_funding()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py::test_calldata_floor_binds_regardless_of_funding@622620d8.

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

Bind the calldata floor however the state charge is funded.

The floor is a lower bound on the sender's bill in the execution dimension alone, so splitting the SSTORE-set charge between the reservoir and gas_left must not move it. All three fundings bill the sender exactly the floor.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
@pytest.mark.parametrize(
    "funding",
    ["reservoir", "mixed", "spill"],
)
@pytest.mark.valid_from("EIP8037")
def test_calldata_floor_binds_regardless_of_funding(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    funding: str,
) -> None:
    """
    Bind the calldata floor however the state charge is funded.

    The floor is a lower bound on the sender's bill in the execution
    dimension alone, so splitting the SSTORE-set charge between the
    reservoir and `gas_left` must not move it. All three fundings bill
    the sender exactly the floor.
    """
    storage = Storage()
    code = Op.SSTORE(storage.store_next(1), 1, new_value=1)
    state_cost = code.state_cost(fork)

    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_execution = intrinsic + code.execution_cost(fork)
    assert floor > tx_execution + state_cost, (
        "calldata floor must exceed the sender's pre-floor bill"
    )

    contract = pre.deploy_contract(code=code)

    tx = Transaction(
        to=contract,
        data=calldata,
        state_gas_reservoir={
            "reservoir": state_cost,
            "mixed": state_cost // 2,
            "spill": 0,
        }[funding],
        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 3 parametrized test cases across 1 fork.