Skip to content

Commit

Permalink
Refactor x/ibc to ADR 031 (#7576)
Browse files Browse the repository at this point in the history
* WIP: Refactor x/ibc to ADR 031

* updated handler

* removed unsued

* fix

* Add proto service for ibc/transfer

* lint

* remove old upgrade handler

* added doc

* review changes

* fix tests

* formatter

* Add MsgServer wiring in RegisterServices

Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and clevinson committed Oct 19, 2020
1 parent a6f61d2 commit 15b5767
Show file tree
Hide file tree
Showing 21 changed files with 5,421 additions and 1,857 deletions.
9 changes: 9 additions & 0 deletions proto/ibc/applications/transfer/v1/transfer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "ibc/core/client/v1/client.proto";

// Msg defines the ibc/transfer Msg service.
service Msg {
// Transfer defines a rpc handler method for MsgTransfer.
rpc Transfer(MsgTransfer) returns (MsgTransferResponse);
}

// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between
// ICS20 enabled chains. See ICS Spec here:
// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures
Expand All @@ -33,6 +39,9 @@ message MsgTransfer {
uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

// MsgTransferResponse defines the Msg/Transfer response type.
message MsgTransferResponse { }

// FungibleTokenPacketData defines a struct for the packet payload
// See FungibleTokenPacketData spec:
// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures
Expand Down
67 changes: 65 additions & 2 deletions proto/ibc/core/channel/v1/channel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types";
import "gogoproto/gogo.proto";
import "ibc/core/client/v1/client.proto";

// Msg defines the ibc/channel Msg service.
service Msg {
// ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit.
rpc ChannelOpenInit(MsgChannelOpenInit) returns (MsgChannelOpenInitResponse);

// ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry.
rpc ChannelOpenTry(MsgChannelOpenTry) returns (MsgChannelOpenTryResponse);

// ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck.
rpc ChannelOpenAck(MsgChannelOpenAck) returns (MsgChannelOpenAckResponse);

// ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm.
rpc ChannelOpenConfirm(MsgChannelOpenConfirm) returns (MsgChannelOpenConfirmResponse);

// ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit.
rpc ChannelCloseInit(MsgChannelCloseInit) returns (MsgChannelCloseInitResponse);

// ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm.
rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse);

// RecvPacket defines a rpc handler method for MsgRecvPacket.
rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse);

// Timeout defines a rpc handler method for MsgTimeout.
rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse);

// TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose.
rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse);

// Acknowledgement defines a rpc handler method for MsgAcknowledgement.
rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse);
}

// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It
// is called by a relayer on Chain A.
message MsgChannelOpenInit {
Expand All @@ -18,7 +51,10 @@ message MsgChannelOpenInit {
string signer = 4;
}

// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
message MsgChannelOpenInitResponse {}

// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
// on Chain B.
message MsgChannelOpenTry {
option (gogoproto.equal) = false;
Expand All @@ -35,6 +71,9 @@ message MsgChannelOpenTry {
string signer = 8;
}

// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type.
message MsgChannelOpenTryResponse {}

// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge
// the change of channel state to TRYOPEN on Chain B.
message MsgChannelOpenAck {
Expand All @@ -51,6 +90,9 @@ message MsgChannelOpenAck {
string signer = 7;
}

// MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type.
message MsgChannelOpenAckResponse {}

// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to
// acknowledge the change of channel state to OPEN on Chain A.
message MsgChannelOpenConfirm {
Expand All @@ -65,6 +107,9 @@ message MsgChannelOpenConfirm {
string signer = 5;
}

// MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type.
message MsgChannelOpenConfirmResponse {}

// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A
// to close a channel with Chain B.
message MsgChannelCloseInit {
Expand All @@ -76,6 +121,9 @@ message MsgChannelCloseInit {
string signer = 3;
}

// MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type.
message MsgChannelCloseInitResponse {}

// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B
// to acknowledge the change of channel state to CLOSED on Chain A.
message MsgChannelCloseConfirm {
Expand All @@ -90,6 +138,9 @@ message MsgChannelCloseConfirm {
string signer = 5;
}

// MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type.
message MsgChannelCloseConfirmResponse {}

// MsgRecvPacket receives incoming IBC packet
message MsgRecvPacket {
option (gogoproto.equal) = false;
Expand All @@ -102,6 +153,9 @@ message MsgRecvPacket {
string signer = 4;
}

// MsgRecvPacketResponse defines the Msg/RecvPacket response type.
message MsgRecvPacketResponse {}

// MsgTimeout receives timed-out packet
message MsgTimeout {
option (gogoproto.equal) = false;
Expand All @@ -115,6 +169,9 @@ message MsgTimeout {
string signer = 5;
}

// MsgTimeoutResponse defines the Msg/Timeout response type.
message MsgTimeoutResponse {}

// MsgTimeoutOnClose timed-out packet upon counterparty channel closure.
message MsgTimeoutOnClose {
option (gogoproto.equal) = false;
Expand All @@ -129,6 +186,9 @@ message MsgTimeoutOnClose {
string signer = 6;
}

// MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type.
message MsgTimeoutOnCloseResponse {}

// MsgAcknowledgement receives incoming IBC acknowledgement
message MsgAcknowledgement {
option (gogoproto.equal) = false;
Expand All @@ -142,6 +202,9 @@ message MsgAcknowledgement {
string signer = 5;
}

// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type.
message MsgAcknowledgementResponse {}

// Channel defines pipeline for exactly-once packet delivery between specific
// modules on separate blockchains, which has at least one end capable of
// sending packets and one end capable of receiving packets.
Expand Down Expand Up @@ -278,4 +341,4 @@ message Acknowledgement {
bytes result = 21;
string error = 22;
}
}
}
101 changes: 64 additions & 37 deletions proto/ibc/core/client/v1/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,19 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

// IdentifiedClientState defines a client state with an additional client
// identifier field.
message IdentifiedClientState {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// client state
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
}
// Msg defines the ibc/client Msg service.
service Msg {
// CreateClient defines a rpc handler method for MsgCreateClient.
rpc CreateClient(MsgCreateClient) returns (MsgCreateClientResponse);

// ConsensusStateWithHeight defines a consensus state with an additional height field.
message ConsensusStateWithHeight {
// consensus state height
Height height = 1 [(gogoproto.nullable) = false];
// consensus state
google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml\"consensus_state\""];
}
// UpdateClient defines a rpc handler method for MsgUpdateClient.
rpc UpdateClient(MsgUpdateClient) returns (MsgUpdateClientResponse);

// ClientConsensusStates defines all the stored consensus states for a given
// client.
message ClientConsensusStates {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// consensus states and their heights associated with the client
repeated ConsensusStateWithHeight consensus_states = 2
[(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false];
}
// UpgradeClient defines a rpc handler method for MsgUpgradeClient.
rpc UpgradeClient(MsgUpgradeClient) returns (MsgUpgradeClientResponse);

// ClientUpdateProposal is a governance proposal. If it passes, the client is
// updated with the provided header. The update may fail if the header is not
// valid given certain conditions specified by the client implementation.
message ClientUpdateProposal {
option (gogoproto.goproto_getters) = false;
// the title of the update proposal
string title = 1;
// the description of the proposal
string description = 2;
// the client identifier for the client to be updated if the proposal passes
string client_id = 3 [(gogoproto.moretags) = "yaml:\"client_id\""];
// the header used to update the client if the proposal passes
google.protobuf.Any header = 4;
// SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour.
rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse);
}

// MsgCreateClient defines a message to create an IBC client
Expand All @@ -64,6 +37,9 @@ message MsgCreateClient {
string signer = 4;
}

// MsgCreateClientResponse defines the Msg/CreateClient response type.
message MsgCreateClientResponse { }

// MsgUpdateClient defines an sdk.Msg to update a IBC client state using
// the given header.
message MsgUpdateClient {
Expand All @@ -78,6 +54,9 @@ message MsgUpdateClient {
string signer = 3;
}

// MsgUpdateClientResponse defines the Msg/UpdateClient response type.
message MsgUpdateClientResponse { }

// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state
message MsgUpgradeClient {
// client unique identifier
Expand All @@ -92,6 +71,9 @@ message MsgUpgradeClient {
string signer = 5;
}

// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type.
message MsgUpgradeClientResponse { }

// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for
// light client misbehaviour.
message MsgSubmitMisbehaviour {
Expand All @@ -106,6 +88,51 @@ message MsgSubmitMisbehaviour {
string signer = 3;
}

// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type.
message MsgSubmitMisbehaviourResponse { }

// IdentifiedClientState defines a client state with an additional client
// identifier field.
message IdentifiedClientState {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// client state
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
}

// ConsensusStateWithHeight defines a consensus state with an additional height field.
message ConsensusStateWithHeight {
// consensus state height
Height height = 1 [(gogoproto.nullable) = false];
// consensus state
google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml\"consensus_state\""];
}

// ClientConsensusStates defines all the stored consensus states for a given
// client.
message ClientConsensusStates {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// consensus states and their heights associated with the client
repeated ConsensusStateWithHeight consensus_states = 2
[(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false];
}

// ClientUpdateProposal is a governance proposal. If it passes, the client is
// updated with the provided header. The update may fail if the header is not
// valid given certain conditions specified by the client implementation.
message ClientUpdateProposal {
option (gogoproto.goproto_getters) = false;
// the title of the update proposal
string title = 1;
// the description of the proposal
string description = 2;
// the client identifier for the client to be updated if the proposal passes
string client_id = 3 [(gogoproto.moretags) = "yaml:\"client_id\""];
// the header used to update the client if the proposal passes
google.protobuf.Any header = 4;
}

// Height is a monotonically increasing data type
// that can be compared against another Height for the purposes of updating and
// freezing clients
Expand Down
27 changes: 27 additions & 0 deletions proto/ibc/core/connection/v1/connection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ import "google/protobuf/any.proto";
import "ibc/core/commitment/v1/commitment.proto";
import "ibc/core/client/v1/client.proto";

// Msg defines the ibc/connection Msg service.
service Msg {
// ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit.
rpc ConnectionOpenInit(MsgConnectionOpenInit) returns (MsgConnectionOpenInitResponse);

// ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry.
rpc ConnectionOpenTry(MsgConnectionOpenTry) returns (MsgConnectionOpenTryResponse);

// ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck.
rpc ConnectionOpenAck(MsgConnectionOpenAck) returns (MsgConnectionOpenAckResponse);

// ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm.
rpc ConnectionOpenConfirm(MsgConnectionOpenConfirm) returns (MsgConnectionOpenConfirmResponse);
}

// MsgConnectionOpenInit defines the msg sent by an account on Chain A to
// initialize a connection with Chain B.
message MsgConnectionOpenInit {
Expand All @@ -21,6 +36,9 @@ message MsgConnectionOpenInit {
string signer = 5;
}

// MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type.
message MsgConnectionOpenInitResponse { }

// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a
// connection on Chain B.
message MsgConnectionOpenTry {
Expand All @@ -47,6 +65,9 @@ message MsgConnectionOpenTry {
string signer = 12;
}

// MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type.
message MsgConnectionOpenTryResponse { }

// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to
// acknowledge the change of connection state to TRYOPEN on Chain B.
message MsgConnectionOpenAck {
Expand All @@ -71,6 +92,9 @@ message MsgConnectionOpenAck {
string signer = 10;
}

// MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type.
message MsgConnectionOpenAckResponse { }

// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to
// acknowledge the change of connection state to OPEN on Chain A.
message MsgConnectionOpenConfirm {
Expand All @@ -85,6 +109,9 @@ message MsgConnectionOpenConfirm {
string signer = 4;
}

// MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm response type.
message MsgConnectionOpenConfirmResponse { }

// ICS03 - Connection Data Structures as defined in
// https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#data-structures

Expand Down
Loading

0 comments on commit 15b5767

Please sign in to comment.