Skip to content

Commit

Permalink
imp(staking): use the constant for the ed25519 pubkey type
Browse files Browse the repository at this point in the history
  • Loading branch information
luchenqun committed Nov 20, 2023
1 parent 78a7467 commit de5a9dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var (

// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
DefaultPowerReduction = sdkmath.NewIntFromUint64(1000000)

// PubKeyEd25519Type is ed25519 for type the consensus params validator pub_key_types params
PubKeyEd25519Type = "ed25519"
)

// TokensToConsensusPower - convert input tokens to potential consensus-engine power
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali
)
}

if pkType == "ed25519" && len(pk.Bytes()) != ed25519.PubKeySize {
if pkType == sdk.PubKeyEd25519Type && len(pk.Bytes()) != ed25519.PubKeySize {
return nil, errorsmod.Wrapf(
types.ErrConsensusPubKeyLenInvalid,
"got: %d, expected: %d", len(pk.Bytes()), ed25519.PubKeySize,
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *KeeperTestSuite) TestMsgCreateValidator() {

ctx = ctx.WithConsensusParams(cmtproto.ConsensusParams{
Validator: &cmtproto.ValidatorParams{
PubKeyTypes: []string{"ed25519"},
PubKeyTypes: []string{sdk.PubKeyEd25519Type},
},
})

Expand Down

0 comments on commit de5a9dd

Please sign in to comment.