From 77fc6c174273f754754a301ca05f1b36c67fb6df Mon Sep 17 00:00:00 2001 From: William Chong <6198816+williamchong@users.noreply.github.com> Date: Wed, 22 Jun 2022 16:40:19 +0800 Subject: [PATCH 1/3] fix : Use bytes instead of string comparison in delete validator queue (#12303) --- x/staking/keeper/validator.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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()) } } From f67083aa65c45ec3ee46ec58b37f3788dd1277cc Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Tue, 26 Mar 2024 06:22:39 +0000 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f53c61cd4..b2f8ef3d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/collection, x/token) [\#1288](https://github.com/Finschia/finschia-sdk/pull/1288) use accAddress to compare in validatebasic function in collection & token modules * (x/collection) [\#1268](https://github.com/Finschia/finschia-sdk/pull/1268) export x/collection params into genesis * (x/collection) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) reject NFT coins on FT APIs +* (x/staking) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) ### Removed From 156864175ca1232e90636c71b7562e81c2968f63 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Tue, 26 Mar 2024 06:28:52 +0000 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f8ef3d06..c8bca5b411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/collection, x/token) [\#1288](https://github.com/Finschia/finschia-sdk/pull/1288) use accAddress to compare in validatebasic function in collection & token modules * (x/collection) [\#1268](https://github.com/Finschia/finschia-sdk/pull/1268) export x/collection params into genesis * (x/collection) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) reject NFT coins on FT APIs -* (x/staking) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) +* (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