Skip to content

test_bal_fork_transition_builder_requests()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py::test_bal_fork_transition_builder_requests@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py::test_bal_fork_transition_builder_requests --fork Amsterdam

Verify the BAL of an activation block that dequeues EIP-8282 builder requests.

The first Amsterdam block carries the chain's first builder deposit and exit requests: the BAL must record both predeploys' request-bus slots, the enqueuing transaction indices, and the clean-sweep dequeue by the post-execution system calls.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
@pytest.mark.valid_at_transition_to("Amsterdam")
def test_bal_fork_transition_builder_requests(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Verify the BAL of an activation block that dequeues EIP-8282 builder
    requests.

    The first Amsterdam block carries the chain's first builder deposit
    and exit requests: the BAL must record both predeploys' request-bus
    slots, the enqueuing transaction indices, and the clean-sweep dequeue
    by the post-execution system calls.
    """
    alice = pre.fund_eoa()
    bob = pre.fund_eoa(amount=0)

    deposit = BuilderDepositRequest(
        pubkey=1,
        withdrawal_credentials=2,
        amount=Spec8282.BUILDER_MIN_DEPOSIT // 10**9,
        signature=3,
        fee=BuilderDepositRequest.get_fee(0),
    )
    builder_exit = BuilderExitRequest(
        pubkey=1, fee=BuilderExitRequest.get_fee(0)
    )

    deposit_interaction = SystemContractInteractionTransaction(
        requests=[deposit]
    ).update_pre(pre)
    exit_interaction = SystemContractInteractionTransaction(
        requests=[builder_exit]
    ).update_pre(pre)
    txs = deposit_interaction.transactions() + exit_interaction.transactions()
    system_call_index = len(txs) + 1

    deposit_sender = deposit_interaction.sender_account
    exit_sender = exit_interaction.sender_account
    assert deposit_sender is not None and exit_sender is not None

    blocks = [
        Block(
            timestamp=FORK_TIMESTAMP - 1,
            txs=[Transaction(sender=alice, to=bob, value=100, gas_price=10)],
            header_verify=Header(
                block_access_list_hash=Header.EMPTY_FIELD,
            ),
        ),
        Block(
            timestamp=FORK_TIMESTAMP,
            txs=txs,
            expected_block_access_list=BlockAccessListExpectation(
                account_expectations={
                    deposit_sender: BalAccountExpectation(
                        nonce_changes=[
                            BalNonceChange(block_access_index=1, post_nonce=1)
                        ],
                    ),
                    exit_sender: BalAccountExpectation(
                        nonce_changes=[
                            BalNonceChange(block_access_index=2, post_nonce=1)
                        ],
                    ),
                    Address(
                        Spec8282.BUILDER_DEPOSIT_CONTRACT_ADDRESS
                    ): _single_request_bus_expectation(
                        1, system_call_index, deposit.value
                    ),
                    Address(
                        Spec8282.BUILDER_EXIT_CONTRACT_ADDRESS
                    ): _single_request_bus_expectation(
                        2, system_call_index, builder_exit.value
                    ),
                }
            ),
        ),
    ]

    blockchain_test(
        pre=pre,
        blocks=blocks,
        post={
            Address(Spec8282.BUILDER_DEPOSIT_CONTRACT_ADDRESS): Account(
                balance=deposit.value
            ),
            Address(Spec8282.BUILDER_EXIT_CONTRACT_ADDRESS): Account(
                balance=builder_exit.value
            ),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.