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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Add `validator` crate with initial protobuf, gRPC server, and sub-command (#[1293](https://github.com/0xMiden/miden-node/pull/1293)).
- Add optional `TransactionInputs` field to `SubmitProvenTransaction` endpoint for transaction re-execution (#[1278](https://github.com/0xMiden/miden-node/pull/1278)).
- [BREAKING] Added `AccountTreeWithHistory` and integrate historical queries into `GetAccountProof` ([#1292](https://github.com/0xMiden/miden-node/pull/1292)).
- [BREAKING] Added `rocksdb` feature to enable rocksdb as `LargeSmt` as `SmtStore` ([#1326](https://github.com/0xMiden/miden-node/pull/1326)).

## v0.11.2 (2025-09-10)

Expand Down
116 changes: 116 additions & 0 deletions Cargo.lock

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

15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ help:

WARNINGS=RUSTDOCFLAGS="-D warnings"
BUILD_PROTO=BUILD_PROTO=1
ALL_FEATURES="--features=tracing-forest,concurrent,tracing-forest,tx-prover,batch-prover,block-prover,std"

# -- linting --------------------------------------------------------------------------------------

.PHONY: clippy
clippy: ## Runs Clippy with configs
cargo clippy --locked --all-targets --all-features --workspace -- -D warnings
cargo clippy --locked --all-targets --all-features -p miden-remote-prover -- -D warnings
cargo clippy --locked --all-targets --workspace ${ALL_FEATURES} -- -D warnings
cargo clippy --locked --all-targets -p miden-remote-prover --features=concurrent -- -D warnings


.PHONY: fix
fix: ## Runs Fix with configs
cargo fix --allow-staged --allow-dirty --all-targets --all-features --workspace
cargo fix --allow-staged --allow-dirty --all-targets --all-features -p miden-remote-prover
cargo fix --allow-staged --allow-dirty --all-targets --workspace ${ALL_FEATURES}
cargo fix --allow-staged --allow-dirty --all-targets -p miden-remote-prover --features=concurrent


.PHONY: format
Expand Down Expand Up @@ -63,7 +64,7 @@ lint: typos-check format fix clippy toml machete ## Runs all linting tasks at on

.PHONY: doc
doc: ## Generates & checks documentation
$(WARNINGS) cargo doc --all-features --keep-going --release --locked
$(WARNINGS) cargo doc ${ALL_FEATURES} --keep-going --release --locked

.PHONY: book
book: ## Builds the book & serves documentation site
Expand All @@ -77,13 +78,13 @@ serve-docs: ## Serves the docs

.PHONY: test
test: ## Runs all tests
cargo nextest run --all-features --workspace
cargo nextest run ${ALL_FEATURES} --workspace

# --- checking ------------------------------------------------------------------------------------

.PHONY: check
check: ## Check all targets and features for errors without code generation
${BUILD_PROTO} cargo check --all-features --all-targets --locked --workspace
${BUILD_PROTO} cargo check ${ALL_FEATURES} --all-targets --locked --workspace

# --- building ------------------------------------------------------------------------------------

Expand Down
10 changes: 10 additions & 0 deletions crates/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ diesel = { features = ["numeric", "sqlite"], version = "2.2" }
diesel_migrations = { features = ["sqlite"], version = "2.2" }
hex = { version = "0.4" }
indexmap = { workspace = true }
miden-crypto = { features = ["concurrent", "hashmaps"], version = "0.17" }
miden-lib = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-proto-build = { features = ["internal"], workspace = true }
Expand Down Expand Up @@ -53,6 +54,15 @@ rand = { workspace = true }
regex = { version = "1.11" }
termtree = { version = "0.5" }

[features]
default = [] # rocksdb has just too many requirements on CI for now
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: comment formatting all good? might be formatter

rocksdb = ["miden-crypto/rocksdb"]

[[bench]]
harness = false
name = "account_tree_historical"
required-features = ["rocksdb"]

[package.metadata.cargo-machete]
# we only need it for dependency feature unification for `rocksdb`
ignored = ["miden-crypto"]
31 changes: 22 additions & 9 deletions crates/store/benches/account_tree_historical.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
use std::hint::black_box;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use miden_node_store::{AccountTreeWithHistory, InMemoryAccountTree};
use miden_node_store::{AccountTreeWithHistory, PersistentAccountTree};
use miden_objects::Word;
use miden_objects::account::AccountId;
use miden_objects::block::BlockNumber;
use miden_objects::block::account_tree::{AccountTree, account_id_to_smt_key};
use miden_objects::crypto::hash::rpo::Rpo256;
use miden_objects::crypto::merkle::{LargeSmt, MemoryStorage};
use miden_objects::crypto::merkle::{LargeSmt, RocksDbConfig, RocksDbStorage};
use miden_objects::testing::account_id::AccountIdBuilder;

/// Counter for creating unique RocksDB directories during benchmarking.
static DB_COUNTER: AtomicUsize = AtomicUsize::new(0);

// HELPER FUNCTIONS
// ================================================================================================

/// Creates a storage backend for a `LargeSmt`.
fn setup_storage() -> MemoryStorage {
// TODO migrate to RocksDB for persistence to gain meaningful numbers
MemoryStorage::default()
/// Creates a `RocksDB` storage instance in target/bench_* directory for benchmarking.
fn setup_storage() -> RocksDbStorage {
let counter = DB_COUNTER.fetch_add(1, Ordering::SeqCst);
let db_path = PathBuf::from(format!("target/bench_rocksdb_{counter}"));

// Clean up the directory if it exists
if db_path.exists() {
fs_err::remove_dir_all(&db_path).ok();
}
fs_err::create_dir_all(db_path.parent().unwrap()).expect("Creation is not enough");

RocksDbStorage::open(RocksDbConfig::new(db_path)).expect("RocksDB failed to open file")
}

/// Generates a deterministic word from a seed.
Expand Down Expand Up @@ -47,7 +60,7 @@ fn generate_account_id(seed: &mut [u8; 32]) -> AccountId {
/// Sets up a vanilla `AccountTree` with specified number of accounts.
fn setup_vanilla_account_tree(
num_accounts: usize,
) -> (AccountTree<LargeSmt<MemoryStorage>>, Vec<AccountId>) {
) -> (AccountTree<LargeSmt<RocksDbStorage>>, Vec<AccountId>) {
let mut seed = [0u8; 32];
let mut account_ids = Vec::new();
let mut entries = Vec::new();
Expand All @@ -70,7 +83,7 @@ fn setup_vanilla_account_tree(
fn setup_account_tree_with_history(
num_accounts: usize,
num_blocks: usize,
) -> (AccountTreeWithHistory<InMemoryAccountTree>, Vec<AccountId>) {
) -> (AccountTreeWithHistory<PersistentAccountTree>, Vec<AccountId>) {
let mut seed = [0u8; 32];
let storage = setup_storage();
let smt = LargeSmt::with_entries(storage, std::iter::empty())
Expand Down Expand Up @@ -164,7 +177,7 @@ fn bench_historical_access(c: &mut Criterion) {

for &num_accounts in &account_counts {
for &block_depth in &block_depths {
if block_depth > AccountTreeWithHistory::<InMemoryAccountTree>::MAX_HISTORY {
if block_depth > AccountTreeWithHistory::<PersistentAccountTree>::MAX_HISTORY {
continue;
}

Expand Down
5 changes: 5 additions & 0 deletions crates/store/src/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ mod tests;
/// Convenience for an in-memory-only account tree.
pub type InMemoryAccountTree = AccountTree<LargeSmt<MemoryStorage>>;

#[cfg(feature = "rocksdb")]
/// Convenience for a persistent account tree.
pub type PersistentAccountTree =
AccountTree<LargeSmt<miden_objects::crypto::merkle::RocksDbStorage>>;

// ACCOUNT TREE STORAGE TRAIT
// ================================================================================================

Expand Down
3 changes: 2 additions & 1 deletion crates/store/src/db/migrations/2025062000000_setup/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CREATE TABLE accounts (
vault BLOB,
nonce INTEGER,

PRIMARY KEY (account_id),
PRIMARY KEY (account_id, block_num),
FOREIGN KEY (block_num) REFERENCES block_headers(block_num),
FOREIGN KEY (code_commitment) REFERENCES account_codes(code_commitment),
CONSTRAINT all_null_or_none_null CHECK
Expand All @@ -34,6 +34,7 @@ CREATE TABLE accounts (
) WITHOUT ROWID;

CREATE INDEX idx_accounts_network_prefix ON accounts(network_account_id_prefix) WHERE network_account_id_prefix IS NOT NULL;
CREATE INDEX idx_accounts_id_block ON accounts(account_id, block_num DESC);

CREATE TABLE notes (
committed_at INTEGER NOT NULL, -- Block number when the note was committed
Expand Down
Loading
Loading