Skip to content

Commit

Permalink
Merge pull request #5 from neutron-org/fix/slashing-bitmap-migration-key
Browse files Browse the repository at this point in the history
fix: fixed key in slashing bitmap migration
  • Loading branch information
pr0n00gler authored Oct 9, 2023
2 parents efa6493 + 8f3a2ad commit fcccb9a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
4 changes: 1 addition & 3 deletions x/slashing/migrations/v4/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
)

const (
addrLen = 20

MissedBlockBitmapChunkSize = 1024 // 2^10 bits
)

Expand All @@ -32,7 +30,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 @@ -40,10 +40,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 fcccb9a

Please sign in to comment.