Skip to content

test_repeated_address_acl()

Documentation for tests/berlin/eip2930_access_list/test_acl.py::test_repeated_address_acl@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/berlin/eip2930_access_list/test_acl.py::test_repeated_address_acl --fork Osaka

Tests that slots are warmed correctly in an access list that has the same address repeated more than once, each time with different slots.

Difference with other ACL tests is that we actually try to access both slots at runtime. We also measure the gas cost of each access in order to make debugging easier.

Source code in tests/berlin/eip2930_access_list/test_acl.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
def test_repeated_address_acl(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Tests that slots are warmed correctly in an access list that has the same
    address repeated more than once, each time with different slots.

    Difference with other ACL tests is that we actually try to
    access both slots at runtime. We also measure the gas cost
    of each access in order to make debugging easier.
    """
    sender = pre.fund_eoa()
    gsc = fork.gas_costs()

    sload0_measure = CodeGasMeasure(
        code=Op.SLOAD(0),
        overhead_cost=gsc.G_VERY_LOW * len(Op.SLOAD.kwargs),  # Cost of pushing SLOAD args
        extra_stack_items=1,  # SLOAD pushes 1 item to the stack
        sstore_key=0,
        stop=False,  # Because it's the first CodeGasMeasure
    )

    sload1_measure = CodeGasMeasure(
        code=Op.SLOAD(1),
        overhead_cost=gsc.G_VERY_LOW * len(Op.SLOAD.kwargs),  # Cost of pushing SLOAD args
        extra_stack_items=1,  # SLOAD pushes 1 item to the stack
        sstore_key=1,
    )

    contract = pre.deploy_contract(sload0_measure + sload1_measure)

    tx = Transaction(
        gas_limit=500_000,
        to=contract,
        value=0,
        sender=sender,
        access_list=[
            AccessList(
                address=contract,
                storage_keys=[0],
            ),
            AccessList(
                address=contract,
                storage_keys=[1],
            ),
        ],
    )

    sload_cost = gsc.G_WARM_ACCOUNT_ACCESS

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            contract: Account(
                storage={0: sload_cost, 1: sload_cost},
            )
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Berlin-state_test
...fork_Berlin-blockchain_test_from_state_test
...fork_London-state_test
...fork_London-blockchain_test_from_state_test
...fork_Paris-state_test
...fork_Paris-blockchain_test_from_state_test
...fork_Shanghai-state_test
...fork_Shanghai-blockchain_test_from_state_test
...fork_Cancun-state_test
...fork_Cancun-blockchain_test_from_state_test
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test