From da1ddfc7b7edd2f82bb495596a0065bace967b23 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 11 Jun 2022 22:23:33 +0200 Subject: [PATCH] chore: Add consensus state heights query (backport #1336) (#1507) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Add consensus state heights query (#1336) * add ConsensusStateHeights query * add cli for ConsensusStateHeights Query * update CHANGELOG.md * Update modules/core/02-client/keeper/grpc_query.go Co-authored-by: Damian Nolan * Update modules/core/02-client/client/cli/query.go Co-authored-by: Damian Nolan * Update modules/core/02-client/client/cli/query.go Co-authored-by: Damian Nolan * Update modules/core/02-client/client/cli/query.go Co-authored-by: Damian Nolan * update consensus height query * very minor changes in modules/core/02-client grpc_query_test * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Sean King * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Sean King * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Sean King * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Sean King * Update modules/core/02-client/client/cli/query.go Co-authored-by: Sean King * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Carlos Rodriguez * Update CHANGELOG.md Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * update swagger.yaml; update 02-client grpc_query_test * Update modules/core/02-client/keeper/grpc_query_test.go Co-authored-by: Damian Nolan * nit Co-authored-by: Damian Nolan Co-authored-by: Sean King Co-authored-by: Carlos Rodriguez Co-authored-by: vuong <56973102+vuong177@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> (cherry picked from commit 042d8187d751bdacdecbb1e730f3dc09da24caed) # Conflicts: # CHANGELOG.md # docs/client/swagger-ui/swagger.yaml * fix conflicts and change gRPC web route to consensus_state/{client_id}/heights Co-authored-by: khanh <50263489+catShaark@users.noreply.github.com> Co-authored-by: crodriguezvega --- CHANGELOG.md | 3 +- docs/client/swagger-ui/swagger.yaml | 411 ++++++++++- docs/ibc/proto-docs.md | 37 + modules/core/02-client/client/cli/cli.go | 1 + modules/core/02-client/client/cli/query.go | 43 ++ modules/core/02-client/keeper/grpc_query.go | 40 ++ .../core/02-client/keeper/grpc_query_test.go | 154 +++- modules/core/02-client/types/query.pb.go | 663 ++++++++++++++++-- modules/core/02-client/types/query.pb.gw.go | 116 +++ modules/core/keeper/grpc_query.go | 5 + proto/ibc/core/client/v1/query.proto | 23 + 11 files changed, 1388 insertions(+), 108 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c02e65b614..c991fc8689e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features -* (modules/apps/transfer) [\#1416](https://github.com/cosmos/ibc-go/pull/1416) Adding gRPC endpoint for getting an escrow account for a given port-id and channel-id. +* (modules/core/02-client) [\#1336](https://github.com/cosmos/ibc-go/pull/1336) Adding Query/ConsensusStateHeights gRPC for fetching the height of every consensus state associated with a client. +* (modules/apps/transfer) [\#1416](https://github.com/cosmos/ibc-go/pull/1416) Adding gRPC endpoint for getting an escrow account for a given port-id and channel-id. ### Bug Fixes diff --git a/docs/client/swagger-ui/swagger.yaml b/docs/client/swagger-ui/swagger.yaml index f575e4b641d..51541bcc941 100644 --- a/docs/client/swagger-ui/swagger.yaml +++ b/docs/client/swagger-ui/swagger.yaml @@ -2188,6 +2188,331 @@ paths: + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: client_id + description: client identifier + in: path + required: true + type: string + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + format: boolean + tags: + - Query + '/ibc/core/client/v1/consensus_states/{client_id}/heights': + get: + summary: >- + ConsensusStateHeights queries the height of every consensus states + associated with a given client. + operationId: ConsensusStateHeights + responses: + '200': + description: A successful response. + schema: + type: object + properties: + consensus_state_heights: + type: array + items: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms + may choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes + of updating and + + freezing clients + title: consensus state heights + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryConsensusStateHeightsResponse is the response type for the + Query/ConsensusStateHeights RPC method + default: + description: An unexpected error response + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := ptypes.MarshalAny(foo) + ... + foo := &pb.Foo{} + if err := ptypes.UnmarshalAny(any, foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON ==== @@ -2475,7 +2800,6 @@ paths: format: byte title: merkle proof of existence proof_height: - title: height at which the proof was retrieved type: object properties: revision_number: @@ -2503,6 +2827,13 @@ paths: RevisionHeight gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes + of updating and + + freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState @@ -11067,6 +11398,76 @@ definitions: RPC method. It returns the current status of the IBC client. + ibc.core.client.v1.QueryConsensusStateHeightsResponse: + type: object + properties: + consensus_state_heights: + type: array + items: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is incremented + so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of + updating and + + freezing clients + title: consensus state heights + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryConsensusStateHeightsResponse is the response type for the + Query/ConsensusStateHeights RPC method ibc.core.client.v1.QueryConsensusStateResponse: type: object properties: @@ -11237,7 +11638,6 @@ definitions: format: byte title: merkle proof of existence proof_height: - title: height at which the proof was retrieved type: object properties: revision_number: @@ -11264,6 +11664,13 @@ definitions: RevisionHeight gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of + updating and + + freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 5f4a7169a9c..f23c000155a 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -147,6 +147,8 @@ - [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) - [QueryClientStatusRequest](#ibc.core.client.v1.QueryClientStatusRequest) - [QueryClientStatusResponse](#ibc.core.client.v1.QueryClientStatusResponse) + - [QueryConsensusStateHeightsRequest](#ibc.core.client.v1.QueryConsensusStateHeightsRequest) + - [QueryConsensusStateHeightsResponse](#ibc.core.client.v1.QueryConsensusStateHeightsResponse) - [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) - [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) - [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) @@ -2324,6 +2326,40 @@ method. It returns the current status of the IBC client. + + +### QueryConsensusStateHeightsRequest +QueryConsensusStateHeightsRequest is the request type for Query/ConsensusStateHeights +RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_id` | [string](#string) | | client identifier | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request | + + + + + + + + +### QueryConsensusStateHeightsResponse +QueryConsensusStateHeightsResponse is the response type for the +Query/ConsensusStateHeights RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `consensus_state_heights` | [Height](#ibc.core.client.v1.Height) | repeated | consensus state heights | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination response | + + + + + + ### QueryConsensusStateRequest @@ -2467,6 +2503,7 @@ Query provides defines the gRPC querier service | `ClientStates` | [QueryClientStatesRequest](#ibc.core.client.v1.QueryClientStatesRequest) | [QueryClientStatesResponse](#ibc.core.client.v1.QueryClientStatesResponse) | ClientStates queries all the IBC light clients of a chain. | GET|/ibc/core/client/v1/client_states| | `ConsensusState` | [QueryConsensusStateRequest](#ibc.core.client.v1.QueryConsensusStateRequest) | [QueryConsensusStateResponse](#ibc.core.client.v1.QueryConsensusStateResponse) | ConsensusState queries a consensus state associated with a client state at a given height. | GET|/ibc/core/client/v1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height}| | `ConsensusStates` | [QueryConsensusStatesRequest](#ibc.core.client.v1.QueryConsensusStatesRequest) | [QueryConsensusStatesResponse](#ibc.core.client.v1.QueryConsensusStatesResponse) | ConsensusStates queries all the consensus state associated with a given client. | GET|/ibc/core/client/v1/consensus_states/{client_id}| +| `ConsensusStateHeights` | [QueryConsensusStateHeightsRequest](#ibc.core.client.v1.QueryConsensusStateHeightsRequest) | [QueryConsensusStateHeightsResponse](#ibc.core.client.v1.QueryConsensusStateHeightsResponse) | ConsensusStateHeights queries the height of every consensus states associated with a given client. | GET|/ibc/core/client/v1/consensus_states/{client_id}/heights| | `ClientStatus` | [QueryClientStatusRequest](#ibc.core.client.v1.QueryClientStatusRequest) | [QueryClientStatusResponse](#ibc.core.client.v1.QueryClientStatusResponse) | Status queries the status of an IBC client. | GET|/ibc/core/client/v1/client_status/{client_id}| | `ClientParams` | [QueryClientParamsRequest](#ibc.core.client.v1.QueryClientParamsRequest) | [QueryClientParamsResponse](#ibc.core.client.v1.QueryClientParamsResponse) | ClientParams queries all parameters of the ibc client. | GET|/ibc/client/v1/params| | `UpgradedClientState` | [QueryUpgradedClientStateRequest](#ibc.core.client.v1.QueryUpgradedClientStateRequest) | [QueryUpgradedClientStateResponse](#ibc.core.client.v1.QueryUpgradedClientStateResponse) | UpgradedClientState queries an Upgraded IBC light client. | GET|/ibc/core/client/v1/upgraded_client_states| diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index be33557d7ed..d06977016bd 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -22,6 +22,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryClientState(), GetCmdQueryClientStatus(), GetCmdQueryConsensusStates(), + GetCmdQueryConsensusStateHeights(), GetCmdQueryConsensusState(), GetCmdQueryHeader(), GetCmdSelfConsensusState(), diff --git a/modules/core/02-client/client/cli/query.go b/modules/core/02-client/client/cli/query.go index d5e18679a28..56093a8368f 100644 --- a/modules/core/02-client/client/cli/query.go +++ b/modules/core/02-client/client/cli/query.go @@ -164,6 +164,49 @@ func GetCmdQueryConsensusStates() *cobra.Command { return cmd } +// GetCmdQueryConsensusStateHeights defines the command to query the heights of all client consensus states associated with the +// provided client ID. +func GetCmdQueryConsensusStateHeights() *cobra.Command { + cmd := &cobra.Command{ + Use: "consensus-state-heights [client-id]", + Short: "Query the heights of all consensus states of a client.", + Long: "Query the heights of all consensus states associated with the provided client ID.", + Example: fmt.Sprintf("%s query %s %s consensus-state-heights [client-id]", version.AppName, host.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + clientID := args[0] + + queryClient := types.NewQueryClient(clientCtx) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + req := &types.QueryConsensusStateHeightsRequest{ + ClientId: clientID, + Pagination: pageReq, + } + + res, err := queryClient.ConsensusStateHeights(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "consensus state heights") + + return cmd +} + // GetCmdQueryConsensusState defines the command to query the consensus state of // the chain as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#query func GetCmdQueryConsensusState() *cobra.Command { diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index d4a2eca5a4f..38b69fd94e6 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -188,6 +188,46 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat }, nil } +// ConsensusStateHeights implements the Query/ConsensusStateHeights gRPC method +func (q Keeper) ConsensusStateHeights(c context.Context, req *types.QueryConsensusStateHeightsRequest) (*types.QueryConsensusStateHeightsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ClientIdentifierValidator(req.ClientId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + ctx := sdk.UnwrapSDKContext(c) + + var consensusStateHeights []types.Height + store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) + + pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, _ []byte, accumulate bool) (bool, error) { + // filter any metadata stored under consensus state key + if bytes.Contains(key, []byte("/")) { + return false, nil + } + + height, err := types.ParseHeight(string(key)) + if err != nil { + return false, err + } + + consensusStateHeights = append(consensusStateHeights, height) + return true, nil + }) + + if err != nil { + return nil, err + } + + return &types.QueryConsensusStateHeightsResponse{ + ConsensusStateHeights: consensusStateHeights, + Pagination: pageRes, + }, nil +} + // ClientStatus implements the Query/ClientStatus gRPC method func (q Keeper) ClientStatus(c context.Context, req *types.QueryClientStatusRequest) (*types.QueryClientStatusResponse, error) { if req == nil { diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 5e393c33a97..a6df44e2820 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "fmt" - "time" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,7 +10,6 @@ import ( "google.golang.org/grpc/metadata" "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" @@ -294,7 +292,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { func (suite *KeeperTestSuite) TestQueryConsensusStates() { var ( req *types.QueryConsensusStatesRequest - expConsensusStates = []types.ConsensusStateWithHeight{} + expConsensusStates []types.ConsensusStateWithHeight ) testCases := []struct { @@ -303,14 +301,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { expPass bool }{ { - "invalid client identifier", - func() { - req = &types.QueryConsensusStatesRequest{} - }, - false, - }, - { - "empty pagination", + "success: without pagination", func() { req = &types.QueryConsensusStatesRequest{ ClientId: testClientID, @@ -334,29 +325,30 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { { "success", func() { - cs := ibctmtypes.NewConsensusState( - suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil, - ) - cs2 := ibctmtypes.NewConsensusState( - suite.consensusState.Timestamp.Add(time.Second), commitmenttypes.NewMerkleRoot([]byte("hash2")), nil, - ) - - clientState := ibctmtypes.NewClientState( - testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, - ) - - // Use CreateClient to ensure that processedTime metadata gets stored. - clientId, err := suite.keeper.CreateClient(suite.ctx, clientState, cs) + path := ibctesting.NewPath(suite.chainA, suite.chainB) + suite.coordinator.SetupClients(path) + + height1 := path.EndpointA.GetClientState().GetLatestHeight().(types.Height) + expConsensusStates = append( + expConsensusStates, + types.NewConsensusStateWithHeight( + height1, + path.EndpointA.GetConsensusState(height1), + )) + + err := path.EndpointA.UpdateClient() suite.Require().NoError(err) - suite.keeper.SetClientConsensusState(suite.ctx, clientId, testClientHeight.Increment(), cs2) - // order is swapped because the res is sorted by client id - expConsensusStates = []types.ConsensusStateWithHeight{ - types.NewConsensusStateWithHeight(testClientHeight, cs), - types.NewConsensusStateWithHeight(testClientHeight.Increment().(types.Height), cs2), - } + height2 := path.EndpointA.GetClientState().GetLatestHeight().(types.Height) + expConsensusStates = append( + expConsensusStates, + types.NewConsensusStateWithHeight( + height2, + path.EndpointA.GetConsensusState(height2), + )) + req = &types.QueryConsensusStatesRequest{ - ClientId: clientId, + ClientId: path.EndpointA.ClientID, Pagination: &query.PageRequest{ Limit: 3, CountTotal: true, @@ -365,6 +357,13 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }, true, }, + { + "invalid client identifier", + func() { + req = &types.QueryConsensusStatesRequest{} + }, + false, + }, } for _, tc := range testCases { @@ -372,9 +371,8 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { suite.SetupTest() // reset tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - - res, err := suite.queryClient.ConsensusStates(ctx, req) + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.chainA.QueryServer.ConsensusStates(ctx, req) if tc.expPass { suite.Require().NoError(err) @@ -395,6 +393,94 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { } } +func (suite *KeeperTestSuite) TestQueryConsensusStateHeights() { + var ( + req *types.QueryConsensusStateHeightsRequest + expConsensusStateHeights []types.Height + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "success: without pagination", + func() { + req = &types.QueryConsensusStateHeightsRequest{ + ClientId: testClientID, + } + }, + true, + }, + { + "success: response contains no results", + func() { + req = &types.QueryConsensusStateHeightsRequest{ + ClientId: testClientID, + Pagination: &query.PageRequest{ + Limit: 3, + CountTotal: true, + }, + } + }, + true, + }, + { + "success: returns consensus heights", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + suite.coordinator.SetupClients(path) + + expConsensusStateHeights = append(expConsensusStateHeights, path.EndpointA.GetClientState().GetLatestHeight().(types.Height)) + + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + expConsensusStateHeights = append(expConsensusStateHeights, path.EndpointA.GetClientState().GetLatestHeight().(types.Height)) + + req = &types.QueryConsensusStateHeightsRequest{ + ClientId: path.EndpointA.ClientID, + Pagination: &query.PageRequest{ + Limit: 3, + CountTotal: true, + }, + } + }, + true, + }, + { + "invalid client identifier", + func() { + req = &types.QueryConsensusStateHeightsRequest{} + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.chainA.QueryServer.ConsensusStateHeights(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(len(expConsensusStateHeights), len(res.ConsensusStateHeights)) + for i := range expConsensusStateHeights { + suite.Require().NotNil(res.ConsensusStateHeights[i]) + suite.Require().Equal(expConsensusStateHeights[i], res.ConsensusStateHeights[i]) + } + } else { + suite.Require().Error(err) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryClientStatus() { var ( req *types.QueryClientStatusRequest diff --git a/modules/core/02-client/types/query.pb.go b/modules/core/02-client/types/query.pb.go index 7ea1d377be6..bcb5ccd498e 100644 --- a/modules/core/02-client/types/query.pb.go +++ b/modules/core/02-client/types/query.pb.go @@ -500,6 +500,118 @@ func (m *QueryConsensusStatesResponse) GetPagination() *query.PageResponse { return nil } +// QueryConsensusStateHeightsRequest is the request type for Query/ConsensusStateHeights +// RPC method. +type QueryConsensusStateHeightsRequest struct { + // client identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // pagination request + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryConsensusStateHeightsRequest) Reset() { *m = QueryConsensusStateHeightsRequest{} } +func (m *QueryConsensusStateHeightsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConsensusStateHeightsRequest) ProtoMessage() {} +func (*QueryConsensusStateHeightsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{8} +} +func (m *QueryConsensusStateHeightsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsensusStateHeightsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsensusStateHeightsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryConsensusStateHeightsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsensusStateHeightsRequest.Merge(m, src) +} +func (m *QueryConsensusStateHeightsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConsensusStateHeightsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsensusStateHeightsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsensusStateHeightsRequest proto.InternalMessageInfo + +func (m *QueryConsensusStateHeightsRequest) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *QueryConsensusStateHeightsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryConsensusStateHeightsResponse is the response type for the +// Query/ConsensusStateHeights RPC method +type QueryConsensusStateHeightsResponse struct { + // consensus state heights + ConsensusStateHeights []Height `protobuf:"bytes,1,rep,name=consensus_state_heights,json=consensusStateHeights,proto3" json:"consensus_state_heights"` + // pagination response + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryConsensusStateHeightsResponse) Reset() { *m = QueryConsensusStateHeightsResponse{} } +func (m *QueryConsensusStateHeightsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConsensusStateHeightsResponse) ProtoMessage() {} +func (*QueryConsensusStateHeightsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{9} +} +func (m *QueryConsensusStateHeightsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsensusStateHeightsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsensusStateHeightsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryConsensusStateHeightsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsensusStateHeightsResponse.Merge(m, src) +} +func (m *QueryConsensusStateHeightsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConsensusStateHeightsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsensusStateHeightsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsensusStateHeightsResponse proto.InternalMessageInfo + +func (m *QueryConsensusStateHeightsResponse) GetConsensusStateHeights() []Height { + if m != nil { + return m.ConsensusStateHeights + } + return nil +} + +func (m *QueryConsensusStateHeightsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryClientStatusRequest is the request type for the Query/ClientStatus RPC // method type QueryClientStatusRequest struct { @@ -511,7 +623,7 @@ func (m *QueryClientStatusRequest) Reset() { *m = QueryClientStatusReque func (m *QueryClientStatusRequest) String() string { return proto.CompactTextString(m) } func (*QueryClientStatusRequest) ProtoMessage() {} func (*QueryClientStatusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{8} + return fileDescriptor_dc42cdfd1d52d76e, []int{10} } func (m *QueryClientStatusRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -557,7 +669,7 @@ func (m *QueryClientStatusResponse) Reset() { *m = QueryClientStatusResp func (m *QueryClientStatusResponse) String() string { return proto.CompactTextString(m) } func (*QueryClientStatusResponse) ProtoMessage() {} func (*QueryClientStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{9} + return fileDescriptor_dc42cdfd1d52d76e, []int{11} } func (m *QueryClientStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,7 +714,7 @@ func (m *QueryClientParamsRequest) Reset() { *m = QueryClientParamsReque func (m *QueryClientParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryClientParamsRequest) ProtoMessage() {} func (*QueryClientParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{10} + return fileDescriptor_dc42cdfd1d52d76e, []int{12} } func (m *QueryClientParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -642,7 +754,7 @@ func (m *QueryClientParamsResponse) Reset() { *m = QueryClientParamsResp func (m *QueryClientParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryClientParamsResponse) ProtoMessage() {} func (*QueryClientParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{11} + return fileDescriptor_dc42cdfd1d52d76e, []int{13} } func (m *QueryClientParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -687,7 +799,7 @@ func (m *QueryUpgradedClientStateRequest) Reset() { *m = QueryUpgradedCl func (m *QueryUpgradedClientStateRequest) String() string { return proto.CompactTextString(m) } func (*QueryUpgradedClientStateRequest) ProtoMessage() {} func (*QueryUpgradedClientStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{12} + return fileDescriptor_dc42cdfd1d52d76e, []int{14} } func (m *QueryUpgradedClientStateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -727,7 +839,7 @@ func (m *QueryUpgradedClientStateResponse) Reset() { *m = QueryUpgradedC func (m *QueryUpgradedClientStateResponse) String() string { return proto.CompactTextString(m) } func (*QueryUpgradedClientStateResponse) ProtoMessage() {} func (*QueryUpgradedClientStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{13} + return fileDescriptor_dc42cdfd1d52d76e, []int{15} } func (m *QueryUpgradedClientStateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -772,7 +884,7 @@ func (m *QueryUpgradedConsensusStateRequest) Reset() { *m = QueryUpgrade func (m *QueryUpgradedConsensusStateRequest) String() string { return proto.CompactTextString(m) } func (*QueryUpgradedConsensusStateRequest) ProtoMessage() {} func (*QueryUpgradedConsensusStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{14} + return fileDescriptor_dc42cdfd1d52d76e, []int{16} } func (m *QueryUpgradedConsensusStateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -812,7 +924,7 @@ func (m *QueryUpgradedConsensusStateResponse) Reset() { *m = QueryUpgrad func (m *QueryUpgradedConsensusStateResponse) String() string { return proto.CompactTextString(m) } func (*QueryUpgradedConsensusStateResponse) ProtoMessage() {} func (*QueryUpgradedConsensusStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc42cdfd1d52d76e, []int{15} + return fileDescriptor_dc42cdfd1d52d76e, []int{17} } func (m *QueryUpgradedConsensusStateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -857,6 +969,8 @@ func init() { proto.RegisterType((*QueryConsensusStateResponse)(nil), "ibc.core.client.v1.QueryConsensusStateResponse") proto.RegisterType((*QueryConsensusStatesRequest)(nil), "ibc.core.client.v1.QueryConsensusStatesRequest") proto.RegisterType((*QueryConsensusStatesResponse)(nil), "ibc.core.client.v1.QueryConsensusStatesResponse") + proto.RegisterType((*QueryConsensusStateHeightsRequest)(nil), "ibc.core.client.v1.QueryConsensusStateHeightsRequest") + proto.RegisterType((*QueryConsensusStateHeightsResponse)(nil), "ibc.core.client.v1.QueryConsensusStateHeightsResponse") proto.RegisterType((*QueryClientStatusRequest)(nil), "ibc.core.client.v1.QueryClientStatusRequest") proto.RegisterType((*QueryClientStatusResponse)(nil), "ibc.core.client.v1.QueryClientStatusResponse") proto.RegisterType((*QueryClientParamsRequest)(nil), "ibc.core.client.v1.QueryClientParamsRequest") @@ -870,69 +984,73 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) } var fileDescriptor_dc42cdfd1d52d76e = []byte{ - // 983 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xa4, 0x69, 0xd4, 0x3e, 0xbb, 0x09, 0x9a, 0xa6, 0xa9, 0xbb, 0x2d, 0x8e, 0xbb, 0x41, - 0x34, 0x2d, 0xc9, 0x4e, 0xe2, 0x40, 0xd3, 0x0b, 0x07, 0x52, 0xa9, 0xb4, 0x97, 0x52, 0x16, 0x21, - 0x24, 0x24, 0x14, 0xed, 0xae, 0x27, 0x9b, 0x95, 0xec, 0x1d, 0xd7, 0xb3, 0x6b, 0x29, 0xaa, 0x72, - 0xa0, 0x47, 0x4e, 0x48, 0x48, 0x5c, 0x91, 0x38, 0x72, 0xa8, 0x38, 0x20, 0x71, 0xe5, 0x84, 0x7a, - 0xac, 0x04, 0x07, 0x4e, 0x04, 0x25, 0xfc, 0x21, 0x68, 0x67, 0x66, 0xe3, 0x1d, 0x7b, 0x8c, 0xd7, - 0x88, 0xde, 0x76, 0xde, 0xe7, 0xef, 0x7d, 0xcc, 0x6f, 0xb4, 0x50, 0x8f, 0xfc, 0x80, 0x04, 0xac, - 0x47, 0x49, 0xd0, 0x8e, 0x68, 0x9c, 0x90, 0xfe, 0x16, 0x79, 0x9a, 0xd2, 0xde, 0xa1, 0xd3, 0xed, - 0xb1, 0x84, 0x61, 0x1c, 0xf9, 0x81, 0x93, 0x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6, 0xbb, 0xd3, 0x39, 0x29, 0x84, 0x4d, 0x81, 0x70, 0x1d, 0xdf, 0x31, 0xb5, 0xd1, 0xc8, 0xc6, - 0x1c, 0xff, 0x82, 0x60, 0xd9, 0xcc, 0x99, 0xf8, 0xee, 0x64, 0x10, 0xc6, 0xbb, 0xb8, 0x33, 0xb5, - 0x5f, 0x99, 0x35, 0x18, 0x47, 0xdb, 0x7c, 0xd7, 0x7d, 0x79, 0x52, 0x47, 0xaf, 0x4e, 0xea, 0xe8, - 0xaf, 0x93, 0x3a, 0xfa, 0xfa, 0xb4, 0x3e, 0xf3, 0xea, 0xb4, 0x3e, 0xf3, 0xc7, 0x69, 0x7d, 0xe6, - 0xf3, 0x7b, 0x61, 0x94, 0x1c, 0xa4, 0xbe, 0x13, 0xb0, 0x0e, 0x51, 0x3f, 0x4b, 0x91, 0x1f, 0x6c, - 0x84, 0x8c, 0xf4, 0xb7, 0x49, 0x87, 0xb5, 0xd2, 0x36, 0xe5, 0x32, 0xcf, 0x66, 0x73, 0x43, 0xa5, - 0x4a, 0x0e, 0xbb, 0x94, 0xfb, 0xf3, 0x82, 0xfd, 0xb7, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xb0, - 0x84, 0x64, 0x2c, 0x98, 0x0d, 0x00, 0x00, + // 1055 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xa4, 0x69, 0xd4, 0x3e, 0xbb, 0x09, 0x9a, 0xe6, 0xc3, 0xdd, 0x16, 0xc7, 0xd9, 0x20, + 0x9a, 0x96, 0x64, 0x27, 0x71, 0x68, 0x12, 0x21, 0x21, 0x41, 0x2a, 0x95, 0xf6, 0x52, 0xca, 0x22, + 0x04, 0x42, 0x42, 0xd1, 0xee, 0x7a, 0xb2, 0x59, 0xc9, 0xde, 0x71, 0x3d, 0xbb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, 0xbb, 0x40, 0x7c, 0xcf, + 0x3e, 0x39, 0x2d, 0xa3, 0xe7, 0xa7, 0x65, 0xf4, 0xd7, 0x69, 0x19, 0x7d, 0x79, 0x56, 0x9e, 0x78, + 0x7e, 0x56, 0x9e, 0xf8, 0xe3, 0xac, 0x3c, 0xf1, 0xe9, 0xae, 0x1f, 0x44, 0x87, 0xb1, 0x6b, 0x79, + 0xac, 0x41, 0xd4, 0x9f, 0xe9, 0xc0, 0xf5, 0xd6, 0x7d, 0x46, 0xda, 0x5b, 0xa4, 0xc1, 0x6a, 0x71, + 0x9d, 0x72, 0x99, 0x67, 0xa3, 0xba, 0xae, 0x52, 0x45, 0x47, 0x4d, 0xca, 0xdd, 0x69, 0x71, 0xc8, + 0xb6, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x42, 0x17, 0xfc, 0x54, 0xb8, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -957,6 +1075,8 @@ type QueryClient interface { // ConsensusStates queries all the consensus state associated with a given // client. ConsensusStates(ctx context.Context, in *QueryConsensusStatesRequest, opts ...grpc.CallOption) (*QueryConsensusStatesResponse, error) + // ConsensusStateHeights queries the height of every consensus states associated with a given client. + ConsensusStateHeights(ctx context.Context, in *QueryConsensusStateHeightsRequest, opts ...grpc.CallOption) (*QueryConsensusStateHeightsResponse, error) // Status queries the status of an IBC client. ClientStatus(ctx context.Context, in *QueryClientStatusRequest, opts ...grpc.CallOption) (*QueryClientStatusResponse, error) // ClientParams queries all parameters of the ibc client. @@ -1011,6 +1131,15 @@ func (c *queryClient) ConsensusStates(ctx context.Context, in *QueryConsensusSta return out, nil } +func (c *queryClient) ConsensusStateHeights(ctx context.Context, in *QueryConsensusStateHeightsRequest, opts ...grpc.CallOption) (*QueryConsensusStateHeightsResponse, error) { + out := new(QueryConsensusStateHeightsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/ConsensusStateHeights", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) ClientStatus(ctx context.Context, in *QueryClientStatusRequest, opts ...grpc.CallOption) (*QueryClientStatusResponse, error) { out := new(QueryClientStatusResponse) err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/ClientStatus", in, out, opts...) @@ -1059,6 +1188,8 @@ type QueryServer interface { // ConsensusStates queries all the consensus state associated with a given // client. ConsensusStates(context.Context, *QueryConsensusStatesRequest) (*QueryConsensusStatesResponse, error) + // ConsensusStateHeights queries the height of every consensus states associated with a given client. + ConsensusStateHeights(context.Context, *QueryConsensusStateHeightsRequest) (*QueryConsensusStateHeightsResponse, error) // Status queries the status of an IBC client. ClientStatus(context.Context, *QueryClientStatusRequest) (*QueryClientStatusResponse, error) // ClientParams queries all parameters of the ibc client. @@ -1085,6 +1216,9 @@ func (*UnimplementedQueryServer) ConsensusState(ctx context.Context, req *QueryC func (*UnimplementedQueryServer) ConsensusStates(ctx context.Context, req *QueryConsensusStatesRequest) (*QueryConsensusStatesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ConsensusStates not implemented") } +func (*UnimplementedQueryServer) ConsensusStateHeights(ctx context.Context, req *QueryConsensusStateHeightsRequest) (*QueryConsensusStateHeightsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsensusStateHeights not implemented") +} func (*UnimplementedQueryServer) ClientStatus(ctx context.Context, req *QueryClientStatusRequest) (*QueryClientStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClientStatus not implemented") } @@ -1174,6 +1308,24 @@ func _Query_ConsensusStates_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_ConsensusStateHeights_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConsensusStateHeightsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ConsensusStateHeights(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Query/ConsensusStateHeights", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ConsensusStateHeights(ctx, req.(*QueryConsensusStateHeightsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_ClientStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryClientStatusRequest) if err := dec(in); err != nil { @@ -1266,6 +1418,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ConsensusStates", Handler: _Query_ConsensusStates_Handler, }, + { + MethodName: "ConsensusStateHeights", + Handler: _Query_ConsensusStateHeights_Handler, + }, { MethodName: "ClientStatus", Handler: _Query_ClientStatus_Handler, @@ -1646,6 +1802,97 @@ func (m *QueryConsensusStatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *QueryConsensusStateHeightsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryConsensusStateHeightsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsensusStateHeightsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryConsensusStateHeightsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryConsensusStateHeightsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsensusStateHeightsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ConsensusStateHeights) > 0 { + for iNdEx := len(m.ConsensusStateHeights) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ConsensusStateHeights[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryClientStatusRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2032,6 +2279,42 @@ func (m *QueryConsensusStatesResponse) Size() (n int) { return n } +func (m *QueryConsensusStateHeightsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConsensusStateHeightsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ConsensusStateHeights) > 0 { + for _, e := range m.ConsensusStateHeights { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryClientStatusRequest) Size() (n int) { if m == nil { return 0 @@ -3102,6 +3385,244 @@ func (m *QueryConsensusStatesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryConsensusStateHeightsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryConsensusStateHeightsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsensusStateHeightsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConsensusStateHeightsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryConsensusStateHeightsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsensusStateHeightsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusStateHeights", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusStateHeights = append(m.ConsensusStateHeights, Height{}) + if err := m.ConsensusStateHeights[len(m.ConsensusStateHeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryClientStatusRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/query.pb.gw.go b/modules/core/02-client/types/query.pb.gw.go index 3704fb07895..4286cc772ae 100644 --- a/modules/core/02-client/types/query.pb.gw.go +++ b/modules/core/02-client/types/query.pb.gw.go @@ -309,6 +309,78 @@ func local_request_Query_ConsensusStates_0(ctx context.Context, marshaler runtim } +var ( + filter_Query_ConsensusStateHeights_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ConsensusStateHeights_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsensusStateHeightsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ConsensusStateHeights_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ConsensusStateHeights(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ConsensusStateHeights_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsensusStateHeightsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ConsensusStateHeights_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ConsensusStateHeights(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_ClientStatus_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryClientStatusRequest var metadata runtime.ServerMetadata @@ -503,6 +575,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ConsensusStateHeights_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ConsensusStateHeights_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ConsensusStateHeights_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ClientStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -704,6 +796,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ConsensusStateHeights_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ConsensusStateHeights_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ConsensusStateHeights_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ClientStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -796,6 +908,8 @@ var ( pattern_Query_ConsensusStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "consensus_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConsensusStateHeights_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "client", "v1", "consensus_states", "client_id", "heights"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ClientStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "client_status", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_ClientParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "client", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) @@ -814,6 +928,8 @@ var ( forward_Query_ConsensusStates_0 = runtime.ForwardResponseMessage + forward_Query_ConsensusStateHeights_0 = runtime.ForwardResponseMessage + forward_Query_ClientStatus_0 = runtime.ForwardResponseMessage forward_Query_ClientParams_0 = runtime.ForwardResponseMessage diff --git a/modules/core/keeper/grpc_query.go b/modules/core/keeper/grpc_query.go index 2fb171a9c02..138a4e7aa01 100644 --- a/modules/core/keeper/grpc_query.go +++ b/modules/core/keeper/grpc_query.go @@ -28,6 +28,11 @@ func (q Keeper) ConsensusStates(c context.Context, req *clienttypes.QueryConsens return q.ClientKeeper.ConsensusStates(c, req) } +// ConsensusStateHeights implements the IBC QueryServer interface +func (q Keeper) ConsensusStateHeights(c context.Context, req *clienttypes.QueryConsensusStateHeightsRequest) (*clienttypes.QueryConsensusStateHeightsResponse, error) { + return q.ClientKeeper.ConsensusStateHeights(c, req) +} + // ClientStatus implements the IBC QueryServer interface func (q Keeper) ClientStatus(c context.Context, req *clienttypes.QueryClientStatusRequest) (*clienttypes.QueryClientStatusResponse, error) { return q.ClientKeeper.ClientStatus(c, req) diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto index 91a906fe54b..33a4191cd06 100644 --- a/proto/ibc/core/client/v1/query.proto +++ b/proto/ibc/core/client/v1/query.proto @@ -36,6 +36,11 @@ service Query { option (google.api.http).get = "/ibc/core/client/v1/consensus_states/{client_id}"; } + // ConsensusStateHeights queries the height of every consensus states associated with a given client. + rpc ConsensusStateHeights(QueryConsensusStateHeightsRequest) returns (QueryConsensusStateHeightsResponse) { + option (google.api.http).get = "/ibc/core/client/v1/consensus_states/{client_id}/heights"; + } + // Status queries the status of an IBC client. rpc ClientStatus(QueryClientStatusRequest) returns (QueryClientStatusResponse) { option (google.api.http).get = "/ibc/core/client/v1/client_status/{client_id}"; @@ -137,6 +142,24 @@ message QueryConsensusStatesResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// QueryConsensusStateHeightsRequest is the request type for Query/ConsensusStateHeights +// RPC method. +message QueryConsensusStateHeightsRequest { + // client identifier + string client_id = 1; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryConsensusStateHeightsResponse is the response type for the +// Query/ConsensusStateHeights RPC method +message QueryConsensusStateHeightsResponse { + // consensus state heights + repeated Height consensus_state_heights = 1 [(gogoproto.nullable) = false]; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryClientStatusRequest is the request type for the Query/ClientStatus RPC // method message QueryClientStatusRequest {