Skip to content

test_calldata_floor_enforced_with_state_gas()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_calldata_floor_enforced_with_state_gas@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_calldata_floor_enforced_with_state_gas --fork Amsterdam

Test EIP-7623 calldata floor is enforced when EIP-8037 is active.

Send 100 non-zero calldata bytes to a call transaction so the regular intrinsic cost is below the calldata floor. A gas_limit at the floor succeeds; one below the floor is rejected.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
@pytest.mark.parametrize(
    "above_floor",
    [
        pytest.param(
            False,
            id="below_floor",
            marks=pytest.mark.exception_test,
        ),
        pytest.param(True, id="at_floor"),
    ],
)
@pytest.mark.valid_from("EIP8037")
def test_calldata_floor_enforced_with_state_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    above_floor: bool,
) -> None:
    """
    Test EIP-7623 calldata floor is enforced when EIP-8037 is active.

    Send 100 non-zero calldata bytes to a call transaction so the
    regular intrinsic cost is below the calldata floor. A gas_limit
    at the floor succeeds; one below the floor is rejected.
    """
    calldata = b"\x01" * 100
    intrinsic_cost = fork.transaction_intrinsic_cost_calculator()
    floor_cost = fork.transaction_data_floor_cost_calculator()

    regular_gas = intrinsic_cost(
        calldata=calldata,
        return_cost_deducted_prior_execution=True,
    )
    floor_gas = floor_cost(data=calldata)
    assert floor_gas > regular_gas, "floor must exceed regular for test"

    if above_floor:
        gas_limit = floor_gas
        error = None
    else:
        # Between regular and floor: satisfies regular but not floor
        gas_limit = (regular_gas + floor_gas) // 2
        error = TransactionException.INTRINSIC_GAS_BELOW_FLOOR_GAS_COST

    tx = Transaction(
        to=pre.fund_eoa(0),
        data=calldata,
        gas_limit=gas_limit,
        sender=pre.fund_eoa(),
        error=error,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.