@@ -38,7 +38,9 @@ import (
3838 upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
3939 icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
4040 icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
41-
41+ icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
42+ icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
43+ icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
4244 appparams "github.com/osmosis-labs/osmosis/v23/app/params"
4345 "github.com/osmosis-labs/osmosis/v23/x/cosmwasmpool"
4446 cosmwasmpooltypes "github.com/osmosis-labs/osmosis/v23/x/cosmwasmpool/types"
@@ -126,11 +128,12 @@ type AppKeepers struct {
126128 ConsensusParamsKeeper * consensusparamkeeper.Keeper
127129
128130 // make scoped keepers public for test purposes
129- ScopedIBCKeeper capabilitykeeper.ScopedKeeper
130- ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
131- ScopedTransferKeeper capabilitykeeper.ScopedKeeper
132- ScopedWasmKeeper capabilitykeeper.ScopedKeeper
133- ScopedICQKeeper capabilitykeeper.ScopedKeeper
131+ ScopedIBCKeeper capabilitykeeper.ScopedKeeper
132+ ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
133+ ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
134+ ScopedTransferKeeper capabilitykeeper.ScopedKeeper
135+ ScopedWasmKeeper capabilitykeeper.ScopedKeeper
136+ ScopedICQKeeper capabilitykeeper.ScopedKeeper
134137
135138 // "Normal" keepers
136139 AccountKeeper * authkeeper.AccountKeeper
@@ -143,6 +146,7 @@ type AppKeepers struct {
143146 IBCKeeper * ibckeeper.Keeper
144147 IBCHooksKeeper * ibchookskeeper.Keeper
145148 ICAHostKeeper * icahostkeeper.Keeper
149+ ICAControllerKeeper * icacontrollerkeeper.Keeper
146150 ICQKeeper * icqkeeper.Keeper
147151 TransferKeeper * ibctransferkeeper.Keeper
148152 IBCWasmClientKeeper * ibcwasmkeeper.Keeper
@@ -292,7 +296,6 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
292296 icaHostKeeper := icahostkeeper .NewKeeper (
293297 appCodec , appKeepers .keys [icahosttypes .StoreKey ],
294298 appKeepers .GetSubspace (icahosttypes .SubModuleName ),
295- // UNFORKINGNOTE: I think it is correct to use rate limiting wrapper here
296299 appKeepers .RateLimitingICS4Wrapper ,
297300 appKeepers .IBCKeeper .ChannelKeeper ,
298301 & appKeepers .IBCKeeper .PortKeeper ,
@@ -302,13 +305,25 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
302305 )
303306 appKeepers .ICAHostKeeper = & icaHostKeeper
304307
305- icaHostIBCModule := icahost .NewIBCModule (* appKeepers .ICAHostKeeper )
306- // Create static IBC router, add transfer route, then set and seal it
307- ibcRouter := porttypes .NewRouter ()
308- ibcRouter .AddRoute (icahosttypes .SubModuleName , icaHostIBCModule ).
309- // The transferIBC module is replaced by rateLimitingTransferModule
310- AddRoute (ibctransfertypes .ModuleName , appKeepers .TransferStack )
311- // Note: the sealing is done after creating wasmd and wiring that up
308+ icaControllerKeeper := icacontrollerkeeper .NewKeeper (
309+ appCodec , appKeepers .keys [icacontrollertypes .StoreKey ],
310+ appKeepers .GetSubspace (icacontrollertypes .SubModuleName ),
311+ appKeepers .RateLimitingICS4Wrapper ,
312+ appKeepers .IBCKeeper .ChannelKeeper ,
313+ & appKeepers .IBCKeeper .PortKeeper ,
314+ appKeepers .ScopedICAControllerKeeper ,
315+ bApp .MsgServiceRouter (),
316+ )
317+ appKeepers .ICAControllerKeeper = & icaControllerKeeper
318+
319+ // initialize ICA module with mock module as the authentication module on the controller side
320+ var icaControllerStack porttypes.IBCModule
321+ icaControllerStack = icacontroller .NewIBCMiddleware (icaControllerStack , * appKeepers .ICAControllerKeeper )
322+
323+ // RecvPacket, message that originates from core IBC and goes down to app, the flow is:
324+ // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
325+ var icaHostStack porttypes.IBCModule
326+ icaHostStack = icahost .NewIBCModule (* appKeepers .ICAHostKeeper )
312327
313328 // ICQ Keeper
314329 icqKeeper := icqkeeper .NewKeeper (
@@ -326,8 +341,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
326341 // Create Async ICQ module
327342 icqModule := icq .NewIBCModule (* appKeepers .ICQKeeper )
328343
329- // Add icq modules to IBC router
330- ibcRouter .AddRoute (icqtypes .ModuleName , icqModule )
344+ // Create static IBC router, add transfer route, then set and seal it
345+ ibcRouter := porttypes .NewRouter ()
346+ ibcRouter .AddRoute (icacontrollertypes .SubModuleName , icaControllerStack ).
347+ AddRoute (icahosttypes .SubModuleName , icaHostStack ).
348+ // The transferIBC module is replaced by rateLimitingTransferModule
349+ AddRoute (ibctransfertypes .ModuleName , appKeepers .TransferStack ).
350+ // Add icq modules to IBC router
351+ AddRoute (icqtypes .ModuleName , icqModule )
331352 // Note: the sealing is done after creating wasmd and wiring that up
332353
333354 // create evidence keeper with router
@@ -676,6 +697,7 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
676697 appKeepers .CapabilityKeeper = capabilitykeeper .NewKeeper (appCodec , appKeepers .keys [capabilitytypes .StoreKey ], appKeepers .memKeys [capabilitytypes .MemStoreKey ])
677698 appKeepers .ScopedIBCKeeper = appKeepers .CapabilityKeeper .ScopeToModule (ibchost .ModuleName )
678699 appKeepers .ScopedICAHostKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icahosttypes .SubModuleName )
700+ appKeepers .ScopedICAControllerKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
679701 appKeepers .ScopedTransferKeeper = appKeepers .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
680702 appKeepers .ScopedWasmKeeper = appKeepers .CapabilityKeeper .ScopeToModule (wasmtypes .ModuleName )
681703 appKeepers .ScopedICQKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icqtypes .ModuleName )
@@ -714,6 +736,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
714736 paramsKeeper .Subspace (ibctransfertypes .ModuleName )
715737 paramsKeeper .Subspace (ibchost .ModuleName )
716738 paramsKeeper .Subspace (icahosttypes .SubModuleName )
739+ paramsKeeper .Subspace (icacontrollertypes .SubModuleName ).WithKeyTable (icacontrollertypes .ParamKeyTable ())
717740 paramsKeeper .Subspace (incentivestypes .ModuleName )
718741 paramsKeeper .Subspace (lockuptypes .ModuleName )
719742 paramsKeeper .Subspace (poolincentivestypes .ModuleName )
@@ -827,6 +850,7 @@ func KVStoreKeys() []string {
827850 consensusparamtypes .StoreKey ,
828851 ibchost .StoreKey ,
829852 icahosttypes .StoreKey ,
853+ icacontrollertypes .StoreKey ,
830854 upgradetypes .StoreKey ,
831855 evidencetypes .StoreKey ,
832856 ibctransfertypes .StoreKey ,
0 commit comments