diff --git a/e2e/testsuite/codec.go b/e2e/testsuite/codec.go index adcd74c67e5..5de0570cd18 100644 --- a/e2e/testsuite/codec.go +++ b/e2e/testsuite/codec.go @@ -32,6 +32,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine" ibctmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -69,6 +70,7 @@ func codecAndEncodingConfig() (*codec.ProtoCodec, testutil.TestEncodingConfig) { connectiontypes.RegisterInterfaces(cfg.InterfaceRegistry) ibctmtypes.RegisterInterfaces(cfg.InterfaceRegistry) wasmtypes.RegisterInterfaces(cfg.InterfaceRegistry) + packetservertypes.RegisterInterfaces(cfg.InterfaceRegistry) // all other types upgradetypes.RegisterInterfaces(cfg.InterfaceRegistry) diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 2a4e28925a9..5b536c2626b 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -409,7 +409,7 @@ func NewSimApp( app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) // NOTE: The mock ContractKeeper is only created for testing. // Real applications should not use the mock ContractKeeper diff --git a/modules/core/02-client/client/cli/cli.go b/modules/core/02-client/client/cli/cli.go index 545dafda7db..b90cac79537 100644 --- a/modules/core/02-client/client/cli/cli.go +++ b/modules/core/02-client/client/cli/cli.go @@ -51,7 +51,7 @@ func NewTxCmd() *cobra.Command { newUpgradeClientCmd(), newSubmitRecoverClientProposalCmd(), newScheduleIBCUpgradeProposalCmd(), - newProvideCounterpartyCmd(), + // newProvideCounterpartyCmd(), ) return txCmd diff --git a/modules/core/02-client/client/cli/tx.go b/modules/core/02-client/client/cli/tx.go index 8f4242ec6ca..7c6636a59fb 100644 --- a/modules/core/02-client/client/cli/tx.go +++ b/modules/core/02-client/client/cli/tx.go @@ -455,40 +455,40 @@ func newScheduleIBCUpgradeProposalCmd() *cobra.Command { } // 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. -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), - 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 - } - - counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) - msg := types.MsgProvideCounterparty{ - ClientId: clientIdentifier, - Counterparty: counterparty, - Signer: clientCtx.GetFromAddress().String(), - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} +// 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. +// 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), +// 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 +// } + +// counterparty := types.NewCounterparty(counterpartyClientIdentifier, counterpartyMerklePathPrefix) +// msg := types.MsgProvideCounterparty{ +// ClientId: clientIdentifier, +// Counterparty: counterparty, +// Signer: clientCtx.GetFromAddress().String(), +// } +// return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) +// }, +// } + +// 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) { diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 995df5e02df..4f7d38fbd87 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -427,8 +427,8 @@ func (q *queryServer) Client(ctx context.Context, req *types.QueryClientRequest) creator, _ := q.GetCreator(sdkCtx, req.ClientId) res.Creator = creator - counterparty, _ := q.GetCounterparty(sdkCtx, req.ClientId) - res.Counterparty = counterparty + // counterparty, _ := q.GetCounterparty(sdkCtx, req.ClientId) + // res.Counterparty = counterparty return &res, nil } diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index c3d69c52779..a5ddf022c37 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -957,9 +957,9 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { func (suite *KeeperTestSuite) TestQueryClient() { var ( - req *types.QueryClientRequest - expCreator string - expCounterparty types.Counterparty + req *types.QueryClientRequest + expCreator string + // expCounterparty types.Counterparty ) testCases := []struct { @@ -972,7 +972,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { func() { ctx := suite.chainA.GetContext() suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(ctx, ibctesting.FirstClientID, expCreator) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) + // suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(ctx, ibctesting.FirstClientID, expCounterparty) req = &types.QueryClientRequest{ ClientId: ibctesting.FirstClientID, @@ -985,7 +985,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { func() { expCreator = "" - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) + // suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), ibctesting.FirstClientID, expCounterparty) req = &types.QueryClientRequest{ ClientId: ibctesting.FirstClientID, @@ -996,7 +996,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { { "success: no counterparty", func() { - expCounterparty = types.Counterparty{} + // expCounterparty = packetservertypes.Counterparty{} suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCreator(suite.chainA.GetContext(), ibctesting.FirstClientID, expCreator) @@ -1029,8 +1029,8 @@ func (suite *KeeperTestSuite) TestQueryClient() { suite.SetupTest() // reset expCreator = ibctesting.TestAccAddress - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) - expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} + // merklePathPrefix := commitmenttypes.NewMerklePath([]byte("prefix")) + // expCounterparty = types.Counterparty{ClientId: ibctesting.SecondClientID, MerklePathPrefix: merklePathPrefix} tc.malleate() @@ -1042,7 +1042,7 @@ func (suite *KeeperTestSuite) TestQueryClient() { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expCreator, res.Creator) - suite.Require().Equal(expCounterparty, res.Counterparty) + // suite.Require().Equal(expCounterparty, res.Counterparty) } else { suite.Require().ErrorIs(err, tc.expError) suite.Require().Nil(res) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 94de6e8887c..dd5fb094657 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -304,25 +304,6 @@ func (k *Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) return k.GetClientConsensusState(ctx, clientID, clientModule.LatestHeight(ctx, clientID)) } -// SetCounterparty sets the Counterparty for a given client identifier. -func (k *Keeper) SetCounterparty(ctx sdk.Context, clientID string, counterparty types.Counterparty) { - bz := k.cdc.MustMarshal(&counterparty) - k.ClientStore(ctx, clientID).Set([]byte(types.CounterpartyKey), bz) -} - -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { - store := k.ClientStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) - if len(bz) == 0 { - return types.Counterparty{}, false - } - - var counterparty types.Counterparty - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true -} - // GetCreator returns the creator of the client. func (k *Keeper) GetCreator(ctx sdk.Context, clientID string) (string, bool) { bz := k.ClientStore(ctx, clientID).Get([]byte(types.CreatorKey)) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 607fbf37fd2..adf412a9459 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -129,23 +129,6 @@ func (suite *KeeperTestSuite) TestSetClientState() { suite.Require().Equal(clientState, retrievedState, "Client states are not equal") } -func (suite *KeeperTestSuite) TestSetCounterparty() { - merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - counterparty := types.Counterparty{ - ClientId: testClientID, - MerklePathPrefix: merklePathPrefix, - } - suite.keeper.SetCounterparty(suite.ctx, testClientID, counterparty) - - retrievedCounterparty, found := suite.keeper.GetCounterparty(suite.ctx, testClientID) - suite.Require().True(found, "GetCounterparty does not return counterparty") - suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") - - retrievedCounterparty, found = suite.keeper.GetCounterparty(suite.ctx, "client-0") - suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") - suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") -} - func (suite *KeeperTestSuite) TestSetCreator() { clientID := ibctesting.FirstClientID expectedCreator := "test-creator" diff --git a/modules/core/02-client/types/client.go b/modules/core/02-client/types/client.go index 5346f2726c0..6e3df24694e 100644 --- a/modules/core/02-client/types/client.go +++ b/modules/core/02-client/types/client.go @@ -12,7 +12,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -65,27 +64,6 @@ func (ics IdentifiedClientStates) Sort() IdentifiedClientStates { return ics } -// NewCounterparty creates a new Counterparty instance -func NewCounterparty(clientID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { - return Counterparty{ - ClientId: clientID, - MerklePathPrefix: merklePathPrefix, - } -} - -// Validate validates the Counterparty -func (c Counterparty) Validate() error { - if err := host.ClientIdentifierValidator(c.ClientId); err != nil { - return err - } - - if err := c.MerklePathPrefix.ValidateAsPrefix(); err != nil { - return errorsmod.Wrap(ErrInvalidCounterparty, err.Error()) - } - - return nil -} - // NewConsensusStateWithHeight creates a new ConsensusStateWithHeight instance func NewConsensusStateWithHeight(height Height, consensusState exported.ConsensusState) ConsensusStateWithHeight { msg, ok := consensusState.(proto.Message) diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 738feab14fd..0a61762a377 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -8,7 +8,6 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" io "io" math "math" math_bits "math/bits" @@ -193,61 +192,6 @@ func (m *ClientConsensusStates) GetConsensusStates() []ConsensusStateWithHeight return nil } -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -type Counterparty struct { - // the client identifier of the counterparty chain - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // the merkle path that all ICS24 paths will be stored under - MerklePathPrefix v2.MerklePath `protobuf:"bytes,2,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` -} - -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_b6bc4c8185546947, []int{3} -} -func (m *Counterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Counterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counterparty.Merge(m, src) -} -func (m *Counterparty) XXX_Size() int { - return m.Size() -} -func (m *Counterparty) XXX_DiscardUnknown() { - xxx_messageInfo_Counterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_Counterparty proto.InternalMessageInfo - -func (m *Counterparty) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { - if m != nil { - return m.MerklePathPrefix - } - return v2.MerklePath{} -} - // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients @@ -271,7 +215,7 @@ type Height struct { func (m *Height) Reset() { *m = Height{} } func (*Height) ProtoMessage() {} func (*Height) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{4} + return fileDescriptor_b6bc4c8185546947, []int{3} } func (m *Height) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -312,7 +256,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{5} + return fileDescriptor_b6bc4c8185546947, []int{4} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -352,7 +296,6 @@ func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") proto.RegisterType((*ClientConsensusStates)(nil), "ibc.core.client.v1.ClientConsensusStates") - proto.RegisterType((*Counterparty)(nil), "ibc.core.client.v1.Counterparty") proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height") proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params") } @@ -360,40 +303,36 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xbf, 0x6f, 0x13, 0x31, - 0x14, 0xc7, 0xcf, 0x69, 0x15, 0x35, 0x4e, 0x95, 0x54, 0x47, 0x2b, 0x85, 0x20, 0x5d, 0xa2, 0x5b, - 0x9a, 0x81, 0x9e, 0xc9, 0x31, 0x50, 0x10, 0x0c, 0x24, 0x0b, 0x1d, 0x40, 0xd1, 0x21, 0x81, 0x84, - 0x84, 0xa2, 0xfb, 0xe1, 0xdc, 0x59, 0x9c, 0xcf, 0xd1, 0xd9, 0x17, 0xc8, 0xcc, 0xc2, 0x84, 0x90, - 0x58, 0x18, 0xfb, 0xe7, 0x74, 0xec, 0xc8, 0x54, 0xa1, 0x64, 0xe3, 0xaf, 0x40, 0x67, 0x3b, 0xa4, - 0x29, 0xa5, 0xea, 0x66, 0xbf, 0xf7, 0x7d, 0xfe, 0x7e, 0xfc, 0x9e, 0x0d, 0x3b, 0x24, 0x08, 0x51, - 0xc8, 0x72, 0x8c, 0xc2, 0x94, 0xe0, 0x4c, 0xa0, 0x59, 0x5f, 0xaf, 0x9c, 0x69, 0xce, 0x04, 0x33, - 0x4d, 0x12, 0x84, 0x4e, 0x29, 0x70, 0x74, 0x78, 0xd6, 0x6f, 0xef, 0xc7, 0x2c, 0x66, 0x32, 0x8d, - 0xca, 0x95, 0x52, 0xb6, 0xef, 0xc6, 0x8c, 0xc5, 0x29, 0x46, 0x72, 0x17, 0x14, 0x13, 0xe4, 0x67, - 0x73, 0x9d, 0x3a, 0x5c, 0xbb, 0x30, 0x4a, 0x89, 0xa0, 0xd2, 0xc9, 0xbd, 0xb4, 0x53, 0x42, 0x9b,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43, 0xd0, 0x03, 0x00, 0x00, + // 456 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0xa5, 0x55, 0xd4, 0x5c, 0x50, 0x82, 0x4c, 0x2b, 0x99, 0x20, 0xd9, 0x51, 0x16, 0x32, + 0xd0, 0x3b, 0x12, 0x06, 0x0a, 0x82, 0x81, 0x74, 0xa1, 0x0b, 0x42, 0x66, 0x40, 0x42, 0x42, 0x91, + 0x7d, 0xbe, 0xda, 0x27, 0xd9, 0x77, 0x95, 0xef, 0x6c, 0x94, 0x7f, 0xc0, 0x84, 0x90, 0x58, 0x18, + 0xfb, 0x73, 0x3a, 0x76, 0x64, 0xaa, 0x50, 0xb2, 0xf1, 0x2b, 0x90, 0xef, 0x2e, 0xaa, 0x5c, 0x0a, + 0x62, 0x7b, 0xf7, 0xbe, 0xef, 0xbd, 0xef, 0xfb, 0x5e, 0x62, 0x18, 0xb0, 0x98, 0x60, 0x22, 0x4a, + 0x8a, 0x49, 0xce, 0x28, 0x57, 0xb8, 0x9e, 0xd9, 0x0a, 0x9d, 0x95, 0x42, 0x09, 0xd7, 0x65, 0x31, + 0x41, 0x0d, 0x01, 0xd9, 0x76, 0x3d, 0x1b, 0xed, 0xa7, 0x22, 0x15, 0x1a, 0xc6, 0x4d, 0x65, 0x98, + 0xa3, 0xfb, 0xa9, 0x10, 0x69, 0x4e, 0xb1, 0x7e, 0xc5, 0xd5, 0x29, 0x8e, 0xf8, 0xca, 0x40, 0x93, + 0x02, 0x1e, 0x9c, 0x24, 0x94, 0x2b, 0x76, 0xca, 0x68, 0x72, 0xac, 0xf7, 0xbc, 0x53, 0x91, 0xa2, + 0xee, 0x03, 0xd8, 0x33, 0x6b, 0x97, 0x2c, 0xf1, 0xc0, 0x18, 0x4c, 0x7b, 0xe1, 0x9e, 0x69, 0x9c, + 0x24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0xb9, 0xf8, 0x44, 0x93, 0xa5, 0xc9, 0x27, 0x3d, 0x30, + 0xde, 0x99, 0xf6, 0xc2, 0x81, 0x6d, 0x9b, 0x6b, 0xca, 0x45, 0x78, 0xb1, 0xf6, 0xc1, 0xe5, 0xda, + 0x07, 0x3f, 0xd7, 0x3e, 0xf8, 0xba, 0xf1, 0x9d, 0xcb, 0x8d, 0xef, 0xfc, 0xd8, 0xf8, 0xce, 0x87, + 0xa3, 0x94, 0xa9, 0xac, 0x8a, 0x11, 0x11, 0x05, 0x26, 0x42, 0x16, 0x42, 0x62, 0x16, 0x93, 0xc3, + 0x54, 0xe0, 0xfa, 0x19, 0x2e, 0x44, 0x52, 0xe5, 0x54, 0x9a, 0xbf, 0xff, 0xe3, 0xf9, 0xa1, 0xfd, + 0x02, 0xd4, 0xea, 0x8c, 0xca, 0xb8, 0xab, 0x7f, 0xcb, 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x94, 0x27, 0x25, 0x2c, 0x21, 0x03, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -527,46 +466,6 @@ func (m *ClientConsensusStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Counterparty) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *Height) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -694,21 +593,6 @@ func (m *ClientConsensusStates) Size() (n int) { return n } -func (m *Counterparty) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - l = m.MerklePathPrefix.Size() - n += 1 + l + sovClient(uint64(l)) - return n -} - func (m *Height) Size() (n int) { if m == nil { return 0 @@ -1098,121 +982,6 @@ func (m *ClientConsensusStates) Unmarshal(dAtA []byte) error { } return nil } -func (m *Counterparty) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Counterparty: 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) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Height) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 2eabd3681f2..43b5b1c7f58 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -88,70 +86,3 @@ func TestValidateClientType(t *testing.T) { } } } - -func TestValidateCounterparty(t *testing.T) { - testCases := []struct { - name string - clientID string - merklePathPrefix commitmenttypes.MerklePath - expError error - }{ - { - "success", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc")), - nil, - }, - { - "success with multiple element prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("address")), - nil, - }, - { - "success with multiple element prefix, last prefix empty", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")), - nil, - }, - { - "success with single empty key prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte("")), - nil, - }, - { - "failure: invalid client id", - "", - commitmenttypes.NewMerklePath([]byte("ibc")), - host.ErrInvalidID, - }, - { - "failure: empty merkle path prefix", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath(), - types.ErrInvalidCounterparty, - }, - { - "failure: empty key in merkle path prefix first element", - ibctesting.FirstClientID, - commitmenttypes.NewMerklePath([]byte(""), []byte("ibc")), - types.ErrInvalidCounterparty, - }, - } - - for _, tc := range testCases { - tc := tc - - counterparty := types.NewCounterparty(tc.clientID, tc.merklePathPrefix) - err := counterparty.Validate() - - expPass := tc.expError == nil - if expPass { - require.NoError(t, err, tc.name) - } else { - require.Error(t, err, tc.name) - require.ErrorIs(t, err, tc.expError) - } - } -} diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index 9e239c83564..082970cd598 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -45,7 +45,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgRecoverClient{}, &MsgIBCSoftwareUpgrade{}, &MsgUpdateParams{}, - &MsgProvideCounterparty{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/errors.go b/modules/core/02-client/types/errors.go index f663019ab0f..62d906bc40c 100644 --- a/modules/core/02-client/types/errors.go +++ b/modules/core/02-client/types/errors.go @@ -38,6 +38,4 @@ var ( ErrFailedNonMembershipVerification = errorsmod.Register(SubModuleName, 31, "non-membership verification failed") ErrRouteNotFound = errorsmod.Register(SubModuleName, 32, "light client module route not found") ErrClientTypeNotSupported = errorsmod.Register(SubModuleName, 33, "client type not supported") - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 34, "invalid counterparty") - ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 35, "counterparty not found") ) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index 29604c2816e..2a37e3588fe 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -37,11 +37,6 @@ const ( // the creator key is imported from types instead of host because // the creator key is not a part of the ics-24 host specification CreatorKey = "creator" - - // CounterpartyKey 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" ) // FormatClientIdentifier returns the client identifier with the sequence appended. diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index b0442e4a62b..e35b7bbbaad 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -7,7 +7,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - commitmenttypes "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" @@ -21,7 +20,6 @@ var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.Msg = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.Msg = (*MsgRecoverClient)(nil) - _ sdk.Msg = (*MsgProvideCounterparty)(nil) _ sdk.HasValidateBasic = (*MsgCreateClient)(nil) _ sdk.HasValidateBasic = (*MsgUpdateClient)(nil) @@ -30,7 +28,6 @@ var ( _ sdk.HasValidateBasic = (*MsgUpdateParams)(nil) _ sdk.HasValidateBasic = (*MsgIBCSoftwareUpgrade)(nil) _ sdk.HasValidateBasic = (*MsgRecoverClient)(nil) - _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -268,34 +265,6 @@ func (msg *MsgRecoverClient) ValidateBasic() error { return nil } -// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance -func NewMsgProvideCounterparty(signer, clientID, counterpartyID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { - counterparty := NewCounterparty(counterpartyID, merklePathPrefix) - - return &MsgProvideCounterparty{ - Signer: signer, - ClientId: clientID, - Counterparty: counterparty, - } -} - -// ValidateBasic performs basic checks on a MsgProvideCounterparty. -func (msg *MsgProvideCounterparty) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if err := host.ClientIdentifierValidator(msg.ClientId); err != nil { - return err - } - - if err := msg.Counterparty.Validate(); err != nil { - return err - } - - return nil -} - // NewMsgIBCSoftwareUpgrade creates a new MsgIBCSoftwareUpgrade instance func NewMsgIBCSoftwareUpgrade(signer string, plan upgradetypes.Plan, upgradedClientState exported.ClientState) (*MsgIBCSoftwareUpgrade, error) { anyClient, err := PackClientState(upgradedClientState) diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index cfc73cc8578..4dc9acb4dfd 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -686,70 +686,6 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { } } -// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty -func (suite *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { - var msg *types.MsgProvideCounterparty - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: invalid signer address", - func() { - msg.Signer = "invalid" - }, - ibcerrors.ErrInvalidAddress, - }, - { - "failure: invalid client ID", - func() { - msg.ClientId = "" - }, - host.ErrInvalidID, - }, - { - "failure: invalid counterparty client ID", - func() { - msg.Counterparty.ClientId = "" - }, - 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.TestAccAddress, - ibctesting.FirstClientID, - ibctesting.SecondClientID, - commitmenttypes.NewMerklePath([]byte("key")), - ) - - tc.malleate() - - err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err, "valid case %s failed", tc.name) - } else { - suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) - } - } -} - // TestMsgRecoverClientGetSigners tests GetSigners for MsgRecoverClient func TestMsgRecoverClientGetSigners(t *testing.T) { testCases := []struct { diff --git a/modules/core/02-client/types/query.pb.go b/modules/core/02-client/types/query.pb.go index b0eb1eea77a..7db16e26ea6 100644 --- a/modules/core/02-client/types/query.pb.go +++ b/modules/core/02-client/types/query.pb.go @@ -1154,8 +1154,7 @@ func (m *QueryClientRequest) GetClientId() string { // 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"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` } func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } @@ -1198,13 +1197,6 @@ func (m *QueryClientResponse) GetCreator() string { return "" } -func (m *QueryClientResponse) GetCounterparty() Counterparty { - if m != nil { - return m.Counterparty - } - return Counterparty{} -} - func init() { proto.RegisterType((*QueryClientStateRequest)(nil), "ibc.core.client.v1.QueryClientStateRequest") proto.RegisterType((*QueryClientStateResponse)(nil), "ibc.core.client.v1.QueryClientStateResponse") @@ -1233,90 +1225,89 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) } var fileDescriptor_dc42cdfd1d52d76e = []byte{ - // 1327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6b, 0x1b, 0x47, - 0x1b, 0xf7, 0x38, 0xb6, 0xe3, 0x3c, 0x52, 0xe2, 0x30, 0x49, 0x1c, 0x65, 0x93, 0xc8, 0xf2, 0xfa, - 0x7d, 0xe3, 0x8f, 0xda, 0xbb, 0x96, 0xdc, 0xd8, 0x4e, 0xa0, 0xd0, 0x3a, 0x25, 0x8d, 0x03, 0x49, - 0x5d, 0x95, 0x7e, 0x50, 0x28, 0x62, 0xb5, 0x1a, 0x4b, 0x4b, 0xa4, 0x5d, 0x65, 0x67, 0x57, 0x20, - 0x8c, 0x2f, 0x39, 0x85, 0x5e, 0x52, 0x28, 0xf4, 0x5a, 0xe8, 0xb1, 0x87, 0x90, 0x43, 0xa1, 0xa7, - 0x42, 0x4f, 0xad, 0x8f, 0x81, 0xf6, 0xd0, 0x53, 0x53, 0xec, 0x42, 0xff, 0x8d, 0xb2, 0x33, 0xb3, - 0xd6, 0xae, 0x34, 0x8a, 0x56, 0x25, 0xe9, 0x6d, 0xe7, 0xf9, 0xfc, 0x3d, 0x1f, 0xf3, 0xcc, 0xc3, - 0x42, 0xd6, 0x2a, 0x9b, 0xba, 0xe9, 0xb8, 0x44, 0x37, 0xeb, 0x16, 0xb1, 0x3d, 0xbd, 0x95, 0xd7, - 0x1f, 0xfa, 0xc4, 0x6d, 0x6b, 0x4d, 0xd7, 0xf1, 0x1c, 0x8c, 0xad, 0xb2, 0xa9, 0x05, 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, - 0x40, 0x39, 0x01, 0x49, 0x67, 0x68, 0x16, 0xf1, 0x7c, 0xff, 0xfb, 0x14, 0xbb, 0x49, 0x5b, 0xc5, - 0x83, 0xc3, 0x2c, 0x7a, 0x7e, 0x98, 0x45, 0x7f, 0x1e, 0x66, 0xd1, 0x97, 0x47, 0xd9, 0x91, 0xe7, - 0x47, 0xd9, 0x91, 0xdf, 0x8f, 0xb2, 0x23, 0x9f, 0x6d, 0x56, 0x2d, 0xaf, 0xe6, 0x97, 0x83, 0x7d, - 0x46, 0x17, 0x3f, 0xb5, 0xac, 0xb2, 0xb9, 0x52, 0x75, 0xf4, 0xd6, 0x0d, 0xbd, 0xe1, 0x54, 0xfc, - 0x3a, 0xa1, 0xdc, 0xc3, 0x6a, 0x61, 0x45, 0x38, 0xf1, 0xda, 0x4d, 0x42, 0xcb, 0x13, 0x6c, 0x6d, - 0x5c, 0xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xa1, 0xea, 0xc5, 0x6c, 0x13, 0x00, 0x00, + // 1301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xa4, 0x49, 0x9a, 0x3e, 0xbb, 0x4d, 0x35, 0xf9, 0xa8, 0xbb, 0x49, 0x9d, 0x64, 0x03, + 0xcd, 0x07, 0xc9, 0x6e, 0xec, 0xd0, 0x24, 0xad, 0x84, 0x04, 0x29, 0x2a, 0x0d, 0x52, 0x4b, 0x30, + 0xe2, 0x43, 0x48, 0xc8, 0x5a, 0xaf, 0x27, 0xf6, 0xaa, 0xf6, 0xae, 0xbb, 0xb3, 0x6b, 0x29, 0xaa, + 0x72, 0xe9, 0xa9, 0xe2, 0x52, 0x24, 0x24, 0xae, 0x48, 0x1c, 0x39, 0x54, 0x3d, 0x20, 0x71, 0x42, + 0xe2, 0x04, 0x39, 0x56, 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9e, 0xae, 0x20, 0x86, 0x7a, 0xe5, 0x06, 0x5a, 0x51, 0x5f, + 0x97, 0x01, 0x6f, 0x32, 0xed, 0x62, 0xbd, 0x85, 0xed, 0x4b, 0x04, 0x23, 0xbc, 0x7e, 0xf8, 0x6a, + 0x8f, 0x46, 0x0c, 0xc1, 0x2d, 0xf6, 0x94, 0x13, 0x90, 0x74, 0x86, 0x66, 0x19, 0x2f, 0x76, 0x7f, + 0x4f, 0xb1, 0x97, 0xb4, 0x53, 0x38, 0x3a, 0xce, 0xa2, 0x67, 0xc7, 0x59, 0xf4, 0xd7, 0x71, 0x16, + 0x7d, 0x75, 0x92, 0x1d, 0x78, 0x76, 0x92, 0x1d, 0xf8, 0xe3, 0x24, 0x3b, 0xf0, 0xf9, 0x76, 0xc5, + 0xf2, 0xaa, 0x7e, 0x29, 0xb8, 0x41, 0x74, 0xf1, 0x47, 0x94, 0x55, 0x32, 0xd7, 0x2a, 0x8e, 0xde, + 0xbc, 0xae, 0xd7, 0x9d, 0xb2, 0x5f, 0x23, 0x94, 0x7b, 0x58, 0xcf, 0xaf, 0x09, 0x27, 0xde, 0x41, + 0x83, 0xd0, 0xd2, 0x08, 0x3b, 0xf5, 0x36, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xef, 0xef, 0x2e, + 0x97, 0x20, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2626,16 +2617,6 @@ func (m *QueryClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) @@ -2992,8 +2973,6 @@ func (m *QueryClientResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = m.Counterparty.Size() - n += 1 + l + sovQuery(uint64(l)) return n } @@ -5252,39 +5231,6 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index fdca53cd3c9..5a22491005e 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -448,88 +448,6 @@ func (m *MsgRecoverClientResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRecoverClientResponse proto.InternalMessageInfo -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -type MsgProvideCounterparty struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // counterparty client - Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } -func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterparty) ProtoMessage() {} -func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{10} -} -func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterparty.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgProvideCounterparty) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) -} -func (m *MsgProvideCounterparty) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -type MsgProvideCounterpartyResponse struct { -} - -func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } -func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } -func (*MsgProvideCounterpartyResponse) ProtoMessage() {} -func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{11} -} -func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgProvideCounterpartyResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) -} -func (m *MsgProvideCounterpartyResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo - // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal type MsgIBCSoftwareUpgrade struct { Plan types1.Plan `protobuf:"bytes,1,opt,name=plan,proto3" json:"plan"` @@ -550,7 +468,7 @@ func (m *MsgIBCSoftwareUpgrade) Reset() { *m = MsgIBCSoftwareUpgrade{} } func (m *MsgIBCSoftwareUpgrade) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgrade) ProtoMessage() {} func (*MsgIBCSoftwareUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{12} + return fileDescriptor_cb5dc4651eb49a04, []int{10} } func (m *MsgIBCSoftwareUpgrade) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -608,7 +526,7 @@ func (m *MsgIBCSoftwareUpgradeResponse) Reset() { *m = MsgIBCSoftwareUpg func (m *MsgIBCSoftwareUpgradeResponse) String() string { return proto.CompactTextString(m) } func (*MsgIBCSoftwareUpgradeResponse) ProtoMessage() {} func (*MsgIBCSoftwareUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{13} + return fileDescriptor_cb5dc4651eb49a04, []int{11} } func (m *MsgIBCSoftwareUpgradeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,7 +569,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{14} + return fileDescriptor_cb5dc4651eb49a04, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -688,7 +606,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb5dc4651eb49a04, []int{15} + return fileDescriptor_cb5dc4651eb49a04, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -728,8 +646,6 @@ func init() { proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") proto.RegisterType((*MsgRecoverClient)(nil), "ibc.core.client.v1.MsgRecoverClient") proto.RegisterType((*MsgRecoverClientResponse)(nil), "ibc.core.client.v1.MsgRecoverClientResponse") - proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.client.v1.MsgProvideCounterparty") - proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.client.v1.MsgProvideCounterpartyResponse") proto.RegisterType((*MsgIBCSoftwareUpgrade)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgrade") proto.RegisterType((*MsgIBCSoftwareUpgradeResponse)(nil), "ibc.core.client.v1.MsgIBCSoftwareUpgradeResponse") proto.RegisterType((*MsgUpdateParams)(nil), "ibc.core.client.v1.MsgUpdateParams") @@ -739,63 +655,59 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 886 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x73, 0xe3, 0x44, - 0x14, 0xb6, 0x1c, 0x9f, 0x87, 0x6c, 0x7c, 0x67, 0x6e, 0xcf, 0x77, 0xe7, 0xd3, 0x71, 0xb6, 0xc7, - 0x5c, 0x11, 0x0c, 0x91, 0x62, 0x33, 0x03, 0x21, 0x40, 0x91, 0xb8, 0x21, 0xcc, 0x78, 0x26, 0xa3, - 0x0c, 0x0d, 0x8d, 0x23, 0xc9, 0x6b, 0x45, 0x8c, 0xa5, 0xd5, 0x68, 0x57, 0x06, 0x77, 0x0c, 0x15, - 0x25, 0x05, 0x0d, 0x1d, 0x35, 0x55, 0x86, 0x1f, 0x40, 0xc7, 0x4c, 0xca, 0x94, 0x54, 0x0c, 0x24, - 0x45, 0xfe, 0x06, 0x23, 0xed, 0x5a, 0x59, 0xc9, 0x92, 0x10, 0x43, 0x27, 0xe9, 0x7d, 0xef, 0xed, - 0xf7, 0xbd, 0x7d, 0xfb, 0xad, 0xc0, 0x4b, 0xdb, 0x30, 0x55, 0x13, 0xfb, 0x48, 0x35, 0x17, 0x36, - 0x72, 0xa9, 0xba, 0x1c, 0xaa, 0xf4, 0x1b, 0xc5, 0xf3, 0x31, 0xc5, 0x10, 0xda, 0x86, 0xa9, 0x84, - 0x41, 0x85, 0x05, 0x95, 0xe5, 0x50, 0x7e, 0x6e, 0x62, 0xe2, 0x60, 0xa2, 0x3a, 0xc4, 0x0a, 0xb1, - 0x0e, 0xb1, 0x18, 0x58, 0x7e, 0xcd, 0x03, 0x81, 0x67, 0xf9, 0xfa, 0x0c, 0xa9, 0xcb, 0xa1, 0x81, - 0xa8, 0x3e, 0x5c, 0xbf, 0x73, 0x54, 0xcb, 0xc2, 0x16, 0x8e, 0x1e, 0xd5, 0xf0, 0x89, 0x7f, 0x7d, - 0x61, 0x61, 0x6c, 0x2d, 0x90, 0x1a, 0xbd, 0x19, 0xc1, 0x5c, 0xd5, 0xdd, 0x15, 0x0f, 0x75, 0x33, - 0x08, 0x72, 0x36, 0x11, 0xa0, 0xff, 0xab, 0x04, 0x9a, 0x13, 0x62, 0x8d, 0x7d, 0xa4, 0x53, 0x34, - 0x8e, 0x22,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 0x39, 0x45, 0x32, 0xb0, 0xf2, 0xa8, 0x3c, 0x56, 0xec, - 0x67, 0xc6, 0x79, 0xcf, 0xeb, 0xe7, 0x26, 0x34, 0xb7, 0x9f, 0xf9, 0xa7, 0x10, 0xce, 0x01, 0x14, - 0x07, 0x88, 0x1f, 0xc4, 0xe2, 0x81, 0x64, 0xa0, 0x7f, 0x19, 0xc8, 0xe4, 0xe1, 0x92, 0x1f, 0x7c, - 0x7b, 0x77, 0x39, 0x90, 0x8e, 0xb5, 0xab, 0x9b, 0x8e, 0x74, 0x7d, 0xd3, 0x91, 0xfe, 0xba, 0xe9, - 0x48, 0x3f, 0xdc, 0x76, 0x2a, 0xd7, 0xb7, 0x9d, 0xca, 0x1f, 0xb7, 0x9d, 0xca, 0x97, 0x07, 0x96, - 0x4d, 0x2f, 0x02, 0x43, 0x31, 0xb1, 0xa3, 0xf2, 0x1f, 0x58, 0xdb, 0x30, 0xf7, 0x2c, 0xac, 0x2e, - 0x3f, 0x52, 0x1d, 0x3c, 0x0b, 0x16, 0x88, 0xb0, 0xdf, 0xcf, 0xfd, 0xd1, 0x1e, 0xff, 0x03, 0xa5, - 0x2b, 0x0f, 0x11, 0xa3, 0x1e, 0x39, 0xd6, 0xfb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xa4, - 0xb8, 0x24, 0x42, 0x0b, 0x00, 0x00, + // 819 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0xd3, 0x34, 0xa2, 0xd7, 0xb4, 0xa1, 0x47, 0x4a, 0x53, 0x97, 0x26, 0x55, 0xe8, 0x50, + 0x0a, 0xb5, 0x9b, 0x22, 0x41, 0x29, 0x30, 0xb4, 0x59, 0xe8, 0x10, 0xa9, 0x72, 0xc5, 0xc2, 0x92, + 0xda, 0xce, 0xc5, 0x35, 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0xab, 0x28, 0x0d, 0xff, 0x81, + 0x48, 0xec, 0x0c, 0x2e, 0x99, 0xe3, 0xd3, 0xbd, 0x84, 0x65, 0xf4, 0x09, 0x6d, 0xfd, 0x9e, 0x04, + 0x13, 0x4d, 0x62, 0xc0, 0x23, 0x50, 0x88, 0x98, 0xfe, 0xdd, 0x51, 0xd5, 0x62, 0x2e, 0x2b, 0xde, + 0x1f, 0x03, 0x34, 0xb0, 0xe2, 0x23, 0x50, 0x88, 0x78, 0x6c, 0x52, 0x85, 0x30, 0x28, 0xb1, 0xc2, + 0x28, 0x5f, 0x84, 0x3a, 0x98, 0x89, 0x9a, 0xc9, 0x6a, 0x62, 0x76, 0x08, 0x25, 0x3e, 0x18, 0x07, + 0x35, 0x28, 0xe2, 0x02, 0x38, 0xc2, 0x14, 0xee, 0x25, 0x9c, 0x31, 0x0c, 0x15, 0xeb, 0x63, 0x43, + 0xc3, 0xc2, 0xa2, 0xbb, 0x9c, 0x24, 0x2c, 0x82, 0x4a, 0x14, 0x36, 0x72, 0xf9, 0x7c, 0x61, 0x23, + 0x16, 0x2f, 0x49, 0xd8, 0x30, 0x34, 0x51, 0x58, 0xf2, 0x3a, 0xc0, 0x0e, 0x80, 0xe1, 0x9b, 0xe4, + 0x1b, 0x91, 0x3e, 0x19, 0x0c, 0xf4, 0x97, 0xc9, 0x88, 0x4e, 0xb9, 0x38, 0xf9, 0xee, 0xea, 0x74, + 0x5d, 0xd8, 0x53, 0xce, 0x2e, 0x2a, 0xc2, 0xf9, 0x45, 0x45, 0xf8, 0x75, 0x51, 0x11, 0x3e, 0x5e, + 0x56, 0x32, 0xe7, 0x97, 0x95, 0xcc, 0x8f, 0xcb, 0x4a, 0xe6, 0xd5, 0xb6, 0x61, 0xd2, 0x63, 0x4f, + 0x93, 0x74, 0x6c, 0xc9, 0xfc, 0xd3, 0xcb, 0xd4, 0xf4, 0x0d, 0x03, 0xcb, 0xbd, 0x27, 0xb2, 0x85, + 0xdb, 0x5e, 0x17, 0x11, 0xf6, 0xe1, 0xb4, 0xb9, 0xb5, 0xc1, 0xbf, 0x9d, 0xe8, 0x89, 0x83, 0x88, + 0x96, 0x0f, 0xac, 0xe3, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xa7, 0x07, 0xfb, 0xfc, + 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -820,8 +732,6 @@ type MsgClient interface { SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(ctx context.Context, in *MsgRecoverClient, opts ...grpc.CallOption) (*MsgRecoverClientResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -881,15 +791,6 @@ func (c *msgClient) RecoverClient(ctx context.Context, in *MsgRecoverClient, opt return out, nil } -func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { - out := new(MsgProvideCounterpartyResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/ProvideCounterparty", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) IBCSoftwareUpgrade(ctx context.Context, in *MsgIBCSoftwareUpgrade, opts ...grpc.CallOption) (*MsgIBCSoftwareUpgradeResponse, error) { out := new(MsgIBCSoftwareUpgradeResponse) err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/IBCSoftwareUpgrade", in, out, opts...) @@ -920,8 +821,6 @@ type MsgServer interface { SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) // RecoverClient defines a rpc handler method for MsgRecoverClient. RecoverClient(context.Context, *MsgRecoverClient) (*MsgRecoverClientResponse, error) - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. IBCSoftwareUpgrade(context.Context, *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. @@ -947,9 +846,6 @@ func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) RecoverClient(ctx context.Context, req *MsgRecoverClient) (*MsgRecoverClientResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecoverClient not implemented") } -func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") -} func (*UnimplementedMsgServer) IBCSoftwareUpgrade(ctx context.Context, req *MsgIBCSoftwareUpgrade) (*MsgIBCSoftwareUpgradeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IBCSoftwareUpgrade not implemented") } @@ -1051,24 +947,6 @@ func _Msg_RecoverClient_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgProvideCounterparty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ProvideCounterparty(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/ProvideCounterparty", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_IBCSoftwareUpgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgIBCSoftwareUpgrade) if err := dec(in); err != nil { @@ -1129,10 +1007,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RecoverClient", Handler: _Msg_RecoverClient_Handler, }, - { - MethodName: "ProvideCounterparty", - Handler: _Msg_ProvideCounterparty_Handler, - }, { MethodName: "IBCSoftwareUpgrade", Handler: _Msg_IBCSoftwareUpgrade_Handler, @@ -1539,76 +1413,6 @@ func (m *MsgRecoverClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - 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)) - } - i-- - dAtA[i] = 0x12 - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgIBCSoftwareUpgrade) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1924,34 +1728,6 @@ func (m *MsgRecoverClientResponse) Size() (n int) { return n } -func (m *MsgProvideCounterparty) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Counterparty.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgProvideCounterpartyResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgIBCSoftwareUpgrade) Size() (n int) { if m == nil { return 0 @@ -3146,203 +2922,6 @@ func (m *MsgRecoverClientResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterparty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterparty: 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) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgIBCSoftwareUpgrade) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 3c5e65b97f6..5055c5d8624 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -19,8 +19,10 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" + commitmentv2types "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetserver "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) var _ porttypes.ICS4Wrapper = (*Keeper)(nil) @@ -95,6 +97,30 @@ func (k *Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel t store.Set(host.ChannelKey(portID, channelID), bz) } +// 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 sdk.Context, portID, channelID string) (packetserver.Counterparty, bool) { + channel, ok := k.GetChannel(ctx, portID, channelID) + if !ok { + return packetserver.Counterparty{}, 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 + } + connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) + if !ok { + return packetserver.Counterparty{}, false + } + merklePathPrefix := commitmentv2types.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) + counterparty := packetserver.Counterparty{ + ClientId: connection.ClientId, + MerklePathPrefix: merklePathPrefix, + } + return counterparty, true +} + // GetAppVersion gets the version for the specified channel. func (k *Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { channel, found := k.GetChannel(ctx, portID, channelID) diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index a6d3cee060c..2edf9a9ea9e 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -2,6 +2,8 @@ package host import "fmt" +var KeyChannelStorePrefix = []byte("channels") + const ( KeyChannelEndPrefix = "channelEnds" KeyChannelPrefix = "channels" diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index da389975107..49b6009ea79 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -56,7 +56,7 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) - packetKeeper := packetserver.NewKeeper(cdc, channelKeeper, clientKeeper) + packetKeeper := packetserver.NewKeeper(cdc, key, channelKeeper, clientKeeper) return &Keeper{ cdc: cdc, diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 30d5c9cf36d..961b5ef8b83 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -17,6 +17,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/internal/telemetry" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" coretypes "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -25,6 +26,7 @@ var ( _ connectiontypes.MsgServer = (*Keeper)(nil) _ channeltypes.MsgServer = (*Keeper)(nil) _ channeltypes.PacketMsgServer = (*Keeper)(nil) + _ packetservertypes.MsgServer = (*Keeper)(nil) ) // CreateClient defines a rpc handler method for MsgCreateClient. @@ -143,10 +145,10 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI } // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. -func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.MsgProvideCounterparty) (*clienttypes.MsgProvideCounterpartyResponse, error) { +func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *packetservertypes.MsgProvideCounterparty) (*packetservertypes.MsgProvideCounterpartyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - creator, found := k.ClientKeeper.GetCreator(ctx, msg.ClientId) + creator, found := k.ClientKeeper.GetCreator(ctx, msg.Counterparty.ClientId) if !found { return nil, errorsmod.Wrap(ibcerrors.ErrUnauthorized, "client creator must be set") } @@ -155,15 +157,15 @@ func (k *Keeper) ProvideCounterparty(goCtx context.Context, msg *clienttypes.Msg return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "client creator (%s) must match signer (%s)", creator, msg.Signer) } - if _, ok := k.ClientKeeper.GetCounterparty(ctx, msg.ClientId); ok { - return nil, errorsmod.Wrapf(clienttypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.ClientId) + if _, ok := k.PacketServerKeeper.GetCounterparty(ctx, msg.ChannelId); ok { + return nil, errorsmod.Wrapf(packetservertypes.ErrInvalidCounterparty, "counterparty already exists for client %s", msg.Counterparty.ClientId) } - k.ClientKeeper.SetCounterparty(ctx, msg.ClientId, msg.Counterparty) + k.PacketServerKeeper.SetCounterparty(ctx, msg.ChannelId, msg.Counterparty) // Delete client creator from state as it is not needed after this point. - k.ClientKeeper.DeleteCreator(ctx, msg.ClientId) + k.ClientKeeper.DeleteCreator(ctx, msg.Counterparty.ClientId) - return &clienttypes.MsgProvideCounterpartyResponse{}, nil + return &packetservertypes.MsgProvideCounterpartyResponse{}, nil } // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index dafd0bd0609..a4756ba5766 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -22,6 +22,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -307,7 +308,7 @@ func (suite *KeeperTestSuite) TestRecvPacketV2() { // any non-nil value of packet is valid suite.Require().NotNil(packet) }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, false, false, @@ -670,7 +671,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacketV2() { func() { packet.SourceChannel = "invalid-client" }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, }, { @@ -996,7 +997,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacketV2() { packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, - clienttypes.ErrCounterpartyNotFound, + packetservertypes.ErrCounterpartyNotFound, false, }, } @@ -1218,7 +1219,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { func (suite *KeeperTestSuite) TestProvideCounterparty() { var ( path *ibctesting.Path - msg *clienttypes.MsgProvideCounterparty + msg *packetservertypes.MsgProvideCounterparty ) cases := []struct { name string @@ -1233,7 +1234,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { { "failure: unknown client identifier", func() { - msg.ClientId = ibctesting.InvalidID + msg.Counterparty.ClientId = ibctesting.InvalidID }, ibcerrors.ErrUnauthorized, }, @@ -1248,9 +1249,9 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { "failure: counterparty already exists", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ClientId, msg.Counterparty) + suite.chainA.App.GetIBCKeeper().PacketServerKeeper.SetCounterparty(suite.chainA.GetContext(), msg.ChannelId, msg.Counterparty) }, - clienttypes.ErrInvalidCounterparty, + packetservertypes.ErrInvalidCounterparty, }, } @@ -1261,7 +1262,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() merklePrefix := commitmenttypesv2.NewMerklePath([]byte("mock-key")) - msg = clienttypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) + msg = packetservertypes.NewMsgProvideCounterparty(signer, path.EndpointA.ClientID, path.EndpointB.ClientID, merklePrefix) tc.malleate() @@ -1274,7 +1275,7 @@ func (suite *KeeperTestSuite) TestProvideCounterparty() { suite.Require().Nil(err) // Assert counterparty set and creator deleted - counterparty, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) + counterparty, found := suite.chainA.App.GetIBCKeeper().PacketServerKeeper.GetCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(found) suite.Require().Equal(counterparty, msg.Counterparty) diff --git a/modules/core/module.go b/modules/core/module.go index 1dc35eec4a8..f81c9f54bda 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/client/cli" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/keeper" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" "github.com/cosmos/ibc-go/v9/modules/core/simulation" "github.com/cosmos/ibc-go/v9/modules/core/types" ) @@ -132,6 +133,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper) + packetservertypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper)) connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper)) diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 5e4aaa1db4a..4a2bb47b981 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -1,19 +1,15 @@ package keeper import ( - "bytes" - "strconv" + "fmt" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" @@ -23,14 +19,16 @@ import ( // It does not manage its own store. type Keeper struct { cdc codec.BinaryCodec + storeKey storetypes.StoreKey ChannelKeeper types.ChannelKeeper ClientKeeper types.ClientKeeper } // NewKeeper creates a new packet keeper -func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { return &Keeper{ cdc: cdc, + storeKey: storeKey, ChannelKeeper: channelKeeper, ClientKeeper: clientKeeper, } @@ -41,360 +39,26 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } -// 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 next sequence send will be initialized if this is the first packet sent for the given client. -func (k Keeper) SendPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - sourceChannel string, - sourcePort string, - destPort string, - timeoutHeight clienttypes.Height, - timeoutTimestamp uint64, - version string, - data []byte, -) (uint64, error) { - // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, sourceChannel) - if !ok { - return 0, errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, sourceChannel) - } - destChannel := counterparty.ClientId - - // retrieve the sequence send for this channel - // if no packets have been sent yet, initialize the sequence to 1. - sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) - if !found { - sequence = 1 - } - - // construct packet from given fields and channel state - packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, - destPort, destChannel, timeoutHeight, timeoutTimestamp, version) - - if err := packet.ValidateBasic(); err != nil { - return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) - } - - // check that the client of counterparty chain is still active - if status := k.ClientKeeper.GetClientStatus(ctx, sourceChannel); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", sourceChannel, status) - } - - // retrieve latest height and timestamp of the client of counterparty chain - latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel) - if latestHeight.IsZero() { - return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) - } - - latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight) - if err != nil { - return 0, err - } - - // check if packet is timed out on the receiving chain - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(latestHeight, latestTimestamp) { - return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") - } - - commitment := channeltypes.CommitPacket(packet) - - // bump the sequence and set the packet commitment so it is provable by the counterparty - k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) - k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - - k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) - - return sequence, nil +func (k Keeper) ChannelStore(ctx sdk.Context, channelID string) storetypes.KVStore { + channelPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyChannelStorePrefix, channelID)) + return prefix.NewStore(ctx.KVStore(k.storeKey), channelPrefix) } -// RecvPacket implements the packet receiving logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If the packet has already been received a no-op error is returned. -// The packet handler will verify that the packet has not timed out and that the -// counterparty stored a packet commitment. If successful, a packet receipt is stored -// to indicate to the counterparty successful delivery. -func (k Keeper) RecvPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) - } - if counterparty.ClientId != packet.SourceChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - // check if packet timed out by comparing it with the latest height of the chain - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if timeout.Elapsed(selfHeight, selfTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") - } - - // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received - // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale - // by the increase of the recvStartSequence. - _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - if found { - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - // This error indicates that the packet has already been relayed. Core IBC will - // treat this error as a no-op in order to prevent an entire relay transaction - // from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - commitment := channeltypes.CommitPacket(packet) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - packet.DestinationChannel, - proofHeight, - 0, 0, - proof, - merklePath, - commitment, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) - } - - // Set Packet Receipt to prevent timeout from occurring on counterparty - k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - - k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil +// SetCounterparty sets the Counterparty for a given channel identifier. +func (k *Keeper) SetCounterparty(ctx sdk.Context, channelID string, counterparty types.Counterparty) { + bz := k.cdc.MustMarshal(&counterparty) + k.ChannelStore(ctx, channelID).Set([]byte(types.CounterpartyKey), bz) } -// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement -// is written into state. -func (k Keeper) WriteAcknowledgement( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packetI exported.PacketI, - ack exported.Acknowledgement, -) error { - packet, ok := packetI.(channeltypes.Packet) - if !ok { - return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) - } - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.DestinationChannel) - if !ok { - return errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.DestinationChannel) - } - if counterparty.ClientId != packet.SourceChannel { - return channeltypes.ErrInvalidChannelIdentifier - } - - // NOTE: IBC app modules might have written the acknowledgement synchronously on - // the OnRecvPacket callback so we need to check if the acknowledgement is already - // set on the store and return an error if so. - if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { - return channeltypes.ErrAcknowledgementExists - } - - if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { - return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") - } - - if ack == nil { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") - } - - bz := ack.Acknowledgement() +// GetCounterparty gets the Counterparty for a given client identifier. +func (k *Keeper) GetCounterparty(ctx sdk.Context, clientID string) (types.Counterparty, bool) { + store := k.ChannelStore(ctx, clientID) + bz := store.Get([]byte(types.CounterpartyKey)) if len(bz) == 0 { - return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") - } - - k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) - - k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) - - return nil -} - -// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// the acknowledgement provided is verified to have been stored by the counterparty. -// If successful, the packet commitment is deleted and the packet has completed its lifecycle. -func (k Keeper) AcknowledgePacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - acknowledgement []byte, - proofAcked []byte, - proofHeight exported.Height, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) - } - - if counterparty.ClientId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - if len(commitment) == 0 { - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - // This error indicates that the acknowledgement has already been relayed - // or there is a misconfigured relayer attempting to prove an acknowledgement - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) - } - - path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyMembership( - ctx, - packet.SourceChannel, - proofHeight, - 0, 0, - proofAcked, - merklePath, - channeltypes.CommitAcknowledgement(acknowledgement), - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) - } - - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) - - channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil -} - -// TimeoutPacket implements the timeout logic required by a packet handler. -// The packet is checked for correctness including asserting that the packet was -// sent and received on clients which are counterparties for one another. -// If no packet commitment exists, a no-op error is returned, otherwise -// an absence proof of the packet receipt is performed to ensure that the packet -// was never delivered to the counterparty. If successful, the packet commitment -// is deleted and the packet has completed its lifecycle. -func (k Keeper) TimeoutPacket( - ctx sdk.Context, - _ *capabilitytypes.Capability, - packet channeltypes.Packet, - proof []byte, - proofHeight exported.Height, - _ uint64, -) (string, error) { - if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { - return "", channeltypes.ErrInvalidPacket - } - // Lookup counterparty associated with our channel and ensure - // that the packet was indeed sent by our counterparty. - counterparty, ok := k.ClientKeeper.GetCounterparty(ctx, packet.SourceChannel) - if !ok { - return "", errorsmod.Wrap(clienttypes.ErrCounterpartyNotFound, packet.SourceChannel) - } - - if counterparty.ClientId != packet.DestinationChannel { - return "", channeltypes.ErrInvalidChannelIdentifier - } - - // check that timeout height or timeout timestamp has passed on the other end - proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) - if err != nil { - return "", err - } - - timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) - if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { - return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + return types.Counterparty{}, false } - // check that the commitment has not been cleared and that it matches the packet sent by relayer - commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - - if len(commitment) == 0 { - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - // This error indicates that the timeout has already been relayed - // or there is a misconfigured relayer attempting to prove a timeout - // for a packet never sent. Core IBC will treat this error as a no-op in order to - // prevent an entire relay transaction from failing and consuming unnecessary fees. - return "", channeltypes.ErrNoOpMsg - } - - packetCommitment := channeltypes.CommitPacket(packet) - // verify we sent the packet and haven't cleared it out yet - if !bytes.Equal(commitment, packetCommitment) { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) - } - - // verify packet receipt absence - path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) - - if err := k.ClientKeeper.VerifyNonMembership( - ctx, - packet.SourceChannel, - proofHeight, - 0, 0, - proof, - merklePath, - ); err != nil { - return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) - } - - // delete packet commitment to prevent replay - k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) - - k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) - - channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) - - return packet.AppVersion, nil + var counterparty types.Counterparty + 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 7de9f82a0da..84b91ede35e 100644 --- a/modules/core/packet-server/keeper/keeper_test.go +++ b/modules/core/packet-server/keeper/keeper_test.go @@ -1,19 +1,21 @@ package keeper_test import ( - "fmt" "testing" testifysuite "github.com/stretchr/testify/suite" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" - "github.com/cosmos/ibc-go/v9/modules/core/exported" - ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/keeper" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" - "github.com/cosmos/ibc-go/v9/testing/mock" +) + +const ( + testClientID = "tendermint-0" ) var ( @@ -30,6 +32,9 @@ type KeeperTestSuite struct { // testing chains used for convenience and readability chainA *ibctesting.TestChain chainB *ibctesting.TestChain + + ctx sdk.Context + keeper *keeper.Keeper } // TestKeeperTestSuite runs all the tests within this package. @@ -46,596 +51,24 @@ func (suite *KeeperTestSuite) SetupTest() { // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) suite.coordinator.CommitNBlocks(suite.chainA, 2) suite.coordinator.CommitNBlocks(suite.chainB, 2) -} - -func (suite *KeeperTestSuite) TestSendPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "counterparty not found", - func() { - packet.SourceChannel = ibctesting.FirstChannelID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "packet failed basic validation", - func() { - // invalid data - packet.Data = nil - }, - channeltypes.ErrInvalidPacket, - }, - { - "client status invalid", - func() { - path.EndpointA.FreezeClient() - }, - clienttypes.ErrClientNotActive, - }, - { - "client state zero height", func() { - clientState := path.EndpointA.GetClientState() - cs, ok := clientState.(*ibctm.ClientState) - suite.Require().True(ok) - - // force a consensus state into the store at height zero to allow client status check to pass. - consensusState := path.EndpointA.GetConsensusState(cs.LatestHeight) - path.EndpointA.SetConsensusState(consensusState, clienttypes.ZeroHeight()) - - cs.LatestHeight = clienttypes.ZeroHeight() - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, cs) - }, - clienttypes.ErrInvalidHeight, - }, - { - "timeout elapsed", func() { - packet.TimeoutTimestamp = 1 - }, - channeltypes.ErrTimeoutElapsed, - }, - } - - for i, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { - suite.SetupTest() // reset - - // create clients and set counterparties on both chains - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // create standard packet that can be malleated - packet = channeltypes.NewPacketWithVersion(mock.MockPacketData, 1, mock.PortID, - path.EndpointA.ClientID, mock.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(1, 100), 0, mock.Version) - - // malleate the test case - tc.malleate() - - // send packet - seq, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, - packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), seq) - expCommitment := channeltypes.CommitPacket(packet) - suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Equal(uint64(0), seq) - suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) - - } - }) - } -} - -func (suite *KeeperTestSuite) TestRecvPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not V2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: counterparty not found", - func() { - packet.DestinationChannel = ibctesting.FirstChannelID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "failure: client is not active", - func() { - path.EndpointB.FreezeClient() - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: counterparty client identifier different than source channel", - func() { - packet.SourceChannel = ibctesting.FirstChannelID - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet has timed out", - func() { - packet.TimeoutHeight = clienttypes.ZeroHeight() - packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - }, - channeltypes.ErrTimeoutElapsed, - }, - { - "failure: packet already received", - func() { - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - }, - channeltypes.ErrNoOpMsg, - }, - { - "failure: verify membership failed", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, []byte("")) - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) - }, - commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - - tc.malleate() - - // get proof of packet commitment from chainA - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointA.QueryProof(packetKey) - - _, err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().True(found) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteAcknowledgement() { - var ( - packet channeltypes.Packet - ack exported.Acknowledgement - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not IBC_VERSION_2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: counterparty not found", - func() { - packet.DestinationChannel = ibctesting.FirstChannelID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "failure: counterparty client identifier different than source channel", - func() { - packet.SourceChannel = ibctesting.FirstChannelID - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: ack already exists", - func() { - ackBz := channeltypes.CommitAcknowledgement(ack.Acknowledgement()) - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence, ackBz) - }, - channeltypes.ErrAcknowledgementExists, - }, - { - "failure: ack is nil", - func() { - ack = nil - }, - channeltypes.ErrInvalidAcknowledgement, - }, - { - "failure: empty ack", - func() { - ack = mock.NewEmptyAcknowledgement() - }, - channeltypes.ErrInvalidAcknowledgement, - }, - { - "failure: receipt not found for packet", - func() { - packet.Sequence = 2 - }, - channeltypes.ErrInvalidPacket, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - ack = mock.MockAcknowledgement - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - - tc.malleate() - - err := suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), nil, packet, ack) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - ackCommitment, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().True(found) - suite.Require().Equal(channeltypes.CommitAcknowledgement(ack.Acknowledgement()), ackCommitment) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestAcknowledgePacket() { - var ( - packet channeltypes.Packet - ack = mock.MockAcknowledgement - freezeClient bool - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: protocol version is not IBC_VERSION_2", - func() { - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: counterparty not found", - func() { - packet.SourceChannel = ibctesting.FirstChannelID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "failure: counterparty client identifier different than source channel", - func() { - packet.DestinationChannel = ibctesting.FirstChannelID - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet commitment doesn't exist.", - func() { - suite.chainA.App.GetIBCKeeper().ChannelKeeper.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) - }, - channeltypes.ErrNoOpMsg, - }, - { - "failure: client status invalid", - func() { - freezeClient = true - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: packet commitment bytes differ", - func() { - packet.Data = []byte("") - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: verify membership fails", - func() { - ack = channeltypes.NewResultAcknowledgement([]byte("swapped acknowledgement")) - }, - commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - freezeClient = false - - // send packet - sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) - - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - tc.malleate() - - packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointB.QueryProof(packetKey) - - if freezeClient { - path.EndpointA.FreezeClient() - } - - _, err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), nil, packet, ack.Acknowledgement(), proof, proofHeight) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) - suite.Require().Empty(commitment) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } + suite.ctx = suite.chainA.GetContext() + suite.keeper = suite.chainA.App.GetPacketServer() } -func (suite *KeeperTestSuite) TestTimeoutPacket() { - var ( - path *ibctesting.Path - packet channeltypes.Packet - freezeClient bool - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success with timeout height", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - nil, - }, - { - "success with timeout timestamp", - func() { - // disable timeout height and set timeout timestamp to a past timestamp - packet.TimeoutHeight = clienttypes.Height{} - packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - nil, - }, - { - "failure: invalid protocol version", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.ProtocolVersion = channeltypes.IBC_VERSION_1 - packet.AppVersion = "" - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: counterparty not found", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.SourceChannel = ibctesting.FirstChannelID - }, - clienttypes.ErrCounterpartyNotFound, - }, - { - "failure: counterparty client identifier different than source channel", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - packet.DestinationChannel = ibctesting.FirstChannelID - }, - channeltypes.ErrInvalidChannelIdentifier, - }, - { - "failure: packet has not timed out yet", - func() { - packet.TimeoutHeight = defaultTimeoutHeight - - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - }, - channeltypes.ErrTimeoutNotReached, - }, - { - "failure: packet already timed out", - func() {}, // equivalent to not sending packet at all - channeltypes.ErrNoOpMsg, - }, - { - "failure: packet does not match commitment", - func() { - // send a different packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, []byte("different data")) - suite.Require().NoError(err, "send packet failed") - }, - channeltypes.ErrInvalidPacket, - }, - { - "failure: client status invalid", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - freezeClient = true - }, - clienttypes.ErrClientNotActive, - }, - { - "failure: verify non-membership failed", - func() { - // send packet - _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, - packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) - suite.Require().NoError(err, "send packet failed") - - // set packet receipt to mock a valid past receive - suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - }, - commitmenttypes.ErrInvalidProof, - }, +func (suite *KeeperTestSuite) TestSetCounterparty() { + merklePathPrefix := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) + counterparty := types.Counterparty{ + ClientId: testClientID, + MerklePathPrefix: merklePathPrefix, } + suite.keeper.SetCounterparty(suite.ctx, testClientID, counterparty) - for _, tc := range testCases { - tc := tc + retrievedCounterparty, found := suite.keeper.GetCounterparty(suite.ctx, testClientID) + suite.Require().True(found, "GetCounterparty does not return counterparty") + suite.Require().Equal(counterparty, retrievedCounterparty, "Counterparty retrieved not equal") - suite.Run(tc.name, func() { - suite.SetupTest() - // initialize freezeClient to false - freezeClient = false - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupV2() - - // create default packet with a timed out height - // test cases may mutate timeout values - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) - - tc.malleate() - - // need to update chainA's client representing chainB to prove missing ack - // commit the changes and update the clients - suite.coordinator.CommitBlock(path.EndpointA.Chain) - suite.Require().NoError(path.EndpointB.UpdateClient()) - suite.Require().NoError(path.EndpointA.UpdateClient()) - - // get proof of packet receipt absence from chainB - receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointB.QueryProof(receiptKey) - - if freezeClient { - path.EndpointA.FreezeClient() - } - - _, err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), nil, packet, proof, proofHeight, 0) - - expPass := tc.expError == nil - if expPass { - suite.Require().NoError(err) - - commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) - suite.Require().Nil(commitment, "packet commitment not deleted") - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } + retrievedCounterparty, found = suite.keeper.GetCounterparty(suite.ctx, "client-0") + suite.Require().False(found, "GetCounterparty unexpectedly returned a counterparty") + suite.Require().Equal(types.Counterparty{}, retrievedCounterparty, "Counterparty retrieved not empty") } diff --git a/modules/core/packet-server/keeper/relay.go b/modules/core/packet-server/keeper/relay.go new file mode 100644 index 00000000000..280de31f30c --- /dev/null +++ b/modules/core/packet-server/keeper/relay.go @@ -0,0 +1,411 @@ +package keeper + +import ( + "bytes" + "strconv" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channelkeeper "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" +) + +// 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 next sequence send will be initialized if this is the first packet sent for the given client. +func (k Keeper) SendPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + sourceChannel string, + sourcePort string, + destPort string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + version string, + data []byte, +) (uint64, error) { + // Lookup counterparty associated with our source channel to retrieve the destination channel + counterparty, ok := k.GetCounterparty(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 { + // we can key on just the source channel here since channel ids are globally unique + k.SetCounterparty(ctx, sourceChannel, counterparty) + } else { + // if neither a counterparty nor channel is found then simply return an error + return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceChannel) + } + } + destChannel := counterparty.CounterpartyChannel + clientID := counterparty.ClientId + + // retrieve the sequence send for this channel + // if no packets have been sent yet, initialize the sequence to 1. + sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + sequence = 1 + } + + // construct packet from given fields and channel state + packet := channeltypes.NewPacketWithVersion(data, sequence, sourcePort, sourceChannel, + destPort, destChannel, timeoutHeight, timeoutTimestamp, version) + + if err := packet.ValidateBasic(); err != nil { + return 0, errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "constructed packet failed basic validation: %v", err) + } + + // check that the client of counterparty chain is still active + if status := k.ClientKeeper.GetClientStatus(ctx, clientID); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) + } + + // retrieve latest height and timestamp of the client of counterparty chain + latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, clientID) + if latestHeight.IsZero() { + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel) + } + + latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, clientID, latestHeight) + if err != nil { + return 0, err + } + + // check if packet is timed out on the receiving chain + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(latestHeight, latestTimestamp) { + return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout") + } + + commitment := channeltypes.CommitPacket(packet) + + // bump the sequence and set the packet commitment so it is provable by the counterparty + k.ChannelKeeper.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) + k.ChannelKeeper.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) + + // log that a packet has been sent + k.Logger(ctx).Info("packet sent", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + channelkeeper.EmitSendPacketEvent(ctx, packet, nil, timeoutHeight) + + // return the sequence + return sequence, nil +} + +// RecvPacket implements the packet receiving logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If the packet has already been received a no-op error is returned. +// The packet handler will verify that the packet has not timed out and that the +// counterparty stored a packet commitment. If successful, a packet receipt is stored +// to indicate to the counterparty successful delivery. +func (k Keeper) RecvPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + // Note: This can be implemented by the current keeper + counterparty, ok := k.GetCounterparty(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 { + // we can key on just the destination channel here since channel ids are globally unique + k.SetCounterparty(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) + } + } + if counterparty.CounterpartyChannel != packet.SourceChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + clientID := counterparty.ClientId + + // check if packet timed out by comparing it with the latest height of the chain + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if timeout.Elapsed(selfHeight, selfTimestamp) { + return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") + } + + // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received + // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale + // by the increase of the recvStartSequence. + _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + if found { + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) + // This error indicates that the packet has already been relayed. Core IBC will + // treat this error as a no-op in order to prevent an entire relay transaction + // from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + // create key/value pair for proof verification by appending the ICS24 path to the last element of the counterparty merklepath + // TODO: allow for custom prefix + path := host.PacketCommitmentKey(packet.SourcePort, packet.SourceChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + commitment := channeltypes.CommitPacket(packet) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + clientID, + proofHeight, + 0, 0, + proof, + merklePath, + commitment, + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet commitment verification for client (%s)", packet.DestinationChannel) + } + + // Set Packet Receipt to prevent timeout from occurring on counterparty + k.ChannelKeeper.SetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + + // log that a packet has been received & executed + k.Logger(ctx).Info("packet received", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit the same events as receive packet without channel fields + channelkeeper.EmitRecvPacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} + +// WriteAcknowledgement implements the async acknowledgement writing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no acknowledgement exists for the given packet, then a commitment of the acknowledgement +// is written into state. +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packetI exported.PacketI, + ack exported.Acknowledgement, +) error { + packet, ok := packetI.(channeltypes.Packet) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "expected type %T, got %T", &channeltypes.Packet{}, packetI) + } + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + counterparty, ok := k.GetCounterparty(ctx, packet.DestinationChannel) + if !ok { + return errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.DestinationChannel) + } + if counterparty.CounterpartyChannel != packet.SourceChannel { + return channeltypes.ErrInvalidChannelIdentifier + } + + // NOTE: IBC app modules might have written the acknowledgement synchronously on + // the OnRecvPacket callback so we need to check if the acknowledgement is already + // set on the store and return an error if so. + if k.ChannelKeeper.HasPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence) { + return channeltypes.ErrAcknowledgementExists + } + + if _, found := k.ChannelKeeper.GetPacketReceipt(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence); !found { + return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet") + } + + if ack == nil { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be nil") + } + + bz := ack.Acknowledgement() + if len(bz) == 0 { + return errorsmod.Wrap(channeltypes.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") + } + + k.ChannelKeeper.SetPacketAcknowledgement(ctx, packet.DestinationPort, packet.DestinationChannel, packet.Sequence, channeltypes.CommitAcknowledgement(bz)) + + // log that a packet acknowledgement has been written + k.Logger(ctx).Info("acknowledgement written", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit the same events as write acknowledgement without channel fields + channelkeeper.EmitWriteAcknowledgementEvent(ctx, packet, nil, bz) + + return nil +} + +// AcknowledgePacket implements the acknowledgement processing logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// the acknowledgement provided is verified to have been stored by the counterparty. +// If successful, the packet commitment is deleted and the packet has completed its lifecycle. +func (k Keeper) AcknowledgePacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + acknowledgement []byte, + proofAcked []byte, + proofHeight exported.Height, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + + // Lookup counterparty associated with our channel and ensure that it was packet was indeed + // sent by our counterparty. + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + } + + if counterparty.CounterpartyChannel != packet.DestinationChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + clientID := counterparty.ClientId + + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + if len(commitment) == 0 { + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) + + // This error indicates that the acknowledgement has already been relayed + // or there is a misconfigured relayer attempting to prove an acknowledgement + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "commitment bytes are not equal: got (%v), expected (%v)", packetCommitment, commitment) + } + + path := host.PacketAcknowledgementKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyMembership( + ctx, + clientID, + proofHeight, + 0, 0, + proofAcked, + merklePath, + channeltypes.CommitAcknowledgement(acknowledgement), + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet acknowledgement verification for client (%s)", packet.SourceChannel) + } + + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + // log that a packet has been acknowledged + k.Logger(ctx).Info("packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), "src_channel", packet.GetSourceChannel(), "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel()) + + // emit the same events as acknowledge packet without channel fields + channelkeeper.EmitAcknowledgePacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} + +// TimeoutPacket implements the timeout logic required by a packet handler. +// The packet is checked for correctness including asserting that the packet was +// sent and received on clients which are counterparties for one another. +// If no packet commitment exists, a no-op error is returned, otherwise +// an absence proof of the packet receipt is performed to ensure that the packet +// was never delivered to the counterparty. If successful, the packet commitment +// is deleted and the packet has completed its lifecycle. +func (k Keeper) TimeoutPacket( + ctx sdk.Context, + _ *capabilitytypes.Capability, + packet channeltypes.Packet, + proof []byte, + proofHeight exported.Height, + _ uint64, +) (string, error) { + if packet.ProtocolVersion != channeltypes.IBC_VERSION_2 { + return "", channeltypes.ErrInvalidPacket + } + // Lookup counterparty associated with our channel and ensure that destination channel + // is the expected counterparty + counterparty, ok := k.GetCounterparty(ctx, packet.SourceChannel) + if !ok { + return "", errorsmod.Wrap(types.ErrCounterpartyNotFound, packet.SourceChannel) + } + clientID := counterparty.ClientId + + if counterparty.CounterpartyChannel != packet.DestinationChannel { + return "", channeltypes.ErrInvalidChannelIdentifier + } + + // check that timeout height or timeout timestamp has passed on the other end + proofTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, packet.SourceChannel, proofHeight) + if err != nil { + return "", err + } + + timeout := channeltypes.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) + if !timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { + return "", errorsmod.Wrap(timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "packet timeout not reached") + } + + // check that the commitment has not been cleared and that it matches the packet sent by relayer + commitment := k.ChannelKeeper.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + + if len(commitment) == 0 { + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) + // This error indicates that the timeout has already been relayed + // or there is a misconfigured relayer attempting to prove a timeout + // for a packet never sent. Core IBC will treat this error as a no-op in order to + // prevent an entire relay transaction from failing and consuming unnecessary fees. + return "", channeltypes.ErrNoOpMsg + } + + packetCommitment := channeltypes.CommitPacket(packet) + // verify we sent the packet and haven't cleared it out yet + if !bytes.Equal(commitment, packetCommitment) { + return "", errorsmod.Wrapf(channeltypes.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) + } + + // verify packet receipt absence + path := host.PacketReceiptKey(packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + merklePath := types.BuildMerklePath(counterparty.MerklePathPrefix, path) + + if err := k.ClientKeeper.VerifyNonMembership( + ctx, + clientID, + proofHeight, + 0, 0, + proof, + merklePath, + ); err != nil { + return "", errorsmod.Wrapf(err, "failed packet receipt absence verification for client (%s)", packet.SourceChannel) + } + + // delete packet commitment to prevent replay + k.ChannelKeeper.DeletePacketCommitment(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + + // log that a packet has been timed out + k.Logger(ctx).Info("packet timed out", "sequence", strconv.FormatUint(packet.Sequence, 10), "src_port", packet.SourcePort, "src_channel", packet.SourceChannel, "dst_port", packet.DestinationPort, "dst_channel", packet.DestinationChannel) + + // emit timeout events + channelkeeper.EmitTimeoutPacketEvent(ctx, packet, nil) + + return packet.AppVersion, nil +} diff --git a/modules/core/packet-server/keeper/relay_test.go b/modules/core/packet-server/keeper/relay_test.go new file mode 100644 index 00000000000..69f95816f8c --- /dev/null +++ b/modules/core/packet-server/keeper/relay_test.go @@ -0,0 +1,592 @@ +package keeper_test + +import ( + "fmt" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/exported" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/ibc-go/v9/testing/mock" +) + +func (suite *KeeperTestSuite) TestSendPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "counterparty not found", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + types.ErrCounterpartyNotFound, + }, + { + "packet failed basic validation", + func() { + // invalid data + packet.Data = nil + }, + channeltypes.ErrInvalidPacket, + }, + { + "client status invalid", + func() { + path.EndpointA.FreezeClient() + }, + clienttypes.ErrClientNotActive, + }, + { + "timeout elapsed", + func() { + packet.TimeoutTimestamp = 1 + }, + channeltypes.ErrTimeoutElapsed, + }, + } + + for i, tc := range testCases { + tc := tc + suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { + suite.SetupTest() // reset + + // create clients and set counterparties on both chains + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // create standard packet that can be malleated + packet = channeltypes.NewPacketWithVersion(mock.MockPacketData, 1, mock.PortID, + path.EndpointA.ClientID, mock.PortID, path.EndpointB.ClientID, clienttypes.NewHeight(1, 100), 0, mock.Version) + + // malleate the test case + tc.malleate() + + // send packet + seq, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, + packet.DestinationPort, packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().Equal(uint64(1), seq) + expCommitment := channeltypes.CommitPacket(packet) + suite.Require().Equal(expCommitment, suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Equal(uint64(0), seq) + suite.Require().Nil(suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, seq)) + + } + }) + } +} + +func (suite *KeeperTestSuite) TestRecvPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not V2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + types.ErrCounterpartyNotFound, + }, + { + "failure: client is not active", + func() { + path.EndpointB.FreezeClient() + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has timed out", + func() { + packet.TimeoutHeight = clienttypes.ZeroHeight() + packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + }, + channeltypes.ErrTimeoutElapsed, + }, + { + "failure: packet already received", + func() { + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: verify membership failed", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, []byte("")) + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // send packet + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) + + tc.malleate() + + // get proof of packet commitment from chainA + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointA.QueryProof(packetKey) + + _, err = suite.chainB.App.GetPacketServer().RecvPacket(suite.chainB.GetContext(), nil, packet, proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().True(found) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestWriteAcknowledgement() { + var ( + packet channeltypes.Packet + ack exported.Acknowledgement + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not IBC_VERSION_2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + types.ErrCounterpartyNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: ack already exists", + func() { + ackBz := channeltypes.CommitAcknowledgement(ack.Acknowledgement()) + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence, ackBz) + }, + channeltypes.ErrAcknowledgementExists, + }, + { + "failure: ack is nil", + func() { + ack = nil + }, + channeltypes.ErrInvalidAcknowledgement, + }, + { + "failure: empty ack", + func() { + ack = mock.NewEmptyAcknowledgement() + }, + channeltypes.ErrInvalidAcknowledgement, + }, + { + "failure: receipt not found for packet", + func() { + packet.Sequence = 2 + }, + channeltypes.ErrInvalidPacket, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, "") + ack = mock.MockAcknowledgement + + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + + tc.malleate() + + err := suite.chainB.App.GetPacketServer().WriteAcknowledgement(suite.chainB.GetContext(), nil, packet, ack) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + ackCommitment, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().True(found) + suite.Require().Equal(channeltypes.CommitAcknowledgement(ack.Acknowledgement()), ackCommitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestAcknowledgePacket() { + var ( + packet channeltypes.Packet + ack = mock.MockAcknowledgement + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: protocol version is not IBC_VERSION_2", + func() { + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + packet.SourceChannel = ibctesting.FirstChannelID + }, + types.ErrCounterpartyNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet commitment doesn't exist.", + func() { + suite.chainA.App.GetIBCKeeper().ChannelKeeper.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) + }, + channeltypes.ErrNoOpMsg, + }, + { + "failure: client status invalid", + func() { + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: packet commitment bytes differ", + func() { + packet.Data = []byte("") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: verify membership fails", + func() { + ack = channeltypes.NewResultAcknowledgement([]byte("swapped acknowledgement")) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + freezeClient = false + + // send packet + sequence, err := path.EndpointA.SendPacketV2(defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version, ibctesting.MockPacketData) + suite.Require().NoError(err) + + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, defaultTimeoutHeight, disabledTimeoutTimestamp, mock.Version) + + err = path.EndpointB.RecvPacket(packet) + suite.Require().NoError(err) + + tc.malleate() + + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointB.QueryProof(packetKey) + + if freezeClient { + path.EndpointA.FreezeClient() + } + + _, err = suite.chainA.App.GetPacketServer().AcknowledgePacket(suite.chainA.GetContext(), nil, packet, ack.Acknowledgement(), proof, proofHeight) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence) + suite.Require().Empty(commitment) + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} + +func (suite *KeeperTestSuite) TestTimeoutPacket() { + var ( + path *ibctesting.Path + packet channeltypes.Packet + freezeClient bool + ) + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success with timeout height", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + nil, + }, + { + "success with timeout timestamp", + func() { + // disable timeout height and set timeout timestamp to a past timestamp + packet.TimeoutHeight = clienttypes.Height{} + packet.TimeoutTimestamp = uint64(suite.chainB.GetContext().BlockTime().UnixNano()) + + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + nil, + }, + { + "failure: invalid protocol version", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.ProtocolVersion = channeltypes.IBC_VERSION_1 + packet.AppVersion = "" + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: counterparty not found", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.SourceChannel = ibctesting.FirstChannelID + }, + types.ErrCounterpartyNotFound, + }, + { + "failure: counterparty client identifier different than source channel", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + packet.DestinationChannel = ibctesting.FirstChannelID + }, + channeltypes.ErrInvalidChannelIdentifier, + }, + { + "failure: packet has not timed out yet", + func() { + packet.TimeoutHeight = defaultTimeoutHeight + + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + }, + channeltypes.ErrTimeoutNotReached, + }, + { + "failure: packet already timed out", + func() {}, // equivalent to not sending packet at all + channeltypes.ErrNoOpMsg, + }, + { + "failure: packet does not match commitment", + func() { + // send a different packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, []byte("different data")) + suite.Require().NoError(err, "send packet failed") + }, + channeltypes.ErrInvalidPacket, + }, + { + "failure: client status invalid", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + freezeClient = true + }, + clienttypes.ErrClientNotActive, + }, + { + "failure: verify non-membership failed", + func() { + // send packet + _, err := suite.chainA.App.GetPacketServer().SendPacket(suite.chainA.GetContext(), nil, packet.SourceChannel, packet.SourcePort, packet.DestinationPort, + packet.TimeoutHeight, packet.TimeoutTimestamp, packet.AppVersion, packet.Data) + suite.Require().NoError(err, "send packet failed") + + // set packet receipt to mock a valid past receive + suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + }, + commitmenttypes.ErrInvalidProof, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() + // initialize freezeClient to false + freezeClient = false + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + // create default packet with a timed out height + // test cases may mutate timeout values + timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) + packet = channeltypes.NewPacketWithVersion(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ClientID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ClientID, timeoutHeight, disabledTimeoutTimestamp, mock.Version) + + tc.malleate() + + // need to update chainA's client representing chainB to prove missing ack + // commit the changes and update the clients + suite.coordinator.CommitBlock(path.EndpointA.Chain) + suite.Require().NoError(path.EndpointB.UpdateClient()) + suite.Require().NoError(path.EndpointA.UpdateClient()) + + // get proof of packet receipt absence from chainB + receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := path.EndpointB.QueryProof(receiptKey) + + if freezeClient { + path.EndpointA.FreezeClient() + } + + _, err := suite.chainA.App.GetPacketServer().TimeoutPacket(suite.chainA.GetContext(), nil, packet, proof, proofHeight, 0) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + + commitment := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.DestinationPort, packet.DestinationChannel, packet.Sequence) + suite.Require().Nil(commitment, "packet commitment not deleted") + } else { + suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/modules/core/packet-server/types/codec.go b/modules/core/packet-server/types/codec.go new file mode 100644 index 00000000000..6d4476be76a --- /dev/null +++ b/modules/core/packet-server/types/codec.go @@ -0,0 +1,14 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterInterfaces registers the packet-server interfaces to protobuf Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgProvideCounterparty{}, + ) +} diff --git a/modules/core/packet-server/types/counterparty.go b/modules/core/packet-server/types/counterparty.go new file mode 100644 index 00000000000..5073e7c36d3 --- /dev/null +++ b/modules/core/packet-server/types/counterparty.go @@ -0,0 +1,34 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" +) + +// NewCounterparty creates a new Counterparty instance +func NewCounterparty(clientID, channelID string, merklePathPrefix commitmenttypes.MerklePath) Counterparty { + return Counterparty{ + ClientId: clientID, + CounterpartyChannel: channelID, + MerklePathPrefix: merklePathPrefix, + } +} + +// Validate validates the Counterparty +func (c Counterparty) Validate() error { + if err := host.ClientIdentifierValidator(c.ClientId); err != nil { + return err + } + + if err := host.ChannelIdentifierValidator(c.CounterpartyChannel); err != nil { + return err + } + + if c.MerklePathPrefix.Empty() { + return errorsmod.Wrap(ErrInvalidCounterparty, "prefix cannot be empty") + } + + return nil +} diff --git a/modules/core/packet-server/types/counterparty.pb.go b/modules/core/packet-server/types/counterparty.pb.go new file mode 100644 index 00000000000..5d898f114e5 --- /dev/null +++ b/modules/core/packet-server/types/counterparty.pb.go @@ -0,0 +1,440 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/packetserver/v1/counterparty.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + v2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// 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 +// this value is stored under our side's channel ID. which we will use to write all packet messages +// sent to counterparty +type Counterparty struct { + // the client identifier of the counterparty chain + // client id of the counterparty stored on our chain + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // the counterparty channel identifier that must be used by the packet + CounterpartyChannel string `protobuf:"bytes,2,opt,name=counterparty_channel,json=counterpartyChannel,proto3" json:"counterparty_channel,omitempty"` + // the key path used to store packet flow messages that the counterparty + // will use to send to us. We will append the channelID and sequence in order to create the final path. + MerklePathPrefix v2.MerklePath `protobuf:"bytes,3,opt,name=merkle_path_prefix,json=merklePathPrefix,proto3" json:"merkle_path_prefix"` +} + +func (m *Counterparty) Reset() { *m = Counterparty{} } +func (m *Counterparty) String() string { return proto.CompactTextString(m) } +func (*Counterparty) ProtoMessage() {} +func (*Counterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_e0c60a0709a0040c, []int{0} +} +func (m *Counterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Counterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Counterparty.Merge(m, src) +} +func (m *Counterparty) XXX_Size() int { + return m.Size() +} +func (m *Counterparty) XXX_DiscardUnknown() { + xxx_messageInfo_Counterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_Counterparty proto.InternalMessageInfo + +func (m *Counterparty) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *Counterparty) GetCounterpartyChannel() string { + if m != nil { + return m.CounterpartyChannel + } + return "" +} + +func (m *Counterparty) GetMerklePathPrefix() v2.MerklePath { + if m != nil { + return m.MerklePathPrefix + } + return v2.MerklePath{} +} + +func init() { + proto.RegisterType((*Counterparty)(nil), "ibc.core.packetserver.v1.Counterparty") +} + +func init() { + proto.RegisterFile("ibc/core/packetserver/v1/counterparty.proto", fileDescriptor_e0c60a0709a0040c) +} + +var fileDescriptor_e0c60a0709a0040c = []byte{ + // 307 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x31, 0x4e, 0xc3, 0x30, + 0x18, 0x85, 0x63, 0x40, 0x88, 0x06, 0x06, 0x14, 0x3a, 0x44, 0x45, 0x32, 0x55, 0x17, 0x2a, 0xa1, + 0xda, 0x6a, 0x99, 0x90, 0x98, 0xda, 0x89, 0x01, 0xa9, 0xea, 0xd0, 0x81, 0x25, 0x4a, 0xdc, 0x9f, + 0xc4, 0x6a, 0x1c, 0x5b, 0x8e, 0x6b, 0xd1, 0x5b, 0x70, 0x1a, 0xce, 0xd0, 0xb1, 0x23, 0x13, 0x42, + 0xed, 0x45, 0x50, 0x12, 0x14, 0x79, 0xb3, 0xff, 0xf7, 0xf9, 0xf9, 0xfd, 0xcf, 0x7f, 0xe0, 0x09, + 0xa3, 0x4c, 0x6a, 0xa0, 0x2a, 0x66, 0x6b, 0x30, 0x25, 0x68, 0x0b, 0x9a, 0xda, 0x31, 0x65, 0x72, + 0x53, 0x18, 0xd0, 0x2a, 0xd6, 0x66, 0x4b, 0x94, 0x96, 0x46, 0x06, 0x21, 0x4f, 0x18, 0xa9, 0x60, + 0xe2, 0xc2, 0xc4, 0x8e, 0x7b, 0xdd, 0x54, 0xa6, 0xb2, 0x86, 0x68, 0x75, 0x6a, 0xf8, 0xde, 0x7d, + 0x6b, 0xce, 0xa4, 0x10, 0xdc, 0x08, 0x28, 0x0c, 0xb5, 0x13, 0xe7, 0xd6, 0x80, 0x83, 0x2f, 0xe4, + 0x5f, 0xcd, 0x9c, 0xff, 0x82, 0x5b, 0xbf, 0xc3, 0x72, 0x0e, 0x85, 0x89, 0xf8, 0x2a, 0x44, 0x7d, + 0x34, 0xec, 0x2c, 0x2e, 0x9a, 0xc1, 0xcb, 0x2a, 0x18, 0xfb, 0x5d, 0x37, 0x5c, 0xc4, 0xb2, 0xb8, + 0x28, 0x20, 0x0f, 0x4f, 0x6a, 0xee, 0xc6, 0xd5, 0x66, 0x8d, 0x14, 0x2c, 0xfd, 0x40, 0x80, 0x5e, + 0xe7, 0x10, 0xa9, 0xd8, 0x64, 0x91, 0xd2, 0xf0, 0xce, 0x3f, 0xc2, 0xd3, 0x3e, 0x1a, 0x5e, 0x4e, + 0x06, 0xa4, 0x5d, 0xcb, 0x09, 0x66, 0x27, 0xe4, 0xb5, 0x7e, 0x31, 0x8f, 0x4d, 0x36, 0x3d, 0xdb, + 0xfd, 0xdc, 0x79, 0x8b, 0x6b, 0xd1, 0x4e, 0xe6, 0xb5, 0xc3, 0x74, 0xb9, 0x3b, 0x60, 0xb4, 0x3f, + 0x60, 0xf4, 0x7b, 0xc0, 0xe8, 0xf3, 0x88, 0xbd, 0xfd, 0x11, 0x7b, 0xdf, 0x47, 0xec, 0xbd, 0x3d, + 0xa7, 0xdc, 0x64, 0x9b, 0xa4, 0xb2, 0xa4, 0x4c, 0x96, 0x42, 0x96, 0x94, 0x27, 0x6c, 0x94, 0x4a, + 0x6a, 0x9f, 0xa8, 0x90, 0xab, 0x4d, 0x0e, 0xa5, 0x5b, 0xfc, 0xe8, 0xbf, 0x79, 0xb3, 0x55, 0x50, + 0x26, 0xe7, 0x75, 0x2f, 0x8f, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x3b, 0xa6, 0xaa, 0x9f, + 0x01, 0x00, 0x00, +} + +func (m *Counterparty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.MerklePathPrefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCounterparty(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.CounterpartyChannel) > 0 { + i -= len(m.CounterpartyChannel) + copy(dAtA[i:], m.CounterpartyChannel) + i = encodeVarintCounterparty(dAtA, i, uint64(len(m.CounterpartyChannel))) + 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-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCounterparty(dAtA []byte, offset int, v uint64) int { + offset -= sovCounterparty(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Counterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + l = len(m.CounterpartyChannel) + if l > 0 { + n += 1 + l + sovCounterparty(uint64(l)) + } + l = m.MerklePathPrefix.Size() + n += 1 + l + sovCounterparty(uint64(l)) + return n +} + +func sovCounterparty(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 (m *Counterparty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Counterparty: 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) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MerklePathPrefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCounterparty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCounterparty + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCounterparty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MerklePathPrefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCounterparty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCounterparty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCounterparty(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCounterparty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCounterparty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCounterparty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCounterparty + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCounterparty + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCounterparty + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCounterparty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCounterparty = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCounterparty = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/packet-server/types/counterparty_test.go b/modules/core/packet-server/types/counterparty_test.go new file mode 100644 index 00000000000..ddf1cb0fe18 --- /dev/null +++ b/modules/core/packet-server/types/counterparty_test.go @@ -0,0 +1,66 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +func TestValidateCounterparty(t *testing.T) { + testCases := []struct { + name string + clientID string + channelID string + merklePathPrefix commitmenttypes.MerklePath + expError error + }{ + { + "success", + ibctesting.FirstClientID, + ibctesting.FirstChannelID, + commitmenttypes.NewMerklePath([]byte("ibc")), + nil, + }, + { + "failure: invalid client id", + "", + ibctesting.FirstChannelID, + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: invalid counterparty channel id", + ibctesting.FirstClientID, + "", + commitmenttypes.NewMerklePath([]byte("ibc")), + host.ErrInvalidID, + }, + { + "failure: empty merkle path prefix", + ibctesting.FirstClientID, + ibctesting.FirstChannelID, + commitmenttypes.NewMerklePath(), + types.ErrInvalidCounterparty, + }, + } + + for _, tc := range testCases { + tc := tc + + counterparty := types.NewCounterparty(tc.clientID, tc.channelID, tc.merklePathPrefix) + err := counterparty.Validate() + + expPass := tc.expError == nil + if expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + require.ErrorIs(t, err, tc.expError) + } + } +} diff --git a/modules/core/packet-server/types/errors.go b/modules/core/packet-server/types/errors.go new file mode 100644 index 00000000000..fc4fe0188c7 --- /dev/null +++ b/modules/core/packet-server/types/errors.go @@ -0,0 +1,12 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +// IBC packet server sentinel errors +var ( + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 1, "invalid counterparty") + ErrCounterpartyNotFound = errorsmod.Register(SubModuleName, 2, "counterparty not found") + ErrInvalidPacketPath = errorsmod.Register(SubModuleName, 3, "invalid packet path") +) diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index c3e23572228..cd6b116a95f 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -38,6 +38,9 @@ type ChannelKeeper interface { // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path // This is a public path that is standardized by the IBC specification SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) + + // GetChannel returns a version 2 counterparty for a given portID and channel ID + GetV2Counterparty(ctx sdk.Context, portID, channelID string) (Counterparty, bool) } type ClientKeeper interface { @@ -45,10 +48,6 @@ type ClientKeeper interface { VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error - // GetCounterparty returns the counterparty client given the client ID on - // the executing chain - // This is a private path that is only used by the IBC lite module - GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool) // GetClientStatus returns the status of a client given the client ID GetClientStatus(ctx sdk.Context, clientID string) exported.Status // GetClientLatestHeight returns the latest height of a client given the client ID diff --git a/modules/core/packet-server/types/keys.go b/modules/core/packet-server/types/keys.go index 1dbfabd45e8..6b684551fac 100644 --- a/modules/core/packet-server/types/keys.go +++ b/modules/core/packet-server/types/keys.go @@ -1,3 +1,11 @@ package types -const SubModuleName = "packetserver" +const ( + // SubModuleName defines the IBC packet server name + SubModuleName string = "packetserver" + + // CounterpartyKey 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" +) diff --git a/modules/core/packet-server/types/msgs.go b/modules/core/packet-server/types/msgs.go new file mode 100644 index 00000000000..33fab11e606 --- /dev/null +++ b/modules/core/packet-server/types/msgs.go @@ -0,0 +1,47 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + commitmenttypes "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" +) + +var ( + _ sdk.Msg = (*MsgProvideCounterparty)(nil) + + _ sdk.HasValidateBasic = (*MsgProvideCounterparty)(nil) +) + +// NewMsgProvideCounterparty creates a new MsgProvideCounterparty instance +// MsgProvideCounterparty will set the channel id to the client id for this chain. It is only allowed to be different +// for existing v1 channels that are aliased to a new Eureka counterparty. +func NewMsgProvideCounterparty(signer, clientID, counterpartyChannelID string, merklePathPrefix commitmenttypes.MerklePath) *MsgProvideCounterparty { + counterparty := NewCounterparty(clientID, counterpartyChannelID, merklePathPrefix) + + return &MsgProvideCounterparty{ + Signer: signer, + ChannelId: clientID, + Counterparty: counterparty, + } +} + +// ValidateBasic performs basic checks on a MsgProvideCounterparty. +func (msg *MsgProvideCounterparty) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + return err + } + + if err := msg.Counterparty.Validate(); err != nil { + return err + } + + return nil +} diff --git a/modules/core/packet-server/types/msgs_test.go b/modules/core/packet-server/types/msgs_test.go new file mode 100644 index 00000000000..b5e86540385 --- /dev/null +++ b/modules/core/packet-server/types/msgs_test.go @@ -0,0 +1,73 @@ +package types_test + +import ( + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + 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/packet-server/types" + ibctesting "github.com/cosmos/ibc-go/v9/testing" +) + +// TestMsgProvideCounterpartyValidateBasic tests ValidateBasic for MsgProvideCounterparty +func (suite *TypesTestSuite) TestMsgProvideCounterpartyValidateBasic() { + var msg *types.MsgProvideCounterparty + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success", + func() {}, + nil, + }, + { + "failure: invalid signer address", + func() { + msg.Signer = "invalid" + }, + ibcerrors.ErrInvalidAddress, + }, + { + "failure: invalid client ID", + func() { + msg.ChannelId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid counterparty client ID", + func() { + msg.Counterparty.ClientId = "" + }, + 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.TestAccAddress, + ibctesting.FirstClientID, + ibctesting.SecondClientID, + commitmenttypes.NewMerklePath([]byte("key")), + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err, "valid case %s failed", tc.name) + } else { + suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) + } + } +} diff --git a/modules/core/packet-server/types/tx.pb.go b/modules/core/packet-server/types/tx.pb.go new file mode 100644 index 00000000000..46212f381ec --- /dev/null +++ b/modules/core/packet-server/types/tx.pb.go @@ -0,0 +1,624 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/packetserver/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +type MsgProvideCounterparty struct { + // unique identifier we will use to write all packet messages sent to counterparty + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // counterparty client + Counterparty Counterparty `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgProvideCounterparty) Reset() { *m = MsgProvideCounterparty{} } +func (m *MsgProvideCounterparty) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterparty) ProtoMessage() {} +func (*MsgProvideCounterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{0} +} +func (m *MsgProvideCounterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterparty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgProvideCounterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterparty.Merge(m, src) +} +func (m *MsgProvideCounterparty) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterparty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterparty proto.InternalMessageInfo + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +type MsgProvideCounterpartyResponse struct { +} + +func (m *MsgProvideCounterpartyResponse) Reset() { *m = MsgProvideCounterpartyResponse{} } +func (m *MsgProvideCounterpartyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProvideCounterpartyResponse) ProtoMessage() {} +func (*MsgProvideCounterpartyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3c556aec8b7966db, []int{1} +} +func (m *MsgProvideCounterpartyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProvideCounterpartyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProvideCounterpartyResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgProvideCounterpartyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProvideCounterpartyResponse.Merge(m, src) +} +func (m *MsgProvideCounterpartyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProvideCounterpartyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProvideCounterpartyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProvideCounterpartyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgProvideCounterparty)(nil), "ibc.core.packetserver.v1.MsgProvideCounterparty") + proto.RegisterType((*MsgProvideCounterpartyResponse)(nil), "ibc.core.packetserver.v1.MsgProvideCounterpartyResponse") +} + +func init() { proto.RegisterFile("ibc/core/packetserver/v1/tx.proto", fileDescriptor_3c556aec8b7966db) } + +var fileDescriptor_3c556aec8b7966db = []byte{ + // 351 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0x29, 0x4e, 0x2d, 0x2a, 0x4b, + 0x2d, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xc8, + 0x4c, 0x4a, 0xd6, 0x03, 0x29, 0xd1, 0x43, 0x56, 0xa2, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, + 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x4b, 0x69, 0xe3, 0x34, 0x32, 0x39, 0xbf, 0x34, + 0xaf, 0x24, 0xb5, 0xa8, 0x20, 0xb1, 0xa8, 0xa4, 0x12, 0xaa, 0x58, 0x3c, 0x39, 0xbf, 0x38, 0x37, + 0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x22, 0xb7, 0x38, 0x1d, 0x22, 0xa1, 0xb4, 0x89, 0x91, + 0x4b, 0xcc, 0xb7, 0x38, 0x3d, 0xa0, 0x28, 0xbf, 0x2c, 0x33, 0x25, 0xd5, 0x19, 0x49, 0xa7, 0x90, + 0x2c, 0x17, 0x57, 0x72, 0x46, 0x62, 0x5e, 0x5e, 0x6a, 0x4e, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x67, 0x10, 0x27, 0x54, 0xc4, 0x33, 0x45, 0x28, 0x80, 0x8b, 0x07, 0xd9, 0x22, 0x09, + 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x5c, 0xde, 0xd0, 0x43, 0x36, 0xdc, 0x89, 0xe5, + 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x14, 0x13, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, + 0x8b, 0x24, 0x98, 0xc1, 0x96, 0x41, 0x79, 0x56, 0xfc, 0x1d, 0x0b, 0xe4, 0x19, 0x9a, 0x9e, 0x6f, + 0xd0, 0x82, 0x0a, 0x28, 0x29, 0x70, 0xc9, 0x61, 0x77, 0x73, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, + 0x71, 0xaa, 0xd1, 0x04, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x46, 0x46, 0x2e, 0x61, 0x6c, + 0x7e, 0x33, 0xc0, 0xed, 0x4c, 0xec, 0x26, 0x4b, 0x59, 0x90, 0xaa, 0x03, 0xe6, 0x16, 0x29, 0xd6, + 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0xc2, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, + 0x21, 0xca, 0x26, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x4f, + 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0x96, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, + 0xc5, 0xc8, 0x31, 0xad, 0x0b, 0x8d, 0xea, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x44, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, 0x6d, 0x15, 0x38, 0x63, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) ProvideCounterparty(ctx context.Context, in *MsgProvideCounterparty, opts ...grpc.CallOption) (*MsgProvideCounterpartyResponse, error) { + out := new(MsgProvideCounterpartyResponse) + err := c.cc.Invoke(ctx, "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + ProvideCounterparty(context.Context, *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) ProvideCounterparty(ctx context.Context, req *MsgProvideCounterparty) (*MsgProvideCounterpartyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProvideCounterparty not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_ProvideCounterparty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgProvideCounterparty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ProvideCounterparty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.packetserver.v1.Msg/ProvideCounterparty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ProvideCounterparty(ctx, req.(*MsgProvideCounterparty)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.packetserver.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ProvideCounterparty", + Handler: _Msg_ProvideCounterparty_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/packetserver/v1/tx.proto", +} + +func (m *MsgProvideCounterparty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgProvideCounterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + 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)) + } + i-- + dAtA[i] = 0x12 + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgProvideCounterpartyResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgProvideCounterpartyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProvideCounterpartyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgProvideCounterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgProvideCounterpartyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgProvideCounterparty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgProvideCounterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgProvideCounterpartyResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProvideCounterpartyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index 270096bc88d..28b008ce3f6 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -7,6 +7,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ) // RegisterInterfaces registers ibc types against interfaces using the global InterfaceRegistry. @@ -15,5 +16,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { clienttypes.RegisterInterfaces(registry) connectiontypes.RegisterInterfaces(registry) channeltypes.RegisterInterfaces(registry) + packetservertypes.RegisterInterfaces(registry) commitmenttypes.RegisterInterfaces(registry) } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 5f09c0a47cc..583cb82e709 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -418,7 +418,7 @@ func NewSimApp( ) // setup packet server keeper for Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) govConfig := govtypes.DefaultConfig() /* diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index a6d5530c369..d2ff2a2801c 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -6,7 +6,6 @@ option go_package = "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -import "ibc/core/commitment/v2/commitment.proto"; // IdentifiedClientState defines a client state with an additional client // identifier field. @@ -35,14 +34,6 @@ message ClientConsensusStates { repeated ConsensusStateWithHeight consensus_states = 2 [(gogoproto.nullable) = false]; } -// Counterparty defines the counterparty for a light client to implement IBC eureka protocol -message Counterparty { - // the client identifier of the counterparty chain - string client_id = 1; - // the merkle path that all ICS24 paths will be stored under - ibc.core.commitment.v2.MerklePath merkle_path_prefix = 2 [(gogoproto.nullable) = false]; -} - // Height is a monotonically increasing data type // that can be compared against another Height for the purposes of updating and // freezing clients diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto index 7bf5e4f70de..3583c276daf 100644 --- a/proto/ibc/core/client/v1/query.proto +++ b/proto/ibc/core/client/v1/query.proto @@ -255,6 +255,6 @@ message QueryClientRequest { // QueryClientRequest is the response type for the Query/Client RPC method message QueryClientResponse { - string creator = 1; - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + string creator = 1; + // ibc.core.packetserver.v1.Counterparty counterparty = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 357c5a7d0a1..1e9e4f47ada 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -29,9 +29,6 @@ service Msg { // RecoverClient defines a rpc handler method for MsgRecoverClient. rpc RecoverClient(MsgRecoverClient) returns (MsgRecoverClientResponse); - // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. - rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); - // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. rpc IBCSoftwareUpgrade(MsgIBCSoftwareUpgrade) returns (MsgIBCSoftwareUpgradeResponse); @@ -143,25 +140,6 @@ message MsgRecoverClient { // MsgRecoverClientResponse defines the Msg/RecoverClient response type. message MsgRecoverClientResponse {} -// MsgProvideCounterparty defines the message used to provide the counterparty client -// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty -// client identifier was not provided in the initial MsgCreateClient message. -message MsgProvideCounterparty { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1; - // counterparty client - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; - // signer address - string signer = 3; -} - -// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. -message MsgProvideCounterpartyResponse {} - // MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of an IBC client using a v1 governance proposal message MsgIBCSoftwareUpgrade { option (cosmos.msg.v1.signer) = "signer"; diff --git a/proto/ibc/core/packetserver/v1/counterparty.proto b/proto/ibc/core/packetserver/v1/counterparty.proto new file mode 100644 index 00000000000..f85bd2d4728 --- /dev/null +++ b/proto/ibc/core/packetserver/v1/counterparty.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package ibc.core.packetserver.v1; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/commitment/v2/commitment.proto"; + +// Counterparty defines the counterparty for a light client to implement IBC eureka protocol +// this value is stored under our side's channel ID. which we will use to write all packet messages +// sent to counterparty +message Counterparty { + // the client identifier of the counterparty chain + // client id of the counterparty stored on our chain + string client_id = 1; + // the counterparty channel identifier that must be used by the packet + string counterparty_channel = 2; + // the key path used to store packet flow messages that the counterparty + // will use to send to us. We will append the channelID and sequence in order to create the final path. + ibc.core.commitment.v2.MerklePath merkle_path_prefix = 3 [(gogoproto.nullable) = false]; +} diff --git a/proto/ibc/core/packetserver/v1/tx.proto b/proto/ibc/core/packetserver/v1/tx.proto new file mode 100644 index 00000000000..99507067561 --- /dev/null +++ b/proto/ibc/core/packetserver/v1/tx.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package ibc.core.packetserver.v1; + +option go_package = "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/packetserver/v1/counterparty.proto"; +import "cosmos/msg/v1/msg.proto"; + +// Msg defines the ibc/packetserver Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // ProvideCounterparty defines a rpc handler method for MsgProvideCounterparty. + rpc ProvideCounterparty(MsgProvideCounterparty) returns (MsgProvideCounterpartyResponse); +} + +// MsgProvideCounterparty defines the message used to provide the counterparty client +// identifier. Can only be invoked one time by the signer of MsgCreateClient if the counterparty +// client identifier was not provided in the initial MsgCreateClient message. +message MsgProvideCounterparty { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // unique identifier we will use to write all packet messages sent to counterparty + string channel_id = 1; + // counterparty client + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + // signer address + string signer = 3; +} + +// MsgProvideCounterpartyResponse defines the Msg/ProvideCounterparty response type. +message MsgProvideCounterpartyResponse {} diff --git a/testing/endpoint.go b/testing/endpoint.go index 4ce12cb675f..9a398b8e3ff 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -19,6 +19,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" "github.com/cosmos/ibc-go/v9/modules/core/exported" + packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" ) @@ -179,7 +180,7 @@ func (endpoint *Endpoint) FreezeClient() { func (endpoint *Endpoint) ProvideCounterparty() (err error) { merklePath := commitmenttypes.NewMerklePath([]byte("ibc"), []byte("")) - msg := clienttypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) + msg := packetservertypes.NewMsgProvideCounterparty(endpoint.Chain.SenderAccount.GetAddress().String(), endpoint.ClientID, endpoint.Counterparty.ClientID, merklePath) // setup counterparty _, err = endpoint.Chain.SendMsgs(msg) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 87c5f1c7b43..cb5a7d3745e 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -373,7 +373,7 @@ func NewSimApp( ) // Setup packet server to call on Eureka tests - app.PacketServer = packetserverkeeper.NewKeeper(appCodec, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) + app.PacketServer = packetserverkeeper.NewKeeper(appCodec, keys[ibcexported.StoreKey], app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ClientKeeper) govConfig := govtypes.DefaultConfig() /*