Skip to content

Commit f856957

Browse files
dudong20Tech
andauthored
fix: check pubkey type from validator params (#724)
* fix: check pubkey type from validator params * docs: add changelog * test: remove comments * Update CHANGELOG.md Co-authored-by: Youngtaek Yoon <[email protected]> Co-authored-by: Youngtaek Yoon <[email protected]>
1 parent 15168bf commit f856957

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
103103
* (global) [\#694](https://github.com/line/lbm-sdk/pull/694) replace deprecated functions since go 1.16 or 1.17
104104
* (x/bankplus) [\#705](https://github.com/line/lbm-sdk/pull/705) add missing blockedAddr checking in bankplus
105105
* (x/foundation) [\#712](https://github.com/line/lbm-sdk/pull/712) fix x/foundation EndBlocker
106+
* (baseapp) [\#724](https://github.com/line/lbm-sdk/pull/724) add checking pubkey type from validator params
106107
* (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept()
107108

108109
### Breaking Changes

baseapp/params.go

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
abci "github.com/line/ostracon/abci/types"
88
ocproto "github.com/line/ostracon/proto/ostracon/types"
9+
octypes "github.com/line/ostracon/types"
910

1011
sdk "github.com/line/lbm-sdk/types"
1112
)
@@ -82,5 +83,14 @@ func ValidateValidatorParams(i interface{}) error {
8283
return errors.New("validator allowed pubkey types must not be empty")
8384
}
8485

86+
for _, pubKeyType := range v.PubKeyTypes {
87+
switch pubKeyType {
88+
case octypes.ABCIPubKeyTypeBls12WithEd25519, octypes.ABCIPubKeyTypeEd25519, octypes.ABCIPubKeyTypeSecp256k1, octypes.ABCIPubKeyTypeBls12:
89+
continue
90+
default:
91+
return fmt.Errorf("not-allowed pubkey type: %s", pubKeyType)
92+
}
93+
}
94+
8595
return nil
8696
}

baseapp/params_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func TestValidateValidatorParams(t *testing.T) {
5858
{ocproto.ValidatorParams{}, true},
5959
{ocproto.ValidatorParams{PubKeyTypes: []string{}}, true},
6060
{ocproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false},
61+
{ocproto.ValidatorParams{PubKeyTypes: []string{"invalidPubKeyType"}}, true},
6162
}
6263

6364
for _, tc := range testCases {

0 commit comments

Comments
 (0)