File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ BREAKING CHANGES
7373 * [ x/stake] \# 2412 Added an unbonding validator queue to EndBlock to automatically update validator.Status when finished Unbonding
7474 * [ x/stake] \# 2500 Block conflicting redelegations until we add an index
7575 * [ x/params] Global Paramstore refactored
76+ * [ x/stake] \# 2508 Utilize Tendermint power for validator power key
7677
7778* Tendermint
7879 * Update tendermint version from v0.23.0 to v0.25.0, notable changes
Original file line number Diff line number Diff line change @@ -71,8 +71,15 @@ func GetBondedValidatorIndexKey(operator sdk.ValAddress) []byte {
7171func getValidatorPowerRank (validator types.Validator ) []byte {
7272
7373 potentialPower := validator .Tokens
74- powerBytes := []byte (potentialPower .ToLeftPadded (maxDigitsForAccount )) // power big-endian (more powerful validators first)
74+
75+ // todo: deal with cases above 2**64, ref https://github.com/cosmos/cosmos-sdk/issues/2439#issuecomment-427167556
76+ tendermintPower := potentialPower .RoundInt64 ()
77+ tendermintPowerBytes := make ([]byte , 8 )
78+ binary .BigEndian .PutUint64 (tendermintPowerBytes [:], uint64 (tendermintPower ))
79+
80+ powerBytes := tendermintPowerBytes
7581 powerBytesLen := len (powerBytes )
82+
7683 // key is of format prefix || powerbytes || heightBytes || counterBytes
7784 key := make ([]byte , 1 + powerBytesLen + 8 + 2 )
7885
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ func TestGetValidatorPowerRank(t *testing.T) {
3535 validator types.Validator
3636 wantHex string
3737 }{
38- {val1 , "05303030303030303030303030ffffffffffffffffffff " },
39- {val2 , "05303030303030303030303031ffffffffffffffffffff " },
40- {val3 , "05303030303030303030303130ffffffffffffffffffff " },
41- {val4 , "0531303939353131363237373736ffffffffffffffffffff " },
38+ {val1 , "050000000000000000ffffffffffffffffffff " },
39+ {val2 , "050000000000000001ffffffffffffffffffff " },
40+ {val3 , "05000000000000000affffffffffffffffffff " },
41+ {val4 , "050000010000000000ffffffffffffffffffff " },
4242 }
4343 for i , tt := range tests {
4444 got := hex .EncodeToString (getValidatorPowerRank (tt .validator ))
You can’t perform that action at this time.
0 commit comments