Skip to content

test_bal_invalid_missing_storage_write()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_missing_storage_write@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_missing_storage_write --fork Amsterdam

Test that clients reject a BAL that omits a storage write that was actually performed.

Writer's storage slot 0 goes from 0 (default) to 1. The BAL is corrupted by removing the account's storage_changes entirely. Unlike test_bal_invalid_field_entries[missing_storage_change], the account has no other changes, so the corrupted entry degrades to an access-only (empty) entry -- a shape that is legitimate for merely-touched accounts.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_missing_storage_write(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject a BAL that omits a storage write that was
    actually performed.

    Writer's storage slot 0 goes from 0 (default) to 1. The BAL is
    corrupted by removing the account's storage_changes entirely.
    Unlike `test_bal_invalid_field_entries[missing_storage_change]`,
    the account has no other changes, so the corrupted entry degrades
    to an access-only (empty) entry -- a shape that is legitimate for
    merely-touched accounts.
    """
    alice = pre.fund_eoa()
    writer = pre.deploy_contract(code=Op.SSTORE(0, 1))

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

    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
                                )
                            ],
                        ),
                        writer: BalAccountExpectation(
                            storage_changes=[
                                BalStorageSlot(
                                    slot=0,
                                    slot_changes=[
                                        BalStorageChange(
                                            block_access_index=1,
                                            post_value=1,
                                        )
                                    ],
                                ),
                            ],
                        ),
                    }
                ).modify(remove_storage(writer)),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.