Skip to content

feat: AccountTreeBackendReader and NullifierTreeBackendReader traits#2755

Merged
mmagician merged 32 commits into
nextfrom
sergerad-clone
May 29, 2026
Merged

feat: AccountTreeBackendReader and NullifierTreeBackendReader traits#2755
mmagician merged 32 commits into
nextfrom
sergerad-clone

Conversation

@sergerad

@sergerad sergerad commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Description

Using the new SmtStorageReader trait from miden-crypto, extract AccountTreeBackendReader and NullifierTreeBackendReader from the existing traits.

In miden-node (PR), we are working towards removing synchronization mechanisms by providing read-only types which can be cloned..

Depends on 0xMiden/crypto#967.

@sergerad sergerad marked this pull request as ready for review May 28, 2026 03:31

@PhilippGackstatter PhilippGackstatter 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.

Looks good to me! Left non-blocking comments.

Comment thread crates/miden-protocol/src/block/account_tree/mod.rs Outdated
Comment on lines +254 to +257
/// Returns a read-only account tree backed by a reader view of this tree's storage.
pub fn reader(&self) -> Result<AccountTree<LargeSmt<Backend::Reader>>, LargeSmtError> {
Ok(AccountTree::new_unchecked(self.smt.reader()?))
}

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.

I might not understand how this is being used upstream, but if I already have an AccountTree backed by a reader backend, I wouldn't need to call this method, right? And if I have a read-write-backed AccountTree, I could also read directly from that.

Is the intention of this to create a read-only view of the tree when we have mutable access, and then pass the view-only type somewhere else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes that is the intention!

@bobbinth bobbinth 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.

Looks good! Thank you! I left a couple of small comments/questions inline.

Comment thread crates/miden-protocol/src/block/account_tree/backend.rs Outdated
Comment thread crates/miden-protocol/src/block/nullifier_tree/backend.rs Outdated

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.

Not related to this PR, but why does the NullifierTree have with_storage_from_entries() but the AccountTree doesn't? It feels like these should be pretty uniform structures.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an impl for it

@mmagician mmagician 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.

LGTM

@mmagician mmagician enabled auto-merge May 29, 2026 12:24
@mmagician mmagician added this pull request to the merge queue May 29, 2026
Merged via the queue into next with commit 5f43e07 May 29, 2026
20 checks passed
@mmagician mmagician deleted the sergerad-clone branch May 29, 2026 12:37
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.

4 participants