Skip to content

Commit

Permalink
Merge of #6309
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 28, 2024
2 parents 0c0f1e5 + fbac1e5 commit 70b62eb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
31 changes: 18 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ delay_map = "0.3"
derivative = "2"
dirs = "3"
either = "1.9"
rust_eth_kzg = "0.3.4"
rust_eth_kzg = "0.5.1"
discv5 = { version = "0.4.1", features = ["libp2p"] }
env_logger = "0.9"
error-chain = "0.12"
Expand Down
8 changes: 6 additions & 2 deletions crypto/kzg/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ pub fn bench_init_context(c: &mut Criterion) {

c.bench_function(&format!("Initialize context rust_eth_kzg"), |b| {
b.iter(|| {
const NUM_THREADS: usize = 1;
let trusted_setup = PeerDASTrustedSetup::from(&trusted_setup);
DASContext::with_threads(&trusted_setup, NUM_THREADS)
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| {
Expand Down
16 changes: 10 additions & 6 deletions crypto/kzg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ impl Kzg {
// Note: One can also use `from_json` to initialize it from the consensus-specs
// json string.
let peerdas_trusted_setup = PeerDASTrustedSetup::from(&trusted_setup);
// Set the number of threads to be used
//
// we set it to 1 to match the c-kzg performance
const NUM_THREADS: usize = 1;

let context = DASContext::with_threads(&peerdas_trusted_setup, NUM_THREADS);
// It's not recommended to change the config parameter for precomputation as storage
// grows exponentially, but the speedup is exponential - after a while the speedup
// starts to become sublinear.
let context = DASContext::new(
&peerdas_trusted_setup,
rust_eth_kzg::UsePrecomp::Yes {
width: rust_eth_kzg::constants::RECOMMENDED_PRECOMP_WIDTH,
},
);

Ok(Self {
trusted_setup: KzgSettings::load_trusted_setup(
Expand Down Expand Up @@ -244,7 +248,7 @@ impl Kzg {
) -> Result<CellsAndKzgProofs, Error> {
let (cells, proofs) = self
.context()?
.recover_cells_and_proofs(cell_ids.to_vec(), cells.to_vec())
.recover_cells_and_kzg_proofs(cell_ids.to_vec(), cells.to_vec())
.map_err(Error::PeerDASKZG)?;

// Convert the proof type to a c-kzg proof type
Expand Down

0 comments on commit 70b62eb

Please sign in to comment.