Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract Height in IBC Clients #6686

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e3ee983
add abstract height method
AdityaSripal Jul 7, 2020
6233c94
convert 07-tendermint to abstract height
AdityaSripal Jul 10, 2020
c51bab1
make localhost build pass
AdityaSripal Jul 10, 2020
ee5edcc
make client keeper changes
AdityaSripal Jul 10, 2020
488d232
fix connection and update proto
AdityaSripal Jul 14, 2020
10c3a3f
update all proto files correctly
AdityaSripal Jul 14, 2020
8fa0e2f
fix all non-test builds
AdityaSripal Jul 14, 2020
b405b9e
fix clients
AdityaSripal Jul 14, 2020
5adc5bc
fix ibc testing package
AdityaSripal Jul 14, 2020
6c494bb
fix tmtypes test
AdityaSripal Jul 15, 2020
faafff7
fix tendermint package tests
AdityaSripal Jul 16, 2020
660b0ff
fix localhost tests
AdityaSripal Jul 16, 2020
04cb265
fix client tests
AdityaSripal Jul 16, 2020
179943d
fix connection tests
AdityaSripal Jul 21, 2020
452a66f
fix channel tests
AdityaSripal Jul 21, 2020
ac32c79
fix all x/ibc tests
AdityaSripal Jul 21, 2020
7dfe1c9
fix all tests
AdityaSripal Jul 21, 2020
2bdf31f
fmt proto files
AdityaSripal Jul 21, 2020
fcefa34
add tendermint abstract height handling tests
AdityaSripal Jul 22, 2020
ff89df0
move frozen test case to appropriate pkg
AdityaSripal Jul 23, 2020
f3f4d3b
fix merge
AdityaSripal Jul 23, 2020
c2e0cd7
fix lint bugs
AdityaSripal Jul 23, 2020
aa0a342
Apply suggestions from code review
AdityaSripal Jul 29, 2020
c74bec9
make Compare more idiomatic
AdityaSripal Jul 29, 2020
b612ac7
fix godoc
AdityaSripal Jul 30, 2020
363287c
address @colin-axner comments
AdityaSripal Jul 30, 2020
28585e9
fix merge in x/ibc
AdityaSripal Aug 25, 2020
aa9d1e6
fix rest of merges
AdityaSripal Aug 25, 2020
3f77210
refix some builds
AdityaSripal Aug 25, 2020
541737c
cleanup last merge issues
AdityaSripal Aug 25, 2020
898c363
start migrating fields to use proto Height
AdityaSripal Aug 25, 2020
cde1aea
start using Height in 02-client
AdityaSripal Aug 25, 2020
3a7910b
start updating clients with proto Height
AdityaSripal Aug 26, 2020
43ec7bf
fix client types
AdityaSripal Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ=
github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso=
github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go=
github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g=
github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk=
Expand Down
22 changes: 11 additions & 11 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,7 @@ 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\""];
bytes signer = 7
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -37,7 +38,7 @@ 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\""];
bytes signer = 6
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -48,7 +49,7 @@ 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\""];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -68,7 +69,7 @@ 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\""];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -77,7 +78,7 @@ 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\""];
bytes signer = 4
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand All @@ -86,7 +87,7 @@ 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\""];
uint64 next_sequence_recv = 4
[(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
bytes signer = 5
Expand All @@ -98,7 +99,7 @@ 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\""];
uint64 next_sequence_recv = 5
[(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
bytes signer = 6
Expand All @@ -110,7 +111,7 @@ 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\""];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
Expand Down Expand Up @@ -222,10 +223,9 @@ 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\""];
// block timestamp (in nanoseconds) after which the packet times out
uint64 timeout_timestamp = 8
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

// PacketAckCommitment defines the genesis type necessary to retrieve and store
Expand Down
18 changes: 10 additions & 8 deletions proto/ibc/channel/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 +94,7 @@ 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;
}

// QueryChannelsRequest is the request type for the Query/Channels RPC method
Expand Down Expand Up @@ -152,7 +152,7 @@ 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;
}

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

// QueryChannelClientStateResponse is the Response type for the
Expand All @@ -178,7 +180,7 @@ 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;
}

// QueryPacketCommitmentRequest is the request type for the
Expand All @@ -203,7 +205,7 @@ 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;
}

// QueryPacketCommitmentsRequest is the request type for the
Expand Down Expand Up @@ -249,7 +251,7 @@ 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;
}

// QueryUnrelayedPacketsRequest is the request type for the
Expand Down Expand Up @@ -294,6 +296,6 @@ 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;
}

15 changes: 15 additions & 0 deletions proto/ibc/client/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@ message ClientConsensusStates {
// consensus states associated with the client
repeated google.protobuf.Any consensus_states = 2 [(gogoproto.moretags) = "yaml:\"consensus_states\""];
}

// Height is a monotonically increasing data type
// that can be compared against another Height for the purposes of updating and freezing clients
//
// Normally the EpochHeight is incremented at each height while keeping epoch number the same
// However some consensus algorithms may choose to reset the height in certain conditions
// e.g. hard forks, state-machine breaking changes
// In these cases, the epoch number is incremented so that height continues to be monitonically increasing
// even as the EpochHeight gets reset
message Height {
// the epoch that the client is currently on
uint64 epoch_number = 1 [(gogoproto.moretags) = "yaml:\"epoch_number\""];
// the height within the given epoch
uint64 epoch_height = 2 [(gogoproto.moretags) = "yaml:\"epoch_height\""];
}
14 changes: 8 additions & 6 deletions proto/ibc/client/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 +49,7 @@ message QueryClientStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
Height proof_height = 4;
}

// QueryClientStatesRequest is the request type for the Query/ClientStates RPC
Expand All @@ -73,10 +73,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 +90,7 @@ message QueryConsensusStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
Height proof_height = 4;
}

// QueryConsensusStatesRequest is the request type for the Query/ConsensusStates RPC method.
Expand Down
13 changes: 7 additions & 6 deletions proto/ibc/connection/connection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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/client/client.proto";
import "ibc/commitment/commitment.proto";

// MsgConnectionOpenInit defines the msg sent by an account on Chain A to
Expand Down Expand Up @@ -36,15 +37,15 @@ 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\""];
// 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
ibc.client.Height consensus_height = 10
[(gogoproto.moretags) = "yaml:\"consensus_height\""];
bytes signer = 11
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
Expand All @@ -60,15 +61,15 @@ 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\""];
// 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
ibc.client.Height consensus_height = 8
[(gogoproto.moretags) = "yaml:\"consensus_height\""];
bytes signer = 9
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
Expand All @@ -82,8 +83,8 @@ 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\""];
bytes signer = 4
ibc.client.Height proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
bytes signer = 5
[(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}

Expand Down
8 changes: 4 additions & 4 deletions proto/ibc/connection/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ message QueryConnectionResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4;
}

// QueryConnectionsRequest is the request type for the Query/Connections RPC
Expand Down Expand Up @@ -99,7 +99,7 @@ message QueryClientConnectionsResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was generated
uint64 proof_height = 4;
ibc.client.Height proof_height = 4;
}

// QueryConnectionClientStateRequest is the request type for the
Expand All @@ -121,7 +121,7 @@ message QueryConnectionClientStateResponse {
// merkle proof path
string proof_path = 3;
// height at which the proof was retrieved
uint64 proof_height = 4;
ibc.client.Height proof_height = 4;
}

// QueryConnectionConsensusStateRequest is the request type for the
Expand All @@ -146,5 +146,5 @@ message QueryConnectionConsensusStateResponse {
// merkle proof path
string proof_path = 4;
// height at which the proof was retrieved
uint64 proof_height = 5;
ibc.client.Height proof_height = 5;
}
9 changes: 5 additions & 4 deletions proto/ibc/tendermint/tendermint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "tendermint/types/types.proto";
import "confio/proofs.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "ibc/client/client.proto";
import "ibc/commitment/commitment.proto";
import "gogoproto/gogo.proto";

Expand Down Expand Up @@ -41,9 +42,9 @@ message ClientState {
(gogoproto.moretags) = "yaml:\"max_clock_drift\""
];
// Block height when the client was frozen due to a misbehaviour
uint64 frozen_height = 6 [(gogoproto.moretags) = "yaml:\"frozen_height\""];
ibc.client.Height frozen_height = 6 [(gogoproto.moretags) = "yaml:\"frozen_height\""];
// Latest height the client was updated to
uint64 latest_height = 7 [(gogoproto.moretags) = "yaml:\"latest_height\""];
ibc.client.Height latest_height = 7 [(gogoproto.moretags) = "yaml:\"latest_height\""];
// Proof specifications used in verifying counterparty state
repeated ics23.ProofSpec proof_specs = 8
[(gogoproto.moretags) = "yaml:\"proof_specs\""];
Expand All @@ -60,7 +61,7 @@ message ConsensusState {
// commitment root (i.e app hash)
ibc.commitment.MerkleRoot root = 2 [(gogoproto.nullable) = false];
// height at which the consensus state was stored.
uint64 height = 3;
ibc.client.Height height = 3;
bytes next_validators_hash = 4 [
(gogoproto.casttype) =
"github.com/tendermint/tendermint/libs/bytes.HexBytes",
Expand Down Expand Up @@ -106,7 +107,7 @@ message Header {

.tendermint.types.ValidatorSet validator_set = 2
[(gogoproto.moretags) = "yaml:\"validator_set\""];
uint64 trusted_height = 3 [(gogoproto.moretags) = "yaml:\"trusted_height\""];
ibc.client.Height trusted_height = 3 [(gogoproto.moretags) = "yaml:\"trusted_height\""];
.tendermint.types.ValidatorSet trusted_validators = 4
[(gogoproto.moretags) = "yaml:\"trusted_validators\""];
}
Expand Down
5 changes: 3 additions & 2 deletions proto/ibc/transfer/transfer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types";

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "ibc/client/client.proto";

// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between
// ICS20 enabled chains. See ICS Spec here:
Expand All @@ -22,10 +23,10 @@ message MsgTransfer {
string receiver = 5;
// Timeout height relative to the current block height.
// The timeout is disabled when set to 0.
uint64 timeout_height = 6 [(gogoproto.moretags) = "yaml:\"timeout_height\""];
ibc.client.Height timeout_height = 7 [(gogoproto.moretags) = "yaml:\"timeout_height\""];
// Timeout timestamp (in nanoseconds) relative to the current block timestamp.
// The timeout is disabled when set to 0.
uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

// FungibleTokenPacketData defines a struct for the packet payload
Expand Down
Loading