Skip to content

test_withdrawal_requests_out_of_gas()

Documentation for tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests_out_of_gas.py::test_withdrawal_requests_out_of_gas@343274cc.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests_out_of_gas.py::test_withdrawal_requests_out_of_gas --fork Amsterdam

Test that a withdrawal request whose triggering call runs out of gas is not included, while the other requests in the block are.

The gas limits are supplied per-request via the interaction's gas_limits list rather than being baked into the withdrawal request descriptor, keeping the gas concern isolated to these dedicated tests.

Source code in tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests_out_of_gas.py
 34
 35
 36
 37
 38
 39
 40
 41
 42
 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@pytest.mark.parametrize(
    "system_contract_interactions_per_block",
    [
        pytest.param(
            [
                [
                    SystemContractInteractionTransaction(
                        requests=[
                            WithdrawalRequest(
                                validator_pubkey=0x01,
                                amount=0,
                                valid=False,
                            ),
                            WithdrawalRequest(
                                validator_pubkey=0x02,
                                amount=0,
                            ),
                        ],
                        # Value obtained from trace minus one
                        gas_limits=[114_247 - 1, None],
                    ),
                ],
            ],
            id="single_block_multiple_withdrawal_request_first_oog",
        ),
        pytest.param(
            [
                [
                    SystemContractInteractionTransaction(
                        requests=[
                            WithdrawalRequest(
                                validator_pubkey=0x01,
                                amount=0,
                            ),
                            WithdrawalRequest(
                                validator_pubkey=0x02,
                                amount=0,
                                valid=False,
                            ),
                        ],
                        # Value obtained from trace minus one
                        gas_limits=[None, 80_047 - 1],
                    ),
                ],
            ],
            id="single_block_multiple_withdrawal_request_last_oog",
        ),
        pytest.param(
            [
                [
                    SystemContractInteractionContract(
                        requests=[
                            WithdrawalRequest(
                                validator_pubkey=1,
                                amount=Spec.MAX_AMOUNT - 1,
                                valid=False,
                            )
                        ]
                        + [
                            WithdrawalRequest(
                                validator_pubkey=i + 1,
                                amount=Spec.MAX_AMOUNT - 1
                                if i % 2 == 0
                                else 0,
                                valid=True,
                            )
                            for i in range(
                                1, Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK
                            )
                        ],
                        # Starve the first inner call of gas
                        gas_limits=[100]
                        + [None]
                        * (Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK - 1),
                    ),
                ],
            ],
            id="single_block_multiple_withdrawal_requests_from_contract_first_oog",
        ),
        pytest.param(
            [
                [
                    SystemContractInteractionContract(
                        requests=[
                            WithdrawalRequest(
                                validator_pubkey=i + 1,
                                amount=Spec.MAX_AMOUNT - 1
                                if i % 2 == 0
                                else 0,
                                valid=True,
                            )
                            for i in range(
                                Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK
                            )
                        ]
                        + [
                            WithdrawalRequest(
                                validator_pubkey=Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK,
                                amount=Spec.MAX_AMOUNT - 1,
                                valid=False,
                            )
                        ],
                        # Starve the last inner call of gas
                        gas_limits=[None]
                        * Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK
                        + [100],
                    ),
                ],
            ],
            id="single_block_multiple_withdrawal_requests_from_contract_last_oog",
        ),
    ],
)
def test_withdrawal_requests_out_of_gas(
    blockchain_test: BlockchainTestFiller,
    blocks: List[Block],
    pre: Alloc,
) -> None:
    """
    Test that a withdrawal request whose triggering call runs out of gas is
    not included, while the other requests in the block are.

    The gas limits are supplied per-request via the interaction's `gas_limits`
    list rather than being baked into the withdrawal request descriptor,
    keeping the gas concern isolated to these dedicated tests.
    """
    blockchain_test(
        genesis_environment=Environment(),
        pre=pre,
        post={},
        blocks=blocks,
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.