From d206c5b2efcc997cf19c04c63a1cab0b37b748ec Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 9 Oct 2024 15:24:27 +0300 Subject: [PATCH 1/5] chore: clean up msgprovidecounterparty. --- modules/core/keeper/msg_server.go | 2 +- modules/core/keeper/msg_server_test.go | 10 +- modules/core/packet-server/client/cli/tx.go | 43 ++------ modules/core/packet-server/types/msgs.go | 12 +-- modules/core/packet-server/types/msgs_test.go | 14 +-- modules/core/packet-server/types/tx.pb.go | 102 +++++++++--------- proto/ibc/core/packetserver/v1/tx.proto | 5 +- testing/endpoint.go | 6 +- testing/values.go | 2 +- 9 files changed, 78 insertions(+), 118 deletions(-) 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, 0xec, 0x5c, 0x53, 0xb7, - 0x4a, 0xa0, 0x6c, 0x7e, 0xcf, 0xdf, 0xfb, 0xde, 0xf7, 0xe9, 0xdd, 0x87, 0x9f, 0xf3, 0x98, 0x12, - 0x2a, 0x15, 0x90, 0x2c, 0xa2, 0x47, 0x60, 0x34, 0xa8, 0x1c, 0x14, 0xc9, 0x77, 0x89, 0x39, 0x0e, - 0x32, 0x25, 0x8d, 0x74, 0x5c, 0x1e, 0xd3, 0xa0, 0x80, 0x04, 0x55, 0x48, 0x90, 0xef, 0x7a, 0x8f, - 0x99, 0x64, 0xb2, 0x04, 0x91, 0xe2, 0x6b, 0x86, 0xf7, 0x5e, 0xce, 0x29, 0xa9, 0x14, 0x82, 0x1b, - 0x01, 0xa9, 0x21, 0x79, 0x58, 0xa9, 0x2c, 0xf0, 0xd5, 0xd2, 0xdd, 0x54, 0x8e, 0x52, 0x03, 0x2a, - 0x8b, 0x94, 0x39, 0xb1, 0xe0, 0x27, 0x54, 0x6a, 0x21, 0x35, 0x11, 0x9a, 0x15, 0x08, 0xa1, 0xd9, - 0xec, 0x47, 0xf3, 0x07, 0xc2, 0x9b, 0x1d, 0xcd, 0xba, 0x4a, 0xe6, 0x3c, 0x81, 0x76, 0x65, 0xd2, - 0x79, 0x86, 0x31, 0x1d, 0x44, 0x69, 0x0a, 0xc3, 0x3e, 0x4f, 0x5c, 0xd4, 0x40, 0xdb, 0xf5, 0x5e, - 0xdd, 0x76, 0x0e, 0x12, 0xa7, 0x8b, 0xef, 0x57, 0x17, 0xb9, 0x2b, 0x0d, 0xb4, 0x7d, 0x2f, 0x7c, - 0x11, 0x2c, 0xf3, 0x1b, 0x54, 0xc9, 0xf7, 0xd7, 0xce, 0x7e, 0x6d, 0xd5, 0x7a, 0xd7, 0x18, 0x9c, - 0x4d, 0xbc, 0xae, 0x39, 0x4b, 0x41, 0xb9, 0xab, 0xe5, 0x32, 0x5b, 0xed, 0x3d, 0xfc, 0xfa, 0x7d, - 0xab, 0xf6, 0xe5, 0x62, 0xdc, 0xb2, 0x8d, 0x66, 0x03, 0xfb, 0x8b, 0x35, 0xf7, 0x40, 0x67, 0x32, - 0xd5, 0xd0, 0x1c, 0x23, 0xbc, 0xd1, 0xd1, 0xac, 0xad, 0x20, 0x32, 0xd0, 0x9e, 0x69, 0x76, 0x9e, - 0xe2, 0x3a, 0x1d, 0x72, 0x48, 0xcd, 0x95, 0x9f, 0xbb, 0xb3, 0xc6, 0x41, 0xe2, 0x1c, 0x62, 0x47, - 0x80, 0x3a, 0x1a, 0x42, 0x3f, 0x8b, 0xcc, 0xa0, 0x9f, 0x29, 0xf8, 0xc4, 0x8f, 0xad, 0xa9, 0xe6, - 0x95, 0xa9, 0xca, 0x19, 0xf2, 0x30, 0xe8, 0x94, 0x13, 0xdd, 0xc8, 0x0c, 0xac, 0xa1, 0x0d, 0x31, - 0xef, 0x74, 0x4b, 0x86, 0xdb, 0x9b, 0xfa, 0x80, 0xdd, 0x9b, 0x8a, 0x2f, 0xed, 0xfc, 0xe3, 0x14, - 0x7b, 0x6b, 0x05, 0x57, 0x78, 0xba, 0x82, 0x57, 0x3b, 0x9a, 0x39, 0x12, 0x3f, 0xb8, 0xee, 0xbb, - 0xb5, 0xfc, 0x26, 0x37, 0x37, 0x7a, 0xe1, 0xed, 0xb1, 0x73, 0x75, 0xa7, 0x08, 0x3f, 0x5a, 0xf4, - 0x80, 0x5e, 0xff, 0x95, 0x6b, 0xc1, 0x84, 0xf7, 0xf6, 0x7f, 0x27, 0x2e, 0x35, 0x78, 0x77, 0x3e, - 0x5f, 0x8c, 0x5b, 0x68, 0xff, 0xf0, 0x6c, 0xe2, 0xa3, 0xf3, 0x89, 0x8f, 0x7e, 0x4f, 0x7c, 0xf4, - 0x6d, 0xea, 0xd7, 0xce, 0xa7, 0x7e, 0xed, 0xe7, 0xd4, 0xaf, 0x7d, 0x7c, 0xcf, 0xb8, 0x19, 0x8c, - 0xe2, 0xe2, 0x80, 0xc4, 0x86, 0x81, 0xc7, 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, 0x52, 0x0a, 0x2b, + 0x21, 0xb5, 0x34, 0x0f, 0x1a, 0xaf, 0x0a, 0xdc, 0x62, 0xca, 0x48, 0x65, 0xa8, 0x34, 0xbc, 0x28, + 0x28, 0x0d, 0x5f, 0x38, 0x3a, 0x5f, 0x10, 0xde, 0xec, 0x1b, 0x3e, 0xd0, 0x2a, 0x17, 0x31, 0xf4, + 0xd4, 0x24, 0xb5, 0xa0, 0xb3, 0x50, 0xdb, 0x53, 0xf7, 0x31, 0xc6, 0x6c, 0x1c, 0xa6, 0x29, 0x24, + 0x23, 0x11, 0xb7, 0xd1, 0x0e, 0x7a, 0xd6, 0x1a, 0xb6, 0x2a, 0xcb, 0x61, 0xec, 0xbe, 0xc4, 0x5b, + 0xac, 0x81, 0x8f, 0x1a, 0xec, 0x4a, 0xc9, 0x3e, 0x6c, 0xba, 0x7b, 0x75, 0xdc, 0x26, 0x5e, 0x37, + 0x82, 0xa7, 0xa0, 0xdb, 0xab, 0x25, 0x56, 0xbd, 0xf6, 0xef, 0x7d, 0xfa, 0xba, 0xed, 0x7c, 0xbc, + 0x9c, 0x76, 0x2b, 0x43, 0x67, 0x07, 0xfb, 0xcb, 0x95, 0x0d, 0xc1, 0x64, 0x2a, 0x35, 0xd0, 0x99, + 0x22, 0xbc, 0xd1, 0x37, 0xbc, 0xa7, 0x21, 0xb4, 0x50, 0x55, 0x70, 0x1f, 0xe1, 0x16, 0x4b, 0x04, + 0xa4, 0xf6, 0x97, 0xea, 0xdb, 0x0b, 0xc3, 0x61, 0xec, 0x1e, 0x61, 0x57, 0x82, 0x3e, 0x4e, 0x60, + 0x94, 0x85, 0x76, 0x3c, 0xca, 0x34, 0xbc, 0x17, 0x27, 0xa5, 0xde, 0x3b, 0x41, 0x87, 0xd4, 0xd3, + 0x6f, 0xcc, 0x2f, 0x0f, 0x48, 0xbf, 0x8c, 0x18, 0x84, 0x76, 0x7c, 0xb0, 0x76, 0xfe, 0x7d, 0xdb, + 0x19, 0x6e, 0xc8, 0xda, 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("")) ) From 49b0b6515e5fb56f40fac95e5a92fbc7509083db Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 9 Oct 2024 18:22:50 +0300 Subject: [PATCH 2/5] Update modules/core/keeper/msg_server_test.go Co-authored-by: Aditya <14364734+AdityaSripal@users.noreply.github.com> --- modules/core/keeper/msg_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index d91b5eaf10e..9a787a14cc6 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1217,7 +1217,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, ibctesting.MerklePath)) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, From 0a747109105b2a819fef4f57371dcdfc1b41f4e6 Mon Sep 17 00:00:00 2001 From: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:25:34 +0200 Subject: [PATCH 3/5] rename counterparty to channel in packetserver --- modules/core/04-channel/keeper/keeper.go | 16 +- modules/core/04-channel/keeper/keeper_test.go | 8 +- modules/core/04-channel/v2/keeper/relay.go | 6 +- modules/core/keeper/msg_server.go | 14 +- modules/core/keeper/msg_server_test.go | 14 +- modules/core/packet-server/client/cli/cli.go | 2 +- .../core/packet-server/client/cli/query.go | 10 +- .../core/packet-server/keeper/grpc_query.go | 18 +- .../packet-server/keeper/grpc_query_test.go | 48 ++-- modules/core/packet-server/keeper/keeper.go | 16 +- .../core/packet-server/keeper/keeper_test.go | 20 +- modules/core/packet-server/keeper/relay.go | 28 +-- .../core/packet-server/keeper/relay_test.go | 10 +- .../types/{counterparty.go => channel.go} | 12 +- .../{counterparty.pb.go => channel.pb.go} | 174 ++++++++------- .../{counterparty_test.go => channel_test.go} | 8 +- modules/core/packet-server/types/errors.go | 4 +- .../packet-server/types/expected_keepers.go | 4 +- modules/core/packet-server/types/keys.go | 4 +- modules/core/packet-server/types/query.pb.go | 211 +++++++++--------- .../core/packet-server/types/query.pb.gw.go | 44 ++-- .../v1/{counterparty.proto => channel.proto} | 10 +- proto/ibc/core/packetserver/v1/query.proto | 22 +- testing/values.go | 10 +- 24 files changed, 362 insertions(+), 351 deletions(-) rename modules/core/packet-server/types/{counterparty.go => channel.go} (63%) rename modules/core/packet-server/types/{counterparty.pb.go => channel.pb.go} (56%) rename modules/core/packet-server/types/{counterparty_test.go => channel_test.go} (91%) rename proto/ibc/core/packetserver/v1/{counterparty.proto => channel.proto} (59%) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 04ef2f584ed..8e8bff09e3b 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -827,28 +827,28 @@ func (k *Keeper) PruneAcknowledgements(ctx context.Context, portID, channelID st return totalPruned, totalRemaining, nil } -// GetV2Counterparty returns a version 2 counterparty for the given port and channel ID -// by converting the channel into a version 2 counterparty -func (k *Keeper) GetV2Counterparty(ctx context.Context, portID, channelID string) (packetserver.Counterparty, bool) { +// GetV2Channel returns a version 2 channel for the given port and channel ID +// by converting the v1 channel into a version 2 channel +func (k *Keeper) GetV2Channel(ctx context.Context, portID, channelID string) (packetserver.Channel, bool) { channel, ok := k.GetChannel(ctx, portID, channelID) if !ok { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } // Do not allow channel to be converted into a version 2 counterparty // if the channel is not OPEN or if it is ORDERED if channel.State != types.OPEN || channel.Ordering == types.ORDERED { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) if !ok { - return packetserver.Counterparty{}, false + return packetserver.Channel{}, false } merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - counterparty := packetserver.Counterparty{ + channelv2 := packetserver.Channel{ CounterpartyChannelId: channel.Counterparty.ChannelId, ClientId: connection.ClientId, MerklePathPrefix: merklePathPrefix, } - return counterparty, true + return channelv2, true } diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index d5401e94c66..72db0ca9800 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -549,7 +549,7 @@ func (suite *KeeperTestSuite) TestUnsetParams() { }) } -func (suite *KeeperTestSuite) TestGetV2Counterparty() { +func (suite *KeeperTestSuite) TestGetV2Channel() { var path *ibctesting.Path testCases := []struct { @@ -608,17 +608,17 @@ func (suite *KeeperTestSuite) TestGetV2Counterparty() { tc.malleate() - counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Counterparty(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) if tc.expPass { suite.Require().True(found) merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expCounterparty := packetservertypes.NewCounterparty(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + expCounterparty := packetservertypes.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) suite.Require().Equal(counterparty, expCounterparty) } else { suite.Require().False(found) - suite.Require().Equal(counterparty, packetservertypes.Counterparty{}) + suite.Require().Equal(counterparty, packetservertypes.Channel{}) } }) } diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 201df3cc5d4..4ba88f4e651 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -43,7 +43,7 @@ func (k *Keeper) sendPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, data[0].SourcePort, sourceID) if !ok { - return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceID) + return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceID) } } @@ -119,7 +119,7 @@ func (k Keeper) recvPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationId) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationId) } } if counterparty.ClientId != packet.SourceId { @@ -193,7 +193,7 @@ func (k Keeper) timeoutPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceId) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationId) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationId) } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e909ebfe765..a9cbe2b1060 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -30,8 +30,6 @@ var ( ) // CreateClient defines a rpc handler method for MsgCreateClient. -// It stores the signer of MsgCreateClient as the creator of the client, which is afterwards -// compared against the signer of MsgProvideCounterparty. // NOTE: The raw bytes of the concrete types encoded into protobuf.Any is passed to the client keeper. // The 02-client handler will route to the appropriate light client module based on client type and it is the responsibility // of the light client module to unmarshal and interpret the proto encoded bytes. @@ -149,8 +147,8 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg channelID := k.ChannelKeeper.GenerateChannelIdentifier(ctx) // Initialize counterparty with empty counterparty channel identifier. - counterparty := packetservertypes.NewCounterparty(msg.ClientId, "", msg.MerklePathPrefix) - k.PacketServerKeeper.SetCounterparty(ctx, channelID, counterparty) + counterparty := packetservertypes.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + k.PacketServerKeeper.SetChannel(ctx, channelID, counterparty) k.PacketServerKeeper.SetCreator(ctx, channelID, msg.Signer) @@ -172,13 +170,13 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "channel creator (%s) must match signer (%s)", creator, msg.Signer) } - counterparty, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId) + counterparty, ok := k.PacketServerKeeper.GetChannel(ctx, msg.ChannelId) if !ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty must exist for channel %s", msg.ChannelId) + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidChannel, "channel must exist for channel %s", msg.ChannelId) } counterparty.CounterpartyChannelId = msg.CounterpartyChannelId - k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, counterparty) + k.PacketServerKeeper.SetChannel(ctx, msg.ChannelId, counterparty) // Delete client creator from state as it is not needed after this point. k.PacketServerKeeper.DeleteCreator(ctx, msg.ChannelId) @@ -874,7 +872,7 @@ func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes. keeper.EmitChannelUpgradeConfirmEvent(ctx, msg.PortId, msg.ChannelId, channel) // Move channel to OPEN state if both chains have finished flushing in-flight packets. - // Counterparty channel state has been verified in ChanUpgradeConfirm. + // Channel channel state has been verified in ChanUpgradeConfirm. if channel.State == channeltypes.FLUSHCOMPLETE && msg.CounterpartyChannelState == channeltypes.FLUSHCOMPLETE { upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) if !found { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 9a787a14cc6..275d33e99a4 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // any non-nil value of packet is valid suite.Require().NotNil(packet) }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, false, false, @@ -658,7 +658,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { func() { packet.SourceChannel = "invalid-client" }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, }, { @@ -984,7 +984,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, - packetservertypes.ErrCounterpartyNotFound, + packetservertypes.ErrChannelNotFound, false, }, } @@ -1217,7 +1217,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewCounterparty(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), msg.ChannelId, packetservertypes.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, @@ -1231,9 +1231,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { { "failure: counterparty does not already exists", func() { - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.CounterpartyKey)) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(packetservertypes.ChannelKey)) }, - packetservertypes.ErrInvalidCounterparty, + packetservertypes.ErrInvalidChannel, }, } @@ -1258,7 +1258,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty channel id filled in and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ChannelID) + counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) suite.Require().Equal(counterparty.CounterpartyChannelId, path.EndpointB.ChannelID) diff --git a/modules/core/packet-server/client/cli/cli.go b/modules/core/packet-server/client/cli/cli.go index eff92825a94..5c5a897b0f9 100644 --- a/modules/core/packet-server/client/cli/cli.go +++ b/modules/core/packet-server/client/cli/cli.go @@ -19,7 +19,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( - getCmdQueryClient(), + getCmdQueryChannel(), ) return queryCmd diff --git a/modules/core/packet-server/client/cli/query.go b/modules/core/packet-server/client/cli/query.go index 7cebadf9a4d..a10f02c8801 100644 --- a/modules/core/packet-server/client/cli/query.go +++ b/modules/core/packet-server/client/cli/query.go @@ -13,8 +13,8 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// getCmdQueryClient defines the command to query the client information (creator and counterparty) for the given client ID. -func getCmdQueryClient() *cobra.Command { +// getCmdQueryChannel defines the command to query the client information (creator and counterparty) for the given client ID. +func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ Use: "client [client-id]", Short: "Query the information of a client.", @@ -28,11 +28,11 @@ func getCmdQueryClient() *cobra.Command { } clientID := args[0] - queryClient := types.NewQueryClient(clientCtx) + queryChannel := types.NewQueryClient(clientCtx) - req := &types.QueryClientRequest{ClientId: clientID} + req := &types.QueryChannelRequest{ChannelId: clientID} - res, err := queryClient.Client(cmd.Context(), req) + res, err := queryChannel.Channel(cmd.Context(), req) if err != nil { return err } diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/packet-server/keeper/grpc_query.go index 7e6b37878bf..b40f78ae261 100644 --- a/modules/core/packet-server/keeper/grpc_query.go +++ b/modules/core/packet-server/keeper/grpc_query.go @@ -28,31 +28,31 @@ func NewQueryServer(k *Keeper) types.QueryServer { } } -// Client implements the Query/Client gRPC method -func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) (*types.QueryClientResponse, error) { +// Channel implements the Query/Channel gRPC method +func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if err := host.ClientIdentifierValidator(req.ClientId); err != nil { + if err := host.ClientIdentifierValidator(req.ChannelId); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - res := types.QueryClientResponse{} + res := types.QueryChannelResponse{} sdkCtx := sdk.UnwrapSDKContext(ctx) - creator, foundCreator := q.GetCreator(sdkCtx, req.ClientId) - counterparty, foundCounterparty := q.GetCounterparty(sdkCtx, req.ClientId) + creator, foundCreator := q.GetCreator(sdkCtx, req.ChannelId) + channel, foundChannel := q.GetChannel(sdkCtx, req.ChannelId) - if !foundCreator && !foundCounterparty { + if !foundCreator && !foundChannel { return nil, status.Error( codes.NotFound, - errorsmod.Wrapf(types.ErrCounterpartyNotFound, "client-id: %s", req.ClientId).Error(), + errorsmod.Wrapf(types.ErrChannelNotFound, "client-id: %s", req.ChannelId).Error(), ) } - res.Counterparty = counterparty + res.Channel = channel res.Creator = creator return &res, nil diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/packet-server/keeper/grpc_query_test.go index 46fa6e5250b..322caef6a2b 100644 --- a/modules/core/packet-server/keeper/grpc_query_test.go +++ b/modules/core/packet-server/keeper/grpc_query_test.go @@ -12,11 +12,11 @@ import ( ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -func (suite *KeeperTestSuite) TestQueryClient() { +func (suite *KeeperTestSuite) TestQueryChannel() { var ( - req *types.QueryClientRequest - expCreator string - expCounterparty types.Counterparty + req *types.QueryChannelRequest + expCreator string + expChannel types.Channel ) testCases := []struct { @@ -28,11 +28,11 @@ func (suite *KeeperTestSuite) TestQueryClient() { "success", func() { ctx := suite.chainA.GetContext() - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(ctx, ibctesting.FirstChannelID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(ctx, ibctesting.FirstChannelID, expChannel) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, @@ -42,23 +42,23 @@ func (suite *KeeperTestSuite) TestQueryClient() { func() { expCreator = "" - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), ibctesting.FirstChannelID, expChannel) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, }, { - "success: no counterparty", + "success: no channel", func() { - expCounterparty = types.Counterparty{} + expChannel = types.Channel{} - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstChannelID, expCreator) - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, nil, @@ -73,16 +73,16 @@ func (suite *KeeperTestSuite) TestQueryClient() { { "no creator and no counterparty", func() { - req = &types.QueryClientRequest{ - ClientId: ibctesting.FirstClientID, + req = &types.QueryChannelRequest{ + ChannelId: ibctesting.FirstChannelID, } }, - status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: counterparty not found", ibctesting.FirstClientID)), + status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: counterparty not found", ibctesting.FirstChannelID)), }, { - "invalid clientID", + "invalid channelID", func() { - req = &types.QueryClientRequest{} + req = &types.QueryChannelRequest{} }, status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), }, @@ -96,19 +96,19 @@ func (suite *KeeperTestSuite) TestQueryClient() { expCreator = ibctesting.TestAccAddress merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) - expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} + expChannel = types.Channel{ClientId: ibctesting.SecondClientID, CounterpartyChannelId: ibctesting.SecondChannelID, MerklePathPrefix: merklePathPrefix} tc.malleate() queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.PacketServerKeeper) - res, err := queryServer.Client(suite.chainA.GetContext(), req) + res, err := queryServer.Channel(suite.chainA.GetContext(), req) expPass := tc.expError == nil if expPass { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expCreator, res.Creator) - suite.Require().Equal(expCounterparty, res.Counterparty) + suite.Require().Equal(expChannel, res.Channel) } else { suite.Require().ErrorIs(err, tc.expError) suite.Require().Nil(res) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 73b2d0358c0..9a2d9ca5169 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -48,21 +48,21 @@ func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.K return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), channelPrefix) } -// SetCounterparty sets the Counterparty for a given client identifier. -func (k *Keeper) SetCounterparty(ctx context.Context, clientID string, counterparty types.Counterparty) { +// SetChannel sets the Channel for a given client identifier. +func (k *Keeper) SetChannel(ctx context.Context, clientID string, counterparty types.Channel) { bz := k.cdc.MustMarshal(&counterparty) - k.ChannelStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) + k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) } -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Counterparty, bool) { +// GetChannel gets the Channel for a given client identifier. +func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel, bool) { store := k.ChannelStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) + bz := store.Get([]byte(types.ChannelKey)) if len(bz) == 0 { - return types.Counterparty{}, false + return types.Channel{}, false } - var counterparty types.Counterparty + var counterparty types.Channel k.cdc.MustUnmarshal(bz, &counterparty) return counterparty, true } diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index 67f9227c9d1..fbb0ee78967 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -8,22 +8,22 @@ import ( const testClientID = "tendermint-0" -func (suite *KeeperTestSuite) TestSetCounterparty() { +func (suite *KeeperTestSuite) TestSetChannel() { merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - counterparty := types.Counterparty{ + counterparty := types.Channel{ ClientId: testClientID, MerklePathPrefix: merklePathPrefix, } - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), testClientID, counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), testClientID, counterparty) - retrievedCounterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), testClientID) - suite.Require().True(found, "GetCounterparty does not return counterparty") - suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") + retrievedChannel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), testClientID) + suite.Require().True(found, "GetChannel does not return counterparty") + suite.Require().Equal(counterparty, retrievedChannel, "Channel retrieved not equal") - // Counterparty not yet stored for another client. - retrievedCounterparty, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), ibctesting.SecondClientID) - suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") - suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") + // Channel not yet stored for another client. + retrievedChannel, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) + suite.Require().False(found, "GetChannel unexpectedly returned a counterparty") + suite.Require().Equal(types.Channel{}, retrievedChannel, "Channel retrieved not empty") } func (suite *KeeperTestSuite) TestSetCreator() { diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index b1e8fd1ea48..0221ff45ba9 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -32,17 +32,17 @@ func (k Keeper) SendPacket( data []byte, ) (uint64, error) { // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.GetCounterparty(ctx, sourceChannel) + counterparty, ok := k.GetChannel(ctx, sourceChannel) if !ok { // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, sourcePort, sourceChannel); ok { + if counterparty, ok = k.ChannelKeeper.GetV2Channel(ctx, sourcePort, sourceChannel); ok { // we can key on just the source channel here since channel ids are globally unique - k.SetCounterparty(ctx, sourceChannel, counterparty) + k.SetChannel(ctx, sourceChannel, counterparty) } else { // if neither a counterparty nor channel is found then simply return an error - return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) + return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } } destChannel := counterparty.CounterpartyChannelId @@ -119,17 +119,17 @@ func (k Keeper) RecvPacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + counterparty, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Counterparty(ctx, packet.DestinationPort, packet.DestinationChannel); ok { + if counterparty, ok = k.ChannelKeeper.GetV2Channel(ctx, packet.DestinationPort, packet.DestinationChannel); ok { // we can key on just the destination channel here since channel ids are globally unique - k.SetCounterparty(ctx, packet.DestinationChannel, counterparty) + k.SetChannel(ctx, packet.DestinationChannel, counterparty) } else { // if neither a counterparty nor channel is found then simply return an error - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } @@ -205,9 +205,9 @@ func (k Keeper) WriteAcknowledgement( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + counterparty, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } if counterparty.CounterpartyChannelId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier @@ -261,9 +261,9 @@ func (k Keeper) AcknowledgePacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } if counterparty.CounterpartyChannelId != packet.DestinationChannel { @@ -332,9 +332,9 @@ func (k Keeper) TimeoutPacket( } // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { - return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } if counterparty.CounterpartyChannelId != packet.DestinationChannel { diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go index d1b61be35d1..f5ad1c3bc0d 100644 --- a/modules/core/packet-server/keeper/relay_test.go +++ b/modules/core/packet-server/keeper/relay_test.go @@ -71,7 +71,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { func() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "packet failed basic validation", @@ -176,7 +176,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { func() { packet.DestinationChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "failure: client is not active", @@ -283,7 +283,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { packet.DestinationChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -384,7 +384,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { func() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "failure: counterparty client identifier different than source channel", @@ -526,7 +526,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet.SourceChannel = ibctesting.InvalidID }, - types.ErrCounterpartyNotFound, + types.ErrChannelNotFound, }, { "failure: counterparty client identifier different than source channel", diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/channel.go similarity index 63% rename from modules/core/packet-server/types/counterparty.go rename to modules/core/packet-server/types/channel.go index d63a92da3e8..3a45be384fb 100644 --- a/modules/core/packet-server/types/counterparty.go +++ b/modules/core/packet-server/types/channel.go @@ -7,17 +7,17 @@ import ( host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) -// NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { - return Counterparty{ +// NewChannel creates a new Channel instance +func NewChannel(clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) Channel { + return Channel{ ClientId: clientID, CounterpartyChannelId: counterpartyChannelID, MerklePathPrefix: merklePathPrefix, } } -// Validate validates the Counterparty -func (c Counterparty) Validate() error { +// Validate validates the Channel +func (c Channel) Validate() error { if err := host.ClientIdentifierValidator(c.ClientId); err != nil { return err } @@ -27,7 +27,7 @@ func (c Counterparty) Validate() error { } if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) + return errorsmod.Wrap(ErrInvalidChannel, err.Error()) } return nil diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/channel.pb.go similarity index 56% rename from modules/core/packet-server/types/counterparty.pb.go rename to modules/core/packet-server/types/channel.pb.go index 2358d3b8213..91dfcd17df5 100644 --- a/modules/core/packet-server/types/counterparty.pb.go +++ b/modules/core/packet-server/types/channel.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/packetserver/v1/counterparty.proto +// source: ibc/core/packetserver/v1/channel.proto package types @@ -24,8 +24,14 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -type Counterparty struct { +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +type Channel struct { // 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 counterparty identifier that must be used by the packet @@ -36,18 +42,18 @@ type Counterparty struct { MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` } -func (m *Counterparty) Reset() { *m = Counterparty{} } -func (m *Counterparty) String() string { return proto.CompactTextString(m) } -func (*Counterparty) ProtoMessage() {} -func (*Counterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_e0c60a0709a0040c, []int{0} +func (m *Channel) Reset() { *m = Channel{} } +func (m *Channel) String() string { return proto.CompactTextString(m) } +func (*Channel) ProtoMessage() {} +func (*Channel) Descriptor() ([]byte, []int) { + return fileDescriptor_740f6a3702ba2291, []int{0} } -func (m *Counterparty) XXX_Unmarshal(b []byte) error { +func (m *Channel) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Channel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + return xxx_messageInfo_Channel.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -57,33 +63,33 @@ func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *Counterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counterparty.Merge(m, src) +func (m *Channel) XXX_Merge(src proto.Message) { + xxx_messageInfo_Channel.Merge(m, src) } -func (m *Counterparty) XXX_Size() int { +func (m *Channel) XXX_Size() int { return m.Size() } -func (m *Counterparty) XXX_DiscardUnknown() { - xxx_messageInfo_Counterparty.DiscardUnknown(m) +func (m *Channel) XXX_DiscardUnknown() { + xxx_messageInfo_Channel.DiscardUnknown(m) } -var xxx_messageInfo_Counterparty proto.InternalMessageInfo +var xxx_messageInfo_Channel proto.InternalMessageInfo -func (m *Counterparty) GetClientId() string { +func (m *Channel) GetClientId() string { if m != nil { return m.ClientId } return "" } -func (m *Counterparty) GetCounterpartyChannelId() string { +func (m *Channel) GetCounterpartyChannelId() string { if m != nil { return m.CounterpartyChannelId } return "" } -func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { +func (m *Channel) GetMerklePathPrefix() v2.MerklePath { if m != nil { return m.MerklePathPrefix } @@ -91,38 +97,38 @@ func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { } func init() { - proto.RegisterType((*Counterparty)(nil), "ibc.core.packetserver.v1.Counterparty") + proto.RegisterType((*Channel)(nil), "ibc.core.packetserver.v1.Channel") } func init() { - proto.RegisterFile("ibc/core/packetserver/v1/counterparty.proto", fileDescriptor_e0c60a0709a0040c) + proto.RegisterFile("ibc/core/packetserver/v1/channel.proto", fileDescriptor_740f6a3702ba2291) } -var fileDescriptor_e0c60a0709a0040c = []byte{ - // 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, +var fileDescriptor_740f6a3702ba2291 = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcf, 0x4a, 0xc3, 0x30, + 0x1c, 0xc7, 0x1b, 0x15, 0x75, 0xf5, 0x22, 0x45, 0x71, 0x4c, 0x88, 0x63, 0x07, 0xdd, 0x65, 0x09, + 0x9b, 0x20, 0x08, 0x9e, 0xe6, 0x69, 0x07, 0x61, 0xec, 0xb0, 0x83, 0x97, 0xd2, 0xa6, 0x3f, 0xdb, + 0xb0, 0xa6, 0x09, 0x69, 0x16, 0xdc, 0x5b, 0xf8, 0x34, 0x3e, 0xc3, 0x8e, 0x3b, 0x7a, 0x12, 0xd9, + 0x5e, 0x44, 0xfa, 0x87, 0xd2, 0x5b, 0xf2, 0xcb, 0x27, 0x9f, 0x7c, 0xf3, 0x75, 0xef, 0x79, 0xc8, + 0x28, 0x93, 0x1a, 0xa8, 0x0a, 0xd8, 0x0a, 0x4c, 0x0e, 0xda, 0x82, 0xa6, 0x76, 0x4c, 0x59, 0x12, + 0x64, 0x19, 0xa4, 0x44, 0x69, 0x69, 0xa4, 0xd7, 0xe5, 0x21, 0x23, 0x05, 0x47, 0xda, 0x1c, 0xb1, + 0xe3, 0xde, 0x55, 0x2c, 0x63, 0x59, 0x42, 0xb4, 0x58, 0x55, 0x7c, 0xef, 0xa1, 0xf1, 0x32, 0x29, + 0x04, 0x37, 0x02, 0x32, 0x43, 0xed, 0xa4, 0xb5, 0xab, 0xc0, 0xc1, 0x37, 0x72, 0xcf, 0x5e, 0xab, + 0xa7, 0xbc, 0x5b, 0xb7, 0xc3, 0x52, 0x0e, 0x99, 0xf1, 0x79, 0xd4, 0x45, 0x7d, 0x34, 0xec, 0x2c, + 0xce, 0xab, 0xc1, 0x2c, 0xf2, 0x9e, 0xdc, 0x1b, 0x26, 0xd7, 0x99, 0x01, 0xad, 0x02, 0x6d, 0x36, + 0x7e, 0x9d, 0xaf, 0x40, 0x8f, 0x4a, 0xf4, 0xba, 0x7d, 0x5c, 0x2b, 0x67, 0x91, 0xb7, 0x74, 0x3d, + 0x01, 0x7a, 0x95, 0x82, 0xaf, 0x02, 0x93, 0xf8, 0x4a, 0xc3, 0x07, 0xff, 0xec, 0x1e, 0xf7, 0xd1, + 0xf0, 0x62, 0x32, 0x20, 0xcd, 0xb7, 0x5a, 0xc1, 0xec, 0x84, 0xbc, 0x95, 0x37, 0xe6, 0x81, 0x49, + 0xa6, 0x27, 0xdb, 0xdf, 0x3b, 0x67, 0x71, 0x29, 0x9a, 0xc9, 0xbc, 0x34, 0x4c, 0x97, 0xdb, 0x3d, + 0x46, 0xbb, 0x3d, 0x46, 0x7f, 0x7b, 0x8c, 0xbe, 0x0e, 0xd8, 0xd9, 0x1d, 0xb0, 0xf3, 0x73, 0xc0, + 0xce, 0xfb, 0x4b, 0xcc, 0x4d, 0xb2, 0x0e, 0x0b, 0x25, 0x65, 0x32, 0x17, 0x32, 0xa7, 0x3c, 0x64, + 0xa3, 0x58, 0x52, 0xfb, 0x4c, 0x85, 0x8c, 0xd6, 0x29, 0xe4, 0xed, 0xce, 0x47, 0x75, 0xe9, 0x66, + 0xa3, 0x20, 0x0f, 0x4f, 0xcb, 0x5e, 0x1e, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x94, 0x68, 0x6c, + 0x3f, 0x9a, 0x01, 0x00, 0x00, } -func (m *Counterparty) Marshal() (dAtA []byte, err error) { +func (m *Channel) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -132,12 +138,12 @@ func (m *Counterparty) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { +func (m *Channel) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -148,29 +154,29 @@ func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintCounterparty(dAtA, i, uint64(size)) + i = encodeVarintChannel(dAtA, i, uint64(size)) } i-- 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 = encodeVarintChannel(dAtA, i, uint64(len(m.CounterpartyChannelId))) i-- dAtA[i] = 0x12 } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) - i = encodeVarintCounterparty(dAtA, i, uint64(len(m.ClientId))) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ClientId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { - offset -= sovCounterparty(v) +func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { + offset -= sovChannel(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -180,7 +186,7 @@ func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Counterparty) Size() (n int) { +func (m *Channel) Size() (n int) { if m == nil { return 0 } @@ -188,24 +194,24 @@ func (m *Counterparty) Size() (n int) { _ = l l = len(m.ClientId) if l > 0 { - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) } l = len(m.CounterpartyChannelId) if l > 0 { - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) } l = m.MerklePathPrefix.Size() - n += 1 + l + sovCounterparty(uint64(l)) + n += 1 + l + sovChannel(uint64(l)) return n } -func sovCounterparty(x uint64) (n int) { +func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozCounterparty(x uint64) (n int) { - return sovCounterparty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozChannel(x uint64) (n int) { + return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Counterparty) Unmarshal(dAtA []byte) error { +func (m *Channel) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -213,7 +219,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -228,10 +234,10 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + return fmt.Errorf("proto: Channel: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Channel: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -241,7 +247,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -255,11 +261,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -273,7 +279,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -287,11 +293,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -305,7 +311,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCounterparty + return ErrIntOverflowChannel } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -318,11 +324,11 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if postIndex > l { return io.ErrUnexpectedEOF @@ -333,12 +339,12 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCounterparty(dAtA[iNdEx:]) + skippy, err := skipChannel(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCounterparty + return ErrInvalidLengthChannel } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -352,7 +358,7 @@ func (m *Counterparty) Unmarshal(dAtA []byte) error { } return nil } -func skipCounterparty(dAtA []byte) (n int, err error) { +func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -360,7 +366,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -377,7 +383,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -393,7 +399,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCounterparty + return 0, ErrIntOverflowChannel } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -406,14 +412,14 @@ func skipCounterparty(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthCounterparty + return 0, ErrInvalidLengthChannel } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCounterparty + return 0, ErrUnexpectedEndOfGroupChannel } depth-- case 5: @@ -422,7 +428,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthCounterparty + return 0, ErrInvalidLengthChannel } if depth == 0 { return iNdEx, nil @@ -432,7 +438,7 @@ func skipCounterparty(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") ) diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/channel_test.go similarity index 91% rename from modules/core/packet-server/types/counterparty_test.go rename to modules/core/packet-server/types/channel_test.go index 462861a211d..160e5853e6a 100644 --- a/modules/core/packet-server/types/counterparty_test.go +++ b/modules/core/packet-server/types/channel_test.go @@ -11,7 +11,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v9/testing" ) -func TestValidateCounterparty(t *testing.T) { +func TestValidateChannel(t *testing.T) { testCases := []struct { name string clientID string @@ -66,21 +66,21 @@ func TestValidateCounterparty(t *testing.T) { ibctesting.FirstClientID, ibctesting.FirstChannelID, commitmenttypes.NewMerklePath(), - types.ErrInvalidCounterparty, + types.ErrInvalidChannel, }, { "failure: empty key in merkle path prefix first element", ibctesting.FirstClientID, ibctesting.FirstChannelID, commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), - types.ErrInvalidCounterparty, + types.ErrInvalidChannel, }, } for _, tc := range testCases { tc := tc - counterparty := types.NewCounterparty(tc.clientID, tc.channelID, tc.merklePathPrefix) + counterparty := types.NewChannel(tc.clientID, tc.channelID, tc.merklePathPrefix) err := counterparty.Validate() expPass := tc.expError == nil diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go index a38e7eaa18f..842c982613b 100644 --- a/modules/core/packet-server/types/errors.go +++ b/modules/core/packet-server/types/errors.go @@ -5,6 +5,6 @@ import ( ) var ( - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") - ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid counterparty") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") ) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 176de889391..41b2673a5a4 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -39,8 +39,8 @@ type ChannelKeeper interface { // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) - // GetV2Counterparty returns a version 2 counterparty for a given portID and channel ID - GetV2Counterparty(ctx context.Context, portID, channelID string) (Counterparty, bool) + // GetV2Channel returns a version 2 counterparty for a given portID and channel ID + GetV2Channel(ctx context.Context, portID, channelID string) (Channel, bool) } type ClientKeeper interface { diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index b6edf17dc7b..627785194b0 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -4,10 +4,10 @@ const ( // SubModuleName defines the IBC packet server name. SubModuleName = "packetserver" - // CounterpartyKey is the key used to store counterparty in the client store. + // ChannelKey is the key used to store counterparty in the client store. // the counterparty key is imported from types instead of host because // the counterparty key is not a part of the ics-24 host specification - CounterpartyKey = "counterparty" + ChannelKey = "counterparty" // CreatorKey is the key used to store the client creator in the client store // the creator key is imported from types instead of host because diff --git a/modules/core/packet-server/types/query.pb.go b/modules/core/packet-server/types/query.pb.go index 02d3e24447a..694ab5b79ba 100644 --- a/modules/core/packet-server/types/query.pb.go +++ b/modules/core/packet-server/types/query.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryClientRequest is the request type for the Query/Client RPC method -type QueryClientRequest struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +// QueryChannelRequest is the request type for the Query/Channel RPC method +type QueryChannelRequest struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` } -func (m *QueryClientRequest) Reset() { *m = QueryClientRequest{} } -func (m *QueryClientRequest) String() string { return proto.CompactTextString(m) } -func (*QueryClientRequest) ProtoMessage() {} -func (*QueryClientRequest) Descriptor() ([]byte, []int) { +func (m *QueryChannelRequest) Reset() { *m = QueryChannelRequest{} } +func (m *QueryChannelRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelRequest) ProtoMessage() {} +func (*QueryChannelRequest) Descriptor() ([]byte, []int) { return fileDescriptor_7ac0ae50eee8e6db, []int{0} } -func (m *QueryClientRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryChannelRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryClientRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryChannelRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,43 +55,43 @@ func (m *QueryClientRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryClientRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientRequest.Merge(m, src) +func (m *QueryChannelRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelRequest.Merge(m, src) } -func (m *QueryClientRequest) XXX_Size() int { +func (m *QueryChannelRequest) XXX_Size() int { return m.Size() } -func (m *QueryClientRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientRequest.DiscardUnknown(m) +func (m *QueryChannelRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryChannelRequest proto.InternalMessageInfo -func (m *QueryClientRequest) GetClientId() string { +func (m *QueryChannelRequest) GetChannelId() string { if m != nil { - return m.ClientId + return m.ChannelId } return "" } -// QueryClientRequest is the response type for the Query/Client RPC method -type QueryClientResponse struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` +// QueryChannelRequest is the response type for the Query/Channel RPC method +type QueryChannelResponse struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Channel Channel `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel"` } -func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } -func (m *QueryClientResponse) String() string { return proto.CompactTextString(m) } -func (*QueryClientResponse) ProtoMessage() {} -func (*QueryClientResponse) Descriptor() ([]byte, []int) { +func (m *QueryChannelResponse) Reset() { *m = QueryChannelResponse{} } +func (m *QueryChannelResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelResponse) ProtoMessage() {} +func (*QueryChannelResponse) Descriptor() ([]byte, []int) { return fileDescriptor_7ac0ae50eee8e6db, []int{1} } -func (m *QueryClientResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryChannelResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryClientResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryChannelResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -101,35 +101,35 @@ func (m *QueryClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryClientResponse.Merge(m, src) +func (m *QueryChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelResponse.Merge(m, src) } -func (m *QueryClientResponse) XXX_Size() int { +func (m *QueryChannelResponse) XXX_Size() int { return m.Size() } -func (m *QueryClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryClientResponse.DiscardUnknown(m) +func (m *QueryChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryClientResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryChannelResponse proto.InternalMessageInfo -func (m *QueryClientResponse) GetCreator() string { +func (m *QueryChannelResponse) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *QueryClientResponse) GetCounterparty() Counterparty { +func (m *QueryChannelResponse) GetChannel() Channel { if m != nil { - return m.Counterparty + return m.Channel } - return Counterparty{} + return Channel{} } func init() { - proto.RegisterType((*QueryClientRequest)(nil), "ibc.core.packetserver.v1.QueryClientRequest") - proto.RegisterType((*QueryClientResponse)(nil), "ibc.core.packetserver.v1.QueryClientResponse") + proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.packetserver.v1.QueryChannelRequest") + proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.packetserver.v1.QueryChannelResponse") } func init() { @@ -137,30 +137,29 @@ func init() { } var fileDescriptor_7ac0ae50eee8e6db = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3d, 0x4b, 0x2b, 0x41, - 0x14, 0xdd, 0x09, 0xef, 0xe5, 0xbd, 0xcc, 0x7b, 0xd5, 0x68, 0xb1, 0x44, 0x59, 0x43, 0x10, 0x8d, - 0x68, 0x76, 0x48, 0xac, 0x04, 0xab, 0xa4, 0xb2, 0xd3, 0x14, 0x16, 0x36, 0xb2, 0x3b, 0xb9, 0xac, - 0x8b, 0xc9, 0xde, 0xcd, 0xcc, 0xec, 0x42, 0x10, 0x0b, 0xfd, 0x05, 0x82, 0x60, 0xed, 0xcf, 0x49, - 0x19, 0xb0, 0xb1, 0x12, 0x49, 0xfc, 0x21, 0xb2, 0x1f, 0x86, 0x0d, 0x12, 0xb0, 0xbb, 0x73, 0xe7, - 0x9c, 0xc3, 0x39, 0xf7, 0xd0, 0x6d, 0xdf, 0x15, 0x5c, 0xa0, 0x04, 0x1e, 0x3a, 0xe2, 0x1a, 0xb4, - 0x02, 0x19, 0x83, 0xe4, 0x71, 0x8b, 0x8f, 0x22, 0x90, 0x63, 0x3b, 0x94, 0xa8, 0x91, 0x99, 0xbe, - 0x2b, 0xec, 0x04, 0x65, 0x17, 0x51, 0x76, 0xdc, 0xaa, 0xee, 0xaf, 0xe4, 0x0b, 0x8c, 0x02, 0x0d, - 0x32, 0x74, 0xa4, 0xce, 0x65, 0xaa, 0x9b, 0x1e, 0xa2, 0x37, 0x00, 0xee, 0x84, 0x3e, 0x77, 0x82, - 0x00, 0xb5, 0xa3, 0x7d, 0x0c, 0x54, 0xfe, 0xbb, 0xee, 0xa1, 0x87, 0xe9, 0xc8, 0x93, 0x29, 0xdb, - 0xd6, 0x5b, 0x94, 0x9d, 0x25, 0x4e, 0xba, 0x03, 0x1f, 0x02, 0xdd, 0x83, 0x51, 0x04, 0x4a, 0xb3, - 0x0d, 0x5a, 0x11, 0xe9, 0xe2, 0xd2, 0xef, 0x9b, 0xa4, 0x46, 0x1a, 0x95, 0xde, 0xdf, 0x6c, 0x71, - 0xd2, 0xaf, 0xdf, 0x11, 0xba, 0xb6, 0xc4, 0x51, 0x21, 0x06, 0x0a, 0x98, 0x49, 0xff, 0x08, 0x09, - 0x8e, 0x46, 0x99, 0x53, 0xbe, 0x9e, 0xec, 0x94, 0xfe, 0x2f, 0xda, 0x35, 0x4b, 0x35, 0xd2, 0xf8, - 0xd7, 0xde, 0xb1, 0x57, 0xc5, 0xb6, 0xbb, 0x05, 0x74, 0xe7, 0xd7, 0xe4, 0x6d, 0xcb, 0xe8, 0x2d, - 0x29, 0xb4, 0x9f, 0x09, 0xfd, 0x9d, 0x7a, 0x60, 0x4f, 0x84, 0x96, 0x33, 0x23, 0xec, 0x60, 0xb5, - 0xe0, 0xf7, 0x8c, 0xd5, 0xe6, 0x0f, 0xd1, 0x59, 0xba, 0x3a, 0xbf, 0x7f, 0xf9, 0x78, 0x2c, 0xed, - 0xb1, 0x5d, 0xbe, 0xa8, 0x24, 0xbb, 0x48, 0x5a, 0x46, 0x3a, 0x29, 0x7e, 0xb3, 0xb8, 0xda, 0x6d, - 0xe7, 0x7c, 0x32, 0xb3, 0xc8, 0x74, 0x66, 0x91, 0xf7, 0x99, 0x45, 0x1e, 0xe6, 0x96, 0x31, 0x9d, - 0x5b, 0xc6, 0xeb, 0xdc, 0x32, 0x2e, 0x8e, 0x3d, 0x5f, 0x5f, 0x45, 0xae, 0x2d, 0x70, 0xc8, 0x05, - 0xaa, 0x21, 0xaa, 0x44, 0xb3, 0xe9, 0x21, 0x8f, 0x8f, 0xf8, 0x10, 0xfb, 0xd1, 0x00, 0x54, 0xb1, - 0xf4, 0x66, 0xde, 0xba, 0x1e, 0x87, 0xa0, 0xdc, 0x72, 0x5a, 0xdc, 0xe1, 0x67, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x90, 0xb9, 0x8b, 0xca, 0x5b, 0x02, 0x00, 0x00, + // 351 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x4b, 0x03, 0x31, + 0x14, 0xc7, 0x2f, 0x45, 0x2d, 0x8d, 0x5b, 0xec, 0x70, 0x14, 0x3d, 0x6b, 0x11, 0xa9, 0x48, 0x13, + 0x5a, 0x5d, 0x04, 0x17, 0xeb, 0xe4, 0x68, 0x07, 0x07, 0x17, 0xb9, 0x4b, 0xc3, 0xf5, 0xb0, 0xbd, + 0x77, 0x4d, 0x72, 0x07, 0x45, 0x5c, 0xfc, 0x04, 0x82, 0xa3, 0xb3, 0xdf, 0xa5, 0x63, 0xc1, 0xc5, + 0x49, 0xa4, 0xf5, 0x83, 0xc8, 0xf5, 0xd2, 0x5a, 0xc1, 0x03, 0xb7, 0x97, 0x97, 0xff, 0xff, 0x97, + 0xf7, 0xf2, 0xc7, 0xfb, 0x81, 0xc7, 0x19, 0x07, 0x29, 0x58, 0xe4, 0xf2, 0x3b, 0xa1, 0x95, 0x90, + 0x89, 0x90, 0x2c, 0x69, 0xb2, 0x61, 0x2c, 0xe4, 0x88, 0x46, 0x12, 0x34, 0x10, 0x3b, 0xf0, 0x38, + 0x4d, 0x55, 0x74, 0x55, 0x45, 0x93, 0x66, 0xe5, 0x20, 0xd7, 0xcf, 0x7b, 0x6e, 0x18, 0x8a, 0x7e, + 0x46, 0xa8, 0x6c, 0xfb, 0x00, 0x7e, 0x5f, 0x30, 0x37, 0x0a, 0x98, 0x1b, 0x86, 0xa0, 0x5d, 0x1d, + 0x40, 0xa8, 0xcc, 0x6d, 0xd9, 0x07, 0x1f, 0xe6, 0x25, 0x4b, 0xab, 0xac, 0x5b, 0x3b, 0xc1, 0x5b, + 0x57, 0xe9, 0x10, 0x17, 0x19, 0xa9, 0x23, 0x86, 0xb1, 0x50, 0x9a, 0xec, 0x60, 0x6c, 0xd8, 0xb7, + 0x41, 0xd7, 0x46, 0x55, 0x54, 0x2f, 0x75, 0x4a, 0xa6, 0x73, 0xd9, 0xad, 0x29, 0x5c, 0xfe, 0xed, + 0x52, 0x11, 0x84, 0x4a, 0x10, 0x1b, 0x17, 0xb9, 0x14, 0xae, 0x06, 0x69, 0x3c, 0x8b, 0x23, 0x39, + 0xc7, 0x45, 0x63, 0xb7, 0x0b, 0x55, 0x54, 0xdf, 0x6c, 0xed, 0xd1, 0xbc, 0x7d, 0xa9, 0xa1, 0xb6, + 0xd7, 0xc6, 0x1f, 0xbb, 0x56, 0x67, 0xe1, 0x6b, 0xbd, 0x22, 0xbc, 0x3e, 0x7f, 0x95, 0xbc, 0x20, + 0x5c, 0x34, 0x22, 0xd2, 0xc8, 0xe7, 0xfc, 0xb1, 0x58, 0x85, 0xfe, 0x57, 0x9e, 0x6d, 0x54, 0x6b, + 0x3e, 0xbe, 0x7d, 0x3d, 0x17, 0x8e, 0xc8, 0x21, 0x5b, 0x86, 0x60, 0xe6, 0x61, 0x49, 0x6b, 0x59, + 0xde, 0xff, 0x7c, 0xd6, 0x43, 0xfb, 0x7a, 0x3c, 0x75, 0xd0, 0x64, 0xea, 0xa0, 0xcf, 0xa9, 0x83, + 0x9e, 0x66, 0x8e, 0x35, 0x99, 0x39, 0xd6, 0xfb, 0xcc, 0xb1, 0x6e, 0xce, 0xfc, 0x40, 0xf7, 0x62, + 0x8f, 0x72, 0x18, 0x30, 0x0e, 0x6a, 0x00, 0x2a, 0xa5, 0x36, 0x7c, 0x60, 0xc9, 0x29, 0x1b, 0x40, + 0x37, 0xee, 0x0b, 0xb5, 0x1a, 0x74, 0xc3, 0x24, 0xad, 0x47, 0x91, 0x50, 0xde, 0xc6, 0x3c, 0xb1, + 0xe3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xe3, 0xea, 0xfa, 0x4f, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -175,8 +174,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Client queries the counterparty of an IBC client. - Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) + // Channel queries the counterparty of an IBC client. + Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) } type queryClient struct { @@ -187,9 +186,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts ...grpc.CallOption) (*QueryClientResponse, error) { - out := new(QueryClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Client", in, out, opts...) +func (c *queryClient) Channel(ctx context.Context, in *QueryChannelRequest, opts ...grpc.CallOption) (*QueryChannelResponse, error) { + out := new(QueryChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Query/Channel", in, out, opts...) if err != nil { return nil, err } @@ -198,36 +197,36 @@ func (c *queryClient) Client(ctx context.Context, in *QueryClientRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { - // Client queries the counterparty of an IBC client. - Client(context.Context, *QueryClientRequest) (*QueryClientResponse, error) + // Channel queries the counterparty of an IBC client. + Channel(context.Context, *QueryChannelRequest) (*QueryChannelResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Client(ctx context.Context, req *QueryClientRequest) (*QueryClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Client not implemented") +func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelRequest) (*QueryChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Channel not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryClientRequest) +func _Query_Channel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Client(ctx, in) + return srv.(QueryServer).Channel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.packetserver.v1.Query/Client", + FullMethod: "/ibc.core.packetserver.v1.Query/Channel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Client(ctx, req.(*QueryClientRequest)) + return srv.(QueryServer).Channel(ctx, req.(*QueryChannelRequest)) } return interceptor(ctx, in, info, handler) } @@ -237,15 +236,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Client", - Handler: _Query_Client_Handler, + MethodName: "Channel", + Handler: _Query_Channel_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/packetserver/v1/query.proto", } -func (m *QueryClientRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryChannelRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -255,27 +254,27 @@ func (m *QueryClientRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryClientRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryChannelRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryClientRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryClientResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryChannelResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -285,18 +284,18 @@ func (m *QueryClientResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryClientResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryChannelResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -326,20 +325,20 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryClientRequest) Size() (n int) { +func (m *QueryChannelRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ClientId) + l = len(m.ChannelId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryClientResponse) Size() (n int) { +func (m *QueryChannelResponse) Size() (n int) { if m == nil { return 0 } @@ -349,7 +348,7 @@ func (m *QueryClientResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = m.Counterparty.Size() + l = m.Channel.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -360,7 +359,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { +func (m *QueryChannelRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -383,15 +382,15 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryClientRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryChannelRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryChannelRequest: illegal tag %d (wire type %d)", fieldNum, wire) } 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 { @@ -419,7 +418,7 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -442,7 +441,7 @@ func (m *QueryClientRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { +func (m *QueryChannelResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -465,10 +464,10 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryClientResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryChannelResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -505,7 +504,7 @@ func (m *QueryClientResponse) 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 Channel", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -532,7 +531,7 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/modules/core/packet-server/types/query.pb.gw.go b/modules/core/packet-server/types/query.pb.gw.go index dbe2224a7b8..caea72e9575 100644 --- a/modules/core/packet-server/types/query.pb.gw.go +++ b/modules/core/packet-server/types/query.pb.gw.go @@ -33,8 +33,8 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest +func request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelRequest var metadata runtime.ServerMetadata var ( @@ -44,24 +44,24 @@ func request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, cl _ = err ) - val, ok = pathParams["client_id"] + val, ok = pathParams["channel_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ClientId, err = runtime.String(val) + protoReq.ChannelId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := client.Client(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Channel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryClientRequest +func local_request_Query_Channel_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelRequest var metadata runtime.ServerMetadata var ( @@ -71,18 +71,18 @@ func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshal _ = err ) - val, ok = pathParams["client_id"] + val, ok = pathParams["channel_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ClientId, err = runtime.String(val) + protoReq.ChannelId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := server.Client(ctx, &protoReq) + msg, err := server.Channel(ctx, &protoReq) return msg, metadata, err } @@ -93,7 +93,7 @@ func local_request_Query_Client_0(ctx context.Context, marshaler runtime.Marshal // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -104,7 +104,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Client_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Channel_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -112,7 +112,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -157,7 +157,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Client_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -166,14 +166,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Client_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Channel_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Client_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Channel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -181,9 +181,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Client_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1", "clients", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 2, 1, 0, 4, 1, 5, 4}, []string{"ibc", "core", "channel", "v2", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Client_0 = runtime.ForwardResponseMessage + forward_Query_Channel_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/channel.proto similarity index 59% rename from proto/ibc/core/packetserver/v1/counterparty.proto rename to proto/ibc/core/packetserver/v1/channel.proto index f708694b21e..8ff15c78023 100644 --- a/proto/ibc/core/packetserver/v1/counterparty.proto +++ b/proto/ibc/core/packetserver/v1/channel.proto @@ -7,8 +7,14 @@ 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"; -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -message Counterparty { +// Channel defines the channel end on a chain that is implementing the version 2 IBC protocol +// Each side will maintain its own Channel to create an IBC channel +// The channel will be referenced by a channelID which will be used to send packets +// to the counterparty +// The channel will contain the client identifier that will provide proof verification for the channel +// and the counterparty channel identifier that the other channel end will be using +// to send packets to our channel end. +message Channel { // the client identifier of the light client representing the counterparty chain string client_id = 1; // the counterparty identifier that must be used by the packet diff --git a/proto/ibc/core/packetserver/v1/query.proto b/proto/ibc/core/packetserver/v1/query.proto index f056da89c32..f429a185e87 100644 --- a/proto/ibc/core/packetserver/v1/query.proto +++ b/proto/ibc/core/packetserver/v1/query.proto @@ -4,25 +4,25 @@ package ibc.core.packetserver.v1; option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; -import "ibc/core/packetserver/v1/counterparty.proto"; +import "ibc/core/packetserver/v1/channel.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; // Query provides defines the gRPC querier service service Query { - // Client queries the counterparty of an IBC client. - rpc Client(QueryClientRequest) returns (QueryClientResponse) { - option (google.api.http).get = "/ibc/core/client/v1/clients/{client_id}"; + // Channel queries the counterparty of an IBC client. + rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { + option (google.api.http).get = "/ibc/core/channel/v2/channel/{channel_id}"; } } -// QueryClientRequest is the request type for the Query/Client RPC method -message QueryClientRequest { - string client_id = 1; +// QueryChannelRequest is the request type for the Query/Channel RPC method +message QueryChannelRequest { + string channel_id = 1; } -// QueryClientRequest is the response type for the Query/Client RPC method -message QueryClientResponse { - string creator = 1; - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; +// QueryChannelRequest is the response type for the Query/Channel RPC method +message QueryChannelResponse { + string creator = 1; + Channel channel = 2 [(gogoproto.nullable) = false]; } diff --git a/testing/values.go b/testing/values.go index 9571004c2db..79c995b4974 100644 --- a/testing/values.go +++ b/testing/values.go @@ -22,10 +22,12 @@ import ( ) const ( - FirstClientID = "07-tendermint-0" - SecondClientID = "07-tendermint-1" - FirstChannelID = "channel-0" - FirstConnectionID = "connection-0" + FirstClientID = "07-tendermint-0" + SecondClientID = "07-tendermint-1" + FirstChannelID = "channel-0" + SecondChannelID = "channel-1" + FirstConnectionID = "connection-0" + SecondConnectionID = "connection-1" // Default params constants used to create a TM client TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 From dc3aeff9e98ccbd3d54184d3325d4aec5f8c68c4 Mon Sep 17 00:00:00 2001 From: Aditya Sripal <14364734+AdityaSripal@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:59:54 +0200 Subject: [PATCH 4/5] change var names --- modules/core/04-channel/keeper/keeper_test.go | 8 +-- modules/core/keeper/msg_server.go | 10 +-- modules/core/keeper/msg_server_test.go | 4 +- .../core/packet-server/client/cli/query.go | 4 +- modules/core/packet-server/client/cli/tx.go | 11 ++-- .../core/packet-server/keeper/grpc_query.go | 2 +- .../packet-server/keeper/grpc_query_test.go | 4 +- modules/core/packet-server/keeper/keeper.go | 10 +-- .../core/packet-server/keeper/keeper_test.go | 10 +-- modules/core/packet-server/keeper/relay.go | 66 +++++++++---------- .../core/packet-server/keeper/relay_test.go | 18 ++--- .../core/packet-server/types/channel_test.go | 4 +- modules/core/packet-server/types/errors.go | 4 +- .../packet-server/types/expected_keepers.go | 2 +- modules/core/packet-server/types/keys.go | 8 +-- modules/core/packet-server/types/msgs_test.go | 2 +- 16 files changed, 83 insertions(+), 84 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index 72db0ca9800..ca57cf1c70a 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -608,17 +608,17 @@ func (suite *KeeperTestSuite) TestGetV2Channel() { tc.malleate() - counterparty, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetV2Channel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) if tc.expPass { suite.Require().True(found) merklePath := commitmentv2types.NewMerklePath([]byte("ibc"), []byte("")) - expCounterparty := packetservertypes.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) - suite.Require().Equal(counterparty, expCounterparty) + expChannel := packetservertypes.NewChannel(path.EndpointA.ClientID, path.EndpointB.ChannelID, merklePath) + suite.Require().Equal(channel, expChannel) } else { suite.Require().False(found) - suite.Require().Equal(counterparty, packetservertypes.Channel{}) + suite.Require().Equal(channel, packetservertypes.Channel{}) } }) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 912c3d3bd3c..9f4351369bc 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -146,9 +146,9 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *packetservertypes.Msg channelID := k.ChannelKeeper.GenerateChannelIdentifier(ctx) - // Initialize counterparty with empty counterparty channel identifier. - counterparty := packetservertypes.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) - k.PacketServerKeeper.SetChannel(ctx, channelID, counterparty) + // Initialize channel with empty counterparty channel identifier. + channel := packetservertypes.NewChannel(msg.ClientId, "", msg.MerklePathPrefix) + k.PacketServerKeeper.SetChannel(ctx, channelID, channel) k.PacketServerKeeper.SetCreator(ctx, channelID, msg.Signer) @@ -172,7 +172,7 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertyp channel, ok := k.PacketServerKeeper.GetChannel(ctx, msg.ChannelId) if !ok { - return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidChannel, "channel must exist for channel %s", msg.ChannelId) + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidChannel, "channel must exist for channel id %s", msg.ChannelId) } channel.CounterpartyChannelId = msg.CounterpartyChannelId @@ -872,7 +872,7 @@ func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes. keeper.EmitChannelUpgradeConfirmEvent(ctx, msg.PortId, msg.ChannelId, channel) // Move channel to OPEN state if both chains have finished flushing in-flight packets. - // Channel channel state has been verified in ChanUpgradeConfirm. + // Counterparty channel state has been verified in ChanUpgradeConfirm. if channel.State == channeltypes.FLUSHCOMPLETE && msg.CounterpartyChannelState == channeltypes.FLUSHCOMPLETE { upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) if !found { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 275d33e99a4..404240f72d7 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1258,9 +1258,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty channel id filled in and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) + channel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelID) suite.Require().True(found) - suite.Require().Equal(counterparty.CounterpartyChannelId, path.EndpointB.ChannelID) + suite.Require().Equal(channel.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/query.go b/modules/core/packet-server/client/cli/query.go index a10f02c8801..ad23f2ef5d6 100644 --- a/modules/core/packet-server/client/cli/query.go +++ b/modules/core/packet-server/client/cli/query.go @@ -13,12 +13,12 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// getCmdQueryChannel defines the command to query the client information (creator and counterparty) for the given client ID. +// getCmdQueryChannel defines the command to query the client information (creator and channel) for the given client ID. func getCmdQueryChannel() *cobra.Command { cmd := &cobra.Command{ Use: "client [client-id]", Short: "Query the information of a client.", - Long: "Query the client information (creator and counterparty) for the provided client ID.", + Long: "Query the client information (creator and channel) for the provided client ID.", Example: fmt.Sprintf("%s query %s %s client [client-id]", version.AppName, exported.ModuleName, types.SubModuleName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/modules/core/packet-server/client/cli/tx.go b/modules/core/packet-server/client/cli/tx.go index 619e96e1875..a1180c24b87 100644 --- a/modules/core/packet-server/client/cli/tx.go +++ b/modules/core/packet-server/client/cli/tx.go @@ -14,14 +14,13 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) -// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client. +// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC channel. func newProvideCounterpartyCmd() *cobra.Command { cmd := &cobra.Command{ - 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.`, + Use: "provide-counterparty [channel-identifier] [counterparty-channel-identifier]", + Args: cobra.ExactArgs(2), + Short: "provide the counterparty channel id to an IBC channel end", + Long: `Provide the counterparty channel id to an IBC channel end specified by its channel ID.`, 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) diff --git a/modules/core/packet-server/keeper/grpc_query.go b/modules/core/packet-server/keeper/grpc_query.go index b40f78ae261..bc0182180bf 100644 --- a/modules/core/packet-server/keeper/grpc_query.go +++ b/modules/core/packet-server/keeper/grpc_query.go @@ -48,7 +48,7 @@ func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelReques if !foundCreator && !foundChannel { return nil, status.Error( codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "client-id: %s", req.ChannelId).Error(), + errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error(), ) } diff --git a/modules/core/packet-server/keeper/grpc_query_test.go b/modules/core/packet-server/keeper/grpc_query_test.go index 322caef6a2b..79a2987c789 100644 --- a/modules/core/packet-server/keeper/grpc_query_test.go +++ b/modules/core/packet-server/keeper/grpc_query_test.go @@ -71,13 +71,13 @@ func (suite *KeeperTestSuite) TestQueryChannel() { status.Error(codes.InvalidArgument, "empty request"), }, { - "no creator and no counterparty", + "no creator and no channel", func() { req = &types.QueryChannelRequest{ ChannelId: ibctesting.FirstChannelID, } }, - status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: counterparty not found", ibctesting.FirstChannelID)), + status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", ibctesting.FirstChannelID)), }, { "invalid channelID", diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 9a2d9ca5169..b862b3e0ed5 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -49,8 +49,8 @@ func (k Keeper) ChannelStore(ctx context.Context, channelID string) storetypes.K } // SetChannel sets the Channel for a given client identifier. -func (k *Keeper) SetChannel(ctx context.Context, clientID string, counterparty types.Channel) { - bz := k.cdc.MustMarshal(&counterparty) +func (k *Keeper) SetChannel(ctx context.Context, clientID string, channel types.Channel) { + bz := k.cdc.MustMarshal(&channel) k.ChannelStore(ctx, clientID).Set([]byte(types.ChannelKey), bz) } @@ -62,9 +62,9 @@ func (k *Keeper) GetChannel(ctx context.Context, clientID string) (types.Channel return types.Channel{}, false } - var counterparty types.Channel - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true + var channel types.Channel + k.cdc.MustUnmarshal(bz, &channel) + return channel, true } // GetCreator returns the creator of the client. diff --git a/modules/core/packet-server/keeper/keeper_test.go b/modules/core/packet-server/keeper/keeper_test.go index fbb0ee78967..3c95dc45e0e 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -10,19 +10,19 @@ const testClientID = "tendermint-0" func (suite *KeeperTestSuite) TestSetChannel() { merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - counterparty := types.Channel{ + channel := types.Channel{ ClientId: testClientID, MerklePathPrefix: merklePathPrefix, } - suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), testClientID, counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetChannel(suite.chainA.GetContext(), testClientID, channel) retrievedChannel, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), testClientID) - suite.Require().True(found, "GetChannel does not return counterparty") - suite.Require().Equal(counterparty, retrievedChannel, "Channel retrieved not equal") + suite.Require().True(found, "GetChannel does not return channel") + suite.Require().Equal(channel, retrievedChannel, "Channel retrieved not equal") // Channel not yet stored for another client. retrievedChannel, found = suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetChannel(suite.chainA.GetContext(), ibctesting.SecondClientID) - suite.Require().False(found, "GetChannel unexpectedly returned a counterparty") + suite.Require().False(found, "GetChannel unexpectedly returned a channel") suite.Require().Equal(types.Channel{}, retrievedChannel, "Channel retrieved not empty") } diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go index 0221ff45ba9..9ad03fb70c8 100644 --- a/modules/core/packet-server/keeper/relay.go +++ b/modules/core/packet-server/keeper/relay.go @@ -19,7 +19,7 @@ import ( // SendPacket implements the packet sending logic required by a packet handler. // It will generate a packet and store the commitment hash if all arguments provided are valid. -// The destination channel will be filled in using the counterparty information. +// The destination channel will be filled in using the channel information. // The next sequence send will be initialized if this is the first packet sent for the given client. func (k Keeper) SendPacket( ctx context.Context, @@ -31,22 +31,22 @@ func (k Keeper) SendPacket( version string, data []byte, ) (uint64, error) { - // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.GetChannel(ctx, sourceChannel) + // Lookup channel associated with our source channel to retrieve the destination channel + channel, ok := k.GetChannel(ctx, sourceChannel) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Channel(ctx, sourcePort, sourceChannel); ok { + if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, sourcePort, sourceChannel); ok { // we can key on just the source channel here since channel ids are globally unique - k.SetChannel(ctx, sourceChannel, counterparty) + k.SetChannel(ctx, sourceChannel, channel) } else { - // if neither a counterparty nor channel is found then simply return an error + // if neither a channel v2 nor channel v1 is found then simply return an error return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) } } - destChannel := counterparty.CounterpartyChannelId - clientID := counterparty.ClientId + destChannel := channel.CounterpartyChannelId + clientID := channel.ClientId // retrieve the sequence send for this channel // if no packets have been sent yet, initialize the sequence to 1. @@ -117,26 +117,26 @@ func (k Keeper) RecvPacket( // packetv2 := convert(packet) - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetChannel(ctx, packet.DestinationChannel) + // Lookup channel associated with our channel and ensure + // that the packet was indeed sent by our channel. + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { - // If the counterparty is not found, attempt to retrieve a v1 channel from the channel keeper - // if it exists, then we will convert it to a v2 counterparty and store it in the packet server keeper + // If the channel is not found, attempt to retrieve a v1 channel from the channel keeper + // if it exists, then we will convert it to a v2 channel and store it in the packet server keeper // for future use. - if counterparty, ok = k.ChannelKeeper.GetV2Channel(ctx, packet.DestinationPort, packet.DestinationChannel); ok { + if channel, ok = k.ChannelKeeper.GetV2Channel(ctx, packet.DestinationPort, packet.DestinationChannel); ok { // we can key on just the destination channel here since channel ids are globally unique - k.SetChannel(ctx, packet.DestinationChannel, counterparty) + k.SetChannel(ctx, packet.DestinationChannel, channel) } else { - // if neither a counterparty nor channel is found then simply return an error + // if neither a channel v1 nor channel v1 is found then simply return an error return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } - if counterparty.CounterpartyChannelId != packet.SourceChannel { + if channel.CounterpartyChannelId != packet.SourceChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.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 @@ -159,7 +159,7 @@ func (k Keeper) RecvPacket( } path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) commitment := channeltypes.CommitPacket(packet) @@ -203,13 +203,13 @@ func (k Keeper) WriteAcknowledgement( return channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure + // Lookup channel associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetChannel(ctx, packet.DestinationChannel) + channel, ok := k.GetChannel(ctx, packet.DestinationChannel) if !ok { return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } - if counterparty.CounterpartyChannelId != packet.SourceChannel { + if channel.CounterpartyChannelId != packet.SourceChannel { return channeltypes.ErrInvalidChannelIdentifier } @@ -261,15 +261,15 @@ func (k Keeper) AcknowledgePacket( // Lookup counterparty associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } - if counterparty.CounterpartyChannelId != packet.DestinationChannel { + if channel.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { @@ -290,7 +290,7 @@ func (k Keeper) AcknowledgePacket( } path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyMembership( ctx, @@ -330,17 +330,17 @@ func (k Keeper) TimeoutPacket( if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { return "", channeltypes.ErrInvalidPacket } - // Lookup counterparty associated with our channel and ensure + // Lookup channel associated with our channel and ensure // that the packet was indeed sent by our counterparty. - counterparty, ok := k.GetChannel(ctx, packet.SourceChannel) + channel, ok := k.GetChannel(ctx, packet.SourceChannel) if !ok { return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.SourceChannel) } - if counterparty.CounterpartyChannelId != packet.DestinationChannel { + if channel.CounterpartyChannelId != packet.DestinationChannel { return "", channeltypes.ErrInvalidChannelIdentifier } - clientID := counterparty.ClientId + clientID := channel.ClientId // check that timeout height or timeout timestamp has passed on the other end proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, proofHeight) @@ -373,7 +373,7 @@ func (k Keeper) TimeoutPacket( // verify packet receipt absence path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + merklePath := types.BuildMerklePath(channel.MerklePathPrefix, path) if err := k.ClientKeeper.VerifyNonMembership( ctx, diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go index f5ad1c3bc0d..e2fb7e8458b 100644 --- a/modules/core/packet-server/keeper/relay_test.go +++ b/modules/core/packet-server/keeper/relay_test.go @@ -67,7 +67,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { nil, }, { - "counterparty not found", + "channel not found", func() { packet.SourceChannel = ibctesting.InvalidID }, @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.DestinationChannel = ibctesting.InvalidID }, @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { clienttypes.ErrClientNotActive, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.SourceChannel = unusedChannel }, @@ -279,14 +279,14 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.DestinationChannel = ibctesting.InvalidID }, types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.SourceChannel = unusedChannel }, @@ -380,14 +380,14 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { packet.SourceChannel = ibctesting.InvalidID }, types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { packet.DestinationChannel = unusedChannel }, @@ -517,7 +517,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { channeltypes.ErrInvalidPacket, }, { - "failure: counterparty not found", + "failure: channel not found", func() { // send packet _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, @@ -529,7 +529,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { types.ErrChannelNotFound, }, { - "failure: counterparty client identifier different than source channel", + "failure: counterparty channel identifier different than source channel", func() { // send packet _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), packet.SourceChannel, packet.SourcePort, packet.DestinationPort, diff --git a/modules/core/packet-server/types/channel_test.go b/modules/core/packet-server/types/channel_test.go index 160e5853e6a..f5d6948a23b 100644 --- a/modules/core/packet-server/types/channel_test.go +++ b/modules/core/packet-server/types/channel_test.go @@ -80,8 +80,8 @@ func TestValidateChannel(t *testing.T) { for _, tc := range testCases { tc := tc - counterparty := types.NewChannel(tc.clientID, tc.channelID, tc.merklePathPrefix) - err := counterparty.Validate() + channel := types.NewChannel(tc.clientID, tc.channelID, tc.merklePathPrefix) + err := channel.Validate() expPass := tc.expError == nil if expPass { diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go index 842c982613b..1c2d5cb3481 100644 --- a/modules/core/packet-server/types/errors.go +++ b/modules/core/packet-server/types/errors.go @@ -5,6 +5,6 @@ import ( ) var ( - ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid counterparty") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 1, "invalid channel") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 2, "channel not found") ) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index 41b2673a5a4..1fa932c4efd 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -39,7 +39,7 @@ type ChannelKeeper interface { // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) - // GetV2Channel returns a version 2 counterparty for a given portID and channel ID + // GetV2Channel returns a version 2 channel for a given portID and channel ID GetV2Channel(ctx context.Context, portID, channelID string) (Channel, bool) } diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index 627785194b0..fcbeb56d5e4 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -4,10 +4,10 @@ const ( // SubModuleName defines the IBC packet server name. SubModuleName = "packetserver" - // ChannelKey is the key used to store counterparty in the client store. - // the counterparty key is imported from types instead of host because - // the counterparty key is not a part of the ics-24 host specification - ChannelKey = "counterparty" + // ChannelKey is the key used to store channel in the client store. + // the channel key is imported from types instead of host because + // the channel key is not a part of the ics-24 host specification + ChannelKey = "channel" // CreatorKey is the key used to store the client creator in the client store // the creator key is imported from types instead of host because diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go index bac3552e9f1..c6af4cf8684 100644 --- a/modules/core/packet-server/types/msgs_test.go +++ b/modules/core/packet-server/types/msgs_test.go @@ -95,7 +95,7 @@ func (s *TypesTestSuite) TestMsgCreateChannelValidateBasic() { host.ErrInvalidID, }, { - "failure: empty key path of counterparty of merkle path prefix", + "failure: empty key path", func() { msg.MerklePathPrefix.KeyPath = nil }, From c20a460e4f6cbee6043ae438e4fbee5881027744 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 9 Oct 2024 23:55:08 +0300 Subject: [PATCH 5/5] chore: fix merge mess. --- modules/core/04-channel/v2/keeper/relay.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/relay.go b/modules/core/04-channel/v2/keeper/relay.go index 7628ff31676..1bedc747b25 100644 --- a/modules/core/04-channel/v2/keeper/relay.go +++ b/modules/core/04-channel/v2/keeper/relay.go @@ -119,7 +119,7 @@ func (k Keeper) recvPacket( // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].DestinationPort, packet.DestinationChannel) if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationId) + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } } if counterparty.ClientId != packet.SourceChannel { @@ -192,8 +192,8 @@ func (k Keeper) timeoutPacket( if !ok { // TODO: figure out how aliasing will work when more than one packet data is sent. counterparty, ok = k.getV1Counterparty(ctx, packet.Data[0].SourcePort, packet.SourceChannel) - if !ok { - return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationId) + if !ok { + return errorsmod.Wrap(types.ErrChannelNotFound, packet.DestinationChannel) } }