Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) (backport #1301) #1309

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 14 additions & 2 deletions x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,21 @@
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)

Check warning on line 382 in x/staking/keeper/validator.go

View check run for this annotation

Codecov / codecov/patch

x/staking/keeper/validator.go#L382

Added line #L382 was not covered by tests
}

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)

Check warning on line 389 in x/staking/keeper/validator.go

View check run for this annotation

Codecov / codecov/patch

x/staking/keeper/validator.go#L388-L389

Added lines #L388 - L389 were not covered by tests
}
if !storedAddr.Equals(deletingAddr) {
newAddrs = append(newAddrs, storedAddr.String())
}
}

Expand Down
Loading