mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 22:34:45 +00:00
Update `c-kzg` from `v1` to `v2`. My motivation here is that `alloy-consensus` now uses `c-kzg` in `v2` and this results in a conflict when using lighthouse in combination with latest alloy. I tried also to disable the `czkg` feature in alloy, but the conflict persisted. See here for the alloy update to `c-kzg v2`: https://github.com/alloy-rs/alloy/pull/2240 Error: ``` error: failed to select a version for `c-kzg`. ... versions that meet the requirements `^1` are: 1.0.3, 1.0.2, 1.0.0 the package `c-kzg` links to the native library `ckzg`, but it conflicts with a previous package which links to `ckzg` as well: package `c-kzg v2.1.0` ... which satisfies dependency `c-kzg = "^2.1"` of package `alloy-consensus v0.13.0` ... which satisfies dependency `alloy-consensus = "^0.13.0"` of package ... ... ``` - Upgrade `alloy-consensus` to `0.14.0` and disable all default features - Upgrade `c-kzg` to `v2.1.0` - Upgrade `alloy-primitives` to `1.0.0` - Adapt the code to the new API `c-kzg` - There is now `NO_PRECOMPUTE` as my understand from https://github.com/ethereum/c-kzg-4844/pull/545/files we should use `0` here as `new_from_trusted_setup_no_precomp` does not precomp. But maybe it is misleading. For all other places I used `RECOMMENDED_PRECOMP_WIDTH` because `8` is matching the recommendation. - `BYTES_PER_G1_POINT` and `BYTES_PER_G2_POINT` are no longer public in `c-kzg` - I adapted two tests that checking for the `Attestation` bitfield size. But I could not pinpoint to what has changed and why now 8 bytes less. I would be happy about any hint, and if this is correct. I found related a PR here: https://github.com/sigp/lighthouse/pull/6915 - Use same fields names, in json, as well as `c-kzg` and `rust_eth_kzg` for `g1_monomial`, `g1_lagrange`, and `g2_monomial`
41 lines
1.5 KiB
Rust
41 lines
1.5 KiB
Rust
use c_kzg::KzgSettings;
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
use kzg::{trusted_setup::get_trusted_setup, TrustedSetup, NO_PRECOMPUTE};
|
|
use rust_eth_kzg::{DASContext, TrustedSetup as PeerDASTrustedSetup};
|
|
|
|
pub fn bench_init_context(c: &mut Criterion) {
|
|
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
|
|
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
|
|
.expect("should have trusted setup");
|
|
|
|
c.bench_function("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("Initialize context c-kzg (4844)", |b| {
|
|
b.iter(|| {
|
|
let trusted_setup: TrustedSetup =
|
|
serde_json::from_reader(get_trusted_setup().as_slice())
|
|
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
|
|
.expect("should have trusted setup");
|
|
KzgSettings::load_trusted_setup(
|
|
&trusted_setup.g1_monomial(),
|
|
&trusted_setup.g1_lagrange(),
|
|
&trusted_setup.g2_monomial(),
|
|
NO_PRECOMPUTE,
|
|
)
|
|
.unwrap()
|
|
})
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, bench_init_context);
|
|
criterion_main!(benches);
|