Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fa881c6
Lock-free store state and apply_block
sergerad Apr 7, 2026
b389c59
Add ReadSnapshot
sergerad Apr 8, 2026
13c2e3f
RWLock for in-memory fields
sergerad Apr 8, 2026
2f71740
Lock and DB commit
sergerad Apr 8, 2026
8404f43
Remove RWLocks and use ArcSwap
sergerad Apr 8, 2026
2b0c1ac
Fix lint
sergerad Apr 8, 2026
30249a8
Drop snapshot sooner
sergerad Apr 9, 2026
43ee1cf
Drop snapshot earlier in get_block_inputs_witnesses
sergerad Apr 9, 2026
28e8070
Tidy error variants
sergerad Apr 9, 2026
5a8b843
Fix comments and reduce pub fields to super
sergerad Apr 9, 2026
42932ff
Remove mention of previous design from comments
sergerad Apr 9, 2026
39ae2a2
Integrate Snapshot / Readers
sergerad Apr 10, 2026
407bce1
Reduce WriterGuard
sergerad Apr 10, 2026
b3d11d4
Remove WriterGuard
sergerad Apr 10, 2026
a1e2cd5
Lint
sergerad Apr 10, 2026
9fc06c8
Fix ntx builder
sergerad Apr 10, 2026
0294773
Scope db queries by state snapshot block num
sergerad Apr 10, 2026
6b6c5c1
Update upstream deps and user readers properly
sergerad Apr 13, 2026
a5a3c06
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-st…
sergerad Apr 13, 2026
a8a35b5
toml
sergerad Apr 13, 2026
3614454
Dedupe entry and leaf counting
sergerad Apr 13, 2026
98c7fc4
read_leaf and rename other helpers
sergerad Apr 13, 2026
259bc97
Add read_leaves
sergerad Apr 13, 2026
73643b5
ManuallyDrop snapshot
sergerad Apr 13, 2026
c62d577
RM as_ptr and clean up comments
sergerad Apr 13, 2026
38e1705
Dedupe more with helpers
sergerad Apr 13, 2026
c658b83
Comments
sergerad Apr 13, 2026
163ccfe
Update deps
sergerad Apr 13, 2026
bdb8156
Reorder AccountTreeWithHistory fns
sergerad Apr 13, 2026
95aa192
Split rocksdb.rs
sergerad Apr 13, 2026
3de3340
Split apply_block_inner impl and move store calls
sergerad Apr 13, 2026
607b992
Revert bridge.mac
sergerad Apr 13, 2026
354f1cd
Remove unnecessary async
sergerad Apr 13, 2026
4aa598b
More chain tip checks
sergerad Apr 13, 2026
619df56
Return block height from get_transactions_input (fix)
sergerad Apr 14, 2026
dfed797
block scope select_existing_note_commitments
sergerad Apr 14, 2026
c2e37e0
Remove unnecessary tip checks and update comments
sergerad Apr 14, 2026
d5a39bc
Return chain tip and avoid using snapshot out of state
sergerad Apr 14, 2026
ee74617
Add scoped result
sergerad Apr 14, 2026
9544008
Fix ntx-builder store fns and add Scoped::into_inner()
sergerad Apr 14, 2026
5fd4954
Update docstring
sergerad Apr 14, 2026
40495be
Allow max block in get_all_network_accounts
sergerad Apr 15, 2026
9c1c261
Update deps
sergerad Apr 15, 2026
99925ff
Clamp block num for get_unconsumed_network_notes_for_account
sergerad Apr 15, 2026
92926fe
Add BlockWriter
sergerad Apr 15, 2026
8f351e0
Update deps
sergerad Apr 15, 2026
cc0b4ee
Update deps
sergerad Apr 15, 2026
0268997
Use reader() and remove unnecessary db handling
sergerad Apr 16, 2026
45c5bc0
block_in_place in write_block
sergerad Apr 17, 2026
c909ef9
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-st…
sergerad Apr 17, 2026
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
72 changes: 35 additions & 37 deletions Cargo.lock

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

27 changes: 20 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ miden-remote-prover-client = { path = "crates/remote-prover-client", versio
miden-node-rocksdb-cxx-linkage-fix = { path = "crates/rocksdb-cxx-linkage-fix", version = "0.15" }

# miden-protocol dependencies. These should be updated in sync.
miden-agglayer = { version = "0.14" }
miden-block-prover = { version = "0.14" }
miden-protocol = { default-features = false, version = "0.14" }
miden-standards = { version = "0.14" }
miden-testing = { version = "0.14" }
miden-tx = { default-features = false, version = "0.14" }
miden-tx-batch-prover = { version = "0.14" }
miden-agglayer = { version = "0.15" }
miden-block-prover = { version = "0.15" }
miden-protocol = { default-features = false, version = "0.15" }
miden-standards = { version = "0.15" }
miden-testing = { version = "0.15" }
miden-tx = { default-features = false, version = "0.15" }
miden-tx-batch-prover = { version = "0.15" }

# Other miden dependencies. These should align with those expected by miden-protocol.
miden-crypto = { version = "0.23" }
Expand Down Expand Up @@ -143,3 +143,16 @@ 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 = { branch = "sergerad-largesmt-reader-trait", git = "https://github.com/0xmiden/crypto" }
miden-serde-utils = { branch = "sergerad-largesmt-reader-trait", git = "https://github.com/0xmiden/crypto" }

miden-agglayer = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-block-prover = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-protocol = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-protocol-macros = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-standards = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-testing = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-tx = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
miden-tx-batch-prover = { branch = "sergerad-clone", git = "https://github.com/0xmiden/protocol" }
2 changes: 1 addition & 1 deletion bin/stress-test/src/seeding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn create_batch(txs: &[ProvenTransaction], block_ref: &BlockHeader) -> ProvenBat
.collect();
let input_notes = txs.iter().flat_map(|tx| tx.input_notes().iter().cloned()).collect();
let output_notes = txs.iter().flat_map(|tx| tx.output_notes().iter().cloned()).collect();
ProvenBatch::new(
ProvenBatch::new_unchecked(
BatchId::from_transactions(txs.iter()),
block_ref.commitment(),
block_ref.block_num(),
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/test_utils/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl TransactionBatchConstructor for ProvenBatch {
output_notes.extend(tx.output_notes().iter().cloned());
}

ProvenBatch::new(
ProvenBatch::new_unchecked(
BatchId::from_transactions(txs.iter().copied()),
Word::empty(),
BlockNumber::GENESIS,
Expand Down
125 changes: 124 additions & 1 deletion crates/large-smt-backend-rocksdb/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use miden_crypto::merkle::smt::{MAX_LEAF_ENTRIES, SmtLeaf, SmtLeafError};
use alloc::boxed::Box;
use alloc::vec::Vec;

use miden_crypto::merkle::NodeIndex;
use miden_crypto::merkle::smt::{MAX_LEAF_ENTRIES, SmtLeaf, SmtLeafError, Subtree};
use miden_crypto::utils::Deserializable;
use miden_crypto::word::LexicographicWord;
use rocksdb::Error as RocksDbError;

Expand Down Expand Up @@ -81,3 +86,121 @@ pub(crate) fn remove_from_leaf(leaf: &mut SmtLeaf, key: Word) -> (Option<Word>,
},
}
}

/// Deserializes a big-endian `usize` count from exactly 8 bytes. `what` is used in the error
/// message if the length is wrong.
pub(crate) fn read_count(what: &'static str, bytes: &[u8]) -> Result<usize, StorageError> {
let arr: [u8; 8] = bytes.try_into().map_err(|_| StorageError::BadValueLen {
what,
expected: 8,
found: bytes.len(),
})?;
Ok(usize::from_be_bytes(arr))
}

/// Deserializes a single SMT leaf from raw bytes.
#[expect(clippy::needless_pass_by_value, reason = "simplifies chaining")]
pub(crate) fn read_leaf(leaf_bytes: Vec<u8>) -> Result<Option<SmtLeaf>, StorageError> {
let leaf = SmtLeaf::read_from_bytes_with_budget(&leaf_bytes, leaf_bytes.len())?;
Ok(Some(leaf))
}

/// Deserializes a batch of optional raw byte vectors into optional SMT leaves.
pub(crate) fn read_leaves(
leaves: Vec<Option<Vec<u8>>>,
) -> Result<Vec<Option<SmtLeaf>>, StorageError> {
leaves
.into_iter()
.map(|leaf| match leaf {
Some(bytes) => Ok(Some(SmtLeaf::read_from_bytes_with_budget(&bytes, bytes.len())?)),
None => Ok(None),
})
.collect()
}

/// Deserializes a single subtree from an optional raw byte vector.
pub(crate) fn read_subtree(
index: NodeIndex,
db_result: Option<Vec<u8>>,
) -> Result<Option<Subtree>, StorageError> {
match db_result {
Some(bytes) => {
let subtree = Subtree::from_vec(index, &bytes)?;
Ok(Some(subtree))
},
None => Ok(None),
}
}

/// Deserializes a batch of raw `multi_get` results into subtrees, preserving the original
/// indices for reassembly.
pub(crate) fn read_subtree_batch(
bucket: Vec<(usize, NodeIndex)>,
db_results: Vec<Result<Option<Vec<u8>>, RocksDbError>>,
) -> Result<Vec<(usize, Option<Subtree>)>, StorageError> {
bucket
.into_iter()
.zip(db_results)
.map(|((original_index, node_index), db_result)| {
let subtree = match db_result {
Ok(Some(bytes)) => Some(Subtree::from_vec(node_index, &bytes)?),
Ok(None) => None,
Err(e) => return Err(map_rocksdb_err(e)),
};
Ok((original_index, subtree))
})
.collect()
}

/// Buckets subtree node indices by depth for batched column family lookups.
///
/// Returns an array of 5 buckets (for depths 56, 48, 40, 32, 24), where each bucket
/// contains `(original_index, NodeIndex)` pairs.
pub(crate) fn bucket_by_depth(
indices: &[NodeIndex],
) -> Result<[Vec<(usize, NodeIndex)>; 5], StorageError> {
let mut depth_buckets: [Vec<(usize, NodeIndex)>; 5] = Default::default();

for (original_index, &node_index) in indices.iter().enumerate() {
let depth = node_index.depth();
let bucket_index = match depth {
56 => 0,
48 => 1,
40 => 2,
32 => 3,
24 => 4,
_ => {
return Err(StorageError::Unsupported(format!(
"unsupported subtree depth {depth}"
)));
},
};
depth_buckets[bucket_index].push((original_index, node_index));
}

Ok(depth_buckets)
}

/// Deserializes depth-24 hash entries from a database iterator into `(index, Word)` pairs.
pub(crate) fn read_depth24_entries(
iter: impl Iterator<Item = Result<(Box<[u8]>, Box<[u8]>), RocksDbError>>,
) -> Result<Vec<(u64, Word)>, StorageError> {
let mut hashes = Vec::new();
for item in iter {
let (key_bytes, value_bytes) = item.map_err(map_rocksdb_err)?;
let index = index_from_key_bytes(&key_bytes)?;
let hash = Word::read_from_bytes(&value_bytes)?;
hashes.push((index, hash));
}
Ok(hashes)
}

/// Deserializes a `u64` index from an 8-byte big-endian key.
pub(crate) fn index_from_key_bytes(key_bytes: &[u8]) -> Result<u64, StorageError> {
if key_bytes.len() != 8 {
return Err(StorageError::BadKeyLen { expected: 8, found: key_bytes.len() });
}
let mut arr = [0u8; 8];
arr.copy_from_slice(key_bytes);
Ok(u64::from_be_bytes(arr))
}
Loading
Loading