Skip to content

Comments

chore: backport LargeSmtForest to 0.19.x branch#834

Merged
drahnr merged 3 commits intoversion/0.19.xfrom
bernhard-backport-large-smt-forest-to-0.19.x-branch
Feb 18, 2026
Merged

chore: backport LargeSmtForest to 0.19.x branch#834
drahnr merged 3 commits intoversion/0.19.xfrom
bernhard-backport-large-smt-forest-to-0.19.x-branch

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Feb 17, 2026

Backport LargeSmt from next to version/0.19.x branch and a few minimal adjacent non-breaking changes, which are limited to mod test_utils addition and a minor extension to SmtLeaf:

diff --git a/miden-crypto/src/merkle/smt/full/leaf.rs b/miden-crypto/src/merkle/smt/full/leaf.rs
index 031ade9a6..3561aa955 100644
--- a/miden-crypto/src/merkle/smt/full/leaf.rs
+++ b/miden-crypto/src/merkle/smt/full/leaf.rs
@@ -175,6 +175,10 @@ impl SmtLeaf {
         self.clone().into_elements()
     }
 
+    pub fn to_entries(&self) -> impl Iterator<Item = (&Word, &Word)> {
+        self.entries().iter().map(|(k, v)| (k, v))
+    }
+
     /// Converts a leaf to a list of field elements
     pub fn into_elements(self) -> Vec<Felt> {
         self.into_entries().into_iter().flat_map(kv_to_elements).collect()
diff --git a/miden-crypto/src/merkle/smt/full/mod.rs b/miden-crypto/src/merkle/smt/full/mod.rs
index 2f2662842..d9b04e4bb 100644
--- a/miden-crypto/src/merkle/smt/full/mod.rs
+++ b/miden-crypto/src/merkle/smt/full/mod.rs
@@ -259,6 +259,11 @@ impl Smt {
         <Self as SparseMerkleTree<SMT_DEPTH>>::get_leaf(self, key)
     }
 
+    /// Returns the leaf corresponding to the provided `index`.
+    pub fn get_leaf_by_index(&self, index: LeafIndex<SMT_DEPTH>) -> Option<SmtLeaf> {
+        self.leaves.get(&index.position()).cloned()
+    }
+
     /// Returns the value associated with `key`
     pub fn get_value(&self, key: &Word) -> Word {
         <Self as SparseMerkleTree<SMT_DEPTH>>::get_value(self, key)

Why do we want this backported?

node PR 0xMiden/miden-node#1635 introduces a free-style version of the LargeForestSmt with in Memory backend, using this implementation should lead to easier to maintain code and do away with a lot of (hopefully all) helper lookup tables.

@drahnr drahnr force-pushed the bernhard-backport-large-smt-forest-to-0.19.x-branch branch from 0c81380 to 70ac3d1 Compare February 17, 2026 16:02
@drahnr drahnr force-pushed the bernhard-backport-large-smt-forest-to-0.19.x-branch branch from c1f46b0 to a8f9efc Compare February 18, 2026 08:57
Copy link
Collaborator

@iamrecursion iamrecursion left a comment

Choose a reason for hiding this comment

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

Insofar as this looks like the code I wrote and the fix for truncate is in place, LGTM!

@drahnr drahnr merged commit 7530076 into version/0.19.x Feb 18, 2026
22 checks passed
@drahnr drahnr deleted the bernhard-backport-large-smt-forest-to-0.19.x-branch branch February 18, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants