Skip to content

test_transaction_gas_limit_cap()

Documentation for tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_transaction_gas_limit_cap@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_transaction_gas_limit_cap --fork Prague

Test the transaction gas limit cap behavior for all transaction types.

Source code in tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 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
@pytest.mark.parametrize_by_fork("tx_gas_limit,error", tx_gas_limit_cap_tests)
@pytest.mark.with_all_tx_types
@pytest.mark.valid_from("Prague")
def test_transaction_gas_limit_cap(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    tx_gas_limit: int,
    error: TransactionException | None,
    tx_type: int,
):
    """Test the transaction gas limit cap behavior for all transaction types."""
    env = Environment()

    sender = pre.fund_eoa()
    storage = Storage()
    contract_address = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(1), 1) + Op.STOP,
    )

    tx_kwargs = {
        "ty": tx_type,
        "to": contract_address,
        "gas_limit": tx_gas_limit,
        "data": b"",
        "value": 0,
        "sender": sender,
        "error": error,
    }

    # Add extra required fields based on transaction type
    if tx_type >= 1:
        # Type 1: EIP-2930 Access List Transaction
        tx_kwargs["access_list"] = [
            {
                "address": contract_address,
                "storage_keys": [0],
            }
        ]
    if tx_type == 3:
        # Type 3: EIP-4844 Blob Transaction
        tx_kwargs["max_fee_per_blob_gas"] = fork.min_base_fee_per_blob_gas()
        tx_kwargs["blob_versioned_hashes"] = add_kzg_version([0], BLOB_COMMITMENT_VERSION_KZG)
    elif tx_type == 4:
        # Type 4: EIP-7702 Set Code Transaction
        signer = pre.fund_eoa(amount=0)
        tx_kwargs["authorization_list"] = [
            AuthorizationTuple(
                signer=signer,
                address=Address(0),
                nonce=0,
            )
        ]

    tx = Transaction(**tx_kwargs)
    post = {contract_address: Account(storage=storage if error is None else {})}

    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) tx_type tx_gas_limit error
...fork_Prague-tx_gas_limit_cap_none0-state_test 4 30000001 None
...fork_Prague-tx_gas_limit_cap_none0-blockchain_test_from_state_test 4 30000001 None
...fork_Prague-tx_gas_limit_cap_none1-state_test 3 30000001 None
...fork_Prague-tx_gas_limit_cap_none1-blockchain_test_from_state_test 3 30000001 None
...fork_Prague-tx_gas_limit_cap_none2-state_test 2 30000001 None
...fork_Prague-tx_gas_limit_cap_none2-blockchain_test_from_state_test 2 30000001 None
...fork_Prague-tx_gas_limit_cap_none3-state_test 1 30000001 None
...fork_Prague-tx_gas_limit_cap_none3-blockchain_test_from_state_test 1 30000001 None
...fork_Prague-tx_gas_limit_cap_none4-state_test 0 30000001 None
...fork_Prague-tx_gas_limit_cap_none4-blockchain_test_from_state_test 0 30000001 None
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum0-state_test 4 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum0-blockchain_test_from_state_test 4 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_none0-state_test 4 30000000 None
...fork_Osaka-tx_gas_limit_cap_none0-blockchain_test_from_state_test 4 30000000 None
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum1-state_test 3 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum1-blockchain_test_from_state_test 3 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_none1-state_test 3 30000000 None
...fork_Osaka-tx_gas_limit_cap_none1-blockchain_test_from_state_test 3 30000000 None
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum2-state_test 2 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum2-blockchain_test_from_state_test 2 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_none2-state_test 2 30000000 None
...fork_Osaka-tx_gas_limit_cap_none2-blockchain_test_from_state_test 2 30000000 None
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum3-state_test 1 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum3-blockchain_test_from_state_test 1 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_none3-state_test 1 30000000 None
...fork_Osaka-tx_gas_limit_cap_none3-blockchain_test_from_state_test 1 30000000 None
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum4-state_test 0 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_exceeds_maximum4-blockchain_test_from_state_test 0 30000001 TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM
...fork_Osaka-tx_gas_limit_cap_none4-state_test 0 30000000 None
...fork_Osaka-tx_gas_limit_cap_none4-blockchain_test_from_state_test 0 30000000 None