Skip to content

Commit 9419ee8

Browse files
mergify[bot]damiannolancrodriguezvega
authored
chore: add client status check to verify membership rpc (#5870) (#6106)
* chore: add client status check to verify membership rpc * Update modules/core/02-client/keeper/grpc_query.go Co-authored-by: DimitrisJim <[email protected]> --------- Co-authored-by: DimitrisJim <[email protected]> (cherry picked from commit 94a4597) # Conflicts: # modules/core/02-client/keeper/grpc_query.go # modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Damian Nolan <[email protected]> Co-authored-by: Carlos Rodriguez <[email protected]>
1 parent 2d60802 commit 9419ee8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

modules/core/02-client/keeper/grpc_query.go

+4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMember
371371
return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrClientNotFound, req.ClientId).Error())
372372
}
373373

374+
if clientStatus := k.GetClientStatus(ctx, clientState, req.ClientId); clientStatus != exported.Active {
375+
return nil, status.Error(codes.FailedPrecondition, errorsmod.Wrapf(types.ErrClientNotActive, "cannot verify membership using client (%s) with status %s", req.ClientId, clientStatus).Error())
376+
}
377+
374378
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 {
375379
k.Logger(ctx).Debug("proof verification failed", "key", req.MerklePath, "error", err)
376380
return &types.QueryVerifyMembershipResponse{

modules/core/02-client/keeper/grpc_query_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,22 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() {
770770
},
771771
types.ErrClientNotFound,
772772
},
773+
{
774+
"client not active",
775+
func() {
776+
params := types.NewParams("") // disable all clients
777+
suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetParams(suite.chainA.GetContext(), params)
778+
779+
req = &types.QueryVerifyMembershipRequest{
780+
ClientId: path.EndpointA.ClientID,
781+
Proof: []byte{0x01},
782+
ProofHeight: types.NewHeight(1, 100),
783+
MerklePath: commitmenttypes.NewMerklePath("/ibc", host.ChannelPath(mock.PortID, ibctesting.FirstChannelID)),
784+
Value: []byte{0x01},
785+
}
786+
},
787+
types.ErrClientNotActive,
788+
},
773789
}
774790

775791
for _, tc := range testCases {

0 commit comments

Comments
 (0)