Skip to content

test_blob_type_tx_pre_fork()

Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_type_tx_pre_fork@3719e927.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_type_tx_pre_fork --fork Prague

Reject blocks with blob type transactions before Cancun fork.

Blocks sent by NewPayloadV2 (Shanghai) that contain blob type transactions, furthermore blobs field within NewPayloadV2 method must be computed as INVALID, due to an invalid block hash.

Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
@pytest.mark.parametrize(
    [
        "blobs_per_tx",
        "parent_excess_blobs",
        "tx_max_fee_per_blob_gas",
        "tx_error",
        "block_error",
    ],
    [
        (
            [0],
            None,
            1,
            [TransactionException.TYPE_3_TX_PRE_FORK, TransactionException.TYPE_3_TX_ZERO_BLOBS],
            [TransactionException.TYPE_3_TX_PRE_FORK, TransactionException.TYPE_3_TX_ZERO_BLOBS],
        ),
        (
            [1],
            None,
            1,
            TransactionException.TYPE_3_TX_PRE_FORK,
            [TransactionException.TYPE_3_TX_PRE_FORK, BlockException.INVALID_VERSIONED_HASHES],
        ),
    ],
    ids=["no_blob_tx", "one_blob_tx"],
)
@pytest.mark.exception_test
@pytest.mark.valid_at_transition_to("Cancun")
def test_blob_type_tx_pre_fork(
    state_test: StateTestFiller,
    pre: Alloc,
    txs: List[Transaction],
    block_error: Optional[TransactionException | BlockException],
):
    """
    Reject blocks with blob type transactions before Cancun fork.

    Blocks sent by NewPayloadV2 (Shanghai) that contain blob type transactions, furthermore blobs
    field within NewPayloadV2 method must be computed as INVALID, due to an invalid block hash.
    """
    assert len(txs) == 1
    state_test(
        pre=pre,
        post={},
        tx=txs[0],
        env=Environment(),  # `env` fixture has blob fields
        block_exception=block_error,
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated) blobs_per_tx parent_excess_blobs tx_max_fee_per_blob_gas tx_error block_error
...fork_Shanghai-state_test-no_blob_tx [0] None 1 [, ] [, ]
...fork_Shanghai-state_test-one_blob_tx [1] None 1 TransactionException.TYPE_3_TX_PRE_FORK [, ]
...fork_ShanghaiToCancunAtTime15k-blockchain_test_from_state_test-no_blob_tx [0] None 1 [, ] [, ]
...fork_ShanghaiToCancunAtTime15k-blockchain_test_from_state_test-one_blob_tx [1] None 1 TransactionException.TYPE_3_TX_PRE_FORK [, ]