Skip to content

test_access_list_floor_cost_with_calldata()

Documentation for tests/amsterdam/eip7981_increase_access_list_cost/test_access_list_cost.py::test_access_list_floor_cost_with_calldata@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7981_increase_access_list_cost/test_access_list_cost.py::test_access_list_floor_cost_with_calldata --fork Amsterdam

Test that the floor cost correctly accounts for both access list and calldata tokens.

According to EIP-7981: - total_floor_data_tokens = floor_tokens_in_calldata + floor_tokens_in_access_list - floor_gas = TX_BASE_COST + total_floor_data_tokens * TOTAL_COST_FLOOR_PER_TOKEN

Source code in tests/amsterdam/eip7981_increase_access_list_cost/test_access_list_cost.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
@pytest.mark.parametrize(
    "access_list,tx_data",
    [
        pytest.param(
            [AccessList(address=Address(1), storage_keys=[Hash(0)])],
            Bytes(b"\x01" * 100),
            id="access_list_and_calldata",
        ),
        pytest.param(
            [
                AccessList(
                    address=Address(1),
                    storage_keys=[Hash(i) for i in range(10)],
                )
            ],
            Bytes(b"\x00" * 50 + b"\x01" * 50),
            id="large_access_list_mixed_calldata",
        ),
    ],
)
@pytest.mark.parametrize(
    "to",
    [pytest.param("eoa", id="")],
    indirect=True,
)
def test_access_list_floor_cost_with_calldata(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
    tx_intrinsic_gas_cost_including_floor_data_cost: int,
) -> None:
    """
    Test that the floor cost correctly accounts for both access list
    and calldata tokens.

    According to EIP-7981:
    - total_floor_data_tokens =
      floor_tokens_in_calldata + floor_tokens_in_access_list
    - floor_gas =
      TX_BASE_COST + total_floor_data_tokens * TOTAL_COST_FLOOR_PER_TOKEN
    """
    tx.expected_receipt = TransactionReceipt(
        cumulative_gas_used=tx_intrinsic_gas_cost_including_floor_data_cost
    )

    state_test(
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 1 fork.