Skip to content

test_intrinsic_within_cap_gas_limit_above_cap()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_intrinsic_within_cap_gas_limit_above_cap@622620d8.

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

Accept a transaction whose gas_limit exceeds the cap when both intrinsic operands stay below it.

EIP-8037 relaxes the EIP-7825 cap on tx.gas itself; only max(intrinsic_execution, calldata_floor) is capped. This positive control sets gas_limit above the cap with a small access list so both operands are far below it, and the transaction must execute. It is the accepting counterpart to the cap-rejection tests above.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
@pytest.mark.valid_from("EIP8037")
def test_intrinsic_within_cap_gas_limit_above_cap(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Accept a transaction whose ``gas_limit`` exceeds the cap when both
    intrinsic operands stay below it.

    EIP-8037 relaxes the EIP-7825 cap on ``tx.gas`` itself; only
    ``max(intrinsic_execution, calldata_floor)`` is capped. This positive
    control sets ``gas_limit`` above the cap with a small access list so
    both operands are far below it, and the transaction must execute. It is
    the accepting counterpart to the cap-rejection tests above.
    """
    cap = fork.transaction_gas_limit_cap()
    assert cap is not None
    floor_cost = fork.transaction_data_floor_cost_calculator()
    intrinsic = fork.transaction_intrinsic_cost_calculator()

    access_list = [
        AccessList(address=Address(0x10000 + i), storage_keys=[])
        for i in range(16)
    ]
    execution = intrinsic(
        access_list=access_list,
        return_cost_deducted_prior_execution=True,
    )
    floor = floor_cost(data=b"", access_list=access_list)
    assert execution <= cap
    assert floor <= cap

    storage = Storage()
    contract = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(1), 1),
    )

    tx = Transaction(
        ty=1,
        to=contract,
        gas_limit=cap + 3_000_000,
        access_list=access_list,
        sender=pre.fund_eoa(),
    )
    state_test(pre=pre, post={contract: Account(storage=storage)}, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.