Skip to content

test_single_tx_state_check_exceeds_block_limit()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py::test_single_tx_state_check_exceeds_block_limit@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py::test_single_tx_state_check_exceeds_block_limit --fork Amsterdam

Verify a single tx is rejected when its gas limit exceeds the entire block gas limit in the state dimension.

No prior txs needed. The state check uses the full tx.gas, so a tx whose tx.gas exceeds block_gas_limit must be rejected at inclusion.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py
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
447
448
449
450
451
452
453
454
455
456
457
@pytest.mark.exception_test
@pytest.mark.valid_from("EIP8037")
def test_single_tx_state_check_exceeds_block_limit(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify a single tx is rejected when its gas limit exceeds the
    entire block gas limit in the state dimension.

    No prior txs needed. The state check uses the full `tx.gas`, so a
    tx whose `tx.gas` exceeds `block_gas_limit` must be rejected at
    inclusion.
    """
    gas_limit_cap = fork.transaction_gas_limit_cap()
    assert gas_limit_cap is not None

    block_gas_limit = gas_limit_cap + 100
    tx_gas = block_gas_limit + 1

    tx = Transaction(
        to=pre.deploy_contract(code=Op.STOP),
        gas_limit=tx_gas,
        sender=pre.fund_eoa(),
        error=TransactionException.GAS_ALLOWANCE_EXCEEDED,
    )

    blockchain_test(
        genesis_environment=Environment(gas_limit=block_gas_limit),
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                gas_limit=block_gas_limit,
                exception=TransactionException.GAS_ALLOWANCE_EXCEEDED,
            )
        ],
        post={},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.