fix: Change Arc<KzgSettings> to EnvKzgSettings (#9054)

This commit is contained in:
Omid Chenane
2024-06-24 18:26:53 +03:30
committed by GitHub
parent 81b5fbf573
commit c5aee02ff7
9 changed files with 49 additions and 74 deletions

View File

@ -1,7 +1,7 @@
#![allow(missing_docs)]
use alloy_eips::eip4844::env_settings::EnvKzgSettings;
use alloy_primitives::hex;
use c_kzg::KzgSettings;
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
@ -11,11 +11,8 @@ use proptest::{
test_runner::{RngAlgorithm, TestRng, TestRunner},
};
use proptest_arbitrary_interop::arb;
use reth_primitives::{
constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, BlobTransactionSidecar, TxEip4844,
};
use reth_primitives::{BlobTransactionSidecar, TxEip4844};
use revm_primitives::MAX_BLOB_NUMBER_PER_BLOCK;
use std::sync::Arc;
// constant seed to use for the rng
const SEED: [u8; 32] = hex!("1337133713371337133713371337133713371337133713371337133713371337");
@ -23,11 +20,10 @@ const SEED: [u8; 32] = hex!("133713371337133713371337133713371337133713371337133
/// Benchmarks EIP-48444 blob validation.
fn blob_validation(c: &mut Criterion) {
let mut group = c.benchmark_group("Blob Transaction KZG validation");
let kzg_settings = MAINNET_KZG_TRUSTED_SETUP.clone();
for num_blobs in 1..=MAX_BLOB_NUMBER_PER_BLOCK {
println!("Benchmarking validation for tx with {num_blobs} blobs");
validate_blob_tx(&mut group, "ValidateBlob", num_blobs, kzg_settings.clone());
validate_blob_tx(&mut group, "ValidateBlob", num_blobs, EnvKzgSettings::Default);
}
}
@ -35,7 +31,7 @@ fn validate_blob_tx(
group: &mut BenchmarkGroup<'_, WallTime>,
description: &str,
num_blobs: u64,
kzg_settings: Arc<KzgSettings>,
kzg_settings: EnvKzgSettings,
) {
let setup = || {
let config = ProptestConfig::default();
@ -73,7 +69,9 @@ fn validate_blob_tx(
// for now we just use the default SubPoolLimit
group.bench_function(group_id, |b| {
b.iter_with_setup(setup, |(tx, blob_sidecar)| {
if let Err(err) = std::hint::black_box(tx.validate_blob(&blob_sidecar, &kzg_settings)) {
if let Err(err) =
std::hint::black_box(tx.validate_blob(&blob_sidecar, kzg_settings.get()))
{
println!("Validation failed: {err:?}");
}
});