diff --git a/CHANGELOG.md b/CHANGELOG.md index e00026e5d3..31e9bdfb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,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 +* (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept() ### Breaking Changes * (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 0771786db5..8d694064a8 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -94,7 +94,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe } } - if !isValidatorExists { + if len(allowedList) > 0 && !isValidatorExists { return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validatorAddress) } diff --git a/x/staking/types/authz_test.go b/x/staking/types/authz_test.go index d425dc358d..87a98a2bae 100644 --- a/x/staking/types/authz_test.go +++ b/x/staking/types/authz_test.go @@ -121,7 +121,20 @@ func TestAuthzAuthorizations(t *testing.T) { false, nil, }, - + { + "delegate: testing with a validator out of denylist", + []sdk.ValAddress{}, + []sdk.ValAddress{val1}, + stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, + nil, + stakingtypes.NewMsgDelegate(delAddr, val2, coin100), + false, + false, + &stakingtypes.StakeAuthorization{ + Validators: &stakingtypes.StakeAuthorization_DenyList{ + DenyList: &stakingtypes.StakeAuthorization_Validators{Address: []string{val1.String()}}, + }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE}, + }, { "undelegate: expect 0 remaining coins", []sdk.ValAddress{val1, val2},