Skip to content

test_bal_invalid_missing_withdrawal_account()

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

Test that clients reject blocks where BAL is missing an account that was modified only by a withdrawal.

Alice sends 5 wei to Bob (1 transaction). Charlie receives 10 gwei withdrawal. BAL is corrupted by removing Charlie's entry entirely. Clients must detect that Charlie's balance was modified by the withdrawal but has no corresponding BAL entry.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_missing_withdrawal_account(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where BAL is missing an account
    that was modified only by a withdrawal.

    Alice sends 5 wei to Bob (1 transaction).
    Charlie receives 10 gwei withdrawal.
    BAL is corrupted by removing Charlie's entry entirely.
    Clients must detect that Charlie's balance was modified by the
    withdrawal but has no corresponding BAL entry.
    """
    alice = pre.fund_eoa()
    bob = pre.fund_eoa(amount=0)
    charlie = pre.fund_eoa(amount=0)

    tx = Transaction(
        sender=alice,
        to=bob,
        value=5,
        gas_limit=21_000,
    )

    blockchain_test(
        pre=pre,
        post={
            alice: Account(nonce=0),
            bob: None,
            charlie: None,
        },
        blocks=[
            Block(
                txs=[tx],
                withdrawals=[
                    Withdrawal(
                        index=0,
                        validator_index=0,
                        address=charlie,
                        amount=10,
                    )
                ],
                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=5
                                )
                            ],
                        ),
                        charlie: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=2,
                                    post_balance=10 * 10**9,
                                )
                            ],
                        ),
                    }
                ).modify(remove_accounts(charlie)),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.