Skip to content

test_bal_invalid_coinbase_balance_value()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_coinbase_balance_value@87aba1a3.

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

Test that clients reject blocks where BAL contains an incorrect balance value for the coinbase/fee recipient.

Same setup as test_bal_invalid_missing_coinbase but the coinbase entry is present with a wrong balance (999 instead of the actual tip).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
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
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_coinbase_balance_value(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test that clients reject blocks where BAL contains an incorrect
    balance value for the coinbase/fee recipient.

    Same setup as test_bal_invalid_missing_coinbase but the coinbase
    entry is present with a wrong balance (999 instead of the
    actual tip).
    """
    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(
                    modify_balance(charlie, block_access_index=1, balance=999)
                ),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.