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@622620d8.

Generate fixtures for these test cases for Cancun with:

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

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
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
@pytest.mark.inclusion_test
@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")
@pytest.mark.slow()
def test_blob_type_tx_pre_fork(
    state_test: StateTestFiller,
    pre: Alloc,
    txs: List[Transaction],
    block_error: Optional[TransactionException | BlockException],
) -> None:
    """
    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 generates 2 parametrized test cases across 1 fork.