Skip to content

Commit

Permalink
chore: add client status check to verify membership rpc (#5870) (#6106)
Browse files Browse the repository at this point in the history
* chore: add client status check to verify membership rpc

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

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
(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 <damiannolan@gmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
3 people authored Apr 8, 2024
1 parent 2d60802 commit 9419ee8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/core/02-client/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
16 changes: 16 additions & 0 deletions modules/core/02-client/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9419ee8

Please sign in to comment.