Skip to content

test_create_tx_below_total_intrinsic()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_tx_below_total_intrinsic@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_tx_below_total_intrinsic --fork Amsterdam

Reject CREATE tx when gas_limit covers regular but not state intrinsic.

EIP-8037 splits the CREATE intrinsic into regular and state components (STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE). test_create_tx_intrinsic_gas_boundary pins the upper boundary (total - 1); this pins the lower end — intrinsic_regular and one gas above — to catch implementations that omit the state component from the pre-validate check.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "extra_gas",
    [
        pytest.param(0, id="at_regular_intrinsic"),
        pytest.param(1, id="one_above_regular_intrinsic"),
    ],
)
@pytest.mark.valid_from("EIP8037")
def test_create_tx_below_total_intrinsic(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    extra_gas: int,
) -> None:
    """
    Reject CREATE tx when gas_limit covers regular but not state intrinsic.

    EIP-8037 splits the CREATE intrinsic into regular and state
    components (`STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE`).
    `test_create_tx_intrinsic_gas_boundary` pins the upper boundary
    (`total - 1`); this pins the lower end — `intrinsic_regular` and
    one gas above — to catch implementations that omit the state
    component from the pre-validate check.
    """
    total_intrinsic = fork.transaction_intrinsic_cost_calculator()(
        contract_creation=True,
    )
    intrinsic_state = fork.transaction_intrinsic_state_gas(
        contract_creation=True,
    )
    intrinsic_regular = total_intrinsic - intrinsic_state
    gas_limit = intrinsic_regular + extra_gas
    assert gas_limit < total_intrinsic

    tx = Transaction(
        to=None,
        gas_limit=gas_limit,
        sender=pre.fund_eoa(),
        error=TransactionException.INTRINSIC_GAS_TOO_LOW,
    )

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.