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@892e6d1e.

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
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
@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.