-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(bank): Add helper for v0.46 denom migration #13891
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1d87a1d
feat(bank): Add helper for v0.46 denom migration
amaury1093 2e331c4
CL
amaury1093 ae793da
Clearer name
amaury1093 13c8a93
Update x/bank/migrations/v046/store.go
amaury1093 3c714b7
rename
amaury1093 8e6a7ba
Merge branch 'am/046-bank-helper' of ssh://github.com/cosmos/cosmos-s…
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -92,3 +92,39 @@ func migrateDenomMetadata(store sdk.KVStore) error { | |||||
|
||||||
return nil | ||||||
} | ||||||
|
||||||
// Migrate_V0464_To_V0465 is a helper function to migrate chains from <=v0.46.4 | ||||||
// to v0.46.5 ONLY. | ||||||
// | ||||||
// IMPORTANT: Please do not use this function if you are upgrading to v0.46 | ||||||
// from <=v0.45. | ||||||
// | ||||||
// This function migrates the store in-place by fixing the bank denom bug | ||||||
// discovered in https://github.com/cosmos/cosmos-sdk/pull/13821. It has been | ||||||
// fixed in v0.46.5, but if your chain had already migrated to v0.46, then you | ||||||
// can apply this patch (in a coordinated upgrade, e.g. in the upgrade handler) | ||||||
// to fix the bank denom state. | ||||||
// | ||||||
// The store is expected to be the bank store, and not any prefixed substore. | ||||||
func Migrate_V0464_To_V0465(store sdk.KVStore) error { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
denomStore := prefix.NewStore(store, DenomMetadataPrefix) | ||||||
|
||||||
iter := denomStore.Iterator(nil, nil) | ||||||
defer iter.Close() | ||||||
|
||||||
for ; iter.Valid(); iter.Next() { | ||||||
oldKey := iter.Key() | ||||||
|
||||||
// In the previous bugged version, we took one character too long, | ||||||
// see this line diff: | ||||||
// https://github.com/cosmos/cosmos-sdk/commit/62443b8c28a23efe43df2158aa2833c02c42af16#diff-d4d8a522eca0bd1fd052a756b80d0a50bff7bd8e487105221475eb78e232b46aR83 | ||||||
// | ||||||
// Therefore we trim the last byte. | ||||||
newKey := oldKey[:len(oldKey)-1] | ||||||
|
||||||
denomStore.Set(newKey, iter.Value()) | ||||||
denomStore.Delete(oldKey) | ||||||
} | ||||||
|
||||||
return nil | ||||||
} |
This file contains 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
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.
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.
Releaase notes should be updated.