-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
x/staking ValidatorPowerRank will have incorrect orderings #2439
Comments
Hmm, I wonder if we should actually rank validators by Tendermint power ( |
Good catch, since we send TM updates in ABCI power (rounded), it seems to make sense. |
How do we go from decimal / int to Tendermint power? |
https://github.com/cosmos/cosmos-sdk/blob/develop/x/stake/types/validator.go#L313 |
I do agree with making what is stored in the key align with tendermint power, depending on the implementation of tendermint power. AFAICT the implementation for deriving tendermint power is broken. (It may not surface as an issue on the hub for a few years though, but it will surface in other chains almost immediately)
We should instead make the tendermint power either a |
or alternatively we could always just use a different base unit (aka order by atoms not nano-atoms) - def don't think we need to be making TendermintPower an This bug probably describes some of the weirdo ordering bugs that were cropping up previously - correcting this should be priority - I'd say should probably be 0.25 |
That latter of what you suggested @ValarDragon just sounds overly complex imo. Using a different unit or type sounds like the more straight forward approach. |
What I described was making the You made a good point though Rigel, we could just fix a base unit, theres not really a need for dynamic updates. Governance can control this bit range via param updates, and we can get it from the Int / Dec with pretty straightforward bitmasks. |
I suppose we don't have to worry about infinitesimal amounts as this is for the validator power store, right? |
This is also for consensus. The amounts being negligible compared to MSB is why we don't have to worry about it. (One third attack success rate would be computed off of these truncated numbers. The thing is, if you can succeed with the truncation, you could succeed in the normal case with a negligible increase in money you have) |
Closing this in favor of #2513 |
Hello, this issue does not seem to be solved with the issue that this one got closed in favor of. cosmos-sdk/x/staking/keeper/key.go Line 76 in ea46da7
This part is causing the problems for us, when validators have large amount of tokens staked, in our case e.g. 20000000000000000000000 (we use a lot of decimal places) Is this planned to be reopened in future? |
/cc @rigelrozanski |
opened up a new issue for this #3985, worth resolving soon |
…osmos#2439) Bumps [github.com/ory/dockertest/v3](https://github.com/ory/dockertest) from 3.9.1 to 3.10.0. - [Release notes](https://github.com/ory/dockertest/releases) - [Commits](ory/dockertest@v3.9.1...v3.10.0) --- updated-dependencies: - dependency-name: github.com/ory/dockertest/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Summary of Bug
This issue is demonstrated quite clearly in: https://github.com/cosmos/cosmos-sdk/pull/2438/files#diff-1fe0bb213f8721408b446de8df30add8R41
Basically, we don't do fixed length encoding for the decimals. Therefore a greater decimal will be longer. However, this doesn't preserve ordering as we'd like. From the linked example, the first line corresponds to
tokens=1
, and the secondtokens=2^40
:The
tokens=1
case will occur first in the iteration, since theff
occurs first.Solution
The solution to this is to create a fixed size byte encoding of decimals. At the same time, we should change the encoding to be more sensible for keys. Currently it converts to a string, and then casts to
[]byte
. Thats good for UI's, not for encoding to state. (You see the0
decimal encoded as a30
in the above hex)The text was updated successfully, but these errors were encountered: