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@892e6d1e.

Generate fixtures for these test cases for Cancun with:

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

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.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
@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.
    """
    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 generates 3 parametrized test cases across 1 fork.