Skip to content

test_bal_invalid_missing_coinbase()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_missing_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_missing_coinbase --fork Amsterdam

Test that clients reject blocks where BAL is missing the coinbase/fee recipient account.

Alice sends 100 wei to Bob with gas_price > base_fee so the coinbase (charlie) receives a non-zero tip. BAL is corrupted by removing charlie's entry entirely.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_missing_coinbase(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test that clients reject blocks where BAL is missing the
    coinbase/fee recipient account.

    Alice sends 100 wei to Bob with gas_price > base_fee so the
    coinbase (charlie) receives a non-zero tip. BAL is corrupted
    by removing charlie's entry entirely.
    """
    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(remove_accounts(charlie)),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.