Skip to content

test_bal_withdrawal_contract_cross_index()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_withdrawal_contract_cross_index@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_withdrawal_contract_cross_index --fork Amsterdam

Test that the withdrawal system contract shows storage changes at both index 1 (during transaction) and index 2 (during post-execution).

This verifies that slots 0x01 and 0x03 are: 1. Incremented during the transaction (index 1) 2. Reset during post-execution (index 2)

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def test_bal_withdrawal_contract_cross_index(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Test that the withdrawal system contract shows storage changes at both
    index 1 (during transaction) and index 2 (during post-execution).

    This verifies that slots 0x01 and 0x03 are:
    1. Incremented during the transaction (index 1)
    2. Reset during post-execution (index 2)
    """
    sender = pre.fund_eoa()

    withdrawal_calldata = (
        (b"\x01" + b"\x00" * 47)  # validator pubkey
        + (b"\x00" * 8)  # amount
    )

    tx = Transaction(
        sender=sender,
        to=WITHDRAWAL_REQUEST_ADDRESS,
        value=1,
        data=withdrawal_calldata,
        gas_limit=1_000_000,
    )

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        WITHDRAWAL_REQUEST_ADDRESS: BalAccountExpectation(
                            # slots 0x01 and 0x03 change at BOTH indices
                            storage_changes=[
                                BalStorageSlot(
                                    slot=0x01,  # Request count
                                    slot_changes=[
                                        BalStorageChange(
                                            # Incremented during tx
                                            block_access_index=1,
                                            post_value=1,
                                        ),
                                        BalStorageChange(
                                            # Reset during post-exec
                                            block_access_index=2,
                                            post_value=0,
                                        ),
                                    ],
                                ),
                                BalStorageSlot(
                                    slot=0x03,  # Target count
                                    slot_changes=[
                                        BalStorageChange(
                                            # Incremented during tx
                                            block_access_index=1,
                                            post_value=1,
                                        ),
                                        BalStorageChange(
                                            # Reset during post-exec
                                            block_access_index=2,
                                            post_value=0,
                                        ),
                                    ],
                                ),
                            ],
                        ),
                    }
                ),
            )
        ],
        post={},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.