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@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_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_regular, 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
@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_regular, 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)
    ]
    regular = intrinsic(
        access_list=access_list,
        return_cost_deducted_prior_execution=True,
    )
    floor = floor_cost(data=b"", access_list=access_list)
    assert regular <= 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.