Skip to content

test_bal_invalid_missing_coinbase()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_missing_coinbase@636b5f17.

Generate fixtures for these test cases for Bogota with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_missing_coinbase --fork Bogota

Test that clients reject blocks where BAL is missing the coinbase/fee recipient account.

Alice sends 100 wei to Bob with gas_price > base_fee so the coinbase (charlie) receives a non-zero tip. BAL is corrupted by removing charlie's entry entirely.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
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
1869
1870
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
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_missing_coinbase(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test that clients reject blocks where BAL is missing the
    coinbase/fee recipient account.

    Alice sends 100 wei to Bob with gas_price > base_fee so the
    coinbase (charlie) receives a non-zero tip. BAL is corrupted
    by removing charlie's entry entirely.
    """
    alice = pre.fund_eoa(amount=10**18)
    bob = pre.fund_eoa(amount=0)
    charlie = pre.fund_eoa(amount=0)

    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
        calldata=b"",
        contract_creation=False,
        access_list=[],
        recipient_type=RecipientType.EMPTY_ACCOUNT,
        sends_value=True,
    )
    top_frame_state_gas = fork.transaction_top_frame_state_gas(
        sends_value=True,
        recipient_type=RecipientType.EMPTY_ACCOUNT,
    )
    total_intrinsic_gas = intrinsic_gas + top_frame_state_gas
    gas_price = 0xA

    tx = Transaction(
        sender=alice,
        to=bob,
        value=100,
        gas_limit=total_intrinsic_gas + 1000,
        gas_price=gas_price,
    )

    genesis_env = Environment(base_fee_per_gas=0x7)
    base_fee_per_gas = fork.base_fee_per_gas_calculator()(
        parent_base_fee_per_gas=int(genesis_env.base_fee_per_gas or 0),
        parent_gas_used=0,
        parent_gas_limit=genesis_env.gas_limit,
    )
    tip = (gas_price - base_fee_per_gas) * total_intrinsic_gas

    blockchain_test(
        pre=pre,
        post={},
        genesis_environment=genesis_env,
        blocks=[
            Block(
                txs=[tx],
                fee_recipient=charlie,
                header_verify=Header(base_fee_per_gas=base_fee_per_gas),
                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
                                )
                            ],
                        ),
                        bob: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=1, post_balance=100
                                )
                            ],
                        ),
                        charlie: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=1, post_balance=tip
                                )
                            ],
                        ),
                    }
                ).modify(remove_accounts(charlie)),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 2 forks.