From 8ab33f58d7bf3ec0c5a0ac97a9dfa754eaf45d10 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:24:32 +0000 Subject: [PATCH] fix: fixed key in slashing bitmap migration (backport #18016) (#18033) Co-authored-by: swelf19 <62722506+swelf19@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + x/slashing/migrations/v4/keys.go | 2 +- x/slashing/migrations/v4/migrate_test.go | 4 ---- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102f290410..1730605f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (x/gov) [#17873](https://github.com/cosmos/cosmos-sdk/pull/17873) Fail any inactive and active proposals that cannot be decoded. +* (x/slashing) [#18016](https://github.com/cosmos/cosmos-sdk/pull/18016) Fixed builder function for missed blocks key (`validatorMissedBlockBitArrayPrefixKey`) in slashing/migration/v4 ### Client Breaking Changes diff --git a/x/slashing/migrations/v4/keys.go b/x/slashing/migrations/v4/keys.go index 1ac42b6c1a..c5ab30ff72 100644 --- a/x/slashing/migrations/v4/keys.go +++ b/x/slashing/migrations/v4/keys.go @@ -28,7 +28,7 @@ func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) { } func validatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte { - return append(validatorMissedBlockBitArrayKeyPrefix, v.Bytes()...) + return append(validatorMissedBlockBitArrayKeyPrefix, address.MustLengthPrefix(v.Bytes())...) } func ValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte { diff --git a/x/slashing/migrations/v4/migrate_test.go b/x/slashing/migrations/v4/migrate_test.go index 844de3e900..fc8a043610 100644 --- a/x/slashing/migrations/v4/migrate_test.go +++ b/x/slashing/migrations/v4/migrate_test.go @@ -41,10 +41,6 @@ func TestMigrate(t *testing.T) { err := v4.Migrate(ctx, cdc, store, params) require.NoError(t, err) - // ensure old entries no longer exist and new bitmap chunk entries exist - entries := v4.GetValidatorMissedBlocks(ctx, cdc, store, consAddr, params) - require.Empty(t, entries) - for i := int64(0); i < params.SignedBlocksWindow; i++ { chunkIndex := i / v4.MissedBlockBitmapChunkSize chunk := store.Get(v4.ValidatorMissedBlockBitmapKey(consAddr, chunkIndex))