Closed
Conversation
Collaborator
|
I have not read the code as it is still a draft, but please make sure that this does not incur any performance regressions for LargeSmt. |
ded92df to
bcb1daa
Compare
Contributor
Author
|
Closing in favour of #967 which points at main for v0.23.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extract a new
SmtStorageReadertrait fromSmtStorage, enablingLargeSmt<S>to work with read-only storage for read operations, and only requireSmtStoragefor mutations.Motivation
Previously,
LargeSmt<S: SmtStorage>required full read+write storage for all operations, including purely read-only ones likeget_leaf,get_value,open, and tree loading. This made it impossible to useLargeSmtwith a read-only storage backend.In miden-node (PR), we are working towards removing synchronization mechanisms by providing read-only types which can be cloned.
Changes
Trait hierarchy (
storage/mod.rs):SmtStorageReader—&selfmethods (leaf/subtree reads, iterators,get_depth24)SmtStorage: SmtStorageReader—&mut selfmethods (inserts, removes,apply)LargeSmt<S>struct bound relaxed (large/mod.rs):S: SmtStoragetoS: SmtStorageReaderimpl<S: SmtStorageReader>— accessors (root,get_leaf,get_value,open,is_empty), iterators, construction from existing storage (new,load,load_with_root)impl<S: SmtStorage>—insert,with_entries, batch construction methodsOther files updated:
smt_trait.rs—SparseMerkleTreeimpl bounded bySmtStoragebatch_ops.rs— bounded bySmtStorageconstruction.rs— split into Reader (load from storage) and Storage (build with entries) blocksiter.rs— bounded bySmtStorageReadermemory.rs,rocksdb.rs— splitimpl SmtStorageintoimpl SmtStorageReader+impl SmtStoragesmt/mod.rs— re-exportsSmtStorageReaderBackwards compatibility
SmtStorageretains all original methods (read + write) via its supertraitSmtStorageReader, so existing code usingS: SmtStoragecontinues to compile unchanged.