-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add MultiStore SMT manager #17
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #17 +/- ##
==========================================
- Coverage 86.93% 86.73% -0.20%
==========================================
Files 8 9 +1
Lines 995 1063 +68
==========================================
+ Hits 865 922 +57
- Misses 94 101 +7
- Partials 36 40 +4
☔ View full report in Codecov by Sentry. |
*SMT | ||
name string | ||
nodeStore MapStore | ||
multi *multi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an interface?
} | ||
) | ||
|
||
type multi struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the fields be exported and have getters so you can plug and play your own and pass it as an interface into the store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h5law Before I review this, can you update the description with the motivation for this?
When I saw this:
The
MultiStore
interface grants the easy management of numerous different SMTs.
It made me feel like the multistore is outside the scope of the smt
repo and is probably something a user of this repo would manage.
Closing this as the MultiStore is not longer a priority. For future reference this should be rescoped to allow the SMT to preform silimar functions to the IAVL+ tree in the context of the [1] https://docs.cosmos.network/v0.45/core/store.html#commitmultistore |
Description
This PR introduces the new
MultiStore
SMT manager. This enables the management of numerous SMTs under a single overarching tree.The
MultiStore
acts as a wrapper around an SMT that includes the name and root hash of the trees it manages. TheStore
interface is a wrapper around a single SMT which tracks theMultiStore
it is a part of and overwrites the SMT'sCommit
method to not only commit theStore
's changes to the database but also update theMultiStore
with the name and root hash of theStore
's tree.This is useful in areas where a single tree / root hash is needed but different SMT's are desired: for example in a blockchain setting this could replace the root tree and each of the trees it manages could track the transactions, accounts etc. It would also be useful for an implementation of the IBC specification where the
MultiStore
would represent the IBC store as a whole with eachStore
representing a single ICS component such as the ICS-02 store or the ICS-03 store.Summary generated by Reviewpad on 31 Jul 23 12:52 UTC
This pull request introduces significant changes to several files related to the
MultiStore
functionality. Here is a summary of the changes:multi_test.go
: The file now includes test functions and helper functions for testing theMultiStore
functionality. The test functions cover various operations such as adding a store, inserting a pre-existing store, getting a store, removing a store, performing store operations, committing changes, and generating proofs. Additionally, a helper functioncustomStoreCreator
is added.multi.go
: This file implements theMultiStore
interface and its associated functions. Themulti
struct represents a collection of multiple stores and implements methods such asAddStore
,InsertStore
,GetStore
,RemoveStore
,Commit
,Root
,Prove
, andSpec
. Thestore
struct represents an individual store within theMultiStore
, maintaining a reference to the parentMultiStore
and implementing aCommit
method that updates the multi-store with the latest root hash.MultiStore.md
: The Markdown file provides an overview of theMultiStore
interface and its functionalities. It explains how theMultiStore
manages multiple stores and describes the operations available for managing stores and trees. It also introduces theStore
type, which is a wrapper around anSMT
and includes aCommit
method to update the multi-store with the root hash of the store. Additionally, it discusses theTreeSpec
type, which specifies the hashing functions and maximum depth of the tree.These changes significantly enhance the functionality and usage of the
MultiStore
concept, allowing for better management and manipulation of multiple stores within the system.Type of change
Please mark the relevant option(s):
List of changes
MultiStore
andStore
interfacesmulti
andstore
structs to implement the interfacesTesting
go test ...
go test ...
go test -v
Required Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist