Skip to content

test_invalid_pre_fork_block_with_slot_number()

Documentation for tests/amsterdam/eip7843_slotnum/test_fork_transition.py::test_invalid_pre_fork_block_with_slot_number@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7843_slotnum/test_fork_transition.py::test_invalid_pre_fork_block_with_slot_number --fork Amsterdam

Reject a pre-fork block that carries the slot number field in its header or its engine newPayload.

The field must not be present before the fork activates: the extra header field changes the header shape, while in the payload case the block is otherwise valid, so clients that silently drop unknown payload fields would answer VALID and must fail this test.

Source code in tests/amsterdam/eip7843_slotnum/test_fork_transition.py
 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
@EIPChecklist.BlockHeaderField.Test.ForkTransition.Before()
@pytest.mark.valid_at_transition_to("EIP7843")
@pytest.mark.exception_test
@pytest.mark.parametrize(
    "block_kwargs",
    [
        pytest.param(
            {"rlp_modifier": Header(slot_number=0)},
            id="header_field",
        ),
        pytest.param(
            {"engine_new_payload_slot_number": 0},
            id="engine_payload_field",
            marks=pytest.mark.blockchain_test_engine_only,
        ),
    ],
)
def test_invalid_pre_fork_block_with_slot_number(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    block_kwargs: dict[str, Any],
) -> None:
    """
    Reject a pre-fork block that carries the slot number field in its
    header or its engine `newPayload`.

    The field must not be present before the fork activates: the extra
    header field changes the header shape, while in the payload case
    the block is otherwise valid, so clients that silently drop
    unknown payload fields would answer VALID and must fail this test.
    """
    sender = pre.fund_eoa()
    receiver = pre.fund_eoa(amount=0)

    tx = Transaction(sender=sender, to=receiver, value=100)

    blockchain_test(
        pre=pre,
        post={},
        blocks=[
            Block(
                timestamp=FORK_TIMESTAMP - 1,
                txs=[tx],
                exception=BlockException.INCORRECT_BLOCK_FORMAT,
                engine_api_error_code=EngineAPIError.InvalidParams,
                **block_kwargs,
            ),
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.