From 1deee4e1188d38e496d16e3482b5c4d813ec971b Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 10 Apr 2024 13:08:29 +0100 Subject: [PATCH 1/9] Replace Router with PortKeeper in IBCKeeper. --- modules/core/05-port/keeper/keeper.go | 5 +++++ modules/core/keeper/keeper.go | 1 - modules/core/keeper/msg_server.go | 30 +++++++++++++-------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index 68e89ecac69..6ff33fd503d 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -81,3 +81,8 @@ func (k Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *cap return types.GetModuleOwner(modules), capability, nil } + +// GetRoute() returns a IBCModule for a given module. +func (k Keeper) GetRoute(module string) (types.IBCModule, bool) { + return k.Router.GetRoute(module) +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 2c5ffcee2b7..cc9bd6d2fd7 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -33,7 +33,6 @@ type Keeper struct { ConnectionKeeper connectionkeeper.Keeper ChannelKeeper channelkeeper.Keeper PortKeeper *portkeeper.Keeper - Router *porttypes.Router authority string } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b213a35b85e..f8ad0efb7b6 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -214,7 +214,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan } // Retrieve application callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel open init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -262,7 +262,7 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann } // Retrieve application callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel open try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -309,7 +309,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann } // Retrieve application callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel open ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -351,7 +351,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC } // Retrieve application callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel open confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -389,7 +389,7 @@ func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCha } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -423,7 +423,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -463,7 +463,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -544,7 +544,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -616,7 +616,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -691,7 +691,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn } // Retrieve callbacks from router - cbs, ok := k.Router.GetRoute(module) + cbs, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -753,7 +753,7 @@ func (k Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgC return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.Router.GetRoute(module) + app, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -801,7 +801,7 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.Router.GetRoute(module) + app, ok := k.PortKeeper.GetRoute(module) if !ok { ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -862,7 +862,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.Router.GetRoute(module) + app, ok := k.PortKeeper.GetRoute(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) @@ -928,7 +928,7 @@ func (k Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.M return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.Router.GetRoute(module) + app, ok := k.PortKeeper.GetRoute(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) @@ -989,7 +989,7 @@ func (k Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgC return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.Router.GetRoute(module) + app, ok := k.PortKeeper.GetRoute(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) From 25d78455b173fcbe4d91d8d40de28bfb51e4e736 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 10 Apr 2024 14:43:14 +0100 Subject: [PATCH 2/9] Major refactoring of tests. --- .../controller/ibc_middleware_test.go | 28 +++++------ .../host/ibc_module_test.go | 20 ++++---- modules/apps/29-fee/ibc_middleware_test.go | 24 +++++----- modules/apps/callbacks/ibc_middleware_test.go | 18 +++---- modules/apps/transfer/ibc_module_test.go | 8 ++-- modules/core/05-port/keeper/keeper_test.go | 47 +++++++++++++++++++ modules/core/keeper/keeper.go | 5 +- 7 files changed, 98 insertions(+), 52 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 2bb6b6e60b5..7bf6f1afe94 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -226,7 +226,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) if isNilApp { @@ -282,7 +282,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { 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().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -370,7 +370,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelID, path.EndpointB.ChannelConfig.Version) @@ -429,7 +429,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanOpenConfirm( @@ -449,7 +449,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanCloseInit( @@ -497,7 +497,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) if isNilApp { @@ -544,7 +544,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -655,7 +655,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) if isNilApp { @@ -750,7 +750,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) if isNilApp { @@ -843,7 +843,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -886,7 +886,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -969,7 +969,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -1050,7 +1050,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeOpen() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -1152,7 +1152,7 @@ func (suite *InterchainAccountsTestSuite) TestGetAppVersion() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) controllerStack, ok := cbs.(porttypes.ICS4Wrapper) 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 e8f2d859b2f..01b43da1bbf 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -211,7 +211,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { chanCap, err := suite.chainB.App.GetScopedIBCKeeper().NewCapability(suite.chainB.GetContext(), host.ChannelCapabilityPath(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) version, err := cbs.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -315,7 +315,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { 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().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanOpenConfirm(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -340,7 +340,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { 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().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanCloseInit( @@ -379,7 +379,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { 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().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanCloseConfirm( @@ -488,7 +488,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { 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().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) ctx := suite.chainB.GetContext() @@ -560,7 +560,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { 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().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -613,7 +613,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { 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().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -650,7 +650,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { 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().Router.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -709,7 +709,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { 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().Router.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -745,7 +745,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { 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().Router.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 22760c243b0..bc612306253 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -109,7 +109,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -212,7 +212,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) _, err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -298,7 +298,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanOpenAck(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, suite.path.EndpointA.Counterparty.ChannelID, tc.cpVersion) @@ -385,7 +385,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanCloseInit(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) @@ -475,7 +475,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnChanCloseConfirm(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) @@ -553,7 +553,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) @@ -832,7 +832,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, ack, relayerAddr) @@ -1043,7 +1043,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), packet, relayerAddr) @@ -1358,7 +1358,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -1468,7 +1468,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeOpen() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -1544,7 +1544,7 @@ func (suite *FeeTestSuite) TestGetAppVersion() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) feeModule, ok := cbs.(porttypes.ICS4Wrapper) @@ -1567,7 +1567,7 @@ func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterface() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) feeModule, ok := cbs.(porttypes.PacketDataUnmarshaler) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index ac2253f9e26..21999a8a599 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -322,7 +322,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) s.Require().True(ok) onAcknowledgementPacket := func() error { @@ -485,7 +485,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) s.Require().True(ok) onTimeoutPacket := func() error { @@ -645,7 +645,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainB.App.GetIBCKeeper().Router.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) s.Require().True(ok) onRecvPacket := func() ibcexported.Acknowledgement { @@ -913,7 +913,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() { module, _, err := s.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(s.chainA.GetContext(), ibctesting.MockFeePort) s.Require().NoError(err) - cbs, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) s.Require().True(ok) mockCallbackStack, ok := cbs.(ibccallbacks.IBCMiddleware) s.Require().True(ok) @@ -944,7 +944,7 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketData() { // We will pass the function call down the transfer stack to the transfer module // transfer stack UnmarshalPacketData call order: callbacks -> fee -> transfer - transferStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) s.Require().True(ok) unmarshalerStack, ok := transferStack.(types.CallbacksCompatibleModule) @@ -970,7 +970,7 @@ func (s *CallbacksTestSuite) TestGetAppVersion() { // Obtain an IBC stack for testing. The function call will use the top of the stack which calls // directly to the channel keeper. Calling from a further down module in the stack is not necessary // for this test. - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.ICS4Wrapper) @@ -985,7 +985,7 @@ func (s *CallbacksTestSuite) TestOnChanCloseInit() { // We will pass the function call down the icacontroller stack to the icacontroller module // icacontroller stack OnChanCloseInit call order: callbacks -> fee -> icacontroller - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.Middleware) @@ -1000,7 +1000,7 @@ func (s *CallbacksTestSuite) TestOnChanCloseConfirm() { // We will pass the function call down the icacontroller stack to the icacontroller module // icacontroller stack OnChanCloseConfirm call order: callbacks -> fee -> icacontroller - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.Middleware) @@ -1015,7 +1015,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacketAsyncAck() { module, _, err := s.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(s.chainA.GetContext(), ibctesting.MockFeePort) s.Require().NoError(err) - cbs, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) s.Require().True(ok) mockFeeCallbackStack, ok := cbs.(porttypes.Middleware) s.Require().True(ok) diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index ad4b0be3861..11f33015984 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -183,7 +183,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel @@ -235,7 +235,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel @@ -379,7 +379,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeTry() { module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), types.PortID) suite.Require().NoError(err) - app, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -450,7 +450,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), types.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index df2051644f9..85a6bef5899 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -1,14 +1,23 @@ package keeper_test import ( + "fmt" "testing" "github.com/stretchr/testify/require" testifysuite "github.com/stretchr/testify/suite" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/05-port/keeper" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v8/testing/simapp" ) @@ -74,3 +83,41 @@ func (suite *KeeperTestSuite) TestAuthenticate() { auth = suite.keeper.Authenticate(suite.ctx, capKey2, validPort) require.False(suite.T(), auth, "invalid authentication for different capKey failed") } + +func (suite *KeeperTestSuite) TestGetRoute() { + testCases := []struct { + msg string + module string + expPass bool + }{ + { + "success", + fmt.Sprintf("%s-%d", exported.Tendermint, 0), + true, + }, + { + "failure - route does not exist", + "invalid-route", + false, + }, + } + for _, tc := range testCases { + suite.Run(tc.msg, func() { + cdc := suite.chainA.App.AppCodec() + storeKey := storetypes.NewKVStoreKey("store-key") + tmLightClientModule := ibctm.NewLightClientModule(cdc, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + router := clienttypes.NewRouter(storeKey) + router.AddRoute(exported.Tendermint, &tmLightClientModule) + + route, ok := suite.keeper.GetRoute(tc.module) + if tc.expPass { + suite.Require().True(ok) + suite.Require().NotNil(route) + suite.Require().IsType(&ibctm.LightClientModule{}, route) + } else { + suite.Require().False(ok) + suite.Require().Nil(route) + } + }) + } +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index cc9bd6d2fd7..3ef7c5876ec 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -92,13 +92,12 @@ func (k *Keeper) SetConsensusHost(consensusHost clienttypes.ConsensusHost) { // SetRouter sets the Router in IBC Keeper and seals it. The method panics if // there is an existing router that's already sealed. func (k *Keeper) SetRouter(rtr *porttypes.Router) { - if k.Router != nil && k.Router.Sealed() { + if k.PortKeeper.Router != nil && k.PortKeeper.Router.Sealed() { panic(errors.New("cannot reset a sealed router")) } k.PortKeeper.Router = rtr - k.Router = rtr - k.Router.Seal() + k.PortKeeper.Router.Seal() } // GetAuthority returns the ibc module's authority. From d08cfe385ea7ae6014ca050c941b44d5a532cce4 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 10 Apr 2024 14:44:22 +0100 Subject: [PATCH 3/9] Remove non-working test code. --- modules/core/05-port/keeper/keeper_test.go | 47 ---------------------- 1 file changed, 47 deletions(-) diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index 85a6bef5899..df2051644f9 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -1,23 +1,14 @@ package keeper_test import ( - "fmt" "testing" "github.com/stretchr/testify/require" testifysuite "github.com/stretchr/testify/suite" - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/05-port/keeper" - "github.com/cosmos/ibc-go/v8/modules/core/exported" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v8/testing/simapp" ) @@ -83,41 +74,3 @@ func (suite *KeeperTestSuite) TestAuthenticate() { auth = suite.keeper.Authenticate(suite.ctx, capKey2, validPort) require.False(suite.T(), auth, "invalid authentication for different capKey failed") } - -func (suite *KeeperTestSuite) TestGetRoute() { - testCases := []struct { - msg string - module string - expPass bool - }{ - { - "success", - fmt.Sprintf("%s-%d", exported.Tendermint, 0), - true, - }, - { - "failure - route does not exist", - "invalid-route", - false, - }, - } - for _, tc := range testCases { - suite.Run(tc.msg, func() { - cdc := suite.chainA.App.AppCodec() - storeKey := storetypes.NewKVStoreKey("store-key") - tmLightClientModule := ibctm.NewLightClientModule(cdc, authtypes.NewModuleAddress(govtypes.ModuleName).String()) - router := clienttypes.NewRouter(storeKey) - router.AddRoute(exported.Tendermint, &tmLightClientModule) - - route, ok := suite.keeper.GetRoute(tc.module) - if tc.expPass { - suite.Require().True(ok) - suite.Require().NotNil(route) - suite.Require().IsType(&ibctm.LightClientModule{}, route) - } else { - suite.Require().False(ok) - suite.Require().Nil(route) - } - }) - } -} From 3fdfbf0963e3bb5e98486dd0e959e12e9b39e4d7 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 10 Apr 2024 16:12:38 +0100 Subject: [PATCH 4/9] Update modules/core/05-port/keeper/keeper.go Co-authored-by: Cian Hatton --- modules/core/05-port/keeper/keeper.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index 015bca02479..14d9616b372 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -82,7 +82,8 @@ func (k *Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *ca return types.GetModuleOwner(modules), capability, nil } -// GetRoute() returns a IBCModule for a given module. +// GetRoute returns a IBCModule for a given module, and a boolean indicating +// whether or not the route is present. func (k Keeper) GetRoute(module string) (types.IBCModule, bool) { return k.Router.GetRoute(module) } From 202421252755a20f11f3903f2daaaa9be59afb1b Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Wed, 10 Apr 2024 16:13:36 +0100 Subject: [PATCH 5/9] Make GetRoute a method of *Keeper --- modules/core/05-port/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index 14d9616b372..d690e5d8f72 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -84,6 +84,6 @@ func (k *Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *ca // GetRoute returns a IBCModule for a given module, and a boolean indicating // whether or not the route is present. -func (k Keeper) GetRoute(module string) (types.IBCModule, bool) { +func (k *Keeper) GetRoute(module string) (types.IBCModule, bool) { return k.Router.GetRoute(module) } From 08656bb19651fcf2fade9c303728d5506c14e781 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 10 Apr 2024 23:14:37 +0200 Subject: [PATCH 6/9] Update 13-v8-to-v9.md --- docs/docs/05-migrations/13-v8-to-v9.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 98425383303..b8d856601a6 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -47,6 +47,10 @@ Please use the new functions `path.Setup`, `path.SetupClients`, `path.SetupConne - Functions `ConstructUpdateTMClientHeader` and `ConstructUpdateTMClientHeaderWithTrustedHeight` of `TestChain` type have been replaced with `IBCClientHeader`. This function will construct a `07-tendermint` header to update the light client on the counterparty chain. The trusted height must be passed in as a non-zero height. - `GetValsAtHeight` has been renamed to `GetTrustedValidators` +### IBC core + +- `Router` field has been removed from IBC core keeper: https://github.com/cosmos/ibc-go/pull/6138 + ### ICS27 - Interchain Accounts In [#5785](https://github.com/cosmos/ibc-go/pull/5785) the list of arguments of the `NewKeeper` constructor function of the host submodule was extended with an extra argument for the gRPC query router that the submodule uses when executing a [`MsgModuleQuerySafe`](https://github.com/cosmos/ibc-go/blob/eecfa5c09a4c38a5c9f2cc2a322d2286f45911da/proto/ibc/applications/interchain_accounts/host/v1/tx.proto#L41-L51) to perform queries that are module safe: From f43ab0948d4b725a90afe931e3dd2eaab88cc40a Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 10 Apr 2024 23:18:42 +0200 Subject: [PATCH 7/9] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef1bf6ff1a..cf37396300c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (core/04-channel) [\#5991](https://github.com/cosmos/ibc-go/pull/5991) The client CLI `QueryLatestConsensusState` has been removed. * (light-clients/06-solomachine) [\#6037](https://github.com/cosmos/ibc-go/pull/6037) Remove `Initialize` function from `ClientState` and move logic to `Initialize` function of `LightClientModule`. * (core/02-client) [\#6084](https://github.com/cosmos/ibc-go/pull/6084) Removed `stakingKeeper` as an argument to `NewKeeper` and replaced with a `ConsensusHost` implementation. +* (core) [\#6138](https://github.com/cosmos/ibc-go/pull/6138) Remove `Router` reference from IBC core keeper and use instead the router on the existing `PortKeeper` reference. ### State Machine Breaking From cabc8fdd56c02d9868e9a6ba50eca3c24d1564dd Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 10 Apr 2024 23:19:19 +0200 Subject: [PATCH 8/9] Update 13-v8-to-v9.md --- docs/docs/05-migrations/13-v8-to-v9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index b8d856601a6..75a2bcfe80b 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -49,7 +49,7 @@ Please use the new functions `path.Setup`, `path.SetupClients`, `path.SetupConne ### IBC core -- `Router` field has been removed from IBC core keeper: https://github.com/cosmos/ibc-go/pull/6138 +- `Router` reference has been removed from IBC core keeper: [#6138](https://github.com/cosmos/ibc-go/pull/6138) ### ICS27 - Interchain Accounts From 06a240acb57092d03a083b923f34bab63c20bed9 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 11 Apr 2024 09:47:00 +0100 Subject: [PATCH 9/9] Change GetRoute signature. --- .../controller/ibc_middleware_test.go | 28 ++++++++--------- .../host/ibc_module_test.go | 20 ++++++------- modules/apps/29-fee/ibc_middleware_test.go | 24 +++++++-------- modules/apps/callbacks/ibc_middleware_test.go | 18 +++++------ modules/apps/transfer/ibc_module_test.go | 8 ++--- modules/core/05-port/keeper/keeper.go | 6 ++-- modules/core/keeper/msg_server.go | 30 +++++++++---------- 7 files changed, 67 insertions(+), 67 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 7bf6f1afe94..e0e6ef288f0 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -226,7 +226,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) if isNilApp { @@ -282,7 +282,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { 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.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -370,7 +370,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelID, path.EndpointB.ChannelConfig.Version) @@ -429,7 +429,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanOpenConfirm( @@ -449,7 +449,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanCloseInit( @@ -497,7 +497,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) if isNilApp { @@ -544,7 +544,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -655,7 +655,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) if isNilApp { @@ -750,7 +750,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) if isNilApp { @@ -843,7 +843,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -886,7 +886,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -969,7 +969,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -1050,7 +1050,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeOpen() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -1152,7 +1152,7 @@ func (suite *InterchainAccountsTestSuite) TestGetAppVersion() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) controllerStack, ok := cbs.(porttypes.ICS4Wrapper) 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 01b43da1bbf..98dbb2b36a0 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -211,7 +211,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { chanCap, err := suite.chainB.App.GetScopedIBCKeeper().NewCapability(suite.chainB.GetContext(), host.ChannelCapabilityPath(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) version, err := cbs.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -315,7 +315,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { 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.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanOpenConfirm(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -340,7 +340,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { 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.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanCloseInit( @@ -379,7 +379,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { 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.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanCloseConfirm( @@ -488,7 +488,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { 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.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) ctx := suite.chainB.GetContext() @@ -560,7 +560,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { 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.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -613,7 +613,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { 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.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) packet := channeltypes.NewPacket( @@ -650,7 +650,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { 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.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -709,7 +709,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { 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.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) @@ -745,7 +745,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { 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.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) suite.Require().True(ok) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index bc612306253..fc16fd900fc 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -109,7 +109,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -212,7 +212,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) _, err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, @@ -298,7 +298,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanOpenAck(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, suite.path.EndpointA.Counterparty.ChannelID, tc.cpVersion) @@ -385,7 +385,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanCloseInit(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) @@ -475,7 +475,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnChanCloseConfirm(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) @@ -553,7 +553,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) @@ -832,7 +832,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, ack, relayerAddr) @@ -1043,7 +1043,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), packet, relayerAddr) @@ -1358,7 +1358,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -1468,7 +1468,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeOpen() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -1544,7 +1544,7 @@ func (suite *FeeTestSuite) TestGetAppVersion() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) feeModule, ok := cbs.(porttypes.ICS4Wrapper) @@ -1567,7 +1567,7 @@ func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterface() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) feeModule, ok := cbs.(porttypes.PacketDataUnmarshaler) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index a74fbb8135f..d4419ffd8ec 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -322,7 +322,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) s.Require().True(ok) onAcknowledgementPacket := func() error { @@ -485,7 +485,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) s.Require().True(ok) onTimeoutPacket := func() error { @@ -645,7 +645,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { tc.malleate() // callbacks module is routed as top level middleware - transferStack, ok := s.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainB.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) s.Require().True(ok) onRecvPacket := func() ibcexported.Acknowledgement { @@ -913,7 +913,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() { module, _, err := s.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(s.chainA.GetContext(), ibctesting.MockFeePort) s.Require().NoError(err) - cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(module) s.Require().True(ok) mockCallbackStack, ok := cbs.(ibccallbacks.IBCMiddleware) s.Require().True(ok) @@ -944,7 +944,7 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketData() { // We will pass the function call down the transfer stack to the transfer module // transfer stack UnmarshalPacketData call order: callbacks -> fee -> transfer - transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(transfertypes.ModuleName) + transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) s.Require().True(ok) unmarshalerStack, ok := transferStack.(types.CallbacksCompatibleModule) @@ -970,7 +970,7 @@ func (s *CallbacksTestSuite) TestGetAppVersion() { // Obtain an IBC stack for testing. The function call will use the top of the stack which calls // directly to the channel keeper. Calling from a further down module in the stack is not necessary // for this test. - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.ICS4Wrapper) @@ -985,7 +985,7 @@ func (s *CallbacksTestSuite) TestOnChanCloseInit() { // We will pass the function call down the icacontroller stack to the icacontroller module // icacontroller stack OnChanCloseInit call order: callbacks -> fee -> icacontroller - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.Middleware) @@ -1000,7 +1000,7 @@ func (s *CallbacksTestSuite) TestOnChanCloseConfirm() { // We will pass the function call down the icacontroller stack to the icacontroller module // icacontroller stack OnChanCloseConfirm call order: callbacks -> fee -> icacontroller - icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(icacontrollertypes.SubModuleName) + icaControllerStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(icacontrollertypes.SubModuleName) s.Require().True(ok) controllerStack, ok := icaControllerStack.(porttypes.Middleware) @@ -1015,7 +1015,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacketAsyncAck() { module, _, err := s.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(s.chainA.GetContext(), ibctesting.MockFeePort) s.Require().NoError(err) - cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(module) s.Require().True(ok) mockFeeCallbackStack, ok := cbs.(porttypes.Middleware) s.Require().True(ok) diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 11f33015984..ee473377227 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -183,7 +183,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, path.EndpointA.ChannelID)) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel @@ -235,7 +235,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) suite.Require().NoError(err) - cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) tc.malleate() // explicitly change fields in channel and testChannel @@ -379,7 +379,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeTry() { module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), types.PortID) suite.Require().NoError(err) - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) @@ -450,7 +450,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeAck() { module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), types.PortID) suite.Require().NoError(err) - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.GetRoute(module) + app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) suite.Require().True(ok) cbs, ok := app.(porttypes.UpgradableModule) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index d690e5d8f72..51d77152a59 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -82,8 +82,8 @@ func (k *Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *ca return types.GetModuleOwner(modules), capability, nil } -// GetRoute returns a IBCModule for a given module, and a boolean indicating +// Route returns a IBCModule for a given module, and a boolean indicating // whether or not the route is present. -func (k *Keeper) GetRoute(module string) (types.IBCModule, bool) { - return k.Router.GetRoute(module) +func (k *Keeper) Route(clientID string) (types.IBCModule, bool) { + return k.Router.GetRoute(clientID) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 90ad590b042..a30e96d1ed6 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -214,7 +214,7 @@ func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgCha } // Retrieve application callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel open init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -262,7 +262,7 @@ func (k *Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChan } // Retrieve application callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel open try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -309,7 +309,7 @@ func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChan } // Retrieve application callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel open ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -351,7 +351,7 @@ func (k *Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.Msg } // Retrieve application callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel open confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -389,7 +389,7 @@ func (k *Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCh } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -423,7 +423,7 @@ func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Ms } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -463,7 +463,7 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -544,7 +544,7 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -616,7 +616,7 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -691,7 +691,7 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck } // Retrieve callbacks from router - cbs, ok := k.PortKeeper.GetRoute(module) + cbs, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -753,7 +753,7 @@ func (k *Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.Msg return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.PortKeeper.GetRoute(module) + app, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -801,7 +801,7 @@ func (k *Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgC return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.PortKeeper.GetRoute(module) + app, ok := k.PortKeeper.Route(module) if !ok { ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) @@ -862,7 +862,7 @@ func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgC return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.PortKeeper.GetRoute(module) + app, ok := k.PortKeeper.Route(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) @@ -928,7 +928,7 @@ func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes. return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.PortKeeper.GetRoute(module) + app, ok := k.PortKeeper.Route(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) @@ -989,7 +989,7 @@ func (k *Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.Msg return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") } - app, ok := k.PortKeeper.GetRoute(module) + app, ok := k.PortKeeper.Route(module) if !ok { err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err)