Skip to content

test_invalid_post_fork_block_without_blob_fields()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py::test_invalid_post_fork_block_without_blob_fields@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py::test_invalid_post_fork_block_without_blob_fields --fork Prague

Test block rejection when excessBlobGas and/or blobGasUsed fields are missing on a post-fork block.

Blocks sent by NewPayloadV3 (Cancun) without excessBlobGas and blobGasUsed fields must be rejected with the appropriate EngineAPIError.InvalidParams error.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
@pytest.mark.valid_at_transition_to("Cancun")
@pytest.mark.parametrize(
    "excess_blob_gas_missing,blob_gas_used_missing",
    [
        (True, False),
        (False, True),
        (True, True),
    ],
)
def test_invalid_post_fork_block_without_blob_fields(
    blockchain_test: BlockchainTestFiller,
    env: Environment,
    pre: Alloc,
    pre_fork_blocks: List[Block],
    excess_blob_gas_missing: bool,
    blob_gas_used_missing: bool,
):
    """
    Test block rejection when `excessBlobGas` and/or `blobGasUsed` fields are missing on a
    post-fork block.

    Blocks sent by NewPayloadV3 (Cancun) without `excessBlobGas` and `blobGasUsed` fields must be
    rejected with the appropriate `EngineAPIError.InvalidParams` error.
    """
    header_modifier = Header()
    if excess_blob_gas_missing:
        header_modifier.excess_blob_gas = Header.REMOVE_FIELD
    if blob_gas_used_missing:
        header_modifier.blob_gas_used = Header.REMOVE_FIELD
    blockchain_test(
        pre=pre,
        post={},
        blocks=pre_fork_blocks
        + [
            Block(
                timestamp=FORK_TIMESTAMP,
                rlp_modifier=header_modifier,
                exception=BlockException.INCORRECT_BLOCK_FORMAT,
                engine_api_error_code=EngineAPIError.InvalidParams,
            )
        ],
        genesis_environment=env,
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) excess_blob_gas_missing blob_gas_used_missing
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_missing_True-blob_gas_used_missing_False True False
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_missing_False-blob_gas_used_missing_True False True
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_missing_True-blob_gas_used_missing_True True True