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

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

williamchong
Copy link
Contributor

@williamchong williamchong commented Jun 20, 2022

Description

We had a chain upgrade that introduced bech32 prefix change and dual prefix support in our cosmos-sdk fork, and after ~21 days of running the upgrade, our chain halted due to this issue. Details of our chain halt incident can be found here

The root issue is in x/staking, DeleteValidatorQueue does a string comparison instead of bytes, which would cause panic when dequeueing validator if the address string format is changed (in our case, default bech32 prefix changed).

I am not sure if this should be considered as a useful fix for general case, since changing bech32 prefix and dual prefix support seems not common. I am also not sure how to write a test without introducing our own dual prefix support feature.

Feel free to comment how would you like to handle this PR.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@williamchong williamchong requested a review from a team as a code owner June 20, 2022 10:10
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is totally acceptable. Thanks for contributing @williamchong :)

Can you please add a quick changelog entry under "improvements" or maybe it should go under "bug fixes".

@alexanderbez
Copy link
Contributor

@williamchong can you rebase the PR please or allow the core team to do it?

@williamchong williamchong force-pushed the feature/fix-validator-queue branch 2 times, most recently from 99ad490 to 2428b21 Compare June 21, 2022 17:21
@williamchong
Copy link
Contributor Author

@williamchong can you rebase the PR please or allow the core team to do it?

sure and rebased

@alexanderbez
Copy link
Contributor

@marbar3778 how does a contributor allow owners to rebase/update themselves again?

@aaronc
Copy link
Member

aaronc commented Jun 21, 2022

@marbar3778 how does a contributor allow owners to rebase/update themselves again?

There should be a button for them in the sidebar

@williamchong williamchong force-pushed the feature/fix-validator-queue branch from 2428b21 to 9bdc5c9 Compare June 21, 2022 21:00
@williamchong
Copy link
Contributor Author

@marbar3778 how does a contributor allow owners to rebase/update themselves again?

There should be a button for them in the sidebar

Can't see the option there, maybe because I am opening this PR from a fork under org account?
Anyway rebased again

@alexanderbez
Copy link
Contributor

It's out of date again haha. Best to figure out how to enable that option in the likecoin org 👍 🙏

@williamchong williamchong force-pushed the feature/fix-validator-queue branch from 9bdc5c9 to 733f629 Compare June 21, 2022 23:26
@codecov
Copy link

codecov bot commented Jun 21, 2022

Codecov Report

Merging #12303 (733f629) into main (bd31b7c) will decrease coverage by 0.38%.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12303      +/-   ##
==========================================
- Coverage   66.54%   66.16%   -0.39%     
==========================================
  Files         689      675      -14     
  Lines       72357    71262    -1095     
==========================================
- Hits        48147    47147    -1000     
+ Misses      21544    21473      -71     
+ Partials     2666     2642      -24     
Impacted Files Coverage Δ
x/staking/keeper/validator.go 86.39% <54.54%> (-1.33%) ⬇️
depinject/errors.go
depinject/simple.go
depinject/module_dep.go
depinject/struct_args.go
depinject/location.go
depinject/group.go
depinject/container.go
depinject/supply.go
depinject/config.go
... and 5 more

@tac0turtle tac0turtle merged commit 84a0e71 into cosmos:main Jun 22, 2022
0Tech added a commit to Finschia/finschia-sdk that referenced this pull request Mar 26, 2024
… (backport cosmos/cosmos-sdk#12303) (#1301)

* fix : Use bytes instead of string comparison in delete validator queue (#12303)

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com>
mergify bot pushed a commit to Finschia/finschia-sdk that referenced this pull request Mar 26, 2024
… (backport cosmos/cosmos-sdk#12303) (#1301)

* fix : Use bytes instead of string comparison in delete validator queue (#12303)

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com>
(cherry picked from commit 1038a39)

# Conflicts:
#	CHANGELOG.md
0Tech added a commit to Finschia/finschia-sdk that referenced this pull request Mar 29, 2024
… (backport cosmos/cosmos-sdk#12303) (backport #1301) (#1309)

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

* fix : Use bytes instead of string comparison in delete validator queue (#12303)

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com>
(cherry picked from commit 1038a39)

# Conflicts:
#	CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Youngtaek Yoon <noreply@yoon.mailer.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants