diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb171aea7..8a6262a3a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (global) [\#694](https://github.com/line/lbm-sdk/pull/694) replace deprecated functions since go 1.16 or 1.17 * (x/bankplus) [\#705](https://github.com/line/lbm-sdk/pull/705) add missing blockedAddr checking in bankplus * (x/foundation) [\#712](https://github.com/line/lbm-sdk/pull/712) fix x/foundation EndBlocker +* (baseapp) [\#724](https://github.com/line/lbm-sdk/pull/724) add checking pubkey type from validator params * (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept() ### Breaking Changes diff --git a/baseapp/params.go b/baseapp/params.go index 502955412d..061c6a17ed 100644 --- a/baseapp/params.go +++ b/baseapp/params.go @@ -6,6 +6,7 @@ import ( abci "github.com/line/ostracon/abci/types" ocproto "github.com/line/ostracon/proto/ostracon/types" + octypes "github.com/line/ostracon/types" sdk "github.com/line/lbm-sdk/types" ) @@ -82,5 +83,14 @@ func ValidateValidatorParams(i interface{}) error { return errors.New("validator allowed pubkey types must not be empty") } + for _, pubKeyType := range v.PubKeyTypes { + switch pubKeyType { + case octypes.ABCIPubKeyTypeBls12WithEd25519, octypes.ABCIPubKeyTypeEd25519, octypes.ABCIPubKeyTypeSecp256k1, octypes.ABCIPubKeyTypeBls12: + continue + default: + return fmt.Errorf("not-allowed pubkey type: %s", pubKeyType) + } + } + return nil } diff --git a/baseapp/params_test.go b/baseapp/params_test.go index a421d13b65..340be7097a 100644 --- a/baseapp/params_test.go +++ b/baseapp/params_test.go @@ -58,6 +58,7 @@ func TestValidateValidatorParams(t *testing.T) { {ocproto.ValidatorParams{}, true}, {ocproto.ValidatorParams{PubKeyTypes: []string{}}, true}, {ocproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false}, + {ocproto.ValidatorParams{PubKeyTypes: []string{"invalidPubKeyType"}}, true}, } for _, tc := range testCases {