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@c74f1a67.

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
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
@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.