From f35e3b2c02a3d4566dcd99fa1df045c8c9cf5892 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Mon, 6 Jul 2020 21:35:35 +0200 Subject: [PATCH] x/ibc: gRPC query service (#6466) * x/ibc: gRPC query service * fixes * connection updates * register channel query service * update clients * change proofs to bytes * implement additional channel grpc queries * unrelayed packets query * query.proto files * move next sequence recv query to channel client * update REST * wip test * add missing cli queries * install the right tools * fixes * build * lint * use gRPC when query proof is not requested * connection gRPC tests * IBC query server interface * more gRPC channel tests * pagination tests * connection use query server * connection pagination tests * channel pagination tests * typo * remove buf * Update x/ibc/03-connection/keeper/grpc_query_test.go Co-authored-by: colin axner <25233464+colin-axner@users.noreply.github.com> * address comments from review * fix tests * unrelayed packet sequences flag * remove ClientsConnections query * fix Co-authored-by: colin axner <25233464+colin-axner@users.noreply.github.com> --- proto/ibc/channel/channel.proto | 103 +- proto/ibc/channel/query.proto | 183 + proto/ibc/connection/connection.proto | 11 +- proto/ibc/connection/query.proto | 75 + x/bank/client/cli/query.go | 1 - x/bank/keeper/grpc_query.go | 3 +- x/ibc-transfer/client/cli/cli.go | 17 - x/ibc-transfer/client/cli/query.go | 49 - x/ibc-transfer/client/rest/query.go | 51 - x/ibc-transfer/client/rest/rest.go | 5 +- x/ibc-transfer/client/rest/tx.go | 6 +- x/ibc-transfer/client/utils/utils.go | 33 - x/ibc-transfer/module.go | 2 +- x/ibc/03-connection/client/cli/cli.go | 1 + x/ibc/03-connection/client/cli/query.go | 106 +- x/ibc/03-connection/client/rest/query.go | 90 +- x/ibc/03-connection/client/utils/utils.go | 98 +- x/ibc/03-connection/keeper/grpc_query.go | 99 + x/ibc/03-connection/keeper/grpc_query_test.go | 216 + x/ibc/03-connection/keeper/keeper.go | 3 + x/ibc/03-connection/keeper/querier.go | 82 - x/ibc/03-connection/module.go | 10 +- x/ibc/03-connection/types/connection.pb.go | 341 +- x/ibc/03-connection/types/genesis.go | 6 - x/ibc/03-connection/types/querier.go | 80 +- x/ibc/03-connection/types/query.pb.go | 1799 +++++++ x/ibc/04-channel/client/cli/cli.go | 12 +- x/ibc/04-channel/client/cli/query.go | 254 +- x/ibc/04-channel/client/rest/query.go | 36 +- x/ibc/04-channel/client/utils/utils.go | 141 +- x/ibc/04-channel/genesis.go | 2 +- x/ibc/04-channel/keeper/grpc_query.go | 267 + x/ibc/04-channel/keeper/grpc_query_test.go | 657 +++ x/ibc/04-channel/keeper/keeper.go | 6 +- x/ibc/04-channel/keeper/querier.go | 144 +- x/ibc/04-channel/keeper/querier_test.go | 454 +- x/ibc/04-channel/module.go | 14 +- x/ibc/04-channel/types/channel.go | 18 +- x/ibc/04-channel/types/channel.pb.go | 912 +++- x/ibc/04-channel/types/genesis.go | 9 - x/ibc/04-channel/types/querier.go | 167 +- x/ibc/04-channel/types/query.pb.go | 4680 +++++++++++++++++ x/ibc/keeper/grpc_query.go | 58 + x/ibc/keeper/keeper.go | 6 + x/ibc/keeper/querier.go | 22 +- x/ibc/keeper/querier_test.go | 65 - x/ibc/module.go | 9 +- x/ibc/testing/chain.go | 5 +- x/ibc/types/query.go | 21 + 49 files changed, 9828 insertions(+), 1601 deletions(-) create mode 100644 proto/ibc/channel/query.proto create mode 100644 proto/ibc/connection/query.proto delete mode 100644 x/ibc-transfer/client/cli/query.go delete mode 100644 x/ibc-transfer/client/rest/query.go delete mode 100644 x/ibc-transfer/client/utils/utils.go create mode 100644 x/ibc/03-connection/keeper/grpc_query.go create mode 100644 x/ibc/03-connection/keeper/grpc_query_test.go delete mode 100644 x/ibc/03-connection/keeper/querier.go create mode 100644 x/ibc/03-connection/types/query.pb.go create mode 100644 x/ibc/04-channel/keeper/grpc_query.go create mode 100644 x/ibc/04-channel/keeper/grpc_query_test.go create mode 100644 x/ibc/04-channel/types/query.pb.go create mode 100644 x/ibc/keeper/grpc_query.go create mode 100644 x/ibc/types/query.go diff --git a/proto/ibc/channel/channel.proto b/proto/ibc/channel/channel.proto index 2175a0fa64e5..6d7911d9ef34 100644 --- a/proto/ibc/channel/channel.proto +++ b/proto/ibc/channel/channel.proto @@ -17,32 +17,32 @@ message MsgChannelOpenInit { // MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel // on Chain B. message MsgChannelOpenTry { - string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - Channel channel = 3 [(gogoproto.nullable) = false]; - string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; - uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""]; - bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + Channel channel = 3 [(gogoproto.nullable) = false]; + string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; + bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge // the change of channel state to TRYOPEN on Chain B. message MsgChannelOpenAck { - string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - string counterparty_version = 3 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - bytes proof_try = 4 [(gogoproto.moretags) = "yaml:\"proof_try\""]; - uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""]; - bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + string counterparty_version = 3 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; + bytes proof_try = 4 [(gogoproto.moretags) = "yaml:\"proof_try\""]; + uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge // the change of channel state to OPEN on Chain A. message MsgChannelOpenConfirm { - string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -58,37 +58,37 @@ message MsgChannelCloseInit { // MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B // to acknowledge the change of channel state to CLOSED on Chain A. message MsgChannelCloseConfirm { - string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""]; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // MsgPacket receives incoming IBC packet message MsgPacket { - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof = 2; - uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; - bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof = 2; + uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // MsgTimeout receives timed-out packet message MsgTimeout { - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof = 2; - uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; - uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; - bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof = 2; + uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; + bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // MsgAcknowledgement receives incoming IBC acknowledgement message MsgAcknowledgement { - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes acknowledgement = 2; - bytes proof = 3; - uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; - bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes acknowledgement = 2; + bytes proof = 3; + uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } // Channel defines pipeline for exactly-once packet delivery between specific @@ -110,6 +110,28 @@ message Channel { string version = 5; } +// IdentifiedChannel defines a channel with additional port and channel identifier +// fields. +message IdentifiedChannel { + option (gogoproto.goproto_getters) = false; + + // current state of the channel end + State state = 1; + // whether the channel is ordered or unordered + Order ordering = 2; + // counterparty channel end + Counterparty counterparty = 3 [(gogoproto.nullable) = false]; + // list of connection identifiers, in order, along which packets sent on this + // channel will travel + repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; + // opaque channel version, which is agreed upon during the handshake + string version = 5; + // port identifier + string port_id = 6 [(gogoproto.customname) = "PortID"]; + // channel identifier + string channel_id = 7 [(gogoproto.customname) = "ChannelID"]; +} + // State defines if a channel is in one of the following states: // CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. enum State { @@ -173,3 +195,18 @@ message Packet { // block timestamp (in nanoseconds) after which the packet times out uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; } + +// PacketAckCommitment defines the genesis type necessary to retrieve and store +// acknowlegements. +message PacketAckCommitment { + option (gogoproto.goproto_getters) = false; + + // channel port identifier. + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + // channel unique identifier. + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + // packet sequence. + uint64 sequence = 3; + // packet commitment hash. + bytes hash = 4; +} diff --git a/proto/ibc/channel/query.proto b/proto/ibc/channel/query.proto new file mode 100644 index 000000000000..08c87bc30c4e --- /dev/null +++ b/proto/ibc/channel/query.proto @@ -0,0 +1,183 @@ +syntax = "proto3"; +package ibc.channel; + +import "gogoproto/gogo.proto"; +import "cosmos/query/pagination.proto"; +import "ibc/channel/channel.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"; + +// Query provides defines the gRPC querier service +service Query { + // Channel queries an IBC Channel. + rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) {} + + // Channels queries all the IBC channels of a chain. + rpc Channels(QueryChannelsRequest) returns (QueryChannelsResponse) {} + + // ConnectionChannels queries all the channels associated with a connection end. + rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) {} + + // PacketCommitment queries a stored packet commitment hash. + rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) {} + + // PacketCommitments returns the all the packet commitments hashes associated with a channel. + rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) {} + + // UnrelayedPackets returns all the unrelayed IBC packets associated with a channel and sequences. + rpc UnrelayedPackets(QueryUnrelayedPacketsRequest) returns (QueryUnrelayedPacketsResponse) {} + + // NextSequenceReceive returns the next receive sequence for a given channel + rpc NextSequenceReceive(QueryNextSequenceReceiveRequest) returns (QueryNextSequenceReceiveResponse) {} + + // TODO: blocked by client proto migration + // rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateRequest) {} +} + +// QueryChannelRequest is the request type for the Query/Channel RPC method +message QueryChannelRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; +} + +// QueryChannelResponse is the response type for the Query/Channel RPC method. +// Besides the Channel end, it includes a proof and the height from which the +// proof was retrieved. +message QueryChannelResponse { + // channel associated with the request identifiers + ibc.channel.Channel channel = 1; + // merkle proof of existence + bytes proof = 2; + // merkle proof path + string proof_path = 3; + // height at which the proof was retrieved + uint64 proof_height = 4; +} + +// QueryChannelsRequest is the request type for the Query/Channels RPC method +message QueryChannelsRequest { + // pagination request + cosmos.query.PageRequest req = 1; +} + +// QueryChannelsResponse is the response type for the Query/Channels RPC method. +message QueryChannelsResponse { + // list of stored channels of the chain. + repeated ibc.channel.IdentifiedChannel channels = 1; + // pagination response + cosmos.query.PageResponse res = 2; + // query block height + int64 height = 3; +} + +// QueryConnectionChannelsRequest is the request type for the Query/QueryConnectionChannels RPC method +message QueryConnectionChannelsRequest { + // connection unique identifier + string connection = 1; + // pagination request + cosmos.query.PageRequest req = 2; +} + +// QueryConnectionChannelsResponse is the Response type for the Query/QueryConnectionChannels RPC method +message QueryConnectionChannelsResponse { + // list of channels associated with a connection. + repeated ibc.channel.IdentifiedChannel channels = 1; + // pagination response + cosmos.query.PageResponse res = 2; + // query block height + int64 height = 3; +} + +// QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method +message QueryPacketCommitmentRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; + // packet sequence + uint64 sequence = 3; +} + +// QueryPacketCommitmentResponse defines the client query response for a packet which also +// includes a proof, its path and the height form which the proof was retrieved +message QueryPacketCommitmentResponse { + // packet associated with the request fields + bytes commitment = 1; + // merkle proof of existence + bytes proof = 2; + // merkle proof path + string proof_path = 3; + // height at which the proof was retrieved + uint64 proof_height = 4; +} + +// QueryPacketCommitmentsRequest is the request type for the Query/QueryPacketCommitments RPC method +message QueryPacketCommitmentsRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; + // pagination request + cosmos.query.PageRequest req = 3; +} + +// QueryPacketCommitmentsResponse is the request type for the Query/QueryPacketCommitments RPC method +message QueryPacketCommitmentsResponse { + repeated ibc.channel.PacketAckCommitment commitments = 1; + // pagination response + cosmos.query.PageResponse res = 2; + // query block height + int64 height = 3; +} + +// QueryUnrelayedPacketsRequest is the request type for the Query/QueryConnectionChannels RPC method +message QueryUnrelayedPacketsRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; + // list of packet sequences + repeated uint64 sequences = 3; + // pagination request + cosmos.query.PageRequest req = 4; +} + +// QueryUnrelayedPacketsResponse is the request type for the Query/QueryConnectionChannels RPC method +message QueryUnrelayedPacketsResponse { + // list of unrelayed packets sequences + repeated uint64 packets = 1; + // pagination response + cosmos.query.PageResponse res = 2; + // query block height + int64 height = 3; +} + +// QueryNextSequenceReceiveRequest is the request type for the Query/QueryNextSequenceReceiveRequest RPC method +message QueryNextSequenceReceiveRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; +} + +// QuerySequenceResponse is the request type for the Query/QueryNextSequenceReceiveResponse RPC method +message QueryNextSequenceReceiveResponse { + // next sequence receive number + uint64 next_sequence_receive = 1; + // merkle proof of existence + bytes proof = 2; + // merkle proof path + string proof_path = 3; + // height at which the proof was retrieved + uint64 proof_height = 4; +} + +// QueryChannelClientStateRequest is the request type for the Query/ClientState RPC method +message QueryChannelClientStateRequest { + // port unique identifier + string port_id = 1 [(gogoproto.customname) = "PortID"]; + // channel unique identifier + string channel_id = 2 [(gogoproto.customname) = "ChannelID"]; +} diff --git a/proto/ibc/connection/connection.proto b/proto/ibc/connection/connection.proto index c94babc3f5b4..0bf2f17b5ef9 100644 --- a/proto/ibc/connection/connection.proto +++ b/proto/ibc/connection/connection.proto @@ -23,7 +23,7 @@ message MsgConnectionOpenTry { Counterparty counterparty = 3 [(gogoproto.nullable) = false]; repeated string counterparty_versions = 4 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; // proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT` - bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; uint64 proof_height = 6; // proof of client consensus state bytes proof_consensus = 7 @@ -110,5 +110,14 @@ message Counterparty { // ClientPaths define all the connection paths for a client state. message ClientPaths { + // list of connection paths repeated string paths = 1; } + +// ConnectionPaths define all the connection paths for a given client state. +message ConnectionPaths { + // client state unique identifier + string client_id = 1 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""]; + // list of connection paths + repeated string paths = 2; +} diff --git a/proto/ibc/connection/query.proto b/proto/ibc/connection/query.proto new file mode 100644 index 000000000000..9eb060efbb8c --- /dev/null +++ b/proto/ibc/connection/query.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +package ibc.connection; + +import "gogoproto/gogo.proto"; +import "cosmos/query/pagination.proto"; +import "ibc/connection/connection.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"; + +// Query provides defines the gRPC querier service +service Query { + // Connection queries an IBC connection end. + rpc Connection(QueryConnectionRequest) returns (QueryConnectionResponse) {} + + // Connections queries all the IBC connections of a chain. + rpc Connections(QueryConnectionsRequest) returns (QueryConnectionsResponse) {} + + // ClientConnections queries the connection paths associated with a client state. + rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) {} +} + +// QueryConnectionRequest is the request type for the Query/Connection RPC method +message QueryConnectionRequest { + // connection unique identifier + string connection_id = 1 [(gogoproto.customname) = "ConnectionID"]; +} + +// QueryConnectionResponse is the response type for the Query/Connection RPC method. +// Besides the connection end, it includes a proof and the height from which the +// proof was retrieved. +message QueryConnectionResponse { + // connection associated with the request identifier + ibc.connection.ConnectionEnd connection = 1; + // merkle proof of existence + bytes proof = 2; + // merkle proof path + string proof_path = 3; + // height at which the proof was retrieved + uint64 proof_height = 4; +} + +// QueryConnectionsRequest is the request type for the Query/Connections RPC method +message QueryConnectionsRequest { + cosmos.query.PageRequest req = 1; +} + +// QueryConnectionsResponse is the response type for the Query/Connections RPC method. +message QueryConnectionsResponse { + // list of stored connections of the chain. + repeated ibc.connection.ConnectionEnd connections = 1; + // pagination response + cosmos.query.PageResponse res = 2; + // query block height + int64 height = 3; +} + +// QueryClientConnectionsRequest is the request type for the Query/ClientConnections +// RPC method +message QueryClientConnectionsRequest { + // client identifier associated with a connection + string client_id = 1 [(gogoproto.customname) = "ClientID"]; +} + +// QueryClientConnectionsResponse is the response type for the Query/ClientConnections +// RPC method +message QueryClientConnectionsResponse { + // slice of all the connection paths associated with a client. + repeated string connection_paths = 1; + // merkle proof of existence + bytes proof = 2; + // merkle proof path + string proof_path = 3; + // height at which the proof was generated + uint64 proof_height = 4; +} \ No newline at end of file diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index 27fa0f6057dc..6f7f25a8455e 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -80,7 +80,6 @@ Example: if err != nil { return err } - return clientCtx.PrintOutput(res.Balances) } diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 9600935440c8..9bcc9d3ea127 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -7,9 +7,8 @@ import ( "google.golang.org/grpc/status" "github.com/cosmos/cosmos-sdk/store/prefix" - "github.com/cosmos/cosmos-sdk/types/query" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/bank/types" ) diff --git a/x/ibc-transfer/client/cli/cli.go b/x/ibc-transfer/client/cli/cli.go index 05c31b55f73c..c09cde72b08f 100644 --- a/x/ibc-transfer/client/cli/cli.go +++ b/x/ibc-transfer/client/cli/cli.go @@ -7,23 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" ) -// GetQueryCmd returns the query commands for IBC fungible token transfer -func GetQueryCmd(clientCtx client.Context) *cobra.Command { - ics20TransferQueryCmd := &cobra.Command{ - Use: "ibc-transfer", - Short: "IBC fungible token transfer query subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - ics20TransferQueryCmd.AddCommand(flags.GetCommands( - GetCmdQueryNextSequence(clientCtx), - )...) - - return ics20TransferQueryCmd -} - // NewTxCmd returns the transaction commands for IBC fungible token transfer func NewTxCmd(clientCtx client.Context) *cobra.Command { ics20TransferTxCmd := &cobra.Command{ diff --git a/x/ibc-transfer/client/cli/query.go b/x/ibc-transfer/client/cli/query.go deleted file mode 100644 index 6c1b0401e11a..000000000000 --- a/x/ibc-transfer/client/cli/query.go +++ /dev/null @@ -1,49 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils" -) - -// GetCmdQueryNextSequence defines the command to query a next receive sequence -// TODO: move to channel -func GetCmdQueryNextSequence(clientCtx client.Context) *cobra.Command { - cmd := &cobra.Command{ - Use: "next-recv [port-id] [channel-id]", - Short: "Query a next receive sequence", - Long: strings.TrimSpace(fmt.Sprintf(`Query an IBC channel end - -Example: -$ %s query ibc-transfer next-recv [port-id] [channel-id] - `, version.ClientName), - ), - Example: fmt.Sprintf("%s query ibc-transfer next-recv [port-id] [channel-id]", version.ClientName), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx = clientCtx.Init() - - portID := args[0] - channelID := args[1] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) - - sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove) - if err != nil { - return err - } - - clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight)) - return clientCtx.PrintOutput(sequenceRes) - }, - } - - cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") - - return cmd -} diff --git a/x/ibc-transfer/client/rest/query.go b/x/ibc-transfer/client/rest/query.go deleted file mode 100644 index 514142c08957..000000000000 --- a/x/ibc-transfer/client/rest/query.go +++ /dev/null @@ -1,51 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils" -) - -func registerQueryRoutes(clientCtx client.Context, r *mux.Router) { - r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/next-sequence-recv", RestPortID, RestChannelID), queryNextSequenceRecvHandlerFn(clientCtx)).Methods("GET") -} - -// queryNextSequenceRecvHandlerFn implements a next sequence receive querying route -// -// @Summary Query next sequence receive -// @Tags IBC -// @Produce json -// @Param port-id path string true "Port ID" -// @Param channel-id path string true "Channel ID" -// @Success 200 {object} QueryNextSequenceRecv "OK" -// @Failure 400 {object} rest.ErrorResponse "Invalid port id or channel id" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/ports/{port-id}/channels/{channel-id}/next-sequence-recv [get] -func queryNextSequenceRecvHandlerFn(clientCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - portID := vars[RestPortID] - channelID := vars[RestChannelID] - prove := rest.ParseQueryParamBool(r, flags.FlagProve) - - clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) - if !ok { - return - } - - sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight)) - rest.PostProcessResponse(w, clientCtx, sequenceRes) - } -} diff --git a/x/ibc-transfer/client/rest/rest.go b/x/ibc-transfer/client/rest/rest.go index 2d790698fbfa..4a498ba3bbd9 100644 --- a/x/ibc-transfer/client/rest/rest.go +++ b/x/ibc-transfer/client/rest/rest.go @@ -9,13 +9,12 @@ import ( ) const ( - RestChannelID = "channel-id" - RestPortID = "port-id" + restChannelID = "channel-id" + restPortID = "port-id" ) // RegisterRoutes - Central function to define routes that get registered by the main application func RegisterRoutes(clientCtx client.Context, r *mux.Router) { - registerQueryRoutes(clientCtx, r) registerTxRoutes(clientCtx, r) } diff --git a/x/ibc-transfer/client/rest/tx.go b/x/ibc-transfer/client/rest/tx.go index c1d20e761219..7e57f26db660 100644 --- a/x/ibc-transfer/client/rest/tx.go +++ b/x/ibc-transfer/client/rest/tx.go @@ -14,7 +14,7 @@ import ( ) func registerTxRoutes(clientCtx client.Context, r *mux.Router) { - r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/transfer", RestPortID, RestChannelID), transferHandlerFn(clientCtx)).Methods("POST") + r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/transfer", restPortID, restChannelID), transferHandlerFn(clientCtx)).Methods("POST") } // transferHandlerFn implements a transfer handler @@ -33,8 +33,8 @@ func registerTxRoutes(clientCtx client.Context, r *mux.Router) { func transferHandlerFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - portID := vars[RestPortID] - channelID := vars[RestChannelID] + portID := vars[restPortID] + channelID := vars[restChannelID] var req TransferTxReq if !rest.ReadRESTReq(w, r, clientCtx.Codec, &req) { diff --git a/x/ibc-transfer/client/utils/utils.go b/x/ibc-transfer/client/utils/utils.go deleted file mode 100644 index 2028bd2ef747..000000000000 --- a/x/ibc-transfer/client/utils/utils.go +++ /dev/null @@ -1,33 +0,0 @@ -package utils - -import ( - "encoding/binary" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" -) - -// QueryNextSequenceRecv queries the store to get the next receive sequence and -// a merkle proof. -func QueryNextSequenceRecv( - clientCtx client.Context, portID, channelID string, prove bool, -) (channeltypes.RecvResponse, error) { - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: host.KeyNextSequenceRecv(portID, channelID), - Prove: prove, - } - - res, err := clientCtx.QueryABCI(req) - if err != nil { - return channeltypes.RecvResponse{}, err - } - - sequence := binary.BigEndian.Uint64(res.Value) - sequenceRes := channeltypes.NewRecvResponse(portID, channelID, sequence, res.Proof, res.Height) - - return sequenceRes, nil -} diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index 54291891958a..412c543996b2 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -77,7 +77,7 @@ func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command { // GetQueryCmd implements AppModuleBasic interface func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { - return cli.GetQueryCmd(clientCtx) + return nil } // RegisterInterfaceTypes registers module concrete types into protobuf Any. diff --git a/x/ibc/03-connection/client/cli/cli.go b/x/ibc/03-connection/client/cli/cli.go index 08d2a75d6231..7907d864955d 100644 --- a/x/ibc/03-connection/client/cli/cli.go +++ b/x/ibc/03-connection/client/cli/cli.go @@ -20,6 +20,7 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command { ics03ConnectionQueryCmd.AddCommand(flags.GetCommands( GetCmdQueryConnections(clientCtx), GetCmdQueryConnection(clientCtx), + GetCmdQueryClientConnections(clientCtx), )...) return ics03ConnectionQueryCmd diff --git a/x/ibc/03-connection/client/cli/query.go b/x/ibc/03-connection/client/cli/query.go index cae0131bc6e0..ec7b4f289c75 100644 --- a/x/ibc/03-connection/client/cli/query.go +++ b/x/ibc/03-connection/client/cli/query.go @@ -1,48 +1,51 @@ package cli import ( + "context" "fmt" - "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" + "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) // GetCmdQueryConnections defines the command to query all the connection ends // that this chain mantains. func GetCmdQueryConnections(clientCtx client.Context) *cobra.Command { cmd := &cobra.Command{ - Use: "connections", - Short: "Query all available light clients", - Long: strings.TrimSpace( - fmt.Sprintf(`Query all available connections - -Example: -$ %s query ibc connection connections - `, version.ClientName), - ), - Example: fmt.Sprintf("%s query ibc connection connections", version.ClientName), + Use: "connections", + Short: "Query all connections", + Long: "Query all connections ends from a chain", + Example: fmt.Sprintf("%s query %s %s connections", version.ClientName, host.ModuleName, types.SubModuleName), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) error { clientCtx = clientCtx.Init() + queryClient := types.NewQueryClient(clientCtx) - page, _ := cmd.Flags().GetInt(flags.FlagPage) + offset, _ := cmd.Flags().GetInt(flags.FlagPage) limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - connections, height, err := utils.QueryAllConnections(clientCtx, page, limit) + req := &types.QueryConnectionsRequest{ + Req: &query.PageRequest{ + Offset: uint64(offset), + Limit: uint64(limit), + }, + } + + res, err := queryClient.Connections(context.Background(), req) if err != nil { return err } - clientCtx = clientCtx.WithHeight(height) - return clientCtx.PrintOutput(connections) + return clientCtx.PrintOutput(res) }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") @@ -52,21 +55,19 @@ $ %s query ibc connection connections // GetCmdQueryConnection defines the command to query a connection end func GetCmdQueryConnection(clientCtx client.Context) *cobra.Command { cmd := &cobra.Command{ - Use: "end [connection-id]", - Short: "Query stored connection end", - Long: strings.TrimSpace(fmt.Sprintf(`Query stored connection end - -Example: -$ %s query ibc connection end [connection-id] - `, version.ClientName), - ), - Example: fmt.Sprintf("%s query ibc connection end [connection-id]", version.ClientName), + Use: "end [connection-id]", + Short: "Query stored connection end", + Long: "Query stored connection end", + Example: fmt.Sprintf("%s query %s %s end [connection-id]", version.ClientName, host.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx = clientCtx.Init() connectionID := args[0] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } connRes, err := utils.QueryConnection(clientCtx, connectionID, prove) if err != nil { @@ -83,59 +84,22 @@ $ %s query ibc connection end [connection-id] return cmd } -// GetCmdQueryAllClientConnections defines the command to query a all the client connection paths. -func GetCmdQueryAllClientConnections(clientCtx client.Context) *cobra.Command { - cmd := &cobra.Command{ - Use: "paths", - Short: "Query all stored client connection paths", - Long: strings.TrimSpace(fmt.Sprintf(`Query all stored client connection paths - -Example: -$ %s query ibc connection paths - `, version.ClientName), - ), - Example: fmt.Sprintf("%s query ibc connection paths", version.ClientName), - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, _ []string) error { - clientCtx = clientCtx.Init() - - page, _ := cmd.Flags().GetInt(flags.FlagPage) - limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - - connectionPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit) - if err != nil { - return err - } - - clientCtx = clientCtx.WithHeight(height) - return clientCtx.PrintOutput(connectionPaths) - }, - } - - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") - cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") - - return cmd -} - // GetCmdQueryClientConnections defines the command to query a client connections func GetCmdQueryClientConnections(clientCtx client.Context) *cobra.Command { return &cobra.Command{ - Use: "path [client-id]", - Short: "Query stored client connection paths", - Long: strings.TrimSpace(fmt.Sprintf(`Query stored client connection paths - -Example: -$ %s query ibc connection path [client-id] - `, version.ClientName), - ), - Example: fmt.Sprintf("%s query ibc connection path [client-id]", version.ClientName), + Use: "path [client-id]", + Short: "Query stored client connection paths", + Long: "Query stored client connection paths", + Example: fmt.Sprintf("%s query %s %s path [client-id]", version.ClientName, host.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx = clientCtx.Init() clientID := args[0] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } connPathsRes, err := utils.QueryClientConnections(clientCtx, clientID, prove) if err != nil { diff --git a/x/ibc/03-connection/client/rest/query.go b/x/ibc/03-connection/client/rest/query.go index 20cdac2432ab..56a4e6804e60 100644 --- a/x/ibc/03-connection/client/rest/query.go +++ b/x/ibc/03-connection/client/rest/query.go @@ -1,6 +1,7 @@ package rest import ( + "context" "fmt" "net/http" @@ -8,62 +9,42 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" + "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" ) func registerQueryRoutes(clientCtx client.Context, r *mux.Router) { r.HandleFunc("/ibc/connections", queryConnectionsHandlerFn(clientCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/ibc/connections/{%s}", RestConnectionID), queryConnectionHandlerFn(clientCtx)).Methods("GET") - r.HandleFunc("/ibc/clients/connections", queryClientsConnectionsHandlerFn(clientCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/ibc/clients/{%s}/connections", RestClientID), queryClientConnectionsHandlerFn(clientCtx)).Methods("GET") } -// queryConnectionsHandlerFn implements connections querying route -// -// @Summary Query a client connection paths -// @Tags IBC -// @Produce json -// @Param page query int false "The page number to query" default(1) -// @Param limit query int false "The number of results per page" default(100) -// @Success 200 {object} QueryConnection "OK" -// @Failure 400 {object} rest.ErrorResponse "Bad Request" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/connections [get] -func queryClientsConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc { +func queryConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - _, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0) - if rest.CheckBadRequestError(w, err) { - return - } - clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) if !ok { return } - connections, height, err := utils.QueryAllConnections(clientCtx, page, limit) + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryConnectionsRequest{ + Req: &query.PageRequest{}, + } + + res, err := queryClient.Connections(context.Background(), req) if err != nil { rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } - clientCtx = clientCtx.WithHeight(height) - rest.PostProcessResponse(w, clientCtx, connections) + clientCtx = clientCtx.WithHeight(res.Height) + rest.PostProcessResponse(w, clientCtx, res) } } -// queryConnectionHandlerFn implements a connection querying route -// -// @Summary Query connection -// @Tags IBC -// @Produce json -// @Param connection-id path string true "Client ID" -// @Param prove query boolean false "Proof of result" -// @Success 200 {object} QueryConnection "OK" -// @Failure 400 {object} rest.ErrorResponse "Invalid connection id" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/connections/{connection-id} [get] func queryConnectionHandlerFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) @@ -86,51 +67,6 @@ func queryConnectionHandlerFn(clientCtx client.Context) http.HandlerFunc { } } -// queryConnectionsHandlerFn implements a client connections paths querying route -// -// @Summary Query all client connection paths -// @Tags IBC -// @Produce json -// @Param page query int false "The page number to query" default(1) -// @Param limit query int false "The number of results per page" default(100) -// @Success 200 {object} QueryClientsConnections "OK" -// @Failure 400 {object} rest.ErrorResponse "Bad Request" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/clients/connections [get] -func queryConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - _, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0) - if rest.CheckBadRequestError(w, err) { - return - } - - clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) - if !ok { - return - } - - connectionsPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - clientCtx = clientCtx.WithHeight(height) - rest.PostProcessResponse(w, clientCtx, connectionsPaths) - } -} - -// queryClientConnectionsHandlerFn implements a client connections querying route -// -// @Summary Query connections of a client -// @Tags IBC -// @Produce json -// @Param client-id path string true "Client ID" -// @Param prove query boolean false "Proof of result" -// @Success 200 {object} QueryClientConnections "OK" -// @Failure 400 {object} rest.ErrorResponse "Invalid client id" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/clients/{client-id}/connections [get] func queryClientConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/x/ibc/03-connection/client/utils/utils.go b/x/ibc/03-connection/client/utils/utils.go index 4c5d7af101f7..fbcd1b730497 100644 --- a/x/ibc/03-connection/client/utils/utils.go +++ b/x/ibc/03-connection/client/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "context" "fmt" "io/ioutil" @@ -15,101 +16,90 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -// QueryAllConnections returns all the connections. It _does not_ return -// any merkle proof. -func QueryAllConnections(clientCtx client.Context, page, limit int) ([]types.ConnectionEnd, int64, error) { - params := types.NewQueryAllConnectionsParams(page, limit) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(params) - if err != nil { - return nil, 0, fmt.Errorf("failed to marshal query params: %w", err) +// QueryConnection returns a connection end. +// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, +// it uses the gRPC query client. +func QueryConnection( + clientCtx client.Context, connectionID string, prove bool, +) (*types.QueryConnectionResponse, error) { + if prove { + return queryConnectionABCI(clientCtx, connectionID) } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAllConnections) - res, height, err := clientCtx.QueryWithData(route, bz) - if err != nil { - return nil, 0, err + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryConnectionRequest{ + ConnectionID: connectionID, } - var connections []types.ConnectionEnd - err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connections) - if err != nil { - return nil, 0, fmt.Errorf("failed to unmarshal connections: %w", err) - } - return connections, height, nil + return queryClient.Connection(context.Background(), req) } -// QueryConnection queries the store to get a connection end and a merkle -// proof. -func QueryConnection( - clientCtx client.Context, connectionID string, prove bool, -) (types.ConnectionResponse, error) { +func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types.QueryConnectionResponse, error) { req := abci.RequestQuery{ Path: "store/ibc/key", Data: host.KeyConnection(connectionID), - Prove: prove, + Prove: true, } res, err := clientCtx.QueryABCI(req) if err != nil { - return types.ConnectionResponse{}, err + return nil, err } var connection types.ConnectionEnd if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &connection); err != nil { - return types.ConnectionResponse{}, err + return nil, err } - connRes := types.NewConnectionResponse(connectionID, connection, res.Proof, res.Height) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + if err != nil { + return nil, err + } - return connRes, nil + return types.NewQueryConnectionResponse(connection, proofBz, res.Height), nil } -// QueryAllClientConnectionPaths returns all the client connections paths. It -// _does not_ return any merkle proof. -func QueryAllClientConnectionPaths(clientCtx client.Context, page, limit int) ([]types.ConnectionPaths, int64, error) { - params := types.NewQueryAllConnectionsParams(page, limit) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(params) - if err != nil { - return nil, 0, fmt.Errorf("failed to marshal query params: %w", err) +// QueryClientConnections queries the connection paths registered for a particular client. +// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, +// it uses the gRPC query client. +func QueryClientConnections( + clientCtx client.Context, clientID string, prove bool, +) (*types.QueryClientConnectionsResponse, error) { + if prove { + return queryClientConnectionsABCI(clientCtx, clientID) } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAllClientConnections) - res, height, err := clientCtx.QueryWithData(route, bz) - if err != nil { - return nil, 0, err + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryClientConnectionsRequest{ + ClientID: clientID, } - var connectionPaths []types.ConnectionPaths - err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connectionPaths) - if err != nil { - return nil, 0, fmt.Errorf("failed to unmarshal client connection paths: %w", err) - } - return connectionPaths, height, nil + return queryClient.ClientConnections(context.Background(), req) } -// QueryClientConnections queries the store to get the registered connection paths -// registered for a particular client and a merkle proof. -func QueryClientConnections( - clientCtx client.Context, clientID string, prove bool, -) (types.ClientConnectionsResponse, error) { +func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*types.QueryClientConnectionsResponse, error) { req := abci.RequestQuery{ Path: "store/ibc/key", Data: host.KeyClientConnections(clientID), - Prove: prove, + Prove: true, } res, err := clientCtx.QueryABCI(req) if err != nil { - return types.ClientConnectionsResponse{}, err + return nil, err } var paths []string if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &paths); err != nil { - return types.ClientConnectionsResponse{}, err + return nil, err + } + + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + if err != nil { + return nil, err } - connPathsRes := types.NewClientConnectionsResponse(clientID, paths, res.Proof, res.Height) - return connPathsRes, nil + return types.NewQueryClientConnectionsResponse(clientID, paths, proofBz, res.Height), nil } // ParsePrefix unmarshals an cmd input argument from a JSON string to a commitment diff --git a/x/ibc/03-connection/keeper/grpc_query.go b/x/ibc/03-connection/keeper/grpc_query.go new file mode 100644 index 000000000000..1c44b1b41ac4 --- /dev/null +++ b/x/ibc/03-connection/keeper/grpc_query.go @@ -0,0 +1,99 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" +) + +var _ types.QueryServer = Keeper{} + +// Connection implements the Query/Connection gRPC method +func (q Keeper) Connection(c context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ConnectionIdentifierValidator(req.ConnectionID); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + ctx := sdk.UnwrapSDKContext(c) + connection, found := q.GetConnection(ctx, req.ConnectionID) + if !found { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrap(types.ErrConnectionNotFound, req.ConnectionID).Error(), + ) + } + + return &types.QueryConnectionResponse{ + Connection: &connection, + ProofHeight: uint64(ctx.BlockHeight()), + }, nil +} + +// Connections implements the Query/Connections gRPC method +func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + + connections := []*types.ConnectionEnd{} + store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyConnectionPrefix) + + res, err := query.Paginate(store, req.Req, func(_, value []byte) error { + var result types.ConnectionEnd + if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil { + return err + } + + connections = append(connections, &result) + return nil + }) + + if err != nil { + return nil, err + } + + return &types.QueryConnectionsResponse{ + Connections: connections, + Res: res, + Height: ctx.BlockHeight(), + }, nil +} + +// ClientConnections implements the Query/ClientConnections gRPC method +func (q Keeper) ClientConnections(c context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, 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) + clientConnectionPaths, found := q.GetClientConnectionPaths(ctx, req.ClientID) + if !found { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrap(types.ErrClientConnectionPathsNotFound, req.ClientID).Error(), + ) + } + + return &types.QueryClientConnectionsResponse{ + ConnectionPaths: clientConnectionPaths, + ProofHeight: uint64(ctx.BlockHeight()), + }, nil +} diff --git a/x/ibc/03-connection/keeper/grpc_query_test.go b/x/ibc/03-connection/keeper/grpc_query_test.go new file mode 100644 index 000000000000..3db371fe6c9c --- /dev/null +++ b/x/ibc/03-connection/keeper/grpc_query_test.go @@ -0,0 +1,216 @@ +package keeper_test + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" +) + +func (suite *KeeperTestSuite) TestQueryConnection() { + var ( + req *types.QueryConnectionRequest + expConnection types.ConnectionEnd + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + {"invalid connectionID", + func() { + req = &types.QueryConnectionRequest{} + }, + false, + }, + {"connection not found", + func() { + req = &types.QueryConnectionRequest{ + ConnectionID: testConnectionIDB, + } + }, + false, + }, + { + "success", + func() { + counterparty := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + expConnection = types.NewConnectionEnd(types.INIT, testConnectionIDB, testClientIDB, counterparty, types.GetCompatibleVersions()) + suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), testConnectionIDB, expConnection) + + req = &types.QueryConnectionRequest{ + ConnectionID: testConnectionIDB, + } + }, + true, + }, + } + + 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.Connection(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(&expConnection, res.Connection) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryConnections() { + var ( + req *types.QueryConnectionsRequest + expConnections = []*types.ConnectionEnd{} + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "empty pagination", + func() { + req = &types.QueryConnectionsRequest{} + }, + true, + }, + { + "success", + func() { + counterparty1 := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + counterparty2 := types.NewCounterparty(testClientIDB, testConnectionIDB, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + counterparty3 := types.NewCounterparty(testClientID3, testConnectionID3, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + + conn1 := types.NewConnectionEnd(types.INIT, testConnectionIDA, testClientIDA, counterparty3, types.GetCompatibleVersions()) + conn2 := types.NewConnectionEnd(types.INIT, testConnectionIDB, testClientIDB, counterparty1, types.GetCompatibleVersions()) + conn3 := types.NewConnectionEnd(types.UNINITIALIZED, testConnectionID3, testClientID3, counterparty2, types.GetCompatibleVersions()) + + expConnections = []*types.ConnectionEnd{&conn1, &conn2, &conn3} + + for i := range expConnections { + suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), expConnections[i].ID, *expConnections[i]) + } + + req = &types.QueryConnectionsRequest{ + Req: &query.PageRequest{ + Limit: 3, + CountTotal: true, + }, + } + }, + true, + }, + } + + 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.Connections(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expConnections, res.Connections) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryClientConnections() { + var ( + req *types.QueryClientConnectionsRequest + expPaths []string + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + {"invalid connectionID", + func() { + req = &types.QueryClientConnectionsRequest{} + }, + false, + }, + {"connection not found", + func() { + req = &types.QueryClientConnectionsRequest{ + ClientID: testClientIDA, + } + }, + false, + }, + { + "success", + func() { + expPaths = []string{testConnectionIDA, testConnectionIDB} + suite.chainA.App.IBCKeeper.ConnectionKeeper.SetClientConnectionPaths(suite.chainA.GetContext(), testClientIDA, expPaths) + + req = &types.QueryClientConnectionsRequest{ + ClientID: testClientIDA, + } + }, + true, + }, + } + + 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.ClientConnections(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expPaths, res.ConnectionPaths) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/x/ibc/03-connection/keeper/keeper.go b/x/ibc/03-connection/keeper/keeper.go index 4af160720b60..2d116911c82a 100644 --- a/x/ibc/03-connection/keeper/keeper.go +++ b/x/ibc/03-connection/keeper/keeper.go @@ -18,6 +18,9 @@ import ( // Keeper defines the IBC connection keeper type Keeper struct { + // implements gRPC QueryServer interface + types.QueryServer + storeKey sdk.StoreKey aminoCdc *codec.Codec // amino codec. TODO: remove after clients have been migrated to proto cdc codec.Marshaler // hybrid codec diff --git a/x/ibc/03-connection/keeper/querier.go b/x/ibc/03-connection/keeper/querier.go deleted file mode 100644 index f0cf97acd1d4..000000000000 --- a/x/ibc/03-connection/keeper/querier.go +++ /dev/null @@ -1,82 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" -) - -// QuerierConnections defines the sdk.Querier to query all the connections. -func QuerierConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryAllConnectionsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - connections := k.GetAllConnections(ctx) - - start, end := client.Paginate(len(connections), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - connections = []types.ConnectionEnd{} - } else { - connections = connections[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, connections) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -// QuerierClientConnections defines the sdk.Querier to query the client connections -func QuerierClientConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryClientConnectionsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - clientConnectionPaths, found := k.GetClientConnectionPaths(ctx, params.ClientID) - if !found { - return nil, sdkerrors.Wrap(types.ErrClientConnectionPathsNotFound, params.ClientID) - } - - bz, err := types.SubModuleCdc.MarshalJSON(clientConnectionPaths) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -// QuerierAllClientConnections defines the sdk.Querier to query the connections paths for clients. -func QuerierAllClientConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryAllConnectionsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - clientsConnectionPaths := k.GetAllClientConnectionPaths(ctx) - - start, end := client.Paginate(len(clientsConnectionPaths), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - clientsConnectionPaths = []types.ConnectionPaths{} - } else { - clientsConnectionPaths = clientsConnectionPaths[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, clientsConnectionPaths) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/ibc/03-connection/module.go b/x/ibc/03-connection/module.go index c4f3a04c952b..6a6d9e2b9b86 100644 --- a/x/ibc/03-connection/module.go +++ b/x/ibc/03-connection/module.go @@ -1,6 +1,7 @@ package connection import ( + "github.com/gogo/protobuf/grpc" "github.com/gorilla/mux" "github.com/spf13/cobra" @@ -10,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" ) -// Name returns the IBC connection ICS name +// Name returns the IBC connection ICS name. func Name() string { return types.SubModuleName } @@ -20,7 +21,7 @@ func GetTxCmd(clientCtx client.Context) *cobra.Command { return cli.NewTxCmd(clientCtx) } -// GetQueryCmd returns no root query command for the IBC connections. +// GetQueryCmd returns the root query command for the IBC connections. func GetQueryCmd(clientCtx client.Context) *cobra.Command { return cli.GetQueryCmd(clientCtx) } @@ -29,3 +30,8 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command { func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { rest.RegisterRoutes(clientCtx, rtr) } + +// RegisterQueryService registers the gRPC query service for IBC connections. +func RegisterQueryService(server grpc.Server, queryServer types.QueryServer) { + types.RegisterQueryServer(server, queryServer) +} diff --git a/x/ibc/03-connection/types/connection.pb.go b/x/ibc/03-connection/types/connection.pb.go index d7f0e8d4ae5e..b60081471b4c 100644 --- a/x/ibc/03-connection/types/connection.pb.go +++ b/x/ibc/03-connection/types/connection.pb.go @@ -507,6 +507,7 @@ var xxx_messageInfo_Counterparty proto.InternalMessageInfo // ClientPaths define all the connection paths for a client state. type ClientPaths struct { + // list of connection paths Paths []string `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` } @@ -550,6 +551,61 @@ func (m *ClientPaths) GetPaths() []string { return nil } +// ConnectionPaths define all the connection paths for a given client state. +type ConnectionPaths struct { + // client state unique identifier + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // list of connection paths + Paths []string `protobuf:"bytes,2,rep,name=paths,proto3" json:"paths,omitempty"` +} + +func (m *ConnectionPaths) Reset() { *m = ConnectionPaths{} } +func (m *ConnectionPaths) String() string { return proto.CompactTextString(m) } +func (*ConnectionPaths) ProtoMessage() {} +func (*ConnectionPaths) Descriptor() ([]byte, []int) { + return fileDescriptor_3bf62bacf5a27ee9, []int{7} +} +func (m *ConnectionPaths) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConnectionPaths) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConnectionPaths.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 *ConnectionPaths) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConnectionPaths.Merge(m, src) +} +func (m *ConnectionPaths) XXX_Size() int { + return m.Size() +} +func (m *ConnectionPaths) XXX_DiscardUnknown() { + xxx_messageInfo_ConnectionPaths.DiscardUnknown(m) +} + +var xxx_messageInfo_ConnectionPaths proto.InternalMessageInfo + +func (m *ConnectionPaths) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *ConnectionPaths) GetPaths() []string { + if m != nil { + return m.Paths + } + return nil +} + func init() { proto.RegisterEnum("ibc.connection.State", State_name, State_value) proto.RegisterType((*MsgConnectionOpenInit)(nil), "ibc.connection.MsgConnectionOpenInit") @@ -559,66 +615,68 @@ func init() { proto.RegisterType((*ConnectionEnd)(nil), "ibc.connection.ConnectionEnd") proto.RegisterType((*Counterparty)(nil), "ibc.connection.Counterparty") proto.RegisterType((*ClientPaths)(nil), "ibc.connection.ClientPaths") + proto.RegisterType((*ConnectionPaths)(nil), "ibc.connection.ConnectionPaths") } func init() { proto.RegisterFile("ibc/connection/connection.proto", fileDescriptor_3bf62bacf5a27ee9) } var fileDescriptor_3bf62bacf5a27ee9 = []byte{ - // 864 bytes of a gzipped FileDescriptorProto + // 879 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x4f, 0x6f, 0xe2, 0x46, - 0x14, 0xc7, 0xc6, 0xfc, 0x1b, 0x20, 0xcb, 0x7a, 0xa1, 0x6b, 0xb9, 0x2b, 0xdb, 0xf5, 0x5e, 0x50, - 0xab, 0x40, 0x77, 0xb7, 0xda, 0x03, 0x52, 0x0f, 0x40, 0x88, 0x6a, 0xa9, 0x21, 0xc8, 0x21, 0x95, - 0x9a, 0x0b, 0x02, 0xdb, 0x81, 0x11, 0xc1, 0x46, 0xf6, 0xa4, 0x0a, 0xdf, 0x20, 0xe2, 0xd4, 0x6b, - 0x0f, 0x91, 0x2a, 0xe5, 0x4b, 0xf4, 0x13, 0x54, 0x39, 0xe6, 0xd8, 0x93, 0x55, 0x91, 0x6f, 0x80, - 0x7a, 0xea, 0xa9, 0xf2, 0x8c, 0xb1, 0x0d, 0x44, 0xad, 0x52, 0x72, 0xa8, 0x7a, 0xe2, 0xfd, 0xf9, - 0xbd, 0x37, 0xf3, 0xde, 0xef, 0xf1, 0x3c, 0x40, 0x84, 0x03, 0xad, 0xaa, 0x59, 0xa6, 0x69, 0x68, - 0x08, 0x5a, 0x66, 0x44, 0xac, 0x4c, 0x6d, 0x0b, 0x59, 0xec, 0x1e, 0x1c, 0x68, 0x95, 0xd0, 0xca, - 0x17, 0x87, 0xd6, 0xd0, 0xc2, 0xae, 0xaa, 0x27, 0x11, 0x14, 0xef, 0xa7, 0x99, 0x4c, 0x20, 0x9a, - 0x18, 0x26, 0x8a, 0x88, 0x04, 0x20, 0xff, 0x42, 0x83, 0xd2, 0x91, 0x33, 0x6c, 0x06, 0x89, 0x8e, - 0xa7, 0x86, 0xa9, 0x98, 0x10, 0xb1, 0x5f, 0x83, 0x8c, 0x76, 0x01, 0x0d, 0x13, 0xf5, 0xa0, 0xce, - 0x51, 0x12, 0x55, 0xce, 0x34, 0xa4, 0x85, 0x2b, 0xa6, 0x9b, 0xd8, 0xa8, 0x1c, 0x2c, 0x5d, 0xb1, - 0x30, 0xeb, 0x4f, 0x2e, 0x6a, 0x72, 0x00, 0x93, 0xd5, 0x34, 0x91, 0x15, 0x9d, 0x3d, 0x02, 0xf9, - 0xf0, 0x76, 0x5e, 0x0a, 0x1a, 0xa7, 0x28, 0x2f, 0x5c, 0x31, 0x17, 0x9e, 0x86, 0xd3, 0x14, 0xfd, - 0x34, 0x51, 0xb8, 0xac, 0xe6, 0x42, 0x5d, 0xd1, 0xd9, 0x43, 0x90, 0xd3, 0xac, 0x4b, 0x13, 0x19, - 0xf6, 0xb4, 0x6f, 0xa3, 0x19, 0x17, 0x97, 0xa8, 0x72, 0xf6, 0xfd, 0x9b, 0xca, 0x7a, 0x17, 0x2a, - 0xcd, 0x08, 0xa6, 0xc1, 0xdc, 0xb9, 0x62, 0x4c, 0x5d, 0x8b, 0x63, 0x15, 0x90, 0x74, 0xe0, 0xd0, - 0x34, 0x6c,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0xd4, 0x0c, 0x02, 0xbd, + 0x9f, 0x19, 0xa6, 0x62, 0x42, 0xc4, 0x7e, 0x0d, 0x32, 0xda, 0x05, 0x34, 0x4c, 0xd4, 0x83, 0x3a, + 0x47, 0x49, 0x54, 0x39, 0xd3, 0x90, 0x96, 0xae, 0x98, 0x6e, 0x62, 0xa3, 0x72, 0xbc, 0x72, 0xc5, + 0xc2, 0xbc, 0x3f, 0xbd, 0xa8, 0xc9, 0x01, 0x4c, 0x56, 0xd3, 0x44, 0x56, 0x74, 0xf6, 0x14, 0xe4, + 0xc3, 0xec, 0xbc, 0x10, 0x34, 0x0e, 0x51, 0x5e, 0xba, 0x62, 0x2e, 0xbc, 0x0d, 0x87, 0x29, 0xfa, + 0x61, 0xa2, 0x70, 0x59, 0xcd, 0x85, 0xba, 0xa2, 0xb3, 0x27, 0x20, 0xa7, 0x59, 0x97, 0x26, 0x32, + 0xec, 0x59, 0xdf, 0x46, 0x73, 0x2e, 0x2e, 0x51, 0xe5, 0xec, 0x9b, 0x97, 0x95, 0xcd, 0x2e, 0x54, + 0x9a, 0x11, 0x4c, 0x83, 0xb9, 0x75, 0xc5, 0x98, 0xba, 0x71, 0x8e, 0x55, 0x40, 0xd2, 0x81, 0x23, + 0xd3, 0xb0, 0x39, 0x46, 0xa2, 0xca, 0xb9, 0xc6, 0xeb, 0x3f, 0x5d, 0xf1, 0x68, 0x04, 0xd1, 0xf8, + 0x72, 0x50, 0xd1, 0xac, 0x69, 0x55, 0xb3, 0x9c, 0xa9, 0xe5, 0xf8, 0x3f, 0x47, 0x8e, 0x3e, 0xa9, + 0xa2, 0xf9, 0xcc, 0x70, 0x2a, 0x75, 0x4d, 0xab, 0xeb, 0xba, 0x6d, 0x38, 0x8e, 0xea, 0x07, 0x90, + 0xff, 0x60, 0x40, 0x71, 0xa7, 0x75, 0x5d, 0x7b, 0xfe, 0x3f, 0xed, 0xdc, 0x39, 0x28, 0x45, 0xf5, + 0xde, 0x0f, 0x86, 0xed, 0x40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f, 0xe0, 0x28, 0xcc, 0x01, 0x51, 0xe4, 0x21, 0x38, 0x0c, 0x93, 0x23, 0xc0, 0x3d, 0xfb, 0x10, + 0xdc, 0x43, 0x47, 0xee, 0xf9, 0xfc, 0x27, 0x0a, 0x24, 0x30, 0x99, 0xec, 0x3b, 0x20, 0x9e, 0x75, + 0xeb, 0xdd, 0x56, 0xef, 0xbc, 0xad, 0xb4, 0x95, 0xae, 0x52, 0xff, 0x56, 0xf9, 0xd0, 0x3a, 0xee, + 0x9d, 0xb7, 0xcf, 0x3a, 0xad, 0xa6, 0x72, 0xa2, 0xb4, 0x8e, 0x0b, 0x31, 0xfe, 0xd9, 0xe2, 0x5a, + 0xca, 0x6f, 0x00, 0x58, 0x0e, 0x00, 0x72, 0xce, 0x33, 0x16, 0x28, 0x3e, 0xbd, 0xb8, 0x96, 0x18, + 0x4f, 0x66, 0x05, 0x90, 0x27, 0x9e, 0xae, 0xfa, 0xfd, 0xfb, 0x4e, 0xab, 0x5d, 0xa0, 0xf9, 0xec, + 0xe2, 0x5a, 0x4a, 0xf9, 0x6a, 0x78, 0x12, 0x3b, 0xe3, 0xe4, 0xa4, 0x27, 0xf3, 0xcc, 0xd5, 0x8d, + 0x10, 0x6b, 0x74, 0x6e, 0x97, 0x02, 0x75, 0xb7, 0x14, 0xa8, 0xdf, 0x97, 0x02, 0xf5, 0xe3, 0xbd, + 0x10, 0xbb, 0xbb, 0x17, 0x62, 0xbf, 0xdd, 0x0b, 0xb1, 0x0f, 0xef, 0xfe, 0xf6, 0x3b, 0xfb, 0x58, + 0xf5, 0x5e, 0x84, 0x5f, 0xbe, 0x3d, 0x8a, 0xbc, 0x2d, 0xf1, 0xb7, 0x37, 0x48, 0xe2, 0x07, 0xe1, + 0xdb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x37, 0x42, 0xa5, 0xea, 0x7a, 0x0a, 0x00, 0x00, } func (m *MsgConnectionOpenInit) Marshal() (dAtA []byte, err error) { @@ -1019,6 +1077,45 @@ func (m *ClientPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ConnectionPaths) 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 *ConnectionPaths) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConnectionPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Paths[iNdEx]) + copy(dAtA[i:], m.Paths[iNdEx]) + i = encodeVarintConnection(dAtA, i, uint64(len(m.Paths[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintConnection(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintConnection(dAtA []byte, offset int, v uint64) int { offset -= sovConnection(v) base := offset @@ -1217,6 +1314,25 @@ func (m *ClientPaths) Size() (n int) { return n } +func (m *ConnectionPaths) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovConnection(uint64(l)) + } + if len(m.Paths) > 0 { + for _, s := range m.Paths { + l = len(s) + n += 1 + l + sovConnection(uint64(l)) + } + } + return n +} + func sovConnection(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2594,6 +2710,123 @@ func (m *ClientPaths) Unmarshal(dAtA []byte) error { } return nil } +func (m *ConnectionPaths) 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 ErrIntOverflowConnection + } + 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: ConnectionPaths: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConnectionPaths: 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 ErrIntOverflowConnection + } + 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 ErrInvalidLengthConnection + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + 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 Paths", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConnection + } + 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 ErrInvalidLengthConnection + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Paths = append(m.Paths, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConnection(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthConnection + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthConnection + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipConnection(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/03-connection/types/genesis.go b/x/ibc/03-connection/types/genesis.go index bec90f6949f8..9eef1ca04bd7 100644 --- a/x/ibc/03-connection/types/genesis.go +++ b/x/ibc/03-connection/types/genesis.go @@ -6,12 +6,6 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -// ConnectionPaths define all the connection paths for a given client state. -type ConnectionPaths struct { - ClientID string `json:"client_id" yaml:"client_id"` - Paths []string `json:"paths" yaml:"paths"` -} - // NewConnectionPaths creates a ConnectionPaths instance. func NewConnectionPaths(id string, paths []string) ConnectionPaths { return ConnectionPaths{ diff --git a/x/ibc/03-connection/types/querier.go b/x/ibc/03-connection/types/querier.go index 7b52eef12edb..d79f9bf5960e 100644 --- a/x/ibc/03-connection/types/querier.go +++ b/x/ibc/03-connection/types/querier.go @@ -3,8 +3,6 @@ package types import ( "strings" - "github.com/tendermint/tendermint/crypto/merkle" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -16,73 +14,35 @@ const ( QueryAllClientConnections = "all_client_connections" ) -// ConnectionResponse defines the client query response for a connection which -// also includes a proof and the height from which the proof was retrieved. -type ConnectionResponse struct { - Connection ConnectionEnd `json:"connection" yaml:"connection"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// NewConnectionResponse creates a new ConnectionResponse instance -func NewConnectionResponse( - connectionID string, connection ConnectionEnd, proof *merkle.Proof, height int64, -) ConnectionResponse { - return ConnectionResponse{ - Connection: connection, - Proof: commitmenttypes.MerkleProof{Proof: proof}, - ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ConnectionPath(connectionID), "/")), +// NewQueryConnectionResponse creates a new QueryConnectionResponse instance +func NewQueryConnectionResponse( + connection ConnectionEnd, proof []byte, height int64, +) *QueryConnectionResponse { + path := commitmenttypes.NewMerklePath(strings.Split(host.ConnectionPath(connection.ID), "/")) + return &QueryConnectionResponse{ + Connection: &connection, + Proof: proof, + ProofPath: path.Pretty(), ProofHeight: uint64(height), } } -// QueryAllConnectionsParams defines the parameters necessary for querying for all -// connections. -type QueryAllConnectionsParams struct { - Page int `json:"page" yaml:"page"` - Limit int `json:"limit" yaml:"limit"` -} - -// NewQueryAllConnectionsParams creates a new QueryAllConnectionsParams instance. -func NewQueryAllConnectionsParams(page, limit int) QueryAllConnectionsParams { - return QueryAllConnectionsParams{ - Page: page, - Limit: limit, - } -} - -// ClientConnectionsResponse defines the client query response for a client -// connection paths which also includes a proof and the height from which the -// proof was retrieved. -type ClientConnectionsResponse struct { - ConnectionPaths []string `json:"connection_paths" yaml:"connection_paths"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// NewClientConnectionsResponse creates a new ConnectionPaths instance -func NewClientConnectionsResponse( - clientID string, connectionPaths []string, proof *merkle.Proof, height int64, -) ClientConnectionsResponse { - return ClientConnectionsResponse{ +// NewQueryClientConnectionsResponse creates a new ConnectionPaths instance +func NewQueryClientConnectionsResponse( + clientID string, connectionPaths []string, proof []byte, height int64, +) *QueryClientConnectionsResponse { + path := commitmenttypes.NewMerklePath(strings.Split(host.ClientConnectionsPath(clientID), "/")) + return &QueryClientConnectionsResponse{ ConnectionPaths: connectionPaths, - Proof: commitmenttypes.MerkleProof{Proof: proof}, - ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ClientConnectionsPath(clientID), "/")), + Proof: proof, + ProofPath: path.Pretty(), ProofHeight: uint64(height), } } -// QueryClientConnectionsParams defines the params for the following queries: -// - 'custom/ibc/client//connections' -type QueryClientConnectionsParams struct { - ClientID string -} - -// NewQueryClientConnectionsParams creates a new QueryClientConnectionsParams instance -func NewQueryClientConnectionsParams(clientID string) QueryClientConnectionsParams { - return QueryClientConnectionsParams{ +// NewQueryClientConnectionsRequest creates a new QueryClientConnectionsRequest instance +func NewQueryClientConnectionsRequest(clientID string) *QueryClientConnectionsRequest { + return &QueryClientConnectionsRequest{ ClientID: clientID, } } diff --git a/x/ibc/03-connection/types/query.pb.go b/x/ibc/03-connection/types/query.pb.go new file mode 100644 index 000000000000..4083182b492c --- /dev/null +++ b/x/ibc/03-connection/types/query.pb.go @@ -0,0 +1,1799 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/connection/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryConnectionRequest is the request type for the Query/Connection RPC method +type QueryConnectionRequest struct { + // connection unique identifier + ConnectionID string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` +} + +func (m *QueryConnectionRequest) Reset() { *m = QueryConnectionRequest{} } +func (m *QueryConnectionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionRequest) ProtoMessage() {} +func (*QueryConnectionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{0} +} +func (m *QueryConnectionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionRequest.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 *QueryConnectionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionRequest.Merge(m, src) +} +func (m *QueryConnectionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionRequest proto.InternalMessageInfo + +func (m *QueryConnectionRequest) GetConnectionID() string { + if m != nil { + return m.ConnectionID + } + return "" +} + +// QueryConnectionResponse is the response type for the Query/Connection RPC method. +// Besides the connection end, it includes a proof and the height from which the +// proof was retrieved. +type QueryConnectionResponse struct { + // connection associated with the request identifier + Connection *ConnectionEnd `protobuf:"bytes,1,opt,name=connection,proto3" json:"connection,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // merkle proof path + ProofPath string `protobuf:"bytes,3,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` + // height at which the proof was retrieved + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` +} + +func (m *QueryConnectionResponse) Reset() { *m = QueryConnectionResponse{} } +func (m *QueryConnectionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionResponse) ProtoMessage() {} +func (*QueryConnectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{1} +} +func (m *QueryConnectionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionResponse.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 *QueryConnectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionResponse.Merge(m, src) +} +func (m *QueryConnectionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionResponse proto.InternalMessageInfo + +func (m *QueryConnectionResponse) GetConnection() *ConnectionEnd { + if m != nil { + return m.Connection + } + return nil +} + +func (m *QueryConnectionResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryConnectionResponse) GetProofPath() string { + if m != nil { + return m.ProofPath + } + return "" +} + +func (m *QueryConnectionResponse) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +// QueryConnectionsRequest is the request type for the Query/Connections RPC method +type QueryConnectionsRequest struct { + Req *query.PageRequest `protobuf:"bytes,1,opt,name=req,proto3" json:"req,omitempty"` +} + +func (m *QueryConnectionsRequest) Reset() { *m = QueryConnectionsRequest{} } +func (m *QueryConnectionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionsRequest) ProtoMessage() {} +func (*QueryConnectionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{2} +} +func (m *QueryConnectionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionsRequest.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 *QueryConnectionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionsRequest.Merge(m, src) +} +func (m *QueryConnectionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionsRequest proto.InternalMessageInfo + +func (m *QueryConnectionsRequest) GetReq() *query.PageRequest { + if m != nil { + return m.Req + } + return nil +} + +// QueryConnectionsResponse is the response type for the Query/Connections RPC method. +type QueryConnectionsResponse struct { + // list of stored connections of the chain. + Connections []*ConnectionEnd `protobuf:"bytes,1,rep,name=connections,proto3" json:"connections,omitempty"` + // pagination response + Res *query.PageResponse `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + // query block height + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryConnectionsResponse) Reset() { *m = QueryConnectionsResponse{} } +func (m *QueryConnectionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionsResponse) ProtoMessage() {} +func (*QueryConnectionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{3} +} +func (m *QueryConnectionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionsResponse.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 *QueryConnectionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionsResponse.Merge(m, src) +} +func (m *QueryConnectionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionsResponse proto.InternalMessageInfo + +func (m *QueryConnectionsResponse) GetConnections() []*ConnectionEnd { + if m != nil { + return m.Connections + } + return nil +} + +func (m *QueryConnectionsResponse) GetRes() *query.PageResponse { + if m != nil { + return m.Res + } + return nil +} + +func (m *QueryConnectionsResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryClientConnectionsRequest is the request type for the Query/ClientConnections +// RPC method +type QueryClientConnectionsRequest struct { + // client identifier associated with a connection + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *QueryClientConnectionsRequest) Reset() { *m = QueryClientConnectionsRequest{} } +func (m *QueryClientConnectionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClientConnectionsRequest) ProtoMessage() {} +func (*QueryClientConnectionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{4} +} +func (m *QueryClientConnectionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientConnectionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientConnectionsRequest.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 *QueryClientConnectionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientConnectionsRequest.Merge(m, src) +} +func (m *QueryClientConnectionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClientConnectionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientConnectionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientConnectionsRequest proto.InternalMessageInfo + +func (m *QueryClientConnectionsRequest) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +// QueryClientConnectionsResponse is the response type for the Query/ClientConnections +// RPC method +type QueryClientConnectionsResponse struct { + // slice of all the connection paths associated with a client. + ConnectionPaths []string `protobuf:"bytes,1,rep,name=connection_paths,json=connectionPaths,proto3" json:"connection_paths,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // merkle proof path + ProofPath string `protobuf:"bytes,3,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` + // height at which the proof was generated + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` +} + +func (m *QueryClientConnectionsResponse) Reset() { *m = QueryClientConnectionsResponse{} } +func (m *QueryClientConnectionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClientConnectionsResponse) ProtoMessage() {} +func (*QueryClientConnectionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ee60d8b08ce3606, []int{5} +} +func (m *QueryClientConnectionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientConnectionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientConnectionsResponse.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 *QueryClientConnectionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientConnectionsResponse.Merge(m, src) +} +func (m *QueryClientConnectionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClientConnectionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientConnectionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientConnectionsResponse proto.InternalMessageInfo + +func (m *QueryClientConnectionsResponse) GetConnectionPaths() []string { + if m != nil { + return m.ConnectionPaths + } + return nil +} + +func (m *QueryClientConnectionsResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryClientConnectionsResponse) GetProofPath() string { + if m != nil { + return m.ProofPath + } + return "" +} + +func (m *QueryClientConnectionsResponse) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func init() { + proto.RegisterType((*QueryConnectionRequest)(nil), "ibc.connection.QueryConnectionRequest") + proto.RegisterType((*QueryConnectionResponse)(nil), "ibc.connection.QueryConnectionResponse") + proto.RegisterType((*QueryConnectionsRequest)(nil), "ibc.connection.QueryConnectionsRequest") + proto.RegisterType((*QueryConnectionsResponse)(nil), "ibc.connection.QueryConnectionsResponse") + proto.RegisterType((*QueryClientConnectionsRequest)(nil), "ibc.connection.QueryClientConnectionsRequest") + proto.RegisterType((*QueryClientConnectionsResponse)(nil), "ibc.connection.QueryClientConnectionsResponse") +} + +func init() { proto.RegisterFile("ibc/connection/query.proto", fileDescriptor_5ee60d8b08ce3606) } + +var fileDescriptor_5ee60d8b08ce3606 = []byte{ + // 527 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xcd, 0x36, 0x6d, 0xd5, 0x4c, 0x02, 0x94, 0x55, 0x55, 0x8c, 0xa5, 0xb8, 0xc1, 0x07, 0x48, + 0x05, 0xb1, 0x51, 0x2a, 0xb8, 0x21, 0xa4, 0x52, 0x10, 0xe1, 0x42, 0xd8, 0x23, 0x97, 0x28, 0xb6, + 0x17, 0xdb, 0x82, 0x7a, 0x9d, 0xec, 0x46, 0xa2, 0x7f, 0xc1, 0x2f, 0x20, 0x7e, 0x80, 0x6f, 0xe0, + 0xc4, 0xb1, 0x47, 0x4e, 0x15, 0x72, 0x7e, 0x04, 0xed, 0xae, 0xd3, 0x35, 0x4d, 0xaa, 0x70, 0xe1, + 0x94, 0xdd, 0x9d, 0x37, 0x33, 0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 0xbf, 0xc2, 0x17, 0x5d, 0x8f, 0x87, 0x3f, 0x0b, 0x07, 0x9d, 0x17, 0x0e, 0xfa, 0x5d, + 0x38, 0xe8, 0xcb, 0xdc, 0xa9, 0x9d, 0xcf, 0x9d, 0xda, 0xaf, 0xb9, 0x53, 0x7b, 0xff, 0x34, 0x4e, + 0x45, 0x32, 0x0b, 0xbc, 0x90, 0x9d, 0xfa, 0xe5, 0x2e, 0xd2, 0x3f, 0x3d, 0x1e, 0x7d, 0xf4, 0x3f, + 0xfb, 0x72, 0x01, 0x3d, 0x3e, 0xea, 0x55, 0x76, 0x90, 0x38, 0xcb, 0x29, 0x0f, 0xb6, 0xd5, 0xfe, + 0x39, 0xfa, 0x13, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x7d, 0x4e, 0xc5, 0x03, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Connection queries an IBC connection end. + Connection(ctx context.Context, in *QueryConnectionRequest, opts ...grpc.CallOption) (*QueryConnectionResponse, error) + // Connections queries all the IBC connections of a chain. + Connections(ctx context.Context, in *QueryConnectionsRequest, opts ...grpc.CallOption) (*QueryConnectionsResponse, error) + // ClientConnections queries the connection paths associated with a client state. + ClientConnections(ctx context.Context, in *QueryClientConnectionsRequest, opts ...grpc.CallOption) (*QueryClientConnectionsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Connection(ctx context.Context, in *QueryConnectionRequest, opts ...grpc.CallOption) (*QueryConnectionResponse, error) { + out := new(QueryConnectionResponse) + err := c.cc.Invoke(ctx, "/ibc.connection.Query/Connection", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Connections(ctx context.Context, in *QueryConnectionsRequest, opts ...grpc.CallOption) (*QueryConnectionsResponse, error) { + out := new(QueryConnectionsResponse) + err := c.cc.Invoke(ctx, "/ibc.connection.Query/Connections", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ClientConnections(ctx context.Context, in *QueryClientConnectionsRequest, opts ...grpc.CallOption) (*QueryClientConnectionsResponse, error) { + out := new(QueryClientConnectionsResponse) + err := c.cc.Invoke(ctx, "/ibc.connection.Query/ClientConnections", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Connection queries an IBC connection end. + Connection(context.Context, *QueryConnectionRequest) (*QueryConnectionResponse, error) + // Connections queries all the IBC connections of a chain. + Connections(context.Context, *QueryConnectionsRequest) (*QueryConnectionsResponse, error) + // ClientConnections queries the connection paths associated with a client state. + ClientConnections(context.Context, *QueryClientConnectionsRequest) (*QueryClientConnectionsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Connection(ctx context.Context, req *QueryConnectionRequest) (*QueryConnectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Connection not implemented") +} +func (*UnimplementedQueryServer) Connections(ctx context.Context, req *QueryConnectionsRequest) (*QueryConnectionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Connections not implemented") +} +func (*UnimplementedQueryServer) ClientConnections(ctx context.Context, req *QueryClientConnectionsRequest) (*QueryClientConnectionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClientConnections not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Connection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConnectionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Connection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.connection.Query/Connection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Connection(ctx, req.(*QueryConnectionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Connections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConnectionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Connections(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.connection.Query/Connections", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Connections(ctx, req.(*QueryConnectionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ClientConnections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClientConnectionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ClientConnections(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.connection.Query/ClientConnections", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ClientConnections(ctx, req.(*QueryClientConnectionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.connection.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Connection", + Handler: _Query_Connection_Handler, + }, + { + MethodName: "Connections", + Handler: _Query_Connections_Handler, + }, + { + MethodName: "ClientConnections", + Handler: _Query_ClientConnections_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/connection/query.proto", +} + +func (m *QueryConnectionRequest) 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 *QueryConnectionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryConnectionResponse) 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 *QueryConnectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ProofPath) > 0 { + i -= len(m.ProofPath) + copy(dAtA[i:], m.ProofPath) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProofPath))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.Connection != nil { + { + size, err := m.Connection.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 *QueryConnectionsRequest) 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 *QueryConnectionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Req != nil { + { + size, err := m.Req.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 *QueryConnectionsResponse) 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 *QueryConnectionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Connections) > 0 { + for iNdEx := len(m.Connections) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Connections[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 *QueryClientConnectionsRequest) 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 *QueryClientConnectionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientConnectionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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 *QueryClientConnectionsResponse) 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 *QueryClientConnectionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientConnectionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ProofPath) > 0 { + i -= len(m.ProofPath) + copy(dAtA[i:], m.ProofPath) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProofPath))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if len(m.ConnectionPaths) > 0 { + for iNdEx := len(m.ConnectionPaths) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConnectionPaths[iNdEx]) + copy(dAtA[i:], m.ConnectionPaths[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConnectionPaths[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryConnectionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConnectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Connection != nil { + l = m.Connection.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ProofPath) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofHeight != 0 { + n += 1 + sovQuery(uint64(m.ProofHeight)) + } + return n +} + +func (m *QueryConnectionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConnectionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Connections) > 0 { + for _, e := range m.Connections { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryClientConnectionsRequest) 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)) + } + return n +} + +func (m *QueryClientConnectionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ConnectionPaths) > 0 { + for _, s := range m.ConnectionPaths { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ProofPath) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofHeight != 0 { + n += 1 + sovQuery(uint64(m.ProofHeight)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryConnectionRequest) 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: QueryConnectionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", 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.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConnectionResponse) 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: QueryConnectionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Connection", 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.Connection == nil { + m.Connection = &ConnectionEnd{} + } + if err := m.Connection.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPath", 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.ProofPath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConnectionsRequest) 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: QueryConnectionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", 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.Req == nil { + m.Req = &query.PageRequest{} + } + if err := m.Req.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConnectionsResponse) 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: QueryConnectionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Connections", 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.Connections = append(m.Connections, &ConnectionEnd{}) + if err := m.Connections[len(m.Connections)-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 Res", 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.Res == nil { + m.Res = &query.PageResponse{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryClientConnectionsRequest) 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: QueryClientConnectionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientConnectionsRequest: 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 + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryClientConnectionsResponse) 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: QueryClientConnectionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientConnectionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionPaths", 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.ConnectionPaths = append(m.ConnectionPaths, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPath", 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.ProofPath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/04-channel/client/cli/cli.go b/x/ibc/04-channel/client/cli/cli.go index 2c81e973197d..041c039fada2 100644 --- a/x/ibc/04-channel/client/cli/cli.go +++ b/x/ibc/04-channel/client/cli/cli.go @@ -19,13 +19,15 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command { } ics04ChannelQueryCmd.AddCommand(flags.GetCommands( - // TODO: Query all channels + GetCmdQueryChannels(clientCtx), GetCmdQueryChannel(clientCtx), - // TODO: Query channels from a connection + GetCmdQueryConnectionChannels(clientCtx), GetCmdQueryChannelClientState(clientCtx), - // TODO: Query all packet commitments - // TODO: Query unrelayed packet ACKS - // TODO: Query unrelayed packet sends + GetCmdQueryPacketCommitment(clientCtx), + GetCmdQueryPacketCommitments(clientCtx), + GetCmdQueryUnrelayedPackets(clientCtx), + GetCmdQueryNextSequenceReceive(clientCtx), + // TODO: next sequence Send ? )...) return ics04ChannelQueryCmd diff --git a/x/ibc/04-channel/client/cli/query.go b/x/ibc/04-channel/client/cli/query.go index c40a13fe8e16..6bb6493052af 100644 --- a/x/ibc/04-channel/client/cli/query.go +++ b/x/ibc/04-channel/client/cli/query.go @@ -1,18 +1,61 @@ package cli import ( + "context" "fmt" + "strconv" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) +const flagSequences = "sequences" + +// GetCmdQueryChannels defines the command to query all the channels ends +// that this chain mantains. +func GetCmdQueryChannels(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "channels", + Short: "Query all channels", + Long: "Query all channels from a chain", + Example: fmt.Sprintf("%s query %s %s channels", version.ClientName, host.ModuleName, types.SubModuleName), + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx = clientCtx.Init() + queryClient := types.NewQueryClient(clientCtx) + + offset, _ := cmd.Flags().GetInt(flags.FlagPage) + limit, _ := cmd.Flags().GetInt(flags.FlagLimit) + + req := &types.QueryChannelsRequest{ + Req: &query.PageRequest{ + Offset: uint64(offset), + Limit: uint64(limit), + }, + } + + res, err := queryClient.Channels(context.Background(), req) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(res.Height) + return clientCtx.PrintOutput(res) + }, + } + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") + cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") + + return cmd +} + // GetCmdQueryChannel defines the command to query a channel end func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command { cmd := &cobra.Command{ @@ -28,7 +71,10 @@ func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command { portID := args[0] channelID := args[1] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } channelRes, err := utils.QueryChannel(clientCtx, portID, channelID, prove) if err != nil { @@ -40,6 +86,44 @@ func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command { }, } cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + return cmd +} + +// GetCmdQueryConnectionChannels defines the command to query all the channels associated with a +// connection +func GetCmdQueryConnectionChannels(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "connections [connection-id]", + Short: "Query all channels associated with a connection", + Long: "Query all channels associated with a connection", + Example: fmt.Sprintf("%s query %s %s connections [connection-id]", version.ClientName, host.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx = clientCtx.Init() + queryClient := types.NewQueryClient(clientCtx) + + offset, _ := cmd.Flags().GetInt(flags.FlagPage) + limit, _ := cmd.Flags().GetInt(flags.FlagLimit) + + req := &types.QueryConnectionChannelsRequest{ + Connection: args[0], + Req: &query.PageRequest{ + Offset: uint64(offset), + Limit: uint64(limit), + }, + } + + res, err := queryClient.ConnectionChannels(context.Background(), req) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(res.Height) + return clientCtx.PrintOutput(res) + }, + } + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") + cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") return cmd } @@ -52,7 +136,7 @@ func GetCmdQueryChannelClientState(clientCtx client.Context) *cobra.Command { Long: "Query the client state associated with a channel, by providing its port and channel identifiers.", Example: fmt.Sprintf("%s query ibc channel client-state [port-id] [channel-id]", version.ClientName), Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { clientCtx = clientCtx.Init() portID := args[0] @@ -69,3 +153,169 @@ func GetCmdQueryChannelClientState(clientCtx client.Context) *cobra.Command { } return cmd } + +// GetCmdQueryPacketCommitments defines the command to query all packet commitments associated with +// a channel +func GetCmdQueryPacketCommitments(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-commitments [port-id] [channel-id]", + Short: "Query all packet commitments associated with a channel", + Long: "Query all packet commitments associated with a channel", + Example: fmt.Sprintf("%s query %s %s packet-commitments [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx = clientCtx.Init() + queryClient := types.NewQueryClient(clientCtx) + + offset, _ := cmd.Flags().GetInt(flags.FlagPage) + limit, _ := cmd.Flags().GetInt(flags.FlagLimit) + + req := &types.QueryPacketCommitmentsRequest{ + PortID: args[0], + ChannelID: args[1], + Req: &query.PageRequest{ + Offset: uint64(offset), + Limit: uint64(limit), + }, + } + + res, err := queryClient.PacketCommitments(context.Background(), req) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(res.Height) + return clientCtx.PrintOutput(res) + }, + } + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") + cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") + + return cmd +} + +// GetCmdQueryPacketCommitment defines the command to query a channel end +func GetCmdQueryPacketCommitment(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-commitment [port-id] [channel-id] [sequence]", + Short: "Query a packet commitment", + Long: "Query a packet commitment", + Example: fmt.Sprintf( + "%s query %s %s end [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx = clientCtx.Init() + + portID := args[0] + channelID := args[1] + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + res, err := utils.QueryPacketCommitment(clientCtx, portID, channelID, seq, prove) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(int64(res.ProofHeight)) + return clientCtx.PrintOutput(res) + }, + } + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + return cmd +} + +// GetCmdQueryUnrelayedPackets defines the command to query all the unrelayed packets. +func GetCmdQueryUnrelayedPackets(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "unrelayed-packets [port-id] [channel-id]", + Short: "Query all the unrelayed packets associated with a channel", + Long: `It indicates if a packet, given a list of packet commitment sequences, is unrelayed. +An unrelayed packet corresponds to: + +- Unrelayed packet commitments: when no acknowledgement exists for the given sequence. +- Unrelayed packet acknowledgements: when an acknowledgement exists and a packet commitment also exists.`, + Example: fmt.Sprintf("%s query %s %s unrelayed-packets [port-id] [channel-id] --sequences=1,2,3", version.ClientName, host.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx = clientCtx.Init() + queryClient := types.NewQueryClient(clientCtx) + + seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences) + if err != nil { + return err + } + + seqs := make([]uint64, len(seqSlice)) + for i := range seqSlice { + seqs[i] = uint64(seqSlice[i]) + } + + offset, _ := cmd.Flags().GetInt(flags.FlagPage) + limit, _ := cmd.Flags().GetInt(flags.FlagLimit) + + req := &types.QueryUnrelayedPacketsRequest{ + PortID: args[0], + ChannelID: args[1], + Sequences: seqs, + Req: &query.PageRequest{ + Offset: uint64(offset), + Limit: uint64(limit), + }, + } + + res, err := queryClient.UnrelayedPackets(context.Background(), req) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(res.Height) + return clientCtx.PrintOutput(res) + }, + } + cmd.Flags().Int64Slice(flagSequences, []int64{}, "comma separated list of packet sequence numbers") + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") + cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") + + return cmd +} + +// GetCmdQueryNextSequenceReceive defines the command to query a next receive sequence for a given channel +func GetCmdQueryNextSequenceReceive(clientCtx client.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "next-sequence-receive [port-id] [channel-id]", + Short: "Query a next receive sequence", + Long: "Query the next receive sequence for a given channel", + Example: fmt.Sprintf( + "%s query %s %s next-sequence-receive [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx = clientCtx.Init() + + portID := args[0] + channelID := args[1] + prove, err := cmd.Flags().GetBool(flags.FlagProve) + if err != nil { + return err + } + + sequenceRes, err := utils.QueryNextSequenceReceive(clientCtx, portID, channelID, prove) + if err != nil { + return err + } + + clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight)) + return clientCtx.PrintOutput(sequenceRes) + }, + } + cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + return cmd +} diff --git a/x/ibc/04-channel/client/rest/query.go b/x/ibc/04-channel/client/rest/query.go index cc296c66e769..7ac297d572ea 100644 --- a/x/ibc/04-channel/client/rest/query.go +++ b/x/ibc/04-channel/client/rest/query.go @@ -15,20 +15,9 @@ import ( func registerQueryRoutes(clientCtx client.Context, r *mux.Router) { r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}", RestPortID, RestChannelID), queryChannelHandlerFn(clientCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/client_state", RestPortID, RestChannelID), queryChannelClientStateHandlerFn(clientCtx)).Methods("GET") + r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/next_sequence_receive", RestPortID, RestChannelID), queryNextSequenceRecvHandlerFn(clientCtx)).Methods("GET") } -// queryChannelHandlerFn implements a channel querying route -// -// @Summary Query channel -// @Tags IBC -// @Produce json -// @Param port-id path string true "Port ID" -// @Param channel-id path string true "Channel ID" -// @Param prove query boolean false "Proof of result" -// @Success 200 {object} QueryChannel "OK" -// @Failure 400 {object} rest.ErrorResponse "Invalid port id or channel id" -// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" -// @Router /ibc/ports/{port-id}/channels/{channel-id} [get] func queryChannelHandlerFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) @@ -73,3 +62,26 @@ func queryChannelClientStateHandlerFn(clientCtx client.Context) http.HandlerFunc rest.PostProcessResponse(w, clientCtx, clientState) } } + +func queryNextSequenceRecvHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + portID := vars[RestPortID] + channelID := vars[RestChannelID] + prove := rest.ParseQueryParamBool(r, flags.FlagProve) + + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + sequenceRes, err := utils.QueryNextSequenceReceive(clientCtx, portID, channelID, prove) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight)) + rest.PostProcessResponse(w, clientCtx, sequenceRes) + } +} diff --git a/x/ibc/04-channel/client/utils/utils.go b/x/ibc/04-channel/client/utils/utils.go index 61c6c7b4f268..d1cd2aac62b6 100644 --- a/x/ibc/04-channel/client/utils/utils.go +++ b/x/ibc/04-channel/client/utils/utils.go @@ -1,6 +1,8 @@ package utils import ( + "context" + "encoding/binary" "fmt" abci "github.com/tendermint/tendermint/abci/types" @@ -11,71 +13,98 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -// QueryPacket returns a packet from the store -func QueryPacket( - ctx client.Context, portID, channelID string, - sequence, timeoutHeight, timeoutTimestamp uint64, prove bool, -) (types.PacketResponse, error) { +// QueryPacketCommitment returns a packet commitment. +// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, +// it uses the gRPC query client. +func QueryPacketCommitment( + clientCtx client.Context, portID, channelID string, + sequence uint64, prove bool, +) (*types.QueryPacketCommitmentResponse, error) { + if prove { + return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence) + } + + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryPacketCommitmentRequest{ + PortID: portID, + ChannelID: channelID, + Sequence: sequence, + } + + return queryClient.PacketCommitment(context.Background(), req) +} + +func queryPacketCommitmentABCI( + clientCtx client.Context, portID, channelID string, sequence uint64, +) (*types.QueryPacketCommitmentResponse, error) { req := abci.RequestQuery{ Path: "store/ibc/key", Data: host.KeyPacketCommitment(portID, channelID, sequence), - Prove: prove, + Prove: true, } - res, err := ctx.QueryABCI(req) + res, err := clientCtx.QueryABCI(req) if err != nil { - return types.PacketResponse{}, err + return nil, err } - channelRes, err := QueryChannel(ctx, portID, channelID, prove) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) if err != nil { - return types.PacketResponse{}, err + return nil, err } - destPortID := channelRes.Channel.Counterparty.PortID - destChannelID := channelRes.Channel.Counterparty.ChannelID - - packet := types.NewPacket( - res.Value, - sequence, - portID, - channelID, - destPortID, - destChannelID, - timeoutHeight, - timeoutTimestamp, - ) - // FIXME: res.Height+1 is hack, fix later - return types.NewPacketResponse(portID, channelID, sequence, packet, res.Proof, res.Height+1), nil + return types.NewQueryPacketCommitmentResponse(portID, channelID, sequence, res.Value, proofBz, res.Height+1), nil } -// QueryChannel queries the store to get a channel and a merkle proof. +// QueryChannel returns a channel end. +// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, +// it uses the gRPC query client. func QueryChannel( - ctx client.Context, portID, channelID string, prove bool, -) (types.ChannelResponse, error) { + clientCtx client.Context, portID, channelID string, prove bool, +) (*types.QueryChannelResponse, error) { + if prove { + return queryChannelABCI(clientCtx, portID, channelID) + } + + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryChannelRequest{ + PortID: portID, + ChannelID: channelID, + } + + return queryClient.Channel(context.Background(), req) +} + +func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*types.QueryChannelResponse, error) { req := abci.RequestQuery{ Path: "store/ibc/key", Data: host.KeyChannel(portID, channelID), - Prove: prove, + Prove: true, } - res, err := ctx.QueryABCI(req) - if res.Value == nil || err != nil { - return types.ChannelResponse{}, err + res, err := clientCtx.QueryABCI(req) + if err != nil { + return nil, err } var channel types.Channel - if err := ctx.Codec.UnmarshalBinaryBare(res.Value, &channel); err != nil { - return types.ChannelResponse{}, err + if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &channel); err != nil { + return nil, err } - return types.NewChannelResponse(portID, channelID, channel, res.Proof, res.Height), nil + + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + if err != nil { + return nil, err + } + + return types.NewQueryChannelResponse(portID, channelID, channel, proofBz, res.Height), nil } // QueryChannelClientState uses the channel Querier to return the ClientState of // a Channel. func QueryChannelClientState(clientCtx client.Context, portID, channelID string) (clientexported.ClientState, int64, error) { - params := types.NewQueryChannelClientStateParams(portID, channelID) + params := types.NewQueryChannelClientStateRequest(portID, channelID) bz, err := clientCtx.JSONMarshaler.MarshalJSON(params) if err != nil { return nil, 0, fmt.Errorf("failed to marshal query params: %w", err) @@ -94,3 +123,43 @@ func QueryChannelClientState(clientCtx client.Context, portID, channelID string) } return clientState, height, nil } + +// QueryNextSequenceReceive returns the next sequence receive. +// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, +// it uses the gRPC query client. +func QueryNextSequenceReceive( + clientCtx client.Context, portID, channelID string, prove bool, +) (*types.QueryNextSequenceReceiveResponse, error) { + if prove { + return queryNextSequenceRecvABCI(clientCtx, portID, channelID) + } + + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryNextSequenceReceiveRequest{ + PortID: portID, + ChannelID: channelID, + } + + return queryClient.NextSequenceReceive(context.Background(), req) +} + +func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID string) (*types.QueryNextSequenceReceiveResponse, error) { + req := abci.RequestQuery{ + Path: "store/ibc/key", + Data: host.KeyNextSequenceRecv(portID, channelID), + Prove: true, + } + + res, err := clientCtx.QueryABCI(req) + if err != nil { + return nil, err + } + + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + if err != nil { + return nil, err + } + + sequence := binary.BigEndian.Uint64(res.Value) + return types.NewQueryNextSequenceReceiveResponse(portID, channelID, sequence, proofBz, res.Height), nil +} diff --git a/x/ibc/04-channel/genesis.go b/x/ibc/04-channel/genesis.go index 8fc68b9c4bed..78ef9b6bd521 100644 --- a/x/ibc/04-channel/genesis.go +++ b/x/ibc/04-channel/genesis.go @@ -11,7 +11,7 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { for _, channel := range gs.Channels { ch := types.NewChannel(channel.State, channel.Ordering, channel.Counterparty, channel.ConnectionHops, channel.Version) - k.SetChannel(ctx, channel.PortID, channel.ID, ch) + k.SetChannel(ctx, channel.PortID, channel.ChannelID, ch) } for _, ack := range gs.Acknowledgements { k.SetPacketAcknowledgement(ctx, ack.PortID, ack.ChannelID, ack.Sequence, ack.Hash) diff --git a/x/ibc/04-channel/keeper/grpc_query.go b/x/ibc/04-channel/keeper/grpc_query.go new file mode 100644 index 000000000000..6c472888b0e8 --- /dev/null +++ b/x/ibc/04-channel/keeper/grpc_query.go @@ -0,0 +1,267 @@ +package keeper + +import ( + "context" + "strconv" + "strings" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" +) + +var _ types.QueryServer = (*Keeper)(nil) + +// Channel implements the Query/Channel gRPC method +func (q Keeper) Channel(c context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + channel, found := q.GetChannel(ctx, req.PortID, req.ChannelID) + if !found { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortID, req.ChannelID).Error(), + ) + } + + return types.NewQueryChannelResponse(req.PortID, req.ChannelID, channel, nil, ctx.BlockHeight()), nil +} + +// Channels implements the Query/Channels gRPC method +func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*types.QueryChannelsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + + channels := []*types.IdentifiedChannel{} + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix)) + + res, err := query.Paginate(store, req.Req, func(key, value []byte) error { + var result types.Channel + if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil { + return err + } + + portID, channelID, err := host.ParseChannelPath(string(key)) + if err != nil { + return err + } + + identifiedChannel := types.NewIdentifiedChannel(portID, channelID, result) + channels = append(channels, &identifiedChannel) + return nil + }) + + if err != nil { + return nil, err + } + + return &types.QueryChannelsResponse{ + Channels: channels, + Res: res, + Height: ctx.BlockHeight(), + }, nil +} + +// ConnectionChannels implements the Query/ConnectionChannels gRPC method +func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnectionChannelsRequest) (*types.QueryConnectionChannelsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ConnectionIdentifierValidator(req.Connection); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + ctx := sdk.UnwrapSDKContext(c) + + channels := []*types.IdentifiedChannel{} + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix)) + + res, err := query.Paginate(store, req.Req, func(key, value []byte) error { + var result types.Channel + if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil { + return err + } + + // ignore channel and continue to the next item if the connection is + // different than the requested one + if result.ConnectionHops[0] != req.Connection { + return nil + } + + portID, channelID, err := host.ParseChannelPath(string(key)) + if err != nil { + return err + } + + identifiedChannel := types.NewIdentifiedChannel(portID, channelID, result) + channels = append(channels, &identifiedChannel) + return nil + }) + + if err != nil { + return nil, err + } + + return &types.QueryConnectionChannelsResponse{ + Channels: channels, + Res: res, + Height: ctx.BlockHeight(), + }, nil +} + +// PacketCommitment implements the Query/PacketCommitment gRPC method +func (q Keeper) PacketCommitment(c context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil { + return nil, err + } + + if req.Sequence == 0 { + return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + + commitmentBz := q.GetPacketCommitment(ctx, req.PortID, req.ChannelID, req.Sequence) + if len(commitmentBz) == 0 { + return nil, status.Error(codes.NotFound, "packet commitment hash not found") + } + + return types.NewQueryPacketCommitmentResponse(req.PortID, req.ChannelID, req.Sequence, commitmentBz, nil, ctx.BlockHeight()), nil +} + +// PacketCommitments implements the Query/PacketCommitments gRPC method +func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommitmentsRequest) (*types.QueryPacketCommitmentsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + + commitments := []*types.PacketAckCommitment{} + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketCommitmentPrefixPath(req.PortID, req.ChannelID))) + + res, err := query.Paginate(store, req.Req, func(key, value []byte) error { + keySplit := strings.Split(string(key), "/") + + sequence, err := strconv.ParseUint(keySplit[len(keySplit)-1], 10, 64) + if err != nil { + return err + } + + commitment := types.NewPacketAckCommitment(req.PortID, req.ChannelID, sequence, value) + commitments = append(commitments, &commitment) + return nil + }) + + if err != nil { + return nil, err + } + + return &types.QueryPacketCommitmentsResponse{ + Commitments: commitments, + Res: res, + Height: ctx.BlockHeight(), + }, nil +} + +// UnrelayedPackets implements the Query/UnrelayedPackets gRPC method +func (q Keeper) UnrelayedPackets(c context.Context, req *types.QueryUnrelayedPacketsRequest) (*types.QueryUnrelayedPacketsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + + var ( + unrelayedPackets = []uint64{} + store sdk.KVStore + res *query.PageResponse + err error + ) + + for i, seq := range req.Sequences { + if seq == 0 { + return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i) + } + + store = prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyPacketAcknowledgement(req.PortID, req.ChannelID, seq)) + res, err = query.Paginate(store, req.Req, func(_, _ []byte) error { + return nil + }) + + if err != nil { + // ignore error and continue to the next sequence item + continue + } + + unrelayedPackets = append(unrelayedPackets, seq) + } + return &types.QueryUnrelayedPacketsResponse{ + Packets: unrelayedPackets, + Res: res, + Height: ctx.BlockHeight(), + }, nil +} + +// NextSequenceReceive implements the Query/NextSequenceReceive gRPC method +func (q Keeper) NextSequenceReceive(c context.Context, req *types.QueryNextSequenceReceiveRequest) (*types.QueryNextSequenceReceiveResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + sequence, found := q.GetNextSequenceRecv(ctx, req.PortID, req.ChannelID) + if !found { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrapf(types.ErrSequenceReceiveNotFound, "port-id: %s, channel-id %s", req.PortID, req.ChannelID).Error(), + ) + } + + return types.NewQueryNextSequenceReceiveResponse(req.PortID, req.ChannelID, sequence, nil, ctx.BlockHeight()), nil +} + +func validategRPCRequest(portID, channelID string) error { + if err := host.PortIdentifierValidator(portID); err != nil { + return status.Error(codes.InvalidArgument, err.Error()) + } + + if err := host.ChannelIdentifierValidator(channelID); err != nil { + return status.Error(codes.InvalidArgument, err.Error()) + } + + return nil +} diff --git a/x/ibc/04-channel/keeper/grpc_query_test.go b/x/ibc/04-channel/keeper/grpc_query_test.go new file mode 100644 index 000000000000..fa3524b3e177 --- /dev/null +++ b/x/ibc/04-channel/keeper/grpc_query_test.go @@ -0,0 +1,657 @@ +package keeper_test + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" +) + +func (suite *KeeperTestSuite) TestQueryChannel() { + var ( + req *types.QueryChannelRequest + expChannel types.Channel + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid port ID", + func() { + req = &types.QueryChannelRequest{ + PortID: "", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "invalid channel ID", + func() { + req = &types.QueryChannelRequest{ + PortID: "test-port-id", + ChannelID: "", + } + }, + false, + }, + {"channel not found", + func() { + req = &types.QueryChannelRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "success", + func() { + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) + // init channel + channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, types.ORDERED) + suite.Require().NoError(err) + + expChannel = suite.chainA.GetChannel(channelA) + + req = &types.QueryChannelRequest{ + PortID: channelA.PortID, + ChannelID: channelA.ID, + } + }, + true, + }, + } + + 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.Channel(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(&expChannel, res.Channel) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryChannels() { + var ( + req *types.QueryChannelsRequest + expChannels = []*types.IdentifiedChannel{} + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "empty pagination", + func() { + req = &types.QueryChannelsRequest{} + }, + true, + }, + { + "success", + func() { + _, _, connA0, connB0, testchannel0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + // channel0 on first connection on chainA + counterparty0 := types.Counterparty{ + PortID: connB0.Channels[0].PortID, + ChannelID: connB0.Channels[0].ID, + } + + // channel1 is second channel on first connection on chainA + testchannel1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA0, connB0, types.ORDERED) + counterparty1 := types.Counterparty{ + PortID: connB0.Channels[1].PortID, + ChannelID: connB0.Channels[1].ID, + } + + channel0 := types.NewChannel( + types.OPEN, types.UNORDERED, + counterparty0, []string{connA0.ID}, ibctesting.ChannelVersion, + ) + channel1 := types.NewChannel( + types.OPEN, types.ORDERED, + counterparty1, []string{connA0.ID}, ibctesting.ChannelVersion, + ) + + idCh0 := types.NewIdentifiedChannel(testchannel0.PortID, testchannel0.ID, channel0) + idCh1 := types.NewIdentifiedChannel(testchannel1.PortID, testchannel1.ID, channel1) + + expChannels = []*types.IdentifiedChannel{&idCh0, &idCh1} + + req = &types.QueryChannelsRequest{ + Req: &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: true, + }, + } + }, + true, + }, + } + + 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.Channels(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expChannels, res.Channels) + suite.Require().Equal(len(expChannels), int(res.Res.Total)) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryConnectionChannels() { + var ( + req *types.QueryConnectionChannelsRequest + expChannels = []*types.IdentifiedChannel{} + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid connection ID", + func() { + req = &types.QueryConnectionChannelsRequest{ + Connection: "", + } + }, + false, + }, + { + "success", + func() { + _, _, connA0, connB0, testchannel0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + // channel0 on first connection on chainA + counterparty0 := types.Counterparty{ + PortID: connB0.Channels[0].PortID, + ChannelID: connB0.Channels[0].ID, + } + + // channel1 is second channel on first connection on chainA + testchannel1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA0, connB0, types.ORDERED) + counterparty1 := types.Counterparty{ + PortID: connB0.Channels[1].PortID, + ChannelID: connB0.Channels[1].ID, + } + + channel0 := types.NewChannel( + types.OPEN, types.UNORDERED, + counterparty0, []string{connA0.ID}, ibctesting.ChannelVersion, + ) + channel1 := types.NewChannel( + types.OPEN, types.ORDERED, + counterparty1, []string{connA0.ID}, ibctesting.ChannelVersion, + ) + + idCh0 := types.NewIdentifiedChannel(testchannel0.PortID, testchannel0.ID, channel0) + idCh1 := types.NewIdentifiedChannel(testchannel1.PortID, testchannel1.ID, channel1) + + expChannels = []*types.IdentifiedChannel{&idCh0, &idCh1} + + req = &types.QueryConnectionChannelsRequest{ + Connection: connB0.ID, + Req: &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: true, + }, + } + }, + true, + }, + { + "success, empty response", + func() { + suite.coordinator.Setup(suite.chainA, suite.chainB) + expChannels = []*types.IdentifiedChannel{} + req = &types.QueryConnectionChannelsRequest{ + Connection: "externalConnID", + Req: &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: false, + }, + } + }, + true, + }, + } + + 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.ConnectionChannels(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expChannels, res.Channels) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryPacketCommitment() { + var ( + req *types.QueryPacketCommitmentRequest + expCommitment []byte + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid port ID", + func() { + req = &types.QueryPacketCommitmentRequest{ + PortID: "", + ChannelID: "test-channel-id", + Sequence: 0, + } + }, + false, + }, + { + "invalid channel ID", + func() { + req = &types.QueryPacketCommitmentRequest{ + PortID: "test-port-id", + ChannelID: "", + Sequence: 0, + } + }, + false, + }, + {"invalid sequence", + func() { + req = &types.QueryPacketCommitmentRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + Sequence: 0, + } + }, + false, + }, + {"channel not found", + func() { + req = &types.QueryPacketCommitmentRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + Sequence: 1, + } + }, + false, + }, + { + "success", + func() { + _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + expCommitment = []byte("hash") + suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, expCommitment) + + req = &types.QueryPacketCommitmentRequest{ + PortID: channelA.PortID, + ChannelID: channelA.ID, + Sequence: 1, + } + }, + true, + }, + } + + 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.PacketCommitment(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCommitment, res.Commitment) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryPacketCommitments() { + var ( + req *types.QueryPacketCommitmentsRequest + expCommitments = []*types.PacketAckCommitment{} + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid ID", + func() { + req = &types.QueryPacketCommitmentsRequest{ + PortID: "", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "success, empty res", + func() { + expCommitments = []*types.PacketAckCommitment{} + + req = &types.QueryPacketCommitmentsRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + Req: &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: true, + }, + } + }, + true, + }, + { + "success", + func() { + _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + + expCommitments = make([]*types.PacketAckCommitment, 9) + + for i := uint64(0); i < 9; i++ { + commitment := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i))) + suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortID, commitment.ChannelID, commitment.Sequence, commitment.Hash) + expCommitments[i] = &commitment + } + + req = &types.QueryPacketCommitmentsRequest{ + PortID: channelA.PortID, + ChannelID: channelA.ID, + Req: &query.PageRequest{ + Key: nil, + Limit: 11, + CountTotal: true, + }, + } + }, + true, + }, + } + + 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.PacketCommitments(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expCommitments, res.Commitments) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryUnrelayedPackets() { + var ( + req *types.QueryUnrelayedPacketsRequest + expSeq = []uint64{} + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid port ID", + func() { + req = &types.QueryUnrelayedPacketsRequest{ + PortID: "", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "invalid channel ID", + func() { + req = &types.QueryUnrelayedPacketsRequest{ + PortID: "test-port-id", + ChannelID: "", + } + }, + false, + }, + { + "invalid seq", + func() { + req = &types.QueryUnrelayedPacketsRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + Sequences: []uint64{0}, + } + }, + false, + }, + { + "success", + func() { + _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash")) + suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash) + + expSeq = []uint64{1} + req = &types.QueryUnrelayedPacketsRequest{ + PortID: channelA.PortID, + ChannelID: channelA.ID, + Sequences: []uint64{1}, + Req: &query.PageRequest{ + Key: nil, + Limit: 1, + CountTotal: false, + }, + } + }, + true, + }, + } + + 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.UnrelayedPackets(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expSeq, res.Packets) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { + var ( + req *types.QueryNextSequenceReceiveRequest + expSeq uint64 + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty request", + func() { + req = nil + }, + false, + }, + { + "invalid port ID", + func() { + req = &types.QueryNextSequenceReceiveRequest{ + PortID: "", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "invalid channel ID", + func() { + req = &types.QueryNextSequenceReceiveRequest{ + PortID: "test-port-id", + ChannelID: "", + } + }, + false, + }, + {"channel not found", + func() { + req = &types.QueryNextSequenceReceiveRequest{ + PortID: "test-port-id", + ChannelID: "test-channel-id", + } + }, + false, + }, + { + "success", + func() { + _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) + expSeq = 1 + suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), channelA.PortID, channelA.ID, expSeq) + + req = &types.QueryNextSequenceReceiveRequest{ + PortID: channelA.PortID, + ChannelID: channelA.ID, + } + }, + true, + }, + } + + 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.NextSequenceReceive(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expSeq, res.NextSequenceReceive) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/x/ibc/04-channel/keeper/keeper.go b/x/ibc/04-channel/keeper/keeper.go index 1d1c7c4ae2e3..06fd4a938902 100644 --- a/x/ibc/04-channel/keeper/keeper.go +++ b/x/ibc/04-channel/keeper/keeper.go @@ -19,6 +19,9 @@ import ( // Keeper defines the IBC channel keeper type Keeper struct { + // implements gRPC QueryServer interface + types.QueryServer + storeKey sdk.StoreKey cdc codec.Marshaler clientKeeper types.ClientKeeper @@ -131,7 +134,8 @@ func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, s // HasPacketCommitment returns true if the packet commitment exists func (k Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool { - return len(k.GetPacketCommitment(ctx, portID, channelID, sequence)) > 0 + store := ctx.KVStore(k.storeKey) + return store.Has(host.KeyPacketCommitment(portID, channelID, sequence)) } // SetPacketCommitment sets the packet commitment hash to the store diff --git a/x/ibc/04-channel/keeper/querier.go b/x/ibc/04-channel/keeper/querier.go index 8c1e3444880e..8eaf14cca40a 100644 --- a/x/ibc/04-channel/keeper/querier.go +++ b/x/ibc/04-channel/keeper/querier.go @@ -3,7 +3,6 @@ package keeper import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -12,75 +11,18 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) -// QuerierChannels defines the sdk.Querier to query all the channels. -func QuerierChannels(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryAllChannelsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - channels := k.GetAllChannels(ctx) - - start, end := client.Paginate(len(channels), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - channels = []types.IdentifiedChannel{} - } else { - channels = channels[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, channels) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -// QuerierConnectionChannels defines the sdk.Querier to query all the channels for a connection. -func QuerierConnectionChannels(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryConnectionChannelsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - channels := k.GetAllChannels(ctx) - - connectionChannels := []types.IdentifiedChannel{} - for _, channel := range channels { - if channel.ConnectionHops[0] == params.Connection { - connectionChannels = append(connectionChannels, channel) - } - } - - start, end := client.Paginate(len(connectionChannels), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - connectionChannels = []types.IdentifiedChannel{} - } else { - connectionChannels = channels[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, connectionChannels) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - // QuerierChannelClientState defines the sdk.Querier to query all the ClientState // associated with a given Channel. -func QuerierChannelClientState(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryChannelClientStateParams +func QuerierChannelClientState(ctx sdk.Context, abciReq abci.RequestQuery, k Keeper) ([]byte, error) { + var req types.QueryChannelClientStateRequest - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { + if err := k.cdc.UnmarshalJSON(abciReq.Data, &req); err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - channel, found := k.GetChannel(ctx, params.PortID, params.ChannelID) + channel, found := k.GetChannel(ctx, req.PortID, req.ChannelID) if !found { - return nil, sdkerrors.Wrapf(types.ErrChannelNotFound, params.PortID, params.ChannelID) + return nil, sdkerrors.Wrapf(types.ErrChannelNotFound, req.PortID, req.ChannelID) } connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) @@ -100,79 +42,3 @@ func QuerierChannelClientState(ctx sdk.Context, req abci.RequestQuery, k Keeper) return res, nil } - -// QuerierPacketCommitments defines the sdk.Querier to query all packet commitments on a -// specified channel. -func QuerierPacketCommitments(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var params types.QueryPacketCommitmentsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - packetCommitments := k.GetAllPacketCommitmentsAtChannel(ctx, params.PortID, params.ChannelID) - sequences := make([]uint64, 0, len(packetCommitments)) - - for _, pc := range packetCommitments { - sequences = append(sequences, pc.Sequence) - } - - start, end := client.Paginate(len(sequences), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - sequences = []uint64{} - } else { - sequences = sequences[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, sequences) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -// QuerierUnrelayedAcknowledgements defines the sdk.Querier to query all unrelayed -// acknowledgements for a specified channel end. -func QuerierUnrelayedAcknowledgements(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - return queryUnrelayedPackets(ctx, req, k, true) -} - -// QuerierUnrelayedPacketSends defines the sdk.Querier to query all unrelayed packets for a -// specified channel end. -func QuerierUnrelayedPacketSends(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - return queryUnrelayedPackets(ctx, req, k, false) -} - -// helper function to query for unrelayed packets as specified by the isForAcks boolean. If -// set to true it will return unrelayed acknowledgements otherwise it will return unrelayed -// packet sends. -func queryUnrelayedPackets(ctx sdk.Context, req abci.RequestQuery, k Keeper, isForAcks bool) ([]byte, error) { - var params types.QueryUnrelayedPacketsParams - - if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - var unrelayedPackets []uint64 - for _, seq := range params.Sequences { - if _, found := k.GetPacketAcknowledgement(ctx, params.PortID, params.ChannelID, seq); found == isForAcks { - unrelayedPackets = append(unrelayedPackets, seq) - } - } - - start, end := client.Paginate(len(unrelayedPackets), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - unrelayedPackets = []uint64{} - } else { - unrelayedPackets = unrelayedPackets[start:end] - } - - res, err := codec.MarshalJSONIndent(k.cdc, unrelayedPackets) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil - -} diff --git a/x/ibc/04-channel/keeper/querier_test.go b/x/ibc/04-channel/keeper/querier_test.go index d07422c3758b..0e5f2a926a1f 100644 --- a/x/ibc/04-channel/keeper/querier_test.go +++ b/x/ibc/04-channel/keeper/querier_test.go @@ -9,222 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) -// TestQueryChannels tests singular, multiple, and no connection for -// correct retrieval of all channels. -func (suite *KeeperTestSuite) TestQueryChannels() { - path := []string{types.SubModuleName, types.QueryAllChannels} - var ( - expRes []byte - err error - ) - - params := types.NewQueryAllChannelsParams(1, 100) - data, err := suite.chainA.App.AppCodec().MarshalJSON(params) - suite.Require().NoError(err) - - query := abci.RequestQuery{ - Path: "", - Data: data, - } - - testCases := []struct { - name string - setup func() - }{ - { - "success with different connection channels", - func() { - channels := make([]types.IdentifiedChannel, 0, 2) - - // create first connection/channel - clientA, clientB, _, _, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - channels = append(channels, - types.NewIdentifiedChannel( - channelA0.PortID, - channelA0.ID, - suite.chainA.GetChannel(channelA0), - ), - ) - - // create second connection - connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB) - - // create second channel on second connection - channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA1, connB1, types.ORDERED) - - channels = append(channels, - types.NewIdentifiedChannel( - channelA1.PortID, - channelA1.ID, - suite.chainA.GetChannel(channelA1), - ), - ) - - // set expected result - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels) - suite.Require().NoError(err) - }, - }, - { - "success with singular connection channels", - func() { - channels := make([]types.IdentifiedChannel, 0, 2) - - // create first connection/channel - _, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - channels = append(channels, - types.NewIdentifiedChannel( - channelA0.PortID, - channelA0.ID, - suite.chainA.GetChannel(channelA0), - ), - ) - - // create second channel on the same connection - channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.UNORDERED) - channels = append(channels, - types.NewIdentifiedChannel( - channelA1.PortID, - channelA1.ID, - suite.chainA.GetChannel(channelA1), - ), - ) - - // set expected result - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels) - suite.Require().NoError(err) - }, - }, - { - "success no channels", - func() { - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []types.IdentifiedChannel{}) - suite.Require().NoError(err) - }, - }, - } - - for i, tc := range testCases { - suite.SetupTest() // reset - tc.setup() - - bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query) - - suite.Require().NoError(err, "test case %d failed: %s", i, tc.name) - suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name) - } -} - -// TestQueryConnectionChannel tests querying existing channels on a singular connection. -func (suite *KeeperTestSuite) TestQueryConnectionChannels() { - path := []string{types.SubModuleName, types.QueryConnectionChannels} - - var ( - expRes []byte - params types.QueryConnectionChannelsParams - err error - ) - - testCases := []struct { - name string - setup func() - }{ - { - "success with singular connection channels", - func() { - channels := make([]types.IdentifiedChannel, 0, 2) - - // create first connection/channel - _, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - channels = append(channels, - types.NewIdentifiedChannel( - channelA0.PortID, - channelA0.ID, - suite.chainA.GetChannel(channelA0), - ), - ) - - // create second channel on the same connection - channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - channels = append(channels, - types.NewIdentifiedChannel( - channelA1.PortID, - channelA1.ID, - suite.chainA.GetChannel(channelA1), - ), - ) - - params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100) - - // set expected result - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels) - suite.Require().NoError(err) - }, - }, - { - "success multiple connection channels", - func() { - channels := make([]types.IdentifiedChannel, 0, 1) - - // create first connection/channel - clientA, clientB, connA, _, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - channels = append(channels, - types.NewIdentifiedChannel( - channelA0.PortID, - channelA0.ID, - suite.chainA.GetChannel(channelA0), - ), - ) - - // create second connection - connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB) - - // create second channel on second connection - suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA1, connB1, types.ORDERED) - - params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100) - - // set expected result - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels) - suite.Require().NoError(err) - }, - }, - { - "success no channels", - func() { - // create connection but no channels - _, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) - params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100) - - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []types.IdentifiedChannel{}) - suite.Require().NoError(err) - }, - }, - } - - for i, tc := range testCases { - suite.SetupTest() // reset - tc.setup() - - data, err := suite.chainA.App.AppCodec().MarshalJSON(params) - suite.Require().NoError(err) - - query := abci.RequestQuery{ - Path: "", - Data: data, - } - - bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query) - - suite.Require().NoError(err, "test case %d failed: %s", i, tc.name) - suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name) - } -} - // TestQuerierChannelClientState verifies correct querying of client state associated // with a channel end. func (suite *KeeperTestSuite) TestQuerierChannelClientState() { @@ -232,7 +16,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { var ( clientID string - params types.QueryChannelClientStateParams + req *types.QueryChannelClientStateRequest ) testCases := []struct { @@ -247,7 +31,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { suite.Require().NoError(err) clientID = clientA - params = types.NewQueryChannelClientStateParams("doesnotexist", "doesnotexist") + req = types.NewQueryChannelClientStateRequest("doesnotexist", "doesnotexist") }, false, }, @@ -264,7 +48,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel) clientID = clientA - params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID) + req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID) }, false, @@ -278,7 +62,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connectiontypes.ConnectionEnd{}) clientID = clientA - params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID) + req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID) }, false, }, @@ -288,7 +72,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { clientA, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) clientID = clientA - params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID) + req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID) }, true, }, @@ -298,7 +82,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { suite.SetupTest() // reset tc.setup() - data, err := suite.chainA.App.AppCodec().MarshalJSON(params) + data, err := suite.chainA.App.AppCodec().MarshalJSON(req) suite.Require().NoError(err) query := abci.RequestQuery{ @@ -322,229 +106,3 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() { } } } - -// TestQueryPacketCommitments tests querying packet commitments on a specified channel end. -func (suite *KeeperTestSuite) TestQueryPacketCommitments() { - path := []string{types.SubModuleName, types.QueryPacketCommitments} - - var ( - expRes []byte - params types.QueryPacketCommitmentsParams - err error - ) - - testCases := []struct { - name string - setup func() - }{ - { - "success", - func() { - _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - seq := uint64(1) - commitments := []uint64{} - - // create several commitments on the same channel and port - for i := seq; i < 10; i++ { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, i, []byte("ack")) - commitments = append(commitments, i) - } - - params = types.NewQueryPacketCommitmentsParams(channelA.PortID, channelA.ID, 1, 100) - - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), commitments) - suite.Require().NoError(err) - }, - }, - { - "success with multiple channels", - func() { - _, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - seq := uint64(1) - commitments := []uint64{} - - // create several commitments on the same channel and port - for i := seq; i < 10; i++ { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA0.PortID, channelA0.ID, i, []byte("ack")) - commitments = append(commitments, i) - } - - // create second channel - channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - - // create several commitments on a different channel and port - for i := seq; i < 10; i++ { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA1.PortID, channelA1.ID, i, []byte("ack")) - } - - params = types.NewQueryPacketCommitmentsParams(channelA0.PortID, channelA1.ID, 1, 100) - - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), commitments) - suite.Require().NoError(err) - }, - }, - { - "success no packet commitments", - func() { - _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - params = types.NewQueryPacketCommitmentsParams(channelA.PortID, channelA.ID, 1, 100) - - expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []uint64{}) - suite.Require().NoError(err) - }, - }, - } - - for i, tc := range testCases { - suite.SetupTest() // reset - tc.setup() - - data, err := suite.chainA.App.AppCodec().MarshalJSON(params) - suite.Require().NoError(err) - - query := abci.RequestQuery{ - Path: "", - Data: data, - } - - bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query) - - suite.Require().NoError(err, "test case %d failed: %s", i, tc.name) - suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name) - } - -} - -// TestQueryUnrelayedPackets tests querying unrelayed acknowledgements and unrelayed packets sends -// on a specified channel end. -func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() { - pathAck := []string{types.SubModuleName, types.QueryUnrelayedAcknowledgements} - pathSend := []string{types.SubModuleName, types.QueryUnrelayedPacketSends} - sequences := []uint64{1, 2, 3, 4, 5} - - var ( - expResAck []byte - expResSend []byte - params types.QueryUnrelayedPacketsParams - err error - ) - - testCases := []struct { - name string - setup func() - }{ - { - "success", - func() { - _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - unrelayedAcks := []uint64{} - unrelayedSends := []uint64{} - - // create acknowledgements for first 3 sequences - for _, seq := range sequences { - if seq < 4 { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("ack")) - unrelayedAcks = append(unrelayedAcks, seq) - } else { - unrelayedSends = append(unrelayedSends, seq) - } - } - - params = types.NewQueryUnrelayedPacketsParams(channelA.PortID, channelA.ID, sequences, 1, 100) - - expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedAcks) - suite.Require().NoError(err) - - expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedSends) - suite.Require().NoError(err) - - }, - }, - { - "success with multiple channels", - func() { - _, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - ctxA := suite.chainA.GetContext() - - unrelayedAcks := []uint64{} - unrelayedSends := []uint64{} - - // create acknowledgements for first 3 sequences - for _, seq := range sequences { - if seq < 4 { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, channelA0.PortID, channelA0.ID, seq, []byte("ack")) - unrelayedAcks = append(unrelayedAcks, seq) - } else { - unrelayedSends = append(unrelayedSends, seq) - } - } - - // create second channel - channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.UNORDERED) - - // create acknowledgements for other sequences on different channel/port - for _, seq := range sequences { - if seq >= 4 { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, channelA1.PortID, channelA1.ID, seq, []byte("ack")) - } - } - - params = types.NewQueryUnrelayedPacketsParams(channelA0.PortID, channelA0.ID, sequences, 1, 100) - - expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedAcks) - suite.Require().NoError(err) - - expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedSends) - suite.Require().NoError(err) - }, - }, - { - "success no unrelayed acks", - func() { - _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - - // create acknowledgements for all sequences - for _, seq := range sequences { - suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("ack")) - } - - params = types.NewQueryUnrelayedPacketsParams(channelA.PortID, channelA.ID, sequences, 1, 100) - - expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []uint64{}) - suite.Require().NoError(err) - - expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), sequences) - suite.Require().NoError(err) - }, - }, - } - - for i, tc := range testCases { - suite.SetupTest() // reset - tc.setup() - - data, err := suite.chainA.App.AppCodec().MarshalJSON(params) - suite.Require().NoError(err) - - query := abci.RequestQuery{ - Path: "", - Data: data, - } - - bz, err := suite.chainA.Querier(suite.chainA.GetContext(), pathAck, query) - - suite.Require().NoError(err, "test case %d failed: %s", i, tc.name) - suite.Require().Equal(expResAck, bz, "test case %d failed: %s", i, tc.name) - - bz, err = suite.chainA.Querier(suite.chainA.GetContext(), pathSend, query) - - suite.Require().NoError(err, "test case %d failed: %s", i, tc.name) - suite.Require().Equal(expResSend, bz, "test case %d failed: %s", i, tc.name) - - } - -} diff --git a/x/ibc/04-channel/module.go b/x/ibc/04-channel/module.go index f7c887feeb6e..e5b8a9edbdce 100644 --- a/x/ibc/04-channel/module.go +++ b/x/ibc/04-channel/module.go @@ -1,6 +1,7 @@ package channel import ( + "github.com/gogo/protobuf/grpc" "github.com/gorilla/mux" "github.com/spf13/cobra" @@ -10,22 +11,27 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) -// Name returns the IBC connection ICS name +// Name returns the IBC channel ICS name. func Name() string { return types.SubModuleName } -// GetTxCmd returns the root tx command for the IBC connections. +// GetTxCmd returns the root tx command for IBC channels. func GetTxCmd(clientCtx client.Context) *cobra.Command { return cli.NewTxCmd(clientCtx) } -// GetQueryCmd returns no root query command for the IBC connections. +// GetQueryCmd returns the root query command for IBC channels. func GetQueryCmd(clientCtx client.Context) *cobra.Command { return cli.GetQueryCmd(clientCtx) } -// RegisterRESTRoutes registers the REST routes for the IBC channel +// RegisterRESTRoutes registers the REST routes for IBC channels. func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { rest.RegisterRoutes(clientCtx, rtr) } + +// RegisterQueryService registers the gRPC query service for IBC channels. +func RegisterQueryService(server grpc.Server, queryServer types.QueryServer) { + types.RegisterQueryServer(server, queryServer) +} diff --git a/x/ibc/04-channel/types/channel.go b/x/ibc/04-channel/types/channel.go index 3032ef98703c..f7bd0b365704 100644 --- a/x/ibc/04-channel/types/channel.go +++ b/x/ibc/04-channel/types/channel.go @@ -116,34 +116,22 @@ func (c Counterparty) ValidateBasic() error { return nil } -// IdentifiedChannel defines a channel with additional port and channel identifier -// fields. -type IdentifiedChannel struct { - ID string `json:"id" yaml:"id"` - PortID string `json:"port_id" yaml:"port_id"` - State State `json:"state" yaml:"state"` - Ordering Order `json:"ordering" yaml:"ordering"` - Counterparty Counterparty `json:"counterparty" yaml:"counterparty"` - ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"` - Version string `json:"version" yaml:"version "` -} - // NewIdentifiedChannel creates a new IdentifiedChannel instance func NewIdentifiedChannel(portID, channelID string, ch Channel) IdentifiedChannel { return IdentifiedChannel{ - ID: channelID, - PortID: portID, State: ch.State, Ordering: ch.Ordering, Counterparty: ch.Counterparty, ConnectionHops: ch.ConnectionHops, Version: ch.Version, + PortID: portID, + ChannelID: channelID, } } // ValidateBasic performs a basic validation of the identifiers and channel fields. func (ic IdentifiedChannel) ValidateBasic() error { - if err := host.ChannelIdentifierValidator(ic.ID); err != nil { + if err := host.ChannelIdentifierValidator(ic.ChannelID); err != nil { return sdkerrors.Wrap(ErrInvalidChannel, err.Error()) } if err := host.PortIdentifierValidator(ic.PortID); err != nil { diff --git a/x/ibc/04-channel/types/channel.pb.go b/x/ibc/04-channel/types/channel.pb.go index b44e804616af..c7f20d62320c 100644 --- a/x/ibc/04-channel/types/channel.pb.go +++ b/x/ibc/04-channel/types/channel.pb.go @@ -839,6 +839,59 @@ func (m *Channel) XXX_DiscardUnknown() { var xxx_messageInfo_Channel proto.InternalMessageInfo +// IdentifiedChannel defines a channel with additional port and channel identifier +// fields. +type IdentifiedChannel struct { + // current state of the channel end + State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.channel.State" json:"state,omitempty"` + // whether the channel is ordered or unordered + Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.channel.Order" json:"ordering,omitempty"` + // counterparty channel end + Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` + // list of connection identifiers, in order, along which packets sent on this + // channel will travel + ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty" yaml:"connection_hops"` + // opaque channel version, which is agreed upon during the handshake + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` + // port identifier + PortID string `protobuf:"bytes,6,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel identifier + ChannelID string `protobuf:"bytes,7,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} } +func (m *IdentifiedChannel) String() string { return proto.CompactTextString(m) } +func (*IdentifiedChannel) ProtoMessage() {} +func (*IdentifiedChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_9277922ccfb7f043, []int{10} +} +func (m *IdentifiedChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedChannel.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 *IdentifiedChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedChannel.Merge(m, src) +} +func (m *IdentifiedChannel) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedChannel) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedChannel proto.InternalMessageInfo + // Counterparty defines a channel end counterparty type Counterparty struct { // port on the counterparty chain which owns the other end of the channel. @@ -851,7 +904,7 @@ func (m *Counterparty) Reset() { *m = Counterparty{} } func (m *Counterparty) String() string { return proto.CompactTextString(m) } func (*Counterparty) ProtoMessage() {} func (*Counterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_9277922ccfb7f043, []int{10} + return fileDescriptor_9277922ccfb7f043, []int{11} } func (m *Counterparty) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -906,7 +959,7 @@ func (m *Packet) Reset() { *m = Packet{} } func (m *Packet) String() string { return proto.CompactTextString(m) } func (*Packet) ProtoMessage() {} func (*Packet) Descriptor() ([]byte, []int) { - return fileDescriptor_9277922ccfb7f043, []int{11} + return fileDescriptor_9277922ccfb7f043, []int{12} } func (m *Packet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -935,6 +988,52 @@ func (m *Packet) XXX_DiscardUnknown() { var xxx_messageInfo_Packet proto.InternalMessageInfo +// PacketAckCommitment defines the genesis type necessary to retrieve and store +// acknowlegements. +type PacketAckCommitment struct { + // channel port identifier. + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + // channel unique identifier. + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + // packet sequence. + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` + // packet commitment hash. + Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *PacketAckCommitment) Reset() { *m = PacketAckCommitment{} } +func (m *PacketAckCommitment) String() string { return proto.CompactTextString(m) } +func (*PacketAckCommitment) ProtoMessage() {} +func (*PacketAckCommitment) Descriptor() ([]byte, []int) { + return fileDescriptor_9277922ccfb7f043, []int{13} +} +func (m *PacketAckCommitment) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketAckCommitment.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 *PacketAckCommitment) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketAckCommitment.Merge(m, src) +} +func (m *PacketAckCommitment) XXX_Size() int { + return m.Size() +} +func (m *PacketAckCommitment) XXX_DiscardUnknown() { + xxx_messageInfo_PacketAckCommitment.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo + func init() { proto.RegisterEnum("ibc.channel.State", State_name, State_value) proto.RegisterEnum("ibc.channel.Order", Order_name, Order_value) @@ -948,89 +1047,97 @@ func init() { proto.RegisterType((*MsgTimeout)(nil), "ibc.channel.MsgTimeout") proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.channel.MsgAcknowledgement") proto.RegisterType((*Channel)(nil), "ibc.channel.Channel") + proto.RegisterType((*IdentifiedChannel)(nil), "ibc.channel.IdentifiedChannel") proto.RegisterType((*Counterparty)(nil), "ibc.channel.Counterparty") proto.RegisterType((*Packet)(nil), "ibc.channel.Packet") + proto.RegisterType((*PacketAckCommitment)(nil), "ibc.channel.PacketAckCommitment") } func init() { proto.RegisterFile("ibc/channel/channel.proto", fileDescriptor_9277922ccfb7f043) } var fileDescriptor_9277922ccfb7f043 = []byte{ - // 1196 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x16, 0xf5, 0x6b, 0x8d, 0x64, 0x5b, 0x5e, 0xff, 0x44, 0x56, 0x5c, 0x51, 0x20, 0x7a, 0x10, - 0x02, 0x58, 0xaa, 0x1d, 0xb7, 0x05, 0x7c, 0xaa, 0xfe, 0x82, 0x08, 0x8d, 0x25, 0x63, 0x2d, 0x17, - 0x68, 0x2e, 0x02, 0x4d, 0x6d, 0x64, 0x42, 0x16, 0xa9, 0x92, 0xb4, 0x13, 0xbd, 0x41, 0x60, 0xa0, - 0x69, 0xef, 0x85, 0x81, 0x02, 0x3d, 0xf5, 0x09, 0xfa, 0x0a, 0x01, 0x7a, 0x68, 0x0e, 0x3d, 0x14, - 0x2d, 0xc0, 0x16, 0xf6, 0x1b, 0xe8, 0xd8, 0x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xf0, 0xf0, 0x9f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x39, 0x21, 0x50, 0x48, 0x6a, 0x10, 0x00, 0x00, + // 1281 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xfa, 0x6f, 0xfc, 0xf2, 0xcf, 0x99, 0xa4, 0xa9, 0xe3, 0x16, 0xaf, 0xb5, 0x70, 0xb0, + 0x2a, 0xea, 0xd0, 0x3f, 0x80, 0xd4, 0x13, 0xb6, 0xe3, 0xaa, 0x2b, 0x1a, 0x3b, 0x9a, 0xb8, 0x48, + 0xf4, 0x62, 0x6d, 0x76, 0xa7, 0xf6, 0xca, 0xf1, 0x8e, 0xd9, 0xdd, 0xb4, 0xcd, 0x37, 0xa8, 0x22, + 0x51, 0xb8, 0xa3, 0x48, 0x48, 0x9c, 0xf8, 0x04, 0x7c, 0x02, 0xa4, 0x4a, 0x1c, 0xe8, 0x81, 0x03, + 0x02, 0x69, 0x41, 0xe9, 0x8d, 0xa3, 0x8f, 0x9c, 0xd0, 0xce, 0xcc, 0xda, 0xbb, 0x4e, 0xe9, 0x21, + 0x46, 0x32, 0x48, 0x9c, 0x76, 0xde, 0x7b, 0xbf, 0x79, 0xf3, 0xde, 0xef, 0x4d, 0xde, 0x9b, 0x18, + 0xb6, 0xcc, 0x03, 0x7d, 0x5b, 0xef, 0x69, 0x96, 0x45, 0x0e, 0x83, 0x6f, 0x65, 0x68, 0x53, 0x97, + 0xa2, 0x45, 0xf3, 0x40, 0xaf, 0x08, 0x55, 0x61, 0xa3, 0x4b, 0xbb, 0x94, 0xe9, 0xb7, 0xfd, 0x15, + 0x87, 0x28, 0x5f, 0xc4, 0x01, 0xed, 0x3a, 0xdd, 0x3a, 0x07, 0xb5, 0x86, 0xc4, 0x52, 0x2d, 0xd3, + 0x45, 0xef, 0x43, 0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, 0xf5, 0xe0, 0x37, 0x28, 0x36, 0x4c, 0x0f, 0xd2, 0xec, + 0xf7, 0xa5, 0x5b, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x95, 0x61, 0xbf, 0x9f, 0x12, 0x00, + 0x00, } func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { @@ -1606,6 +1713,79 @@ func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IdentifiedChannel) 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 *IdentifiedChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x3a + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0x32 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.ConnectionHops) > 0 { + for iNdEx := len(m.ConnectionHops) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConnectionHops[iNdEx]) + copy(dAtA[i:], m.ConnectionHops[iNdEx]) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ConnectionHops[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Ordering != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Ordering)) + i-- + dAtA[i] = 0x10 + } + if m.State != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *Counterparty) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1716,6 +1896,55 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PacketAckCommitment) 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 *PacketAckCommitment) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketAckCommitment) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x22 + } + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { offset -= sovChannel(v) base := offset @@ -1993,6 +2222,41 @@ func (m *Channel) Size() (n int) { return n } +func (m *IdentifiedChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.State != 0 { + n += 1 + sovChannel(uint64(m.State)) + } + if m.Ordering != 0 { + n += 1 + sovChannel(uint64(m.Ordering)) + } + l = m.Counterparty.Size() + n += 1 + l + sovChannel(uint64(l)) + if len(m.ConnectionHops) > 0 { + for _, s := range m.ConnectionHops { + l = len(s) + n += 1 + l + sovChannel(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + func (m *Counterparty) Size() (n int) { if m == nil { return 0 @@ -2048,6 +2312,30 @@ func (m *Packet) Size() (n int) { return n } +func (m *PacketAckCommitment) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4062,7 +4350,7 @@ func (m *Channel) Unmarshal(dAtA []byte) error { } return nil } -func (m *Counterparty) Unmarshal(dAtA []byte) error { +func (m *IdentifiedChannel) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4085,17 +4373,17 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + return fmt.Errorf("proto: IdentifiedChannel: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: IdentifiedChannel: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) } - var stringLen uint64 + m.State = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -4105,29 +4393,281 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.State |= State(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ordering", wireType) } - var stringLen uint64 + m.Ordering = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ordering |= Order(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionHops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionHops = append(m.ConnectionHops, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Counterparty) 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 ErrIntOverflowChannel + } + 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: Counterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -4451,6 +4991,176 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } return nil } +func (m *PacketAckCommitment) 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 ErrIntOverflowChannel + } + 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: PacketAckCommitment: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketAckCommitment: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + 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 ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/04-channel/types/genesis.go b/x/ibc/04-channel/types/genesis.go index cc1a3a519c7e..762b17f55308 100644 --- a/x/ibc/04-channel/types/genesis.go +++ b/x/ibc/04-channel/types/genesis.go @@ -7,15 +7,6 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -// PacketAckCommitment defines the genesis type necessary to retrieve and store -// acknowlegements. -type PacketAckCommitment struct { - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Hash []byte `json:"hash" yaml:"hash"` -} - // NewPacketAckCommitment creates a new PacketAckCommitment instance. func NewPacketAckCommitment(portID, channelID string, seq uint64, hash []byte) PacketAckCommitment { return PacketAckCommitment{ diff --git a/x/ibc/04-channel/types/querier.go b/x/ibc/04-channel/types/querier.go index d42f06b8c1f4..fa35b0a50a19 100644 --- a/x/ibc/04-channel/types/querier.go +++ b/x/ibc/04-channel/types/querier.go @@ -3,8 +3,6 @@ package types import ( "strings" - "github.com/tendermint/tendermint/crypto/merkle" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -20,153 +18,46 @@ const ( QueryUnrelayedPacketSends = "unrelayed-packet-sends" ) -// ChannelResponse defines the client query response for a channel which also -// includes a proof,its path and the height from which the proof was retrieved. -type ChannelResponse struct { - Channel IdentifiedChannel `json:"channel" yaml:"channel"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// NewChannelResponse creates a new ChannelResponse instance -func NewChannelResponse( - portID, channelID string, channel Channel, proof *merkle.Proof, height int64, -) ChannelResponse { - return ChannelResponse{ - - Channel: NewIdentifiedChannel(portID, channelID, channel), - Proof: commitmenttypes.MerkleProof{Proof: proof}, - ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ChannelPath(portID, channelID), "/")), +// NewQueryChannelResponse creates a new QueryChannelResponse instance +func NewQueryChannelResponse(portID, channelID string, channel Channel, proof []byte, height int64) *QueryChannelResponse { + path := commitmenttypes.NewMerklePath(strings.Split(host.ChannelPath(portID, channelID), "/")) + return &QueryChannelResponse{ + Channel: &channel, + Proof: proof, + ProofPath: path.Pretty(), ProofHeight: uint64(height), } } -// QueryAllChannelsParams defines the parameters necessary for querying for all -// channels. -type QueryAllChannelsParams struct { - Page int `json:"page" yaml:"page"` - Limit int `json:"limit" yaml:"limit"` -} - -// NewQueryAllChannelsParams creates a new QueryAllChannelsParams instance. -func NewQueryAllChannelsParams(page, limit int) QueryAllChannelsParams { - return QueryAllChannelsParams{ - Page: page, - Limit: limit, - } -} - -// QueryConnectionChannelsParams defines the parameters necessary for querying -// for all channels associated with a given connection. -type QueryConnectionChannelsParams struct { - Connection string `json:"connection" yaml:"connection"` - Page int `json:"page" yaml:"page"` - Limit int `json:"limit" yaml:"limit"` -} - -// NewQueryConnectionChannelsParams creates a new QueryConnectionChannelsParams instance. -func NewQueryConnectionChannelsParams(connection string, page, limit int) QueryConnectionChannelsParams { - return QueryConnectionChannelsParams{ - Connection: connection, - Page: page, - Limit: limit, - } -} - -// QueryPacketCommitmentsParams defines the parameters necessary for querying -// all packet commitments at an associated port ID and channel ID. -type QueryPacketCommitmentsParams struct { - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` - Page int `json:"page" yaml:"page"` - Limit int `json:"limit" yaml:"limit"` -} - -// NewQueryPacketCommitmentsParams creates a new QueryPacketCommitmentsParams instance. -func NewQueryPacketCommitmentsParams(portID, channelID string, page, limit int) QueryPacketCommitmentsParams { - return QueryPacketCommitmentsParams{ - PortID: portID, - ChannelID: channelID, - Page: page, - Limit: limit, - } -} - -// QueryUnrelayedPacketsParams defines the parameters necessary for querying -// unrelayed packets at an associated port ID and channel ID. -type QueryUnrelayedPacketsParams struct { - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` - Sequences []uint64 `json:"sequences" yaml:"sequences"` - Page int `json:"page" yaml:"page"` - Limit int `json:"limit" yaml:"limit"` -} - -// NewQueryUnrealyedPacketsParams creates a new QueryUnrelayedPacketsParams instance. -func NewQueryUnrelayedPacketsParams(portID, channelID string, sequences []uint64, page, limit int) QueryUnrelayedPacketsParams { - return QueryUnrelayedPacketsParams{ - PortID: portID, - ChannelID: channelID, - Sequences: sequences, - Page: page, - Limit: limit, - } -} - -// PacketResponse defines the client query response for a packet which also -// includes a proof, its path and the height form which the proof was retrieved -type PacketResponse struct { - Packet Packet `json:"packet" yaml:"packet"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// NewPacketResponse creates a new PacketResponswe instance -func NewPacketResponse( - portID, channelID string, sequence uint64, packet Packet, proof *merkle.Proof, height int64, -) PacketResponse { - return PacketResponse{ - Packet: packet, - Proof: commitmenttypes.MerkleProof{Proof: proof}, - ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.PacketCommitmentPath(portID, channelID, sequence), "/")), +// NewQueryPacketCommitmentResponse creates a new QueryPacketCommitmentResponse instance +func NewQueryPacketCommitmentResponse( + portID, channelID string, sequence uint64, commitment []byte, proof []byte, height int64, +) *QueryPacketCommitmentResponse { + path := commitmenttypes.NewMerklePath(strings.Split(host.PacketCommitmentPath(portID, channelID, sequence), "/")) + return &QueryPacketCommitmentResponse{ + Commitment: commitment, + Proof: proof, + ProofPath: path.Pretty(), ProofHeight: uint64(height), } } -// RecvResponse defines the client query response for the next receive sequence -// number which also includes a proof, its path and the height form which the -// proof was retrieved -type RecvResponse struct { - NextSequenceRecv uint64 `json:"next_sequence_recv" yaml:"next_sequence_recv"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// NewRecvResponse creates a new RecvResponse instance -func NewRecvResponse( - portID, channelID string, sequenceRecv uint64, proof *merkle.Proof, height int64, -) RecvResponse { - return RecvResponse{ - NextSequenceRecv: sequenceRecv, - Proof: commitmenttypes.MerkleProof{Proof: proof}, - ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.NextSequenceRecvPath(portID, channelID), "/")), - ProofHeight: uint64(height), +// NewQueryNextSequenceReceiveResponse creates a new QueryNextSequenceReceiveResponse instance +func NewQueryNextSequenceReceiveResponse( + portID, channelID string, sequence uint64, proof []byte, height int64, +) *QueryNextSequenceReceiveResponse { + path := commitmenttypes.NewMerklePath(strings.Split(host.NextSequenceRecvPath(portID, channelID), "/")) + return &QueryNextSequenceReceiveResponse{ + NextSequenceReceive: sequence, + Proof: proof, + ProofPath: path.Pretty(), + ProofHeight: uint64(height), } } -// QueryChannelClientStateParams defines the parameters necessary for querying -// ClientState at an associated port ID and channel ID. -type QueryChannelClientStateParams struct { - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` -} - -// NewQueryChannelClientStateParams creates a new QueryChannelClientStateParams instance. -func NewQueryChannelClientStateParams(portID, channelID string) QueryChannelClientStateParams { - return QueryChannelClientStateParams{ +// NewQueryChannelClientStateRequest creates a new QueryChannelClientStateRequest instance. +func NewQueryChannelClientStateRequest(portID, channelID string) *QueryChannelClientStateRequest { + return &QueryChannelClientStateRequest{ PortID: portID, ChannelID: channelID, } diff --git a/x/ibc/04-channel/types/query.pb.go b/x/ibc/04-channel/types/query.pb.go new file mode 100644 index 000000000000..ca1044481203 --- /dev/null +++ b/x/ibc/04-channel/types/query.pb.go @@ -0,0 +1,4680 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/channel/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryChannelRequest is the request type for the Query/Channel RPC method +type QueryChannelRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *QueryChannelRequest) Reset() { *m = QueryChannelRequest{} } +func (m *QueryChannelRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelRequest) ProtoMessage() {} +func (*QueryChannelRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{0} +} +func (m *QueryChannelRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelRequest.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 *QueryChannelRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelRequest.Merge(m, src) +} +func (m *QueryChannelRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelRequest proto.InternalMessageInfo + +func (m *QueryChannelRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryChannelRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +// QueryChannelResponse is the response type for the Query/Channel RPC method. +// Besides the Channel end, it includes a proof and the height from which the +// proof was retrieved. +type QueryChannelResponse struct { + // channel associated with the request identifiers + Channel *Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // merkle proof path + ProofPath string `protobuf:"bytes,3,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` + // height at which the proof was retrieved + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` +} + +func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } +func (m *QueryChannelResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelResponse) ProtoMessage() {} +func (*QueryChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{1} +} +func (m *QueryChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelResponse.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 *QueryChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelResponse.Merge(m, src) +} +func (m *QueryChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelResponse proto.InternalMessageInfo + +func (m *QueryChannelResponse) GetChannel() *Channel { + if m != nil { + return m.Channel + } + return nil +} + +func (m *QueryChannelResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryChannelResponse) GetProofPath() string { + if m != nil { + return m.ProofPath + } + return "" +} + +func (m *QueryChannelResponse) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +// QueryChannelsRequest is the request type for the Query/Channels RPC method +type QueryChannelsRequest struct { + // pagination request + Req *query.PageRequest `protobuf:"bytes,1,opt,name=req,proto3" json:"req,omitempty"` +} + +func (m *QueryChannelsRequest) Reset() { *m = QueryChannelsRequest{} } +func (m *QueryChannelsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelsRequest) ProtoMessage() {} +func (*QueryChannelsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{2} +} +func (m *QueryChannelsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelsRequest.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 *QueryChannelsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelsRequest.Merge(m, src) +} +func (m *QueryChannelsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelsRequest proto.InternalMessageInfo + +func (m *QueryChannelsRequest) GetReq() *query.PageRequest { + if m != nil { + return m.Req + } + return nil +} + +// QueryChannelsResponse is the response type for the Query/Channels RPC method. +type QueryChannelsResponse struct { + // list of stored channels of the chain. + Channels []*IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3" json:"channels,omitempty"` + // pagination response + Res *query.PageResponse `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + // query block height + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryChannelsResponse) Reset() { *m = QueryChannelsResponse{} } +func (m *QueryChannelsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelsResponse) ProtoMessage() {} +func (*QueryChannelsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{3} +} +func (m *QueryChannelsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelsResponse.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 *QueryChannelsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelsResponse.Merge(m, src) +} +func (m *QueryChannelsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelsResponse proto.InternalMessageInfo + +func (m *QueryChannelsResponse) GetChannels() []*IdentifiedChannel { + if m != nil { + return m.Channels + } + return nil +} + +func (m *QueryChannelsResponse) GetRes() *query.PageResponse { + if m != nil { + return m.Res + } + return nil +} + +func (m *QueryChannelsResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryConnectionChannelsRequest is the request type for the Query/QueryConnectionChannels RPC method +type QueryConnectionChannelsRequest struct { + // connection unique identifier + Connection string `protobuf:"bytes,1,opt,name=connection,proto3" json:"connection,omitempty"` + // pagination request + Req *query.PageRequest `protobuf:"bytes,2,opt,name=req,proto3" json:"req,omitempty"` +} + +func (m *QueryConnectionChannelsRequest) Reset() { *m = QueryConnectionChannelsRequest{} } +func (m *QueryConnectionChannelsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionChannelsRequest) ProtoMessage() {} +func (*QueryConnectionChannelsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{4} +} +func (m *QueryConnectionChannelsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionChannelsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionChannelsRequest.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 *QueryConnectionChannelsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionChannelsRequest.Merge(m, src) +} +func (m *QueryConnectionChannelsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionChannelsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionChannelsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionChannelsRequest proto.InternalMessageInfo + +func (m *QueryConnectionChannelsRequest) GetConnection() string { + if m != nil { + return m.Connection + } + return "" +} + +func (m *QueryConnectionChannelsRequest) GetReq() *query.PageRequest { + if m != nil { + return m.Req + } + return nil +} + +// QueryConnectionChannelsResponse is the Response type for the Query/QueryConnectionChannels RPC method +type QueryConnectionChannelsResponse struct { + // list of channels associated with a connection. + Channels []*IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3" json:"channels,omitempty"` + // pagination response + Res *query.PageResponse `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + // query block height + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryConnectionChannelsResponse) Reset() { *m = QueryConnectionChannelsResponse{} } +func (m *QueryConnectionChannelsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConnectionChannelsResponse) ProtoMessage() {} +func (*QueryConnectionChannelsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{5} +} +func (m *QueryConnectionChannelsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConnectionChannelsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConnectionChannelsResponse.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 *QueryConnectionChannelsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConnectionChannelsResponse.Merge(m, src) +} +func (m *QueryConnectionChannelsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConnectionChannelsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConnectionChannelsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConnectionChannelsResponse proto.InternalMessageInfo + +func (m *QueryConnectionChannelsResponse) GetChannels() []*IdentifiedChannel { + if m != nil { + return m.Channels + } + return nil +} + +func (m *QueryConnectionChannelsResponse) GetRes() *query.PageResponse { + if m != nil { + return m.Res + } + return nil +} + +func (m *QueryConnectionChannelsResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method +type QueryPacketCommitmentRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitmentRequest{} } +func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentRequest) ProtoMessage() {} +func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{6} +} +func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentRequest.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 *QueryPacketCommitmentRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentRequest.Merge(m, src) +} +func (m *QueryPacketCommitmentRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentRequest proto.InternalMessageInfo + +func (m *QueryPacketCommitmentRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryPacketCommitmentRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *QueryPacketCommitmentRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +// QueryPacketCommitmentResponse defines the client query response for a packet which also +// includes a proof, its path and the height form which the proof was retrieved +type QueryPacketCommitmentResponse struct { + // packet associated with the request fields + Commitment []byte `protobuf:"bytes,1,opt,name=commitment,proto3" json:"commitment,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // merkle proof path + ProofPath string `protobuf:"bytes,3,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` + // height at which the proof was retrieved + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` +} + +func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommitmentResponse{} } +func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentResponse) ProtoMessage() {} +func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{7} +} +func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentResponse.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 *QueryPacketCommitmentResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentResponse.Merge(m, src) +} +func (m *QueryPacketCommitmentResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentResponse proto.InternalMessageInfo + +func (m *QueryPacketCommitmentResponse) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil +} + +func (m *QueryPacketCommitmentResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryPacketCommitmentResponse) GetProofPath() string { + if m != nil { + return m.ProofPath + } + return "" +} + +func (m *QueryPacketCommitmentResponse) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +// QueryPacketCommitmentsRequest is the request type for the Query/QueryPacketCommitments RPC method +type QueryPacketCommitmentsRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // pagination request + Req *query.PageRequest `protobuf:"bytes,3,opt,name=req,proto3" json:"req,omitempty"` +} + +func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommitmentsRequest{} } +func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentsRequest) ProtoMessage() {} +func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{8} +} +func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentsRequest.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 *QueryPacketCommitmentsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentsRequest.Merge(m, src) +} +func (m *QueryPacketCommitmentsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentsRequest proto.InternalMessageInfo + +func (m *QueryPacketCommitmentsRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryPacketCommitmentsRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *QueryPacketCommitmentsRequest) GetReq() *query.PageRequest { + if m != nil { + return m.Req + } + return nil +} + +// QueryPacketCommitmentsResponse is the request type for the Query/QueryPacketCommitments RPC method +type QueryPacketCommitmentsResponse struct { + Commitments []*PacketAckCommitment `protobuf:"bytes,1,rep,name=commitments,proto3" json:"commitments,omitempty"` + // pagination response + Res *query.PageResponse `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + // query block height + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommitmentsResponse{} } +func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPacketCommitmentsResponse) ProtoMessage() {} +func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{9} +} +func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPacketCommitmentsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPacketCommitmentsResponse.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 *QueryPacketCommitmentsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPacketCommitmentsResponse.Merge(m, src) +} +func (m *QueryPacketCommitmentsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPacketCommitmentsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPacketCommitmentsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPacketCommitmentsResponse proto.InternalMessageInfo + +func (m *QueryPacketCommitmentsResponse) GetCommitments() []*PacketAckCommitment { + if m != nil { + return m.Commitments + } + return nil +} + +func (m *QueryPacketCommitmentsResponse) GetRes() *query.PageResponse { + if m != nil { + return m.Res + } + return nil +} + +func (m *QueryPacketCommitmentsResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryUnrelayedPacketsRequest is the request type for the Query/QueryConnectionChannels RPC method +type QueryUnrelayedPacketsRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // list of packet sequences + Sequences []uint64 `protobuf:"varint,3,rep,packed,name=sequences,proto3" json:"sequences,omitempty"` + // pagination request + Req *query.PageRequest `protobuf:"bytes,4,opt,name=req,proto3" json:"req,omitempty"` +} + +func (m *QueryUnrelayedPacketsRequest) Reset() { *m = QueryUnrelayedPacketsRequest{} } +func (m *QueryUnrelayedPacketsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUnrelayedPacketsRequest) ProtoMessage() {} +func (*QueryUnrelayedPacketsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{10} +} +func (m *QueryUnrelayedPacketsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnrelayedPacketsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnrelayedPacketsRequest.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 *QueryUnrelayedPacketsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnrelayedPacketsRequest.Merge(m, src) +} +func (m *QueryUnrelayedPacketsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUnrelayedPacketsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnrelayedPacketsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnrelayedPacketsRequest proto.InternalMessageInfo + +func (m *QueryUnrelayedPacketsRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryUnrelayedPacketsRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *QueryUnrelayedPacketsRequest) GetSequences() []uint64 { + if m != nil { + return m.Sequences + } + return nil +} + +func (m *QueryUnrelayedPacketsRequest) GetReq() *query.PageRequest { + if m != nil { + return m.Req + } + return nil +} + +// QueryUnrelayedPacketsResponse is the request type for the Query/QueryConnectionChannels RPC method +type QueryUnrelayedPacketsResponse struct { + // list of unrelayed packets sequences + Packets []uint64 `protobuf:"varint,1,rep,packed,name=packets,proto3" json:"packets,omitempty"` + // pagination response + Res *query.PageResponse `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + // query block height + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryUnrelayedPacketsResponse) Reset() { *m = QueryUnrelayedPacketsResponse{} } +func (m *QueryUnrelayedPacketsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUnrelayedPacketsResponse) ProtoMessage() {} +func (*QueryUnrelayedPacketsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{11} +} +func (m *QueryUnrelayedPacketsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnrelayedPacketsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnrelayedPacketsResponse.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 *QueryUnrelayedPacketsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnrelayedPacketsResponse.Merge(m, src) +} +func (m *QueryUnrelayedPacketsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUnrelayedPacketsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnrelayedPacketsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnrelayedPacketsResponse proto.InternalMessageInfo + +func (m *QueryUnrelayedPacketsResponse) GetPackets() []uint64 { + if m != nil { + return m.Packets + } + return nil +} + +func (m *QueryUnrelayedPacketsResponse) GetRes() *query.PageResponse { + if m != nil { + return m.Res + } + return nil +} + +func (m *QueryUnrelayedPacketsResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryNextSequenceReceiveRequest is the request type for the Query/QueryNextSequenceReceiveRequest RPC method +type QueryNextSequenceReceiveRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *QueryNextSequenceReceiveRequest) Reset() { *m = QueryNextSequenceReceiveRequest{} } +func (m *QueryNextSequenceReceiveRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNextSequenceReceiveRequest) ProtoMessage() {} +func (*QueryNextSequenceReceiveRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{12} +} +func (m *QueryNextSequenceReceiveRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextSequenceReceiveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextSequenceReceiveRequest.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 *QueryNextSequenceReceiveRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextSequenceReceiveRequest.Merge(m, src) +} +func (m *QueryNextSequenceReceiveRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNextSequenceReceiveRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextSequenceReceiveRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextSequenceReceiveRequest proto.InternalMessageInfo + +func (m *QueryNextSequenceReceiveRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryNextSequenceReceiveRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +// QuerySequenceResponse is the request type for the Query/QueryNextSequenceReceiveResponse RPC method +type QueryNextSequenceReceiveResponse struct { + // next sequence receive number + NextSequenceReceive uint64 `protobuf:"varint,1,opt,name=next_sequence_receive,json=nextSequenceReceive,proto3" json:"next_sequence_receive,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + // merkle proof path + ProofPath string `protobuf:"bytes,3,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` + // height at which the proof was retrieved + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` +} + +func (m *QueryNextSequenceReceiveResponse) Reset() { *m = QueryNextSequenceReceiveResponse{} } +func (m *QueryNextSequenceReceiveResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNextSequenceReceiveResponse) ProtoMessage() {} +func (*QueryNextSequenceReceiveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{13} +} +func (m *QueryNextSequenceReceiveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNextSequenceReceiveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNextSequenceReceiveResponse.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 *QueryNextSequenceReceiveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNextSequenceReceiveResponse.Merge(m, src) +} +func (m *QueryNextSequenceReceiveResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNextSequenceReceiveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNextSequenceReceiveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNextSequenceReceiveResponse proto.InternalMessageInfo + +func (m *QueryNextSequenceReceiveResponse) GetNextSequenceReceive() uint64 { + if m != nil { + return m.NextSequenceReceive + } + return 0 +} + +func (m *QueryNextSequenceReceiveResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryNextSequenceReceiveResponse) GetProofPath() string { + if m != nil { + return m.ProofPath + } + return "" +} + +func (m *QueryNextSequenceReceiveResponse) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +// QueryChannelClientStateRequest is the request type for the Query/ClientState RPC method +type QueryChannelClientStateRequest struct { + // port unique identifier + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *QueryChannelClientStateRequest) Reset() { *m = QueryChannelClientStateRequest{} } +func (m *QueryChannelClientStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelClientStateRequest) ProtoMessage() {} +func (*QueryChannelClientStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2150995751d4f15a, []int{14} +} +func (m *QueryChannelClientStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelClientStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelClientStateRequest.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 *QueryChannelClientStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelClientStateRequest.Merge(m, src) +} +func (m *QueryChannelClientStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelClientStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelClientStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelClientStateRequest proto.InternalMessageInfo + +func (m *QueryChannelClientStateRequest) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *QueryChannelClientStateRequest) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func init() { + proto.RegisterType((*QueryChannelRequest)(nil), "ibc.channel.QueryChannelRequest") + proto.RegisterType((*QueryChannelResponse)(nil), "ibc.channel.QueryChannelResponse") + proto.RegisterType((*QueryChannelsRequest)(nil), "ibc.channel.QueryChannelsRequest") + proto.RegisterType((*QueryChannelsResponse)(nil), "ibc.channel.QueryChannelsResponse") + proto.RegisterType((*QueryConnectionChannelsRequest)(nil), "ibc.channel.QueryConnectionChannelsRequest") + proto.RegisterType((*QueryConnectionChannelsResponse)(nil), "ibc.channel.QueryConnectionChannelsResponse") + proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.channel.QueryPacketCommitmentRequest") + proto.RegisterType((*QueryPacketCommitmentResponse)(nil), "ibc.channel.QueryPacketCommitmentResponse") + proto.RegisterType((*QueryPacketCommitmentsRequest)(nil), "ibc.channel.QueryPacketCommitmentsRequest") + proto.RegisterType((*QueryPacketCommitmentsResponse)(nil), "ibc.channel.QueryPacketCommitmentsResponse") + proto.RegisterType((*QueryUnrelayedPacketsRequest)(nil), "ibc.channel.QueryUnrelayedPacketsRequest") + proto.RegisterType((*QueryUnrelayedPacketsResponse)(nil), "ibc.channel.QueryUnrelayedPacketsResponse") + proto.RegisterType((*QueryNextSequenceReceiveRequest)(nil), "ibc.channel.QueryNextSequenceReceiveRequest") + proto.RegisterType((*QueryNextSequenceReceiveResponse)(nil), "ibc.channel.QueryNextSequenceReceiveResponse") + proto.RegisterType((*QueryChannelClientStateRequest)(nil), "ibc.channel.QueryChannelClientStateRequest") +} + +func init() { proto.RegisterFile("ibc/channel/query.proto", fileDescriptor_2150995751d4f15a) } + +var fileDescriptor_2150995751d4f15a = []byte{ + // 827 bytes of a gzipped FileDescript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, 0x5c, 0x9f, 0xd1, 0x53, 0x88, 0xc2, + 0x5a, 0xc4, 0x69, 0x44, 0x11, 0x1b, 0x12, 0xdf, 0x2b, 0xd4, 0xfd, 0x84, 0x68, 0x19, 0xf5, 0xf0, + 0xf9, 0x8f, 0x91, 0xa6, 0x5c, 0x8e, 0x34, 0xe5, 0xd7, 0x48, 0x53, 0xde, 0x5f, 0x6b, 0xa9, 0xcb, + 0x6b, 0x2d, 0xf5, 0xf3, 0x5a, 0x4b, 0xbd, 0x3e, 0xe8, 0x3a, 0xb4, 0x77, 0xd6, 0x36, 0x6c, 0x6f, + 0x50, 0x15, 0x0f, 0x73, 0xfe, 0xd9, 0x27, 0x9d, 0x7e, 0xf5, 0xbc, 0x1a, 0xbe, 0xc6, 0x1f, 0x3d, + 0xde, 0x97, 0x0f, 0x72, 0x7a, 0xe1, 0x63, 0xd2, 0xce, 0xb2, 0xf7, 0xf8, 0xc1, 0x9f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xdf, 0x68, 0xc7, 0x94, 0x07, 0x0c, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Channel queries an IBC Channel. + Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) + // Channels queries all the IBC channels of a chain. + Channels(ctx context.Context, in *QueryChannelsRequest, opts ...grpc.CallOption) (*QueryChannelsResponse, error) + // ConnectionChannels queries all the channels associated with a connection end. + ConnectionChannels(ctx context.Context, in *QueryConnectionChannelsRequest, opts ...grpc.CallOption) (*QueryConnectionChannelsResponse, error) + // PacketCommitment queries a stored packet commitment hash. + PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) + // PacketCommitments returns the all the packet commitments hashes associated with a channel. + PacketCommitments(ctx context.Context, in *QueryPacketCommitmentsRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentsResponse, error) + // UnrelayedPackets returns all the unrelayed IBC packets associated with a channel and sequences. + UnrelayedPackets(ctx context.Context, in *QueryUnrelayedPacketsRequest, opts ...grpc.CallOption) (*QueryUnrelayedPacketsResponse, error) + // NextSequenceReceive returns the next receive sequence for a given channel + NextSequenceReceive(ctx context.Context, in *QueryNextSequenceReceiveRequest, opts ...grpc.CallOption) (*QueryNextSequenceReceiveResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) { + out := new(QueryChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/Channel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Channels(ctx context.Context, in *QueryChannelsRequest, opts ...grpc.CallOption) (*QueryChannelsResponse, error) { + out := new(QueryChannelsResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/Channels", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ConnectionChannels(ctx context.Context, in *QueryConnectionChannelsRequest, opts ...grpc.CallOption) (*QueryConnectionChannelsResponse, error) { + out := new(QueryConnectionChannelsResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/ConnectionChannels", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PacketCommitment(ctx context.Context, in *QueryPacketCommitmentRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentResponse, error) { + out := new(QueryPacketCommitmentResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/PacketCommitment", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PacketCommitments(ctx context.Context, in *QueryPacketCommitmentsRequest, opts ...grpc.CallOption) (*QueryPacketCommitmentsResponse, error) { + out := new(QueryPacketCommitmentsResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/PacketCommitments", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) UnrelayedPackets(ctx context.Context, in *QueryUnrelayedPacketsRequest, opts ...grpc.CallOption) (*QueryUnrelayedPacketsResponse, error) { + out := new(QueryUnrelayedPacketsResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/UnrelayedPackets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) NextSequenceReceive(ctx context.Context, in *QueryNextSequenceReceiveRequest, opts ...grpc.CallOption) (*QueryNextSequenceReceiveResponse, error) { + out := new(QueryNextSequenceReceiveResponse) + err := c.cc.Invoke(ctx, "/ibc.channel.Query/NextSequenceReceive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Channel queries an IBC Channel. + Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) + // Channels queries all the IBC channels of a chain. + Channels(context.Context, *QueryChannelsRequest) (*QueryChannelsResponse, error) + // ConnectionChannels queries all the channels associated with a connection end. + ConnectionChannels(context.Context, *QueryConnectionChannelsRequest) (*QueryConnectionChannelsResponse, error) + // PacketCommitment queries a stored packet commitment hash. + PacketCommitment(context.Context, *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) + // PacketCommitments returns the all the packet commitments hashes associated with a channel. + PacketCommitments(context.Context, *QueryPacketCommitmentsRequest) (*QueryPacketCommitmentsResponse, error) + // UnrelayedPackets returns all the unrelayed IBC packets associated with a channel and sequences. + UnrelayedPackets(context.Context, *QueryUnrelayedPacketsRequest) (*QueryUnrelayedPacketsResponse, error) + // NextSequenceReceive returns the next receive sequence for a given channel + NextSequenceReceive(context.Context, *QueryNextSequenceReceiveRequest) (*QueryNextSequenceReceiveResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") +} +func (*UnimplementedQueryServer) Channels(ctx context.Context, req *QueryChannelsRequest) (*QueryChannelsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Channels not implemented") +} +func (*UnimplementedQueryServer) ConnectionChannels(ctx context.Context, req *QueryConnectionChannelsRequest) (*QueryConnectionChannelsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConnectionChannels not implemented") +} +func (*UnimplementedQueryServer) PacketCommitment(ctx context.Context, req *QueryPacketCommitmentRequest) (*QueryPacketCommitmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketCommitment not implemented") +} +func (*UnimplementedQueryServer) PacketCommitments(ctx context.Context, req *QueryPacketCommitmentsRequest) (*QueryPacketCommitmentsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PacketCommitments not implemented") +} +func (*UnimplementedQueryServer) UnrelayedPackets(ctx context.Context, req *QueryUnrelayedPacketsRequest) (*QueryUnrelayedPacketsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnrelayedPackets not implemented") +} +func (*UnimplementedQueryServer) NextSequenceReceive(ctx context.Context, req *QueryNextSequenceReceiveRequest) (*QueryNextSequenceReceiveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NextSequenceReceive not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Channel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/Channel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Channel(ctx, req.(*QueryChannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Channels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Channels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/Channels", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Channels(ctx, req.(*QueryChannelsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ConnectionChannels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConnectionChannelsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ConnectionChannels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/ConnectionChannels", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ConnectionChannels(ctx, req.(*QueryConnectionChannelsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PacketCommitment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketCommitmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketCommitment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/PacketCommitment", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketCommitment(ctx, req.(*QueryPacketCommitmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PacketCommitments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPacketCommitmentsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PacketCommitments(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/PacketCommitments", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PacketCommitments(ctx, req.(*QueryPacketCommitmentsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_UnrelayedPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUnrelayedPacketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UnrelayedPackets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/UnrelayedPackets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UnrelayedPackets(ctx, req.(*QueryUnrelayedPacketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_NextSequenceReceive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNextSequenceReceiveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NextSequenceReceive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.channel.Query/NextSequenceReceive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NextSequenceReceive(ctx, req.(*QueryNextSequenceReceiveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.channel.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Channel", + Handler: _Query_Channel_Handler, + }, + { + MethodName: "Channels", + Handler: _Query_Channels_Handler, + }, + { + MethodName: "ConnectionChannels", + Handler: _Query_ConnectionChannels_Handler, + }, + { + MethodName: "PacketCommitment", + Handler: _Query_PacketCommitment_Handler, + }, + { + MethodName: "PacketCommitments", + Handler: _Query_PacketCommitments_Handler, + }, + { + MethodName: "UnrelayedPackets", + Handler: _Query_UnrelayedPackets_Handler, + }, + { + MethodName: "NextSequenceReceive", + Handler: _Query_NextSequenceReceive_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/channel/query.proto", +} + +func (m *QueryChannelRequest) 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 *QueryChannelRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryChannelResponse) 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 *QueryChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ProofPath) > 0 { + i -= len(m.ProofPath) + copy(dAtA[i:], m.ProofPath) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProofPath))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.Channel != nil { + { + size, err := m.Channel.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 *QueryChannelsRequest) 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 *QueryChannelsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Req != nil { + { + size, err := m.Req.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 *QueryChannelsResponse) 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 *QueryChannelsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Channels) > 0 { + for iNdEx := len(m.Channels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Channels[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 *QueryConnectionChannelsRequest) 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 *QueryConnectionChannelsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionChannelsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Connection) > 0 { + i -= len(m.Connection) + copy(dAtA[i:], m.Connection) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Connection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryConnectionChannelsResponse) 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 *QueryConnectionChannelsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConnectionChannelsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Channels) > 0 { + for iNdEx := len(m.Channels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Channels[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 *QueryPacketCommitmentRequest) 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 *QueryPacketCommitmentRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketCommitmentResponse) 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 *QueryPacketCommitmentResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ProofPath) > 0 { + i -= len(m.ProofPath) + copy(dAtA[i:], m.ProofPath) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProofPath))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketCommitmentsRequest) 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 *QueryPacketCommitmentsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPacketCommitmentsResponse) 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 *QueryPacketCommitmentsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPacketCommitmentsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Commitments) > 0 { + for iNdEx := len(m.Commitments) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commitments[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 *QueryUnrelayedPacketsRequest) 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 *QueryUnrelayedPacketsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnrelayedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.Sequences) > 0 { + dAtA10 := make([]byte, len(m.Sequences)*10) + var j9 int + for _, num := range m.Sequences { + for num >= 1<<7 { + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j9++ + } + dAtA10[j9] = uint8(num) + j9++ + } + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintQuery(dAtA, i, uint64(j9)) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUnrelayedPacketsResponse) 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 *QueryUnrelayedPacketsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnrelayedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Packets) > 0 { + dAtA13 := make([]byte, len(m.Packets)*10) + var j12 int + for _, num := range m.Packets { + for num >= 1<<7 { + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j12++ + } + dAtA13[j12] = uint8(num) + j12++ + } + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintQuery(dAtA, i, uint64(j12)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNextSequenceReceiveRequest) 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 *QueryNextSequenceReceiveRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextSequenceReceiveRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNextSequenceReceiveResponse) 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 *QueryNextSequenceReceiveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNextSequenceReceiveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ProofPath) > 0 { + i -= len(m.ProofPath) + copy(dAtA[i:], m.ProofPath) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProofPath))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.NextSequenceReceive != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NextSequenceReceive)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryChannelClientStateRequest) 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 *QueryChannelClientStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelClientStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryChannelRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Channel != nil { + l = m.Channel.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ProofPath) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofHeight != 0 { + n += 1 + sovQuery(uint64(m.ProofHeight)) + } + return n +} + +func (m *QueryChannelsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryChannelsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Channels) > 0 { + for _, e := range m.Channels { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryConnectionChannelsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Connection) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConnectionChannelsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Channels) > 0 { + for _, e := range m.Channels { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryPacketCommitmentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + return n +} + +func (m *QueryPacketCommitmentResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Commitment) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ProofPath) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofHeight != 0 { + n += 1 + sovQuery(uint64(m.ProofHeight)) + } + return n +} + +func (m *QueryPacketCommitmentsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPacketCommitmentsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Commitments) > 0 { + for _, e := range m.Commitments { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryUnrelayedPacketsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Sequences) > 0 { + l = 0 + for _, e := range m.Sequences { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryUnrelayedPacketsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Packets) > 0 { + l = 0 + for _, e := range m.Packets { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryNextSequenceReceiveRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNextSequenceReceiveResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextSequenceReceive != 0 { + n += 1 + sovQuery(uint64(m.NextSequenceReceive)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ProofPath) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofHeight != 0 { + n += 1 + sovQuery(uint64(m.ProofHeight)) + } + return n +} + +func (m *QueryChannelClientStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryChannelRequest) 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: QueryChannelRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelResponse) 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: QueryChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", 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.Channel == nil { + m.Channel = &Channel{} + } + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPath", 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.ProofPath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelsRequest) 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: QueryChannelsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", 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.Req == nil { + m.Req = &query.PageRequest{} + } + if err := m.Req.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelsResponse) 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: QueryChannelsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channels", 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.Channels = append(m.Channels, &IdentifiedChannel{}) + if err := m.Channels[len(m.Channels)-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 Res", 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.Res == nil { + m.Res = &query.PageResponse{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConnectionChannelsRequest) 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: QueryConnectionChannelsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionChannelsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Connection", 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.Connection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", 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.Req == nil { + m.Req = &query.PageRequest{} + } + if err := m.Req.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConnectionChannelsResponse) 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: QueryConnectionChannelsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConnectionChannelsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channels", 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.Channels = append(m.Channels, &IdentifiedChannel{}) + if err := m.Channels[len(m.Channels)-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 Res", 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.Res == nil { + m.Res = &query.PageResponse{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentRequest) 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: QueryPacketCommitmentRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentResponse) 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: QueryPacketCommitmentResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitment", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPath", 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.ProofPath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentsRequest) 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: QueryPacketCommitmentsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", 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.Req == nil { + m.Req = &query.PageRequest{} + } + if err := m.Req.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPacketCommitmentsResponse) 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: QueryPacketCommitmentsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPacketCommitmentsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitments", 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.Commitments = append(m.Commitments, &PacketAckCommitment{}) + if err := m.Commitments[len(m.Commitments)-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 Res", 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.Res == nil { + m.Res = &query.PageResponse{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnrelayedPacketsRequest) 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: QueryUnrelayedPacketsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnrelayedPacketsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Sequences) == 0 { + m.Sequences = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequences = append(m.Sequences, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Sequences", wireType) + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", 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.Req == nil { + m.Req = &query.PageRequest{} + } + if err := m.Req.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnrelayedPacketsResponse) 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: QueryUnrelayedPacketsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnrelayedPacketsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Packets = append(m.Packets, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Packets) == 0 { + m.Packets = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Packets = append(m.Packets, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Packets", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", 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.Res == nil { + m.Res = &query.PageResponse{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNextSequenceReceiveRequest) 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: QueryNextSequenceReceiveRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextSequenceReceiveRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNextSequenceReceiveResponse) 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: QueryNextSequenceReceiveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNextSequenceReceiveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceReceive", wireType) + } + m.NextSequenceReceive = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextSequenceReceive |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPath", 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.ProofPath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelClientStateRequest) 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: QueryChannelClientStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelClientStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", 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.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/keeper/grpc_query.go b/x/ibc/keeper/grpc_query.go new file mode 100644 index 000000000000..8c986409da40 --- /dev/null +++ b/x/ibc/keeper/grpc_query.go @@ -0,0 +1,58 @@ +package keeper + +import ( + "context" + + connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" +) + +// Connection implements the IBC QueryServer interface +func (q Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) { + return q.ConnectionKeeper.Connection(c, req) +} + +// Connections implements the IBC QueryServer interface +func (q Keeper) Connections(c context.Context, req *connectiontypes.QueryConnectionsRequest) (*connectiontypes.QueryConnectionsResponse, error) { + return q.ConnectionKeeper.Connections(c, req) +} + +// ClientConnections implements the IBC QueryServer interface +func (q Keeper) ClientConnections(c context.Context, req *connectiontypes.QueryClientConnectionsRequest) (*connectiontypes.QueryClientConnectionsResponse, error) { + return q.ConnectionKeeper.ClientConnections(c, req) +} + +// Channel implements the IBC QueryServer interface +func (q Keeper) Channel(c context.Context, req *channeltypes.QueryChannelRequest) (*channeltypes.QueryChannelResponse, error) { + return q.ChannelKeeper.Channel(c, req) +} + +// Channels implements the IBC QueryServer interface +func (q Keeper) Channels(c context.Context, req *channeltypes.QueryChannelsRequest) (*channeltypes.QueryChannelsResponse, error) { + return q.ChannelKeeper.Channels(c, req) +} + +// ConnectionChannels implements the IBC QueryServer interface +func (q Keeper) ConnectionChannels(c context.Context, req *channeltypes.QueryConnectionChannelsRequest) (*channeltypes.QueryConnectionChannelsResponse, error) { + return q.ChannelKeeper.ConnectionChannels(c, req) +} + +// PacketCommitment implements the IBC QueryServer interface +func (q Keeper) PacketCommitment(c context.Context, req *channeltypes.QueryPacketCommitmentRequest) (*channeltypes.QueryPacketCommitmentResponse, error) { + return q.ChannelKeeper.PacketCommitment(c, req) +} + +// PacketCommitments implements the IBC QueryServer interface +func (q Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPacketCommitmentsRequest) (*channeltypes.QueryPacketCommitmentsResponse, error) { + return q.ChannelKeeper.PacketCommitments(c, req) +} + +// UnrelayedPackets implements the IBC QueryServer interface +func (q Keeper) UnrelayedPackets(c context.Context, req *channeltypes.QueryUnrelayedPacketsRequest) (*channeltypes.QueryUnrelayedPacketsResponse, error) { + return q.ChannelKeeper.UnrelayedPackets(c, req) +} + +// NextSequenceReceive implements the IBC QueryServer interface +func (q Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNextSequenceReceiveRequest) (*channeltypes.QueryNextSequenceReceiveResponse, error) { + return q.ChannelKeeper.NextSequenceReceive(c, req) +} diff --git a/x/ibc/keeper/keeper.go b/x/ibc/keeper/keeper.go index 7bb6d017ddba..b113553e41b3 100644 --- a/x/ibc/keeper/keeper.go +++ b/x/ibc/keeper/keeper.go @@ -10,10 +10,16 @@ import ( channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper" portkeeper "github.com/cosmos/cosmos-sdk/x/ibc/05-port/keeper" porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" + "github.com/cosmos/cosmos-sdk/x/ibc/types" ) +var _ types.QueryServer = (*Keeper)(nil) + // Keeper defines each ICS keeper for IBC type Keeper struct { + // implements gRPC QueryServer interface + types.QueryServer + aminoCdc *codec.Codec cdc codec.Marshaler diff --git a/x/ibc/keeper/querier.go b/x/ibc/keeper/querier.go index 340b308f7508..025bae1c2ede 100644 --- a/x/ibc/keeper/querier.go +++ b/x/ibc/keeper/querier.go @@ -7,7 +7,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" - connectionkeeper "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" @@ -30,30 +29,11 @@ func NewQuerier(k Keeper) sdk.Querier { err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", clienttypes.SubModuleName) } case connectiontypes.SubModuleName: - switch path[1] { - case connectiontypes.QueryAllConnections: - res, err = connectionkeeper.QuerierConnections(ctx, req, k.ConnectionKeeper) - case connectiontypes.QueryAllClientConnections: - res, err = connectionkeeper.QuerierAllClientConnections(ctx, req, k.ConnectionKeeper) - case connectiontypes.QueryClientConnections: - res, err = connectionkeeper.QuerierClientConnections(ctx, req, k.ConnectionKeeper) - default: - err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", connectiontypes.SubModuleName) - } + err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", connectiontypes.SubModuleName) case channeltypes.SubModuleName: switch path[1] { - case channeltypes.QueryAllChannels: - res, err = channelkeeper.QuerierChannels(ctx, req, k.ChannelKeeper) - case channeltypes.QueryConnectionChannels: - res, err = channelkeeper.QuerierConnectionChannels(ctx, req, k.ChannelKeeper) case channeltypes.QueryChannelClientState: res, err = channelkeeper.QuerierChannelClientState(ctx, req, k.ChannelKeeper) - case channeltypes.QueryPacketCommitments: - res, err = channelkeeper.QuerierPacketCommitments(ctx, req, k.ChannelKeeper) - case channeltypes.QueryUnrelayedAcknowledgements: - res, err = channelkeeper.QuerierUnrelayedAcknowledgements(ctx, req, k.ChannelKeeper) - case channeltypes.QueryUnrelayedPacketSends: - res, err = channelkeeper.QuerierUnrelayedPacketSends(ctx, req, k.ChannelKeeper) default: err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", channeltypes.SubModuleName) } diff --git a/x/ibc/keeper/querier_test.go b/x/ibc/keeper/querier_test.go index 7912a7d820c6..f5ece386adc4 100644 --- a/x/ibc/keeper/querier_test.go +++ b/x/ibc/keeper/querier_test.go @@ -26,94 +26,29 @@ func (suite *KeeperTestSuite) TestNewQuerier() { expectsDefaultErr bool errMsg string }{ - {"client - QuerierClientState", - []string{clienttypes.SubModuleName, clienttypes.QueryClientState}, - false, - "", - }, {"client - QuerierClients", []string{clienttypes.SubModuleName, clienttypes.QueryAllClients}, false, "", }, - { - "client - QuerierConsensusState", - []string{clienttypes.SubModuleName, clienttypes.QueryConsensusState}, - false, - "", - }, { "client - invalid query", []string{clienttypes.SubModuleName, "foo"}, true, fmt.Sprintf("unknown IBC %s query endpoint", clienttypes.SubModuleName), }, - { - "connection - QuerierConnections", - []string{connectiontypes.SubModuleName, connectiontypes.QueryAllConnections}, - false, - "", - }, - { - "connection - QuerierAllClientConnections", - []string{connectiontypes.SubModuleName, connectiontypes.QueryAllClientConnections}, - false, - "", - }, - { - "connection - QuerierClientConnections", - []string{connectiontypes.SubModuleName, connectiontypes.QueryClientConnections}, - false, - "", - }, { "connection - invalid query", []string{connectiontypes.SubModuleName, "foo"}, true, fmt.Sprintf("unknown IBC %s query endpoint", connectiontypes.SubModuleName), }, - { - "channel - QuerierChannel", - []string{channeltypes.SubModuleName, channeltypes.QueryChannel}, - false, - "", - }, - { - "channel - QuerierChannels", - []string{channeltypes.SubModuleName, channeltypes.QueryAllChannels}, - false, - "", - }, - { - "channel - QuerierConnectionChannels", - []string{channeltypes.SubModuleName, channeltypes.QueryConnectionChannels}, - false, - "", - }, { "channel - QuerierChannelClientState", []string{channeltypes.SubModuleName, channeltypes.QueryChannelClientState}, false, "", }, - { - "channel - QuerierPacketCommitments", - []string{channeltypes.SubModuleName, channeltypes.QueryPacketCommitments}, - false, - "", - }, - { - "channel - QuerierUnrelayedAcknowledgements", - []string{channeltypes.SubModuleName, channeltypes.QueryUnrelayedAcknowledgements}, - false, - "", - }, - { - "channel - QuerierUnrelayedPacketSends", - []string{channeltypes.SubModuleName, channeltypes.QueryUnrelayedPacketSends}, - false, - "", - }, { "channel - invalid query", []string{channeltypes.SubModuleName, "foo"}, diff --git a/x/ibc/module.go b/x/ibc/module.go index c5e584c8f5e1..0ce331dd424d 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -17,7 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - client2 "github.com/cosmos/cosmos-sdk/x/ibc/02-client" + ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/client/cli" "github.com/cosmos/cosmos-sdk/x/ibc/client/rest" @@ -124,7 +124,10 @@ func (am AppModule) NewQuerierHandler() sdk.Querier { return keeper.NewQuerier(*am.keeper) } -func (am AppModule) RegisterQueryService(grpc.Server) {} +// RegisterQueryService registers the gRPC query service for the ibc module. +func (am AppModule) RegisterQueryService(server grpc.Server) { + types.RegisterQueryService(server, am.keeper) +} // InitGenesis performs genesis initialization for the ibc module. It returns // no validator updates. @@ -146,7 +149,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json // BeginBlock returns the begin blocker for the ibc module. func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - client2.BeginBlocker(ctx, am.keeper.ClientKeeper) + ibcclient.BeginBlocker(ctx, am.keeper.ClientKeeper) } // EndBlock returns the end blocker for the ibc module. It returns no validator diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 56ab205af527..2e99a8bf7474 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -29,6 +29,7 @@ import ( commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/keeper" + "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -64,7 +65,8 @@ type TestChain struct { ChainID string LastHeader ibctmtypes.Header // header for last block height committed CurrentHeader abci.Header // header for current block height - Querier sdk.Querier + Querier sdk.Querier // TODO: deprecate once clients are migrated to gRPC + QueryServer types.QueryServer Vals *tmtypes.ValidatorSet Signers []tmtypes.PrivValidator @@ -119,6 +121,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { App: app, CurrentHeader: header, Querier: keeper.NewQuerier(*app.IBCKeeper), + QueryServer: app.IBCKeeper, Vals: valSet, Signers: signers, senderPrivKey: senderPrivKey, diff --git a/x/ibc/types/query.go b/x/ibc/types/query.go new file mode 100644 index 000000000000..d529361d0be1 --- /dev/null +++ b/x/ibc/types/query.go @@ -0,0 +1,21 @@ +package types + +import ( + connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" + connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" + channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + "github.com/gogo/protobuf/grpc" +) + +// QueryServer defines the IBC interfaces that the gRPC query server must implement +type QueryServer interface { + connectiontypes.QueryServer + channeltypes.QueryServer +} + +// RegisterQueryService registers each individual IBC submodule query service +func RegisterQueryService(server grpc.Server, queryService QueryServer) { + connection.RegisterQueryService(server, queryService) + channel.RegisterQueryService(server, queryService) +}