Skip to content

test_bal_invalid_extraneous_coinbase()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_extraneous_coinbase@622620d8.

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_extraneous_coinbase --fork Amsterdam

Test that clients reject blocks where BAL contains a spurious coinbase entry when the coinbase received no fees.

Coinbase is only included in BAL when it receives transaction tips. In blocks with no transactions, the coinbase receives nothing — even if withdrawals modify other accounts' balances.

  • empty_block: No txs, no withdrawals. Only system contracts.
  • withdrawal_only: No txs, one withdrawal to a different address. Withdrawals don't pay fees, so coinbase is still untouched.
Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "has_withdrawal",
    [
        pytest.param(False, id="empty_block"),
        pytest.param(True, id="withdrawal_only"),
    ],
)
def test_bal_invalid_extraneous_coinbase(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    has_withdrawal: bool,
) -> None:
    """
    Test that clients reject blocks where BAL contains a spurious
    coinbase entry when the coinbase received no fees.

    Coinbase is only included in BAL when it receives transaction tips.
    In blocks with no transactions, the coinbase receives nothing —
    even if withdrawals modify other accounts' balances.

    - empty_block: No txs, no withdrawals. Only system contracts.
    - withdrawal_only: No txs, one withdrawal to a different address.
      Withdrawals don't pay fees, so coinbase is still untouched.
    """
    coinbase = pre.fund_eoa(amount=0)

    withdrawals = None
    post: dict = {}
    if has_withdrawal:
        recipient = pre.fund_eoa(amount=0)
        withdrawals = [
            Withdrawal(
                index=0,
                validator_index=0,
                address=recipient,
                amount=10,
            )
        ]
        post[recipient] = None

    blockchain_test(
        pre=pre,
        post=post,
        blocks=[
            Block(
                txs=[],
                fee_recipient=coinbase,
                withdrawals=withdrawals,
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={coinbase: None}
                ).modify(
                    append_account(BalAccountChange(address=coinbase)),
                    sort_accounts_by_address(),
                ),
            )
        ],
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.