diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f71ecc87992..036e124ef9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/x/bank/migrations/v046/store.go b/x/bank/migrations/v046/store.go index 8f4e628a11ea..8e5db7b6733f 100644 --- a/x/bank/migrations/v046/store.go +++ b/x/bank/migrations/v046/store.go @@ -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 diff --git a/x/bank/migrations/v046/store_test.go b/x/bank/migrations/v046/store_test.go index db44f2591fdc..4c43dec5b4e0 100644 --- a/x/bank/migrations/v046/store_test.go +++ b/x/bank/migrations/v046/store_test.go @@ -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) @@ -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)