test_blobhash()
Documentation for tests/benchmark/compute/instruction/test_tx_context.py::test_blobhash@8db70f93.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/benchmark/compute/instruction/test_tx_context.py::test_blobhash --gas-benchmark-values 1
Benchmark BLOBHASH instruction.
Source code in tests/benchmark/compute/instruction/test_tx_context.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 | @pytest.mark.repricing
@pytest.mark.execute(
pytest.mark.skip(reason="type 3 tx not supported in execute")
)
@pytest.mark.parametrize(
"blob_present",
[
pytest.param(0, id="no_blobs"),
pytest.param(1, id="one_blob"),
],
)
def test_blobhash(
fork: Fork,
benchmark_test: BenchmarkTestFiller,
blob_present: int,
fixed_opcode_count: int | None,
gas_benchmark_value: int,
) -> None:
"""Benchmark BLOBHASH instruction."""
tx_kwargs: dict = {}
if blob_present:
cap = fork.transaction_gas_limit_cap()
if fixed_opcode_count is None and cap is not None:
# Check if blob tx splits would exceed block blob limit
required_splits = math.ceil(gas_benchmark_value / cap)
max_blobs = fork.max_blobs_per_block()
if required_splits > max_blobs:
pytest.skip(
f"Blob tx needs {required_splits} splits but fork allows "
f"{max_blobs} blobs/block"
)
tx_kwargs = {
"ty": TransactionType.BLOB_TRANSACTION,
"max_fee_per_blob_gas": fork.min_base_fee_per_blob_gas(),
"blob_versioned_hashes": add_kzg_version(
[i.to_bytes(32, "big") for i in range(blob_present)],
BlobsSpec.BLOB_COMMITMENT_VERSION_KZG,
),
}
benchmark_test(
target_opcode=Op.BLOBHASH,
code_generator=ExtCallGenerator(
attack_block=Op.BLOBHASH(Op.PUSH0),
tx_kwargs=tx_kwargs,
),
)
|
Parametrized Test Cases
This test generates 2 parametrized test cases across 3 forks.