Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce data access recording capabilities #162

Merged
merged 2 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/store.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
use miden_crypto::merkle::{MerkleStore, MerkleTree, NodeIndex, SimpleSmt};
use miden_crypto::merkle::{DefaultMerkleStore as MerkleStore, MerkleTree, NodeIndex, SimpleSmt};
use miden_crypto::Word;
use miden_crypto::{hash::rpo::RpoDigest, Felt};
use rand_utils::{rand_array, rand_value};
Expand Down
1 change: 1 addition & 0 deletions src/merkle/mmr/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::error::Error;
///
/// Since this is a full representation of the MMR, elements are never removed and the MMR will
/// grow roughly `O(2n)` in number of leaf elements.
#[derive(Debug, Clone)]
pub struct Mmr {
/// Refer to the `forest` method documentation for details of the semantics of this value.
pub(super) forest: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/merkle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
hash::rpo::{Rpo256, RpoDigest},
utils::collections::{vec, BTreeMap, BTreeSet, Vec},
utils::collections::{vec, BTreeMap, BTreeSet, KvMap, RecordingMap, Vec},
Felt, StarkField, Word, WORD_SIZE, ZERO,
};
use core::fmt;
Expand Down Expand Up @@ -33,7 +33,7 @@ mod mmr;
pub use mmr::{Mmr, MmrPeaks, MmrProof};

mod store;
pub use store::MerkleStore;
pub use store::{DefaultMerkleStore, MerkleStore, RecordingMerkleStore};

mod node;
pub use node::InnerNodeInfo;
Expand Down
3 changes: 2 additions & 1 deletion src/merkle/partial_mt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ impl PartialMerkleTree {
self.leaves.iter().map(|&leaf| {
(
leaf,
self.get_node(leaf).expect(&format!("Leaf with {leaf} is not in the nodes map")),
self.get_node(leaf)
.unwrap_or_else(|_| panic!("Leaf with {leaf} is not in the nodes map")),
)
})
}
Expand Down
5 changes: 4 additions & 1 deletion src/merkle/partial_mt/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::{
super::{digests_to_words, int_to_node, MerkleStore, MerkleTree, NodeIndex, PartialMerkleTree},
super::{
digests_to_words, int_to_node, DefaultMerkleStore as MerkleStore, MerkleTree, NodeIndex,
PartialMerkleTree,
},
RpoDigest, ValuePath, Vec,
};

Expand Down
6 changes: 6 additions & 0 deletions src/merkle/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl MerklePath {
}
}

impl From<MerklePath> for Vec<RpoDigest> {
fn from(path: MerklePath) -> Self {
path.nodes
}
}

impl From<Vec<RpoDigest>> for MerklePath {
fn from(path: Vec<RpoDigest>) -> Self {
Self::new(path)
Expand Down
Loading