From 2fff828b7fd801e4936a5e5aafcd8cd2efdb6c53 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Mon, 17 Oct 2022 23:17:36 +0900 Subject: [PATCH 1/2] fix: check allowedList size in StakeAuthorization.Accept --- x/staking/types/authz.go | 2 +- x/staking/types/authz_test.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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}, From 4d2b5d465918257a9dc343b7052090a085bc39a2 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Tue, 18 Oct 2022 00:17:53 +0900 Subject: [PATCH 2/2] docs: add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcf04b11c2..554880c327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/foundation) [\#687](https://github.com/line/lbm-sdk/pull/687) fix bugs on aborting x/foundation proposals * (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/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