-
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
Possible inconsistency in LooseTokens #1870
Comments
Wow, great catch! ref #1471 /cc @rigelrozanski , @cwgoes |
Yup, this needs to be fixed - ref #1807. |
I guess we just need to double check whether or not this is still a concern with the decimal implementation. |
We should verify this once staking refactor has been completed. |
This is still an issue; the staking refactor did not change the delegation/undelegation logic. |
I think we need to change the approach here altogether, this seems like an attack vector - if it's possible to get "extra" tokens by rounding, there's likely some way to create such delegations en masse and mint currency. Either we need to round down instead, or we need to restrict unbonding to whole-token amounts. |
rounding down seems fine for now... |
OK, let's also update the pool accordingly so supply tracking remains consistent. |
I think rounding down is fine because this is going to be such a fractionally small amount of tokens (10^-8 of an atom) should be okay |
Summary of Bug
When a validator is slashed and an individual share is is now a floating point number like 1.6 a delegator will get
2 steaks
back when he unrevokes because of bankers rounding.cosmos-sdk/x/stake/keeper/delegation.go
Line 331 in c9936b3
However LooseTokens will only be incremented by the Rat value of
1.6
cosmos-sdk/x/stake/types/validator.go
Lines 398 to 404 in c9936b3
cosmos-sdk/x/stake/types/pool.go
Line 73 in c9936b3
This will lead to an inconsistency between the real staking tokens in circulation and LooseTokens.
For Admin Use
The text was updated successfully, but these errors were encountered: