Skip to content

test_bal_builder_request_dequeue()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip8282.py::test_bal_builder_request_dequeue@622620d8.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip8282.py::test_bal_builder_request_dequeue --fork Amsterdam

Ensure BAL tracks a builder request predeploy across a clean sweep, a target-exceeding sweep that writes the excess, and a partial sweep that advances the queue head.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip8282.py
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
@pytest.mark.parametrize(
    "request_class",
    [BuilderDepositRequest, BuilderExitRequest],
    ids=["deposit", "exit"],
)
@pytest.mark.parametrize(
    "scenario,via_contract",
    [
        pytest.param("single", False, id="single_from_eoa"),
        pytest.param("target_exceeded", False, id="target_exceeded_from_eoa"),
        pytest.param("carry_over", True, id="carry_over_from_contract"),
    ],
)
def test_bal_builder_request_dequeue(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    request_class: Type[FeeSystemContractRequest],
    scenario: str,
    via_contract: bool,
) -> None:
    """
    Ensure BAL tracks a builder request predeploy across a clean sweep, a
    target-exceeding sweep that writes the excess, and a partial sweep that
    advances the queue head.
    """
    if scenario == "single":
        num_requests = 1
    elif scenario == "target_exceeded":
        num_requests = request_class.target_per_block + 1
    else:  # carry_over: exceed the per-block dequeue cap
        num_requests = request_class.max_per_block + 1
    requests = [
        _request(request_class, i, fee)
        for i, fee in enumerate(request_class.get_enqueue_fees(num_requests))
    ]
    interaction: SystemContractInteractionBase
    if via_contract:
        interaction = SystemContractInteractionContract(requests=requests)
    else:
        interaction = SystemContractInteractionTransaction(requests=requests)
    prepared = interaction.update_pre(pre)
    txs = prepared.transactions()
    system_call_index = len(txs) + 1

    if via_contract:
        enqueues = [(1, num_requests)]
    else:
        enqueues = [(i + 1, i + 1) for i in range(num_requests)]

    sender = prepared.sender_account
    assert sender is not None

    block = Block(
        txs=txs,
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                sender: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(
                            block_access_index=i + 1, post_nonce=i + 1
                        )
                        for i in range(len(txs))
                    ],
                ),
                request_class.system_contract_address: (
                    _request_queue_expectation(
                        request_class, enqueues, system_call_index
                    )
                ),
            }
        ),
    )

    blockchain_test(pre=pre, blocks=[block], post={})

Parametrized Test Cases

This test generates 6 parametrized test cases across 1 fork.