Skip to content

test_intrinsic_gas_floor_boundary_contract_creation()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_contract_creation@622620d8.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py::test_intrinsic_gas_floor_boundary_contract_creation --fork Amsterdam

Reject a contract-creation transaction when gas_limit = intrinsic_gas - 1.

A creation tx's intrinsic is TX_BASE + CREATE_ACCESS plus the init-code and calldata terms; the created account's NEW_ACCOUNT state gas is charged at the top frame and plays no part in the validity check. The init code never runs.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_intrinsic_gas_boundary.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@EIPChecklist.GasCostChanges.Test.OutOfGas()
@pytest.mark.inclusion_test
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "value",
    [
        pytest.param(0, id="zero_value"),
        pytest.param(1, id="non-zero_value"),
    ],
)
def test_intrinsic_gas_floor_boundary_contract_creation(
    fork: Fork,
    pre: Alloc,
    state_test: StateTestFiller,
    value: int,
) -> None:
    """
    Reject a contract-creation transaction when
    ``gas_limit = intrinsic_gas - 1``.

    A creation tx's intrinsic is ``TX_BASE + CREATE_ACCESS`` plus the
    init-code and calldata terms; the created account's ``NEW_ACCOUNT``
    state gas is charged at the top frame and plays no part in the
    validity check. The init code never runs.
    """
    sender = pre.fund_eoa(10**18)
    init_code = Op.STOP

    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
        calldata=init_code,
        contract_creation=True,
        sends_value=bool(value),
        return_cost_deducted_prior_execution=True,
    )

    tx = Transaction(
        sender=sender,
        to=None,
        value=value,
        data=init_code,
        gas_limit=intrinsic_gas - 1,
        gas_price=1_000_000_000,
        error=TransactionException.INTRINSIC_GAS_TOO_LOW,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.