-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: state migration from IAVL to SMT (ADR-040) #10962
Conversation
State migration from iavl to smt
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.
This should work, but we should introduce it in the context of the command where it will be used, and include a unit test. We should make the usage clear: the v2 store schema needs to contain all the v1 stores at initialization.
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.
A few comments, thanks!
@i-norden I address the pr comments, Can you please review it again. |
MigrationV2 will return RootStore as output
@robert-zaremba @roysc I address the pr comments, can you look into those changesd |
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.
LGTM
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.
not everything was addressed.
store/rootmulti/store.go
Outdated
func (rs *Store) GetStores() map[types.StoreKey]types.CommitKVStore { | ||
return rs.stores | ||
// GetStoreNames returns the storeNames and StoreKeys | ||
func (rs *Store) GetStoreNames() map[string]types.StoreKey { |
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.
Why renaming? If we want to rename then let's be more precise. I suggest: StoreKeysByName
(no need for Get prefix)
store/v2/multi/migration.go
Outdated
) | ||
|
||
// MigrateV2 will migrate the state from iavl to smt | ||
func MigrateV2(rootMultiStore *v1Store.Store, store2db dbm.DBConnection, storeConfig StoreConfig) (*Store, error) { |
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.
func MigrateV2(rootMultiStore *v1Store.Store, store2db dbm.DBConnection, storeConfig StoreConfig) (*Store, error) { | |
func MigrateFromV1(rootMultiStore *v1Store.Store, store2db dbm.DBConnection, storeConfig StoreConfig) (*Store, error) { |
store/v2/multi/migration.go
Outdated
|
||
// iterate through the rootmulti stores and save the key/values into smt tree | ||
for _, store := range stores { | ||
subStore, err := rootStore.getSubstore(store.name) |
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.
shouldn't we make sure that we use the same store key when doing migration?
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.
we are registering the storeKeys
into v2Store from v1Store
https://github.com/cosmos/cosmos-sdk/pull/10962/files#diff-ad3a972d3e8f738c0ee269b134134e2beee4e5f0ee9849b0c71eb7cc9d669ce1R24
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.
Lgtm except for the remaining renames
store/rootmulti/snapshot_test.go
Outdated
@@ -210,7 +210,8 @@ func TestMultistoreSnapshotRestore(t *testing.T) { | |||
require.Equal(t, *dummyExtensionItem.GetExtension(), *nextItem.GetExtension()) | |||
|
|||
assert.Equal(t, source.LastCommitID(), target.LastCommitID()) | |||
for key, sourceStore := range source.GetStores() { | |||
for _, key := range source.GetStoreNames() { |
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.
Need to finish the renames in this file
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.
ok
@gsk967 you should "resolve" addressed suggestions, it helps with review. |
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.
Approving. Please add Changelog updates.
@robert-zaremba Update the changelog and move the migration into alpha1 |
@gsk967 a test is not passing. |
State migration from iavl to smt
This migration works on upgrade handler
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change