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@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_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
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
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
@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=[],
    )
    gas_price = 0xA

    tx = Transaction(
        sender=alice,
        to=bob,
        value=100,
        gas_limit=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) * 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.