Skip to content

test_floor_cost_validation_with_access_list()

Documentation for tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py::test_floor_cost_validation_with_access_list@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py::test_floor_cost_validation_with_access_list --fork Amsterdam

Test that the floor cost validation includes access list tokens.

According to EIP-7981: - Any transaction with a gas limit below the floor cost is invalid - Floor cost = TX_BASE_COST + TOTAL_COST_FLOOR_PER_TOKEN * total_floor_data_tokens - total_floor_data_tokens = floor_tokens_in_calldata + floor_tokens_in_access_list

Source code in tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py
 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
116
117
118
119
120
121
122
@pytest.mark.exception_test
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
@pytest.mark.parametrize(
    "access_list,tx_data,tx_gas_delta",
    [
        pytest.param(
            [AccessList(address=Address(1), storage_keys=[Hash(0)])],
            Bytes(b"\x01" * 1000),
            -1,
            id="large_calldata_and_access_list_insufficient_gas",
        ),
        pytest.param(
            [AccessList(address=Address(1), storage_keys=[Hash(0)])],
            Bytes(b"\x00" * 1000),
            -1,
            id="large_zero_calldata_and_access_list_insufficient_gas",
        ),
    ],
)
@pytest.mark.parametrize(
    "to",
    [pytest.param("eoa", id="")],
    indirect=True,
)
def test_floor_cost_validation_with_access_list(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
) -> None:
    """
    Test that the floor cost validation includes access list tokens.

    According to EIP-7981:
    - Any transaction with a gas limit below the floor cost is invalid
    - Floor cost = TX_BASE_COST + TOTAL_COST_FLOOR_PER_TOKEN *
      total_floor_data_tokens
    - total_floor_data_tokens =
      floor_tokens_in_calldata + floor_tokens_in_access_list
    """
    state_test(
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 1 fork.