mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-24 07:14:46 +00:00
* update rust_eth_kzg Co-authored-by: Eitan Seri-Levi <eserilev@ucsc.edu> * Update kzg module Co-authored-by: Eitan Seri-Levi <eserilev@ucsc.edu> * update benchmark code Co-authored-by: Eitan Seri-Levi <eserilev@ucsc.edu> * Add note on trusted setup configuration.
36 lines
1.4 KiB
Rust
36 lines
1.4 KiB
Rust
use c_kzg::KzgSettings;
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
use eth2_network_config::TRUSTED_SETUP_BYTES;
|
|
use kzg::TrustedSetup;
|
|
use rust_eth_kzg::{DASContext, TrustedSetup as PeerDASTrustedSetup};
|
|
|
|
pub fn bench_init_context(c: &mut Criterion) {
|
|
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
|
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
|
|
.expect("should have trusted setup");
|
|
|
|
c.bench_function(&format!("Initialize context rust_eth_kzg"), |b| {
|
|
b.iter(|| {
|
|
let trusted_setup = PeerDASTrustedSetup::from(&trusted_setup);
|
|
DASContext::new(
|
|
&trusted_setup,
|
|
rust_eth_kzg::UsePrecomp::Yes {
|
|
width: rust_eth_kzg::constants::RECOMMENDED_PRECOMP_WIDTH,
|
|
},
|
|
)
|
|
})
|
|
});
|
|
c.bench_function(&format!("Initialize context c-kzg (4844)"), |b| {
|
|
b.iter(|| {
|
|
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
|
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
|
|
.expect("should have trusted setup");
|
|
KzgSettings::load_trusted_setup(&trusted_setup.g1_points(), &trusted_setup.g2_points())
|
|
.unwrap()
|
|
})
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, bench_init_context);
|
|
criterion_main!(benches);
|