Skip to content

test_calldata_floor_charged_to_sender()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py::test_calldata_floor_charged_to_sender@8acae1b0.

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

Verify the calldata floor is what the sender pays for.

With a STOP callee and large all-nonzero calldata, execution gas falls below the calldata floor. The sender must be charged calldata_floor * gas_price, so the final balance reflects the floor-applied value, not the pre-floor execution cost.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_calldata_floor.py
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
@pytest.mark.valid_from("EIP8037")
def test_calldata_floor_charged_to_sender(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify the calldata floor is what the sender pays for.

    With a STOP callee and large all-nonzero calldata, execution gas
    falls below the calldata floor. The sender must be charged
    `calldata_floor * gas_price`, so the final balance reflects the
    floor-applied value, not the pre-floor execution cost.
    """
    gas_limit_cap = fork.transaction_gas_limit_cap()
    assert gas_limit_cap is not None
    calldata = b"\xff" * 1024
    calldata_floor = fork.transaction_data_floor_cost_calculator()(
        data=calldata,
    )
    execution = fork.transaction_intrinsic_cost_calculator()(
        calldata=calldata,
        return_cost_deducted_prior_execution=True,
    )
    assert execution < calldata_floor, "calldata floor must bind"
    gas_price = 10**9
    initial = gas_limit_cap * gas_price

    contract = pre.deploy_contract(code=Op.STOP)
    sender = pre.fund_eoa(amount=initial)

    tx = Transaction(
        to=contract,
        data=calldata,
        gas_limit=gas_limit_cap,
        gas_price=gas_price,
        sender=sender,
    )

    blockchain_test(
        pre=pre,
        blocks=[Block(txs=[tx])],
        post={sender: Account(balance=initial - calldata_floor * gas_price)},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.