feat: AccountTreeBackendReader and NullifierTreeBackendReader traits#2755
Conversation
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Looks good to me! Left non-blocking comments.
| /// 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()?)) | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yes that is the intention!
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left a couple of small comments/questions inline.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Added an impl for it
Description
Using the new
SmtStorageReadertrait from miden-crypto, extractAccountTreeBackendReaderandNullifierTreeBackendReaderfrom 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.