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@e9958ed2.

Generate fixtures for these test cases for Osaka with:

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

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
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
398
399
400
401
402
403
404
405
@pytest.mark.valid_at_transition_to("Cancun", subsequent_forks=False)
@pytest.mark.parametrize(
    "excess_blob_gas_missing,blob_gas_used_missing",
    [
        (True, False),
        (False, True),
        (True, True),
    ],
)
@pytest.mark.exception_test
def test_invalid_post_fork_block_without_blob_fields(
    blockchain_test: BlockchainTestFiller,
    genesis_environment: Environment,
    pre: Alloc,
    pre_fork_blocks: List[Block],
    excess_blob_gas_missing: bool,
    blob_gas_used_missing: bool,
) -> None:
    """
    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=genesis_environment,
    )

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