Skip to content

test_bal_account_touch_system_address()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_account_touch_system_address@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_account_touch_system_address --fork Amsterdam

Ensure a regular transaction that explicitly touches SYSTEM_ADDRESS via an account-accessing opcode includes SYSTEM_ADDRESS as an account-only BAL entry.

This confirms that SYSTEM_ADDRESS is only excluded from the BAL when it appears as the synthetic caller of a pre-execution system call; a real EVM state access from user code MUST still land in the BAL.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
@pytest.mark.parametrize(
    "access_opcode",
    [
        pytest.param(lambda target: Op.BALANCE(target), id="balance"),
        pytest.param(lambda target: Op.EXTCODESIZE(target), id="extcodesize"),
        pytest.param(lambda target: Op.EXTCODEHASH(target), id="extcodehash"),
        pytest.param(
            lambda target: Op.EXTCODECOPY(target, 0, 0, 0),
            id="extcodecopy",
        ),
        pytest.param(lambda target: Op.CALL(address=target), id="call"),
        pytest.param(
            lambda target: Op.STATICCALL(address=target),
            id="staticcall",
        ),
    ],
)
def test_bal_account_touch_system_address(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    access_opcode: Callable[[Address], Bytecode],
) -> None:
    """
    Ensure a regular transaction that explicitly touches SYSTEM_ADDRESS via
    an account-accessing opcode includes SYSTEM_ADDRESS as an account-only
    BAL entry.

    This confirms that SYSTEM_ADDRESS is only excluded from the BAL when it
    appears as the synthetic caller of a pre-execution system call; a real
    EVM state access from user code MUST still land in the BAL.
    """
    alice = pre.fund_eoa()
    pre.fund_address(SYSTEM_ADDRESS, amount=1)

    toucher = pre.deploy_contract(code=access_opcode(SYSTEM_ADDRESS) + Op.STOP)

    tx = Transaction(
        sender=alice,
        to=toucher,
        gas_limit=200_000,
    )

    block = Block(
        txs=[tx],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                toucher: BalAccountExpectation.empty(),
                SYSTEM_ADDRESS: BalAccountExpectation.empty(),
            }
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            alice: Account(nonce=1),
            toucher: Account(),
            SYSTEM_ADDRESS: Account(balance=1),
        },
    )

Parametrized Test Cases

This test generates 6 parametrized test cases across 1 fork.