diff --git a/docs/ibc/custom.md b/docs/ibc/custom.md index 24decd4fc041..44c4c4851bba 100644 --- a/docs/ibc/custom.md +++ b/docs/ibc/custom.md @@ -340,7 +340,9 @@ receive acknowledegments with the IBC modules as byte strings. Thus, modules must agree on how to encode/decode acknowledgements. The process of creating an acknowledgement struct along with encoding and decoding it, is very similar to the packet data -example above. +example above. [ICS 04](https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope) +specifies a recommended format for acknowledgements. This acknowledgement type can be imported from +[channel types](https://github.com/cosmos/cosmos-sdk/tree/master/x/ibc/04-channel/types). #### Acknowledging Packets diff --git a/proto/ibc/channel/channel.proto b/proto/ibc/channel/channel.proto index fa30c56c290f..fc9b23a181f6 100644 --- a/proto/ibc/channel/channel.proto +++ b/proto/ibc/channel/channel.proto @@ -48,7 +48,7 @@ message MsgChannelOpenConfirm { bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } -// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain A +// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A // to close a channel with Chain B. message MsgChannelCloseInit { string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; @@ -114,8 +114,8 @@ message Channel { Order ordering = 2; // counterparty channel end Counterparty counterparty = 3 [(gogoproto.nullable) = false]; - // list of connection identifiers, in order, along which packets sent on this - // channel will travel + // list of connection identifiers, in order, along which packets sent on + // this channel will travel repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; // opaque channel version, which is agreed upon during the handshake string version = 5; @@ -132,8 +132,8 @@ message IdentifiedChannel { Order ordering = 2; // counterparty channel end Counterparty counterparty = 3 [(gogoproto.nullable) = false]; - // list of connection identifiers, in order, along which packets sent on this - // channel will travel + // list of connection identifiers, in order, along which packets sent on + // this channel will travel repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; // opaque channel version, which is agreed upon during the handshake string version = 5; @@ -189,9 +189,9 @@ message Counterparty { message Packet { option (gogoproto.goproto_getters) = false; - // number corresponds to the order of sends and receives, where a Packet with - // an earlier sequence number must be sent and received before a Packet with a - // later sequence number. + // number corresponds to the order of sends and receives, where a Packet + // with an earlier sequence number must be sent and received before a Packet + // with a later sequence number. uint64 sequence = 1; // identifies the port on the sending chain. string source_port = 2 [(gogoproto.moretags) = "yaml:\"source_port\""]; @@ -223,3 +223,18 @@ message PacketAckCommitment { // packet commitment hash. bytes hash = 4; } + +// Acknowledgement is the recommended acknowledgement format to be used by +// app-specific protocols. +// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +// conflicts with other protobuf message formats used for acknowledgements. +// The first byte of any message with this format will be the non-ASCII values +// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +// https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope +message Acknowledgement { + // response contains either a result or an error and must be non-empty + oneof response { + bytes result = 21; + string error = 22; + } +} diff --git a/proto/ibc/transfer/transfer.proto b/proto/ibc/transfer/transfer.proto index 56b177b53e05..e7fd1383bc04 100644 --- a/proto/ibc/transfer/transfer.proto +++ b/proto/ibc/transfer/transfer.proto @@ -43,31 +43,25 @@ message FungibleTokenPacketData { string receiver = 4; } -// FungibleTokenPacketAcknowledgement contains a boolean success flag and an -// optional error msg error msg is empty string on success See spec for -// onAcknowledgePacket: -// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay -message FungibleTokenPacketAcknowledgement { - bool success = 1; - string error = 2; -} - -// DenomTrace contains the base denomination for ICS20 fungible tokens and the source tracing -// information path. +// DenomTrace contains the base denomination for ICS20 fungible tokens and the +// source tracing information path. message DenomTrace { - // path defines the chain of port/channel identifiers used for tracing the source of the fungible - // token. + // path defines the chain of port/channel identifiers used for tracing the + // source of the fungible token. string path = 1; // base denomination of the relayed fungible token. string base_denom = 2; } // Params defines the set of IBC transfer parameters. -// NOTE: To prevent a single token from being transferred, set the TransfersEnabled parameter to -// true and then set the bank module's SendEnabled parameter for the denomination to false. +// NOTE: To prevent a single token from being transferred, set the +// TransfersEnabled parameter to true and then set the bank module's SendEnabled +// parameter for the denomination to false. message Params { - // send_enabled enables or disables all cross-chain token transfers from this chain. + // send_enabled enables or disables all cross-chain token transfers from this + // chain. bool send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled\""]; - // receive_enabled enables or disables all cross-chain token transfers to this chain. + // receive_enabled enables or disables all cross-chain token transfers to this + // chain. bool receive_enabled = 2 [(gogoproto.moretags) = "yaml:\"receive_enabled\""]; } diff --git a/x/ibc-transfer/handler_test.go b/x/ibc-transfer/handler_test.go index 97784e07169f..bd013bc31179 100644 --- a/x/ibc-transfer/handler_test.go +++ b/x/ibc-transfer/handler_test.go @@ -48,7 +48,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { // relay send fungibleTokenPacket := types.NewFungibleTokenPacketData(coinToSendToB.Denom, coinToSendToB.Amount.Uint64(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String()) packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - ack := types.FungibleTokenPacketAcknowledgement{Success: true} + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) err = suite.coordinator.RelayPacket(suite.chainA, suite.chainB, clientA, clientB, packet, ack.GetBytes()) suite.Require().NoError(err) // relay committed diff --git a/x/ibc-transfer/keeper/relay.go b/x/ibc-transfer/keeper/relay.go index 43a27f6a1bd5..dc48f13db706 100644 --- a/x/ibc-transfer/keeper/relay.go +++ b/x/ibc-transfer/keeper/relay.go @@ -232,11 +232,15 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t // acknowledgement written on the receiving chain. If the acknowledgement // was a success then nothing occurs. If the acknowledgement failed, then // the sender is refunded their tokens using the refundPacketToken function. -func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData, ack types.FungibleTokenPacketAcknowledgement) error { - if !ack.Success { +func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData, ack channeltypes.Acknowledgement) error { + switch ack.Response.(type) { + case *channeltypes.Acknowledgement_Error: return k.refundPacketToken(ctx, packet, data) + default: + // the acknowledgement succeeded on the receiving chain so nothing + // needs to be executed and no error needs to be returned + return nil } - return nil } // OnTimeoutPacket refunds the sender since the original packet sent was diff --git a/x/ibc-transfer/keeper/relay_test.go b/x/ibc-transfer/keeper/relay_test.go index 984701a4acae..0b17f630160e 100644 --- a/x/ibc-transfer/keeper/relay_test.go +++ b/x/ibc-transfer/keeper/relay_test.go @@ -192,7 +192,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { // relay send packet fungibleTokenPacket := types.NewFungibleTokenPacketData(coinFromBToA, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String()) packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelB.PortID, channelB.ID, channelA.PortID, channelA.ID, 110, 0) - ack := types.FungibleTokenPacketAcknowledgement{Success: true} + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) err = suite.coordinator.RelayPacket(suite.chainB, suite.chainA, clientB, clientA, packet, ack.GetBytes()) suite.Require().NoError(err) // relay committed @@ -229,13 +229,8 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { // to chainB. func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { var ( - successAck = types.FungibleTokenPacketAcknowledgement{ - Success: true, - } - failedAck = types.FungibleTokenPacketAcknowledgement{ - Success: false, - Error: "failed packet transfer", - } + successAck = channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + failedAck = channeltypes.NewErrorAcknowledgement("failed packet transfer") channelA, channelB ibctesting.TestChannel coins sdk.Coins @@ -243,7 +238,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { testCases := []struct { msg string - ack types.FungibleTokenPacketAcknowledgement + ack channeltypes.Acknowledgement malleate func() source bool success bool // success of ack diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index d0d5766e7ac9..547fbb2ba849 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -305,16 +305,11 @@ func (am AppModule) OnRecvPacket( return nil, nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet data: %s", err.Error()) } - acknowledgement := types.FungibleTokenPacketAcknowledgement{ - Success: true, - Error: "", - } + acknowledgement := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - if err := am.keeper.OnRecvPacket(ctx, packet, data); err != nil { - acknowledgement = types.FungibleTokenPacketAcknowledgement{ - Success: false, - Error: err.Error(), - } + err := am.keeper.OnRecvPacket(ctx, packet, data) + if err != nil { + acknowledgement = channeltypes.NewErrorAcknowledgement(err.Error()) } ctx.EventManager().EmitEvent( @@ -324,6 +319,7 @@ func (am AppModule) OnRecvPacket( sdk.NewAttribute(types.AttributeKeyReceiver, data.Receiver), sdk.NewAttribute(types.AttributeKeyDenom, data.Denom), sdk.NewAttribute(types.AttributeKeyAmount, fmt.Sprintf("%d", data.Amount)), + sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", err != nil)), ), ) @@ -338,7 +334,7 @@ func (am AppModule) OnAcknowledgementPacket( packet channeltypes.Packet, acknowledgement []byte, ) (*sdk.Result, error) { - var ack types.FungibleTokenPacketAcknowledgement + var ack channeltypes.Acknowledgement if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-20 transfer packet acknowledgement: %v", err) } @@ -358,15 +354,23 @@ func (am AppModule) OnAcknowledgementPacket( sdk.NewAttribute(types.AttributeKeyReceiver, data.Receiver), sdk.NewAttribute(types.AttributeKeyDenom, data.Denom), sdk.NewAttribute(types.AttributeKeyAmount, fmt.Sprintf("%d", data.Amount)), - sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success)), + sdk.NewAttribute(types.AttributeKeyAck, fmt.Sprintf("%v", ack)), ), ) - if !ack.Success { + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypePacket, + sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), + ), + ) + case *channeltypes.Acknowledgement_Error: ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypePacket, - sdk.NewAttribute(types.AttributeKeyAckError, ack.Error), + sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), ), ) } diff --git a/x/ibc-transfer/spec/01_concepts.md b/x/ibc-transfer/spec/01_concepts.md index 31cbdc5467f7..a9e1a30ccb4e 100644 --- a/x/ibc-transfer/spec/01_concepts.md +++ b/x/ibc-transfer/spec/01_concepts.md @@ -3,3 +3,13 @@ order: 1 --> # Concepts + +## Acknowledgements + +ICS20 uses the recommended acknowledgement format as specified by [ICS 04](https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope). + +A successful receive of a transfer packet will result in a Result Acknowledgement being written +with the value `[]byte(byte(1))` in the `Response` field. + +An unsuccessful receive of a transfer packet will result in an Error Acknowledgement being written +with the error message in the `Response` field. diff --git a/x/ibc-transfer/spec/05_events.md b/x/ibc-transfer/spec/05_events.md index 626a98a4f1a8..51b49da4602d 100644 --- a/x/ibc-transfer/spec/05_events.md +++ b/x/ibc-transfer/spec/05_events.md @@ -21,17 +21,18 @@ order: 5 | fungible_token_packet | receiver | {receiver} | | fungible_token_packet | denom | {denom} | | fungible_token_packet | amount | {amount} | +| fungible_token_packet | success | {ackSuccess} | | denomination_trace | trace_hash | {hex_hash} | ## OnAcknowledgePacket callback -| Type | Attribute Key | Attribute Value | -|-----------------------|---------------|-----------------| -| fungible_token_packet | module | transfer | -| fungible_token_packet | receiver | {receiver} | -| fungible_token_packet | denom | {denom} | -| fungible_token_packet | amount | {amount} | -| fungible_token_packet | success | {ackSuccess} | +| Type | Attribute Key | Attribute Value | +|-----------------------|-----------------|-------------------| +| fungible_token_packet | module | transfer | +| fungible_token_packet | receiver | {receiver} | +| fungible_token_packet | denom | {denom} | +| fungible_token_packet | amount | {amount} | +| fungible_token_packet | success | error | {ack.Response} | ## OnTimeoutPacket callback diff --git a/x/ibc-transfer/types/events.go b/x/ibc-transfer/types/events.go index 68832f937ded..a3ed5b413c73 100644 --- a/x/ibc-transfer/types/events.go +++ b/x/ibc-transfer/types/events.go @@ -15,6 +15,7 @@ const ( AttributeKeyRefundDenom = "refund_denom" AttributeKeyRefundAmount = "refund_amount" AttributeKeyAckSuccess = "success" + AttributeKeyAck = "acknowledgement" AttributeKeyAckError = "error" AttributeKeyTraceHash = "trace_hash" ) diff --git a/x/ibc-transfer/types/packet.go b/x/ibc-transfer/types/packet.go index 4acbacce7e85..c9d37d267441 100644 --- a/x/ibc-transfer/types/packet.go +++ b/x/ibc-transfer/types/packet.go @@ -52,8 +52,3 @@ func (ftpd FungibleTokenPacketData) ValidateBasic() error { func (ftpd FungibleTokenPacketData) GetBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&ftpd)) } - -// GetBytes is a helper for serialising -func (ack FungibleTokenPacketAcknowledgement) GetBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&ack)) -} diff --git a/x/ibc-transfer/types/transfer.pb.go b/x/ibc-transfer/types/transfer.pb.go index b5a85391bbd9..0a38b92f3067 100644 --- a/x/ibc-transfer/types/transfer.pb.go +++ b/x/ibc-transfer/types/transfer.pb.go @@ -205,67 +205,11 @@ func (m *FungibleTokenPacketData) GetReceiver() string { return "" } -// FungibleTokenPacketAcknowledgement contains a boolean success flag and an -// optional error msg error msg is empty string on success See spec for -// onAcknowledgePacket: -// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay -type FungibleTokenPacketAcknowledgement struct { - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` -} - -func (m *FungibleTokenPacketAcknowledgement) Reset() { *m = FungibleTokenPacketAcknowledgement{} } -func (m *FungibleTokenPacketAcknowledgement) String() string { return proto.CompactTextString(m) } -func (*FungibleTokenPacketAcknowledgement) ProtoMessage() {} -func (*FungibleTokenPacketAcknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_08134a70fd29e656, []int{2} -} -func (m *FungibleTokenPacketAcknowledgement) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FungibleTokenPacketAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FungibleTokenPacketAcknowledgement.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 *FungibleTokenPacketAcknowledgement) XXX_Merge(src proto.Message) { - xxx_messageInfo_FungibleTokenPacketAcknowledgement.Merge(m, src) -} -func (m *FungibleTokenPacketAcknowledgement) XXX_Size() int { - return m.Size() -} -func (m *FungibleTokenPacketAcknowledgement) XXX_DiscardUnknown() { - xxx_messageInfo_FungibleTokenPacketAcknowledgement.DiscardUnknown(m) -} - -var xxx_messageInfo_FungibleTokenPacketAcknowledgement proto.InternalMessageInfo - -func (m *FungibleTokenPacketAcknowledgement) GetSuccess() bool { - if m != nil { - return m.Success - } - return false -} - -func (m *FungibleTokenPacketAcknowledgement) GetError() string { - if m != nil { - return m.Error - } - return "" -} - -// DenomTrace contains the base denomination for ICS20 fungible tokens and the source tracing -// information path. +// DenomTrace contains the base denomination for ICS20 fungible tokens and the +// source tracing information path. type DenomTrace struct { - // path defines the chain of port/channel identifiers used for tracing the source of the fungible - // token. + // path defines the chain of port/channel identifiers used for tracing the + // source of the fungible token. Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // base denomination of the relayed fungible token. BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` @@ -275,7 +219,7 @@ func (m *DenomTrace) Reset() { *m = DenomTrace{} } func (m *DenomTrace) String() string { return proto.CompactTextString(m) } func (*DenomTrace) ProtoMessage() {} func (*DenomTrace) Descriptor() ([]byte, []int) { - return fileDescriptor_08134a70fd29e656, []int{3} + return fileDescriptor_08134a70fd29e656, []int{2} } func (m *DenomTrace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -319,12 +263,15 @@ func (m *DenomTrace) GetBaseDenom() string { } // Params defines the set of IBC transfer parameters. -// NOTE: To prevent a single token from being transferred, set the TransfersEnabled parameter to -// true and then set the bank module's SendEnabled parameter for the denomination to false. +// NOTE: To prevent a single token from being transferred, set the +// TransfersEnabled parameter to true and then set the bank module's SendEnabled +// parameter for the denomination to false. type Params struct { - // send_enabled enables or disables all cross-chain token transfers from this chain. + // send_enabled enables or disables all cross-chain token transfers from this + // chain. SendEnabled bool `protobuf:"varint,1,opt,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty" yaml:"send_enabled"` - // receive_enabled enables or disables all cross-chain token transfers to this chain. + // receive_enabled enables or disables all cross-chain token transfers to this + // chain. ReceiveEnabled bool `protobuf:"varint,2,opt,name=receive_enabled,json=receiveEnabled,proto3" json:"receive_enabled,omitempty" yaml:"receive_enabled"` } @@ -332,7 +279,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_08134a70fd29e656, []int{4} + return fileDescriptor_08134a70fd29e656, []int{3} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -378,7 +325,6 @@ func (m *Params) GetReceiveEnabled() bool { func init() { proto.RegisterType((*MsgTransfer)(nil), "ibc.transfer.MsgTransfer") proto.RegisterType((*FungibleTokenPacketData)(nil), "ibc.transfer.FungibleTokenPacketData") - proto.RegisterType((*FungibleTokenPacketAcknowledgement)(nil), "ibc.transfer.FungibleTokenPacketAcknowledgement") proto.RegisterType((*DenomTrace)(nil), "ibc.transfer.DenomTrace") proto.RegisterType((*Params)(nil), "ibc.transfer.Params") } @@ -386,47 +332,44 @@ func init() { func init() { proto.RegisterFile("ibc/transfer/transfer.proto", fileDescriptor_08134a70fd29e656) } var fileDescriptor_08134a70fd29e656 = []byte{ - // 629 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x41, 0x4f, 0xdb, 0x4a, - 0x10, 0x8e, 0x21, 0x04, 0xd8, 0x00, 0xef, 0xbd, 0x7d, 0x3c, 0x30, 0x79, 0x25, 0x8e, 0x7c, 0xca, - 0x05, 0x5b, 0x69, 0x55, 0x55, 0xe2, 0xd2, 0x62, 0x68, 0x55, 0x54, 0x55, 0x42, 0x56, 0x0e, 0x55, - 0x2f, 0xd1, 0x7a, 0x3d, 0x75, 0xac, 0xc4, 0xbb, 0xd1, 0xee, 0x86, 0x16, 0xf5, 0x17, 0xf4, 0xd6, - 0x9f, 0x85, 0xd4, 0x0b, 0xc7, 0x9e, 0xac, 0x0a, 0xfe, 0x41, 0x8e, 0x3d, 0x55, 0xeb, 0x5d, 0x02, - 0xa9, 0x50, 0x4f, 0xbb, 0xdf, 0x7c, 0xf3, 0x8d, 0xe7, 0x9b, 0x9d, 0x04, 0xfd, 0x9f, 0x27, 0x34, - 0x54, 0x82, 0x30, 0xf9, 0x01, 0xc4, 0xfc, 0x12, 0x4c, 0x04, 0x57, 0x1c, 0x6f, 0xe4, 0x09, 0x0d, - 0x6e, 0x63, 0xad, 0xed, 0x8c, 0x67, 0xbc, 0x22, 0x42, 0x7d, 0x33, 0x39, 0xad, 0x36,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46, 0xf5, 0x09, 0x51, 0x43, 0x6b, 0xa2, - 0xba, 0xe3, 0x7d, 0x84, 0xf4, 0x8a, 0x0c, 0x8c, 0x3d, 0x23, 0x5e, 0xd7, 0x91, 0x4a, 0xe7, 0x7f, - 0x71, 0x50, 0xe3, 0x8c, 0x08, 0x52, 0x48, 0x7c, 0x88, 0x36, 0xb4, 0x8f, 0x01, 0x30, 0x92, 0x8c, - 0x21, 0x35, 0x0d, 0x44, 0xbb, 0xb3, 0xd2, 0xfb, 0xd7, 0x6e, 0xe8, 0x3d, 0xd6, 0x8f, 0x9b, 0x1a, - 0xbe, 0x34, 0x08, 0x1f, 0xa3, 0xbf, 0xac, 0xd3, 0xb9, 0x7c, 0xa9, 0x92, 0xb7, 0x66, 0xa5, 0xb7, - 0x63, 0xe4, 0xbf, 0x25, 0xf8, 0xf1, 0x96, 0x8d, 0xd8, 0x22, 0xd1, 0x9b, 0xcb, 0xeb, 0xb6, 0x73, - 0x75, 0xdd, 0x76, 0x7e, 0x5c, 0xb7, 0x9d, 0xaf, 0x37, 0xed, 0xda, 0xd5, 0x4d, 0xbb, 0xf6, 0xfd, - 0xa6, 0x5d, 0x7b, 0xdf, 0xfb, 0xe3, 0xc6, 0x7e, 0x0a, 0xf3, 0x84, 0x1e, 0xdc, 0xfd, 0x41, 0xe8, - 0x05, 0x4e, 0x1a, 0xd5, 0x2f, 0xf8, 0xc9, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x4b, 0xfa, - 0xcf, 0x3d, 0x04, 0x00, 0x00, + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x4d, 0x4f, 0x13, 0x41, + 0x18, 0xee, 0x42, 0xa9, 0x30, 0x05, 0xd4, 0x11, 0x61, 0xa9, 0xb2, 0xdb, 0xec, 0xa9, 0x17, 0x76, + 0x53, 0x8d, 0x31, 0xe1, 0xa2,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0x9b, 0xd6, 0xb8, 0xe7, 0x03, 0x00, 0x00, } func (m *MsgTransfer) Marshal() (dAtA []byte, err error) { @@ -554,46 +497,6 @@ func (m *FungibleTokenPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *FungibleTokenPacketAcknowledgement) 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 *FungibleTokenPacketAcknowledgement) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FungibleTokenPacketAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Error) > 0 { - i -= len(m.Error) - copy(dAtA[i:], m.Error) - i = encodeVarintTransfer(dAtA, i, uint64(len(m.Error))) - i-- - dAtA[i] = 0x12 - } - if m.Success { - i-- - if m.Success { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *DenomTrace) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -741,22 +644,6 @@ func (m *FungibleTokenPacketData) Size() (n int) { return n } -func (m *FungibleTokenPacketAcknowledgement) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Success { - n += 2 - } - l = len(m.Error) - if l > 0 { - n += 1 + l + sovTransfer(uint64(l)) - } - return n -} - func (m *DenomTrace) Size() (n int) { if m == nil { return 0 @@ -1231,111 +1118,6 @@ func (m *FungibleTokenPacketData) Unmarshal(dAtA []byte) error { } return nil } -func (m *FungibleTokenPacketAcknowledgement) 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 ErrIntOverflowTransfer - } - 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: FungibleTokenPacketAcknowledgement: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FungibleTokenPacketAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTransfer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Success = bool(v != 0) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTransfer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTransfer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTransfer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Error = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTransfer(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTransfer - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTransfer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *DenomTrace) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/04-channel/types/channel.go b/x/ibc/04-channel/types/channel.go index 7fdb6f4e0c2f..f1e8d91f6027 100644 --- a/x/ibc/04-channel/types/channel.go +++ b/x/ibc/04-channel/types/channel.go @@ -1,6 +1,9 @@ package types import ( + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/exported" @@ -123,3 +126,45 @@ func (ic IdentifiedChannel) ValidateBasic() error { channel := NewChannel(ic.State, ic.Ordering, ic.Counterparty, ic.ConnectionHops, ic.Version) return channel.ValidateBasic() } + +// NewResultAcknowledgement returns a new instance of Acknowledgement using an Acknowledgement_Result +// type in the Response field. +func NewResultAcknowledgement(result []byte) Acknowledgement { + return Acknowledgement{ + Response: &Acknowledgement_Result{ + Result: result, + }, + } +} + +// NewErrorAcknowledgement returns a new instance of Acknowledgement using an Acknowledgement_Error +// type in the Response field. +func NewErrorAcknowledgement(err string) Acknowledgement { + return Acknowledgement{ + Response: &Acknowledgement_Error{ + Error: err, + }, + } +} + +// GetBytes is a helper for serialising acknowledgements +func (ack Acknowledgement) GetBytes() []byte { + return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(&ack)) +} + +// ValidateBasic performs a basic validation of the acknowledgement +func (ack Acknowledgement) ValidateBasic() error { + switch resp := ack.Response.(type) { + case *Acknowledgement_Result: + if len(resp.Result) == 0 { + return sdkerrors.Wrap(ErrInvalidAcknowledgement, "acknowledgement result cannot be empty") + } + case *Acknowledgement_Error: + if strings.TrimSpace(resp.Error) == "" { + return sdkerrors.Wrap(ErrInvalidAcknowledgement, "acknowledgement error cannot be empty") + } + default: + return sdkerrors.Wrapf(ErrInvalidAcknowledgement, "unsupported acknowledgement response field type %T", resp) + } + return nil +} diff --git a/x/ibc/04-channel/types/channel.pb.go b/x/ibc/04-channel/types/channel.pb.go index 9b5be470e971..259e4095897e 100644 --- a/x/ibc/04-channel/types/channel.pb.go +++ b/x/ibc/04-channel/types/channel.pb.go @@ -429,7 +429,7 @@ func (m *MsgChannelOpenConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.A return nil } -// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain A +// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A // to close a channel with Chain B. type MsgChannelCloseInit struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` @@ -887,8 +887,8 @@ type Channel struct { Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.channel.Order" json:"ordering,omitempty"` // counterparty channel end Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` - // list of connection identifiers, in order, along which packets sent on this - // channel will travel + // list of connection identifiers, in order, along which packets sent on + // this channel will travel ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty" yaml:"connection_hops"` // opaque channel version, which is agreed upon during the handshake Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` @@ -936,8 +936,8 @@ type IdentifiedChannel struct { Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.channel.Order" json:"ordering,omitempty"` // counterparty channel end Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` - // list of connection identifiers, in order, along which packets sent on this - // channel will travel + // list of connection identifiers, in order, along which packets sent on + // this channel will travel ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty" yaml:"connection_hops"` // opaque channel version, which is agreed upon during the handshake Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` @@ -1023,9 +1023,9 @@ var xxx_messageInfo_Counterparty proto.InternalMessageInfo // Packet defines a type that carries data across different chains through IBC type Packet struct { - // number corresponds to the order of sends and receives, where a Packet with - // an earlier sequence number must be sent and received before a Packet with a - // later sequence number. + // number corresponds to the order of sends and receives, where a Packet + // with an earlier sequence number must be sent and received before a Packet + // with a later sequence number. Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` // identifies the port on the sending chain. SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty" yaml:"source_port"` @@ -1122,6 +1122,100 @@ func (m *PacketAckCommitment) XXX_DiscardUnknown() { var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo +// Acknowledgement is the recommended acknowledgement format to be used by +// app-specifc protocols. +// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +// conflicts with other protobuf message formats used for acknowledgements. +// The first byte of any message with this format will be the non-ASCII values +// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +// https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope +type Acknowledgement struct { + // response contains either a result or an error and must be non-empty + // + // Types that are valid to be assigned to Response: + // *Acknowledgement_Result + // *Acknowledgement_Error + Response isAcknowledgement_Response `protobuf_oneof:"response"` +} + +func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } +func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } +func (*Acknowledgement) ProtoMessage() {} +func (*Acknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_9277922ccfb7f043, []int{15} +} +func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Acknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Acknowledgement.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 *Acknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_Acknowledgement.Merge(m, src) +} +func (m *Acknowledgement) XXX_Size() int { + return m.Size() +} +func (m *Acknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_Acknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo + +type isAcknowledgement_Response interface { + isAcknowledgement_Response() + MarshalTo([]byte) (int, error) + Size() int +} + +type Acknowledgement_Result struct { + Result []byte `protobuf:"bytes,21,opt,name=result,proto3,oneof" json:"result,omitempty"` +} +type Acknowledgement_Error struct { + Error string `protobuf:"bytes,22,opt,name=error,proto3,oneof" json:"error,omitempty"` +} + +func (*Acknowledgement_Result) isAcknowledgement_Response() {} +func (*Acknowledgement_Error) isAcknowledgement_Response() {} + +func (m *Acknowledgement) GetResponse() isAcknowledgement_Response { + if m != nil { + return m.Response + } + return nil +} + +func (m *Acknowledgement) GetResult() []byte { + if x, ok := m.GetResponse().(*Acknowledgement_Result); ok { + return x.Result + } + return nil +} + +func (m *Acknowledgement) GetError() string { + if x, ok := m.GetResponse().(*Acknowledgement_Error); ok { + return x.Error + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Acknowledgement) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Acknowledgement_Result)(nil), + (*Acknowledgement_Error)(nil), + } +} + func init() { proto.RegisterEnum("ibc.channel.State", State_name, State_value) proto.RegisterEnum("ibc.channel.Order", Order_name, Order_value) @@ -1140,96 +1234,99 @@ func init() { proto.RegisterType((*Counterparty)(nil), "ibc.channel.Counterparty") proto.RegisterType((*Packet)(nil), "ibc.channel.Packet") proto.RegisterType((*PacketAckCommitment)(nil), "ibc.channel.PacketAckCommitment") + proto.RegisterType((*Acknowledgement)(nil), "ibc.channel.Acknowledgement") } func init() { proto.RegisterFile("ibc/channel/channel.proto", fileDescriptor_9277922ccfb7f043) } var fileDescriptor_9277922ccfb7f043 = []byte{ - // 1330 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, 0x23, 0x2b, 0x89, 0x56, 0x2c, 0x3d, 0x98, - 0x94, 0xc8, 0xcd, 0x07, 0x2d, 0xe4, 0x54, 0x49, 0x56, 0x88, 0x68, 0x2c, 0x99, 0xb1, 0x52, 0xda, - 0x5c, 0xc4, 0x7a, 0x35, 0x91, 0x16, 0x59, 0x3b, 0xea, 0xee, 0x38, 0x89, 0x8f, 0xbd, 0x05, 0x43, - 0xa1, 0x7f, 0x40, 0x0d, 0x85, 0x42, 0x8f, 0xbd, 0xf6, 0x5c, 0x7a, 0xc9, 0xa1, 0xd0, 0x5c, 0x0a, - 0x3d, 0x2d, 0x25, 0xf9, 0x0f, 0x74, 0x49, 0xe9, 0xa9, 0xec, 0xcc, 0xac, 0xb4, 0x2b, 0x3b, 0x39, - 0x44, 0xae, 0xf0, 0xa1, 0xa7, 0x9d, 0x79, 0xef, 0x37, 0x33, 0xef, 0xfd, 0xde, 0x9b, 0x37, 0x4f, - 0x82, 0x0d, 0x73, 0xdf, 0xd8, 0x32, 0xba, 0xba, 0x65, 0x91, 0x03, 0xff, 0x5b, 0x1c, 0xd8, 0x94, - 0x51, 0x34, 0x6f, 0xee, 0x1b, 0x45, 0x29, 0xca, 0xad, 0x75, 0x68, 0x87, 0x72, 0xf9, 0x96, 0x37, - 0x12, 0x90, 0xdc, 0x65, 0xbe, 0xfa, 0xc0, 0x24, 0x16, 0x93, 0x1f, 0xa1, 0xd0, 0xfe, 0x56, 0x00, + // 1373 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x3b, 0x6f, 0x1b, 0x47, + 0x10, 0xe6, 0xf1, 0x29, 0x8e, 0x5e, 0xd4, 0xea, 0x61, 0x8a, 0xb6, 0x79, 0xc4, 0x21, 0x85, 0xe0, + 0xc0, 0x54, 0xfc, 0x40, 0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c, 0x87, 0x7c, 0xe4, 0xc6, 0x53, 0x48, 0xf0, 0x1e, 0x89, 0x3e, 0x80, 0xb5, + 0x06, 0xde, 0xaa, 0xe2, 0x56, 0xbd, 0x51, 0xaf, 0x4e, 0xf8, 0xcb, 0xb7, 0xf4, 0xf4, 0x48, 0x83, + 0x45, 0x81, 0x7a, 0x58, 0xe7, 0xcf, 0xea, 0x56, 0x46, 0xc9, 0xcd, 0x1f, 0x9f, 0x14, 0xd2, 0x23, + 0x85, 0xe7, 0xb0, 0xc0, 0xf8, 0x08, 0xe9, 0xb0, 0x14, 0xc5, 0xc1, 0xe5, 0x9d, 0x17, 0xaf, 0xf2, + 0xca, 0xcb, 0x57, 0x79, 0xe5, 0xaf, 0x57, 0x79, 0xe5, 0xdb, 0xd7, 0xf9, 0xc8, 0xcb, 0xd7, 0xf9, + 0xc8, 0x9f, 0xaf, 0xf3, 0x91, 0x47, 0x77, 0xde, 0x79, 0xb5, 0x3e, 0xdb, 0x34, 0xf7, 0x8d, 0xcd, + 0x8f, 0xee, 0xde, 0xf4, 0xff, 0x61, 0xe4, 0x77, 0xed, 0x7e, 0x92, 0xff, 0x49, 0x78, 0xe7, 0xdf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x78, 0x52, 0x52, 0x7d, 0x14, 0x00, 0x00, } func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { @@ -2146,6 +2243,72 @@ func (m *PacketAckCommitment) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Acknowledgement) 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 *Acknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Response != nil { + { + size := m.Response.Size() + i -= size + if _, err := m.Response.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Acknowledgement_Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Result != nil { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xaa + } + return len(dAtA) - i, nil +} +func (m *Acknowledgement_Error) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb2 + return len(dAtA) - i, nil +} func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { offset -= sovChannel(v) base := offset @@ -2557,6 +2720,41 @@ func (m *PacketAckCommitment) Size() (n int) { return n } +func (m *Acknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Response != nil { + n += m.Response.Size() + } + return n +} + +func (m *Acknowledgement_Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != nil { + l = len(m.Result) + n += 2 + l + sovChannel(uint64(l)) + } + return n +} +func (m *Acknowledgement_Error) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Error) + n += 2 + l + sovChannel(uint64(l)) + return n +} + func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5734,6 +5932,124 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error { } return nil } +func (m *Acknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Acknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Acknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 21: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Response = &Acknowledgement_Result{v} + iNdEx = postIndex + case 22: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Response = &Acknowledgement_Error{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/04-channel/types/channel_test.go b/x/ibc/04-channel/types/channel_test.go index c02114672a5c..a5c528bbf9db 100644 --- a/x/ibc/04-channel/types/channel_test.go +++ b/x/ibc/04-channel/types/channel_test.go @@ -30,3 +30,63 @@ func TestCounterpartyValidateBasic(t *testing.T) { } } } + +// tests acknowledgement.ValidateBasic and acknowledgement.GetBytes +func (suite TypesTestSuite) TestAcknowledgement() { + testCases := []struct { + name string + ack types.Acknowledgement + expPass bool + }{ + { + "valid successful ack", + types.NewResultAcknowledgement([]byte("success")), + true, + }, + { + "valid failed ack", + types.NewErrorAcknowledgement("error"), + true, + }, + { + "empty successful ack", + types.NewResultAcknowledgement([]byte{}), + false, + }, + { + "empty faied ack", + types.NewErrorAcknowledgement(" "), + false, + }, + { + "nil response", + types.Acknowledgement{ + Response: nil, + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + err := tc.ack.ValidateBasic() + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + + // expect all acks to be able to be marshaled + suite.NotPanics(func() { + bz := tc.ack.GetBytes() + suite.Require().NotNil(bz) + }) + }) + } + +} diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index ff16a5b44d33..950417785c66 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -67,13 +67,13 @@ var ( addr = sdk.AccAddress("testaddr") ) -type MsgTestSuite struct { +type TypesTestSuite struct { suite.Suite proof []byte } -func (suite *MsgTestSuite) SetupTest() { +func (suite *TypesTestSuite) SetupTest() { app := simapp.Setup(false) db := dbm.NewMemDB() store := rootmulti.NewStore(db) @@ -99,12 +99,12 @@ func (suite *MsgTestSuite) SetupTest() { suite.proof = proof } -func TestMsgTestSuite(t *testing.T) { - suite.Run(t, new(MsgTestSuite)) +func TestTypesTestSuite(t *testing.T) { + suite.Run(t, new(TypesTestSuite)) } // TestMsgChannelOpenInit tests ValidateBasic for MsgChannelOpenInit -func (suite *MsgTestSuite) TestMsgChannelOpenInit() { +func (suite *TypesTestSuite) TestMsgChannelOpenInit() { testMsgs := []*types.MsgChannelOpenInit{ types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg types.NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id @@ -156,7 +156,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() { } // TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry -func (suite *MsgTestSuite) TestMsgChannelOpenTry() { +func (suite *TypesTestSuite) TestMsgChannelOpenTry() { testMsgs := []*types.MsgChannelOpenTry{ types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // valid msg types.NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // too short port id @@ -214,7 +214,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { } // TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck -func (suite *MsgTestSuite) TestMsgChannelOpenAck() { +func (suite *TypesTestSuite) TestMsgChannelOpenAck() { testMsgs := []*types.MsgChannelOpenAck{ types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, height, addr), // valid msg types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, height, addr), // too short port id @@ -256,7 +256,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { } // TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm -func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { +func (suite *TypesTestSuite) TestMsgChannelOpenConfirm() { testMsgs := []*types.MsgChannelOpenConfirm{ types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id @@ -296,7 +296,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { } // TestMsgChannelCloseInit tests ValidateBasic for MsgChannelCloseInit -func (suite *MsgTestSuite) TestMsgChannelCloseInit() { +func (suite *TypesTestSuite) TestMsgChannelCloseInit() { testMsgs := []*types.MsgChannelCloseInit{ types.NewMsgChannelCloseInit("testportid", "testchannel", addr), // valid msg types.NewMsgChannelCloseInit(invalidShortPort, "testchannel", addr), // too short port id @@ -332,7 +332,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() { } // TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm -func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { +func (suite *TypesTestSuite) TestMsgChannelCloseConfirm() { testMsgs := []*types.MsgChannelCloseConfirm{ types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id @@ -372,14 +372,14 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { } // TestMsgRecvPacketType tests Type for MsgRecvPacket. -func (suite *MsgTestSuite) TestMsgRecvPacketType() { +func (suite *TypesTestSuite) TestMsgRecvPacketType() { msg := types.NewMsgRecvPacket(packet, suite.proof, height, addr1) suite.Equal("recv_packet", msg.Type()) } // TestMsgRecvPacketValidation tests ValidateBasic for MsgRecvPacket -func (suite *MsgTestSuite) TestMsgRecvPacketValidation() { +func (suite *TypesTestSuite) TestMsgRecvPacketValidation() { testMsgs := []*types.MsgRecvPacket{ types.NewMsgRecvPacket(packet, suite.proof, height, addr1), // valid msg types.NewMsgRecvPacket(packet, suite.proof, clienttypes.Height{}, addr1), // proof height is zero @@ -411,7 +411,7 @@ func (suite *MsgTestSuite) TestMsgRecvPacketValidation() { } // TestMsgRecvPacketGetSignBytes tests GetSignBytes for MsgRecvPacket -func (suite *MsgTestSuite) TestMsgRecvPacketGetSignBytes() { +func (suite *TypesTestSuite) TestMsgRecvPacketGetSignBytes() { msg := types.NewMsgRecvPacket(packet, suite.proof, height, addr1) res := msg.GetSignBytes() @@ -423,7 +423,7 @@ func (suite *MsgTestSuite) TestMsgRecvPacketGetSignBytes() { } // TestMsgRecvPacketGetSigners tests GetSigners for MsgRecvPacket -func (suite *MsgTestSuite) TestMsgRecvPacketGetSigners() { +func (suite *TypesTestSuite) TestMsgRecvPacketGetSigners() { msg := types.NewMsgRecvPacket(packet, suite.proof, height, addr1) res := msg.GetSigners() @@ -432,7 +432,7 @@ func (suite *MsgTestSuite) TestMsgRecvPacketGetSigners() { } // TestMsgTimeout tests ValidateBasic for MsgTimeout -func (suite *MsgTestSuite) TestMsgTimeout() { +func (suite *TypesTestSuite) TestMsgTimeout() { testMsgs := []*types.MsgTimeout{ types.NewMsgTimeout(packet, 1, suite.proof, height, addr), types.NewMsgTimeout(packet, 1, suite.proof, clienttypes.Height{}, addr), @@ -464,7 +464,7 @@ func (suite *MsgTestSuite) TestMsgTimeout() { } // TestMsgTimeoutOnClose tests ValidateBasic for MsgTimeoutOnClose -func (suite *MsgTestSuite) TestMsgTimeoutOnClose() { +func (suite *TypesTestSuite) TestMsgTimeoutOnClose() { testCases := []struct { name string msg sdk.Msg @@ -494,7 +494,7 @@ func (suite *MsgTestSuite) TestMsgTimeoutOnClose() { } // TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement -func (suite *MsgTestSuite) TestMsgAcknowledgement() { +func (suite *TypesTestSuite) TestMsgAcknowledgement() { testMsgs := []*types.MsgAcknowledgement{ types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, addr), types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, clienttypes.Height{}, addr),