diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 4bd4eec1884..e909ebfe765 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -177,7 +177,7 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty must exist for channel %s", msg.ChannelId) } - counterparty.CounterpartyChannelId = msg.Counterparty.CounterpartyChannelId + counterparty.CounterpartyChannelId = msg.CounterpartyChannelId k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, counterparty) // Delete client creator from state as it is not needed after this point. k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index c45feaa1823..d91b5eaf10e 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -17,7 +17,6 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -1218,7 +1217,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, ibctesting.MerklePath)) }, nil, }, @@ -1246,8 +1245,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().NoError(path.EndpointA.CreateChannel()) signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, merklePrefix, signer) + msg = packetservertypes.NewMsgProvideCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) tc.malleate() @@ -1259,10 +1257,10 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().NotNil(resp) suite.Require().Nil(err) - // Assert counterparty set and creator deleted + // Assert counterparty channel id filled in and creator deleted counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) - suite.Require().Equal(counterparty, msg.Counterparty) + suite.Require().Equal(counterparty.CounterpartyChannelId, path.EndpointB.ChannelID) _, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().False(found) diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 0482ba21e30..619e96e1875 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -1,9 +1,7 @@ package cli import ( - "encoding/hex" "fmt" - "strings" "github.com/spf13/cobra" @@ -12,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/version" - commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) @@ -20,30 +17,25 @@ import ( // newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. func newProvideCounterpartyCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "provide-counterparty [client-identifier] [counterparty-client-identifier] [counterparty-merkle-path-prefix]", - Args: cobra.ExactArgs(3), - Short: "provide the counterparty to an IBC client", - Long: `Provide the counterparty to an IBC client specified by its client ID. + Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", + Args: cobra.ExactArgs(2), + Short: "provide the counterparty channel to an IBC channel end", + Long: `Provide the counterparty to an IBC channel end specified by its channel ID. The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.`, - Example: fmt.Sprintf("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61", version.AppName, exported.ModuleName, types.SubModuleName), + Example: fmt.Sprintf("%s tx %s %s provide-counterparty channel-0 channel-1", version.AppName, exported.ModuleName, types.SubModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - clientIdentifier := args[0] - counterpartyClientIdentifier := args[1] - counterpartyMerklePathPrefix, err := parseMerklePathPrefix(args[2]) - if err != nil { - return err - } + channelID := args[0] + counterpartyChannelID := args[1] - counterparty := types.NewCounterparty(clientIdentifier, counterpartyClientIdentifier, counterpartyMerklePathPrefix) msg := types.MsgProvideCounterparty{ - ChannelId: clientIdentifier, - Counterparty: counterparty, - Signer: clientCtx.GetFromAddress().String(), + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, + Signer: clientCtx.GetFromAddress().String(), } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, @@ -52,18 +44,3 @@ The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded s flags.AddTxFlagsToCmd(cmd) return cmd } - -// parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath. -func parseMerklePathPrefix(merklePathPrefixString string) (commitmenttypesv2.MerklePath, error) { - var keyPath [][]byte - hexPrefixes := strings.Split(merklePathPrefixString, ",") - for _, hexPrefix := range hexPrefixes { - prefix, err := hex.DecodeString(hexPrefix) - if err != nil { - return commitmenttypesv2.MerklePath{}, fmt.Errorf("invalid hex merkle path prefix: %w", err) - } - keyPath = append(keyPath, prefix) - } - - return commitmenttypesv2.MerklePath{KeyPath: keyPath}, nil -} diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go index 86849d43be7..a291f62ab2d 100644 --- a/modules/core/packet-server/types/msgs.go +++ b/modules/core/packet-server/types/msgs.go @@ -16,13 +16,11 @@ var ( ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath, signer string) *MsgProvideCounterparty { - counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) - +func NewMsgProvideCounterparty(channelID, counterpartyChannelID string, signer string) *MsgProvideCounterparty { return &MsgProvideCounterparty{ - Signer: signer, - ChannelId: clientID, - Counterparty: counterparty, + Signer: signer, + ChannelId: channelID, + CounterpartyChannelId: counterpartyChannelID, } } @@ -36,7 +34,7 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { return err } - if err := msg.Counterparty.Validate(); err != nil { + if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { return err } diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index f61f8a1a052..bac3552e9f1 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -32,33 +32,25 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { ibcerrors.ErrInvalidAddress, }, { - "failure: invalid client ID", + "failure: invalid channel ID", func() { msg.ChannelId = "" }, host.ErrInvalidID, }, { - "failure: invalid counterparty client ID", + "failure: invalid counterparty channel ID", func() { - msg.Counterparty.ClientId = "" + msg.CounterpartyChannelId = "" }, host.ErrInvalidID, }, - { - "failure: empty key path of counterparty of merkle path prefix", - func() { - msg.Counterparty.MerklePathPrefix.KeyPath = nil - }, - types.ErrInvalidCounterparty, - }, } for _, tc := range testCases { msg = types.NewMsgProvideCounterparty( ibctesting.FirstClientID, ibctesting.SecondClientID, - commitmenttypes.NewMerklePath([]byte("key")), ibctesting.TestAccAddress, ) diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index 626e262a3d9..22b052db787 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -36,8 +36,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgProvideCounterparty struct { // unique identifier we will use to write all packet messages sent to counterparty ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // counterparty client - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` + // counterparty channel identifier + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` // signer address Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } @@ -204,37 +204,37 @@ func init() { func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } var fileDescriptor_3c556aec8b7966db = []byte{ - // 478 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0xb5, 0xa5, 0x22, 0x07, 0x88, 0xca, 0xa0, 0x62, 0x19, 0xe1, 0x86, 0x0c, 0x50, 0x05, - 0xd5, 0x47, 0xcd, 0x02, 0x15, 0x12, 0x52, 0x33, 0x75, 0x88, 0x14, 0x65, 0xe8, 0xc0, 0x12, 0xd9, - 0xe7, 0xc7, 0xe5, 0xd4, 0x9c, 0xcf, 0xba, 0xbb, 0x58, 0xed, 0x46, 0x99, 0x18, 0xf9, 0x09, 0xfc, - 0x84, 0x88, 0x5f, 0xd1, 0xb1, 0x23, 0x13, 0x42, 0xc9, 0xd0, 0xbf, 0x81, 0x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 0x74, 0x87, 0x49, 0x92, 0xbf, 0x23, 0x42, 0x26, 0xa3, - 0x21, 0xe8, 0x6a, 0x9c, 0x76, 0x6c, 0x9e, 0xcc, 0x49, 0x06, 0x3a, 0x5e, 0x2f, 0xd3, 0xf2, 0xe6, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x9c, 0x69, 0x26, 0xf1, 0x03, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x7d, 0x6d, 0xa9, 0xc8, 0x21, 0x44, 0x65, 0xa0, 0x8d, 0x8c, 0x70, 0x4b, 0x16, 0x50, + 0xa4, 0xde, 0x51, 0x23, 0x21, 0xa8, 0x90, 0x90, 0x9a, 0xa9, 0x43, 0xa4, 0x28, 0x43, 0x07, 0x96, + 0xc8, 0x3e, 0x3f, 0x2e, 0xa7, 0xfa, 0x7c, 0xd6, 0xdd, 0xc5, 0x6a, 0x37, 0xca, 0xc4, 0xc8, 0xc8, + 0xc8, 0x47, 0xc8, 0xc7, 0xe8, 0xd8, 0x91, 0x09, 0xa1, 0x64, 0xe8, 0xd7, 0x40, 0x76, 0x5c, 0x63, + 0xaa, 0x00, 0x65, 0xf3, 0xbd, 0xf7, 0x7b, 0xef, 0xfd, 0xdf, 0xf3, 0x7b, 0xf8, 0x89, 0x88, 0x18, + 0x65, 0x4a, 0x03, 0xcd, 0x42, 0x76, 0x0c, 0xd6, 0x80, 0xce, 0x41, 0xd3, 0x7c, 0x8f, 0xda, 0x13, + 0x92, 0x69, 0x65, 0x95, 0xdb, 0x16, 0x11, 0x23, 0x05, 0x42, 0x9a, 0x08, 0xc9, 0xf7, 0xbc, 0x07, + 0x5c, 0x71, 0x55, 0x42, 0xb4, 0xf8, 0x5a, 0xf0, 0xde, 0xd3, 0x3a, 0x25, 0x53, 0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xda, 0x32, 0x28, 0x33, 0xdc, 0xbc, 0xa9, 0xb7, 0xb8, 0x7d, 0x5d, 0xf1, 0x55, + 0x3b, 0xff, 0x18, 0xf8, 0xfe, 0x5a, 0x91, 0x2b, 0x38, 0x5b, 0xc1, 0xab, 0x7d, 0xc3, 0x5d, 0x85, + 0xef, 0xfe, 0xde, 0x77, 0x97, 0xfc, 0x69, 0x79, 0xc8, 0xf5, 0x8a, 0x5e, 0x70, 0x73, 0xb6, 0x56, + 0x77, 0x86, 0xf0, 0xfd, 0x65, 0x6b, 0xf2, 0xfc, 0xaf, 0xb9, 0x96, 0x44, 0x78, 0xaf, 0xfe, 0x37, + 0xe2, 0x4a, 0x83, 0x77, 0xeb, 0xc3, 0xe5, 0xb4, 0x8b, 0x0e, 0x8e, 0xce, 0x67, 0x3e, 0xba, 0x98, + 0xf9, 0xe8, 0xc7, 0xcc, 0x47, 0x9f, 0xe7, 0xbe, 0x73, 0x31, 0xf7, 0x9d, 0x6f, 0x73, 0xdf, 0x79, + 0xf7, 0x86, 0x0b, 0x3b, 0x9e, 0x44, 0xc5, 0x0f, 0xa4, 0xd5, 0xca, 0x8b, 0x88, 0xed, 0x72, 0x45, + 0xf3, 0xd7, 0x54, 0xaa, 0x78, 0x92, 0x80, 0x69, 0xde, 0xe0, 0x6e, 0x75, 0x84, 0xf6, 0x34, 0x03, + 0x13, 0xad, 0x97, 0x37, 0xf1, 0xe2, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x8b, 0x7a, 0x32, + 0xaa, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -384,16 +384,13 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x1a } - { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.ChannelId) > 0 { i -= len(m.ChannelId) copy(dAtA[i:], m.ChannelId) @@ -525,8 +522,10 @@ func (m *MsgProvideCounterparty) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Counterparty.Size() - n += 1 + l + sovTx(uint64(l)) + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -644,9 +643,9 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -656,24 +655,23 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto index 9e831d45944..c179e9ae25c 100644 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -7,7 +7,6 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/type import "gogoproto/gogo.proto"; import "ibc/core/commitment/v2/commitment.proto"; -import "ibc/core/packetserver/v1/counterparty.proto"; import "cosmos/msg/v1/msg.proto"; // Msg defines the ibc/packetserver Msg service. @@ -31,8 +30,8 @@ message MsgProvideCounterparty { // unique identifier we will use to write all packet messages sent to counterparty string channel_id = 1; - // counterparty client - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + // counterparty channel identifier + string counterparty_channel_id = 2; // signer address string signer = 3; } diff --git a/testing/endpoint.go b/testing/endpoint.go index 18f5973a481..05ad6c1e654 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -178,9 +178,7 @@ func (endpoint *Endpoint) FreezeClient() { // ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint. func (endpoint *Endpoint) ProvideCounterparty() (err error) { - merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - - msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String()) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) @@ -190,7 +188,7 @@ func (endpoint *Endpoint) ProvideCounterparty() (err error) { // CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint. func (endpoint *Endpoint) CreateChannel() (err error) { - msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, merklePath, endpoint.Chain.SenderAccount.GetAddress().String()) + msg := packetservertypes.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String()) // create channel res, err := endpoint.Chain.SendMsgs(msg) diff --git a/testing/values.go b/testing/values.go index 61fe31badbb..9571004c2db 100644 --- a/testing/values.go +++ b/testing/values.go @@ -77,5 +77,5 @@ var ( prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) // unusedHash is a placeholder hash used for testing. unusedHash = tmhash.Sum([]byte{0x00}) - merklePath = commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + MerklePath = commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) )