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@5c024cbb.

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
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
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
@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.