Skip to content

test_below_amsterdam_floor_with_exact_balance_sender()

Documentation for tests/amsterdam/eip7976_increase_calldata_floor_cost/test_floor_boundary_exact_balance.py::test_below_amsterdam_floor_with_exact_balance_sender@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7976_increase_calldata_floor_cost/test_floor_boundary_exact_balance.py::test_below_amsterdam_floor_with_exact_balance_sender --fork Amsterdam

Reject when gas_limit sits between Prague and Amsterdam floor.

EIP-7976 raises the per-byte calldata floor cost. A transaction with gas_limit in [Prague_floor, Amsterdam_floor) must reject with INTRINSIC_GAS_BELOW_FLOOR_GAS_COST. The sender is funded with exactly gas_limit * gas_price so an implementation that uses the Prague floor cannot fall back to silent execution.

Type-0 only on purpose; broader type-½/¾ coverage lives in test_transaction_validity.py.

Source code in tests/amsterdam/eip7976_increase_calldata_floor_cost/test_floor_boundary_exact_balance.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "zero_bytes",
    [
        pytest.param(200, id="200_zero_bytes"),
        pytest.param(1000, id="1000_zero_bytes"),
    ],
)
def test_below_amsterdam_floor_with_exact_balance_sender(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    zero_bytes: int,
) -> None:
    """
    Reject when gas_limit sits between Prague and Amsterdam floor.

    EIP-7976 raises the per-byte calldata floor cost. A transaction
    with `gas_limit` in `[Prague_floor, Amsterdam_floor)` must reject
    with `INTRINSIC_GAS_BELOW_FLOOR_GAS_COST`. The sender is funded
    with exactly `gas_limit * gas_price` so an implementation that
    uses the Prague floor cannot fall back to silent execution.

    Type-0 only on purpose; broader type-1/2/3/4 coverage lives in
    `test_transaction_validity.py`.
    """
    tx_data = Bytes(b"\x00" * zero_bytes)
    intrinsic_regular = fork.transaction_intrinsic_cost_calculator()(
        calldata=tx_data,
        return_cost_deducted_prior_execution=True,
    )
    amsterdam_floor = fork.transaction_data_floor_cost_calculator()(
        data=tx_data,
    )
    # Prague counts each zero byte as one token at TX_DATA_TOKEN_FLOOR
    # gas/token. Cannot be derived from amsterdam_floor because EIP-7976
    # changes both the per-token rate (10->16) and the floor tokenization
    # (zero/nonzero both weighted by 4).
    prague_floor = 21000 + Spec7623.TX_DATA_TOKEN_FLOOR * zero_bytes
    gas_limit = (prague_floor + amsterdam_floor) // 2
    assert intrinsic_regular <= gas_limit
    assert prague_floor <= gas_limit < amsterdam_floor

    gas_price = 10
    sender = pre.fund_eoa(amount=gas_limit * gas_price)
    tx = Transaction(
        sender=sender,
        to=pre.fund_eoa(amount=0),
        data=tx_data,
        gas_limit=gas_limit,
        gas_price=gas_price,
        error=TransactionException.INTRINSIC_GAS_BELOW_FLOOR_GAS_COST,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.