Skip to content

Commit 04d9eef

Browse files
authored
chore: update peerdas-kzg library (#6118)
* chore: update peerDAS lib * chore: update library * chore: update library to version that include "init context" benchmarks and optional validation checks * chore: (can remove) -- Add benchmarks for init context
1 parent 55a3be7 commit 04d9eef

File tree

5 files changed

+47
-10
lines changed

5 files changed

+47
-10
lines changed

Cargo.lock

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ delay_map = "0.3"
9999
derivative = "2"
100100
dirs = "3"
101101
either = "1.9"
102-
peerdas-kzg = { git = "https://github.com/crate-crypto/peerdas-kzg", rev = "bb8295011cf27dc663699539c7f9a17fe273e896", package = "eip7594" }
102+
peerdas-kzg = { git = "https://github.com/crate-crypto/peerdas-kzg", rev = "55ae9e9011d792a2998d242c2a71d822ba909fa9", package = "eip7594" }
103103
discv5 = { version = "0.4.1", features = ["libp2p"] }
104104
env_logger = "0.9"
105105
error-chain = "0.12"

crypto/kzg/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ ethereum_hashing = { workspace = true }
1919
c-kzg = { workspace = true }
2020
peerdas-kzg = { workspace = true }
2121
mockall = { workspace = true }
22+
23+
[dev-dependencies]
24+
criterion = { workspace = true }
25+
serde_json = { workspace = true }
26+
eth2_network_config = { workspace = true }
27+
28+
[[bench]]
29+
name = "benchmark"
30+
harness = false

crypto/kzg/benches/benchmark.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use c_kzg::KzgSettings;
2+
use criterion::{criterion_group, criterion_main, Criterion};
3+
use eth2_network_config::TRUSTED_SETUP_BYTES;
4+
use kzg::TrustedSetup;
5+
use peerdas_kzg::{PeerDASContext, TrustedSetup as PeerDASTrustedSetup};
6+
7+
pub fn bench_init_context(c: &mut Criterion) {
8+
c.bench_function(&format!("Initialize context peerdas-kzg"), |b| {
9+
b.iter(|| {
10+
const NUM_THREADS: usize = 1;
11+
let trusted_setup = PeerDASTrustedSetup::default();
12+
PeerDASContext::with_threads(&trusted_setup, NUM_THREADS)
13+
})
14+
});
15+
c.bench_function(&format!("Initialize context c-kzg (4844)"), |b| {
16+
b.iter(|| {
17+
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
18+
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
19+
.expect("should have trusted setup");
20+
KzgSettings::load_trusted_setup(&trusted_setup.g1_points(), &trusted_setup.g2_points())
21+
.unwrap()
22+
})
23+
});
24+
}
25+
26+
criterion_group!(benches, bench_init_context);
27+
criterion_main!(benches);

crypto/kzg/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use mockall::automock;
1717

1818
pub use peerdas_kzg::{
1919
constants::{BYTES_PER_CELL, CELLS_PER_EXT_BLOB},
20-
Cell, CellID, CellRef, TrustedSetup as PeerDASTrustedSetup,
20+
Cell, CellIndex as CellID, CellRef, TrustedSetup as PeerDASTrustedSetup,
2121
};
2222
use peerdas_kzg::{prover::ProverError, verifier::VerifierError, PeerDASContext};
2323
pub type CellsAndKzgProofs = ([Cell; CELLS_PER_EXT_BLOB], [KzgProof; CELLS_PER_EXT_BLOB]);
@@ -181,7 +181,6 @@ impl Kzg {
181181

182182
let (cells, proofs) = self
183183
.context
184-
.prover_ctx()
185184
.compute_cells_and_kzg_proofs(blob_bytes)
186185
.map_err(Error::ProverKZG)?;
187186

@@ -212,7 +211,7 @@ impl Kzg {
212211
.iter()
213212
.map(|commitment| commitment.as_ref())
214213
.collect();
215-
let verification_result = self.context.verifier_ctx().verify_cell_kzg_proof_batch(
214+
let verification_result = self.context.verify_cell_kzg_proof_batch(
216215
commitments.to_vec(),
217216
rows,
218217
columns,
@@ -236,7 +235,6 @@ impl Kzg {
236235
) -> Result<CellsAndKzgProofs, Error> {
237236
let (cells, proofs) = self
238237
.context
239-
.prover_ctx()
240238
.recover_cells_and_proofs(cell_ids.to_vec(), cells.to_vec())
241239
.map_err(Error::ProverKZG)?;
242240

0 commit comments

Comments
 (0)