diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 29f0ad19597..390c719b271 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -148,7 +148,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) + creator, found := k.ClientKeeper.GetCreator(ctx, msg.Counterparty.ClientId) if !found { return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "client creator must be set") } @@ -157,13 +157,13 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) } - if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ClientId); ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) + if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId); ok { + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ChannelId) } - k.PacketServerKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) + k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, msg.Counterparty) // Delete client creator from state as it is not needed after this point. - k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) + k.ClientKeeper.DeleteCreator(ctx, msg.Counterparty.ClientId) return &packetservertypes.MsgProvideCounterpartyResponse{}, nil } diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 7f352c689eb..1e54f08eecd 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1222,7 +1222,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { { "failure: unknown client identifier", func() { - msg.ClientId = ibctesting.InvalidID + msg.Counterparty.ClientId = ibctesting.InvalidID }, ibcerrors.ErrUnauthorized, }, @@ -1237,7 +1237,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "failure: counterparty already exists", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) }, packetservertypes.ErrInvalidCounterparty, }, diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 45485e804a6..0482ba21e30 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -39,9 +39,9 @@ The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded s return err } - counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) + counterparty := types.NewCounterparty(clientIdentifier, counterpartyClientIdentifier, counterpartyMerklePathPrefix) msg := types.MsgProvideCounterparty{ - ClientId: clientIdentifier, + ChannelId: clientIdentifier, Counterparty: counterparty, Signer: clientCtx.GetFromAddress().String(), } diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 50553fd454d..eaa16b9f80f 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -36,7 +36,8 @@ func (k Keeper) SendPacket( if !ok { return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) } - destChannel := counterparty.ClientId + destChannel := counterparty.CounterpartyChannelId + clientID := counterparty.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -54,17 +55,17 @@ func (k Keeper) SendPacket( } // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) + if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", clientID) } - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) if err != nil { return 0, err } @@ -113,9 +114,11 @@ func (k Keeper) RecvPacket( if !ok { return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) } - if counterparty.ClientId != packet.SourceChannel { + + if counterparty.CounterpartyChannelId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId // check if packet timed out by comparing it with the latest height of the chain sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 @@ -144,14 +147,14 @@ func (k Keeper) RecvPacket( if err := k.ClientKeeper.VerifyMembership( ctx, - packet.DestinationChannel, + clientID, proofHeight, 0, 0, proof, merklePath, commitment, ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) + return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", clientID) } // Set Packet Receipt to prevent timeout from occurring on counterparty @@ -248,6 +251,7 @@ func (k Keeper) AcknowledgePacket( if counterparty.ClientId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { @@ -272,14 +276,14 @@ func (k Keeper) AcknowledgePacket( if err := k.ClientKeeper.VerifyMembership( ctx, - packet.SourceChannel, + clientID, proofHeight, 0, 0, proofAcked, merklePath, channeltypes.CommitAcknowledgement(acknowledgement), ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) + return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", clientID) } k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) @@ -318,6 +322,7 @@ func (k Keeper) TimeoutPacket( if counterparty.ClientId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } + clientID := counterparty.ClientId // check that timeout height or timeout timestamp has passed on the other end proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) @@ -354,13 +359,13 @@ func (k Keeper) TimeoutPacket( if err := k.ClientKeeper.VerifyNonMembership( ctx, - packet.SourceChannel, + clientID, proofHeight, 0, 0, proof, merklePath, ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", clientID) } // delete packet commitment to prevent replay diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/counterparty.go index 09fda058b43..d63a92da3e8 100644 --- a/modules/core/packet-server/types/counterparty.go +++ b/modules/core/packet-server/types/counterparty.go @@ -8,10 +8,11 @@ import ( ) // NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { +func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { return Counterparty{ - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, + ClientId: clientID, + CounterpartyChannelId: counterpartyChannelID, + MerklePathPrefix: merklePathPrefix, } } @@ -21,6 +22,10 @@ func (c Counterparty) Validate() error { return err } + if err := host.ChannelIdentifierValidator(c.CounterpartyChannelId); err != nil { + return err + } + if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) } diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/counterparty.pb.go index d8612d6a3f9..2358d3b8213 100644 --- a/modules/core/packet-server/types/counterparty.pb.go +++ b/modules/core/packet-server/types/counterparty.pb.go @@ -26,10 +26,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Counterparty defines the counterparty for a light client to implement IBC eureka protocol type Counterparty struct { - // the client identifier of the counterparty chain + // the client identifier of the light client representing the counterparty chain ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the merkle path that all ICS24 paths will be stored under - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` + // the counterparty identifier that must be used by the packet + CounterpartyChannelId string `protobuf:"bytes,2,opt,name=counterparty_channel_id,json=counterpartyChannelId,proto3" json:"counterparty_channel_id,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` } func (m *Counterparty) Reset() { *m = Counterparty{} } @@ -72,6 +76,13 @@ func (m *Counterparty) GetClientId() string { return "" } +func (m *Counterparty) GetCounterpartyChannelId() string { + if m != nil { + return m.CounterpartyChannelId + } + return "" +} + func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { if m != nil { return m.MerklePathPrefix @@ -88,25 +99,27 @@ func init() { } var fileDescriptor_e0c60a0709a0040c = []byte{ - // 286 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4b, 0xc3, 0x40, - 0x14, 0xc6, 0x73, 0x22, 0x62, 0xa3, 0x83, 0x04, 0x87, 0x52, 0xe1, 0x2c, 0x5d, 0x2c, 0x48, 0xef, - 0x68, 0x9c, 0x04, 0xa7, 0x3a, 0x39, 0x08, 0xa5, 0x43, 0x07, 0x97, 0x90, 0x5c, 0x9e, 0xc9, 0xd1, - 0x5c, 0xee, 0xb8, 0x5c, 0x0e, 0x3b, 0xfb, 0x0f, 0xf8, 0x67, 0x75, 0xec, 0xe8, 0x24, 0x92, 0xfc, - 0x23, 0x92, 0x44, 0x42, 0xb6, 0xbb, 0x8f, 0xdf, 0xfb, 0xbe, 0xf7, 0x3e, 0xf7, 0x9e, 0x47, 0x8c, - 0x32, 0xa9, 0x81, 0xaa, 0x90, 0xed, 0xc0, 0x14, 0xa0, 0x2d, 0x68, 0x6a, 0x97, 0x94, 0xc9, 0x32, - 0x37, 0xa0, 0x55, 0xa8, 0xcd, 0x9e, 0x28, 0x2d, 0x8d, 0xf4, 0xc6, 0x3c, 0x62, 0xa4, 0x81, 0xc9, - 0x10, 0x26, 0x76, 0x39, 0xb9, 0x4e, 0x64, 0x22, 0x5b, 0x88, 0x36, 0xaf, 0x8e, 0x9f, 0xdc, 0xf5, - 0xe6, 0x4c, 0x0a, 0xc1, 0x8d, 0x80, 0xdc, 0x50, 0xeb, 0x0f, 0x7e, 0x1d, 0x38, 0xfb, 0x44, 0xee, - 0xe5, 0xf3, 0x20, 0xcf, 0xbb, 0x71, 0x47, 0x2c, 0xe3, 0x90, 0x9b, 0x80, 0xc7, 0x63, 0x34, 0x45, - 0xf3, 0xd1, 0xe6, 0xbc, 0x13, 0x5e, 0x62, 0x6f, 0xeb, 0x7a, 0x02, 0xf4, 0x2e, 0x83, 0x40, 0x85, - 0x26, 0x0d, 0x94, 0x86, 0x77, 0xfe, 0x31, 0x3e, 0x99, 0xa2, 0xf9, 0x85, 0x3f, 0x23, 0xfd, 0x8e, - 0x83, 0x14, 0xeb, 0x93, 0xd7, 0x76, 0x62, 0x1d, 0x9a, 0x74, 0x75, 0x7a, 0xf8, 0xb9, 0x75, 0x36, - 0x57, 0xa2, 0x57, 0xd6, 0xad, 0xc3, 0x6a, 0x7b, 0xa8, 0x30, 0x3a, 0x56, 0x18, 0xfd, 0x56, 0x18, - 0x7d, 0xd5, 0xd8, 0x39, 0xd6, 0xd8, 0xf9, 0xae, 0xb1, 0xf3, 0xf6, 0x94, 0x70, 0x93, 0x96, 0x51, - 0x63, 0x49, 0x99, 0x2c, 0x84, 0x2c, 0x28, 0x8f, 0xd8, 0x22, 0x91, 0xd4, 0x3e, 0x52, 0x21, 0xe3, - 0x32, 0x83, 0x62, 0xd8, 0xe2, 0xe2, 0xbf, 0x46, 0xb3, 0x57, 0x50, 0x44, 0x67, 0xed, 0x91, 0x0f, - 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x87, 0x96, 0x5e, 0x91, 0x6c, 0x01, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc3, 0x30, + 0x1c, 0xc6, 0x1b, 0x15, 0x71, 0xd5, 0x83, 0x14, 0xc5, 0x31, 0x21, 0x8e, 0x5d, 0x1c, 0xc8, 0x12, + 0x36, 0x41, 0x10, 0x3c, 0x6d, 0xa7, 0x1d, 0x84, 0xb1, 0xc3, 0x0e, 0x5e, 0x4a, 0x9b, 0xfe, 0x6d, + 0xc3, 0x9a, 0x26, 0xa4, 0x59, 0x70, 0x6f, 0xe1, 0xfb, 0xf8, 0x02, 0x3b, 0xee, 0xe8, 0x49, 0x64, + 0x7b, 0x11, 0x69, 0x2b, 0x23, 0xb7, 0xe4, 0xff, 0xfd, 0xf2, 0xe5, 0xfb, 0x7f, 0xfe, 0x03, 0x8f, + 0x19, 0x65, 0x52, 0x03, 0x55, 0x11, 0x5b, 0x82, 0x29, 0x41, 0x5b, 0xd0, 0xd4, 0x0e, 0x29, 0x93, + 0xab, 0xc2, 0x80, 0x56, 0x91, 0x36, 0x6b, 0xa2, 0xb4, 0x34, 0x32, 0x68, 0xf3, 0x98, 0x91, 0x0a, + 0x26, 0x2e, 0x4c, 0xec, 0xb0, 0x73, 0x95, 0xca, 0x54, 0xd6, 0x10, 0xad, 0x4e, 0x0d, 0xdf, 0xb9, + 0x3f, 0x98, 0x33, 0x29, 0x04, 0x37, 0x02, 0x0a, 0x43, 0xed, 0xc8, 0xb9, 0x35, 0x60, 0xef, 0x0b, + 0xf9, 0x17, 0x13, 0xe7, 0xbf, 0xe0, 0xd6, 0x6f, 0xb1, 0x9c, 0x43, 0x61, 0x42, 0x9e, 0xb4, 0x51, + 0x17, 0xf5, 0x5b, 0xf3, 0xb3, 0x66, 0x30, 0x4d, 0x82, 0x27, 0xff, 0xc6, 0x0d, 0x17, 0xb2, 0x2c, + 0x2a, 0x0a, 0xc8, 0x2b, 0xf4, 0xa8, 0x46, 0xaf, 0x5d, 0x79, 0xd2, 0xa8, 0xd3, 0x24, 0x58, 0xf8, + 0x81, 0x00, 0xbd, 0xcc, 0x21, 0x54, 0x91, 0xc9, 0x42, 0xa5, 0xe1, 0x9d, 0x7f, 0xb4, 0x8f, 0xbb, + 0xa8, 0x7f, 0x3e, 0xea, 0x91, 0xc3, 0x6e, 0x4e, 0x3a, 0x3b, 0x22, 0xaf, 0xf5, 0x8b, 0x59, 0x64, + 0xb2, 0xf1, 0xc9, 0xe6, 0xe7, 0xce, 0x9b, 0x5f, 0x8a, 0xc3, 0x64, 0x56, 0x3b, 0x8c, 0x17, 0x9b, + 0x1d, 0x46, 0xdb, 0x1d, 0x46, 0xbf, 0x3b, 0x8c, 0x3e, 0xf7, 0xd8, 0xdb, 0xee, 0xb1, 0xf7, 0xbd, + 0xc7, 0xde, 0xdb, 0x4b, 0xca, 0x4d, 0xb6, 0x8a, 0x2b, 0x4b, 0xca, 0x64, 0x29, 0x64, 0x49, 0x79, + 0xcc, 0x06, 0xa9, 0xa4, 0xf6, 0x99, 0x0a, 0x99, 0xac, 0x72, 0x28, 0xdd, 0xf6, 0x07, 0xff, 0xf5, + 0x9b, 0xb5, 0x82, 0x32, 0x3e, 0xad, 0xcb, 0x79, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x34, 0xa3, + 0x29, 0x7a, 0xa4, 0x01, 0x00, 0x00, } func (m *Counterparty) Marshal() (dAtA []byte, err error) { @@ -138,7 +151,14 @@ func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintCounterparty(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x12 + } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) @@ -170,6 +190,10 @@ func (m *Counterparty) Size() (n int) { if l > 0 { n += 1 + l + sovCounterparty(uint64(l)) } + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } l = m.MerklePathPrefix.Size() n += 1 + l + sovCounterparty(uint64(l)) return n @@ -243,6 +267,38 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + 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 ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) } diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/counterparty_test.go index 20772bd7598..462861a211d 100644 --- a/modules/core/packet-server/types/counterparty_test.go +++ b/modules/core/packet-server/types/counterparty_test.go @@ -15,48 +15,63 @@ func TestValidateCounterparty(t *testing.T) { testCases := []struct { name string clientID string + channelID string merklePathPrefix commitmenttypes.MerklePath expError error }{ { "success", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc")), nil, }, { "success with multiple element prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), nil, }, { "success with multiple element prefix, last prefix empty", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), nil, }, { "success with single empty key prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte("")), nil, }, { "failure: invalid client id", "", + ibctesting.FirstChannelID, + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: invalid channel id", + ibctesting.FirstClientID, + "", commitmenttypes.NewMerklePath([]byte("ibc")), host.ErrInvalidID, }, { "failure: empty merkle path prefix", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath(), types.ErrInvalidCounterparty, }, { "failure: empty key in merkle path prefix first element", ibctesting.FirstClientID, + ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), types.ErrInvalidCounterparty, }, @@ -65,7 +80,7 @@ func TestValidateCounterparty(t *testing.T) { for _, tc := range testCases { tc := tc - counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) + counterparty := types.NewCounterparty(tc.clientID, tc.channelID, tc.merklePathPrefix) err := counterparty.Validate() expPass := tc.expError == nil diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go index f8c55ad8a72..3ecdaa5326e 100644 --- a/modules/core/packet-server/types/msgs.go +++ b/modules/core/packet-server/types/msgs.go @@ -16,12 +16,12 @@ var ( ) // NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { - counterparty := NewCounterparty(counterpartyID, merklePathPrefix) +func NewMsgProvideCounterparty(signer, clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { + counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) return &MsgProvideCounterparty{ Signer: signer, - ClientId: clientID, + ChannelId: clientID, Counterparty: counterparty, } } @@ -32,7 +32,7 @@ func (msg *MsgProvideCounterparty) ValidateBasic() error { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) } - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { + if err := host.ChannelIdentifierValidator(msg.ChannelId); 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 50e8848ae7c..e3ad1c6b99b 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -32,7 +32,7 @@ func (s *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { { "failure: invalid client ID", func() { - msg.ClientId = "" + msg.ChannelId = "" }, host.ErrInvalidID, }, diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go index 8350e3a7fd0..46212f381ec 100644 --- a/modules/core/packet-server/types/tx.pb.go +++ b/modules/core/packet-server/types/tx.pb.go @@ -33,8 +33,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty // client identifier was not provided in the initial MsgCreateClient message. type MsgProvideCounterparty struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // 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"` // signer address @@ -119,29 +119,29 @@ func init() { func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } var fileDescriptor_3c556aec8b7966db = []byte{ - // 350 bytes of a gzipped FileDescriptorProto + // 351 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x4c, 0x4a, 0xd6, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0x29, 0x4e, 0x2d, 0x2a, 0x4b, 0x2d, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xc8, 0x4c, 0x4a, 0xd6, 0x03, 0x29, 0xd1, 0x43, 0x56, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x4b, 0x69, 0xe3, 0x34, 0x32, 0x39, 0xbf, 0x34, 0xaf, 0x24, 0xb5, 0xa8, 0x20, 0xb1, 0xa8, 0xa4, 0x12, 0xaa, 0x58, 0x3c, 0x39, 0xbf, 0x38, 0x37, - 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x22, 0xb7, 0x38, 0x1d, 0x22, 0xa1, 0xb4, 0x81, 0x91, + 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x22, 0xb7, 0x38, 0x1d, 0x22, 0xa1, 0xb4, 0x89, 0x91, 0x4b, 0xcc, 0xb7, 0x38, 0x3d, 0xa0, 0x28, 0xbf, 0x2c, 0x33, 0x25, 0xd5, 0x19, 0x49, 0xa7, 0x90, - 0x34, 0x17, 0x67, 0x72, 0x4e, 0x66, 0x6a, 0x5e, 0x49, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3, - 0x06, 0x67, 0x10, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x1a, 0x09, 0x26, - 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0x9e, 0xd0, 0x43, 0x36, 0xda, 0x89, 0xe5, 0xc4, - 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, 0x8b, - 0x24, 0x98, 0xc1, 0x76, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, 0xd0, - 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x71, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, - 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, 0x3e, - 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, 0x86, - 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, - 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, - 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4b, 0x99, - 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, - 0xc8, 0xf1, 0xac, 0x0b, 0x8d, 0xe8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x34, 0x1a, - 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x61, 0x52, 0xe3, 0xab, 0x61, 0x02, 0x00, 0x00, + 0x2c, 0x17, 0x57, 0x72, 0x46, 0x62, 0x5e, 0x5e, 0x6a, 0x4e, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x67, 0x10, 0x27, 0x54, 0xc4, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x22, 0x09, + 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0xde, 0xd0, 0x43, 0x36, 0xdc, 0x89, 0xe5, + 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, + 0x8b, 0x24, 0x98, 0xc1, 0x96, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, + 0xd0, 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x73, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, + 0x71, 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, + 0x7e, 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, + 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, + 0x21, 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4f, + 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, + 0xc5, 0xc8, 0x31, 0xad, 0x0b, 0x8d, 0xea, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x44, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, 0x6d, 0x15, 0x38, 0x63, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -263,10 +263,10 @@ func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) } i-- dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) i-- dAtA[i] = 0xa } @@ -313,7 +313,7 @@ func (m *MsgProvideCounterparty) Size() (n int) { } var l int _ = l - l = len(m.ClientId) + l = len(m.ChannelId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -372,7 +372,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -400,7 +400,7 @@ func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/counterparty.proto index 906c0db3fa2..f708694b21e 100644 --- a/proto/ibc/core/packetserver/v1/counterparty.proto +++ b/proto/ibc/core/packetserver/v1/counterparty.proto @@ -9,8 +9,12 @@ import "ibc/core/commitment/v2/commitment.proto"; // Counterparty defines the counterparty for a light client to implement IBC eureka protocol message Counterparty { - // the client identifier of the counterparty chain + // the client identifier of the light client representing the counterparty chain string client_id = 1; - // the merkle path that all ICS24 paths will be stored under - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; + // the counterparty identifier that must be used by the packet + string counterparty_channel_id = 2; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. In backwards compatible cases, we will append the channelID and sequence in order to create + // the final path. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto index dec4a17f42c..2a0b835a179 100644 --- a/proto/ibc/core/packetserver/v1/tx.proto +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -25,8 +25,8 @@ message MsgProvideCounterparty { option (gogoproto.goproto_getters) = false; - // client unique identifier - string client_id = 1; + // 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]; // signer address