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) #1301

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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)
0Tech marked this conversation as resolved.
Show resolved Hide resolved

### 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#L389

Added line #L389 was not covered by tests
}
if !storedAddr.Equals(deletingAddr) {
newAddrs = append(newAddrs, storedAddr.String())
}
}

Expand Down
Loading