Skip to content

Staking ValidatorPowerRank should use "Potential Consensus Power" #3985

@rigelrozanski

Description

@rigelrozanski

Referring to "Potential Tendermint Power" as the tokens reduced by a threshold (as is currently used within the ABCI)

func TokensToTendermintPower(tokens Int) int64 {

This issue is followup to this comment in the code which contains incorrect variable names:

func getValidatorPowerRank(validator types.Validator) []byte {
potentialPower := validator.Tokens
// todo: deal with cases above 2**64, ref https://github.com/cosmos/cosmos-sdk/issues/2439#issuecomment-427167556
tendermintPower := potentialPower.Int64()
tendermintPowerBytes := make([]byte, 8)
binary.BigEndian.PutUint64(tendermintPowerBytes[:], uint64(tendermintPower))

Which was referenced recently in #2439


By using the Potential Tendermint Power we remove any Int64 overflow issues, not to mention make the variable names in the code reflective of reality (currently these variable names are misleading/incorrect - this is NOT the tendermint power, the tendermint power is equivalent to Potential Tendermint Power)

CC @alexanderbez @keichiri @cwgoes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions