Skip to content

Commit

Permalink
x/ibc: implement Height interface (#7211)
Browse files Browse the repository at this point in the history
* change interfaces

* fix tendermint client interfaces

* fix other clients interfaces

* fix queries

* fix tendermint build

* fix builds of clients

* fix 02-build

* start fixing connection and make queries non-nullable

* fix connection keepers and queries

* fix connection build

* fix channel build

* fix all non-test files

* fix testing build

* cleanup

* lint

* fix timeout height interface

* fix tendermint tests

* fix rest of clients

* fix connection tests

* fix client tests

* fix channel tests

* fix all ibc tests

* fix transfer tests:

* docs

* fix connection query

* Apply suggestions from code review

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* wrap-up review

Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 3, 2020
1 parent d76f5ce commit 4f9e31e
Show file tree
Hide file tree
Showing 106 changed files with 2,786 additions and 1,676 deletions.
46 changes: 37 additions & 9 deletions proto/ibc/channel/channel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ibc.channel;
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types";

import "gogoproto/gogo.proto";
import "ibc/client/client.proto";

// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It
// is called by a relayer on Chain A.
Expand All @@ -24,7 +25,10 @@ message MsgChannelOpenTry {
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\""];
ibc.client.Height proof_height = 6 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 7
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -37,7 +41,10 @@ message MsgChannelOpenAck {
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\""];
ibc.client.Height proof_height = 5 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 6
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -48,7 +55,10 @@ message MsgChannelOpenConfirm {
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""];
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 4 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -68,7 +78,10 @@ message MsgChannelCloseConfirm {
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""];
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 4 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -77,7 +90,10 @@ message MsgChannelCloseConfirm {
message MsgRecvPacket {
Packet packet = 1 [(gogoproto.nullable) = false];
bytes proof = 2;
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 3 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 4
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -86,7 +102,10 @@ message MsgRecvPacket {
message MsgTimeout {
Packet packet = 1 [(gogoproto.nullable) = false];
bytes proof = 2;
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 3 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
uint64 next_sequence_recv = 4
[(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
bytes signer = 5
Expand All @@ -98,7 +117,10 @@ message MsgTimeoutOnClose {
Packet packet = 1 [(gogoproto.nullable) = false];
bytes proof = 2;
bytes proof_close = 3 [(gogoproto.moretags) = "yaml:\"proof_close\""];
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 4 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
uint64 next_sequence_recv = 5
[(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
bytes signer = 6
Expand All @@ -110,7 +132,10 @@ message MsgAcknowledgement {
Packet packet = 1 [(gogoproto.nullable) = false];
bytes acknowledgement = 2;
bytes proof = 3;
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 4 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand Down Expand Up @@ -222,7 +247,10 @@ message Packet {
// actual opaque bytes transferred directly to the application module
bytes data = 6;
// block height after which the packet times out
uint64 timeout_height = 7 [(gogoproto.moretags) = "yaml:\"timeout_height\""];
ibc.client.Height timeout_height = 7 [
(gogoproto.moretags) = "yaml:\"timeout_height\"",
(gogoproto.nullable) = false
];
// block timestamp (in nanoseconds) after which the packet times out
uint64 timeout_timestamp = 8
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
Expand Down
49 changes: 36 additions & 13 deletions proto/ibc/channel/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "ibc/channel/channel.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types";

Expand Down Expand Up @@ -39,7 +40,7 @@ service Query {
// associated with the provided channel identifiers.
rpc ChannelConsensusState(QueryChannelConsensusStateRequest)
returns (QueryChannelConsensusStateResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/{height}";
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/epoch/{epoch_number}/height/{epoch_height}";
}

// PacketCommitment queries a stored packet commitment hash.
Expand Down Expand Up @@ -94,7 +95,9 @@ message QueryChannelResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

// QueryChannelsRequest is the request type for the Query/Channels RPC method
Expand All @@ -110,7 +113,9 @@ message QueryChannelsResponse {
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
// query block height
int64 height = 3;
ibc.client.Height height = 3 [
(gogoproto.nullable) = false
];
}

// QueryConnectionChannelsRequest is the request type for the
Expand All @@ -130,7 +135,9 @@ message QueryConnectionChannelsResponse {
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
// query block height
int64 height = 3;
ibc.client.Height height = 3 [
(gogoproto.nullable) = false
];
}

// QueryChannelClientStateRequest is the request type for the Query/ClientState
Expand All @@ -152,7 +159,9 @@ message QueryChannelClientStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

// QueryChannelConsensusStateRequest is the request type for the
Expand All @@ -162,8 +171,10 @@ message QueryChannelConsensusStateRequest {
string port_id = 1;
// channel unique identifier
string channel_id = 2;
// height of the consensus state
uint64 height = 3;
// epoch number of the consensus state
uint64 epoch_number = 3;
// epoch height of the consensus state
uint64 epoch_height = 4;
}

// QueryChannelClientStateResponse is the Response type for the
Expand All @@ -178,7 +189,9 @@ message QueryChannelConsensusStateResponse {
// merkle proof path
string proof_path = 4;
// height at which the proof was retrieved
uint64 proof_height = 5;
ibc.client.Height proof_height = 5 [
(gogoproto.nullable) = false
];
}

// QueryPacketCommitmentRequest is the request type for the
Expand All @@ -203,7 +216,9 @@ message QueryPacketCommitmentResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

// QueryPacketCommitmentsRequest is the request type for the
Expand All @@ -224,7 +239,9 @@ message QueryPacketCommitmentsResponse {
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
// query block height
int64 height = 3;
ibc.client.Height height = 3 [
(gogoproto.nullable) = false
];
}

// QueryPacketAcknowledgementRequest is the request type for the
Expand All @@ -249,7 +266,9 @@ message QueryPacketAcknowledgementResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

// QueryUnrelayedPacketsRequest is the request type for the
Expand All @@ -272,7 +291,9 @@ message QueryUnrelayedPacketsResponse {
// list of unrelayed packet sequences
repeated uint64 sequences = 1;
// query block height
int64 height = 2;
ibc.client.Height height = 2 [
(gogoproto.nullable) = false
];
}

// QueryNextSequenceReceiveRequest is the request type for the
Expand All @@ -294,6 +315,8 @@ message QueryNextSequenceReceiveResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

1 change: 1 addition & 0 deletions proto/ibc/client/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ message MsgSubmitMisbehaviour {
// In these cases, the epoch number is incremented so that height continues to
// be monitonically increasing even as the EpochHeight gets reset
message Height {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

// the epoch that the client is currently on
Expand Down
20 changes: 14 additions & 6 deletions proto/ibc/client/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "ibc/client/client.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types";

Expand All @@ -22,7 +23,7 @@ service Query {

// ConsensusState queries a consensus state associated with a client state at a given height.
rpc ConsensusState(QueryConsensusStateRequest) returns (QueryConsensusStateResponse) {
option (google.api.http).get = "/ibc/client/v1beta1/consensus_states/{client_id}/{height}";
option (google.api.http).get = "/ibc/client/v1beta1/consensus_states/{client_id}/epoch/{epoch_number}/height/{epoch_height}";
}

// ConsensusStates queries all the consensus state associated with a given client.
Expand All @@ -49,7 +50,9 @@ message QueryClientStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
}

// QueryClientStatesRequest is the request type for the Query/ClientStates RPC
Expand All @@ -73,10 +76,12 @@ message QueryClientStatesResponse {
message QueryConsensusStateRequest {
// client identifier
string client_id = 1;
// consensus state height
uint64 height = 2;
// consensus state epoch number
uint64 epoch_number = 2;
// consensus state epoch height
uint64 epoch_height = 3;
// latest_height overrrides the height field and queries the latest stored ConsensusState
bool latest_height = 3;
bool latest_height = 4;
}

// QueryConsensusStateResponse is the response type for the Query/ConsensusState RPC method
Expand All @@ -88,7 +93,10 @@ message QueryConsensusStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4 [
(gogoproto.nullable) = false
];
;
}

// QueryConsensusStatesRequest is the request type for the Query/ConsensusStates RPC method.
Expand Down
28 changes: 21 additions & 7 deletions proto/ibc/connection/connection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "ibc/commitment/commitment.proto";
import "ibc/client/client.proto";

// MsgConnectionOpenInit defines the msg sent by an account on Chain A to
// initialize a connection with Chain B.
Expand Down Expand Up @@ -36,16 +37,21 @@ message MsgConnectionOpenTry {
Counterparty counterparty = 4 [(gogoproto.nullable) = false];
repeated string counterparty_versions = 5
[(gogoproto.moretags) = "yaml:\"counterparty_versions\""];
uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 6 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
// proof of the initialization the connection on Chain A: `UNITIALIZED ->
// INIT`
bytes proof_init = 7 [(gogoproto.moretags) = "yaml:\"proof_init\""];
// proof of client state included in message
bytes proof_client = 8 [(gogoproto.moretags) = "yaml:\"proof_client\""];
// proof of client consensus state
bytes proof_consensus = 9 [(gogoproto.moretags) = "yaml:\"proof_consensus\""];
uint64 consensus_height = 10
[(gogoproto.moretags) = "yaml:\"consensus_height\""];
ibc.client.Height consensus_height = 10 [
(gogoproto.moretags) = "yaml:\"consensus_height\"",
(gogoproto.nullable) = false
];
bytes signer = 11
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -60,16 +66,21 @@ message MsgConnectionOpenAck {
google.protobuf.Any client_state = 3 [
(gogoproto.moretags) = "yaml:\"client_state\""
];
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 4 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
// proof of the initialization the connection on Chain B: `UNITIALIZED ->
// TRYOPEN`
bytes proof_try = 5 [(gogoproto.moretags) = "yaml:\"proof_try\""];
// proof of client state included in message
bytes proof_client = 6 [(gogoproto.moretags) = "yaml:\"proof_client\""];
// proof of client consensus state
bytes proof_consensus = 7 [(gogoproto.moretags) = "yaml:\"proof_consensus\""];
uint64 consensus_height = 8
[(gogoproto.moretags) = "yaml:\"consensus_height\""];
ibc.client.Height consensus_height = 8 [
(gogoproto.moretags) = "yaml:\"consensus_height\"",
(gogoproto.nullable) = false
];
bytes signer = 9
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -82,7 +93,10 @@ message MsgConnectionOpenConfirm {
];
// proof for the change of the connection state on Chain A: `INIT -> OPEN`
bytes proof_ack = 2 [(gogoproto.moretags) = "yaml:\"proof_ack\""];
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
ibc.client.Height proof_height = 3 [
(gogoproto.moretags) = "yaml:\"proof_height\"",
(gogoproto.nullable) = false
];
bytes signer = 4
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand Down
Loading

0 comments on commit 4f9e31e

Please sign in to comment.