From 54571ea3737fa5004061e71a1f5ea89c60dc1e5f Mon Sep 17 00:00:00 2001 From: bznein Date: Mon, 2 Sep 2024 16:16:04 +0100 Subject: [PATCH 1/4] remove unneeded methods --- modules/core/04-channel/keeper/keeper.go | 11 ----------- modules/core/24-host/channel_keys.go | 6 ------ testing/chain.go | 17 ++--------------- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 17e41d72618..40f56aac65e 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -17,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" 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" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" @@ -553,16 +552,6 @@ func (k *Keeper) GetChannelConnection(ctx context.Context, portID, channelID str return connectionID, connection, nil } -// LookupModuleByChannel will return the IBCModule along with the capability associated with a given channel defined by its portID and channelID -func (k *Keeper) LookupModuleByChannel(ctx context.Context, portID, channelID string) (string, *capabilitytypes.Capability, error) { - modules, capability, err := k.scopedKeeper.LookupModules(ctx, host.ChannelCapabilityPath(portID, channelID)) - if err != nil { - return "", nil, err - } - - return porttypes.GetModuleOwner(modules), capability, nil -} - // GetUpgradeErrorReceipt returns the upgrade error receipt for the provided port and channel identifiers. func (k *Keeper) GetUpgradeErrorReceipt(ctx context.Context, portID, channelID string) (types.ErrorReceipt, bool) { store := k.storeService.OpenKVStore(ctx) diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index a6d3cee060c..3d5dbb524b0 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -20,12 +20,6 @@ func ChannelKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID))) } -// ChannelCapabilityPath defines the path under which capability keys associated -// with a channel are stored -func ChannelCapabilityPath(portID, channelID string) string { - return fmt.Sprintf("%s/%s", KeyChannelCapabilityPrefix, channelPath(portID, channelID)) -} - // ChannelUpgradeErrorKey returns the store key for a particular channelEnd used to stor the ErrorReceipt in the case that a chain does not accept the proposed upgrade func ChannelUpgradeErrorKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID))) diff --git a/testing/chain.go b/testing/chain.go index cda9fe83b4c..fc4f1ef4b46 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -594,26 +594,13 @@ func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capabi // if it does not already exist. This function will fail testing on any resulting error. The // scoped keeper passed in will claim the new capability. func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string) { - capName := host.ChannelCapabilityPath(portID, channelID) - // check if the portId is already binded, if not bind it - _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName) - if !ok { - capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) - require.NoError(chain.TB, err) - err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, capName) - require.NoError(chain.TB, err) - } - - chain.NextBlock() + // TODO delete } // GetChannelCapability returns the channel capability for the given portID and channelID. // The capability must exist, otherwise testing will fail. func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { - capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) - require.True(chain.TB, ok) - - return capability + // TODO delete } // GetClientLatestHeight returns the latest height for the client state with the given client identifier. From 3883da1f2e603e7c52dc61b8d5a2bf57cc6186a3 Mon Sep 17 00:00:00 2001 From: bznein Date: Mon, 2 Sep 2024 16:29:19 +0100 Subject: [PATCH 2/4] Remvoed capabilites, need to remove tests --- .../controller/keeper/account_test.go | 10 ----- .../controller/keeper/msg_server_test.go | 10 ----- .../host/keeper/genesis.go | 12 ----- .../host/keeper/keeper.go | 18 -------- modules/apps/transfer/keeper/genesis.go | 13 ------ modules/apps/transfer/keeper/keeper.go | 18 -------- testing/chain.go | 44 ------------------- 7 files changed, 125 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go index 13196d7314b..c6f507428ed 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go @@ -3,7 +3,6 @@ package keeper_test import ( icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -23,15 +22,6 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() { { "success", func() {}, nil, }, - { - "port is already bound for owner but capability is claimed by another module", - func() { - capability := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), TestPortID) - err := suite.chainA.GetSimApp().TransferKeeper.ClaimCapability(suite.chainA.GetContext(), capability, host.PortPath(TestPortID)) - suite.Require().NoError(err) - }, - icatypes.ErrPortAlreadyBound, - }, { "fails to generate port-id", func() { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go index d81abf18c00..6f60a25f88b 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go @@ -13,7 +13,6 @@ import ( icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/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" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -64,15 +63,6 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() { }, icatypes.ErrInvalidAccountAddress, }, - { - "port is already bound for owner but capability is claimed by another module", - func() { - capability := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), TestPortID) - err := suite.chainA.GetSimApp().TransferKeeper.ClaimCapability(suite.chainA.GetContext(), capability, host.PortPath(TestPortID)) - suite.Require().NoError(err) - }, - icatypes.ErrPortAlreadyBound, - }, } for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis.go b/modules/apps/27-interchain-accounts/host/keeper/genesis.go index 9fc935907a4..4b3dafa3d49 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -6,24 +6,12 @@ import ( genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) // InitGenesis initializes the interchain accounts host application state from a provided genesis state func InitGenesis(ctx context.Context, keeper Keeper, state genesistypes.HostGenesisState) { keeper.setPort(ctx, state.Port) - // generate port capability if it does not already exist - if !keeper.hasCapability(ctx, state.Port) { - // use the port keeper to generate a new capability - capability := keeper.portKeeper.BindPort(ctx, state.Port) - - // use the host scoped keeper to claim the port capability - if err := keeper.ClaimCapability(ctx, capability, host.PortPath(state.Port)); err != nil { - panic(fmt.Errorf("could not claim port capability: %v", err)) - } - } - for _, ch := range state.ActiveChannels { keeper.SetActiveChannelID(ctx, ch.ConnectionId, ch.PortId, ch.ChannelId) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 7a3169c0b1d..479f1a12cf2 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -22,13 +22,11 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types" "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/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/exported" ) @@ -124,22 +122,6 @@ func (k Keeper) setPort(ctx context.Context, portID string) { } } -// hasCapability checks if the interchain account host module owns the port capability for the desired port -func (k Keeper) hasCapability(ctx context.Context, portID string) bool { - _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) - return ok -} - -// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function -func (k Keeper) AuthenticateCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) bool { - return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) -} - -// ClaimCapability wraps the scopedKeeper's ClaimCapability function -func (k Keeper) ClaimCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) error { - return k.scopedKeeper.ClaimCapability(ctx, cap, name) -} - // GetAppVersion calls the ICS4Wrapper GetAppVersion function. func (k Keeper) GetAppVersion(ctx context.Context, portID, channelID string) (string, bool) { return k.ics4Wrapper.GetAppVersion(ctx, portID, channelID) diff --git a/modules/apps/transfer/keeper/genesis.go b/modules/apps/transfer/keeper/genesis.go index 4239bf3afd8..d9653ce3c6c 100644 --- a/modules/apps/transfer/keeper/genesis.go +++ b/modules/apps/transfer/keeper/genesis.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -17,17 +15,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { k.setDenomMetadata(ctx, denom) } - // Only try to bind to port if it is not already bound, since we may already own - // port capability from capability InitGenesis - if !k.hasCapability(ctx, state.PortId) { - // transfer module binds to the transfer port on InitChain - // and claims the returned capability - err := k.BindPort(ctx, state.PortId) - if err != nil { - panic(fmt.Errorf("could not claim port capability: %v", err)) - } - } - k.SetParams(ctx, state.Params) // Every denom will have only one total escrow amount, since any diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 6e21c87637f..00c6beb1d74 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -104,19 +104,6 @@ func (Keeper) Logger(ctx context.Context) log.Logger { return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"-"+types.ModuleName) } -// hasCapability checks if the transfer module owns the port capability for the desired port -func (k Keeper) hasCapability(ctx context.Context, portID string) bool { - _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) - return ok -} - -// BindPort defines a wrapper function for the port Keeper's function in -// order to expose it to module's InitGenesis function -func (k Keeper) BindPort(ctx context.Context, portID string) error { - capability := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, capability, host.PortPath(portID)) -} - // GetPort returns the portID for the transfer module. Used in ExportGenesis func (k Keeper) GetPort(ctx context.Context) string { store := k.storeService.OpenKVStore(ctx) @@ -319,11 +306,6 @@ func (k Keeper) IterateTokensInEscrow(ctx context.Context, storeprefix []byte, c } } -// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function -func (k Keeper) AuthenticateCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) bool { - return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) -} - // ClaimCapability allows the transfer module that can claim a capability that IBC module // passes to it func (k Keeper) ClaimCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) error { diff --git a/testing/chain.go b/testing/chain.go index fc4f1ef4b46..8a8dbabba0f 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -27,8 +27,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" cmtversion "github.com/cometbft/cometbft/version" - capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/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" @@ -561,48 +559,6 @@ func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) cmttypes.B } } -// CreatePortCapability binds and claims a capability for the given portID if it does not -// already exist. This function will fail testing on any resulting error. -// NOTE: only creation of a capability for a transfer or mock port is supported -// Other applications must bind to the port in InitGenesis or modify this code. -func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string) { - // check if the portId is already binded, if not bind it - _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) - if !ok { - // create capability using the IBC capability keeper - capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) - require.NoError(chain.TB, err) - - // claim capability using the scopedKeeper - err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, host.PortPath(portID)) - require.NoError(chain.TB, err) - } - - chain.NextBlock() -} - -// GetPortCapability returns the port capability for the given portID. The capability must -// exist, otherwise testing will fail. -func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability { - capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) - require.True(chain.TB, ok) - - return capability -} - -// CreateChannelCapability binds and claims a capability for the given portID and channelID -// if it does not already exist. This function will fail testing on any resulting error. The -// scoped keeper passed in will claim the new capability. -func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string) { - // TODO delete -} - -// GetChannelCapability returns the channel capability for the given portID and channelID. -// The capability must exist, otherwise testing will fail. -func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { - // TODO delete -} - // GetClientLatestHeight returns the latest height for the client state with the given client identifier. // If an invalid client identifier is provided then a zero value height will be returned and testing will fail. func (chain *TestChain) GetClientLatestHeight(clientID string) exported.Height { From c6cd79192e0f90ecaa4ad58b96fbd7109b493bc0 Mon Sep 17 00:00:00 2001 From: bznein Date: Tue, 3 Sep 2024 09:25:11 +0100 Subject: [PATCH 3/4] fix tests --- .../host/ibc_module_test.go | 49 ++++--------------- .../host/keeper/genesis_test.go | 5 -- modules/apps/transfer/ibc_module_test.go | 37 +++----------- .../transfer/keeper/relay_forwarding_test.go | 6 +-- 4 files changed, 19 insertions(+), 78 deletions(-) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 68dba2a2623..e2d08f7e714 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -204,10 +204,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { // ensure channel on chainB is set in state suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, *channel) - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) version, err := cbs.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -312,10 +309,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { tc.malleate() - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) err = cbs.OnChanOpenConfirm(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -341,10 +335,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) err = cbs.OnChanCloseInit( @@ -382,10 +373,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { suite.Require().NoError(err) tc.malleate() // malleate mutates test data - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) err = cbs.OnChanCloseConfirm( @@ -493,10 +482,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { tc.malleate() - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) ctx := suite.chainB.GetContext() @@ -567,10 +553,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { tc.malleate() // malleate mutates test data - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -622,10 +605,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { tc.malleate() // malleate mutates test data - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -663,10 +643,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { suite.Require().NoError(err) // call application callback directly - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -724,10 +701,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { tc.malleate() // malleate mutates test data - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -764,10 +738,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { suite.Require().NoError(err) // call application callback directly - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID) - suite.Require().NoError(err) - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go index 101ea1eb8c8..079e2aa7903 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -46,10 +45,6 @@ func (suite *KeeperTestSuite) TestInitGenesis() { store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(types.StoreKey)) suite.Require().True(store.Has(icatypes.KeyPort(icatypes.HostPortID))) - - capability, found := suite.chainA.GetSimApp().ScopedICAHostKeeper.GetCapability(suite.chainA.GetContext(), host.PortPath(icatypes.HostPortID)) - suite.Require().True(found) - suite.Require().NotNil(capability) } func (suite *KeeperTestSuite) TestGenesisParams() { diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index fb35ea90c78..6ff8ab21fee 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -178,10 +178,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { } counterpartyVersion = types.V2 - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) - suite.Require().NoError(err) - - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(ibctesting.TransferPort) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel @@ -232,15 +229,12 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { path.EndpointA.ChannelID = ibctesting.FirstChannelID counterpartyVersion = types.V2 - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) - suite.Require().NoError(err) - - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(ibctesting.TransferPort) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel - err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointA.Counterparty.ChannelID, counterpartyVersion) + err := cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointA.Counterparty.ChannelID, counterpartyVersion) expPass := tc.expError == nil if expPass { @@ -372,10 +366,7 @@ func (suite *TransferTestSuite) TestOnRecvPacket() { packet = channeltypes.NewPacket(packetData.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.ZeroHeight(), suite.chainA.GetTimeoutTimestamp()) ctx := suite.chainB.GetContext() - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(ctx, ibctesting.TransferPort) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(ibctesting.TransferPort) suite.Require().True(ok) tc.malleate() // change fields in packet @@ -439,10 +430,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { "already timed-out packet", sdk.NewCoins(ibctesting.TestCoin), func() { - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) - suite.Require().NoError(err) - - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(ibctesting.TransferPort) suite.Require().True(ok) suite.Require().NoError(cbs.OnTimeoutPacket(suite.chainA.GetContext(), path.EndpointA.GetChannel().Version, packet, suite.chainA.SenderAccount.GetAddress())) @@ -477,10 +465,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { packet, err = ibctesting.ParsePacketFromEvents(res.Events) suite.Require().NoError(err) - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) - suite.Require().NoError(err) - - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(ibctesting.TransferPort) suite.Require().True(ok) tc.malleate() // change fields in packet @@ -627,10 +612,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeTry() { tc.malleate() - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), types.PortID) - suite.Require().NoError(err) - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(types.PortID) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -698,10 +680,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeAck() { tc.malleate() - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), types.PortID) - suite.Require().NoError(err) - - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(types.PortID) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) diff --git a/modules/apps/transfer/keeper/relay_forwarding_test.go b/modules/apps/transfer/keeper/relay_forwarding_test.go index 452cea3f597..183a077db1e 100644 --- a/modules/apps/transfer/keeper/relay_forwarding_test.go +++ b/modules/apps/transfer/keeper/relay_forwarding_test.go @@ -1105,11 +1105,7 @@ func (suite *ForwardingTestSuite) TestOnTimeoutPacketForwarding() { packet.TimeoutHeight, packet.TimeoutTimestamp) - // retrieve module callbacks - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), pathBtoC.EndpointA.ChannelConfig.PortID) - suite.Require().NoError(err) - - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(pathBtoC.EndpointA.ChannelConfig.PortID) suite.Require().True(ok) // Trigger OnTimeoutPacket for chainB From 5caf10bd0a88b7caeae94d560e00b8153e8a84b3 Mon Sep 17 00:00:00 2001 From: bznein Date: Wed, 4 Sep 2024 11:52:11 +0100 Subject: [PATCH 4/4] Changelod and further removal --- CHANGELOG.md | 6 +++++- modules/apps/transfer/keeper/keeper.go | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d94f9904301..10e8f282e04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (core, apps) [\#7213](https://github.com/cosmos/ibc-go/pull/7213) Remove capabilities from `SendPacket`. * (core, apps) [\#7213](https://github.com/cosmos/ibc-go/pull/7225) Remove capabilities from `WriteAcknowledgement`. -* (core, apps) [\#7232](https://github.com/cosmos/ibc-go/pull/7232) Remove capabilities from channel handshake methods. +* (core, apps) [\#7232](https://github.com/cosmos/ibc-go/pull/7232) Remove capabilities from channel handshake methods. TODO list all changes +* (core/04-channel) [\#7239](https://github.com/cosmos/ibc-go/pull/7239) Removed function `LookupModuleByChannel` +* (core/24-host) [\#7239](https://github.com/cosmos/ibc-go/pull/7239) Removed function `ChannelCapabilityPath` +* (apps/27-interchain-accounts) [\#7239](https://github.com/cosmos/ibc-go/pull/7239) The following functions have been removed: `AuthenticateCapability`, `ClaimCapability` +* (apps/transfer) [\#7239](https://github.com/cosmos/ibc-go/pull/7239) The following functions have been removed: `BindPort`, `AuthenticateCapability`, `ClaimCapability` ### State Machine Breaking diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 00c6beb1d74..879a69b5f9a 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -19,7 +19,6 @@ import ( cmtbytes "github.com/cometbft/cometbft/libs/bytes" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" @@ -306,12 +305,6 @@ func (k Keeper) IterateTokensInEscrow(ctx context.Context, storeprefix []byte, c } } -// ClaimCapability allows the transfer module that can claim a capability that IBC module -// passes to it -func (k Keeper) ClaimCapability(ctx context.Context, cap *capabilitytypes.Capability, name string) error { - return k.scopedKeeper.ClaimCapability(ctx, cap, name) -} - // setForwardedPacket sets the forwarded packet in the store. func (k Keeper) setForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64, packet channeltypes.Packet) { store := k.storeService.OpenKVStore(ctx)