Skip to content

test_bal_precompile_call_opcode()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_precompile_call_opcode@622620d8.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_precompile_call_opcode --fork Amsterdam

Ensure BAL records the precompile address regardless of call opcode.

Alice calls Oracle contract which invokes the precompile via the parametrized call opcode. For DELEGATECALL/CALLCODE the precompile provides the code but is not the call target, so its access has to be recorded explicitly rather than incidentally.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
@pytest.mark.with_all_precompiles
@pytest.mark.with_all_call_opcodes
def test_bal_precompile_call_opcode(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    precompile: int,
    call_opcode: Op,
) -> None:
    """
    Ensure BAL records the precompile address regardless of call opcode.

    Alice calls Oracle contract which invokes the precompile via the
    parametrized call opcode. For DELEGATECALL/CALLCODE the precompile
    provides the code but is not the call target, so its access has to
    be recorded explicitly rather than incidentally.
    """
    alice = pre.fund_eoa()

    oracle = pre.deploy_contract(
        code=call_opcode(address=precompile) + Op.STOP
    )

    tx = Transaction(sender=alice, to=oracle)

    block = Block(
        txs=[tx],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                alice: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1)
                    ],
                ),
                oracle: BalAccountExpectation.empty(),
                precompile: BalAccountExpectation.empty(),
            }
        ),
    )

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

Parametrized Test Cases

This test generates 72 parametrized test cases across 1 fork.