Skip to content

test_invalid_pre_fork_block_with_blob_fields()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py::test_invalid_pre_fork_block_with_blob_fields@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

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

Blocks sent by NewPayloadV2 (Shanghai) that contain excessBlobGas and blobGasUsed fields must be rejected with the appropriate EngineAPIError.InvalidParams error error.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py
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
@pytest.mark.valid_at_transition_to("Cancun", subsequent_forks=False)
@pytest.mark.parametrize(
    "excess_blob_gas_present,blob_gas_used_present",
    [
        (True, False),
        (False, True),
        (True, True),
    ],
)
@pytest.mark.exception_test
def test_invalid_pre_fork_block_with_blob_fields(
    blockchain_test: BlockchainTestFiller,
    genesis_environment: Environment,
    pre: Alloc,
    pre_fork_blocks: List[Block],
    excess_blob_gas_present: bool,
    blob_gas_used_present: bool,
) -> None:
    """
    Test block rejection when `excessBlobGas` and/or `blobGasUsed` fields are
    present on a pre-fork block.

    Blocks sent by NewPayloadV2 (Shanghai) that contain `excessBlobGas` and
    `blobGasUsed` fields must be rejected with the appropriate
    `EngineAPIError.InvalidParams` error error.
    """
    header_modifier = Header(
        excess_blob_gas=0 if excess_blob_gas_present else None,
        blob_gas_used=0 if blob_gas_used_present else None,
    )
    blockchain_test(
        pre=pre,
        post={},
        blocks=pre_fork_blocks[:-1]
        + [
            Block(
                timestamp=(FORK_TIMESTAMP - 1),
                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_present blob_gas_used_present
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_present_True-blob_gas_used_present_False True False
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_present_False-blob_gas_used_present_True False True
...fork_ShanghaiToCancunAtTime15k-blockchain_test-excess_blob_gas_present_True-blob_gas_used_present_True True True