Skip to content
Open
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
531 changes: 357 additions & 174 deletions Cargo.lock

Large diffs are not rendered by default.

55 changes: 35 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/block-producer",
"crates/db",
"crates/grpc-error-macro",
"crates/large-smt-backend-rocksdb",
"crates/ntx-builder",
"crates/proto",
"crates/remote-prover-client",
Expand Down Expand Up @@ -45,33 +46,43 @@ debug = true

[workspace.dependencies]
# Workspace crates.
miden-node-block-producer = { path = "crates/block-producer", version = "0.14" }
miden-node-db = { path = "crates/db", version = "0.14" }
miden-node-grpc-error-macro = { path = "crates/grpc-error-macro", version = "0.14" }
miden-node-ntx-builder = { path = "crates/ntx-builder", version = "0.14" }
miden-node-proto = { path = "crates/proto", version = "0.14" }
miden-node-proto-build = { path = "proto", version = "0.14" }
miden-node-rpc = { path = "crates/rpc", version = "0.14" }
miden-node-store = { path = "crates/store", version = "0.14" }
miden-node-test-macro = { path = "crates/test-macro" }
miden-node-utils = { path = "crates/utils", version = "0.14" }
miden-node-validator = { path = "crates/validator", version = "0.14" }
miden-remote-prover-client = { path = "crates/remote-prover-client", version = "0.14" }
miden-large-smt-backend-rocksdb = { path = "crates/large-smt-backend-rocksdb", version = "0.14" }
miden-node-block-producer = { path = "crates/block-producer", version = "0.14" }
miden-node-db = { path = "crates/db", version = "0.14" }
miden-node-grpc-error-macro = { path = "crates/grpc-error-macro", version = "0.14" }
miden-node-ntx-builder = { path = "crates/ntx-builder", version = "0.14" }
miden-node-proto = { path = "crates/proto", version = "0.14" }
miden-node-proto-build = { path = "proto", version = "0.14" }
miden-node-rpc = { path = "crates/rpc", version = "0.14" }
miden-node-store = { path = "crates/store", version = "0.14" }
miden-node-test-macro = { path = "crates/test-macro" }
miden-node-utils = { path = "crates/utils", version = "0.14" }
miden-node-validator = { path = "crates/validator", version = "0.14" }
miden-remote-prover-client = { path = "crates/remote-prover-client", version = "0.14" }

# Temporary workaround until <https://github.com/rust-rocksdb/rust-rocksdb/pull/1029>
# is part of `rocksdb-rust` release
miden-node-rocksdb-cxx-linkage-fix = { path = "crates/rocksdb-cxx-linkage-fix", version = "0.14" }

# miden-base aka protocol dependencies. These should be updated in sync.
miden-block-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
miden-protocol = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
miden-standards = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
miden-testing = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
miden-tx = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
miden-tx-batch-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
# miden-block-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
# miden-protocol = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
# miden-standards = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
# miden-testing = { branch = "next", git = "https://github.com/0xMiden/miden-base" }
# miden-tx = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
# miden-tx-batch-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base" }

# Other miden dependencies. These should align with those expected by miden-base.
miden-air = { features = ["std", "testing"], version = "0.20" }
miden-crypto = { default-features = false, version = "0.19" }
miden-air = { features = ["std", "testing"], version = "0.20" }
# miden-crypto = { default-features = false, version = "0.19.4" }
miden-block-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base.git" }
miden-protocol = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base.git" }
miden-standards = { branch = "next", git = "https://github.com/0xMiden/miden-base.git" }
miden-testing = { branch = "next", git = "https://github.com/0xMiden/miden-base.git" }
miden-tx = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base.git" }
miden-tx-batch-prover = { branch = "next", git = "https://github.com/0xMiden/miden-base.git" }

miden-crypto = { version = "0.19.6" }

# External dependencies
anyhow = { version = "1.0" }
Expand Down Expand Up @@ -141,3 +152,7 @@ should_panic_without_expect = "allow" # We don't care about the specific panic
# Configure `cargo-typos`
[workspace.metadata.typos]
files.extend-exclude = ["*.svg"] # Ignore SVG files.

[patch.crates-io]
#miden-crypto = { path = "../miden-crypto-bernhard-migrate-rocksdb-from-crypto/miden-crypto/" }
miden-crypto = { branch = "bernhard-migrate-rocksdb-from-crypto", git = "https://github.com/0xMiden/crypto.git" }
2 changes: 1 addition & 1 deletion bin/network-monitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ miden-testing = { workspace = true }
miden-tx = { features = ["std"], workspace = true }
rand = { version = "0.9" }
rand_chacha = { version = "0.9" }
reqwest = { features = ["json"], version = "0.12" }
reqwest = { features = ["json"], version = "0.13" }
serde = { features = ["derive"], version = "1.0" }
serde_json = { version = "1.0" }
sha2 = { version = "0.10" }
Expand Down
42 changes: 20 additions & 22 deletions bin/network-monitor/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ async fn perform_faucet_test(
debug!("Generated account ID: {} (length: {})", account_id, account_id.len());

// Step 1: Request PoW challenge
let pow_url = faucet_url.join("/pow")?;
let response = client
.get(pow_url)
.query(&[("account_id", &account_id), ("amount", &MINT_AMOUNT.to_string())])
.send()
.await?;
let mut pow_url = faucet_url.join("/pow")?;
pow_url
.query_pairs_mut()
.append_pair("account_id", &account_id)
.append_pair("amount", &MINT_AMOUNT.to_string());

let response_text = response.text().await?;
let response = client.get(pow_url).send().await?;

let response_text: String = response.text().await?;
debug!("Faucet PoW response: {}", response_text);

let challenge_response: PowChallengeResponse = serde_json::from_str(&response_text)
Expand All @@ -215,21 +216,18 @@ async fn perform_faucet_test(
debug!("Solved PoW challenge with nonce: {}", nonce);

// Step 3: Request tokens with the solution
let tokens_url = faucet_url.join("/get_tokens")?;

let response = client
.get(tokens_url)
.query(&[
("account_id", account_id.as_str()),
("is_private_note", "false"),
("asset_amount", &MINT_AMOUNT.to_string()),
("challenge", &challenge_response.challenge),
("nonce", &nonce.to_string()),
])
.send()
.await?;

let response_text = response.text().await?;
let mut tokens_url = faucet_url.join("/get_tokens")?;
tokens_url
.query_pairs_mut()
.append_pair("account_id", account_id.as_str())
.append_pair("is_private_note", "false")
.append_pair("asset_amount", &MINT_AMOUNT.to_string())
.append_pair("challenge", &challenge_response.challenge)
.append_pair("nonce", &nonce.to_string());

let response = client.get(tokens_url).send().await?;

let response_text: String = response.text().await?;

let tokens_response: GetTokensResponse = serde_json::from_str(&response_text)
.with_context(|| format!("Failed to parse tokens response: {response_text}"))?;
Expand Down
4 changes: 2 additions & 2 deletions bin/remote-prover/src/server/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ impl Prover {
}
}

/// Proves a [`ProofRequest`] using the appropriate prover implementation as specified during
/// construction.
/// Proves a [`proto::ProofRequest`] using the appropriate prover implementation as specified
/// during construction.
pub fn prove(&self, request: proto::ProofRequest) -> Result<proto::Proof, tonic::Status> {
match self {
Prover::Transaction(prover) => prover.prove_request(request),
Expand Down
5 changes: 2 additions & 3 deletions crates/block-producer/src/server/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use miden_node_store::{GenesisState, Store};
use miden_node_utils::fee::test_fee_params;
use miden_node_validator::Validator;
use miden_protocol::crypto::dsa::ecdsa_k256_keccak::SecretKey;
use miden_protocol::testing::random_signer::RandomBlockSigner as _;
use tokio::net::TcpListener;
use tokio::time::sleep;
use tokio::{runtime, task};
Expand Down Expand Up @@ -49,7 +48,7 @@ async fn block_producer_startup_is_robust_to_network_failures() {
Validator {
address: validator_addr,
grpc_timeout,
signer: SecretKey::random(),
signer: SecretKey::new(),
data_directory,
}
.serve()
Expand Down Expand Up @@ -130,7 +129,7 @@ async fn start_store(
store_addr: std::net::SocketAddr,
data_directory: &std::path::Path,
) -> runtime::Runtime {
let genesis_state = GenesisState::new(vec![], test_fee_params(), 1, 1, SecretKey::random());
let genesis_state = GenesisState::new(vec![], test_fee_params(), 1, 1, SecretKey::new());
Store::bootstrap(genesis_state.clone(), data_directory).expect("store should bootstrap");

let dir = data_directory.to_path_buf();
Expand Down
22 changes: 22 additions & 0 deletions crates/large-smt-backend-rocksdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
authors.workspace = true
description = "Large-scale Sparse Merkle Tree backed by pluggable storage - RocksDB backend"
edition.workspace = true
homepage.workspace = true
keywords = ["merkle", "miden", "node", "smt"]
license.workspace = true
name = "miden-large-smt-backend-rocksdb"
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
miden-crypto = { features = ["concurrent", "std"], workspace = true }
miden-protocol = { features = ["std"], workspace = true }
rayon = { version = "1.10" }
rocksdb = { default-features = false, features = ["bindgen-runtime", "lz4"], version = "0.24" }
winter-utils = { version = "0.13" }
45 changes: 45 additions & 0 deletions crates/large-smt-backend-rocksdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# miden-large-smt-backend-rocksdb

Large-scale Sparse Merkle Tree backed by pluggable storage - RocksDB backend implementation.

This crate provides `LargeSmt`, a hybrid SMT implementation that stores the top of the tree
(depths 0–23) in memory and persists the lower depths (24–64) in storage as fixed-size subtrees.
This hybrid layout scales beyond RAM while keeping common operations fast.

## Migration Status

This crate is the future home for `LargeSmt` and its storage backends. Currently it re-exports
types from `miden-protocol` (which re-exports from `miden-crypto`).

The migration will be completed in phases:
1. ✅ Create this crate as a re-export layer (current state)
2. Copy the full implementation from miden-crypto to this crate
3. Update miden-crypto to remove the rocksdb feature
4. Update dependents to use this crate directly

## Features

- **concurrent**: Enables parallel processing with rayon (enabled by default)
- **rocksdb**: (Future) Enables RocksDB storage backend

## Usage

```rust
use miden_large_smt::{LargeSmt, MemoryStorage};

// Create an empty tree with in-memory storage
let storage = MemoryStorage::new();
let smt = LargeSmt::new(storage).unwrap();
```

## Re-exported Types

This crate re-exports the following types from `miden-protocol`:

- `LargeSmt` - The large-scale SMT implementation
- `LargeSmtError` - Error type for LargeSmt operations
- `MemoryStorage` - In-memory storage backend
- `SmtStorage` - Storage backend trait
- `Subtree` - Serializable subtree representation
- `StorageUpdates` / `StorageUpdateParts` - Batch update types
- Various SMT types: `Smt`, `SmtLeaf`, `SmtProof`, `LeafIndex`, etc.
57 changes: 57 additions & 0 deletions crates/large-smt-backend-rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Large-scale Sparse Merkle Tree backed by pluggable storage.
//!
//! `LargeSmt` stores the top of the tree (depths 0–23) in memory and persists the lower
//! depths (24–64) in storage as fixed-size subtrees. This hybrid layout scales beyond RAM
//! while keeping common operations fast.
//!
//! # Usage
//!
//! ```ignore
//! use miden_large_smt::{LargeSmt, MemoryStorage};
//!
//! // Create an empty tree with in-memory storage
//! let storage = MemoryStorage::new();
//! let smt = LargeSmt::new(storage).unwrap();
//! ```
//!
//! ```ignore
//! use miden_large_smt_backend_rocksdb::{LargeSmt, RocksDbConfig, RocksDbStorage};
//!
//! let storage = RocksDbStorage::open(RocksDbConfig::new("/path/to/db")).unwrap();
//! let smt = LargeSmt::new(storage).unwrap();
//! ```

extern crate alloc;

mod rocksdb;
// Re-export from miden-protocol.
pub use miden_protocol::crypto::merkle::smt::{
InnerNode,
LargeSmt,
LargeSmtError,
LeafIndex,
MemoryStorage,
SMT_DEPTH,
Smt,
SmtLeaf,
SmtLeafError,
SmtProof,
SmtStorage,
StorageError,
StorageUpdateParts,
StorageUpdates,
Subtree,
SubtreeError,
SubtreeUpdate,
};
// Also re-export commonly used types for convenience
pub use miden_protocol::{
EMPTY_WORD,
Felt,
Word,
crypto::{
hash::rpo::Rpo256,
merkle::{EmptySubtreeRoots, InnerNodeInfo, MerkleError, NodeIndex, SparseMerklePath},
},
};
pub use rocksdb::{RocksDbConfig, RocksDbStorage};
Loading