Skip to content

feat: open LargeSmtForest backend API for external implementations - #3413

Merged
huitseeker merged 5 commits into
0xMiden:nextfrom
JereSalo:open-forest-backend-api-for-external-impls
Jul 24, 2026
Merged

feat: open LargeSmtForest backend API for external implementations#3413
huitseeker merged 5 commits into
0xMiden:nextfrom
JereSalo:open-forest-backend-api-for-external-impls

Conversation

@JereSalo

@JereSalo JereSalo commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

The Backend trait for LargeSmtForest is public but cannot be implemented outside this crate, because compute_mutations and apply_mutations must return LineageMutation and AppliedLineageMutation values whose fields are private and whose constructors are pub(crate). This PR makes both constructors public and adds a LineageId::as_bytes getter so backends can persist lineage identifiers.

It also adds a MutationSet::from_parts constructor. An external backend has to produce the forward and reverse mutation sets carried by AppliedLineageMutation, and since MutationSet fields are private the only way to build them today is to load the full tree into memory and run Smt::compute_mutations / apply_mutations_with_reversion, which makes update cost scale with tree size instead of change size. With the constructor, a backend can compute mutations against its persisted tree data (affected leaves and stored subtree nodes only) and assemble both sets directly, the same way the built-in RocksDB backend does internally. In the SQLite backend prototype this took a single-entry committed update on a 1,000,000-entry tree from ~30 s to ~1 ms.

We need this change because in 0xMiden/rust-sdk#2315 we want to use the LargeSmtForest but with an SQLite backend. And it's very likely that we'll want to do the same in the web SDK with IndexedDB.

In order to make use of this change we should also bump miden-crypto, so it'd be good to have this in 0.28.1 since miden-protocol currently pins ^0.28.

@JereSalo
JereSalo marked this pull request as ready for review July 21, 2026 20:46
@github-actions

Copy link
Copy Markdown

Automated check (CONTRIBUTING.md)

Findings:

Recommendations:

  • Consider adding a Test plan or clear review steps.

Next steps:

  • Link a relevant issue (e.g., "Fixes Implement SHA256 in Miden Assembly #123") and ensure it is assigned to you.
  • See CONTRIBUTING.md for expectations.
  • If this is a false positive, comment: /quality-review.

@JereSalo

Copy link
Copy Markdown
Contributor Author

Ideally we would like this in crypto 0.28.1 so we can get to use this soon. Since crypto has been moved to this repository I'm not entirely sure how crypto releases are managed. I pointed this PR to next, but if you need me to make any changes regarding that let me know.

@huitseeker
huitseeker requested review from Al-Kindi-0, bobbinth and huitseeker and removed request for bobbinth July 22, 2026 14:59

@Al-Kindi-0 Al-Kindi-0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@huitseeker huitseeker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This works! This will get published as 0.28.1 and does not need a major bump.

@huitseeker

Copy link
Copy Markdown
Collaborator

@JereSalo This will normalize as soon as we release the VM at 0.28, but what you did is just fine.

@JereSalo

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I had to add one more little change that I noticed was necessary while implementing the LargeSmtForest Backend in 0xMiden/rust-sdk#2333. It's just a constructor. I updated the PR description accordingly. Let me know what you think.

@huitseeker
huitseeker merged commit db4fd2f into 0xMiden:next Jul 24, 2026
25 checks passed
igamigo added a commit to 0xMiden/rust-sdk that referenced this pull request Jul 28, 2026
miden-crypto 0.28.1 is still unpublished, so the patch remains, but it
now pins the official 0xMiden/miden-vm repo at the squash-merge of
0xMiden/miden-vm#3413 instead of a mutable personal-fork branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants