Skip to content

Commit

Permalink
fix: fixed key in slashing bitmap migration (backport #18016) (#18033)
Browse files Browse the repository at this point in the history
Co-authored-by: swelf19 <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent 95c0083 commit 8ab33f5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion x/slashing/migrations/v4/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions x/slashing/migrations/v4/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8ab33f5

Please sign in to comment.