diff --git a/go.sum b/go.sum index 85c103b1ecd4..aa0ebc744b63 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/proto/ibc/channel/channel.proto b/proto/ibc/channel/channel.proto index 3d603942c2da..69b0811d88e6 100644 --- a/proto/ibc/channel/channel.proto +++ b/proto/ibc/channel/channel.proto @@ -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. @@ -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"]; } @@ -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"]; } @@ -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"]; } @@ -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"]; } @@ -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"]; } @@ -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 @@ -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 @@ -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"]; } @@ -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 diff --git a/proto/ibc/channel/query.proto b/proto/ibc/channel/query.proto index f5fa3532efb6..540a2c4a4a2e 100644 --- a/proto/ibc/channel/query.proto +++ b/proto/ibc/channel/query.proto @@ -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. @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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; } diff --git a/proto/ibc/client/client.proto b/proto/ibc/client/client.proto index 15be107ea4cc..89d2f095a263 100644 --- a/proto/ibc/client/client.proto +++ b/proto/ibc/client/client.proto @@ -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\""]; +} diff --git a/proto/ibc/client/query.proto b/proto/ibc/client/query.proto index 0571f2441398..a5dfdec43814 100644 --- a/proto/ibc/client/query.proto +++ b/proto/ibc/client/query.proto @@ -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. @@ -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 @@ -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 @@ -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. diff --git a/proto/ibc/connection/connection.proto b/proto/ibc/connection/connection.proto index 5135fd0fa403..f3f6d724467a 100644 --- a/proto/ibc/connection/connection.proto +++ b/proto/ibc/connection/connection.proto @@ -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 @@ -36,7 +37,7 @@ 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\""]; @@ -44,7 +45,7 @@ message MsgConnectionOpenTry { 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"]; @@ -60,7 +61,7 @@ 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\""]; @@ -68,7 +69,7 @@ message MsgConnectionOpenAck { 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"]; @@ -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"]; } diff --git a/proto/ibc/connection/query.proto b/proto/ibc/connection/query.proto index 71c03959c7e5..854d3a6e7ec8 100644 --- a/proto/ibc/connection/query.proto +++ b/proto/ibc/connection/query.proto @@ -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 @@ -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 @@ -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 @@ -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; } diff --git a/proto/ibc/tendermint/tendermint.proto b/proto/ibc/tendermint/tendermint.proto index e6cd0f6e7903..b4622c76cf2b 100644 --- a/proto/ibc/tendermint/tendermint.proto +++ b/proto/ibc/tendermint/tendermint.proto @@ -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"; @@ -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\""]; @@ -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", @@ -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\""]; } diff --git a/proto/ibc/transfer/transfer.proto b/proto/ibc/transfer/transfer.proto index 5b0306cdd9bf..0e25d6c6e49e 100644 --- a/proto/ibc/transfer/transfer.proto +++ b/proto/ibc/transfer/transfer.proto @@ -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: @@ -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 diff --git a/x/ibc-transfer/client/cli/tx.go b/x/ibc-transfer/client/cli/tx.go index 01b17527c852..cf00472258d8 100644 --- a/x/ibc-transfer/client/cli/tx.go +++ b/x/ibc-transfer/client/cli/tx.go @@ -16,6 +16,7 @@ import ( ) const ( + flagPacketTimeoutEpoch = "packet-timeout-epoch" flagPacketTimeoutHeight = "packet-timeout-height" flagPacketTimeoutTimestamp = "packet-timeout-timestamp" flagAbsoluteTimeouts = "absolute-timeouts" @@ -59,6 +60,11 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), return err } + timeoutEpoch, err := cmd.Flags().GetUint64(flagPacketTimeoutEpoch) + if err != nil { + return err + } + timeoutTimestamp, err := cmd.Flags().GetUint64(flagPacketTimeoutTimestamp) if err != nil { return err @@ -77,8 +83,13 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), return err } + // If timeoutEpoch is not specified, use same epoch as latest consensus state + if timeoutEpoch != 0 { + timeoutEpoch = consensusState.GetHeight().EpochNumber + } + if timeoutHeight != 0 { - timeoutHeight = consensusState.GetHeight() + timeoutHeight + timeoutHeight = consensusState.GetHeight().EpochHeight + timeoutHeight } if timeoutTimestamp != 0 { @@ -87,7 +98,7 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), } msg := types.NewMsgTransfer( - srcPort, srcChannel, coin, sender, receiver, timeoutHeight, timeoutTimestamp, + srcPort, srcChannel, coin, sender, receiver, timeoutEpoch, timeoutHeight, timeoutTimestamp, ) if err := msg.ValidateBasic(); err != nil { return err @@ -97,6 +108,7 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), }, } + cmd.Flags().Uint64(flagPacketTimeoutEpoch, 0, "Absolute timeout block epoch.") cmd.Flags().Uint64(flagPacketTimeoutHeight, types.DefaultRelativePacketTimeoutHeight, "Packet timeout block height. The timeout is disabled when set to 0.") cmd.Flags().Uint64(flagPacketTimeoutTimestamp, types.DefaultRelativePacketTimeoutTimestamp, "Packet timeout timestamp in nanoseconds. Default is 10 minutes. The timeout is disabled when set to 0.") cmd.Flags().Bool(flagAbsoluteTimeouts, false, "Timeout flags are used as absolute timeouts.") diff --git a/x/ibc-transfer/keeper/relay.go b/x/ibc-transfer/keeper/relay.go index 9a63c96c0ece..85feb5e36885 100644 --- a/x/ibc-transfer/keeper/relay.go +++ b/x/ibc-transfer/keeper/relay.go @@ -49,6 +49,7 @@ func (k Keeper) SendTransfer( token sdk.Coin, sender sdk.AccAddress, receiver string, + timeoutEpoch, timeoutHeight, timeoutTimestamp uint64, ) error { @@ -139,6 +140,7 @@ func (k Keeper) SendTransfer( sourceChannel, destinationPort, destinationChannel, + timeoutEpoch, timeoutHeight, timeoutTimestamp, ) diff --git a/x/ibc-transfer/types/msgs.go b/x/ibc-transfer/types/msgs.go index 113990bf82cd..9f828b83a049 100644 --- a/x/ibc-transfer/types/msgs.go +++ b/x/ibc-transfer/types/msgs.go @@ -23,6 +23,7 @@ func NewMsgTransfer( Token: token, Sender: sender, Receiver: receiver, + TimeoutEpoch: timeoutEpoch, TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, } diff --git a/x/ibc-transfer/types/msgs_test.go b/x/ibc-transfer/types/msgs_test.go index 6895a874602e..2811d9fbea74 100644 --- a/x/ibc-transfer/types/msgs_test.go +++ b/x/ibc-transfer/types/msgs_test.go @@ -36,14 +36,14 @@ var ( // TestMsgTransferRoute tests Route for MsgTransfer func TestMsgTransferRoute(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 10, 0) + msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 3, 10, 0) require.Equal(t, RouterKey, msg.Route()) } // TestMsgTransferType tests Type for MsgTransfer func TestMsgTransferType(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 10, 0) + msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 3, 10, 0) require.Equal(t, "transfer", msg.Type()) } @@ -83,16 +83,16 @@ func TestMsgTransferValidation(t *testing.T) { // TestMsgTransferGetSignBytes tests GetSignBytes for MsgTransfer func TestMsgTransferGetSignBytes(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 110, 10) + msg := NewMsgTransfer(validPort, validChannel, coins, addr1, addr2, 3, 110, 10) res := msg.GetSignBytes() - expected := `{"receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid","timeout_height":"110","timeout_timestamp":"10","token":{"amount":"100","denom":"atom"}}` + expected := `{"type":"cosmos-sdk/MsgTransfer","value":{"amount":[{"amount":"100","denom":"atom"}],"receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid","timeout_epoch":"3","timeout_height":"110","timeout_timestamp":"10"}}` require.Equal(t, expected, string(res)) } // TestMsgTransferGetSigners tests GetSigners for MsgTransfer func TestMsgTransferGetSigners(t *testing.T) { - msg := NewMsgTransfer(validPort, validChannel, coin, addr1, addr2, 10, 0) + msg := NewMsgTransfer(validPort, validChannel, coins, addr1, addr2, 3, 10, 0) res := msg.GetSigners() expected := "[746573746164647231]" diff --git a/x/ibc-transfer/types/transfer.pb.go b/x/ibc-transfer/types/transfer.pb.go index 00a5ec176d33..94ad00dab1c6 100644 --- a/x/ibc-transfer/types/transfer.pb.go +++ b/x/ibc-transfer/types/transfer.pb.go @@ -7,6 +7,7 @@ import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -41,10 +42,10 @@ type MsgTransfer struct { Receiver string `protobuf:"bytes,5,opt,name=receiver,proto3" json:"receiver,omitempty"` // Timeout height relative to the current block height. // The timeout is disabled when set to 0. - TimeoutHeight uint64 `protobuf:"varint,6,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty" yaml:"timeout_height"` + TimeoutHeight *types1.Height `protobuf:"bytes,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty" yaml:"timeout_height"` // Timeout timestamp (in nanoseconds) relative to the current block timestamp. // The timeout is disabled when set to 0. - TimeoutTimestamp uint64 `protobuf:"varint,7,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` + TimeoutTimestamp uint64 `protobuf:"varint,8,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` } func (m *MsgTransfer) Reset() { *m = MsgTransfer{} } @@ -115,11 +116,11 @@ func (m *MsgTransfer) GetReceiver() string { return "" } -func (m *MsgTransfer) GetTimeoutHeight() uint64 { +func (m *MsgTransfer) GetTimeoutHeight() *types1.Height { if m != nil { return m.TimeoutHeight } - return 0 + return nil } func (m *MsgTransfer) GetTimeoutTimestamp() uint64 { @@ -385,45 +386,46 @@ func init() { func init() { proto.RegisterFile("ibc/transfer/transfer.proto", fileDescriptor_08134a70fd29e656) } var fileDescriptor_08134a70fd29e656 = []byte{ - // 601 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x41, 0x6f, 0xd3, 0x30, + // 620 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x41, 0x6f, 0xd3, 0x30, 0x14, 0x6e, 0xb6, 0xae, 0xdb, 0xdc, 0x6d, 0x80, 0x19, 0x5b, 0x56, 0x20, 0xa9, 0x72, 0xea, 0x65, 0x89, 0x0a, 0x42, 0x48, 0xbb, 0xc0, 0xba, 0x81, 0x98, 0x10, 0xd2, 0x14, 0xf5, 0xc4, 0xa5, 0x72, - 0x9c, 0x47, 0x1a, 0xb5, 0xb1, 0x2b, 0x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, + 0xca, 0x13, 0xba, 0xff, 0xf7, 0xcf, 0x41, 0x2f, 0x6f, 0xd2, 0xa8, 0x7e, 0xbd, 0xcf, 0xff, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x0a, 0x6e, 0x10, 0x15, 0x39, 0x04, 0x00, 0x00, } func (m *MsgTransfer) Marshal() (dAtA []byte, err error) { @@ -449,12 +451,19 @@ func (m *MsgTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.TimeoutTimestamp != 0 { i = encodeVarintTransfer(dAtA, i, uint64(m.TimeoutTimestamp)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } - if m.TimeoutHeight != 0 { - i = encodeVarintTransfer(dAtA, i, uint64(m.TimeoutHeight)) + if m.TimeoutHeight != nil { + { + size, err := m.TimeoutHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTransfer(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x30 + dAtA[i] = 0x3a } if len(m.Receiver) > 0 { i -= len(m.Receiver) @@ -701,8 +710,9 @@ func (m *MsgTransfer) Size() (n int) { if l > 0 { n += 1 + l + sovTransfer(uint64(l)) } - if m.TimeoutHeight != 0 { - n += 1 + sovTransfer(uint64(m.TimeoutHeight)) + if m.TimeoutHeight != nil { + l = m.TimeoutHeight.Size() + n += 1 + l + sovTransfer(uint64(l)) } if m.TimeoutTimestamp != 0 { n += 1 + sovTransfer(uint64(m.TimeoutTimestamp)) @@ -980,11 +990,11 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { } m.Receiver = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: - if wireType != 0 { + case 7: + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) } - m.TimeoutHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTransfer @@ -994,12 +1004,29 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TimeoutHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 7: + if msglen < 0 { + return ErrInvalidLengthTransfer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTransfer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TimeoutHeight == nil { + m.TimeoutHeight = &types1.Height{} + } + if err := m.TimeoutHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) } diff --git a/x/ibc/02-client/abci_test.go b/x/ibc/02-client/abci_test.go index b924f007d0fd..2916a5b72bda 100644 --- a/x/ibc/02-client/abci_test.go +++ b/x/ibc/02-client/abci_test.go @@ -45,7 +45,7 @@ func (suite *ClientTestSuite) TestBeginBlocker() { }, "BeginBlocker shouldn't panic") localHostClient = suite.chainA.GetClientState(exported.ClientTypeLocalHost) - suite.Require().Equal(prevHeight+1, int64(localHostClient.GetLatestHeight())) + suite.Require().Equal(clientexported.NewHeight(0, prevHeight+1), int64(localHostClient.GetLatestHeight())) prevHeight = int64(localHostClient.GetLatestHeight()) } } diff --git a/x/ibc/02-client/client/cli/query.go b/x/ibc/02-client/client/cli/query.go index 95d6953a4e22..613c4d66a0bb 100644 --- a/x/ibc/02-client/client/cli/query.go +++ b/x/ibc/02-client/client/cli/query.go @@ -12,11 +12,15 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" + "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -const flagLatestHeight = "latest-height" +const ( + flagEpoch = "epoch" + flagLatestHeight = "latest-height" +) // GetCmdQueryClientStates defines the command to query all the light clients // that this chain mantains. @@ -171,9 +175,15 @@ If the '--latest' flag is included, the query returns the latest consensus state } } + epoch, err := cmd.Flags().GetInt(flagEpoch) + if err != nil { + return fmt.Errorf("expected integer epoch: %w", err) + } + prove, _ := cmd.Flags().GetBool(flags.FlagProve) - csRes, err := utils.QueryConsensusState(clientCtx, clientID, height, prove, queryLatestHeight) + clientHeight := exported.NewHeight(uint64(epoch), height) + csRes, err := utils.QueryConsensusState(clientCtx, clientID, clientHeight, prove, queryLatestHeight) if err != nil { return err } @@ -183,6 +193,7 @@ If the '--latest' flag is included, the query returns the latest consensus state } cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") + cmd.Flags().Int(flagEpoch, 0, "epoch for the consensus state") cmd.Flags().Bool(flagLatestHeight, false, "return latest stored consensus state") flags.AddQueryFlagsToCmd(cmd) diff --git a/x/ibc/02-client/client/utils/utils.go b/x/ibc/02-client/client/utils/utils.go index 7df4a1ea6e19..da877994a1dd 100644 --- a/x/ibc/02-client/client/utils/utils.go +++ b/x/ibc/02-client/client/utils/utils.go @@ -73,7 +73,7 @@ func QueryClientStateABCI( // 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 QueryConsensusState( - clientCtx client.Context, clientID string, height uint64, prove, latestHeight bool, + clientCtx client.Context, clientID string, height exported.Height, prove, latestHeight bool, ) (*types.QueryConsensusStateResponse, error) { if prove { return QueryConsensusStateABCI(clientCtx, clientID, height) diff --git a/x/ibc/02-client/exported/exported.go b/x/ibc/02-client/exported/exported.go index 82fe7e63670b..57fa95e442b5 100644 --- a/x/ibc/02-client/exported/exported.go +++ b/x/ibc/02-client/exported/exported.go @@ -19,9 +19,9 @@ import ( type ClientState interface { GetChainID() string ClientType() ClientType - GetLatestHeight() uint64 + GetLatestHeight() Height IsFrozen() bool - GetFrozenHeight() uint64 + GetFrozenHeight() Height Validate() error GetProofSpecs() []*ics23.ProofSpec @@ -36,7 +36,7 @@ type ClientState interface { store sdk.KVStore, cdc codec.BinaryMarshaler, root commitmentexported.Root, - height uint64, + height Height, prefix commitmentexported.Prefix, counterpartyClientIdentifier string, proof []byte, @@ -46,9 +46,9 @@ type ClientState interface { store sdk.KVStore, cdc codec.BinaryMarshaler, root commitmentexported.Root, - height uint64, + height Height, counterpartyClientIdentifier string, - consensusHeight uint64, + consensusHeight Height, prefix commitmentexported.Prefix, proof []byte, consensusState ConsensusState, @@ -56,7 +56,7 @@ type ClientState interface { VerifyConnectionState( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, connectionID string, @@ -65,7 +65,7 @@ type ClientState interface { VerifyChannelState( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -75,7 +75,7 @@ type ClientState interface { VerifyPacketCommitment( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -86,7 +86,7 @@ type ClientState interface { VerifyPacketAcknowledgement( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -97,7 +97,7 @@ type ClientState interface { VerifyPacketAcknowledgementAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -107,7 +107,7 @@ type ClientState interface { VerifyNextSequenceRecv( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -121,7 +121,7 @@ type ConsensusState interface { ClientType() ClientType // Consensus kind // GetHeight returns the height of the consensus state - GetHeight() uint64 + GetHeight() Height // GetRoot returns the commitment root of the consensus state, // which is used for key-value pair verification. @@ -136,6 +136,7 @@ type ConsensusState interface { // Misbehaviour defines counterparty misbehaviour for a specific consensus type type Misbehaviour interface { evidenceexported.Evidence + GetIBCHeight() Height ClientType() ClientType GetClientID() string } @@ -143,7 +144,7 @@ type Misbehaviour interface { // Header is the consensus state update information type Header interface { ClientType() ClientType - GetHeight() uint64 + GetHeight() Height } // message and evidence types for the IBC client @@ -172,6 +173,16 @@ type MsgUpdateClient interface { GetHeader() Header } +// Height is a wrapper interface over clienttypes.Height +// all clients must use the concrete implementation in types +type Height interface { + IsZero() bool + LT(Height) bool + EQ(Height) bool + GT(Height) bool + Valid() bool +} + // ClientType defines the type of the consensus algorithm type ClientType byte diff --git a/x/ibc/02-client/handler.go b/x/ibc/02-client/handler.go index 0be44574d92c..a2baa892143e 100644 --- a/x/ibc/02-client/handler.go +++ b/x/ibc/02-client/handler.go @@ -46,7 +46,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg exported.MsgCre types.EventTypeCreateClient, sdk.NewAttribute(types.AttributeKeyClientID, msg.GetClientID()), sdk.NewAttribute(types.AttributeKeyClientType, msg.GetClientType()), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%d", consensusHeight)), + sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%v", consensusHeight)), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/x/ibc/02-client/keeper/client.go b/x/ibc/02-client/keeper/client.go index c795c0cc514c..a65d6cbf258e 100644 --- a/x/ibc/02-client/keeper/client.go +++ b/x/ibc/02-client/keeper/client.go @@ -62,7 +62,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H var ( consensusState exported.ConsensusState - consensusHeight uint64 + consensusHeight exported.Height err error ) @@ -88,7 +88,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H types.EventTypeUpdateClient, sdk.NewAttribute(types.AttributeKeyClientID, clientID), sdk.NewAttribute(types.AttributeKeyClientType, clientType.String()), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%d", consensusHeight)), + sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()), ), ) diff --git a/x/ibc/02-client/keeper/client_test.go b/x/ibc/02-client/keeper/client_test.go index ed4997eb8e2b..a8a735c3b66b 100644 --- a/x/ibc/02-client/keeper/client_test.go +++ b/x/ibc/02-client/keeper/client_test.go @@ -237,7 +237,9 @@ func (suite *KeeperTestSuite) TestUpdateClientLocalhost() { updatedClientState, err := suite.keeper.UpdateClient(suite.ctx, exported.ClientTypeLocalHost, nil) suite.Require().NoError(err, err) - suite.Require().Equal(localhostClient.GetLatestHeight()+1, updatedClientState.GetLatestHeight()) + suite.Require().Equal(localhostClient.GetID(), updatedClientState.GetID()) + suite.Require().Equal(localhostClient.GetLatestHeight().EpochNumber, updatedClientState.GetLatestHeight().EpochNumber) + suite.Require().Equal(localhostClient.GetLatestHeight().EpochHeight+1, updatedClientState.GetLatestHeight().EpochHeight) } func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { @@ -291,8 +293,8 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { { "misbehavior at later height should pass", &ibctmtypes.Misbehaviour{ - Header1: ibctmtypes.CreateTestHeader(testChainID, testClientHeight+5, testClientHeight, altTime, bothValSet, valSet, bothSigners), - Header2: ibctmtypes.CreateTestHeader(testChainID, testClientHeight+5, testClientHeight, suite.ctx.BlockTime(), bothValSet, valSet, bothSigners), + Header1: ibctmtypes.CreateTestHeader(testChainID, exported.NewHeight(0, testClientHeight.EpochHeight+5), exported.NewHeight(0, testClientHeight.EpochHeight+5), altTime, bothValSet, valSet, bothSigners), + Header2: ibctmtypes.CreateTestHeader(testChainID, exported.NewHeight(0, testClientHeight.EpochHeight+5), exported.NewHeight(0, testClientHeight.EpochHeight+5), suite.ctx.BlockTime(), bothValSet, valSet, bothSigners), ChainId: testChainID, ClientId: testClientID, }, diff --git a/x/ibc/02-client/keeper/keeper.go b/x/ibc/02-client/keeper/keeper.go index fac2b3735159..615cd1e8197d 100644 --- a/x/ibc/02-client/keeper/keeper.go +++ b/x/ibc/02-client/keeper/keeper.go @@ -78,7 +78,7 @@ func (k Keeper) SetClientType(ctx sdk.Context, clientID string, clientType expor } // GetClientConsensusState gets the stored consensus state from a client at a given height. -func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height uint64) (exported.ConsensusState, bool) { +func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) { store := k.ClientStore(ctx, clientID) bz := store.Get(host.KeyConsensusState(height)) if bz == nil { @@ -91,7 +91,7 @@ func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height // SetClientConsensusState sets a ConsensusState to a particular client at the given // height -func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height uint64, consensusState exported.ConsensusState) { +func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height, consensusState exported.ConsensusState) { store := k.ClientStore(ctx, clientID) store.Set(host.KeyConsensusState(height), k.MustMarshalConsensusState(consensusState)) } @@ -157,7 +157,7 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta // HasClientConsensusState returns if keeper has a ConsensusState for a particular // client at the given height -func (k Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height uint64) bool { +func (k Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) bool { store := k.ClientStore(ctx, clientID) return store.Has(host.KeyConsensusState(height)) } @@ -173,11 +173,18 @@ func (k Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) // GetClientConsensusStateLTE will get the latest ConsensusState of a particular client at the latest height // less than or equal to the given height -func (k Keeper) GetClientConsensusStateLTE(ctx sdk.Context, clientID string, maxHeight uint64) (exported.ConsensusState, bool) { - for i := maxHeight; i > 0; i-- { - found := k.HasClientConsensusState(ctx, clientID, i) +func (k Keeper) GetClientConsensusStateLTE(ctx sdk.Context, clientID string, maxHeight exported.Height) (exported.ConsensusState, bool) { + // NOTE: For tendermint Heights this is only implemented for a single epoch + height := maxHeight + var success bool + for height.Valid() { + found := k.HasClientConsensusState(ctx, clientID, height) if found { - return k.GetClientConsensusState(ctx, clientID, i) + return k.GetClientConsensusState(ctx, clientID, height) + } + height, success = height.Decrement() + if !success { + break } } return nil, false @@ -185,8 +192,10 @@ func (k Keeper) GetClientConsensusStateLTE(ctx sdk.Context, clientID string, max // GetSelfConsensusState introspects the (self) past historical info at a given height // and returns the expected consensus state at that height. -func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height uint64) (exported.ConsensusState, bool) { - histInfo, found := k.stakingKeeper.GetHistoricalInfo(ctx, int64(height)) +func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, bool) { + // Only support retrieving HistoricalInfo from the current epoch for now + // TODO: check EpochNumber matches expected + histInfo, found := k.stakingKeeper.GetHistoricalInfo(ctx, int64(height.EpochHeight)) if !found { return nil, false } diff --git a/x/ibc/02-client/keeper/keeper_test.go b/x/ibc/02-client/keeper/keeper_test.go index 423fb3136356..969602fcf9a2 100644 --- a/x/ibc/02-client/keeper/keeper_test.go +++ b/x/ibc/02-client/keeper/keeper_test.go @@ -32,13 +32,13 @@ const ( testClientID2 = "ethbridge" testClientID3 = "ethermint" - testClientHeight = 5 - trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 maxClockDrift time.Duration = time.Second * 10 ) +var testClientHeight = exported.NewHeight(0, 5) + type KeeperTestSuite struct { suite.Suite @@ -73,8 +73,8 @@ func (suite *KeeperTestSuite) SetupTest() { now2 := suite.now.Add(time.Hour) app := simapp.Setup(isCheckTx) - suite.cdc = app.AppCodec() - suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: testClientHeight, ChainID: testClientID, Time: now2}) + suite.cdc = app.Codec() + suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: int64(testClientHeight.EpochHeight), ChainID: testClientID, Time: now2}) suite.keeper = &app.IBCKeeper.ClientKeeper suite.privVal = tmtypes.NewMockPV() @@ -269,7 +269,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { for i, tc := range cases { tc := tc - cs, found := suite.keeper.GetSelfConsensusState(suite.ctx, tc.height) + cs, found := suite.keeper.GetSelfConsensusState(suite.ctx, exported.NewHeight(0, tc.height)) if tc.expPass { suite.Require().True(found, "Case %d should have passed: %s", i, tc.name) suite.Require().NotNil(cs, "Case %d should have passed: %s", i, tc.name) @@ -287,24 +287,31 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() { suite.keeper.SetClientState(suite.ctx, testClientID, clientState) suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) - nextState := ibctmtypes.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("next")), testClientHeight+5, suite.valSetHash) + nextState := ibctmtypes.ConsensusState{ + Height: exported.NewHeight(0, testClientHeight.EpochHeight+5), + Timestamp: suite.now, + Root: commitmenttypes.NewMerkleRoot([]byte("next")), + ValidatorSet: suite.valSet, + } - header := ibctmtypes.CreateTestHeader(testClientID, testClientHeight+5, testClientHeight, suite.header.Header.Time.Add(time.Minute), - suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) + header := ibctmtypes.CreateTestHeader( + testClientID, exported.NewHeight(0, testClientHeight.EpochHeight+5), testClientHeight, suite.header.Time.Add(time.Minute), suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}, + ) // mock update functionality clientState.LatestHeight = header.GetHeight() - suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight+5, nextState) - suite.keeper.SetClientState(suite.ctx, testClientID, clientState) + suite.keeper.SetClientConsensusState(suite.ctx, testClientID, exported.NewHeight(0, testClientHeight.EpochHeight+5), nextState) + suite.keeper.SetClientState(suite.ctx, clientState) latest, ok := suite.keeper.GetLatestClientConsensusState(suite.ctx, testClientID) suite.Require().True(ok) suite.Require().Equal(nextState, latest, "Latest client not returned correctly") // Should return existing consensusState at latestClientHeight - lte, ok := suite.keeper.GetClientConsensusStateLTE(suite.ctx, testClientID, testClientHeight+3) + lte, ok := suite.keeper.GetClientConsensusStateLTE(suite.ctx, testClientID, exported.NewHeight(0, testClientHeight.EpochHeight+3)) suite.Require().True(ok) - suite.Require().Equal(suite.consensusState, lte, "LTE helper function did not return latest client state below height: %d", testClientHeight+3) + suite.Require().Equal(suite.consensusState, lte, "LTE helper function did not return latest client state below height: %d", + exported.NewHeight(0, testClientHeight.EpochHeight+3)) } func (suite KeeperTestSuite) TestGetAllConsensusStates() { diff --git a/x/ibc/02-client/simulation/decoder_test.go b/x/ibc/02-client/simulation/decoder_test.go index f016d0f150c1..bba820672f39 100644 --- a/x/ibc/02-client/simulation/decoder_test.go +++ b/x/ibc/02-client/simulation/decoder_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/simulation" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -19,33 +18,32 @@ func TestDecodeStore(t *testing.T) { app := simapp.Setup(false) clientID := "clientidone" - clientState := &ibctmtypes.ClientState{ - FrozenHeight: 10, + clientState := ibctmtypes.ClientState{ + ID: clientID, + FrozenHeight: exported.NewHeight(0, 10), } - consState := &ibctmtypes.ConsensusState{ - Height: 10, + consState := ibctmtypes.ConsensusState{ + Height: exported.NewHeight(0, 10), Timestamp: time.Now().UTC(), } - kvPairs := kv.Pairs{ - Pairs: []kv.Pair{ - { - Key: host.FullKeyClientPath(clientID, host.KeyClientState()), - Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState), - }, - { - Key: host.FullKeyClientPath(clientID, host.KeyClientType()), - Value: []byte(exported.Tendermint.String()), - }, - { - Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(10)), - Value: app.IBCKeeper.ClientKeeper.MustMarshalConsensusState(consState), - }, - { - Key: []byte{0x99}, - Value: []byte{0x99}, - }, + kvPairs := tmkv.Pairs{ + tmkv.Pair{ + Key: host.FullKeyClientPath(clientID, host.KeyClientState()), + Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState), + }, + tmkv.Pair{ + Key: host.FullKeyClientPath(clientID, host.KeyClientType()), + Value: []byte(exported.Tendermint.String()), + }, + tmkv.Pair{ + Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(exported.NewHeight(0, 10))), + Value: app.IBCKeeper.ClientKeeper.MustMarshalConsensusState(consState), + }, + tmkv.Pair{ + Key: []byte{0x99}, + Value: []byte{0x99}, }, } tests := []struct { diff --git a/x/ibc/02-client/types/client.pb.go b/x/ibc/02-client/types/client.pb.go index a380e095e01b..de5a2cf2df29 100644 --- a/x/ibc/02-client/types/client.pb.go +++ b/x/ibc/02-client/types/client.pb.go @@ -134,15 +134,78 @@ func (m *ClientConsensusStates) GetConsensusStates() []*types.Any { return nil } +// 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 +type Height struct { + // the epoch that the client is currently on + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty" yaml:"epoch_number"` + // the height within the given epoch + EpochHeight uint64 `protobuf:"varint,2,opt,name=epoch_height,json=epochHeight,proto3" json:"epoch_height,omitempty" yaml:"epoch_height"` +} + +func (m *Height) Reset() { *m = Height{} } +func (m *Height) String() string { return proto.CompactTextString(m) } +func (*Height) ProtoMessage() {} +func (*Height) Descriptor() ([]byte, []int) { + return fileDescriptor_226f80e576f20abd, []int{2} +} +func (m *Height) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Height) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Height.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 *Height) XXX_Merge(src proto.Message) { + xxx_messageInfo_Height.Merge(m, src) +} +func (m *Height) XXX_Size() int { + return m.Size() +} +func (m *Height) XXX_DiscardUnknown() { + xxx_messageInfo_Height.DiscardUnknown(m) +} + +var xxx_messageInfo_Height proto.InternalMessageInfo + +func (m *Height) GetEpochNumber() uint64 { + if m != nil { + return m.EpochNumber + } + return 0 +} + +func (m *Height) GetEpochHeight() uint64 { + if m != nil { + return m.EpochHeight + } + return 0 +} + func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.client.IdentifiedClientState") proto.RegisterType((*ClientConsensusStates)(nil), "ibc.client.ClientConsensusStates") + proto.RegisterType((*Height)(nil), "ibc.client.Height") } func init() { proto.RegisterFile("ibc/client/client.proto", fileDescriptor_226f80e576f20abd) } var fileDescriptor_226f80e576f20abd = []byte{ - // 314 bytes of a gzipped FileDescriptorProto + // 372 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x4c, 0x4a, 0xd6, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0x81, 0x52, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x5c, 0x99, 0x49, 0xc9, 0x7a, 0x10, 0x11, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xb0, 0x3e, 0x88, @@ -157,12 +220,16 @@ var fileDescriptor_226f80e576f20abd = []byte{ 0xc8, 0x25, 0x0a, 0x71, 0x94, 0x73, 0x7e, 0x5e, 0x71, 0x6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f, 0x44, 0x16, 0xa6, 0x17, 0x62, 0xaf, 0x93, 0xcf, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0x43, 0x29, 0xdd, 0xe2, 0x94, + 0x6c, 0xfd, 0x0a, 0x7d, 0x50, 0xda, 0x32, 0x30, 0xd2, 0x85, 0x26, 0xaf, 0x92, 0xca, 0x82, 0xd4, + 0xe2, 0x24, 0x36, 0x70, 0x60, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xdc, 0x3e, 0x45, + 0x79, 0x02, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -251,6 +318,39 @@ func (m *ClientConsensusStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Height) 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 *Height) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Height) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochHeight != 0 { + i = encodeVarintClient(dAtA, i, uint64(m.EpochHeight)) + i-- + dAtA[i] = 0x10 + } + if m.EpochNumber != 0 { + i = encodeVarintClient(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintClient(dAtA []byte, offset int, v uint64) int { offset -= sovClient(v) base := offset @@ -298,6 +398,21 @@ func (m *ClientConsensusStates) Size() (n int) { return n } +func (m *Height) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovClient(uint64(m.EpochNumber)) + } + if m.EpochHeight != 0 { + n += 1 + sovClient(uint64(m.EpochHeight)) + } + return n +} + func sovClient(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -544,6 +659,97 @@ func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error { } return nil } +func (m *Height) 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 ErrIntOverflowClient + } + 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: Height: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Height: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) + } + m.EpochNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochHeight", wireType) + } + m.EpochHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipClient(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/02-client/types/genesis_test.go b/x/ibc/02-client/types/genesis_test.go index e7471bc57a97..a40292d55417 100644 --- a/x/ibc/02-client/types/genesis_test.go +++ b/x/ibc/02-client/types/genesis_test.go @@ -32,7 +32,7 @@ func TestValidateGenesis(t *testing.T) { val := tmtypes.NewValidator(pubKey, 10) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) - header := ibctmtypes.CreateTestHeader(chainID, height, height-1, now, valSet, valSet, []tmtypes.PrivValidator{privVal}) + header := ibctmtypes.CreateTestHeader("chainID", exported.NewHeight(0, 10), exported.NewHeight(0, 10), now, valSet, valSet, []tmtypes.PrivValidator{privVal}) testCases := []struct { name string @@ -124,7 +124,7 @@ func TestValidateGenesis(t *testing.T) { "(CLIENTID2)", []exported.ConsensusState{ ibctmtypes.NewConsensusState( - header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), 0, header.Header.NextValidatorsHash, + header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), exported.NewHeight(0, 0), header.Header.NextValidatorsHash, ), }, ), @@ -149,7 +149,7 @@ func TestValidateGenesis(t *testing.T) { clientID, []exported.ConsensusState{ ibctmtypes.NewConsensusState( - header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), 0, header.Header.NextValidatorsHash, + header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), exported.NewHeight(0, 0), header.Header.NextValidatorsHash, ), }, ), diff --git a/x/ibc/02-client/types/height.go b/x/ibc/02-client/types/height.go new file mode 100644 index 000000000000..4c6d229f8b2d --- /dev/null +++ b/x/ibc/02-client/types/height.go @@ -0,0 +1,96 @@ +package types + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" +) + +var _ exported.Height = (*Height)(nil) + +// NewHeight is a constructor for the IBC height type +func NewHeight(epochNumber, epochHeight uint64) *Height { + return &Height{ + EpochNumber: epochNumber, + EpochHeight: epochHeight, + } +} + +/// Compare implements a method to compare two heights. When comparing two heights a, b +// we can call a.Compare(b) which will return +// -1 if a < b +// 0 if a = b +// 1 if a > b +// +// It first compares based on epoch numbers, whichever has the higher epoch number is the higher height +// If epoch number is the same, then the epoch height is compared +func (h *Height) Compare(other exported.Height) int64 { + height, ok := other.(*Height) + if !ok { + panic(fmt.Sprintf("cannot compare against invalid height type: %T. expected height type: %T", other, h)) + } + var cmp int64 + if h.EpochNumber != height.EpochNumber { + cmp = int64(h.EpochNumber) - int64(height.EpochNumber) + } else { + cmp = int64(h.EpochHeight) - int64(height.EpochHeight) + } + if cmp < 0 { + return -1 + } else if cmp > 0 { + return 1 + } + return 0 +} + +// LT Helper comparison function returns true if h < other +func (h *Height) LT(other exported.Height) bool { + return h.Compare(other) == -1 +} + +// GT Helper comparison function returns true if h > other +func (h *Height) GT(other exported.Height) bool { + return h.Compare(other) == 1 +} + +// EQ Helper comparison function returns true if h == other +func (h *Height) EQ(other exported.Height) bool { + return h.Compare(other) == 0 +} + +// Decrement will return a decremented height from the given height. If this is not possible, +// an error is returned +// Decrement will return a new height with the EpochHeight decremented +// If the EpochHeight is already at lowest value (1), then false success flag is returend +func (h *Height) Decrement() (decremented exported.Height, success bool) { + if h.EpochHeight <= 1 { + return &Height{}, false + } + return NewHeight(h.EpochNumber, h.EpochHeight-1), true +} + +// Increment will return an incremented height from the given height. +// Increment will return a height with the same epoch number but an +// incremented epoch height +func (h *Height) Increment() exported.Height { + return NewHeight(h.EpochNumber, h.EpochHeight+1) +} + +// Valid returns true if height is valid, false otherwise +// Returns false if EpochHeight is 0 +func (h *Height) Valid() bool { + if h == nil { + return false + } + return h.EpochHeight != 0 +} + +// String implements the fmt.Stringer interface +// func (h Height) String() string { +// return fmt.Sprintf("epoch-%d_height-%d", h.EpochNumber, h.EpochHeight) +// } + +// IsZero returns true if height epoch and epoch-height are both 0 +func (h *Height) IsZero() bool { + return h.EpochNumber == 0 && h.EpochHeight == 0 +} diff --git a/x/ibc/02-client/types/height_test.go b/x/ibc/02-client/types/height_test.go new file mode 100644 index 000000000000..4ab598223f58 --- /dev/null +++ b/x/ibc/02-client/types/height_test.go @@ -0,0 +1,62 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCompareHeights(t *testing.T) { + testCases := []struct { + name string + height1 Height + height2 Height + compareSign int64 + }{ + {"epoch number 1 is lesser", NewHeight(1, 3), NewHeight(3, 4), -1}, + {"epoch number 1 is greater", NewHeight(7, 5), NewHeight(4, 5), 1}, + {"epoch height 1 is lesser", NewHeight(3, 4), NewHeight(3, 9), -1}, + {"epoch height 1 is greater", NewHeight(3, 8), NewHeight(3, 3), 1}, + {"height is equal", NewHeight(4, 4), NewHeight(4, 4), 0}, + } + + for i, tc := range testCases { + compare := tc.height1.Compare(tc.height2) + + switch tc.compareSign { + case -1: + require.True(t, compare == -1, "case %d: %s should return negative value on comparison, got: %d", + i, tc.name, compare) + case 0: + require.True(t, compare == 0, "case %d: %s should return zero on comparison, got: %d", + i, tc.name, compare) + case 1: + require.True(t, compare == 1, "case %d: %s should return positive value on comparison, got: %d", + i, tc.name, compare) + } + } +} + +func TestDecrement(t *testing.T) { + validDecrement := NewHeight(3, 3) + expected := NewHeight(3, 2) + + actual, success := validDecrement.Decrement() + require.Equal(t, expected, actual, "decrementing %s did not return expected height: %s. got %s", + validDecrement.String(), expected.String(), actual.String()) + require.True(t, success, "decrement failed unexpectedly") + + invalidDecrement := NewHeight(3, 1) + actual, success = invalidDecrement.Decrement() + + require.Equal(t, Height{}, actual, "invalid decrement returned non-zero height: %s", actual.String()) + require.False(t, success, "invalid decrement passed") +} + +func TestValid(t *testing.T) { + valid := NewHeight(0, 2) + require.True(t, valid.Valid(), "valid height did not return true on Valid()") + + invalid := NewHeight(2, 0) + require.False(t, invalid.Valid(), "invalid height returned true on Valid()") +} diff --git a/x/ibc/02-client/types/query.go b/x/ibc/02-client/types/query.go index cce305f9504c..8fe41a42a063 100644 --- a/x/ibc/02-client/types/query.go +++ b/x/ibc/02-client/types/query.go @@ -10,26 +10,28 @@ import ( // NewQueryClientStateResponse creates a new QueryClientStateResponse instance. func NewQueryClientStateResponse( - clientID string, clientStateAny *codectypes.Any, proof []byte, height int64, + clientID string, clientStateAny *codectypes.Any, proof []byte, height *Height, ) *QueryClientStateResponse { path := commitmenttypes.NewMerklePath(append([]string{clientID}, strings.Split(host.ClientStatePath(), "/")...)) return &QueryClientStateResponse{ ClientState: clientStateAny, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryConsensusStateResponse creates a new QueryConsensusStateResponse instance. func NewQueryConsensusStateResponse( - clientID string, consensusStateAny *codectypes.Any, proof []byte, height int64, + clientID string, consensusStateAny *codectypes.Any, proof []byte, height *Height, ) *QueryConsensusStateResponse { - path := commitmenttypes.NewMerklePath(strings.Split(host.FullClientPath(clientID, host.ConsensusStatePath(uint64(height))), "/")) + path := commitmenttypes.NewMerklePath( + strings.Split(host.FullClientPath(clientID, host.ConsensusStatePath(height)), "/"), + ) return &QueryConsensusStateResponse{ ConsensusState: consensusStateAny, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } diff --git a/x/ibc/02-client/types/query.pb.go b/x/ibc/02-client/types/query.pb.go index 9153c4b16e30..7ea892cc75ed 100644 --- a/x/ibc/02-client/types/query.pb.go +++ b/x/ibc/02-client/types/query.pb.go @@ -88,7 +88,7 @@ type QueryClientStateResponse struct { // 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"` + ProofHeight *Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryClientStateResponse) Reset() { *m = QueryClientStateResponse{} } @@ -145,11 +145,11 @@ func (m *QueryClientStateResponse) GetProofPath() string { return "" } -func (m *QueryClientStateResponse) GetProofHeight() uint64 { +func (m *QueryClientStateResponse) GetProofHeight() *Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryClientStatesRequest is the request type for the Query/ClientStates RPC @@ -260,10 +260,12 @@ func (m *QueryClientStatesResponse) GetPagination() *query.PageResponse { type QueryConsensusStateRequest struct { // client identifier ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // consensus state height - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // consensus state epoch-number + EpochNumber uint64 `protobuf:"varint,2,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + // consensus state epoch-height + EpochHeight uint64 `protobuf:"varint,3,opt,name=epoch_height,json=epochHeight,proto3" json:"epoch_height,omitempty"` // latest_height overrrides the height field and queries the latest stored ConsensusState - LatestHeight bool `protobuf:"varint,3,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` + LatestHeight bool `protobuf:"varint,4,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` } func (m *QueryConsensusStateRequest) Reset() { *m = QueryConsensusStateRequest{} } @@ -306,9 +308,16 @@ func (m *QueryConsensusStateRequest) GetClientId() string { return "" } -func (m *QueryConsensusStateRequest) GetHeight() uint64 { +func (m *QueryConsensusStateRequest) GetEpochNumber() uint64 { if m != nil { - return m.Height + return m.EpochNumber + } + return 0 +} + +func (m *QueryConsensusStateRequest) GetEpochHeight() uint64 { + if m != nil { + return m.EpochHeight } return 0 } @@ -329,7 +338,7 @@ type QueryConsensusStateResponse struct { // 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"` + ProofHeight *Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryConsensusStateResponse) Reset() { *m = QueryConsensusStateResponse{} } @@ -386,11 +395,11 @@ func (m *QueryConsensusStateResponse) GetProofPath() string { return "" } -func (m *QueryConsensusStateResponse) GetProofHeight() uint64 { +func (m *QueryConsensusStateResponse) GetProofHeight() *Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryConsensusStatesRequest is the request type for the Query/ConsensusStates RPC method. @@ -517,50 +526,52 @@ func init() { func init() { proto.RegisterFile("ibc/client/query.proto", fileDescriptor_320a7d3a97b17345) } var fileDescriptor_320a7d3a97b17345 = []byte{ - // 688 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xcf, 0x4f, 0xd4, 0x4e, - 0x18, 0xc6, 0x99, 0xe5, 0x47, 0xe0, 0xdd, 0x05, 0xbe, 0x99, 0x10, 0x58, 0x0a, 0xdf, 0xcd, 0xb2, - 0x28, 0xac, 0x26, 0xcc, 0xc0, 0x1a, 0x7f, 0xc5, 0x18, 0x83, 0x26, 0x28, 0x89, 0x07, 0xac, 0x37, - 0x2f, 0xa4, 0xed, 0x0e, 0xbb, 0x8d, 0xd0, 0x29, 0xcc, 0x2c, 0x91, 0x10, 0x2e, 0x1c, 0xbc, 0x6a, - 0xe2, 0xdd, 0x93, 0x07, 0x13, 0x3d, 0xfa, 0x47, 0x78, 0x24, 0xf1, 0xe2, 0xd1, 0x80, 0x27, 0xff, - 0x0a, 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fa, 0xa8, 0xd2, 0x75, 0x70, 0x54, 0xe9, 0xfa, 0x7a, 0x54, 0xe9, 0x7a, - 0xd6, 0x68, 0xf9, 0xb2, 0xdd, 0x71, 0x89, 0xc7, 0x37, 0xa8, 0xf9, 0x9d, 0xd5, 0x8f, 0x39, 0xd1, - 0x7c, 0x4e, 0x5f, 0x28, 0xa5, 0xf9, 0xc6, 0x9c, 0x11, 0x93, 0x3b, 0x21, 0x13, 0x6e, 0x9f, 0xba, - 0x22, 0xd7, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x03, 0xb5, 0x39, 0xdd, 0xbd, 0x07, 0x00, 0x00, + // 720 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0x66, 0xf8, 0x61, 0xe0, 0x75, 0x01, 0x33, 0x21, 0x52, 0x16, 0x6c, 0xa0, 0x28, 0x54, 0x13, + 0x66, 0xa0, 0x06, 0xf5, 0x62, 0x8c, 0x9a, 0xa0, 0x24, 0xc6, 0xe0, 0x7a, 0xd3, 0x18, 0xb2, 0xbb, + 0x1d, 0xda, 0x8d, 0xb0, 0xb3, 0x74, 0xa6, 0x46, 0x42, 0xb8, 0x70, 0xf0, 0x64, 0xa2, 0x89, 0x77, + 0x4f, 0x1e, 0x3c, 0xf8, 0x3f, 0x78, 0x33, 0x1c, 0x49, 0xbc, 0x78, 0x34, 0xe0, 0x1f, 0x62, 0x3a, + 0x33, 0x4b, 0xa7, 0xb0, 0x52, 0x34, 0xc6, 0xd3, 0x76, 0xde, 0x7b, 0xf3, 0xde, 0xf7, 0xbe, 0xef, + 0xbd, 0x29, 0x5c, 0x88, 0x82, 0x90, 0x86, 0xeb, 0x11, 0x8b, 0x25, 0xdd, 0x6c, 0xb0, 0xfa, 0x16, + 0x49, 0xea, 0x5c, 0x72, 0x0c, 0x51, 0x10, 0x12, 0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 0xf7, 0xc3, 0x42, 0xd7, 0xd3, + 0x72, 0x35, 0x92, 0xb5, 0x46, 0x40, 0x42, 0xbe, 0x41, 0xcd, 0x1f, 0xbc, 0xfe, 0xcc, 0x89, 0xca, + 0x0b, 0xfa, 0x4a, 0x55, 0x9a, 0x2f, 0xcf, 0x99, 0x62, 0x72, 0x2b, 0x61, 0x22, 0x38, 0xa7, 0x96, + 0xe8, 0xda, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x54, 0x96, 0x54, 0x36, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -809,10 +820,17 @@ func (m *QueryClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -955,10 +973,15 @@ func (m *QueryConsensusStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, err dAtA[i] = 0 } i-- + dAtA[i] = 0x20 + } + if m.EpochHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochHeight)) + i-- dAtA[i] = 0x18 } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) i-- dAtA[i] = 0x10 } @@ -992,10 +1015,17 @@ func (m *QueryConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -1159,8 +1189,9 @@ func (m *QueryClientStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1207,8 +1238,11 @@ func (m *QueryConsensusStateRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if m.EpochHeight != 0 { + n += 1 + sovQuery(uint64(m.EpochHeight)) } if m.LatestHeight { n += 2 @@ -1234,8 +1268,9 @@ func (m *QueryConsensusStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1499,10 +1534,10 @@ func (m *QueryClientStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1512,11 +1547,28 @@ func (m *QueryClientStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1816,9 +1868,9 @@ func (m *QueryConsensusStateRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) } - m.Height = 0 + m.EpochNumber = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1828,12 +1880,31 @@ func (m *QueryConsensusStateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.EpochNumber |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochHeight", wireType) + } + m.EpochHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LatestHeight", wireType) } @@ -2009,10 +2080,10 @@ func (m *QueryConsensusStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2022,11 +2093,28 @@ func (m *QueryConsensusStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ibc/02-client/types/query.pb.gw.go b/x/ibc/02-client/types/query.pb.gw.go index 9dbd863cd2ec..3fd7e0efa148 100644 --- a/x/ibc/02-client/types/query.pb.gw.go +++ b/x/ibc/02-client/types/query.pb.gw.go @@ -122,7 +122,7 @@ func local_request_Query_ClientStates_0(ctx context.Context, marshaler runtime.M } var ( - filter_Query_ConsensusState_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0, "height": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_Query_ConsensusState_0 = &utilities.DoubleArray{Encoding: map[string]int{"client_id": 0, "epoch_number": 1, "epoch_height": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} ) func request_Query_ConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -147,15 +147,26 @@ func request_Query_ConsensusState_0(ctx context.Context, marshaler runtime.Marsh return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } - val, ok = pathParams["height"] + val, ok = pathParams["epoch_number"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_number") } - protoReq.Height, err = runtime.Uint64(val) + protoReq.EpochNumber, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_number", err) + } + + val, ok = pathParams["epoch_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_height") + } + + protoReq.EpochHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_height", err) } if err := req.ParseForm(); err != nil { @@ -192,15 +203,26 @@ func local_request_Query_ConsensusState_0(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } - val, ok = pathParams["height"] + val, ok = pathParams["epoch_number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_number") + } + + protoReq.EpochNumber, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_number", err) + } + + val, ok = pathParams["epoch_height"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_height") } - protoReq.Height, err = runtime.Uint64(val) + protoReq.EpochHeight, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_height", err) } if err := req.ParseForm(); err != nil { @@ -501,7 +523,7 @@ var ( pattern_Query_ClientStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "client", "v1beta1", "client_states"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "client", "v1beta1", "consensus_states", "client_id", "height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "client", "v1beta1", "consensus_states", "client_id", "epoch", "epoch_number", "height", "epoch_height"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_ConsensusStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ibc", "client", "v1beta1", "consensus_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) ) diff --git a/x/ibc/03-connection/client/cli/tx.go b/x/ibc/03-connection/client/cli/tx.go index 160531446743..f0f7229452a4 100644 --- a/x/ibc/03-connection/client/cli/tx.go +++ b/x/ibc/03-connection/client/cli/tx.go @@ -15,6 +15,10 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) +const ( + flagProofEpoch, flagConsensusEpoch string = "proof-epoch", "consensus-epoch" +) + // NewConnectionOpenInitCmd defines the command to initialize a connection on // chain A with a given counterparty chain B func NewConnectionOpenInitCmd() *cobra.Command { @@ -124,11 +128,20 @@ func NewConnectionOpenTryCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(flagProofEpoch) + if err != nil { + return err + } + consensusEpoch, err := cmd.Flags().GetInt(flagConsensusEpoch) + if err != nil { + return err + } + msg := types.NewMsgConnectionOpenTry( connectionID, clientID, counterpartyConnectionID, counterpartyClientID, counterpartyClient, counterpartyPrefix, []string{counterpartyVersions}, - proofInit, proofClient, proofConsensus, proofHeight, - consensusHeight, clientCtx.GetFromAddress(), + proofInit, proofClient, proofConsensus, uint64(proofEpoch), proofHeight, + uint64(consensusEpoch), consensusHeight, clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { @@ -139,6 +152,8 @@ func NewConnectionOpenTryCmd() *cobra.Command { }, } + cmd.Flags().Int(flagProofEpoch, 0, "epoch for proof height") + cmd.Flags().Int(flagConsensusEpoch, 0, "epoch for consensus height") flags.AddTxFlagsToCmd(cmd) return cmd @@ -191,11 +206,21 @@ func NewConnectionOpenAckCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(flagProofEpoch) + if err != nil { + return err + } + consensusEpoch, err := cmd.Flags().GetInt(flagConsensusEpoch) + if err != nil { + return err + } + version := args[5] msg := types.NewMsgConnectionOpenAck( - connectionID, counterpartyClient, proofTry, proofClient, proofConsensus, proofHeight, - consensusHeight, version, clientCtx.GetFromAddress(), + connectionID, counterpartyClient, proofTry, proofClient, proofConsensus, + uint64(proofEpoch), proofHeight, uint64(consensusEpoch), consensusHeight, + version, clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { @@ -206,6 +231,8 @@ func NewConnectionOpenAckCmd() *cobra.Command { }, } + cmd.Flags().Int(flagProofEpoch, 0, "epoch for proof height") + cmd.Flags().Int(flagConsensusEpoch, 0, "epoch for consensus height") flags.AddTxFlagsToCmd(cmd) return cmd @@ -242,8 +269,13 @@ func NewConnectionOpenConfirmCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(flagProofEpoch) + if err != nil { + return err + } + msg := types.NewMsgConnectionOpenConfirm( - connectionID, proofAck, proofHeight, clientCtx.GetFromAddress(), + connectionID, proofAck, uint64(proofEpoch), proofHeight, clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { @@ -254,6 +286,7 @@ func NewConnectionOpenConfirmCmd() *cobra.Command { }, } + cmd.Flags().Int(flagProofEpoch, 0, "epoch for proof height") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/ibc/03-connection/handler.go b/x/ibc/03-connection/handler.go index 4ce2932f1b92..d7883b51fe3d 100644 --- a/x/ibc/03-connection/handler.go +++ b/x/ibc/03-connection/handler.go @@ -3,6 +3,7 @@ package connection import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" @@ -107,6 +108,8 @@ func HandleMsgConnectionOpenAck(ctx sdk.Context, k keeper.Keeper, msg *types.Msg // HandleMsgConnectionOpenConfirm defines the sdk.Handler for MsgConnectionOpenConfirm func HandleMsgConnectionOpenConfirm(ctx sdk.Context, k keeper.Keeper, msg *types.MsgConnectionOpenConfirm) (*sdk.Result, error) { + // For now, convert uint64 heights to clientexported.Height + proofHeight := clientexported.NewHeight(msg.ProofEpoch, msg.ProofHeight) if err := k.ConnOpenConfirm( ctx, msg.ConnectionId, msg.ProofAck, msg.ProofHeight, ); err != nil { diff --git a/x/ibc/03-connection/keeper/handshake.go b/x/ibc/03-connection/keeper/handshake.go index e48a96719ada..cacfcaab0ba7 100644 --- a/x/ibc/03-connection/keeper/handshake.go +++ b/x/ibc/03-connection/keeper/handshake.go @@ -54,13 +54,16 @@ func (k Keeper) ConnOpenTry( proofInit []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit) proofClient []byte, // proof that chainA stored a light client of chainB proofConsensus []byte, // proof that chainA stored chainB's consensus state at consensus height - proofHeight uint64, // height at which relayer constructs proof of A storing connectionEnd in state - consensusHeight uint64, // latest height of chain B which chain A has stored in its chain B client + proofHeight clientexported.Height, // height at which relayer constructs proof of A storing connectionEnd in state + consensusHeight clientexported.Height, // latest height of chain B which chain A has stored in its chain B client ) error { - if consensusHeight >= uint64(ctx.BlockHeight()) { + // ConsensusHeight must be less than current height + // NOTE: Only epoch=0 supported for now + selfHeight := clientexported.NewHeight(0, uint64(ctx.BlockHeight())) + if !consensusHeight.LT(selfHeight) { return sdkerrors.Wrapf( sdkerrors.ErrInvalidHeight, - "consensus height is greater than or equal to the current block height (%d >= %d)", consensusHeight, uint64(ctx.BlockHeight()), + "consensus height is greater than or equal to the current block height (%v >= %v)", consensusHeight, selfHeight, ) } @@ -146,14 +149,15 @@ func (k Keeper) ConnOpenAck( proofTry []byte, // proof that connectionEnd was added to ChainB state in ConnOpenTry proofClient []byte, // proof of client state on chainB for chainA proofConsensus []byte, // proof that chainB has stored ConsensusState of chainA on its client - proofHeight uint64, // height that relayer constructed proofTry - consensusHeight uint64, // latest height of chainA that chainB has stored on its chainA client + proofHeight clientexported.Height, // height that relayer constructed proofTry + consensusHeight clientexported.Height, // latest height of chainA that chainB has stored on its chainA client ) error { - // Check that chainB client hasn't stored invalid height - if consensusHeight >= uint64(ctx.BlockHeight()) { + // ConsensusHeight must be less than current height + // NOTE: Only epoch=0 supported for now + if !consensusHeight.LT(clientexported.NewHeight(0, uint64(ctx.BlockHeight()))) { return sdkerrors.Wrapf( sdkerrors.ErrInvalidHeight, - "consensus height is greater than or equal to the current block height (%d >= %d)", consensusHeight, uint64(ctx.BlockHeight()), + "consensus height is greater than or equal to the current block height (%v >= %v)", consensusHeight, ctx.BlockHeight(), ) } @@ -242,7 +246,7 @@ func (k Keeper) ConnOpenConfirm( ctx sdk.Context, connectionID string, proofAck []byte, // proof that connection opened on ChainA during ConnOpenAck - proofHeight uint64, // height that relayer constructed proofAck + proofHeight clientexported.Height, // height that relayer constructed proofAck ) error { // Retrieve connection connection, found := k.GetConnection(ctx, connectionID) diff --git a/x/ibc/03-connection/keeper/handshake_test.go b/x/ibc/03-connection/keeper/handshake_test.go index bbb2e128951d..9966f994a3ea 100644 --- a/x/ibc/03-connection/keeper/handshake_test.go +++ b/x/ibc/03-connection/keeper/handshake_test.go @@ -63,7 +63,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { clientA string clientB string versions []string - consensusHeight uint64 + consensusHeight clientexported.Height counterpartyClient clientexported.ClientState ) @@ -100,20 +100,18 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) + consensusHeight = clientexported.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) - - consensusHeight = uint64(suite.chainB.GetContext().BlockHeight()) }, false}, {"self consensus state not found", func() { clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, clientexported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) + consensusHeight = clientexported.NewHeight(0, 1) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) - - consensusHeight = 1 }, false}, {"counterparty versions is empty", func() { clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, clientexported.Tendermint) @@ -196,9 +194,9 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { tc := tc suite.Run(tc.msg, func() { - suite.SetupTest() // reset - consensusHeight = 0 // must be explicitly changed in malleate - versions = types.GetCompatibleEncodedVersions() // must be explicitly changed in malleate + suite.SetupTest() // reset + consensusHeight = clientexported.NewHeight(0, 0) // must be explicitly changed in malleate + versions = types.GetCompatibleEncodedVersions() // must be explicitly changed in malleate tc.malleate() @@ -213,7 +211,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { consState, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(suite.chainA.GetContext(), clientA) suite.Require().True(found) - if consensusHeight == 0 { + if !consensusHeight.Valid() { consensusHeight = consState.GetHeight() } consensusKey := host.FullKeyClientPath(clientA, host.KeyConsensusState(consensusHeight)) @@ -244,7 +242,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { var ( clientA string clientB string - consensusHeight uint64 + consensusHeight clientexported.Height version string counterpartyClient clientexported.ClientState ) @@ -315,7 +313,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA) suite.Require().NoError(err) - consensusHeight = uint64(suite.chainA.GetContext().BlockHeight()) + consensusHeight = clientexported.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight())) }, false}, {"connection not found", func() { // connections are never created @@ -391,7 +389,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA) suite.Require().NoError(err) - consensusHeight = 1 + consensusHeight = clientexported.NewHeight(0, 1) }, false}, {"connection state verification failed", func() { // chainB connection is not in INIT @@ -445,8 +443,8 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset + consensusHeight = clientexported.NewHeight(0, 0) // must be explicitly changed in malleate version = types.GetCompatibleEncodedVersions()[0] // must be explicitly changed in malleate - consensusHeight = 0 // must be explicitly changed in malleate tc.malleate() @@ -460,7 +458,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { consState, found := suite.chainB.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(suite.chainB.GetContext(), clientB) suite.Require().True(found) - if consensusHeight == 0 { + if !consensusHeight.Valid() { consensusHeight = consState.GetHeight() } consensusKey := host.FullKeyClientPath(clientB, host.KeyConsensusState(consensusHeight)) diff --git a/x/ibc/03-connection/keeper/keeper.go b/x/ibc/03-connection/keeper/keeper.go index 060790146c4b..e88fd9c0c934 100644 --- a/x/ibc/03-connection/keeper/keeper.go +++ b/x/ibc/03-connection/keeper/keeper.go @@ -69,7 +69,7 @@ func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection t // GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the // given height. -func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.ConnectionEnd, height uint64) (uint64, error) { +func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.ConnectionEnd, height clientexported.Height) (uint64, error) { consensusState, found := k.clientKeeper.GetClientConsensusState( ctx, connection.GetClientID(), height, ) @@ -77,7 +77,7 @@ func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.Connectio if !found { return 0, sdkerrors.Wrapf( clienttypes.ErrConsensusStateNotFound, - "clientID (%s), height (%d)", connection.GetClientID(), height, + "clientID (%s), height (%v)", connection.GetClientID(), height, ) } diff --git a/x/ibc/03-connection/keeper/keeper_test.go b/x/ibc/03-connection/keeper/keeper_test.go index 1ef84101e1fa..6dc634273165 100644 --- a/x/ibc/03-connection/keeper/keeper_test.go +++ b/x/ibc/03-connection/keeper/keeper_test.go @@ -118,7 +118,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { tc.malleate() actualTimestamp, err := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetTimestampAtHeight( - suite.chainA.GetContext(), connection, uint64(suite.chainB.LastHeader.GetHeight()), + suite.chainA.GetContext(), connection, suite.chainB.LastHeader.GetHeight(), ) if tc.expPass { diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index a4f4a222662e..c023a6d16336 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -43,8 +43,8 @@ func (k Keeper) VerifyClientState( func (k Keeper) VerifyClientConsensusState( ctx sdk.Context, connection exported.ConnectionI, - height uint64, - consensusHeight uint64, + height clientexported.Height, + consensusHeight clientexported.Height, proof []byte, consensusState clientexported.ConsensusState, ) error { @@ -74,7 +74,7 @@ func (k Keeper) VerifyClientConsensusState( func (k Keeper) VerifyConnectionState( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, connectionID string, connectionEnd exported.ConnectionI, // opposite connection @@ -99,7 +99,7 @@ func (k Keeper) VerifyConnectionState( func (k Keeper) VerifyChannelState( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -126,7 +126,7 @@ func (k Keeper) VerifyChannelState( func (k Keeper) VerifyPacketCommitment( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -154,7 +154,7 @@ func (k Keeper) VerifyPacketCommitment( func (k Keeper) VerifyPacketAcknowledgement( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -183,7 +183,7 @@ func (k Keeper) VerifyPacketAcknowledgement( func (k Keeper) VerifyPacketAcknowledgementAbsence( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -210,7 +210,7 @@ func (k Keeper) VerifyPacketAcknowledgementAbsence( func (k Keeper) VerifyNextSequenceRecv( ctx sdk.Context, connection exported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index 304bf774829e..0a90eaaa0b19 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -125,13 +125,16 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() { } proof, consensusHeight := suite.chainB.QueryConsensusStateProof(connB.ClientID) - proofHeight := uint64(suite.chainB.GetContext().BlockHeight() - 1) + proofHeight := clientexported.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight()-1)) consensusState, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetSelfConsensusState(suite.chainA.GetContext(), consensusHeight) suite.Require().True(found) + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff) err := suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyClientConsensusState( suite.chainA.GetContext(), connection, - proofHeight+heightDiff, consensusHeight, proof, consensusState, + proofHeight, consensusHeight, + proof, consensusState, ) if tc.expPass { @@ -180,9 +183,11 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { expectedConnection.State = types.TRYOPEN } + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err := suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyConnectionState( suite.chainA.GetContext(), connection, - proofHeight+tc.heightDiff, proof, connB.ID, expectedConnection, + proofHeight, proof, connB.ID, expectedConnection, ) if tc.expPass { @@ -230,8 +235,10 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { channel.State = channeltypes.TRYOPEN } + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err := suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyChannelState( - suite.chainA.GetContext(), connection, proofHeight+tc.heightDiff, proof, + suite.chainA.GetContext(), connection, proofHeight, proof, channelB.PortID, channelB.ID, channel, ) @@ -273,7 +280,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { connection.ClientId = ibctesting.InvalidID } - packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 100000, 0) + packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 0, 100000, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -284,8 +291,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { packet.Data = []byte(ibctesting.InvalidID) } + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err = suite.chainB.App.IBCKeeper.ConnectionKeeper.VerifyPacketCommitment( - suite.chainB.GetContext(), connection, proofHeight+tc.heightDiff, proof, + suite.chainB.GetContext(), connection, proofHeight, proof, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), channeltypes.CommitPacket(packet), ) @@ -328,7 +337,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { } // send and receive packet - packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 100000, 0) + packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 0, 100000, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -343,8 +352,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { ack = []byte(ibctesting.InvalidID) } + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketAcknowledgement( - suite.chainA.GetContext(), connection, proofHeight+tc.heightDiff, proof, + suite.chainA.GetContext(), connection, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ack, ) @@ -387,7 +398,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { } // send, only receive if specified - packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 100000, 0) + packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 0, 100000, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -403,8 +414,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetAckKey) + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketAcknowledgementAbsence( - suite.chainA.GetContext(), connection, proofHeight+tc.heightDiff, proof, + suite.chainA.GetContext(), connection, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ) @@ -447,7 +460,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { } // send and receive packet - packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 100000, 0) + packet := channeltypes.NewPacket(ibctesting.TestHash, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, 0, 100000, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -457,8 +470,10 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) proof, proofHeight := suite.chainB.QueryProof(nextSeqRecvKey) + // increment EpochHeight with testcase height diff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+tc.heightDiff) err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyNextSequenceRecv( - suite.chainA.GetContext(), connection, proofHeight+tc.heightDiff, proof, + suite.chainA.GetContext(), connection, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()+tc.offsetSeq, ) diff --git a/x/ibc/03-connection/types/connection.pb.go b/x/ibc/03-connection/types/connection.pb.go index 023066b0cd87..8378304c8145 100644 --- a/x/ibc/03-connection/types/connection.pb.go +++ b/x/ibc/03-connection/types/connection.pb.go @@ -7,7 +7,8 @@ import ( fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + types2 "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -137,12 +138,12 @@ func (m *MsgConnectionOpenInit) GetSigner() github_com_cosmos_cosmos_sdk_types.A // MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a // connection on Chain B. type MsgConnectionOpenTry struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - ConnectionId string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` - ClientState *types.Any `protobuf:"bytes,3,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` - Counterparty Counterparty `protobuf:"bytes,4,opt,name=counterparty,proto3" json:"counterparty"` - CounterpartyVersions []string `protobuf:"bytes,5,rep,name=counterparty_versions,json=counterpartyVersions,proto3" json:"counterparty_versions,omitempty" yaml:"counterparty_versions"` - ProofHeight uint64 `protobuf:"varint,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + ConnectionId string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` + ClientState *types.Any `protobuf:"bytes,3,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + Counterparty Counterparty `protobuf:"bytes,4,opt,name=counterparty,proto3" json:"counterparty"` + CounterpartyVersions []string `protobuf:"bytes,5,rep,name=counterparty_versions,json=counterpartyVersions,proto3" json:"counterparty_versions,omitempty" yaml:"counterparty_versions"` + ProofHeight *types1.Height `protobuf:"bytes,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` // proof of the initialization the connection on Chain A: `UNITIALIZED -> // INIT` ProofInit []byte `protobuf:"bytes,7,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` @@ -150,7 +151,7 @@ type MsgConnectionOpenTry struct { ProofClient []byte `protobuf:"bytes,8,opt,name=proof_client,json=proofClient,proto3" json:"proof_client,omitempty" yaml:"proof_client"` // proof of client consensus state ProofConsensus []byte `protobuf:"bytes,9,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus,omitempty" yaml:"proof_consensus"` - ConsensusHeight uint64 `protobuf:"varint,10,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` + ConsensusHeight *types1.Height `protobuf:"bytes,10,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,11,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -222,11 +223,11 @@ func (m *MsgConnectionOpenTry) GetCounterpartyVersions() []string { return nil } -func (m *MsgConnectionOpenTry) GetProofHeight() uint64 { +func (m *MsgConnectionOpenTry) GetProofHeight() *types1.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgConnectionOpenTry) GetProofInit() []byte { @@ -250,11 +251,11 @@ func (m *MsgConnectionOpenTry) GetProofConsensus() []byte { return nil } -func (m *MsgConnectionOpenTry) GetConsensusHeight() uint64 { +func (m *MsgConnectionOpenTry) GetConsensusHeight() *types1.Height { if m != nil { return m.ConsensusHeight } - return 0 + return nil } func (m *MsgConnectionOpenTry) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -267,10 +268,10 @@ func (m *MsgConnectionOpenTry) GetSigner() github_com_cosmos_cosmos_sdk_types.Ac // MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to // acknowledge the change of connection state to TRYOPEN on Chain B. type MsgConnectionOpenAck struct { - ConnectionId string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - ClientState *types.Any `protobuf:"bytes,3,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ConnectionId string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + ClientState *types.Any `protobuf:"bytes,3,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + ProofHeight *types1.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` // proof of the initialization the connection on Chain B: `UNITIALIZED -> // TRYOPEN` ProofTry []byte `protobuf:"bytes,5,opt,name=proof_try,json=proofTry,proto3" json:"proof_try,omitempty" yaml:"proof_try"` @@ -278,7 +279,7 @@ type MsgConnectionOpenAck struct { ProofClient []byte `protobuf:"bytes,6,opt,name=proof_client,json=proofClient,proto3" json:"proof_client,omitempty" yaml:"proof_client"` // proof of client consensus state ProofConsensus []byte `protobuf:"bytes,7,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus,omitempty" yaml:"proof_consensus"` - ConsensusHeight uint64 `protobuf:"varint,8,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` + ConsensusHeight *types1.Height `protobuf:"bytes,8,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,9,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -336,11 +337,11 @@ func (m *MsgConnectionOpenAck) GetClientState() *types.Any { return nil } -func (m *MsgConnectionOpenAck) GetProofHeight() uint64 { +func (m *MsgConnectionOpenAck) GetProofHeight() *types1.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgConnectionOpenAck) GetProofTry() []byte { @@ -364,11 +365,11 @@ func (m *MsgConnectionOpenAck) GetProofConsensus() []byte { return nil } -func (m *MsgConnectionOpenAck) GetConsensusHeight() uint64 { +func (m *MsgConnectionOpenAck) GetConsensusHeight() *types1.Height { if m != nil { return m.ConsensusHeight } - return 0 + return nil } func (m *MsgConnectionOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -384,8 +385,8 @@ type MsgConnectionOpenConfirm struct { ConnectionId string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` // proof for the change of the connection state on Chain A: `INIT -> OPEN` ProofAck []byte `protobuf:"bytes,2,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack,omitempty" yaml:"proof_ack"` - ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` - Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` + ProofHeight *types1.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } func (m *MsgConnectionOpenConfirm) Reset() { *m = MsgConnectionOpenConfirm{} } @@ -435,11 +436,11 @@ func (m *MsgConnectionOpenConfirm) GetProofAck() []byte { return nil } -func (m *MsgConnectionOpenConfirm) GetProofHeight() uint64 { +func (m *MsgConnectionOpenConfirm) GetProofHeight() *types1.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgConnectionOpenConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -555,7 +556,7 @@ type Counterparty struct { // given connection. ConnectionId string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` // commitment merkle prefix of the counterparty chain - Prefix types1.MerklePrefix `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix"` + Prefix types2.MerklePrefix `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix"` } func (m *Counterparty) Reset() { *m = Counterparty{} } @@ -751,69 +752,70 @@ func init() { func init() { proto.RegisterFile("ibc/connection/connection.proto", fileDescriptor_3bf62bacf5a27ee9) } var fileDescriptor_3bf62bacf5a27ee9 = []byte{ - // 989 bytes of a gzipped FileDescriptorProto + // 1002 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x4f, 0x6f, 0xe2, 0x46, - 0x14, 0xc7, 0xc4, 0xfc, 0x7b, 0x40, 0xc2, 0xba, 0xa4, 0xeb, 0xd2, 0x2d, 0x46, 0xee, 0x05, 0xb5, - 0x0a, 0x34, 0xbb, 0xd5, 0x1e, 0x22, 0xf5, 0x00, 0x2c, 0x51, 0xad, 0x76, 0xb3, 0xc8, 0x21, 0x95, - 0x9a, 0x0b, 0x02, 0x33, 0x90, 0x11, 0x61, 0x8c, 0xec, 0xa1, 0x5a, 0xbe, 0xc1, 0x2a, 0xa7, 0x4a, - 0x3d, 0x55, 0x6a, 0xa4, 0x4a, 0xfd, 0x26, 0x55,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0x69, 0x06, 0xbf, 0x66, 0x48, 0xfa, 0x12, 0x80, 0x7b, 0x31, 0xc1, 0x54, 0x4e, 0x30, - 0x19, 0xec, 0xce, 0x1d, 0xe5, 0x41, 0x38, 0xd3, 0xf5, 0xa9, 0x7a, 0x8a, 0x01, 0x26, 0xf9, 0x60, - 0x45, 0xce, 0x92, 0x9c, 0x64, 0x79, 0x6b, 0x2b, 0x72, 0xaf, 0xbf, 0x62, 0x83, 0x21, 0xa9, 0x01, - 0x3b, 0x9e, 0xd7, 0x24, 0x36, 0x22, 0xf6, 0xd4, 0x96, 0x53, 0x2c, 0xbd, 0x30, 0x77, 0x94, 0x0f, - 0x97, 0xd2, 0xfd, 0x00, 0x55, 0xdf, 0xe6, 0x33, 0xf8, 0x03, 0xd2, 0x21, 0xe4, 0x02, 0xaf, 0x5f, - 0x36, 0xb0, 0xb2, 0x3f, 0x9e, 0x3b, 0xca, 0xc3, 0x40, 0x25, 0x4b, 0x11, 0xaa, 0xbe, 0x13, 0x0c, - 0x79, 0xe5, 0x2f, 0x3a, 0x20, 0xbd, 0x69, 0x07, 0xfc, 0x21, 0xde, 0xd0, 0x01, 0x35, 0x63, 0xb4, - 0x2e, 0x67, 0xe1, 0x56, 0x72, 0x96, 0x21, 0xe1, 0x09, 0x80, 0xf7, 0x81, 0xee, 0xc3, 0x77, 0x20, - 0xf4, 0x55, 0x25, 0x89, 0xb7, 0x50, 0xd2, 0x3e, 0x70, 0x81, 0x74, 0xa8, 0x35, 0x93, 0x63, 0x8c, - 0xcd, 0x50, 0xa3, 0x07, 0x2e, 0x55, 0x4f, 0x32, 0xdb, 0x3d, 0x1b, 0x56, 0x65, 0x14, 0xdf, 0x4c, - 0x46, 0x89, 0x7b, 0x91, 0x51, 0x72, 0x23, 0x19, 0xa5, 0x36, 0x95, 0xd1, 0x4f, 0x51, 0x90, 0xd7, - 0x64, 0xd4, 0x30, 0xc9, 0x00, 0x5b, 0xe3, 0x4d, 0xa5, 0x14, 0x6c, 0x51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0x59, 0x4d, 0x33, 0x35, 0x8c, 0x24, + 0xc6, 0x2d, 0x1a, 0xe9, 0xc9, 0xe5, 0xc4, 0xab, 0x5f, 0x2b, 0xb1, 0x46, 0xe7, 0xf5, 0x55, 0x85, + 0x7b, 0x73, 0x55, 0xe1, 0xfe, 0xba, 0xaa, 0x70, 0x3f, 0x5e, 0x57, 0x62, 0x6f, 0xae, 0x2b, 0xb1, + 0x3f, 0xae, 0x2b, 0xb1, 0xd3, 0x27, 0xff, 0xdb, 0x5d, 0x5e, 0xd6, 0xbc, 0x1f, 0x89, 0x2f, 0x1e, + 0x1f, 0x44, 0x7e, 0x63, 0x48, 0xc7, 0x19, 0xa4, 0xc8, 0x3d, 0xfb, 0xf8, 0xbf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x55, 0x7b, 0x8f, 0x26, 0xe5, 0x0c, 0x00, 0x00, } func (m *MsgConnectionOpenInit) Marshal() (dAtA []byte, err error) { @@ -897,10 +899,17 @@ func (m *MsgConnectionOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x5a } - if m.ConsensusHeight != 0 { - i = encodeVarintConnection(dAtA, i, uint64(m.ConsensusHeight)) + if m.ConsensusHeight != nil { + { + size, err := m.ConsensusHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConnection(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x50 + dAtA[i] = 0x52 } if len(m.ProofConsensus) > 0 { i -= len(m.ProofConsensus) @@ -923,10 +932,17 @@ func (m *MsgConnectionOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - if m.ProofHeight != 0 { - i = encodeVarintConnection(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConnection(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x30 + dAtA[i] = 0x32 } if len(m.CounterpartyVersions) > 0 { for iNdEx := len(m.CounterpartyVersions) - 1; iNdEx >= 0; iNdEx-- { @@ -1003,10 +1019,17 @@ func (m *MsgConnectionOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x4a } - if m.ConsensusHeight != 0 { - i = encodeVarintConnection(dAtA, i, uint64(m.ConsensusHeight)) + if m.ConsensusHeight != nil { + { + size, err := m.ConsensusHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConnection(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x40 + dAtA[i] = 0x42 } if len(m.ProofConsensus) > 0 { i -= len(m.ProofConsensus) @@ -1029,10 +1052,17 @@ func (m *MsgConnectionOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.ProofHeight != 0 { - i = encodeVarintConnection(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConnection(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if m.ClientState != nil { { @@ -1088,12 +1118,19 @@ func (m *MsgConnectionOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error copy(dAtA[i:], m.Signer) i = encodeVarintConnection(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } - if m.ProofHeight != 0 { - i = encodeVarintConnection(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConnection(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x22 } if len(m.ProofAck) > 0 { i -= len(m.ProofAck) @@ -1444,8 +1481,9 @@ func (m *MsgConnectionOpenTry) Size() (n int) { n += 1 + l + sovConnection(uint64(l)) } } - if m.ProofHeight != 0 { - n += 1 + sovConnection(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovConnection(uint64(l)) } l = len(m.ProofInit) if l > 0 { @@ -1459,8 +1497,9 @@ func (m *MsgConnectionOpenTry) Size() (n int) { if l > 0 { n += 1 + l + sovConnection(uint64(l)) } - if m.ConsensusHeight != 0 { - n += 1 + sovConnection(uint64(m.ConsensusHeight)) + if m.ConsensusHeight != nil { + l = m.ConsensusHeight.Size() + n += 1 + l + sovConnection(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -1487,8 +1526,9 @@ func (m *MsgConnectionOpenAck) Size() (n int) { l = m.ClientState.Size() n += 1 + l + sovConnection(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovConnection(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovConnection(uint64(l)) } l = len(m.ProofTry) if l > 0 { @@ -1502,8 +1542,9 @@ func (m *MsgConnectionOpenAck) Size() (n int) { if l > 0 { n += 1 + l + sovConnection(uint64(l)) } - if m.ConsensusHeight != 0 { - n += 1 + sovConnection(uint64(m.ConsensusHeight)) + if m.ConsensusHeight != nil { + l = m.ConsensusHeight.Size() + n += 1 + l + sovConnection(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -1526,8 +1567,9 @@ func (m *MsgConnectionOpenConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovConnection(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovConnection(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovConnection(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2045,10 +2087,10 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { m.CounterpartyVersions = append(m.CounterpartyVersions, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 6: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConnection @@ -2058,11 +2100,28 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthConnection + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ProofHeight == nil { + m.ProofHeight = &types1.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) @@ -2166,10 +2225,10 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 10: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHeight", wireType) } - m.ConsensusHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConnection @@ -2179,11 +2238,28 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ConsensusHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthConnection + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsensusHeight == nil { + m.ConsensusHeight = &types1.Height{} + } + if err := m.ConsensusHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -2372,10 +2448,10 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConnection @@ -2385,11 +2461,28 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthConnection + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ProofHeight == nil { + m.ProofHeight = &types1.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) @@ -2493,10 +2586,10 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 8: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHeight", wireType) } - m.ConsensusHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConnection @@ -2506,11 +2599,28 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ConsensusHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthConnection + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsensusHeight == nil { + m.ConsensusHeight = &types1.Height{} + } + if err := m.ConsensusHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -2664,11 +2774,11 @@ func (m *MsgConnectionOpenConfirm) Unmarshal(dAtA []byte) error { m.ProofAck = []byte{} } iNdEx = postIndex - case 3: - if wireType != 0 { + case 4: + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConnection @@ -2678,12 +2788,29 @@ func (m *MsgConnectionOpenConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 4: + if msglen < 0 { + return ErrInvalidLengthConnection + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConnection + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ProofHeight == nil { + m.ProofHeight = &types1.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } diff --git a/x/ibc/03-connection/types/msgs.go b/x/ibc/03-connection/types/msgs.go index e4b8d0b6a54b..cf1e5e63c5af 100644 --- a/x/ibc/03-connection/types/msgs.go +++ b/x/ibc/03-connection/types/msgs.go @@ -68,7 +68,7 @@ func NewMsgConnectionOpenTry( counterpartyClientID string, counterpartyClient clientexported.ClientState, counterpartyPrefix commitmenttypes.MerklePrefix, counterpartyVersions []string, proofInit, proofClient, proofConsensus []byte, - proofHeight, consensusHeight uint64, signer sdk.AccAddress, + proofHeight, consensusHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgConnectionOpenTry { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) csAny, _ := clienttypes.PackClientState(counterpartyClient) @@ -132,11 +132,11 @@ func (msg MsgConnectionOpenTry) ValidateBasic() error { if len(msg.ProofConsensus) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of consensus state") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } - if msg.ConsensusHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "consensus height must be > 0") + if msg.ConsensusHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "consensus height invalid: %v", msg.ConsensusHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress @@ -160,7 +160,7 @@ var _ sdk.Msg = &MsgConnectionOpenAck{} func NewMsgConnectionOpenAck( connectionID string, counterpartyClient clientexported.ClientState, proofTry, proofClient, proofConsensus []byte, - proofHeight, consensusHeight uint64, version string, + proofHeight, consensusHeight *clienttypes.Height, version string, signer sdk.AccAddress, ) *MsgConnectionOpenAck { csAny, _ := clienttypes.PackClientState(counterpartyClient) @@ -214,11 +214,11 @@ func (msg MsgConnectionOpenAck) ValidateBasic() error { if len(msg.ProofConsensus) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of consensus state") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } - if msg.ConsensusHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "consensus height must be > 0") + if msg.ConsensusHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "consensus height invalid: %v", msg.ConsensusHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress @@ -240,7 +240,7 @@ var _ sdk.Msg = &MsgConnectionOpenConfirm{} // NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance func NewMsgConnectionOpenConfirm( - connectionID string, proofAck []byte, proofHeight uint64, + connectionID string, proofAck []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgConnectionOpenConfirm { return &MsgConnectionOpenConfirm{ @@ -269,8 +269,8 @@ func (msg MsgConnectionOpenConfirm) ValidateBasic() error { if len(msg.ProofAck) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof ack") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress diff --git a/x/ibc/03-connection/types/msgs_test.go b/x/ibc/03-connection/types/msgs_test.go index 42d36e7bdc52..57619528a7b9 100644 --- a/x/ibc/03-connection/types/msgs_test.go +++ b/x/ibc/03-connection/types/msgs_test.go @@ -240,11 +240,11 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") testMsgs := []*types.MsgConnectionOpenConfirm{ - types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer), - types.NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer), - types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer), - types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil), - types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer), + types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 3, 10, signer), + types.NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 3, 10, signer), + types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 3, 0, signer), + types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 3, 10, nil), + types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 3, 10, signer), } var testCases = []struct { diff --git a/x/ibc/03-connection/types/query.go b/x/ibc/03-connection/types/query.go index 27e7e122a571..d9cdefb3d8ff 100644 --- a/x/ibc/03-connection/types/query.go +++ b/x/ibc/03-connection/types/query.go @@ -11,27 +11,27 @@ import ( // NewQueryConnectionResponse creates a new QueryConnectionResponse instance func NewQueryConnectionResponse( - connectionID string, connection ConnectionEnd, proof []byte, height int64, + connectionID string, connection ConnectionEnd, proof []byte, height *clienttypes.Height, ) *QueryConnectionResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.ConnectionPath(connectionID), "/")) return &QueryConnectionResponse{ Connection: &connection, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryClientConnectionsResponse creates a new ConnectionPaths instance func NewQueryClientConnectionsResponse( - clientID string, connectionPaths []string, proof []byte, height int64, + clientID string, connectionPaths []string, proof []byte, height *clienttypes.Height, ) *QueryClientConnectionsResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.ClientConnectionsPath(clientID), "/")) return &QueryClientConnectionsResponse{ ConnectionPaths: connectionPaths, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } @@ -43,24 +43,24 @@ func NewQueryClientConnectionsRequest(clientID string) *QueryClientConnectionsRe } // NewQueryConnectionClientStateResponse creates a newQueryConnectionClientStateResponse instance -func NewQueryConnectionClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height int64) *QueryConnectionClientStateResponse { +func NewQueryConnectionClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height *clienttypes.Height) *QueryConnectionClientStateResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.FullClientPath(identifiedClientState.ClientId, host.ClientStatePath()), "/")) return &QueryConnectionClientStateResponse{ IdentifiedClientState: &identifiedClientState, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryConnectionConsensusStateResponse creates a newQueryConnectionConsensusStateResponse instance -func NewQueryConnectionConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, consensusStateHeight uint64, proof []byte, height int64) *QueryConnectionConsensusStateResponse { +func NewQueryConnectionConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, consensusStateHeight *clienttypes.Height, proof []byte, height *clienttypes.Height) *QueryConnectionConsensusStateResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.FullClientPath(clientID, host.ConsensusStatePath(consensusStateHeight)), "/")) return &QueryConnectionConsensusStateResponse{ ConsensusState: anyConsensusState, ClientId: clientID, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } diff --git a/x/ibc/03-connection/types/query.pb.go b/x/ibc/03-connection/types/query.pb.go index bd475d50dbf1..3b5b89973274 100644 --- a/x/ibc/03-connection/types/query.pb.go +++ b/x/ibc/03-connection/types/query.pb.go @@ -90,7 +90,7 @@ type QueryConnectionResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryConnectionResponse) Reset() { *m = QueryConnectionResponse{} } @@ -147,11 +147,11 @@ func (m *QueryConnectionResponse) GetProofPath() string { return "" } -func (m *QueryConnectionResponse) GetProofHeight() uint64 { +func (m *QueryConnectionResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryConnectionsRequest is the request type for the Query/Connections RPC @@ -322,7 +322,7 @@ type QueryClientConnectionsResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryClientConnectionsResponse) Reset() { *m = QueryClientConnectionsResponse{} } @@ -379,11 +379,11 @@ func (m *QueryClientConnectionsResponse) GetProofPath() string { return "" } -func (m *QueryClientConnectionsResponse) GetProofHeight() uint64 { +func (m *QueryClientConnectionsResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryConnectionClientStateRequest is the request type for the @@ -443,7 +443,7 @@ type QueryConnectionClientStateResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryConnectionClientStateResponse) Reset() { *m = QueryConnectionClientStateResponse{} } @@ -500,11 +500,11 @@ func (m *QueryConnectionClientStateResponse) GetProofPath() string { return "" } -func (m *QueryConnectionClientStateResponse) GetProofHeight() uint64 { +func (m *QueryConnectionClientStateResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryConnectionConsensusStateRequest is the request type for the @@ -574,7 +574,7 @@ type QueryConnectionConsensusStateResponse struct { // merkle proof path ProofPath string `protobuf:"bytes,4,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` // height at which the proof was retrieved - ProofHeight uint64 `protobuf:"varint,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` + ProofHeight *types.Height `protobuf:"bytes,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryConnectionConsensusStateResponse) Reset() { *m = QueryConnectionConsensusStateResponse{} } @@ -638,11 +638,11 @@ func (m *QueryConnectionConsensusStateResponse) GetProofPath() string { return "" } -func (m *QueryConnectionConsensusStateResponse) GetProofHeight() uint64 { +func (m *QueryConnectionConsensusStateResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func init() { @@ -661,60 +661,60 @@ func init() { func init() { proto.RegisterFile("ibc/connection/query.proto", fileDescriptor_5ee60d8b08ce3606) } var fileDescriptor_5ee60d8b08ce3606 = []byte{ - // 840 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x4e, 0xd4, 0x5e, - 0x14, 0xe6, 0xce, 0x00, 0xbf, 0xdf, 0x9c, 0x41, 0xd4, 0x9b, 0x01, 0x6a, 0x95, 0x61, 0x28, 0xff, - 0x46, 0x0d, 0xad, 0x0c, 0x42, 0x8c, 0x8a, 0x51, 0x08, 0x08, 0x71, 0x83, 0x75, 0xa5, 0x1b, 0xd2, - 0xce, 0x94, 0x4e, 0x23, 0xf4, 0x0e, 0xdc, 0x8e, 0x71, 0x62, 0xd8, 0xb8, 0x35, 0x26, 0x26, 0xee, - 0xdc, 0xfa, 0x02, 0xc6, 0x57, 0x70, 0xc3, 0x92, 0x44, 0x13, 0x4d, 0x4c, 0x8c, 0x01, 0x9f, 0xc0, - 0x27, 0x30, 0xbd, 0xf7, 0x0e, 0x6d, 0xe7, 0x8f, 0x05, 0x22, 0xab, 0x69, 0xef, 0x39, 0xa7, 0xe7, - 0x3b, 0xdf, 0xf9, 0xfa, 0x75, 0x40, 0x76, 0xcc, 0xa2, 0x56, 0x24, 0xae, 0x6b, 0x15, 0x3d, 0x87, - 0xb8, 0xda, 0x56, 0xd5, 0xda, 0xae,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43, 0x99, 0x9a, 0xb1, 0xb9, 0x71, 0x53, 0x89, 0x84, 0x95, 0x86, 0x77, - 0xe4, 0x2b, 0x02, 0xe5, 0x6f, 0x4d, 0x04, 0x1b, 0x8f, 0x61, 0xc0, 0x39, 0x5c, 0xfa, 0x9a, 0x20, - 0x96, 0xfa, 0x29, 0x42, 0x89, 0xc3, 0x5c, 0x23, 0xdc, 0x17, 0x42, 0xfa, 0x08, 0x3d, 0xab, 0xcf, - 0x69, 0x75, 0x7c, 0x6a, 0xec, 0xed, 0xc0, 0x68, 0xe3, 0x60, 0xfe, 0x28, 0x2e, 0xad, 0xd2, 0x7f, - 0x48, 0x60, 0x48, 0xa0, 0x09, 0x86, 0xa1, 0x2e, 0xd0, 0xef, 0x08, 0xc6, 0x62, 0xfa, 0x1f, 0x5a, - 0x91, 0xaf, 0x28, 0x1e, 0x89, 0x70, 0x9a, 0x51, 0xb9, 0x35, 0xaa, 0x75, 0x6b, 0x54, 0xef, 0xb9, - 0x35, 0xbd, 0xb7, 0x18, 0x79, 0x4c, 0x54, 0xe8, 0x89, 0xa8, 0xd0, 0x03, 0x72, 0x93, 0xed, 0xc9, - 0xed, 0x8c, 0x23, 0xb7, 0xab, 0x89, 0xdc, 0xc2, 0xab, 0xff, 0xa0, 0x8b, 0x4d, 0x87, 0xdf, 0x21, - 0x80, 0x60, 0x44, 0x3c, 0xde, 0xe8, 0x15, 0xad, 0x0d, 0x5c, 0x9e, 0x88, 0xcd, 0xe3, 0xec, 0x28, - 0xb7, 0x5e, 0x7e, 0xfe, 0xf5, 0x36, 0x31, 0x83, 0xa7, 0xb5, 0x86, 0xcf, 0x4c, 0xfd, 0x43, 0x15, - 0xb2, 0x1d, 0xed, 0x45, 0x64, 0x55, 0x3b, 0xf8, 0x35, 0x82, 0x74, 0xe8, 0xe5, 0xc6, 0x71, 0x5d, - 0xeb, 0xee, 0x21, 0xe7, 0xe3, 0x13, 0x05, 0xbe, 0xab, 0x0c, 0xdf, 0x18, 0x1e, 0x39, 0x02, 0x3e, - 0xfc, 0x11, 0xc1, 0xf9, 0x26, 0xcb, 0xc1, 0x93, 0xad, 0x9b, 0xb5, 0x71, 0x36, 0x59, 0x3d, 0x6a, - 0xba, 0x40, 0x78, 0x87, 0x21, 0xbc, 0x81, 0x67, 0xdb, 0x22, 0xe4, 0xf2, 0x89, 0x12, 0x59, 0x97, - 0xd4, 0x0e, 0xde, 0x45, 0xd0, 0xd7, 0xd2, 0x1d, 0xf0, 0x54, 0x0c, 0x4b, 0xcd, 0x76, 0x25, 0x17, - 0x8e, 0x53, 0x22, 0x06, 0x58, 0x66, 0x03, 0xcc, 0xe3, 0xbb, 0x27, 0x90, 0x80, 0x16, 0xf6, 0x2a, - 0xfc, 0x05, 0x81, 0xd4, 0xee, 0x7d, 0xc4, 0xd7, 0xe3, 0xa0, 0xb5, 0xb2, 0x0f, 0x79, 0xe6, 0x98, - 0x55, 0x62, 0xa6, 0x07, 0x6c, 0xa6, 0x45, 0xbc, 0x70, 0xa2, 0x99, 0xa2, 0x76, 0x31, 0xbf, 0xba, - 0xbb, 0x9f, 0x45, 0x7b, 0xfb, 0x59, 0xf4, 0x73, 0x3f, 0x8b, 0xde, 0x1c, 0x64, 0x3b, 0xf6, 0x0e, - 0xb2, 0x1d, 0xdf, 0x0e, 0xb2, 0x1d, 0x4f, 0x66, 0x6d, 0xc7, 0x2b, 0x57, 0x4d, 0xb5, 0x48, 0x36, - 0x35, 0xf1, 0x5f, 0x8f, 0xff, 0x4c, 0xd2, 0xd2, 0x53, 0xed, 0x39, 0x6b, 0x7e, 0x6d, 0x7a, 0x32, - 0xd4, 0xdf, 0xab, 0x55, 0x2c, 0x6a, 0x76, 0x33, 0xcb, 0x99, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, - 0x4c, 0x81, 0x0a, 0xe4, 0x63, 0x0a, 0x00, 0x00, + // 845 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 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0x19, 0x65, + 0x47, 0x33, 0x5c, 0x97, 0x78, 0xec, 0x58, 0x2a, 0xac, 0x17, 0x84, 0x95, 0xad, 0xcc, 0xca, 0x86, + 0x66, 0xb8, 0x02, 0x84, 0x32, 0x0f, 0xfd, 0x0f, 0xfd, 0xa2, 0x16, 0xeb, 0x27, 0xea, 0xd6, 0x76, + 0xc5, 0xa2, 0x1e, 0x1e, 0x85, 0x33, 0x41, 0x9a, 0x75, 0xa7, 0x28, 0xa1, 0x61, 0x94, 0x4b, 0xe9, + 0x3d, 0xc1, 0xe6, 0x6a, 0x51, 0xf9, 0x84, 0x60, 0xa0, 0x29, 0x9e, 0x96, 0x89, 0x4b, 0x2d, 0x3c, + 0x0f, 0x10, 0xf8, 0xb2, 0xe8, 0x74, 0x7e, 0x50, 0x8d, 0x92, 0xa6, 0x06, 0x71, 0x4b, 0x6e, 0x51, + 0x0f, 0x05, 0xe0, 0x0c, 0x74, 0x95, 0x77, 0x08, 0xd9, 0x90, 0x12, 0xc3, 0x28, 0xd7, 0xa3, 0xf3, + 0x05, 0x1e, 0x04, 0x60, 0x1f, 0xeb, 0x65, 0xc3, 0x2b, 0x49, 0x49, 0x56, 0x52, 0x8a, 0xed, 0xac, + 0x19, 0x5e, 0x09, 0xcf, 0x42, 0x0f, 0x37, 0x97, 0x2c, 0xc7, 0x2e, 0x79, 0x52, 0x27, 0xcb, 0x8a, + 0x79, 0x56, 0xce, 0xe8, 0x0a, 0xb3, 0xe8, 0x69, 0xe6, 0xc7, 0x17, 0x8a, 0xd1, 0x84, 0x82, 0xd6, + 0x68, 0x58, 0x06, 0x08, 0xfa, 0x24, 0x50, 0x4c, 0xa8, 0xbc, 0xa9, 0xaa, 0xdf, 0x54, 0x95, 0xcf, + 0x84, 0x68, 0xaa, 0xba, 0x66, 0xd8, 0x96, 0x88, 0xd5, 0x43, 0x91, 0xca, 0x47, 0x04, 0x52, 0x73, + 0x0e, 0x41, 0xd5, 0x32, 0xa4, 0x03, 0xe4, 0x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xc2, 0x9a, 0x86, 0xbf, 0x20, 0x90, 0xda, 0xdd, 0x51, 0x7c, 0x3d, 0xae, 0xb4, 0x56, + 0x92, 0x22, 0xcf, 0x1e, 0x33, 0x4a, 0x60, 0x7a, 0xc0, 0x30, 0x2d, 0xe1, 0xc5, 0x13, 0x61, 0x8a, + 0x4a, 0xc8, 0xc2, 0xda, 0xde, 0x41, 0x16, 0xed, 0x1f, 0x64, 0xd1, 0xf7, 0x83, 0x2c, 0x7a, 0x73, + 0x98, 0xed, 0xd8, 0x3f, 0xcc, 0x76, 0x7c, 0x3d, 0xcc, 0x76, 0x3c, 0x99, 0xb3, 0x1d, 0xaf, 0x54, + 0x31, 0xd5, 0x02, 0xd9, 0xd2, 0xc4, 0x7f, 0x47, 0xfe, 0x33, 0x45, 0x8b, 0x4f, 0xb5, 0xe7, 0x2c, + 0xf9, 0xb5, 0x99, 0xa9, 0x50, 0x7e, 0xaf, 0x5a, 0xb6, 0xa8, 0xd9, 0xcd, 0x64, 0x68, 0xe6, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x41, 0x9c, 0xc9, 0xb3, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1007,10 +1007,17 @@ func (m *QueryConnectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -1180,10 +1187,17 @@ func (m *QueryClientConnectionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -1261,10 +1275,17 @@ func (m *QueryConnectionClientStateResponse) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -1350,10 +1371,17 @@ func (m *QueryConnectionConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x2a } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -1433,8 +1461,9 @@ func (m *QueryConnectionResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1507,8 +1536,9 @@ func (m *QueryClientConnectionsResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1544,8 +1574,9 @@ func (m *QueryConnectionClientStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1588,8 +1619,9 @@ func (m *QueryConnectionConsensusStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -1817,10 +1849,10 @@ func (m *QueryConnectionResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1830,11 +1862,28 @@ func (m *QueryConnectionResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2303,10 +2352,10 @@ func (m *QueryClientConnectionsResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2316,11 +2365,28 @@ func (m *QueryClientConnectionsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2562,10 +2628,10 @@ func (m *QueryConnectionClientStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2575,11 +2641,28 @@ func (m *QueryConnectionClientStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2872,10 +2955,10 @@ func (m *QueryConnectionConsensusStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2885,11 +2968,28 @@ func (m *QueryConnectionConsensusStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ibc/04-channel/client/cli/tx.go b/x/ibc/04-channel/client/cli/tx.go index af00a4d37534..78b8521cf56f 100644 --- a/x/ibc/04-channel/client/cli/tx.go +++ b/x/ibc/04-channel/client/cli/tx.go @@ -19,6 +19,7 @@ import ( const ( FlagOrdered = "ordered" FlagIBCVersion = "ibc-version" + FlagProofEpoch = "proof-epoch" ) // NewChannelOpenInitCmd returns the command to create a MsgChannelOpenInit transaction @@ -94,10 +95,15 @@ func NewChannelOpenTryCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(FlagProofEpoch) + if err != nil { + return err + } + msg := types.NewMsgChannelOpenTry( portID, channelID, version, order, hops, counterpartyPortID, counterpartyChannelID, version, - proofInit, uint64(proofHeight), clientCtx.GetFromAddress(), + proofInit, uint64(proofEpoch), uint64(proofHeight), clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { return err @@ -108,6 +114,7 @@ func NewChannelOpenTryCmd() *cobra.Command { } cmd.Flags().Bool(FlagOrdered, true, "Pass flag for opening ordered channels") + cmd.Flags().Int(FlagProofEpoch, 0, "epoch for proof height") cmd.Flags().String(FlagIBCVersion, ibctransfertypes.Version, "IBC application version") flags.AddTxFlagsToCmd(cmd) @@ -143,8 +150,13 @@ func NewChannelOpenAckCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(FlagProofEpoch) + if err != nil { + return err + } + msg := types.NewMsgChannelOpenAck( - portID, channelID, version, proofTry, uint64(proofHeight), clientCtx.GetFromAddress(), + portID, channelID, version, proofTry, uint64(proofEpoch), uint64(proofHeight), clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { return err @@ -153,6 +165,8 @@ func NewChannelOpenAckCmd() *cobra.Command { return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } + + cmd.Flags().Int(FlagProofEpoch, 0, "epoch for proof height") cmd.Flags().String(FlagIBCVersion, ibctransfertypes.Version, "IBC application version") flags.AddTxFlagsToCmd(cmd) @@ -185,8 +199,13 @@ func NewChannelOpenConfirmCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(FlagProofEpoch) + if err != nil { + return err + } + msg := types.NewMsgChannelOpenConfirm( - portID, channelID, proofAck, uint64(proofHeight), clientCtx.GetFromAddress(), + portID, channelID, proofAck, uint64(proofEpoch), uint64(proofHeight), clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { return err @@ -196,6 +215,7 @@ func NewChannelOpenConfirmCmd() *cobra.Command { }, } + cmd.Flags().Int(FlagProofEpoch, 0, "epoch for proof height") flags.AddTxFlagsToCmd(cmd) return cmd @@ -257,8 +277,13 @@ func NewChannelCloseConfirmCmd() *cobra.Command { return err } + proofEpoch, err := cmd.Flags().GetInt(FlagProofEpoch) + if err != nil { + return err + } + msg := types.NewMsgChannelCloseConfirm( - portID, channelID, proofInit, uint64(proofHeight), clientCtx.GetFromAddress(), + portID, channelID, proofInit, uint64(proofEpoch), uint64(proofHeight), clientCtx.GetFromAddress(), ) if err := msg.ValidateBasic(); err != nil { return err @@ -268,6 +293,7 @@ func NewChannelCloseConfirmCmd() *cobra.Command { }, } + cmd.Flags().Int(FlagProofEpoch, 0, "epoch for proof height") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/ibc/04-channel/exported/exported.go b/x/ibc/04-channel/exported/exported.go index bbbd84f2dc1d..48a035cf24d6 100644 --- a/x/ibc/04-channel/exported/exported.go +++ b/x/ibc/04-channel/exported/exported.go @@ -21,6 +21,7 @@ type CounterpartyI interface { // PacketI defines the standard interface for IBC packets type PacketI interface { GetSequence() uint64 + GetTimeoutEpoch() uint64 GetTimeoutHeight() uint64 GetTimeoutTimestamp() uint64 GetSourcePort() string diff --git a/x/ibc/04-channel/handler.go b/x/ibc/04-channel/handler.go index 17b173556716..9cf2c8ed933f 100644 --- a/x/ibc/04-channel/handler.go +++ b/x/ibc/04-channel/handler.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) @@ -69,6 +70,8 @@ func HandleMsgChannelOpenTry(ctx sdk.Context, k keeper.Keeper, portCap *capabili // HandleMsgChannelOpenAck defines the sdk.Handler for MsgChannelOpenAck func HandleMsgChannelOpenAck(ctx sdk.Context, k keeper.Keeper, channelCap *capabilitytypes.Capability, msg *types.MsgChannelOpenAck) (*sdk.Result, error) { + // For now, convert uint64 heights to clientexported.Height + proofHeight := clientexported.NewHeight(msg.ProofEpoch, msg.ProofHeight) err := k.ChanOpenAck( ctx, msg.PortId, msg.ChannelId, channelCap, msg.CounterpartyVersion, msg.ProofTry, msg.ProofHeight, ) diff --git a/x/ibc/04-channel/keeper/handshake.go b/x/ibc/04-channel/keeper/handshake.go index 50162cd6a0b2..ab0aa441d33a 100644 --- a/x/ibc/04-channel/keeper/handshake.go +++ b/x/ibc/04-channel/keeper/handshake.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" @@ -105,7 +106,7 @@ func (k Keeper) ChanOpenTry( version, counterpartyVersion string, proofInit []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) (*capabilitytypes.Capability, error) { // channel identifier and connection hop length checked on msg.ValidateBasic() previousChannel, found := k.GetChannel(ctx, portID, channelID) @@ -199,7 +200,7 @@ func (k Keeper) ChanOpenAck( chanCap *capabilitytypes.Capability, counterpartyVersion string, proofTry []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) error { channel, found := k.GetChannel(ctx, portID, channelID) if !found { @@ -267,7 +268,7 @@ func (k Keeper) ChanOpenConfirm( channelID string, chanCap *capabilitytypes.Capability, proofAck []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) error { channel, found := k.GetChannel(ctx, portID, channelID) if !found { @@ -378,7 +379,7 @@ func (k Keeper) ChanCloseConfirm( channelID string, chanCap *capabilitytypes.Capability, proofInit []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) error { if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { return sdkerrors.Wrap(types.ErrChannelCapabilityNotFound, "caller does not own capability for channel, port ID (%s) channel ID (%s)") diff --git a/x/ibc/04-channel/keeper/handshake_test.go b/x/ibc/04-channel/keeper/handshake_test.go index 836c27f80830..85a07cb2d1ac 100644 --- a/x/ibc/04-channel/keeper/handshake_test.go +++ b/x/ibc/04-channel/keeper/handshake_test.go @@ -260,10 +260,12 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { channelKey := host.KeyChannel(counterparty.PortId, counterparty.ChannelId) proof, proofHeight := suite.chainA.QueryProof(channelKey) + // increment proofHeight by heightDiff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff) cap, err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenTry( suite.chainB.GetContext(), types.ORDERED, []string{connB.ID}, channelB.PortID, channelB.ID, portCap, counterparty, channelB.Version, connA.FirstOrNextTestChannel(ibctesting.TransferPort).Version, - proof, proofHeight+heightDiff, + proof, clienttypes.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff), ) if tc.expPass { @@ -389,9 +391,11 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channelKey := host.KeyChannel(channelB.PortID, channelB.ID) proof, proofHeight := suite.chainB.QueryProof(channelKey) + // increment proofHeight by heightDiff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff) err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenAck( suite.chainA.GetContext(), channelA.PortID, channelA.ID, channelCap, channelB.Version, - proof, proofHeight+heightDiff, + proof, clienttypes.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff), ) if tc.expPass { @@ -517,9 +521,11 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channelKey := host.KeyChannel(channelA.PortID, channelA.ID) proof, proofHeight := suite.chainA.QueryProof(channelKey) + // increment proofHeight by heightDiff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff) err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenConfirm( suite.chainB.GetContext(), channelB.PortID, channelB.ID, - channelCap, proof, proofHeight+heightDiff, + channelCap, proof, proofHeight, ) if tc.expPass { @@ -718,9 +724,11 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { channelKey := host.KeyChannel(channelA.PortID, channelA.ID) proof, proofHeight := suite.chainA.QueryProof(channelKey) + // increment proofHeight by heightDiff + proofHeight = clientexported.NewHeight(proofHeight.EpochNumber, proofHeight.EpochHeight+heightDiff) err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanCloseConfirm( suite.chainB.GetContext(), channelB.PortID, channelB.ID, channelCap, - proof, proofHeight+heightDiff, + proof, proofHeight, ) if tc.expPass { diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index 0e4779f92eb7..011fbed13a25 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" @@ -77,10 +78,11 @@ func (k Keeper) SendPacket( // check if packet timeouted on the receiving chain latestHeight := clientState.GetLatestHeight() - if packet.GetTimeoutHeight() != 0 && latestHeight >= packet.GetTimeoutHeight() { + timeoutHeight := clientexported.NewHeight(packet.GetTimeoutEpoch(), packet.GetTimeoutHeight()) + if packet.GetTimeoutHeight() != 0 && !latestHeight.LT(timeoutHeight) { return sdkerrors.Wrapf( types.ErrPacketTimeout, - "receiving chain block height >= packet timeout height (%d >= %d)", latestHeight, packet.GetTimeoutHeight(), + "receiving chain block height >= packet timeout height (%v >= %v)", latestHeight, timeoutHeight, ) } @@ -121,6 +123,7 @@ func (k Keeper) SendPacket( sdk.NewEvent( types.EventTypeSendPacket, sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), + sdk.NewAttribute(types.AttributeKeyTimeoutEpoch, fmt.Sprintf("%d", packet.GetTimeoutEpoch())), sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), @@ -146,7 +149,7 @@ func (k Keeper) RecvPacket( ctx sdk.Context, packet exported.PacketI, proof []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) error { channel, found := k.GetChannel(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { @@ -191,10 +194,13 @@ func (k Keeper) RecvPacket( } // check if packet timeouted by comparing it with the latest height of the chain - if packet.GetTimeoutHeight() != 0 && uint64(ctx.BlockHeight()) >= packet.GetTimeoutHeight() { + // support current height with epoch-0 for now + blockHeight := clientexported.NewHeight(0, uint64(ctx.BlockHeight())) + timeoutHeight := clientexported.NewHeight(packet.GetTimeoutEpoch(), packet.GetTimeoutHeight()) + if packet.GetTimeoutHeight() != 0 && !blockHeight.LT(timeoutHeight) { return sdkerrors.Wrapf( types.ErrPacketTimeout, - "block height >= packet timeout height (%d >= %d)", uint64(ctx.BlockHeight()), packet.GetTimeoutHeight(), + "block height >= packet timeout height (%v >= %v)", blockHeight, timeoutHeight, ) } @@ -311,6 +317,7 @@ func (k Keeper) PacketExecuted( types.EventTypeRecvPacket, sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)), + sdk.NewAttribute(types.AttributeKeyTimeoutEpoch, fmt.Sprintf("%d", packet.GetTimeoutEpoch())), sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), @@ -340,7 +347,7 @@ func (k Keeper) AcknowledgePacket( packet exported.PacketI, acknowledgement []byte, proof []byte, - proofHeight uint64, + proofHeight clientexported.Height, ) error { channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) if !found { @@ -472,6 +479,7 @@ func (k Keeper) AcknowledgementExecuted( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcknowledgePacket, + sdk.NewAttribute(types.AttributeKeyTimeoutEpoch, fmt.Sprintf("%d", packet.GetTimeoutEpoch())), sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index ec9dbca184f1..3c168dfc6fa6 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -16,6 +16,7 @@ var ( validPacketData = []byte("VALID PACKET DATA") disabledTimeoutTimestamp = uint64(0) disabledTimeoutHeight = uint64(0) + timeoutEpoch = uint64(0) timeoutHeight = uint64(100) // for when the testing package cannot be used @@ -38,7 +39,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { testCases := []testCase{ {"success: UNORDERED channel", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, true}, {"success: ORDERED channel", func() { @@ -50,7 +51,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { {"sending packet out of order on UNORDERED channel", func() { // setup creates an unordered channel _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 5, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 5, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"sending packet out of order on ORDERED channel", func() { @@ -61,18 +62,18 @@ func (suite *KeeperTestSuite) TestSendPacket() { }, false}, {"packet basic validation failed, empty packet data", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket([]byte{}, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket([]byte{}, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"channel not found", func() { // use wrong channel naming _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"channel closed", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err := suite.coordinator.SetChannelClosed(suite.chainA, suite.chainB, channelA) suite.Require().NoError(err) @@ -80,13 +81,13 @@ func (suite *KeeperTestSuite) TestSendPacket() { {"packet dest port ≠ channel counterparty port", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong port for dest - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"packet dest channel ID ≠ channel counterparty channel ID", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong channel for dest - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, ibctesting.InvalidID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, ibctesting.InvalidID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"connection not found", func() { @@ -98,7 +99,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { channelA.PortID, channelA.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelB.PortID, channelB.ID), []string{connIDA}, channelA.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.chainA.CreateChannelCapability(channelA.PortID, channelA.ID) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, @@ -116,7 +117,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { channelA.PortID, channelA.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelB.PortID, channelB.ID), []string{connIDA}, channelA.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.chainA.CreateChannelCapability(channelA.PortID, channelA.ID) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, @@ -128,14 +129,15 @@ func (suite *KeeperTestSuite) TestSendPacket() { connection.ClientId = ibctesting.InvalidID suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"timeout height passed", func() { clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use client state latest height for timeout clientState := suite.chainA.GetClientState(clientA) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clientState.GetLatestHeight(), disabledTimeoutTimestamp) + height := clientState.GetLatestHeight() + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, height.EpochNumber, height.EpochHeight, disabledTimeoutTimestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"timeout timestamp passed", func() { @@ -146,7 +148,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { timestamp, err := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection, clientState.GetLatestHeight()) suite.Require().NoError(err) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, disabledTimeoutHeight, timestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, disabledTimeoutHeight, timestamp) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"next sequence send not found", func() { @@ -165,13 +167,13 @@ func (suite *KeeperTestSuite) TestSendPacket() { }, false}, {"next sequence wrong", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 5) channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"channel capability not found", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = capabilitytypes.NewCapability(5) }, false}, } @@ -214,20 +216,20 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"success UNORDERED channel", func() { // setup uses an UNORDERED channel _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) }, true}, {"success with out of order packet: UNORDERED channel", func() { // setup uses an UNORDERED channel _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) // send 2 packets err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) // set sequence to 2 - packet = types.NewPacket(validPacketData, 2, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 2, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err = suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) // attempts to receive packet 2 without receiving packet 1 @@ -241,7 +243,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) // set sequence to 2 - packet = types.NewPacket(validPacketData, 2, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 2, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err = suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) // attempts to receive packet 2 without receiving packet 1 @@ -249,11 +251,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"channel not found", func() { // use wrong channel naming _, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, ibctesting.InvalidID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, ibctesting.InvalidID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"channel not open", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err := suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) suite.Require().NoError(err) @@ -261,12 +263,12 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"packet source port ≠ channel counterparty port", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong port for dest - packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"packet source channel ID ≠ channel counterparty channel ID", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong port for dest - packet = types.NewPacket(validPacketData, 1, channelA.PortID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"connection not found", func() { channelA := ibctesting.TestChannel{PortID: portID, ID: channelIDA} @@ -277,7 +279,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelB.PortID, channelB.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelA.PortID, channelA.ID), []string{connIDB}, channelB.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"connection not OPEN", func() { clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, clientexported.Tendermint) @@ -293,20 +295,20 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelB.PortID, channelB.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelA.PortID, channelA.ID), []string{connB.ID}, channelB.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"timeout height passed", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, uint64(suite.chainB.GetContext().BlockHeight()), disabledTimeoutTimestamp) }, false}, {"timeout timestamp passed", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, disabledTimeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, disabledTimeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) }, false}, {"acknowledgement already received", func() { // setup uses an UNORDERED channel clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // write packet acknowledgement @@ -324,7 +326,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelA.PortID, channelA.ID), []string{connB.ID}, channelB.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) // manually set packet commitment suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, packet.GetSequence(), ibctesting.TestHash) @@ -332,7 +334,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"validation failed", func() { // packet commitment not set resulting in invalid proof _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, } @@ -370,7 +372,7 @@ func (suite *KeeperTestSuite) TestPacketExecuted() { {"success: UNORDERED", func() { // setup uses an UNORDERED channel _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, true}, @@ -384,12 +386,12 @@ func (suite *KeeperTestSuite) TestPacketExecuted() { {"channel not found", func() { // use wrong channel naming _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, ibctesting.InvalidID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, ibctesting.InvalidID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"channel not OPEN", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err := suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) suite.Require().NoError(err) @@ -418,7 +420,7 @@ func (suite *KeeperTestSuite) TestPacketExecuted() { }, false}, {"acknowledgement is empty", func() { _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) @@ -471,7 +473,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { {"success on unordered channel", func() { // setup uses an UNORDERED channel clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) // create packet commitment err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) @@ -484,11 +486,11 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { {"channel not found", func() { // use wrong channel naming _, _, _, _, _, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"channel not open", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) err := suite.coordinator.SetChannelClosed(suite.chainA, suite.chainB, channelA) suite.Require().NoError(err) @@ -496,12 +498,12 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { {"packet destination port ≠ channel counterparty port", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong port for dest - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, ibctesting.InvalidID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"packet destination channel ID ≠ channel counterparty channel ID", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) // use wrong channel for dest - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, ibctesting.InvalidID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, ibctesting.InvalidID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"connection not found", func() { channelA := ibctesting.TestChannel{PortID: portID, ID: channelIDA} @@ -512,7 +514,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channelB.PortID, channelB.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelA.PortID, channelA.ID), []string{connIDB}, channelB.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"connection not OPEN", func() { clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, clientexported.Tendermint) @@ -528,17 +530,17 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channelA.PortID, channelA.ID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(channelB.PortID, channelB.ID), []string{connA.ID}, channelA.Version), ) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"packet hasn't been sent", func() { // packet commitment never written _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"packet ack verification failed", func() { // ack never written _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) // create packet commitment suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) @@ -609,7 +611,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { {"success ORDERED", func() { // setup uses an UNORDERED channel clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) // create packet commitment err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) @@ -624,11 +626,11 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { {"channel not found", func() { // use wrong channel naming _, _, _, _, _, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) }, false}, {"incorrect capability", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, disabledTimeoutTimestamp) chanCap = capabilitytypes.NewCapability(100) }, false}, diff --git a/x/ibc/04-channel/keeper/timeout.go b/x/ibc/04-channel/keeper/timeout.go index 687e3d1b8629..6582d66aa624 100644 --- a/x/ibc/04-channel/keeper/timeout.go +++ b/x/ibc/04-channel/keeper/timeout.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" @@ -23,7 +24,7 @@ func (k Keeper) TimeoutPacket( ctx sdk.Context, packet exported.PacketI, proof []byte, - proofHeight, + proofHeight clientexported.Height, nextSequenceRecv uint64, ) error { channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) @@ -72,7 +73,8 @@ func (k Keeper) TimeoutPacket( return err } - if (packet.GetTimeoutHeight() == 0 || proofHeight < packet.GetTimeoutHeight()) && + timeoutHeight := clientexported.NewHeight(packet.GetTimeoutEpoch(), packet.GetTimeoutHeight()) + if (packet.GetTimeoutHeight() == 0 || proofHeight.LT(timeoutHeight)) && (packet.GetTimeoutTimestamp() == 0 || proofTimestamp < packet.GetTimeoutTimestamp()) { return sdkerrors.Wrap(types.ErrPacketTimeout, "packet timeout has not been reached for height or timestamp") } @@ -178,7 +180,7 @@ func (k Keeper) TimeoutOnClose( packet exported.PacketI, proof, proofClosed []byte, - proofHeight, + proofHeight clientexported.Height, nextSequenceRecv uint64, ) error { channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) diff --git a/x/ibc/04-channel/keeper/timeout_test.go b/x/ibc/04-channel/keeper/timeout_test.go index 83040b60c6bf..82efb534c182 100644 --- a/x/ibc/04-channel/keeper/timeout_test.go +++ b/x/ibc/04-channel/keeper/timeout_test.go @@ -26,7 +26,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // need to update chainA's client representing chainB to prove missing ack suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, clientexported.Tendermint) @@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { ordered = false clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // need to update chainA's client representing chainB to prove missing ack suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, clientexported.Tendermint) @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, clientexported.Tendermint) }, false}, @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { var ( proof []byte - proofHeight uint64 + proofHeight clientexported.Height ) suite.SetupTest() // reset @@ -161,7 +161,7 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { {"success ORDERED", func() { _, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) @@ -174,7 +174,7 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { {"incorrect capability", func() { _, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) chanCap = capabilitytypes.NewCapability(100) @@ -216,7 +216,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { ordered = true clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack @@ -270,7 +270,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { {"packet hasn't been sent", func() { _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"packet already received", func() { @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { ordered = true clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { ordered = true _, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, @@ -299,7 +299,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { ordered = false clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, clientexported.Tendermint) @@ -309,7 +309,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { // set ordered to true providing the wrong proof for UNORDERED case ordered = true clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), disabledTimeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, clientexported.Tendermint) @@ -319,7 +319,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { ordered = true clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack diff --git a/x/ibc/04-channel/types/channel.pb.go b/x/ibc/04-channel/types/channel.pb.go index eb32530a5f91..d52c061e5ea3 100644 --- a/x/ibc/04-channel/types/channel.pb.go +++ b/x/ibc/04-channel/types/channel.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -178,7 +179,7 @@ type MsgChannelOpenTry struct { Channel Channel `protobuf:"bytes,3,opt,name=channel,proto3" json:"channel"` CounterpartyVersion string `protobuf:"bytes,4,opt,name=counterparty_version,json=counterpartyVersion,proto3" json:"counterparty_version,omitempty" yaml:"counterparty_version"` ProofInit []byte `protobuf:"bytes,5,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` - ProofHeight uint64 `protobuf:"varint,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -250,11 +251,11 @@ func (m *MsgChannelOpenTry) GetProofInit() []byte { return nil } -func (m *MsgChannelOpenTry) GetProofHeight() uint64 { +func (m *MsgChannelOpenTry) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgChannelOpenTry) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -271,7 +272,7 @@ type MsgChannelOpenAck struct { ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` CounterpartyVersion string `protobuf:"bytes,3,opt,name=counterparty_version,json=counterpartyVersion,proto3" json:"counterparty_version,omitempty" yaml:"counterparty_version"` ProofTry []byte `protobuf:"bytes,4,opt,name=proof_try,json=proofTry,proto3" json:"proof_try,omitempty" yaml:"proof_try"` - ProofHeight uint64 `protobuf:"varint,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -336,11 +337,11 @@ func (m *MsgChannelOpenAck) GetProofTry() []byte { return nil } -func (m *MsgChannelOpenAck) GetProofHeight() uint64 { +func (m *MsgChannelOpenAck) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgChannelOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -356,7 +357,7 @@ type MsgChannelOpenConfirm struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` ProofAck []byte `protobuf:"bytes,3,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack,omitempty" yaml:"proof_ack"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -414,11 +415,11 @@ func (m *MsgChannelOpenConfirm) GetProofAck() []byte { return nil } -func (m *MsgChannelOpenConfirm) GetProofHeight() uint64 { +func (m *MsgChannelOpenConfirm) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgChannelOpenConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -496,7 +497,7 @@ type MsgChannelCloseConfirm struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` ProofInit []byte `protobuf:"bytes,3,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -554,11 +555,11 @@ func (m *MsgChannelCloseConfirm) GetProofInit() []byte { return nil } -func (m *MsgChannelCloseConfirm) GetProofHeight() uint64 { +func (m *MsgChannelCloseConfirm) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgChannelCloseConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -572,7 +573,7 @@ func (m *MsgChannelCloseConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types. type MsgRecvPacket struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -623,11 +624,11 @@ func (m *MsgRecvPacket) GetProof() []byte { return nil } -func (m *MsgRecvPacket) GetProofHeight() uint64 { +func (m *MsgRecvPacket) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgRecvPacket) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -641,7 +642,7 @@ func (m *MsgRecvPacket) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddres type MsgTimeout struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` NextSequenceRecv uint64 `protobuf:"varint,4,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty" yaml:"next_sequence_recv"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -693,11 +694,11 @@ func (m *MsgTimeout) GetProof() []byte { return nil } -func (m *MsgTimeout) GetProofHeight() uint64 { +func (m *MsgTimeout) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgTimeout) GetNextSequenceRecv() uint64 { @@ -719,7 +720,7 @@ type MsgTimeoutOnClose struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` ProofClose []byte `protobuf:"bytes,3,opt,name=proof_close,json=proofClose,proto3" json:"proof_close,omitempty" yaml:"proof_close"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` NextSequenceRecv uint64 `protobuf:"varint,5,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty" yaml:"next_sequence_recv"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -778,11 +779,11 @@ func (m *MsgTimeoutOnClose) GetProofClose() []byte { return nil } -func (m *MsgTimeoutOnClose) GetProofHeight() uint64 { +func (m *MsgTimeoutOnClose) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgTimeoutOnClose) GetNextSequenceRecv() uint64 { @@ -804,7 +805,7 @@ type MsgAcknowledgement struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -862,11 +863,11 @@ func (m *MsgAcknowledgement) GetProof() []byte { return nil } -func (m *MsgAcknowledgement) GetProofHeight() uint64 { +func (m *MsgAcknowledgement) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func (m *MsgAcknowledgement) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { @@ -1037,7 +1038,7 @@ type Packet struct { // actual opaque bytes transferred directly to the application module Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` // block height after which the packet times out - TimeoutHeight uint64 `protobuf:"varint,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty" yaml:"timeout_height"` + TimeoutHeight *types.Height `protobuf:"bytes,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty" yaml:"timeout_height"` // block timestamp (in nanoseconds) after which the packet times out TimeoutTimestamp uint64 `protobuf:"varint,8,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` } @@ -1144,89 +1145,90 @@ func init() { func init() { proto.RegisterFile("ibc/channel/channel.proto", fileDescriptor_9277922ccfb7f043) } var fileDescriptor_9277922ccfb7f043 = []byte{ - // 1303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xbd, 0x6f, 0xdb, 0x46, - 0x14, 0x17, 0xf5, 0x69, 0x3d, 0x7f, 0xc9, 0x67, 0xc7, 0x91, 0x95, 0x44, 0x14, 0x88, 0x0e, 0x42, - 0x8a, 0xc8, 0xcd, 0x07, 0x5a, 0x20, 0x53, 0x25, 0x59, 0x41, 0x84, 0xc6, 0x92, 0x71, 0x56, 0x0a, - 0x34, 0x0b, 0x41, 0x53, 0x17, 0x89, 0x90, 0xc5, 0x53, 0x49, 0x3a, 0x89, 0xf7, 0x0e, 0x81, 0x81, - 0x16, 0xfd, 0x07, 0x0c, 0x14, 0xe8, 0xd4, 0xa5, 0x53, 0x81, 0x76, 0xe9, 0xd4, 0x25, 0x5b, 0x33, - 0x76, 0x62, 0x8a, 0x64, 0xea, 0xca, 0xa9, 0xe8, 0x54, 0xf0, 0xee, 0x28, 0x91, 0x72, 0x9a, 0xc1, - 0x0a, 0x94, 0x0c, 0x9d, 0xc8, 0xf7, 0xde, 0xef, 0xee, 0xde, 0xfb, 0xbd, 0xc7, 0xf7, 0x4e, 0x82, - 0x2d, 0xe3, 0x40, 0xdf, 0xd6, 0xfb, 0x9a, 0x69, 0x92, 0xc3, 0xe0, 0x59, 0x19, 0x59, 0xd4, 0xa1, - 0x68, 0xd1, 0x38, 0xd0, 0x2b, 0x42, 0x55, 0xd8, 0xe8, 0xd1, 0x1e, 0x65, 0xfa, 0x6d, 0xff, 0x8d, - 0x43, 0x94, 0xbf, 0x25, 0x40, 0xbb, 0x76, 0xaf, 0xce, 0x41, 0xed, 0x11, 0x31, 0x9b, 0xa6, 0xe1, - 0xa0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6, 0x55, 0x31, 0xf6, 0xfc, 0x55, 0x31, 0xf6, 0xc7, 0xab, 0x62, 0xec, - 0xc1, 0xcd, 0x37, 0x4e, 0xbc, 0x27, 0xdb, 0xc6, 0x81, 0xbe, 0xfd, 0xd1, 0xad, 0x6b, 0xc1, 0xff, - 0x63, 0x6c, 0x04, 0x1e, 0xa4, 0xd9, 0x7f, 0x5f, 0x37, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xbc, - 0xba, 0x59, 0x74, 0x3b, 0x13, 0x00, 0x00, + // 1324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcd, 0x6b, 0x1b, 0x47, + 0x14, 0xd7, 0xea, 0xd3, 0x7a, 0xfe, 0x92, 0xc7, 0x8e, 0x2d, 0x2b, 0x89, 0x56, 0x2c, 0x3d, 0x98, + 0x94, 0xc8, 0xcd, 0x07, 0x2d, 0xe4, 0x54, 0x49, 0x56, 0x88, 0x68, 0x2c, 0x99, 0xb1, 0x52, 0x68, + 0x2e, 0x62, 0xbd, 0x9a, 0x48, 0x8b, 0xac, 0x1d, 0x75, 0x77, 0x9c, 0xc4, 0xff, 0x41, 0x30, 0x14, + 0x7a, 0xec, 0xc5, 0x50, 0xda, 0x7b, 0xaf, 0x3d, 0xf5, 0xd4, 0x4b, 0x0e, 0x85, 0xa6, 0xb7, 0x9e, + 0x96, 0x92, 0xfc, 0x07, 0xca, 0xa5, 0x14, 0x0a, 0x65, 0x67, 0x66, 0xa5, 0x5d, 0xd9, 0xc9, 0x21, + 0x32, 0xc2, 0x87, 0x9e, 0x76, 0xe6, 0xbd, 0xdf, 0xcc, 0xbc, 0xf7, 0x7b, 0x6f, 0xde, 0x3c, 0x09, + 0x36, 0xcd, 0x03, 0x63, 0xdb, 0xe8, 0xea, 0x96, 0x45, 0x0e, 0xfd, 0x6f, 0x71, 0x60, 0x53, 0x46, + 0xd1, 0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 0x16, 0x5c, 0xf4, 0x45, 0x3b, 0x9f, 0xff, 0xc4, 0xb4, 0xfc, 0x4f, 0xfd, 0x2a, + 0xfe, 0x10, 0xe5, 0xfd, 0x77, 0xc9, 0xe8, 0x59, 0xf4, 0xd9, 0x21, 0x69, 0x77, 0x48, 0x9f, 0x58, + 0x1f, 0x94, 0xc7, 0x5b, 0xb0, 0xac, 0x87, 0x77, 0x91, 0xa1, 0x98, 0x14, 0x8f, 0x43, 0x15, 0x7b, + 0x5f, 0xc6, 0x5f, 0xa2, 0xd2, 0xf6, 0x4d, 0x14, 0x52, 0xf2, 0x99, 0x40, 0x5b, 0x90, 0x70, 0x98, + 0xce, 0x08, 0x27, 0x66, 0xc9, 0xb7, 0x4f, 0x12, 0xb3, 0xef, 0x69, 0xb0, 0x00, 0xa0, 0x22, 0xcc, + 0x51, 0xbb, 0x4d, 0x6c, 0xd3, 0xea, 0x70, 0x26, 0x26, 0xc1, 0x0d, 0x4f, 0x89, 0x47, 0x18, 0x54, + 0x81, 0x85, 0x60, 0x17, 0x26, 0xaf, 0xfc, 0x66, 0xb8, 0x37, 0x0f, 0x00, 0x24, 0xff, 0xa1, 0x45, + 0xa8, 0x02, 0xcb, 0x06, 0xb5, 0x2c, 0x62, 0x30, 0x93, 0x5a, 0xad, 0x2e, 0x1d, 0x38, 0xd9, 0x78, + 0x21, 0xb6, 0x95, 0x2e, 0xe7, 0x86, 0xae, 0xba, 0xee, 0xb7, 0x80, 0x21, 0x80, 0x86, 0x97, 0xc6, + 0x92, 0x07, 0x74, 0xe0, 0xa0, 0x2c, 0xa4, 0xfc, 0xfe, 0xd1, 0xe3, 0x2e, 0x8d, 0xfd, 0xe9, 0xbd, + 0xf8, 0x8b, 0xef, 0xd5, 0x88, 0xf6, 0x7b, 0x14, 0x56, 0x6a, 0x6d, 0x62, 0x31, 0xf3, 0x89, 0x49, + 0xda, 0xff, 0x33, 0xe3, 0x35, 0xcb, 0x1b, 0xe3, 0x96, 0x21, 0xc9, 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, 0x9d, 0xb0, 0x97, 0x6f, 0xe9, 0xc9, 0x91, 0x06, 0xcb, + 0x02, 0xf5, 0xa8, 0xce, 0xbf, 0xd5, 0x9d, 0x8c, 0x92, 0x5b, 0x3c, 0x39, 0x2d, 0xa4, 0x47, 0x02, + 0xcf, 0x60, 0x81, 0xf1, 0x11, 0xd2, 0x60, 0x39, 0x15, 0x07, 0x97, 0x77, 0x5f, 0xbe, 0xce, 0x2b, + 0xaf, 0x5e, 0xe7, 0x95, 0xbf, 0x5e, 0xe7, 0x95, 0x6f, 0xdf, 0xe4, 0x23, 0xaf, 0xde, 0xe4, 0x23, + 0x7f, 0xbe, 0xc9, 0x47, 0x1e, 0xdf, 0x79, 0xef, 0x2b, 0xf8, 0x7c, 0xdb, 0x3c, 0x30, 0xb6, 0x3f, + 0xb9, 0x7b, 0xd3, 0xff, 0xb3, 0x8f, 0x3f, 0x8b, 0x07, 0x49, 0xfe, 0x7f, 0xdd, 0x9d, 0xff, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x56, 0x27, 0xc7, 0xae, 0x08, 0x14, 0x00, 0x00, } func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { @@ -1310,10 +1312,17 @@ func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x30 + dAtA[i] = 0x32 } if len(m.ProofInit) > 0 { i -= len(m.ProofInit) @@ -1383,10 +1392,17 @@ func (m *MsgChannelOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x2a } if len(m.ProofTry) > 0 { i -= len(m.ProofTry) @@ -1446,10 +1462,17 @@ func (m *MsgChannelOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofAck) > 0 { i -= len(m.ProofAck) @@ -1546,10 +1569,17 @@ func (m *MsgChannelCloseConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x2a } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofInit) > 0 { i -= len(m.ProofInit) @@ -1602,10 +1632,17 @@ func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } if len(m.Proof) > 0 { i -= len(m.Proof) @@ -1659,10 +1696,17 @@ func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } if len(m.Proof) > 0 { i -= len(m.Proof) @@ -1716,10 +1760,17 @@ func (m *MsgTimeoutOnClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofClose) > 0 { i -= len(m.ProofClose) @@ -1775,10 +1826,17 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.ProofHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.Proof) > 0 { i -= len(m.Proof) @@ -2001,10 +2059,17 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x40 } - if m.TimeoutHeight != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutHeight)) + if m.TimeoutHeight != nil { + { + size, err := m.TimeoutHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x38 + dAtA[i] = 0x3a } if len(m.Data) > 0 { i -= len(m.Data) @@ -2156,8 +2221,9 @@ func (m *MsgChannelOpenTry) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2188,8 +2254,9 @@ func (m *MsgChannelOpenAck) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2216,8 +2283,9 @@ func (m *MsgChannelOpenConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2265,8 +2333,9 @@ func (m *MsgChannelCloseConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2287,8 +2356,9 @@ func (m *MsgRecvPacket) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2309,8 +2379,9 @@ func (m *MsgTimeout) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } if m.NextSequenceRecv != 0 { n += 1 + sovChannel(uint64(m.NextSequenceRecv)) @@ -2338,8 +2409,9 @@ func (m *MsgTimeoutOnClose) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } if m.NextSequenceRecv != 0 { n += 1 + sovChannel(uint64(m.NextSequenceRecv)) @@ -2367,8 +2439,9 @@ func (m *MsgAcknowledgement) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovChannel(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } l = len(m.Signer) if l > 0 { @@ -2485,8 +2558,9 @@ func (m *Packet) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.TimeoutHeight != 0 { - n += 1 + sovChannel(uint64(m.TimeoutHeight)) + if m.TimeoutHeight != nil { + l = m.TimeoutHeight.Size() + n += 1 + l + sovChannel(uint64(l)) } if m.TimeoutTimestamp != 0 { n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) @@ -2901,10 +2975,10 @@ func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 6: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -2914,11 +2988,28 @@ func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -3137,10 +3228,10 @@ func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -3150,11 +3241,28 @@ func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -3341,10 +3449,10 @@ func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -3354,11 +3462,28 @@ func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -3696,10 +3821,10 @@ func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -3709,11 +3834,28 @@ func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -3869,10 +4011,10 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -3882,11 +4024,28 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -4042,10 +4201,10 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -4055,11 +4214,28 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) @@ -4268,10 +4444,10 @@ func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -4281,11 +4457,28 @@ func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) @@ -4494,10 +4687,10 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -4507,11 +4700,28 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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 m.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -5338,10 +5548,10 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 7: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) } - m.TimeoutHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowChannel @@ -5351,11 +5561,28 @@ func (m *Packet) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TimeoutHeight |= uint64(b&0x7F) << shift + 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 m.TimeoutHeight == nil { + m.TimeoutHeight = &types.Height{} + } + if err := m.TimeoutHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) diff --git a/x/ibc/04-channel/types/events.go b/x/ibc/04-channel/types/events.go index bd01adeee434..eee3264da7d7 100644 --- a/x/ibc/04-channel/types/events.go +++ b/x/ibc/04-channel/types/events.go @@ -21,6 +21,7 @@ const ( AttributeKeyData = "packet_data" AttributeKeyAck = "packet_ack" + AttributeKeyTimeoutEpoch = "packet_timeout_epoch" AttributeKeyTimeoutHeight = "packet_timeout_height" AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp" AttributeKeySequence = "packet_sequence" diff --git a/x/ibc/04-channel/types/expected_keepers.go b/x/ibc/04-channel/types/expected_keepers.go index dea6b6b49c41..cada09413d8d 100644 --- a/x/ibc/04-channel/types/expected_keepers.go +++ b/x/ibc/04-channel/types/expected_keepers.go @@ -21,12 +21,12 @@ type ConnectionKeeper interface { GetTimestampAtHeight( ctx sdk.Context, connection connectiontypes.ConnectionEnd, - height uint64, + height clientexported.Height, ) (uint64, error) VerifyChannelState( ctx sdk.Context, connection connectionexported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -35,7 +35,7 @@ type ConnectionKeeper interface { VerifyPacketCommitment( ctx sdk.Context, connection connectionexported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -45,7 +45,7 @@ type ConnectionKeeper interface { VerifyPacketAcknowledgement( ctx sdk.Context, connection connectionexported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -55,7 +55,7 @@ type ConnectionKeeper interface { VerifyPacketAcknowledgementAbsence( ctx sdk.Context, connection connectionexported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, @@ -64,7 +64,7 @@ type ConnectionKeeper interface { VerifyNextSequenceRecv( ctx sdk.Context, connection connectionexported.ConnectionI, - height uint64, + height clientexported.Height, proof []byte, portID, channelID string, diff --git a/x/ibc/04-channel/types/msgs.go b/x/ibc/04-channel/types/msgs.go index 73d4114d7f9c..a50803503f23 100644 --- a/x/ibc/04-channel/types/msgs.go +++ b/x/ibc/04-channel/types/msgs.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -64,7 +65,7 @@ var _ sdk.Msg = &MsgChannelOpenTry{} func NewMsgChannelOpenTry( portID, channelID, version string, channelOrder Order, connectionHops []string, counterpartyPortID, counterpartyChannelID, counterpartyVersion string, - proofInit []byte, proofHeight uint64, signer sdk.AccAddress, + proofInit []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgChannelOpenTry { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := NewChannel(INIT, channelOrder, counterparty, connectionHops, version) @@ -100,8 +101,8 @@ func (msg MsgChannelOpenTry) ValidateBasic() error { if len(msg.ProofInit) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof init") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } // Signer can be empty return msg.Channel.ValidateBasic() @@ -121,8 +122,8 @@ var _ sdk.Msg = &MsgChannelOpenAck{} // NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance func NewMsgChannelOpenAck( - portID, channelID string, cpv string, proofTry []byte, proofHeight uint64, - signer sdk.AccAddress, + portID, channelID string, cpv string, proofTry []byte, + proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgChannelOpenAck { return &MsgChannelOpenAck{ PortId: portID, @@ -155,8 +156,8 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { if len(msg.ProofTry) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof try") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } // Signer can be empty return nil @@ -176,7 +177,7 @@ var _ sdk.Msg = &MsgChannelOpenConfirm{} // NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance func NewMsgChannelOpenConfirm( - portID, channelID string, proofAck []byte, proofHeight uint64, + portID, channelID string, proofAck []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgChannelOpenConfirm { return &MsgChannelOpenConfirm{ @@ -209,8 +210,8 @@ func (msg MsgChannelOpenConfirm) ValidateBasic() error { if len(msg.ProofAck) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof ack") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } // Signer can be empty return nil @@ -275,7 +276,7 @@ var _ sdk.Msg = &MsgChannelCloseConfirm{} // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( - portID, channelID string, proofInit []byte, proofHeight uint64, + portID, channelID string, proofInit []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgChannelCloseConfirm { return &MsgChannelCloseConfirm{ @@ -308,8 +309,8 @@ func (msg MsgChannelCloseConfirm) ValidateBasic() error { if len(msg.ProofInit) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof init") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } // Signer can be empty return nil @@ -327,9 +328,9 @@ func (msg MsgChannelCloseConfirm) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgRecvPacket{} -// NewMsgRecvPacket constructs new MsgRecvPacket +// NewMsgPacket constructs new MsgPacket func NewMsgRecvPacket( - packet Packet, proof []byte, proofHeight uint64, + packet Packet, proof []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgRecvPacket { return &MsgRecvPacket{ @@ -350,8 +351,8 @@ func (msg MsgRecvPacket) ValidateBasic() error { if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress @@ -387,7 +388,7 @@ var _ sdk.Msg = &MsgTimeout{} // NewMsgTimeout constructs new MsgTimeout func NewMsgTimeout( packet Packet, nextSequenceRecv uint64, proof []byte, - proofHeight uint64, signer sdk.AccAddress, + proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgTimeout { return &MsgTimeout{ Packet: packet, @@ -408,8 +409,8 @@ func (msg MsgTimeout) ValidateBasic() error { if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress @@ -437,7 +438,7 @@ func (msg MsgTimeout) Type() string { func NewMsgTimeoutOnClose( packet Packet, nextSequenceRecv uint64, proof, proofClose []byte, - proofHeight uint64, signer sdk.AccAddress, + proofHeight *clienttypes.Height, signer sdk.AccAddress, ) *MsgTimeoutOnClose { return &MsgTimeoutOnClose{ Packet: packet, @@ -462,8 +463,8 @@ func (msg MsgTimeoutOnClose) ValidateBasic() error { if len(msg.ProofClose) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of closed counterparty channel end") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress @@ -491,7 +492,7 @@ var _ sdk.Msg = &MsgAcknowledgement{} // NewMsgAcknowledgement constructs a new MsgAcknowledgement func NewMsgAcknowledgement( - packet Packet, ack []byte, proof []byte, proofHeight uint64, signer sdk.AccAddress) *MsgAcknowledgement { + packet Packet, ack []byte, proof []byte, proofHeight *clienttypes.Height, signer sdk.AccAddress) *MsgAcknowledgement { return &MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, @@ -511,8 +512,8 @@ func (msg MsgAcknowledgement) ValidateBasic() error { if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if msg.ProofHeight == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") + if msg.ProofHeight.Valid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "proof height invalid: %v", msg.ProofHeight) } if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index b6c9c4774313..5d7f54d3dd05 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -36,14 +36,16 @@ const ( // define variables used for testing var ( + timeoutEpoch = uint64(0) timeoutHeight = uint64(100) timeoutTimestamp = uint64(100) disabledTimeout = uint64(0) validPacketData = []byte("testdata") unknownPacketData = []byte("unknown") - packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp) invalidPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + invalidAck = invalidAckData emptyProof = []byte{} invalidProofs1 = commitmentexported.Proof(nil) @@ -156,24 +158,24 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() { // TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry func (suite *MsgTestSuite) TestMsgChannelOpenTry() { testMsgs := []*types.MsgChannelOpenTry{ - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg - types.NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id - types.NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id - types.NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short channel id - types.NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long channel id - types.NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 1, addr), // empty counterparty version - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, addr), // suite.proof height is zero - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // invalid channel order - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection hops more than 1 - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short connection id - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long connection id - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection id contains non-alpha - types.NewMsgChannelOpenTry("testportid", "testchannel", "", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id - types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", emptyProof, 1, addr), // empty proof + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // valid msg + types.NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too short port id + types.NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too long port id + types.NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // port id contains non-alpha + types.NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too short channel id + types.NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too long channel id + types.NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // channel id contains non-alpha + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 0, 1, addr), // empty counterparty version + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 0, addr), // suite.proof height is zero + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // invalid channel order + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // connection hops more than 1 + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too short connection id + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // too long connection id + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // connection id contains non-alpha + types.NewMsgChannelOpenTry("testportid", "testchannel", "", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, 1, addr), // empty channel version + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 0, 1, addr), // invalid counterparty port id + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 0, 1, addr), // invalid counterparty channel id + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", emptyProof, 0, 1, addr), // empty proof } testCases := []struct { @@ -214,16 +216,16 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { // TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck func (suite *MsgTestSuite) TestMsgChannelOpenAck() { testMsgs := []*types.MsgChannelOpenAck{ - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg - types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id - types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id - types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 1, addr), // too short channel id - types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id - types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", emptyProof, 1, addr), // empty proof - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, 1, addr), // valid msg + types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 0, 1, addr), // too short port id + types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 0, 1, addr), // too long port id + types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 0, 1, addr), // port id contains non-alpha + types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 0, 1, addr), // too short channel id + types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 0, 1, addr), // too long channel id + types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 0, 1, addr), // channel id contains non-alpha + types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 0, 1, addr), // empty counterparty version + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", emptyProof, 0, 1, addr), // empty proof + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, 0, addr), // proof height is zero } testCases := []struct { @@ -256,15 +258,15 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { // TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { testMsgs := []*types.MsgChannelOpenConfirm{ - types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg - types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id - types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id - types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id - types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id - types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelOpenConfirm("testportid", "testchannel", emptyProof, 1, addr), // empty proof - types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, 1, addr), // valid msg + types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 0, 1, addr), // too short port id + types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 0, 1, addr), // too long port id + types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 0, 1, addr), // port id contains non-alpha + types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 0, 1, addr), // too short channel id + types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 0, 1, addr), // too long channel id + types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 0, 1, addr), // channel id contains non-alpha + types.NewMsgChannelOpenConfirm("testportid", "testchannel", emptyProof, 0, 1, addr), // empty proof + types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, 0, addr), // proof height is zero } testCases := []struct { @@ -332,15 +334,15 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() { // TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { testMsgs := []*types.MsgChannelCloseConfirm{ - types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg - types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id - types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id - types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id - types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id - types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelCloseConfirm("testportid", "testchannel", emptyProof, 1, addr), // empty proof - types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, 1, addr), // valid msg + types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 0, 1, addr), // too short port id + types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 0, 1, addr), // too long port id + types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 0, 1, addr), // port id contains non-alpha + types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 0, 1, addr), // too short channel id + types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 0, 1, addr), // too long channel id + types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 0, 1, addr), // channel id contains non-alpha + types.NewMsgChannelCloseConfirm("testportid", "testchannel", emptyProof, 0, 1, addr), // empty proof + types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, 0, addr), // proof height is zero } testCases := []struct { @@ -371,7 +373,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { // TestMsgRecvPacketType tests Type for MsgRecvPacket. func (suite *MsgTestSuite) TestMsgRecvPacketType() { - msg := types.NewMsgRecvPacket(packet, suite.proof, 1, addr1) + msg := types.NewMsgRecvPacket(packet, suite.proof, 0, 1, addr1) suite.Equal("recv_packet", msg.Type()) } @@ -379,11 +381,11 @@ func (suite *MsgTestSuite) TestMsgRecvPacketType() { // TestMsgRecvPacketValidation tests ValidateBasic for MsgRecvPacket func (suite *MsgTestSuite) TestMsgRecvPacketValidation() { testMsgs := []*types.MsgRecvPacket{ - types.NewMsgRecvPacket(packet, suite.proof, 1, addr1), // valid msg - types.NewMsgRecvPacket(packet, suite.proof, 0, addr1), // proof height is zero - types.NewMsgRecvPacket(packet, emptyProof, 1, addr1), // empty proof - types.NewMsgRecvPacket(packet, suite.proof, 1, emptyAddr), // missing signer address - types.NewMsgRecvPacket(invalidPacket, suite.proof, 1, addr1), // unknown packet + types.NewMsgRecvPacket(packet, suite.proof, 0, 1, addr1), // valid msg + types.NewMsgRecvPacket(packet, suite.proof, 0, 0, addr1), // proof height is zero + types.NewMsgRecvPacket(packet, emptyProof, 0, 1, addr1), // empty proof + types.NewMsgRecvPacket(packet, suite.proof, 0, 1, emptyAddr), // missing signer address + types.NewMsgRecvPacket(invalidPacket, suite.proof, 0, 1, addr1), // unknown packet } testCases := []struct { @@ -410,7 +412,7 @@ func (suite *MsgTestSuite) TestMsgRecvPacketValidation() { // TestMsgRecvPacketGetSignBytes tests GetSignBytes for MsgRecvPacket func (suite *MsgTestSuite) TestMsgRecvPacketGetSignBytes() { - msg := types.NewMsgRecvPacket(packet, suite.proof, 1, addr1) + msg := types.NewMsgRecvPacket(packet, suite.proof, 0, 1, addr1) res := msg.GetSignBytes() expected := fmt.Sprintf( @@ -422,7 +424,7 @@ func (suite *MsgTestSuite) TestMsgRecvPacketGetSignBytes() { // TestMsgRecvPacketGetSigners tests GetSigners for MsgRecvPacket func (suite *MsgTestSuite) TestMsgRecvPacketGetSigners() { - msg := types.NewMsgRecvPacket(packet, suite.proof, 1, addr1) + msg := types.NewMsgRecvPacket(packet, suite.proof, 0, 1, addr1) res := msg.GetSigners() expected := "[746573746164647231]" @@ -432,11 +434,11 @@ func (suite *MsgTestSuite) TestMsgRecvPacketGetSigners() { // TestMsgTimeout tests ValidateBasic for MsgTimeout func (suite *MsgTestSuite) TestMsgTimeout() { testMsgs := []*types.MsgTimeout{ - types.NewMsgTimeout(packet, 1, suite.proof, 1, addr), - types.NewMsgTimeout(packet, 1, suite.proof, 0, addr), - types.NewMsgTimeout(packet, 1, suite.proof, 1, emptyAddr), - types.NewMsgTimeout(packet, 1, emptyProof, 1, addr), - types.NewMsgTimeout(invalidPacket, 1, suite.proof, 1, addr), + types.NewMsgTimeout(packet, 1, suite.proof, 0, 1, addr), + types.NewMsgTimeout(packet, 1, suite.proof, 0, 0, addr), + types.NewMsgTimeout(packet, 1, suite.proof, 0, 1, emptyAddr), + types.NewMsgTimeout(packet, 1, emptyProof, 0, 1, addr), + types.NewMsgTimeout(invalidPacket, 1, suite.proof, 0, 1, addr), } testCases := []struct { @@ -494,11 +496,12 @@ func (suite *MsgTestSuite) TestMsgTimeoutOnClose() { // TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement func (suite *MsgTestSuite) TestMsgAcknowledgement() { testMsgs := []*types.MsgAcknowledgement{ - types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 1, addr), - types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 0, addr), - types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 1, emptyAddr), - types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 1, addr), - types.NewMsgAcknowledgement(invalidPacket, packet.GetData(), suite.proof, 1, addr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 0, 1, addr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 0, 0, addr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 0, 1, emptyAddr), + types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 0, 1, addr), + types.NewMsgAcknowledgement(invalidPacket, packet.GetData(), suite.proof, 0, 1, addr), + types.NewMsgAcknowledgement(packet, invalidAck, suite.proof, 0, 1, addr), } testCases := []struct { diff --git a/x/ibc/04-channel/types/packet.go b/x/ibc/04-channel/types/packet.go index d54a9193bc6d..df789409344a 100644 --- a/x/ibc/04-channel/types/packet.go +++ b/x/ibc/04-channel/types/packet.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -31,7 +32,7 @@ func NewPacket( data []byte, sequence uint64, sourcePort, sourceChannel, destinationPort, destinationChannel string, - timeoutHeight uint64, timeoutTimestamp uint64, + timeoutHeight *clienttypes.Height, timeoutTimestamp uint64, ) Packet { return Packet{ Data: data, @@ -63,8 +64,10 @@ func (p Packet) GetDestChannel() string { return p.DestinationChannel } // GetData implements PacketI interface func (p Packet) GetData() []byte { return p.Data } +func (p Packet) GetTimeoutEpoch() uint64 { return p.TimeoutHeight.EpochNumber } + // GetTimeoutHeight implements PacketI interface -func (p Packet) GetTimeoutHeight() uint64 { return p.TimeoutHeight } +func (p Packet) GetTimeoutHeight() uint64 { return p.TimeoutHeight.EpochHeight } // GetTimeoutTimestamp implements PacketI interface func (p Packet) GetTimeoutTimestamp() uint64 { return p.TimeoutTimestamp } @@ -86,7 +89,7 @@ func (p Packet) ValidateBasic() error { if p.Sequence == 0 { return sdkerrors.Wrap(ErrInvalidPacket, "packet sequence cannot be 0") } - if p.TimeoutHeight == 0 && p.TimeoutTimestamp == 0 { + if p.TimeoutHeight.Valid() && p.TimeoutTimestamp == 0 { return sdkerrors.Wrap(ErrInvalidPacket, "packet timeout height and packet timeout timestamp cannot both be 0") } if len(p.Data) == 0 { diff --git a/x/ibc/04-channel/types/packet_test.go b/x/ibc/04-channel/types/packet_test.go index 7d18373c67a4..1bf10d148217 100644 --- a/x/ibc/04-channel/types/packet_test.go +++ b/x/ibc/04-channel/types/packet_test.go @@ -14,16 +14,16 @@ func TestPacketValidateBasic(t *testing.T) { expPass bool errMsg string }{ - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, - {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"}, - {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"}, - {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, disabledTimeout), false, "disabled both timeout height and timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, disabledTimeout), true, "disabled timeout timestamp, valid timeout height"}, - {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), false, "invalid sequence"}, + {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), false, "invalid source port"}, + {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), false, "invalid source channel"}, + {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), false, "invalid destination port"}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutEpoch, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, disabledTimeout, disabledTimeout), false, "disabled both timeout height and timestamp"}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, disabledTimeout), true, "disabled timeout timestamp, valid timeout height"}, + {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutEpoch, timeoutHeight, timeoutTimestamp), true, ""}, } for i, tc := range testCases { diff --git a/x/ibc/04-channel/types/query.go b/x/ibc/04-channel/types/query.go index a4979dd2e535..f1aad9a7de77 100644 --- a/x/ibc/04-channel/types/query.go +++ b/x/ibc/04-channel/types/query.go @@ -10,74 +10,74 @@ import ( ) // NewQueryChannelResponse creates a new QueryChannelResponse instance -func NewQueryChannelResponse(portID, channelID string, channel Channel, proof []byte, height int64) *QueryChannelResponse { +func NewQueryChannelResponse(portID, channelID string, channel Channel, proof []byte, height *clienttypes.Height) *QueryChannelResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.ChannelPath(portID, channelID), "/")) return &QueryChannelResponse{ Channel: &channel, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryChannelClientStateResponse creates a newQueryChannelClientStateResponse instance -func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height int64) *QueryChannelClientStateResponse { +func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height *clienttypes.Height) *QueryChannelClientStateResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.FullClientPath(identifiedClientState.ClientId, host.ClientStatePath()), "/")) return &QueryChannelClientStateResponse{ IdentifiedClientState: &identifiedClientState, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryChannelConsensusStateResponse creates a newQueryChannelConsensusStateResponse instance -func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, consensusStateHeight uint64, proof []byte, height int64) *QueryChannelConsensusStateResponse { +func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, proof []byte, consensusStateHeight, height *clienttypes.Height) *QueryChannelConsensusStateResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.FullClientPath(clientID, host.ConsensusStatePath(consensusStateHeight)), "/")) return &QueryChannelConsensusStateResponse{ ConsensusState: anyConsensusState, ClientId: clientID, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryPacketCommitmentResponse creates a new QueryPacketCommitmentResponse instance func NewQueryPacketCommitmentResponse( - portID, channelID string, sequence uint64, commitment []byte, proof []byte, height int64, + portID, channelID string, sequence uint64, commitment []byte, proof []byte, height *clienttypes.Height, ) *QueryPacketCommitmentResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.PacketCommitmentPath(portID, channelID, sequence), "/")) return &QueryPacketCommitmentResponse{ Commitment: commitment, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryPacketAcknowledgementResponse creates a new QueryPacketAcknowledgementResponse instance func NewQueryPacketAcknowledgementResponse( - portID, channelID string, sequence uint64, acknowledgement []byte, proof []byte, height int64, + portID, channelID string, sequence uint64, acknowledgement []byte, proof []byte, height *clienttypes.Height, ) *QueryPacketAcknowledgementResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.PacketAcknowledgementPath(portID, channelID, sequence), "/")) return &QueryPacketAcknowledgementResponse{ Acknowledgement: acknowledgement, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } // NewQueryNextSequenceReceiveResponse creates a new QueryNextSequenceReceiveResponse instance func NewQueryNextSequenceReceiveResponse( - portID, channelID string, sequence uint64, proof []byte, height int64, + portID, channelID string, sequence uint64, proof []byte, height *clienttypes.Height, ) *QueryNextSequenceReceiveResponse { path := commitmenttypes.NewMerklePath(strings.Split(host.NextSequenceRecvPath(portID, channelID), "/")) return &QueryNextSequenceReceiveResponse{ NextSequenceReceive: sequence, Proof: proof, ProofPath: path.Pretty(), - ProofHeight: uint64(height), + ProofHeight: height, } } diff --git a/x/ibc/04-channel/types/query.pb.go b/x/ibc/04-channel/types/query.pb.go index e6f1c9abf5f2..95d03c4e394d 100644 --- a/x/ibc/04-channel/types/query.pb.go +++ b/x/ibc/04-channel/types/query.pb.go @@ -97,7 +97,7 @@ type QueryChannelResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } @@ -154,11 +154,11 @@ func (m *QueryChannelResponse) GetProofPath() string { return "" } -func (m *QueryChannelResponse) GetProofHeight() uint64 { +func (m *QueryChannelResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryChannelsRequest is the request type for the Query/Channels RPC method @@ -458,7 +458,7 @@ type QueryChannelClientStateResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryChannelClientStateResponse) Reset() { *m = QueryChannelClientStateResponse{} } @@ -515,11 +515,11 @@ func (m *QueryChannelClientStateResponse) GetProofPath() string { return "" } -func (m *QueryChannelClientStateResponse) GetProofHeight() uint64 { +func (m *QueryChannelClientStateResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryChannelConsensusStateRequest is the request type for the @@ -529,8 +529,10 @@ type QueryChannelConsensusStateRequest struct { 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"` + // epoch of the consensus state + EpochNumber uint64 `protobuf:"varint,3,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // height of the consensus state - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + EpochHeight uint64 `protobuf:"varint,4,opt,name=epoch_height,json=epochHeight,proto3" json:"epoch_height,omitempty"` } func (m *QueryChannelConsensusStateRequest) Reset() { *m = QueryChannelConsensusStateRequest{} } @@ -580,9 +582,16 @@ func (m *QueryChannelConsensusStateRequest) GetChannelId() string { return "" } -func (m *QueryChannelConsensusStateRequest) GetHeight() uint64 { +func (m *QueryChannelConsensusStateRequest) GetEpochNumber() uint64 { if m != nil { - return m.Height + return m.EpochNumber + } + return 0 +} + +func (m *QueryChannelConsensusStateRequest) GetEpochHeight() uint64 { + if m != nil { + return m.EpochHeight } return 0 } @@ -599,7 +608,7 @@ type QueryChannelConsensusStateResponse struct { // merkle proof path ProofPath string `protobuf:"bytes,4,opt,name=proof_path,json=proofPath,proto3" json:"proof_path,omitempty"` // height at which the proof was retrieved - ProofHeight uint64 `protobuf:"varint,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` + ProofHeight *types.Height `protobuf:"bytes,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryChannelConsensusStateResponse) Reset() { *m = QueryChannelConsensusStateResponse{} } @@ -663,11 +672,11 @@ func (m *QueryChannelConsensusStateResponse) GetProofPath() string { return "" } -func (m *QueryChannelConsensusStateResponse) GetProofHeight() uint64 { +func (m *QueryChannelConsensusStateResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryPacketCommitmentRequest is the request type for the @@ -746,7 +755,7 @@ type QueryPacketCommitmentResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommitmentResponse{} } @@ -803,11 +812,11 @@ func (m *QueryPacketCommitmentResponse) GetProofPath() string { return "" } -func (m *QueryPacketCommitmentResponse) GetProofHeight() uint64 { +func (m *QueryPacketCommitmentResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryPacketCommitmentsRequest is the request type for the @@ -1015,7 +1024,7 @@ type QueryPacketAcknowledgementResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketAcknowledgementResponse{} } @@ -1072,11 +1081,11 @@ func (m *QueryPacketAcknowledgementResponse) GetProofPath() string { return "" } -func (m *QueryPacketAcknowledgementResponse) GetProofHeight() uint64 { +func (m *QueryPacketAcknowledgementResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } // QueryUnrelayedPacketsRequest is the request type for the @@ -1276,7 +1285,7 @@ type QueryNextSequenceReceiveResponse struct { // 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"` + ProofHeight *types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` } func (m *QueryNextSequenceReceiveResponse) Reset() { *m = QueryNextSequenceReceiveResponse{} } @@ -1333,11 +1342,11 @@ func (m *QueryNextSequenceReceiveResponse) GetProofPath() string { return "" } -func (m *QueryNextSequenceReceiveResponse) GetProofHeight() uint64 { +func (m *QueryNextSequenceReceiveResponse) GetProofHeight() *types.Height { if m != nil { return m.ProofHeight } - return 0 + return nil } func init() { @@ -1366,86 +1375,88 @@ func init() { func init() { proto.RegisterFile("ibc/channel/query.proto", fileDescriptor_2150995751d4f15a) } var fileDescriptor_2150995751d4f15a = []byte{ - // 1250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcf, 0x6f, 0x1b, 0xc5, - 0x17, 0xef, 0xd8, 0xce, 0xaf, 0x97, 0xe8, 0x9b, 0x7c, 0x27, 0x09, 0x49, 0xdd, 0xc4, 0x75, 0x56, - 0x02, 0x42, 0x4a, 0x76, 0x69, 0x8a, 0x10, 0xaa, 0xa0, 0x52, 0x13, 0x89, 0x36, 0x48, 0xa1, 0xe9, - 0x46, 0x91, 0x9a, 0x22, 0x61, 0xd6, 0xeb, 0x89, 0xbd, 0x4a, 0xb2, 0xbb, 0xf5, 0xae, 0xdb, 0x44, - 0x91, 0x2f, 0x9c, 0x38, 0xa2, 0x72, 0xe0, 0x82, 0xe8, 0xad, 0x12, 0x17, 0xb8, 0x70, 0x46, 0x88, - 0x1f, 0x12, 0x12, 0x97, 0x4a, 0x05, 0xa9, 0x47, 0x94, 0xf0, 0x87, 0xa0, 0x9d, 0x79, 0xbb, 0xde, - 0x5d, 0xef, 0xba, 0x56, 0x1c, 0x1f, 0x38, 0x39, 0xf3, 0xe6, 0xcd, 0xbc, 0xcf, 0xe7, 0x33, 0x6f, - 0xde, 0xbc, 0x0d, 0xcc, 0x18, 0x65, 0x5d, 0xd1, 0x6b, 0x9a, 0x69, 0xb2, 0x7d, 0xe5, 0x41, 0x83, - 0xd5, 0x8f, 0x64, 0xbb, 0x6e, 0xb9, 0x16, 0x1d, 0x35, 0xca, 0xba, 0x8c, 0x13, 0x79, 0xe1, 0xb5, - 0x6f,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36, 0x57, 0x24, 0x8b, 0x39, 0x75, 0x94, 0xdb, 0x6e, 0x73, 0x93, - 0xf4, 0x49, 0x14, 0x9f, 0xe3, 0x13, 0xfe, 0x00, 0xa0, 0xa5, 0x37, 0x42, 0x7c, 0x4d, 0x16, 0x87, - 0x23, 0x7b, 0x87, 0x23, 0x8b, 0xb3, 0xc5, 0xc3, 0x91, 0x37, 0xb5, 0x2a, 0xc3, 0xb5, 0x6a, 0x68, - 0xa5, 0xf4, 0x03, 0x81, 0xe9, 0x58, 0x00, 0x54, 0xe0, 0x3a, 0x0c, 0x23, 0x39, 0x67, 0x96, 0x14, - 0xb3, 0x8b, 0xa3, 0x2b, 0x85, 0x88, 0x04, 0xeb, 0x15, 0x66, 0xba, 0xc6, 0xae, 0xc1, 0x2a, 0xbe, - 0x18, 0x81, 0x3f, 0xbd, 0x15, 0x41, 0x97, 0xe1, 0xe8, 0x5e, 0x7f, 0x29, 0x3a, 0x11, 0x38, 0x0c, - 0x8f, 0xbe, 0x02, 0x83, 0xa8, 0x8d, 0x27, 0x5e, 0x56, 0xc5, 0x91, 0xf4, 0x39, 0x81, 0x82, 0x80, - 0x6d, 0x99, 0x26, 0xd3, 0x3d, 0xdf, 0xb8, 0x42, 0x05, 0x00, 0x3d, 0x98, 0xc4, 0xac, 0x08, 0x59, - 0x62, 0x0a, 0x66, 0xce, 0xac, 0xe0, 0x8f, 0x04, 0x2e, 0xa7, 0x42, 0xf9, 0x2f, 0x68, 0x79, 0xcf, - 0x97, 0x52, 0x44, 0x5c, 0xe3, 0xd7, 0x7d, 0xcb, 0xd5, 0x5c, 0xd6, 0xeb, 0xed, 0xfa, 0x33, 0x90, - 0x26, 0x61, 0x6b, 0x94, 0x66, 0x07, 0x66, 0x8c, 0x80, 0x7d, 0x49, 0xd4, 0x9a, 0x92, 0xe3, 0xb9, - 0x60, 0x56, 0x2f, 0x08, 0xa5, 0x44, 0x11, 0x0a, 0x09, 0x15, 0xda, 0x6b, 0xda, 0x48, 0x32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x0d, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x00, 0x9a, 0x4e, 0x58, 0x14, - 0x00, 0x00, + // 1293 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x4f, 0x6c, 0x1b, 0xc5, + 0x17, 0xee, 0xd8, 0x69, 0xfe, 0x3c, 0x47, 0xbf, 0xe4, 0x37, 0x49, 0x48, 0xea, 0x26, 0x6e, 0xb2, + 0x12, 0x10, 0x52, 0xb2, 0x4b, 0x53, 0x40, 0xa8, 0x82, 0x4a, 0x4d, 0x24, 0xda, 0x20, 0xa5, 0x4d, + 0x37, 0x8a, 0xd4, 0xf4, 0x80, 0x59, 0xaf, 0x27, 0xf6, 0x2a, 0xf1, 0xee, 0xd6, 0xbb, 0x6e, 0x12, + 0x45, 0xbe, 0x70, 0xe2, 0x88, 0xca, 0x15, 0xa9, 0xe2, 0xc2, 0x85, 0x03, 0x12, 0xe2, 0xc4, 0x01, + 0xa1, 0x02, 0x12, 0x52, 0x2f, 0x95, 0x7a, 0xe1, 0x88, 0x12, 0x0e, 0x1c, 0xb8, 0x73, 0x45, 0x3b, + 0xf3, 0xc6, 0xde, 0xb5, 0x77, 0x5d, 0x2b, 0x4e, 0x23, 0x71, 0x72, 0x66, 0xe6, 0xcd, 0xbc, 0xef, + 0xfb, 0xde, 0x9b, 0x37, 0x6f, 0x03, 0x93, 0x56, 0xc1, 0xd4, 0xcc, 0xb2, 0x61, 0xdb, 0x6c, 0x57, + 0x7b, 0x50, 0x63, 0xd5, 0x03, 0xd5, 0xad, 0x3a, 0xbe, 0x43, 0x33, 0x56, 0xc1, 0x54, 0x71, 0x21, + 0x2b, 0xac, 0x76, 0x2d, 0x66, 0xfb, 0xf8, 0x23, 0xac, 0xb2, 0x0b, 0xa6, 0xe3, 0x55, 0x1c, 0x4f, + 0x2b, 0x18, 0x1e, 0x13, 0xdb, 0xb5, 0x87, 0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x66, 0x4f, 0x8a, 0xf0, 0x21, 0x40, + 0x33, 0x06, 0x08, 0xfb, 0x35, 0x55, 0x04, 0x4c, 0x0d, 0x02, 0xa6, 0x8a, 0x78, 0x63, 0xc0, 0xd4, + 0x75, 0xa3, 0xc4, 0x70, 0xaf, 0x1e, 0xda, 0xa9, 0x7c, 0x4f, 0x60, 0xa2, 0xc5, 0x01, 0xaa, 0x72, + 0x0d, 0x06, 0x91, 0xb0, 0x37, 0x45, 0x66, 0xd3, 0xf3, 0x99, 0xa5, 0x5c, 0x44, 0x96, 0xd5, 0x22, + 0xb3, 0x7d, 0x6b, 0xdb, 0x62, 0x45, 0x29, 0x50, 0xc3, 0x9e, 0xde, 0x8c, 0xa0, 0x4b, 0x71, 0x74, + 0xaf, 0xbf, 0x10, 0x9d, 0x70, 0x1c, 0x86, 0x47, 0x5f, 0x81, 0x7e, 0xd4, 0x2b, 0x10, 0x34, 0xad, + 0xe3, 0x48, 0xf9, 0x8c, 0x40, 0x4e, 0xc0, 0x76, 0x6c, 0x9b, 0x99, 0x81, 0x6d, 0xab, 0x42, 0x39, + 0x00, 0xb3, 0xb1, 0x88, 0x99, 0x12, 0x9a, 0x69, 0x51, 0x30, 0x75, 0x62, 0x05, 0x7f, 0x24, 0x70, + 0x29, 0x11, 0xca, 0x7f, 0x41, 0xcb, 0x7b, 0x52, 0x4a, 0xe1, 0x71, 0x85, 0x27, 0xe3, 0x86, 0x6f, + 0xf8, 0xac, 0xd7, 0x1b, 0xf7, 0x57, 0x43, 0x9a, 0x98, 0xa3, 0x51, 0x9a, 0x2d, 0x98, 0xb4, 0x1a, + 0xec, 0xf3, 0xe2, 0x26, 0xe4, 0xbd, 0xc0, 0x04, 0xb3, 0x7a, 0x2e, 0x7c, 0x45, 0x42, 0x42, 0x85, + 0xce, 0x9a, 0xb0, 0xe2, 0xa6, 0xcf, 0xf4, 0x9e, 0x7e, 0x45, 0x60, 0x2e, 0x42, 0x35, 0x20, 0x67, + 0x7b, 0x35, 0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x7f, 0xa5, 0xf8, 0x59, 0xf4, 0x8a, 0x3b, 0xda, 0x3e, 0x47, + 0xf0, 0xd6, 0xdb, 0x8b, 0x12, 0x84, 0x7f, 0xe0, 0x32, 0xaf, 0xd0, 0xcf, 0xbf, 0x60, 0xaf, 0xfe, + 0x1b, 0x00, 0x00, 0xff, 0xff, 0x76, 0xb7, 0x75, 0x0e, 0x21, 0x15, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1939,10 +1950,17 @@ func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2215,10 +2233,17 @@ func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2269,8 +2294,13 @@ func (m *QueryChannelConsensusStateRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if m.EpochHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochHeight)) + i-- + dAtA[i] = 0x20 + } + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) i-- dAtA[i] = 0x18 } @@ -2311,10 +2341,17 @@ func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x2a } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2414,10 +2451,17 @@ func (m *QueryPacketCommitmentResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2608,10 +2652,17 @@ func (m *QueryPacketAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2668,20 +2719,20 @@ func (m *QueryUnrelayedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, e dAtA[i] = 0x20 } if len(m.PacketCommitmentSequences) > 0 { - dAtA11 := make([]byte, len(m.PacketCommitmentSequences)*10) - var j10 int + dAtA16 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j15 int for _, num := range m.PacketCommitmentSequences { for num >= 1<<7 { - dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) + dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j10++ + j15++ } - dAtA11[j10] = uint8(num) - j10++ + dAtA16[j15] = uint8(num) + j15++ } - i -= j10 - copy(dAtA[i:], dAtA11[:j10]) - i = encodeVarintQuery(dAtA, i, uint64(j10)) + i -= j15 + copy(dAtA[i:], dAtA16[:j15]) + i = encodeVarintQuery(dAtA, i, uint64(j15)) i-- dAtA[i] = 0x1a } @@ -2728,20 +2779,20 @@ func (m *QueryUnrelayedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, dAtA[i] = 0x10 } if len(m.Sequences) > 0 { - dAtA13 := make([]byte, len(m.Sequences)*10) - var j12 int + dAtA18 := make([]byte, len(m.Sequences)*10) + var j17 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j12++ + j17++ } - dAtA13[j12] = uint8(num) - j12++ + dAtA18[j17] = uint8(num) + j17++ } - i -= j12 - copy(dAtA[i:], dAtA13[:j12]) - i = encodeVarintQuery(dAtA, i, uint64(j12)) + i -= j17 + copy(dAtA[i:], dAtA18[:j17]) + i = encodeVarintQuery(dAtA, i, uint64(j17)) i-- dAtA[i] = 0xa } @@ -2805,10 +2856,17 @@ func (m *QueryNextSequenceReceiveResponse) MarshalToSizedBuffer(dAtA []byte) (in _ = i var l int _ = l - if m.ProofHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProofHeight)) + if m.ProofHeight != nil { + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.ProofPath) > 0 { i -= len(m.ProofPath) @@ -2878,8 +2936,9 @@ func (m *QueryChannelResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -2993,8 +3052,9 @@ func (m *QueryChannelClientStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -3013,8 +3073,11 @@ func (m *QueryChannelConsensusStateRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if m.EpochHeight != 0 { + n += 1 + sovQuery(uint64(m.EpochHeight)) } return n } @@ -3041,8 +3104,9 @@ func (m *QueryChannelConsensusStateResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -3085,8 +3149,9 @@ func (m *QueryPacketCommitmentResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -3172,8 +3237,9 @@ func (m *QueryPacketAcknowledgementResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -3258,8 +3324,9 @@ func (m *QueryNextSequenceReceiveResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ProofHeight != 0 { - n += 1 + sovQuery(uint64(m.ProofHeight)) + if m.ProofHeight != nil { + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -3519,10 +3586,10 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3532,11 +3599,28 @@ func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4304,10 +4388,10 @@ func (m *QueryChannelClientStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4317,11 +4401,28 @@ func (m *QueryChannelClientStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4441,9 +4542,9 @@ func (m *QueryChannelConsensusStateRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) } - m.Height = 0 + m.EpochNumber = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4453,7 +4554,26 @@ func (m *QueryChannelConsensusStateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochHeight", wireType) + } + m.EpochHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -4646,10 +4766,10 @@ func (m *QueryChannelConsensusStateResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4659,11 +4779,28 @@ func (m *QueryChannelConsensusStateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4954,10 +5091,10 @@ func (m *QueryPacketCommitmentResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4967,11 +5104,28 @@ func (m *QueryPacketCommitmentResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5557,10 +5711,10 @@ func (m *QueryPacketAcknowledgementResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5570,11 +5724,28 @@ func (m *QueryPacketAcknowledgementResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6192,10 +6363,10 @@ func (m *QueryNextSequenceReceiveResponse) Unmarshal(dAtA []byte) error { m.ProofPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - m.ProofHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -6205,11 +6376,28 @@ func (m *QueryNextSequenceReceiveResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProofHeight |= uint64(b&0x7F) << shift + 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.ProofHeight == nil { + m.ProofHeight = &types.Height{} + } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ibc/04-channel/types/query.pb.gw.go b/x/ibc/04-channel/types/query.pb.gw.go index 520d86c54948..1181eca5aa4c 100644 --- a/x/ibc/04-channel/types/query.pb.gw.go +++ b/x/ibc/04-channel/types/query.pb.gw.go @@ -324,15 +324,26 @@ func request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) } - val, ok = pathParams["height"] + val, ok = pathParams["epoch_number"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_number") } - protoReq.Height, err = runtime.Uint64(val) + protoReq.EpochNumber, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_number", err) + } + + val, ok = pathParams["epoch_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_height") + } + + protoReq.EpochHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_height", err) } msg, err := client.ChannelConsensusState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -373,15 +384,26 @@ func local_request_Query_ChannelConsensusState_0(ctx context.Context, marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) } - val, ok = pathParams["height"] + val, ok = pathParams["epoch_number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_number") + } + + protoReq.EpochNumber, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_number", err) + } + + val, ok = pathParams["epoch_height"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_height") } - protoReq.Height, err = runtime.Uint64(val) + protoReq.EpochHeight, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_height", err) } msg, err := server.ChannelConsensusState(ctx, &protoReq) @@ -1333,7 +1355,7 @@ var ( pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "client_state"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "consensus_state", "height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 2, 8, 1, 0, 4, 1, 5, 9, 2, 10, 1, 0, 4, 1, 5, 11}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "consensus_state", "epoch", "epoch_number", "height", "epoch_height"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index 22e1a8845062..6d7bdb315ba7 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -27,7 +27,7 @@ var _ clientexported.ClientState = (*ClientState)(nil) func NewClientState( chainID string, trustLevel Fraction, trustingPeriod, ubdPeriod, maxClockDrift time.Duration, - latestHeight uint64, specs []*ics23.ProofSpec, + latestHeight *clienttypes.Height, specs []*ics23.ProofSpec, ) *ClientState { return &ClientState{ ChainId: chainID, @@ -36,7 +36,7 @@ func NewClientState( UnbondingPeriod: ubdPeriod, MaxClockDrift: maxClockDrift, LatestHeight: latestHeight, - FrozenHeight: 0, + FrozenHeight: &clienttypes.Height{}, ProofSpecs: specs, } } @@ -52,18 +52,18 @@ func (cs ClientState) ClientType() clientexported.ClientType { } // GetLatestHeight returns latest block height. -func (cs ClientState) GetLatestHeight() uint64 { +func (cs ClientState) GetLatestHeight() clientexported.Height { return cs.LatestHeight } // IsFrozen returns true if the frozen height has been set. func (cs ClientState) IsFrozen() bool { - return cs.FrozenHeight != 0 + return !cs.FrozenHeight.IsZero() } // FrozenHeight returns the height at which client is frozen // NOTE: FrozenHeight is 0 if client is unfrozen -func (cs ClientState) GetFrozenHeight() uint64 { +func (cs ClientState) GetFrozenHeight() clientexported.Height { return cs.FrozenHeight } @@ -84,8 +84,8 @@ func (cs ClientState) Validate() error { if cs.MaxClockDrift == 0 { return sdkerrors.Wrap(ErrInvalidMaxClockDrift, "max clock drift cannot be zero") } - if cs.LatestHeight == 0 { - return sdkerrors.Wrap(ErrInvalidHeaderHeight, "tendermint height cannot be zero") + if cs.LatestHeight.Valid() { + return sdkerrors.Wrapf(ErrInvalidHeaderHeight, "tendermint height invalid: %v", cs.LatestHeight) } if cs.TrustingPeriod >= cs.UnbondingPeriod { return sdkerrors.Wrapf( @@ -118,7 +118,7 @@ func (cs ClientState) VerifyClientState( store sdk.KVStore, cdc codec.BinaryMarshaler, provingRoot commitmentexported.Root, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, counterpartyClientIdentifier string, proof []byte, @@ -158,9 +158,9 @@ func (cs ClientState) VerifyClientConsensusState( store sdk.KVStore, cdc codec.BinaryMarshaler, provingRoot commitmentexported.Root, - height uint64, + height clientexported.Height, counterpartyClientIdentifier string, - consensusHeight uint64, + consensusHeight clientexported.Height, prefix commitmentexported.Prefix, proof []byte, consensusState clientexported.ConsensusState, @@ -202,7 +202,7 @@ func (cs ClientState) VerifyClientConsensusState( func (cs ClientState) VerifyConnectionState( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, connectionID string, @@ -240,7 +240,7 @@ func (cs ClientState) VerifyConnectionState( func (cs ClientState) VerifyChannelState( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -279,7 +279,7 @@ func (cs ClientState) VerifyChannelState( func (cs ClientState) VerifyPacketCommitment( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -309,7 +309,7 @@ func (cs ClientState) VerifyPacketCommitment( func (cs ClientState) VerifyPacketAcknowledgement( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -340,7 +340,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( func (cs ClientState) VerifyPacketAcknowledgementAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -369,7 +369,7 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( func (cs ClientState) VerifyNextSequenceRecv( store sdk.KVStore, cdc codec.BinaryMarshaler, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, portID, @@ -402,19 +402,22 @@ func produceVerificationArgs( store sdk.KVStore, cdc codec.BinaryMarshaler, cs ClientState, - height uint64, + height clientexported.Height, prefix commitmentexported.Prefix, proof []byte, ) (merkleProof commitmenttypes.MerkleProof, consensusState *ConsensusState, err error) { - if cs.GetLatestHeight() < height { + if cs.GetLatestHeight().LT(height) { return commitmenttypes.MerkleProof{}, nil, sdkerrors.Wrapf( sdkerrors.ErrInvalidHeight, - "client state height < proof height (%d < %d)", cs.GetLatestHeight(), height, + "client state height < proof height (%s < %s)", cs.GetLatestHeight(), height, ) } - if cs.IsFrozen() && cs.FrozenHeight <= height { - return commitmenttypes.MerkleProof{}, nil, clienttypes.ErrClientFrozen + if cs.IsFrozen() && !height.LT(cs.FrozenHeight) { + return commitmenttypes.MerkleProof{}, nil, sdkerrors.Wrapf( + sdkerrors.ErrInvalidHeight, + "frozen client frozen height <= proof height (%s <= %s)", cs.FrozenHeight, height, + ) } if prefix == nil { diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index fad950bc1edc..440035957af4 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -130,7 +130,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { }, { name: "client is frozen", - clientState: &types.ClientState{LatestHeight: height, FrozenHeight: height - 1}, + clientState: &types.ClientState{LatestHeight: height, FrozenHeight: clientexported.NewHeight(0, height.EpochHeight-1)}, consensusState: types.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), }, @@ -190,12 +190,12 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { @@ -268,12 +268,12 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { @@ -347,12 +347,12 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { @@ -429,12 +429,12 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { @@ -517,12 +517,12 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { @@ -604,12 +604,12 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { }, { "latest client height < height", func() { - proofHeight = clientState.LatestHeight + 1 + proofHeight = clientexported.NewHeight(0, clientState.LatestHeight.EpochHeight+1) }, false, }, { "client is frozen", func() { - clientState.FrozenHeight = 1 + clientState.FrozenHeight = clientexported.NewHeight(0, 1) }, false, }, { diff --git a/x/ibc/07-tendermint/types/consensus_state.go b/x/ibc/07-tendermint/types/consensus_state.go index 6f5b6a3907ef..6296d2eedf28 100644 --- a/x/ibc/07-tendermint/types/consensus_state.go +++ b/x/ibc/07-tendermint/types/consensus_state.go @@ -15,7 +15,7 @@ import ( // NewConsensusState creates a new ConsensusState instance. func NewConsensusState( - timestamp time.Time, root commitmenttypes.MerkleRoot, height uint64, + timestamp time.Time, root commitmenttypes.MerkleRoot, height *clienttypes.Height, nextValsHash tmbytes.HexBytes, ) *ConsensusState { return &ConsensusState{ @@ -37,7 +37,7 @@ func (cs ConsensusState) GetRoot() commitmentexported.Root { } // GetHeight returns the height for the specific consensus state -func (cs ConsensusState) GetHeight() uint64 { +func (cs ConsensusState) GetHeight() clientexported.Height { return cs.Height } @@ -54,8 +54,8 @@ func (cs ConsensusState) ValidateBasic() error { if err := tmtypes.ValidateHash(cs.NextValidatorsHash); err != nil { return sdkerrors.Wrap(err, "next validators hash is invalid") } - if cs.Height == 0 { - return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "height cannot be 0") + if cs.Height.EpochHeight == 0 { + return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "epoch-height cannot be 0") } if cs.Timestamp.IsZero() { return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be zero Unix time") diff --git a/x/ibc/07-tendermint/types/consensus_state_test.go b/x/ibc/07-tendermint/types/consensus_state_test.go index 3bb0a2d5b54c..a303c417f6ed 100644 --- a/x/ibc/07-tendermint/types/consensus_state_test.go +++ b/x/ibc/07-tendermint/types/consensus_state_test.go @@ -50,7 +50,7 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { {"height is 0", &types.ConsensusState{ Timestamp: suite.now, - Height: 0, + Height: clientexported.NewHeight(0, 0), Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, diff --git a/x/ibc/07-tendermint/types/header.go b/x/ibc/07-tendermint/types/header.go index d69361edaa26..fae794fda931 100644 --- a/x/ibc/07-tendermint/types/header.go +++ b/x/ibc/07-tendermint/types/header.go @@ -21,8 +21,13 @@ func (h Header) ClientType() clientexported.ClientType { // ConsensusState returns the updated consensus state associated with the header func (h Header) ConsensusState() *ConsensusState { + height := h.GetHeight() + var tmHeight *clienttypes.Height + if height != nil { + tmHeight, _ = height.(*clienttypes.Height) + } return &ConsensusState{ - Height: h.GetHeight(), + Height: tmHeight, Timestamp: h.GetTime(), Root: commitmenttypes.NewMerkleRoot(h.Header.GetAppHash()), NextValidatorsHash: h.Header.NextValidatorsHash, @@ -33,12 +38,12 @@ func (h Header) ConsensusState() *ConsensusState { // header is nil. // // NOTE: also referred as `sequence` -func (h Header) GetHeight() uint64 { - if h.Header == nil { - return 0 +func (h Header) GetHeight() clientexported.Height { + if h.SignedHeader == nil { + return nil } - - return uint64(h.Header.Height) + // TODO: retrieve epoch number from chain-id + return clienttypes.NewHeight(0, uint64(h.Header.Height)) } // GetTime returns the current block timestamp. It returns a zero time if @@ -71,8 +76,8 @@ func (h Header) ValidateBasic(chainID string) error { // TrustedHeight is less than Header for updates // and less than or equal to Header for misbehaviour - if h.TrustedHeight > h.GetHeight() { - return sdkerrors.Wrapf(ErrInvalidHeaderHeight, "TrustedHeight %d must be less than or equal to header height %d", + if h.TrustedHeight.GT(h.GetHeight()) { + return sdkerrors.Wrapf(ErrInvalidHeaderHeight, "TrustedHeight %s must be less than or equal to header height %s", h.TrustedHeight, h.GetHeight()) } diff --git a/x/ibc/07-tendermint/types/header_test.go b/x/ibc/07-tendermint/types/header_test.go index bd8dd2221bfc..b574250d0647 100644 --- a/x/ibc/07-tendermint/types/header_test.go +++ b/x/ibc/07-tendermint/types/header_test.go @@ -45,7 +45,8 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { chainID = "chainid" }, false}, {"trusted height is greater than header height", func() { - header.TrustedHeight = header.GetHeight() + 1 + header.TrustedHeight = header.GetHeight() + header.TrustedHeight.EpochHeight++ }, false}, {"validator set nil", func() { header.ValidatorSet = nil diff --git a/x/ibc/07-tendermint/types/misbehaviour.go b/x/ibc/07-tendermint/types/misbehaviour.go index 4d13ebc59fc8..1e47989a3d39 100644 --- a/x/ibc/07-tendermint/types/misbehaviour.go +++ b/x/ibc/07-tendermint/types/misbehaviour.go @@ -70,11 +70,19 @@ func (misbehaviour Misbehaviour) Hash() tmbytes.HexBytes { return tmhash.Sum(bz) } -// GetHeight returns the height at which misbehaviour occurred +// GetHeight returns the epoch-height at which misbehaviour occurred +// This satisfies the evidenceexported.Evidence interface // // NOTE: assumes that misbehaviour headers have the same height func (misbehaviour Misbehaviour) GetHeight() int64 { - return int64(math.Min(float64(misbehaviour.Header1.GetHeight()), float64(misbehaviour.Header2.GetHeight()))) + return misbehaviour.Header1.Header.Height +} + +// GetIBCHeight returns the IBC Height at which the misbehaviour occurred +// +// NOTE: assumes that misbehaviour headers have the same height +func (misbehaviour Misbehaviour) GetIBCHeight() clientexported.Height { + return misbehaviour.Header1.GetHeight() } // GetTime returns the timestamp at which misbehaviour occurred. It uses the @@ -93,11 +101,11 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { if misbehaviour.Header2 == nil { return sdkerrors.Wrap(ErrInvalidHeader, "misbehaviour Header2 cannot be nil") } - if misbehaviour.Header1.TrustedHeight == 0 { - return sdkerrors.Wrap(ErrInvalidHeaderHeight, "misbehaviour Header1 must have non-zero trusted height") + if misbehaviour.Header1.TrustedHeight.Valid() { + return sdkerrors.Wrapf(ErrInvalidHeaderHeight, "misbehaviour Header1 has invalid trusted height: %v", misbehaviour.Header1.TrustedHeight) } - if misbehaviour.Header2.TrustedHeight == 0 { - return sdkerrors.Wrap(ErrInvalidHeaderHeight, "misbehaviour Header2 must have non-zero trusted height") + if misbehaviour.Header2.TrustedHeight.Valid() { + return sdkerrors.Wrapf(ErrInvalidHeaderHeight, "misbehaviour Header2 has invalid trusted height: %v", misbehaviour.Header2.TrustedHeight) } if misbehaviour.Header1.TrustedValidators == nil { return sdkerrors.Wrap(ErrInvalidValidatorSet, "trusted validator set in Header1 cannot be empty") @@ -124,8 +132,8 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { ) } // Ensure that Heights are the same - if misbehaviour.Header1.GetHeight() != misbehaviour.Header2.GetHeight() { - return sdkerrors.Wrapf(clienttypes.ErrInvalidMisbehaviour, "headers in misbehaviour are on different heights (%d ≠ %d)", misbehaviour.Header1.GetHeight(), misbehaviour.Header2.GetHeight()) + if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) { + return sdkerrors.Wrapf(clienttypes.ErrInvalidMisbehaviour, "headers in misbehaviour are on different heights (%s ≠ %s)", misbehaviour.Header1.GetHeight(), misbehaviour.Header2.GetHeight()) } blockID1, err := tmtypes.BlockIDFromProto(&misbehaviour.Header1.SignedHeader.Commit.BlockID) diff --git a/x/ibc/07-tendermint/types/misbehaviour_handle.go b/x/ibc/07-tendermint/types/misbehaviour_handle.go index 26266341ef10..a1bca2a4ade9 100644 --- a/x/ibc/07-tendermint/types/misbehaviour_handle.go +++ b/x/ibc/07-tendermint/types/misbehaviour_handle.go @@ -27,7 +27,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( ) (clientexported.ClientState, error) { // If client is already frozen at earlier height than misbehaviour, return with error - if cs.IsFrozen() && cs.FrozenHeight <= uint64(misbehaviour.GetHeight()) { + if cs.IsFrozen() && !cs.FrozenHeight.GT(misbehaviour.GetIBCHeight()) { return nil, sdkerrors.Wrapf(clienttypes.ErrInvalidMisbehaviour, "client is already frozen at earlier height %d than misbehaviour height %d", cs.FrozenHeight, misbehaviour.GetHeight()) } @@ -56,7 +56,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( infractionHeight := tmEvidence.GetHeight() infractionTime := tmEvidence.GetTime() ageDuration := ctx.BlockTime().Sub(infractionTime) - ageBlocks := int64(cs.LatestHeight) - infractionHeight + ageBlocks := int64(cs.LatestHeight.EpochHeight) - infractionHeight // TODO: Retrieve consensusparams from client state and not context // Issue #6516: https://github.com/cosmos/cosmos-sdk/issues/6516 @@ -96,7 +96,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( return nil, sdkerrors.Wrap(err, "verifying Header2 in Misbehaviour failed") } - cs.FrozenHeight = uint64(tmEvidence.GetHeight()) + cs.FrozenHeight = tmEvidence.GetIBCHeight().(*clienttypes.Height) return &cs, nil } diff --git a/x/ibc/07-tendermint/types/msgs.go b/x/ibc/07-tendermint/types/msgs.go index e93239e2f178..0ca01c8642e2 100644 --- a/x/ibc/07-tendermint/types/msgs.go +++ b/x/ibc/07-tendermint/types/msgs.go @@ -11,6 +11,7 @@ import ( evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -117,7 +118,7 @@ func (msg MsgCreateClient) GetConsensusState() clientexported.ConsensusState { return &ConsensusState{ Timestamp: msg.Header.GetTime(), Root: root, - Height: msg.Header.GetHeight(), + Height: msg.Header.GetHeight().(*clienttypes.Height), NextValidatorsHash: msg.Header.Header.NextValidatorsHash, } } @@ -126,7 +127,7 @@ func (msg MsgCreateClient) GetConsensusState() clientexported.ConsensusState { func (msg MsgCreateClient) InitializeClientState() clientexported.ClientState { return NewClientState(msg.Header.Header.GetChainID(), msg.TrustLevel, msg.TrustingPeriod, msg.UnbondingPeriod, msg.MaxClockDrift, - msg.Header.GetHeight(), msg.ProofSpecs, + msg.Header.GetHeight().(*clienttypes.Height), msg.ProofSpecs, ) } diff --git a/x/ibc/07-tendermint/types/store.go b/x/ibc/07-tendermint/types/store.go index e218c3b97192..4ea705a4cd29 100644 --- a/x/ibc/07-tendermint/types/store.go +++ b/x/ibc/07-tendermint/types/store.go @@ -11,7 +11,7 @@ import ( // GetConsensusState retrieves the consensus state from the client prefixed // store. An error is returned if the consensus state does not exist. -func GetConsensusState(store sdk.KVStore, cdc codec.BinaryMarshaler, height uint64) (*ConsensusState, error) { +func GetConsensusState(store sdk.KVStore, cdc codec.BinaryMarshaler, height clientexported.Height) (*ConsensusState, error) { bz := store.Get(host.KeyConsensusState(height)) if bz == nil { return nil, sdkerrors.Wrapf( diff --git a/x/ibc/07-tendermint/types/tendermint.pb.go b/x/ibc/07-tendermint/types/tendermint.pb.go index 28ed8dd574b8..94048c4326bc 100644 --- a/x/ibc/07-tendermint/types/tendermint.pb.go +++ b/x/ibc/07-tendermint/types/tendermint.pb.go @@ -7,14 +7,15 @@ import ( fmt "fmt" _go "github.com/confio/ics23/go" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + types "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" github_com_tendermint_tendermint_libs_bytes "github.com/tendermint/tendermint/libs/bytes" - types1 "github.com/tendermint/tendermint/proto/tendermint/types" + types2 "github.com/tendermint/tendermint/proto/tendermint/types" io "io" math "math" math_bits "math/bits" @@ -46,9 +47,9 @@ type ClientState struct { // defines how much new (untrusted) header's Time can drift into the future. MaxClockDrift time.Duration `protobuf:"bytes,5,opt,name=max_clock_drift,json=maxClockDrift,proto3,stdduration" json:"max_clock_drift" yaml:"max_clock_drift"` // Block height when the client was frozen due to a misbehaviour - FrozenHeight uint64 `protobuf:"varint,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height,omitempty" yaml:"frozen_height"` + FrozenHeight *types.Height `protobuf:"bytes,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height,omitempty" yaml:"frozen_height"` // Latest height the client was updated to - LatestHeight uint64 `protobuf:"varint,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty" yaml:"latest_height"` + LatestHeight *types.Height `protobuf:"bytes,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty" yaml:"latest_height"` // Proof specifications used in verifying counterparty state ProofSpecs []*_go.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"` } @@ -92,9 +93,9 @@ type ConsensusState struct { // was stored. Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` // commitment root (i.e app hash) - Root types.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` + Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` // height at which the consensus state was stored. - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height *types.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height,omitempty"` NextValidatorsHash github_com_tendermint_tendermint_libs_bytes.HexBytes `protobuf:"bytes,4,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"` } @@ -185,10 +186,10 @@ var xxx_messageInfo_Misbehaviour proto.InternalMessageInfo // hash to TrustedConsensusState.NextValidatorsHash since that is the last // trusted validator set at the TrustedHeight. type Header struct { - *types1.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty" yaml:"signed_header"` - ValidatorSet *types1.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` - TrustedHeight uint64 `protobuf:"varint,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height,omitempty" yaml:"trusted_height"` - TrustedValidators *types1.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` + *types2.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty" yaml:"signed_header"` + ValidatorSet *types2.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` + TrustedHeight *types.Height `protobuf:"bytes,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height,omitempty" yaml:"trusted_height"` + TrustedValidators *types2.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` } func (m *Header) Reset() { *m = Header{} } @@ -224,21 +225,21 @@ func (m *Header) XXX_DiscardUnknown() { var xxx_messageInfo_Header proto.InternalMessageInfo -func (m *Header) GetValidatorSet() *types1.ValidatorSet { +func (m *Header) GetValidatorSet() *types2.ValidatorSet { if m != nil { return m.ValidatorSet } return nil } -func (m *Header) GetTrustedHeight() uint64 { +func (m *Header) GetTrustedHeight() *types.Height { if m != nil { return m.TrustedHeight } - return 0 + return nil } -func (m *Header) GetTrustedValidators() *types1.ValidatorSet { +func (m *Header) GetTrustedValidators() *types2.ValidatorSet { if m != nil { return m.TrustedValidators } @@ -438,76 +439,77 @@ func init() { func init() { proto.RegisterFile("ibc/tendermint/tendermint.proto", fileDescriptor_76a953d5a747dd66) } var fileDescriptor_76a953d5a747dd66 = []byte{ - // 1096 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0x67, 0x8d, 0x31, 0x66, 0x6c, 0xfe, 0x74, 0x42, 0xa9, 0x21, 0xd4, 0x6b, 0x6d, 0x2f, 0x5c, - 0x58, 0x17, 0x27, 0x6a, 0x25, 0xa4, 0x4a, 0xc9, 0x12, 0x55, 0x50, 0x15, 0x95, 0x0e, 0x4d, 0x2b, - 0x55, 0xaa, 0x56, 0xeb, 0xdd, 0xb1, 0x3d, 0x62, 0x77, 0xc7, 0xda, 0x19, 0x23, 0xe8, 0x27, 0x48, - 0x6f, 0x39, 0xe6, 0xd8, 0x7c, 0x87, 0xaa, 0xdf, 0xa0, 0x52, 0x8e, 0x1c, 0x7b, 0xda, 0x56, 0xf0, - 0x0d, 0x7c, 0xe4, 0x54, 0xed, 0xcc, 0xec, 0x1f, 0x1b, 0x94, 0x34, 0x51, 0xc2, 0x05, 0xe6, 0xfd, - 0xfb, 0xbd, 0x99, 0xe7, 0xdf, 0x7b, 0x6f, 0x81, 0x4e, 0xba, 0x6e, 0x9b, 0xe3, 0xd0, 0xc3, 0x51, - 0x40, 0x42, 0x5e, 0x38, 0x9a, 0xc3, 0x88, 0x72, 0x0a, 0x97, 0x48, 0xd7, 0x35, 0x73, 0xed, 0x46, - 0xab, 0xe8, 0x7c, 0x3e, 0xc4, 0xac, 0x7d, 0xea, 0xf8, 0xc4, 0x73, 0x38, 0x8d, 0x64, 0xc4, 0xc6, - 0xe6, 0x0d, 0x0f, 0xf1, 0x57, 0x59, 0xef, 0xb9, 0x34, 0xec, 0x11, 0xda, 0x1e, 0x46, 0x94, 0xf6, - 0x52, 0x65, 0xb3, 0x4f, 0x69, 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0x3f, 0xdf, 0xbb, 0x15, 0x41, 0xda, 0x07, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, - 0xbf, 0xdb, 0xea, 0x9e, 0x2c, 0x0c, 0x00, 0x00, + // 1113 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4d, 0x4f, 0x1b, 0xc7, + 0x1b, 0x67, 0x6d, 0x30, 0x66, 0x6c, 0x5e, 0xfe, 0x13, 0xfe, 0xc4, 0x10, 0xea, 0x45, 0xdb, 0x0b, + 0xaa, 0xc4, 0xba, 0x38, 0x51, 0x2b, 0x71, 0x6a, 0x96, 0xa8, 0x82, 0xaa, 0xa8, 0x64, 0x48, 0x5a, + 0xa9, 0x52, 0xb5, 0x5a, 0xef, 0x8e, 0xed, 0x11, 0xbb, 0x3b, 0xd6, 0xce, 0x18, 0x41, 0x3f, 0x41, + 0x7b, 0xa9, 0x72, 0xcc, 0xb1, 0xf9, 0x06, 0x3d, 0xf5, 0x1b, 0x54, 0xe2, 0xc8, 0xb1, 0xa7, 0x6d, + 0x05, 0xdf, 0xc0, 0xc7, 0x9c, 0xaa, 0x9d, 0x99, 0x7d, 0xb1, 0xa1, 0x24, 0x8d, 0x12, 0x2e, 0x78, + 0xe6, 0x79, 0x9e, 0xdf, 0xef, 0x99, 0x79, 0xe6, 0x79, 0x59, 0x80, 0x4e, 0x3a, 0x6e, 0x8b, 0xe3, + 0xd0, 0xc3, 0x51, 0x40, 0x42, 0x5e, 0x58, 0x9a, 0x83, 0x88, 0x72, 0x0a, 0x17, 0x48, 0xc7, 0x35, + 0x73, 0xe9, 0xda, 0x46, 0xd1, 0xf8, 0x6c, 0x80, 0x59, 0xeb, 0xc4, 0xf1, 0x89, 0xe7, 0x70, 0x1a, + 0x49, 0xc4, 0xda, 0xfa, 0x35, 0x0b, 0xf1, 0x57, 0x69, 0xef, 0xb9, 0x34, 0xec, 0x12, 0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 0xa9, 0x3f, 0xaf, 0x9a, 0x53, 0xdf, 0x7f, 0x76, 0x2b, 0xf3, 0x69, 0x2b, 0xf9, 0x26, 0xff, + 0xf4, 0xf3, 0xad, 0xc9, 0xff, 0x13, 0x3a, 0x15, 0x91, 0xb4, 0x0f, 0xff, 0x09, 0x00, 0x00, 0xff, + 0xff, 0x1c, 0x9e, 0xe7, 0x7b, 0x95, 0x0c, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -544,38 +546,52 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x42 } } - if m.LatestHeight != 0 { - i = encodeVarintTendermint(dAtA, i, uint64(m.LatestHeight)) + if m.LatestHeight != nil { + { + size, err := m.LatestHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x38 + dAtA[i] = 0x3a } - if m.FrozenHeight != 0 { - i = encodeVarintTendermint(dAtA, i, uint64(m.FrozenHeight)) + if m.FrozenHeight != nil { + { + size, err := m.FrozenHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x30 + dAtA[i] = 0x32 } - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) - if err1 != nil { - return 0, err1 + n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) + if err3 != nil { + return 0, err3 } - i -= n1 - i = encodeVarintTendermint(dAtA, i, uint64(n1)) + i -= n3 + i = encodeVarintTendermint(dAtA, i, uint64(n3)) i-- dAtA[i] = 0x2a - n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err2 != nil { - return 0, err2 + n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err4 != nil { + return 0, err4 } - i -= n2 - i = encodeVarintTendermint(dAtA, i, uint64(n2)) + i -= n4 + i = encodeVarintTendermint(dAtA, i, uint64(n4)) i-- dAtA[i] = 0x22 - n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) - if err3 != nil { - return 0, err3 + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) + if err5 != nil { + return 0, err5 } - i -= n3 - i = encodeVarintTendermint(dAtA, i, uint64(n3)) + i -= n5 + i = encodeVarintTendermint(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x1a { @@ -625,10 +641,17 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.Height != 0 { - i = encodeVarintTendermint(dAtA, i, uint64(m.Height)) + if m.Height != nil { + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } { size, err := m.Root.MarshalToSizedBuffer(dAtA[:i]) @@ -640,12 +663,12 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err6 != nil { - return 0, err6 + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) + if err9 != nil { + return 0, err9 } - i -= n6 - i = encodeVarintTendermint(dAtA, i, uint64(n6)) + i -= n9 + i = encodeVarintTendermint(dAtA, i, uint64(n9)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -744,10 +767,17 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.TrustedHeight != 0 { - i = encodeVarintTendermint(dAtA, i, uint64(m.TrustedHeight)) + if m.TrustedHeight != nil { + { + size, err := m.TrustedHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } if m.ValidatorSet != nil { { @@ -850,28 +880,28 @@ func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - n12, err12 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) - if err12 != nil { - return 0, err12 + n16, err16 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) + if err16 != nil { + return 0, err16 } - i -= n12 - i = encodeVarintTendermint(dAtA, i, uint64(n12)) + i -= n16 + i = encodeVarintTendermint(dAtA, i, uint64(n16)) i-- dAtA[i] = 0x32 - n13, err13 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err13 != nil { - return 0, err13 + n17, err17 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err17 != nil { + return 0, err17 } - i -= n13 - i = encodeVarintTendermint(dAtA, i, uint64(n13)) + i -= n17 + i = encodeVarintTendermint(dAtA, i, uint64(n17)) i-- dAtA[i] = 0x2a - n14, err14 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) - if err14 != nil { - return 0, err14 + n18, err18 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) + if err18 != nil { + return 0, err18 } - i -= n14 - i = encodeVarintTendermint(dAtA, i, uint64(n14)) + i -= n18 + i = encodeVarintTendermint(dAtA, i, uint64(n18)) i-- dAtA[i] = 0x22 { @@ -1026,11 +1056,13 @@ func (m *ClientState) Size() (n int) { n += 1 + l + sovTendermint(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift) n += 1 + l + sovTendermint(uint64(l)) - if m.FrozenHeight != 0 { - n += 1 + sovTendermint(uint64(m.FrozenHeight)) + if m.FrozenHeight != nil { + l = m.FrozenHeight.Size() + n += 1 + l + sovTendermint(uint64(l)) } - if m.LatestHeight != 0 { - n += 1 + sovTendermint(uint64(m.LatestHeight)) + if m.LatestHeight != nil { + l = m.LatestHeight.Size() + n += 1 + l + sovTendermint(uint64(l)) } if len(m.ProofSpecs) > 0 { for _, e := range m.ProofSpecs { @@ -1051,8 +1083,9 @@ func (m *ConsensusState) Size() (n int) { n += 1 + l + sovTendermint(uint64(l)) l = m.Root.Size() n += 1 + l + sovTendermint(uint64(l)) - if m.Height != 0 { - n += 1 + sovTendermint(uint64(m.Height)) + if m.Height != nil { + l = m.Height.Size() + n += 1 + l + sovTendermint(uint64(l)) } l = len(m.NextValidatorsHash) if l > 0 { @@ -1100,8 +1133,9 @@ func (m *Header) Size() (n int) { l = m.ValidatorSet.Size() n += 1 + l + sovTendermint(uint64(l)) } - if m.TrustedHeight != 0 { - n += 1 + sovTendermint(uint64(m.TrustedHeight)) + if m.TrustedHeight != nil { + l = m.TrustedHeight.Size() + n += 1 + l + sovTendermint(uint64(l)) } if m.TrustedValidators != nil { l = m.TrustedValidators.Size() @@ -1398,10 +1432,10 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 6: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FrozenHeight", wireType) } - m.FrozenHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1411,16 +1445,33 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.FrozenHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FrozenHeight == nil { + m.FrozenHeight = &types.Height{} + } + if err := m.FrozenHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 7: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LatestHeight", wireType) } - m.LatestHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1430,11 +1481,28 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LatestHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.LatestHeight == nil { + m.LatestHeight = &types.Height{} + } + if err := m.LatestHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofSpecs", wireType) @@ -1589,10 +1657,10 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1602,11 +1670,28 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Height == nil { + m.Height = &types.Height{} + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NextValidatorsHash", wireType) @@ -1913,7 +1998,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.SignedHeader == nil { - m.SignedHeader = &types1.SignedHeader{} + m.SignedHeader = &types2.SignedHeader{} } if err := m.SignedHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1949,17 +2034,17 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.ValidatorSet == nil { - m.ValidatorSet = &types1.ValidatorSet{} + m.ValidatorSet = &types2.ValidatorSet{} } if err := m.ValidatorSet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TrustedHeight", wireType) } - m.TrustedHeight = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1969,11 +2054,28 @@ func (m *Header) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TrustedHeight |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TrustedHeight == nil { + m.TrustedHeight = &types.Height{} + } + if err := m.TrustedHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TrustedValidators", wireType) @@ -2004,7 +2106,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.TrustedValidators == nil { - m.TrustedValidators = &types1.ValidatorSet{} + m.TrustedValidators = &types2.ValidatorSet{} } if err := m.TrustedValidators.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/ibc/07-tendermint/types/tendermint_test.go b/x/ibc/07-tendermint/types/tendermint_test.go index 894a589e50bf..a1fd55fde09f 100644 --- a/x/ibc/07-tendermint/types/tendermint_test.go +++ b/x/ibc/07-tendermint/types/tendermint_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -25,6 +26,8 @@ const ( maxClockDrift time.Duration = time.Second * 10 ) +var height = clientexported.NewHeight(0, 4) + type TendermintTestSuite struct { suite.Suite diff --git a/x/ibc/07-tendermint/types/test_utils.go b/x/ibc/07-tendermint/types/test_utils.go index b06461ea2822..482c444489c1 100644 --- a/x/ibc/07-tendermint/types/test_utils.go +++ b/x/ibc/07-tendermint/types/test_utils.go @@ -4,6 +4,8 @@ import ( "bytes" "time" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/proto/tendermint/version" @@ -22,16 +24,17 @@ func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.Bl } // CreateTestHeader creates a mock header for testing only. -func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) *Header { +func CreateTestHeader(chainID string, height, trustedHeight clientexported.Height, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) *Header { var ( valSet *tmproto.ValidatorSet trustedVals *tmproto.ValidatorSet ) vsetHash := tmValSet.Hash() + epochHeight := int64(height.(*clienttypes.Height).EpochHeight) tmHeader := tmtypes.Header{ Version: version.Consensus{Block: 2, App: 2}, ChainID: chainID, - Height: height, + Height: epochHeight, Time: timestamp, LastBlockID: MakeBlockID(make([]byte, tmhash.Size), 10_000, make([]byte, tmhash.Size)), LastCommitHash: tmhash.Sum([]byte("last_commit_hash")), @@ -47,8 +50,8 @@ func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp tim hhash := tmHeader.Hash() blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chainID, height, 1, tmproto.PrecommitType, tmValSet) - commit, err := tmtypes.MakeCommit(blockID, height, 1, voteSet, signers, timestamp) + voteSet := tmtypes.NewVoteSet(chainID, epochHeight, 1, tmproto.PrecommitType, tmValSet) + commit, err := tmtypes.MakeCommit(blockID, epochHeight, 1, voteSet, signers, timestamp) if err != nil { panic(err) } @@ -75,7 +78,7 @@ func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp tim return &Header{ SignedHeader: &signedHeader, ValidatorSet: valSet, - TrustedHeight: uint64(trustedHeight), + TrustedHeight: trustedHeight.(*clienttypes.Height), TrustedValidators: trustedVals, } } diff --git a/x/ibc/07-tendermint/types/update.go b/x/ibc/07-tendermint/types/update.go index 911b65b82113..d05ff2be788f 100644 --- a/x/ibc/07-tendermint/types/update.go +++ b/x/ibc/07-tendermint/types/update.go @@ -115,7 +115,7 @@ func checkValidity( } // assert header height is newer than consensus state - if header.GetHeight() <= consState.Height { + if header.GetHeight().GT(consState.Height) { return sdkerrors.Wrapf( clienttypes.ErrInvalidHeader, "header height ≤ consensus state height (%d ≤ %d)", header.GetHeight(), consState.Height, @@ -125,7 +125,7 @@ func checkValidity( // Construct a trusted header using the fields in consensus state // Only Height, Time, and NextValidatorsHash are necessary for verification trustedHeader := tmtypes.Header{ - Height: int64(consState.Height), + Height: int64(consState.Height.EpochHeight), Time: consState.Timestamp, NextValidatorsHash: consState.NextValidatorsHash, } @@ -151,11 +151,11 @@ func checkValidity( // update the consensus state from a new header func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) { - if header.GetHeight() > clientState.LatestHeight { - clientState.LatestHeight = header.GetHeight() + if header.GetHeight().GT(clientState.LatestHeight) { + clientState.LatestHeight = header.GetHeight().(*clienttypes.Height) } consensusState := &ConsensusState{ - Height: header.GetHeight(), + Height: header.GetHeight().(*clienttypes.Height), Timestamp: header.GetTime(), Root: commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), NextValidatorsHash: header.Header.NextValidatorsHash, diff --git a/x/ibc/09-localhost/types/client_state.go b/x/ibc/09-localhost/types/client_state.go index 74e4b1a6f123..9a5bff321b37 100644 --- a/x/ibc/09-localhost/types/client_state.go +++ b/x/ibc/09-localhost/types/client_state.go @@ -42,8 +42,9 @@ func (cs ClientState) ClientType() clientexported.ClientType { } // GetLatestHeight returns the latest height stored. -func (cs ClientState) GetLatestHeight() uint64 { - return cs.Height +func (cs ClientState) GetLatestHeight() clientexported.Height { + // Currently only support epoch-0 + return clienttypes.NewHeight(0, uint64(cs.Height)) } // IsFrozen returns false. @@ -52,8 +53,8 @@ func (cs ClientState) IsFrozen() bool { } // GetFrozenHeight returns 0. -func (cs ClientState) GetFrozenHeight() uint64 { - return 0 +func (cs ClientState) GetFrozenHeight() clientexported.Height { + return clienttypes.NewHeight(0, 0) } // Validate performs a basic validation of the client state fields. @@ -61,7 +62,7 @@ func (cs ClientState) Validate() error { if strings.TrimSpace(cs.ChainId) == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidChainID, "chain id cannot be blank") } - if cs.Height <= 0 { + if cs.Height == 0 { return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "height must be positive: %d", cs.Height) } return nil @@ -94,7 +95,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // VerifyClientState verifies that the localhost client state is stored locally func (cs ClientState) VerifyClientState( store sdk.KVStore, cdc codec.BinaryMarshaler, _ commitmentexported.Root, - _ uint64, _ commitmentexported.Prefix, _ string, _ []byte, clientState clientexported.ClientState, + _ clientexported.Height, _ commitmentexported.Prefix, _ string, _ []byte, clientState clientexported.ClientState, ) error { path := host.KeyClientState() bz := store.Get(path) @@ -118,7 +119,7 @@ func (cs ClientState) VerifyClientState( // states. func (cs ClientState) VerifyClientConsensusState( sdk.KVStore, codec.BinaryMarshaler, commitmentexported.Root, - uint64, string, uint64, commitmentexported.Prefix, []byte, clientexported.ConsensusState, + clientexported.Height, string, clientexported.Height, commitmentexported.Prefix, []byte, clientexported.ConsensusState, ) error { return nil } @@ -128,8 +129,8 @@ func (cs ClientState) VerifyClientConsensusState( func (cs ClientState) VerifyConnectionState( store sdk.KVStore, cdc codec.BinaryMarshaler, - _ uint64, - _ commitmentexported.Prefix, + _ clientexported.Height, + prefix commitmentexported.Prefix, _ []byte, connectionID string, connectionEnd connectionexported.ConnectionI, @@ -161,7 +162,7 @@ func (cs ClientState) VerifyConnectionState( func (cs ClientState) VerifyChannelState( store sdk.KVStore, cdc codec.BinaryMarshaler, - _ uint64, + _ clientexported.Height, prefix commitmentexported.Prefix, _ []byte, portID, @@ -195,8 +196,8 @@ func (cs ClientState) VerifyChannelState( func (cs ClientState) VerifyPacketCommitment( store sdk.KVStore, _ codec.BinaryMarshaler, - _ uint64, - _ commitmentexported.Prefix, + _ clientexported.Height, + prefix commitmentexported.Prefix, _ []byte, portID, channelID string, @@ -225,8 +226,8 @@ func (cs ClientState) VerifyPacketCommitment( func (cs ClientState) VerifyPacketAcknowledgement( store sdk.KVStore, _ codec.BinaryMarshaler, - _ uint64, - _ commitmentexported.Prefix, + _ clientexported.Height, + prefix commitmentexported.Prefix, _ []byte, portID, channelID string, @@ -256,8 +257,8 @@ func (cs ClientState) VerifyPacketAcknowledgement( func (cs ClientState) VerifyPacketAcknowledgementAbsence( store sdk.KVStore, _ codec.BinaryMarshaler, - _ uint64, - _ commitmentexported.Prefix, + _ clientexported.Height, + prefix commitmentexported.Prefix, _ []byte, portID, channelID string, @@ -278,8 +279,8 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( func (cs ClientState) VerifyNextSequenceRecv( store sdk.KVStore, _ codec.BinaryMarshaler, - _ uint64, - _ commitmentexported.Prefix, + _ clientexported.Height, + prefix commitmentexported.Prefix, _ []byte, portID, channelID string, diff --git a/x/ibc/24-host/keys.go b/x/ibc/24-host/keys.go index 9db7a6bcf1b0..73f48e8993a6 100644 --- a/x/ibc/24-host/keys.go +++ b/x/ibc/24-host/keys.go @@ -2,6 +2,8 @@ package host import ( "fmt" + + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" ) const ( @@ -69,8 +71,8 @@ func ClientTypePath() string { // ConsensusStatePath takes an Identifier and returns a Path under which to // store the consensus state of a client. -func ConsensusStatePath(height uint64) string { - return fmt.Sprintf("consensusState/%d", height) +func ConsensusStatePath(height clientexported.Height) string { + return fmt.Sprintf("consensusState/%s", height) } // KeyClientState returns the store key for a particular client state @@ -85,7 +87,7 @@ func KeyClientType() []byte { // KeyConsensusState returns the store key for the consensus state of a particular // client -func KeyConsensusState(height uint64) []byte { +func KeyConsensusState(height clientexported.Height) []byte { return []byte(ConsensusStatePath(height)) } diff --git a/x/ibc/handler.go b/x/ibc/handler.go index 9e370c3380aa..b134fa5ba2e2 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -180,8 +180,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, sdkerrors.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) } + // For now, convert uint64 heights to clientexported.Height + proofHeight := clientexported.NewHeight(msg.ProofEpoch, msg.ProofHeight) // Perform TAO verification - if err := k.ChannelKeeper.RecvPacket(ctx, msg.Packet, msg.Proof, msg.ProofHeight); err != nil { + if err := k.ChannelKeeper.RecvPacket(ctx, msg.Packet, msg.Proof, proofHeight); err != nil { return nil, sdkerrors.Wrap(err, "receive packet verification failed") } @@ -211,8 +213,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, sdkerrors.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) } + // For now, convert uint64 heights to clientexported.Height + proofHeight := clientexported.NewHeight(msg.ProofEpoch, msg.ProofHeight) // Perform TAO verification - if err := k.ChannelKeeper.AcknowledgePacket(ctx, msg.Packet, msg.Acknowledgement, msg.Proof, msg.ProofHeight); err != nil { + if err := k.ChannelKeeper.AcknowledgePacket(ctx, msg.Packet, msg.Acknowledgement, msg.Proof, proofHeight); err != nil { return nil, sdkerrors.Wrap(err, "acknowledge packet verification failed") } @@ -242,8 +246,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, sdkerrors.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) } + // For now, convert uint64 heights to clientexported.Height + proofHeight := clientexported.NewHeight(msg.ProofEpoch, msg.ProofHeight) // Perform TAO verification - if err := k.ChannelKeeper.TimeoutPacket(ctx, msg.Packet, msg.Proof, msg.ProofHeight, msg.NextSequenceRecv); err != nil { + if err := k.ChannelKeeper.TimeoutPacket(ctx, msg.Packet, msg.Proof, proofHeight, msg.NextSequenceRecv); err != nil { return nil, sdkerrors.Wrap(err, "timeout packet verification failed") } diff --git a/x/ibc/handler_test.go b/x/ibc/handler_test.go index 1fb487ce0637..60064b20f578 100644 --- a/x/ibc/handler_test.go +++ b/x/ibc/handler_test.go @@ -15,6 +15,7 @@ import ( ) const ( + timeoutEpoch = uint64(0) timeoutHeight = uint64(10000) totalPackets = uint64(10) ) @@ -64,7 +65,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { }, true}, {"success: UNORDERED", func() { _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -75,7 +76,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { // attempts to receive packet with sequence 10 without receiving packet with sequence 1 for i := uint64(1); i < 10; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -87,7 +88,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { // attempts to receive packet with sequence 10 without receiving packet with sequence 1 for i := uint64(1); i < 10; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -99,7 +100,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { }, false}, {"packet not sent", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) }, false}, {"ORDERED: packet already received (replay)", func() { clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) @@ -115,7 +116,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { {"UNORDERED: packet already received (replay)", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -139,7 +140,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainA.QueryProof(packetKey) - msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight.EpochNumber, proofHeight.EpochHeight, suite.chainB.SenderAccount.GetAddress()) // ante-handle RecvPacket _, err := handler(suite.chainB.GetContext(), msg) @@ -190,7 +191,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { }, true}, {"success: UNORDERED", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -204,7 +205,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { // attempts to acknowledge ack with sequence 10 without acknowledging ack with sequence 1 (removing packet commitment) for i := uint64(1); i < 10; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -220,7 +221,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { // attempts to acknowledge ack with sequence 10 without acknowledging ack with sequence 1 (removing packet commitment for i := uint64(1); i < 10; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -235,7 +236,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { }, false}, {"packet not received", func() { _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -257,7 +258,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { {"UNORDERED: packet already received (replay)", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) @@ -286,7 +287,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { ack := ibctesting.TestHash - msg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight.EpochNumber, proofHeight.EpochHeight, suite.chainA.SenderAccount.GetAddress()) _, err := handler(suite.chainA.GetContext(), msg) @@ -327,7 +328,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { {"success: ORDERED", func() { clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.ORDERED) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight())), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) // send from chainA to chainB msg := ibctransfertypes.NewMsgTransfer(channelA.PortID, channelA.ID, ibctesting.TestCoin, suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), packet.GetTimeoutHeight(), packet.GetTimeoutTimestamp()) @@ -341,7 +342,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { }, true}, {"success: UNORDERED", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, uint64(suite.chainB.GetContext().BlockHeight()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) // send from chainA to chainB msg := ibctransfertypes.NewMsgTransfer(channelA.PortID, channelA.ID, ibctesting.TestCoin, suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), packet.GetTimeoutHeight(), packet.GetTimeoutTimestamp()) @@ -361,7 +362,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { // attempts to timeout the last packet sent without timing out the first packet // packet sequences begin at 1 for i := uint64(0); i < totalPackets; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i+1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, uint64(suite.chainB.GetContext().BlockHeight()), 0) msgs[i] = ibctransfertypes.NewMsgTransfer(channelA.PortID, channelA.ID, ibctesting.TestCoin, suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), packet.GetTimeoutHeight(), packet.GetTimeoutTimestamp()) } @@ -382,7 +383,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { // attempts to timeout the last packet sent without timing out the first packet // packet sequences begin at 1 for i := uint64(0); i < totalPackets; i++ { - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i+1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, uint64(suite.chainB.GetContext().BlockHeight()), 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), i, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, uint64(suite.chainB.GetContext().BlockHeight()), 0) msgs[i] = ibctransfertypes.NewMsgTransfer(channelA.PortID, channelA.ID, ibctesting.TestCoin, suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress().String(), packet.GetTimeoutHeight(), packet.GetTimeoutTimestamp()) } @@ -403,7 +404,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { }, false}, {"UNORDERED: packet not sent", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB) - packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) + packet = channeltypes.NewPacket(suite.chainA.GetPacketData(suite.chainB), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutEpoch, timeoutHeight, 0) packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, false}, } @@ -420,7 +421,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { proof, proofHeight := suite.chainB.QueryProof(packetKey) - msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) + msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight.EpochNumber, proofHeight.EpochHeight, suite.chainA.SenderAccount.GetAddress()) _, err := handler(suite.chainA.GetContext(), msg) diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 9458691add84..bd51c72d8623 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ) @@ -59,7 +60,9 @@ func (suite *IBCTestSuite) SetupTest() { val := tmtypes.NewValidator(pubKey, 10) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) - suite.header = ibctmtypes.CreateTestHeader(chainID, height, height-1, now, valSet, valSet, []tmtypes.PrivValidator{privVal}) + height := clientexported.NewHeight(0, 10) + trustedHeight := clientexported.NewHeight(0, 9) + suite.header = ibctmtypes.CreateTestHeader(chainID, height, trustedHeight, now, valSet, []tmtypes.PrivValidator{privVal}) suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) } diff --git a/x/ibc/simulation/decoder_test.go b/x/ibc/simulation/decoder_test.go index 8061b751ec3f..d6e4be1c7228 100644 --- a/x/ibc/simulation/decoder_test.go +++ b/x/ibc/simulation/decoder_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types/kv" + clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -25,7 +26,8 @@ func TestDecodeStore(t *testing.T) { portID := "portidone" clientState := &ibctmtypes.ClientState{ - FrozenHeight: 10, + ID: clientID, + FrozenHeight: clientexported.NewHeight(0, 10), } connection := connectiontypes.ConnectionEnd{ ClientId: "clientidone", diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 29b6db995eaa..962dd74653bb 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -151,8 +151,8 @@ func (chain *TestChain) GetContext() sdk.Context { } // QueryProof performs an abci query with the given key and returns the proto encoded merkle proof -// for the query and the height at which the proof will succeed on a tendermint verifier. -func (chain *TestChain) QueryProof(key []byte) ([]byte, uint64) { +// for the query and the Height at which the proof will succeed on a tendermint verifier. +func (chain *TestChain) QueryProof(key []byte) ([]byte, clientexported.Height) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), Height: chain.App.LastBlockHeight() - 1, @@ -170,7 +170,8 @@ func (chain *TestChain) QueryProof(key []byte) ([]byte, uint64) { // proof height + 1 is returned as the proof created corresponds to the height the proof // was created in the IAVL tree. Tendermint and subsequently the clients that rely on it // have heights 1 above the IAVL tree. Thus we return proof height + 1 - return proof, uint64(res.Height) + 1 + // The epoch is always 0 on current chain for now + return proof, clientexported.NewHeight(0, uint64(res.Height)+1) } // QueryClientStateProof performs and abci query for a client state @@ -188,7 +189,7 @@ func (chain *TestChain) QueryClientStateProof(clientID string) (clientexported.C // QueryConsensusStateProof performs an abci query for a consensus state // stored on the given clientID. The proof and consensusHeight are returned. -func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, uint64) { +func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clientexported.Height) { // retrieve consensus state to provide proof for consState, found := chain.App.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(chain.GetContext(), clientID) require.True(chain.t, found) @@ -458,6 +459,7 @@ func (chain *TestChain) CreateTMClientHeader() *ibctmtypes.Header { // The relayer is responsible for querying client and injecting appropriate trusted fields. return &ibctmtypes.Header{ SignedHeader: signedHeader, + Height: clientexported.NewHeight(0, uint64(signedHeader.Header.Height)), ValidatorSet: valSet, } } @@ -499,12 +501,16 @@ func (chain *TestChain) ConnectionOpenTry( proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) + // For now, assume our own epoch numebr is 0, while retrieving epoch number for counterparty + // from keeper + // TODO: Extract our epoch number from chain-id msg := connectiontypes.NewMsgConnectionOpenTry( connection.ID, connection.ClientID, counterpartyConnection.ID, counterpartyConnection.ClientID, counterpartyClient, counterparty.GetPrefix(), []string{ConnectionVersion}, proofInit, proofClient, proofConsensus, - proofHeight, consensusHeight, + proofHeight.EpochNumber, proofHeight.EpochHeight, + consensusHeight.EpochNumber, consensusHeight.EpochHeight, chain.SenderAccount.GetAddress(), ) return chain.sendMsgs(msg) @@ -522,10 +528,14 @@ func (chain *TestChain) ConnectionOpenAck( proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) + // For now, assume our own epoch numebr is 0, while retrieving epoch number for counterparty + // from keeper + // TODO: Extract our epoch number from chain-id msg := connectiontypes.NewMsgConnectionOpenAck( connection.ID, counterpartyClient, proofTry, proofClient, proofConsensus, - proofHeight, consensusHeight, + proofHeight.EpochNumber, proofHeight.EpochHeight, + consensusHeight.EpochNumber, consensusHeight.EpochHeight, ConnectionVersion, chain.SenderAccount.GetAddress(), ) @@ -542,7 +552,7 @@ func (chain *TestChain) ConnectionOpenConfirm( msg := connectiontypes.NewMsgConnectionOpenConfirm( connection.ID, - proof, height, + proof, height.EpochNumber, height.EpochHeight, chain.SenderAccount.GetAddress(), ) return chain.sendMsgs(msg) @@ -661,7 +671,7 @@ func (chain *TestChain) ChanOpenConfirm( msg := channeltypes.NewMsgChannelOpenConfirm( ch.PortID, ch.ID, - proof, height, + proof, height.EpochNumber, height.EpochHeight, chain.SenderAccount.GetAddress(), ) return chain.sendMsgs(msg)