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

Fix build after SimpleSmt change in miden-crypto #1200

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std = ["miden-crypto/std", "math/std", "winter-utils/std"]
[dependencies]
math = { package = "winter-math", version = "0.7", default-features = false }
# miden-crypto = { package = "miden-crypto", version = "0.8", default-features = false }
miden-crypto = { package = "miden-crypto", git = "https://github.com/0xPolygonMiden/crypto", branch= "next", default-features = false }
miden-crypto = { package = "miden-crypto", git = "https://github.com/0xPolygonMiden/crypto", branch= "plafer-smt-trait", default-features = false }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder to revert this

winter-utils = { package = "winter-utils", version = "0.7", default-features = false }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
#[macro_use]

Check warning on line 4 in core/src/lib.rs

View workflow job for this annotation

GitHub Actions / no-std (stable, wasm32-unknown-unknown)

unused `#[macro_use]` import

Check warning on line 4 in core/src/lib.rs

View workflow job for this annotation

GitHub Actions / no-std (nightly, wasm32-unknown-unknown)

unused `#[macro_use]` import
extern crate alloc;

pub mod chiplets;
Expand All @@ -11,8 +11,8 @@
pub mod crypto {
pub mod merkle {
pub use miden_crypto::merkle::{
DefaultMerkleStore, EmptySubtreeRoots, InnerNodeInfo, MerkleError, MerklePath,
MerkleStore, MerkleTree, Mmr, MmrPeaks, NodeIndex, PartialMerkleTree,
DefaultMerkleStore, EmptySubtreeRoots, InnerNodeInfo, LeafIndex, MerkleError,
MerklePath, MerkleStore, MerkleTree, Mmr, MmrPeaks, NodeIndex, PartialMerkleTree,
RecordingMerkleStore, SimpleSmt, StoreNode, TieredSmt,
};
}
Expand Down
6 changes: 5 additions & 1 deletion miden/src/cli/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
path::{Path, PathBuf},
};
use stdlib::StdLibrary;
pub use tracing::{event, info_span, instrument, trace_span, Level};

Check warning on line 17 in miden/src/cli/data.rs

View workflow job for this annotation

GitHub Actions / Check Rust stable on ubuntu with --all-targets --all-features

unused imports: `info_span`, `trace_span`

Check warning on line 17 in miden/src/cli/data.rs

View workflow job for this annotation

GitHub Actions / Check Rust nightly on ubuntu with --all-targets --all-features

unused imports: `info_span`, `trace_span`

// CONSTANTS
// ================================================================================================
const SIMPLE_SMT_DEPTH: u8 = u64::BITS as u8;

// HELPERS
// ================================================================================================

Expand Down Expand Up @@ -206,7 +210,7 @@
}
MerkleData::SparseMerkleTree(data) => {
let entries = Self::parse_sparse_merkle_tree(data)?;
let tree = SimpleSmt::with_leaves(u64::BITS as u8, entries)
let tree = SimpleSmt::<SIMPLE_SMT_DEPTH>::with_leaves(entries)
.map_err(|e| format!("failed to parse a Sparse Merkle Tree: {e}"))?;
merkle_store.extend(tree.inner_nodes());
event!(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tests/collections/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use test_utils::{
crypto::{MerkleStore, SimpleSmt},
crypto::{LeafIndex, MerkleStore, SimpleSmt},
Felt, StarkField, TestError, Word, EMPTY_WORD, ONE, ZERO,
};

Expand Down
20 changes: 13 additions & 7 deletions stdlib/tests/collections/smt64.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use super::{Felt, MerkleStore, SimpleSmt, StarkField, TestError, Word, EMPTY_WORD, ONE, ZERO};
use super::{
Felt, LeafIndex, MerkleStore, SimpleSmt, StarkField, TestError, Word, EMPTY_WORD, ONE, ZERO,
};
use crate::build_test;

// TEST DATA
// ================================================================================================

const DEPTH: u8 = 64;

const LEAVES: [(u64, Word); 5] = [
(
0b00000000_00000000_11111111_11111111_11111111_11111111_11111111_11111111_u64,
Expand Down Expand Up @@ -36,7 +40,7 @@ const LEAVES: [(u64, Word); 5] = [

#[test]
fn get() {
let smt = SimpleSmt::with_leaves(64, LEAVES).unwrap();
let smt = SimpleSmt::<DEPTH>::with_leaves(LEAVES).unwrap();

let source = "
use.std::collections::smt64
Expand All @@ -58,7 +62,7 @@ fn get() {

#[test]
fn insert() {
let mut smt = SimpleSmt::new(64).unwrap();
let mut smt = SimpleSmt::<DEPTH>::new().unwrap();

let source = "
use.std::collections::smt64
Expand Down Expand Up @@ -88,7 +92,7 @@ fn insert() {

#[test]
fn set() {
let mut smt = SimpleSmt::new(64).unwrap();
let mut smt = SimpleSmt::<DEPTH>::new().unwrap();
let empty_tree_root = smt.root();

let source = "
Expand Down Expand Up @@ -133,17 +137,19 @@ fn set() {
fn prepare_insert_or_set(
index: u64,
value: Word,
smt: &mut SimpleSmt,
smt: &mut SimpleSmt<DEPTH>,
) -> (Vec<u64>, Vec<u64>, MerkleStore) {
let index = LeafIndex::new_max_depth(index);

// set initial state of the stack to be [VALUE, key, ROOT, ...]
let mut initial_stack = Vec::new();
append_word_to_vec(&mut initial_stack, smt.root().into());
initial_stack.push(index);
initial_stack.push(index.value());
append_word_to_vec(&mut initial_stack, value);

// build a Merkle store for the test before the tree is updated, and then update the tree
let store: MerkleStore = (&*smt).into();
let old_value = smt.update_leaf(index, value).unwrap();
let old_value = smt.insert(index, value);

// after insert or set, the stack should be [OLD_VALUE, ROOT, ...]
let expected_output = build_expected_stack(old_value, smt.root().into());
Expand Down
4 changes: 2 additions & 2 deletions test-utils/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub use vm_core::crypto::{
dsa::*,
hash::{Rpo256, RpoDigest},
merkle::{
EmptySubtreeRoots, MerkleError, MerklePath, MerkleStore, MerkleTree, Mmr, MmrPeaks,
NodeIndex, PartialMerkleTree, SimpleSmt, TieredSmt,
EmptySubtreeRoots, LeafIndex, MerkleError, MerklePath, MerkleStore, MerkleTree, Mmr,
MmrPeaks, NodeIndex, PartialMerkleTree, SimpleSmt, TieredSmt,
},
};

Expand Down
Loading