diff --git a/CHANGELOG.md b/CHANGELOG.md index 36980f7335..e2cb976818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (sec) [\#1302](https://github.com/Finschia/finschia-sdk/pull/1302) remove map iteration non-determinism with keys + sorting * (client) [\#1303](https://github.com/Finschia/finschia-sdk/pull/1303) fix possible overflow in BuildUnsignedTx * (types) [\#1299](https://github.com/Finschia/finschia-sdk/pull/1299) add missing nil checks +* (x/staking) [\#1301](https://github.com/Finschia/finschia-sdk/pull/1301) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) ### Removed diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index a10de577d8..9c5e5fd003 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -375,9 +375,21 @@ func (k Keeper) DeleteValidatorQueue(ctx sdk.Context, val types.Validator) { addrs := k.GetUnbondingValidators(ctx, val.UnbondingTime, val.UnbondingHeight) newAddrs := []string{} + // since address string may change due to Bech32 prefix change, we parse the addresses into bytes + // format for normalization + deletingAddr, err := sdk.ValAddressFromBech32(val.OperatorAddress) + if err != nil { + panic(err) + } + for _, addr := range addrs { - if addr != val.OperatorAddress { - newAddrs = append(newAddrs, addr) + storedAddr, err := sdk.ValAddressFromBech32(addr) + if err != nil { + // even if we don't panic here, it will panic in UnbondAllMatureValidators at unbond time + panic(err) + } + if !storedAddr.Equals(deletingAddr) { + newAddrs = append(newAddrs, storedAddr.String()) } }