From 6b8f602cfb2cc8efdee01a5b41ef4ff98d36e26c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:22:58 +0100 Subject: [PATCH] chore: add client status check to verify membership rpc (#5870) (#5874) * chore: add client status check to verify membership rpc * Update modules/core/02-client/keeper/grpc_query.go Co-authored-by: DimitrisJim --------- Co-authored-by: DimitrisJim (cherry picked from commit 94a4597cf2ec8f6835f31e9b59b57841c6d67ca4) Co-authored-by: Damian Nolan --- modules/core/02-client/keeper/grpc_query.go | 4 ++++ modules/core/02-client/keeper/grpc_query_test.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index cf2714b329e..01cbaacdc2f 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -371,6 +371,10 @@ func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMember return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrClientNotFound, req.ClientId).Error()) } + if clientStatus := k.GetClientStatus(ctx, clientState, req.ClientId); clientStatus != exported.Active { + return nil, status.Error(codes.FailedPrecondition, errorsmod.Wrapf(types.ErrClientNotActive, "cannot verify membership using client (%s) with status %s", req.ClientId, clientStatus).Error()) + } + if err := clientState.VerifyMembership(cachedCtx, k.ClientStore(cachedCtx, req.ClientId), k.cdc, req.ProofHeight, req.TimeDelay, req.BlockDelay, req.Proof, req.MerklePath, req.Value); err != nil { k.Logger(ctx).Debug("proof verification failed", "key", req.MerklePath, "error", err) return &types.QueryVerifyMembershipResponse{ diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 2b0eb21ba6b..75520f1935c 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -770,6 +770,22 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { }, types.ErrClientNotFound, }, + { + "client not active", + func() { + params := types.NewParams("") // disable all clients + suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetParams(suite.chainA.GetContext(), params) + + req = &types.QueryVerifyMembershipRequest{ + ClientId: path.EndpointA.ClientID, + Proof: []byte{0x01}, + ProofHeight: types.NewHeight(1, 100), + MerklePath: commitmenttypes.NewMerklePath("/ibc", host.ChannelPath(mock.PortID, ibctesting.FirstChannelID)), + Value: []byte{0x01}, + } + }, + types.ErrClientNotActive, + }, } for _, tc := range testCases {