Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Apr 10, 2024
1 parent f00c51b commit 2a68fc5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
36 changes: 19 additions & 17 deletions benches/cascading_merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
#[allow(clippy::wildcard_imports)]
use semaphore::cascading_merkle_tree::*;
use semaphore::generic_storage::MmapVec;
use semaphore::merkle_tree::Hasher;
use semaphore::poseidon_tree::PoseidonHash;
use semaphore::Field;
use semaphore::{
generic_storage::MmapVec, merkle_tree::Hasher, poseidon_tree::PoseidonHash, Field,
};

criterion_main!(cascading_merkle_tree);
criterion_group!(
Expand Down Expand Up @@ -126,12 +125,13 @@ fn bench_cascading_create_dense_mmap_tree(criterion: &mut Criterion) {
bencher.iter(|| {
let storage: MmapVec<<PoseidonHash as Hasher>::Hash> =
unsafe { MmapVec::open_create("./testfile").unwrap() };
let _tree: CascadingMerkleTree<PoseidonHash, _> = CascadingMerkleTree::from_storage_with_leaves(
storage,
value.depth,
&value.empty_value,
&value.initial_values,
);
let _tree: CascadingMerkleTree<PoseidonHash, _> =
CascadingMerkleTree::from_storage_with_leaves(
storage,
value.depth,
&value.empty_value,
&value.initial_values,
);
let _root = _tree.root();
});
},
Expand All @@ -153,12 +153,13 @@ fn bench_cascading_restore_dense_mmap_tree(criterion: &mut Criterion) {
// file should be saved
(0..3).zip(&tree_values).for_each(|(id, value)| {
let storage: MmapVec<_> = unsafe { MmapVec::open_create("./testfile").unwrap() };
let _tree: CascadingMerkleTree<PoseidonHash, _> = CascadingMerkleTree::from_storage_with_leaves(
storage,
value.depth,
&value.empty_value,
&value.initial_values,
);
let _tree: CascadingMerkleTree<PoseidonHash, _> =
CascadingMerkleTree::from_storage_with_leaves(
storage,
value.depth,
&value.empty_value,
&value.initial_values,
);
let _root = _tree.root();
});

Expand All @@ -173,7 +174,8 @@ fn bench_cascading_restore_dense_mmap_tree(criterion: &mut Criterion) {
let storage =
unsafe { MmapVec::open_create(format!("./testfile{}", id)).unwrap() };
let _tree: CascadingMerkleTree<PoseidonHash, _> =
CascadingMerkleTree::from_storage(storage, value.depth, &value.empty_value).unwrap();
CascadingMerkleTree::from_storage(storage, value.depth, &value.empty_value)
.unwrap();
let _root = _tree.root();
});
},
Expand Down
4 changes: 3 additions & 1 deletion examples/abort_test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ fn main() -> Result<()> {
if args.len() == 1 {
println!("initializing\n");
let leaves = vec![1; 1_000_000];
let _ = CascadingMerkleTree::<TestHasher, _>::from_storage_with_leaves(mmap_vec, 30, &1, &leaves);
let _ = CascadingMerkleTree::<TestHasher, _>::from_storage_with_leaves(
mmap_vec, 30, &1, &leaves,
);
for i in 0..100 {
println!("running interation {}", i);
let output = std::process::Command::new("target/debug/examples/abort_test")
Expand Down
6 changes: 4 additions & 2 deletions src/cascading_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use color_eyre::eyre::{bail, ensure, Result};
use itertools::Itertools;
use rayon::prelude::*;

use crate::generic_storage::GenericStorage;
use crate::merkle_tree::{Branch, Hasher, Proof};
use crate::{
generic_storage::GenericStorage,
merkle_tree::{Branch, Hasher, Proof},
};

mod storage_ops;

Expand Down
8 changes: 5 additions & 3 deletions src/generic_storage/mmap_vec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::fs::{File, OpenOptions};
use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::{
fs::{File, OpenOptions},
ops::{Deref, DerefMut},
path::Path,
};

use bytemuck::Pod;
use color_eyre::eyre::bail;
Expand Down

0 comments on commit 2a68fc5

Please sign in to comment.