-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
GetAllHistoricalInfo
returns wrong order when height goes through 10^n (i.e. number of digits change)
#11463
Comments
@AdityaSripal does this effect IBC? |
Looks like the key is poorly designed, yes. If need be, we can fix it with a migration. |
Yes that is unintended, but as stated, it luckily does not affect IBC. The only place where it could have been an issue is in our pruning logic. Since we prune old historical info once we no longer need it. But we retrieve it by getting each individual historical info here:
Rather than iterating lexicographically. It would be nice to fix this so that the above gets are efficient. But it is not a critical issue |
Can I pick this up? |
Yes please @deepto98! Thanks for all the help :) |
@alexanderbez @AdityaSripal I'm working on this, but am not able to reproduce the exact issue. For me, |
@deepto98 you mean you implemented the test in the issue body and it did not fail for you? |
Hi, I would appreciate some early feedback. The question is - how should we prepare the migration? |
## Description Closes: #11463 --- ### 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] added `!` to the type prefix if API or client breaking change * [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) * [ ] provided a link to the relevant issue or specification * [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) * [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) * [ ] added a changelog entry to `CHANGELOG.md` * [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) * [ ] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) 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)
Summary of Bug
In
staking
module, when the block heights for historical info goes through boundary of 10^n (i.e. number of digits change),GetAllHistoricalInfo
returns the info in wrong order.Reason: the module is using decimal string of the block height as store key for historical info:
So when the number of digits in the decimal string changes, the key order will be wrong:
9, 10, 11
results in10, 11, 9
since this is the character order for the strings.Unfortunately there is no easy fix, since it's related to key format. Doing extra sort in
GetAllHistoricalInfo
will fix this function, but the iterator order can't be fixed.Fortunately
GetAllHistoricalInfo
andIterateHistoricalInfo
are not in use by any code in the SDK (includingibc-go
) other than the test case.So why writing them in the first place?Version
Tested in v0.44.6, suspects that this exists in every version
Steps to Reproduce
Simply change the block heights in
TestGetAllHistoricalInfo
from10, 11, 12
to9, 10, 11
, then the test will fail.Result:
For Admin Use
The text was updated successfully, but these errors were encountered: