Skip to content

test_block_at_rlp_limit_with_withdrawals()

Documentation for tests/osaka/eip7934_block_rlp_limit/test_max_block_rlp_size.py::test_block_at_rlp_limit_with_withdrawals@e9958ed2.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7934_block_rlp_limit/test_max_block_rlp_size.py::test_block_at_rlp_limit_with_withdrawals --fork Osaka

Test that a block at the RLP size limit is valid even when the block contains withdrawals.

Source code in tests/osaka/eip7934_block_rlp_limit/test_max_block_rlp_size.py
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
@EIPChecklist.BlockLevelConstraint.Test.Content.Withdrawals()
@pytest.mark.verify_sync
@pytest.mark.valid_from("Osaka")
def test_block_at_rlp_limit_with_withdrawals(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    post: Alloc,
    env: Environment,
    sender: EOA,
    fork: Fork,
    block_size_limit: int,
) -> None:
    """
    Test that a block at the RLP size limit is valid even when the block
    contains withdrawals.
    """
    withdrawals = [
        Withdrawal(
            index=0,
            validator_index=0,
            address=pre.fund_eoa(),
            amount=1,
        ),
        Withdrawal(
            index=1,
            validator_index=1,
            address=pre.fund_eoa(),
            amount=1,
        ),
    ]

    transactions, gas_used = exact_size_transactions(
        sender,
        block_size_limit,
        fork,
        pre,
        env.gas_limit,
        withdrawals=withdrawals,
    )

    block_rlp_size = get_block_rlp_size(transactions, gas_used=gas_used, withdrawals=withdrawals)
    assert block_rlp_size == block_size_limit, (
        f"Block RLP size {block_rlp_size} does not exactly match limit {block_size_limit}, "
        f"difference: {block_rlp_size - block_size_limit} bytes"
    )

    block = Block(
        txs=transactions,
        withdrawals=withdrawals,
        extra_data=Bytes(EXTRA_DATA_AT_LIMIT),
        timestamp=ZeroPaddedHexNumber(HEADER_TIMESTAMP),
    )

    blockchain_test(
        genesis_environment=env,
        pre=pre,
        post=post,
        blocks=[block],
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Osaka-blockchain_test
...fork_Osaka-blockchain_test_sync