Skip to content

test_bal_invalid_noop_value_change()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_noop_value_change@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_noop_value_change --fork Amsterdam

Test that clients reject a BAL balance/nonce/code change entry whose post-value equals the account's real, unchanged value.

Oracle legitimately appears in the BAL only via a storage read (slot 0 is read, not written). Its balance (0), nonce (1), and code are never touched by the transaction. The BAL is corrupted by appending a change entry for one of these fields whose post-value equals the account's actual unchanged value -- distinct from the wrong-value corruption covered elsewhere, since here post == pre exactly.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
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
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "modifier",
    [
        pytest.param(
            lambda oracle, code: append_change(  # noqa: ARG005
                account=oracle,
                change=BalBalanceChange(block_access_index=1, post_balance=0),
            ),
            id="noop_balance_change",
        ),
        pytest.param(
            lambda oracle, code: append_change(  # noqa: ARG005
                account=oracle,
                change=BalNonceChange(block_access_index=1, post_nonce=1),
            ),
            id="noop_nonce_change",
        ),
        pytest.param(
            lambda oracle, code: append_change(
                account=oracle,
                change=BalCodeChange(block_access_index=1, new_code=code),
            ),
            id="noop_code_change",
        ),
    ],
)
def test_bal_invalid_noop_value_change(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    modifier: Callable,
) -> None:
    """
    Test that clients reject a BAL balance/nonce/code change entry whose
    post-value equals the account's real, unchanged value.

    Oracle legitimately appears in the BAL only via a storage read (slot
    0 is read, not written). Its balance (0), nonce (1), and code are
    never touched by the transaction. The BAL is corrupted by appending
    a change entry for one of these fields whose post-value equals the
    account's actual unchanged value -- distinct from the wrong-value
    corruption covered elsewhere, since here post == pre exactly.
    """
    alice = pre.fund_eoa()
    code = Op.SLOAD(0)
    oracle = pre.deploy_contract(code=code, storage={0: 0x42})

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

    blockchain_test(
        pre=pre,
        # The block reverts and the post state remains unchanged.
        post=pre,
        blocks=[
            Block(
                txs=[tx],
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        alice: BalAccountExpectation(
                            nonce_changes=[
                                BalNonceChange(
                                    block_access_index=1, post_nonce=1
                                )
                            ],
                        ),
                        oracle: BalAccountExpectation(
                            storage_reads=[0],
                        ),
                    }
                ).modify(modifier(oracle=oracle, code=code)),
            )
        ],
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 1 fork.