-
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
R4R: Fix validator power key #2508
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2508 +/- ##
=======================================
Coverage 60% 60%
=======================================
Files 151 151
Lines 8844 8844
=======================================
Hits 5307 5307
Misses 3167 3167
Partials 370 370 |
Ref #2509 as a followup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -71,8 +71,15 @@ func GetBondedValidatorIndexKey(operator sdk.ValAddress) []byte { | |||
func getValidatorPowerRank(validator types.Validator) []byte { | |||
|
|||
potentialPower := validator.Tokens | |||
powerBytes := []byte(potentialPower.ToLeftPadded(maxDigitsForAccount)) // power big-endian (more powerful validators first) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can to delete ToLeftPadded
now I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it could be useful in general for other serialization purposes though.
// todo: deal with cases above 2**64, ref https://github.com/cosmos/cosmos-sdk/issues/2439#issuecomment-427167556 | ||
tendermintPower := potentialPower.RoundInt64() | ||
tendermintPowerBytes := make([]byte, 8) | ||
binary.BigEndian.PutUint64(tendermintPowerBytes[:], uint64(tendermintPower)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the approach we want to take. Now we lose sorting past the tmpower. Instead we should make the entire Decimal/Int get marshalled in constant size for the store key, imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe... what's the benefit of sorting past TM power precision?
(I agree with changing how TM power is calculated as was discussed in the issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per discussion in slack, I now agree. Lets only use tmpower everywhere.
Ref #2439, although it doesn't address all of that issue (only fixing the current key, not changing the Tendermint power calculation).
docs/
)PENDING.md
with issue #Files changed
in the github PR explorerFor Admin Use: