Skip to content

test_worst_blobhash()

Documentation for tests/benchmark/test_worst_compute.py::test_worst_blobhash@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_compute.py::test_worst_blobhash -m benchmark

Test running a block with as many BLOBHASH instructions as possible.

Source code in tests/benchmark/test_worst_compute.py
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
@pytest.mark.parametrize(
    "blob_index, blobs_present",
    [
        pytest.param(0, 0, id="no blobs"),
        pytest.param(0, 1, id="one blob and accessed"),
        pytest.param(1, 1, id="one blob but access non-existent index"),
        pytest.param(5, 6, id="six blobs, access latest"),
    ],
)
def test_worst_blobhash(
    fork: Fork,
    benchmark_test: BenchmarkTestFiller,
    blob_index: int,
    blobs_present: bool,
) -> None:
    """Test running a block with as many BLOBHASH instructions as possible."""
    tx_kwargs: Dict[str, Any] = {}
    if blobs_present > 0:
        tx_kwargs["ty"] = TransactionType.BLOB_TRANSACTION
        tx_kwargs["max_fee_per_blob_gas"] = fork.min_base_fee_per_blob_gas()
        tx_kwargs["blob_versioned_hashes"] = add_kzg_version(
            [i.to_bytes() * 32 for i in range(blobs_present)],
            BlobsSpec.BLOB_COMMITMENT_VERSION_KZG,
        )

    benchmark_test(
        code_generator=ExtCallGenerator(
            attack_block=Op.BLOBHASH(blob_index),
            tx_kwargs=tx_kwargs,
        ),
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) blob_index blobs_present
...fork_Prague-blockchain_test-no blobs 0 0
...fork_Prague-blockchain_test-one blob and accessed 0 1
...fork_Prague-blockchain_test-one blob but access non-existent index 1 1
...fork_Prague-blockchain_test-six blobs, access latest 5 6
...fork_Osaka-blockchain_test-no blobs 0 0
...fork_Osaka-blockchain_test-one blob and accessed 0 1
...fork_Osaka-blockchain_test-one blob but access non-existent index 1 1
...fork_Osaka-blockchain_test-six blobs, access latest 5 6