Skip to content
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

fix: bank store migration (backport #13821) #13829

Merged
merged 2 commits into from Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (x/bank) [#13821](https://github.com/cosmos/cosmos-sdk/pull/13821) Fix bank store migration of coin metadata.
* (x/group) [#13808](https://github.com/cosmos/cosmos-sdk/pull/13808) Fix propagation of message events to the current context in `EndBlocker`.
* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`.
* (store) [#13803](https://github.com/cosmos/cosmos-sdk/pull/13803) Add an error log if iavl set operation failed.
Expand Down
2 changes: 1 addition & 1 deletion x/bank/migrations/v046/store.go
Expand Up @@ -80,7 +80,7 @@ func migrateDenomMetadata(store sdk.KVStore) error {

for ; oldDenomMetaDataIter.Valid(); oldDenomMetaDataIter.Next() {
oldKey := oldDenomMetaDataIter.Key()
l := len(oldKey)/2 + 1
l := len(oldKey) / 2

newKey := make([]byte, len(types.DenomMetadataPrefix)+l)
// old key: prefix_bytes | denom_bytes | denom_bytes
Expand Down
6 changes: 3 additions & 3 deletions x/bank/migrations/v046/store_test.go
Expand Up @@ -87,8 +87,8 @@ func TestMigrateDenomMetaData(t *testing.T) {
denomMetadataStore := prefix.NewStore(store, v043.DenomMetadataPrefix)

for i := range []int{0, 1} {
key := append(v043.DenomMetadataPrefix, []byte(metaData[i].Base)...)
// keys before 0.45 had denom two times in the key
key := append([]byte{}, []byte(metaData[i].Base)...)
key = append(key, []byte(metaData[i].Base)...)
bz, err := encCfg.Codec.Marshal(&metaData[i])
require.NoError(t, err)
Expand All @@ -105,11 +105,11 @@ func TestMigrateDenomMetaData(t *testing.T) {
newKey := denomMetadataIter.Key()

// make sure old entry is deleted
oldKey := append(newKey, newKey[1:]...)
oldKey := append(newKey, newKey[0:]...)
bz := denomMetadataStore.Get(oldKey)
require.Nil(t, bz)

require.Equal(t, string(newKey)[1:], metaData[i].Base, "idx: %d", i)
require.Equal(t, string(newKey), metaData[i].Base, "idx: %d", i)
bz = denomMetadataStore.Get(denomMetadataIter.Key())
require.NotNil(t, bz)
err := encCfg.Codec.Unmarshal(bz, &result)
Expand Down