@@ -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,24 @@ 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+ icaHostStack := icahost .NewIBCModule (* appKeepers .ICAHostKeeper )
312326
313327 // ICQ Keeper
314328 icqKeeper := icqkeeper .NewKeeper (
@@ -326,8 +340,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
326340 // Create Async ICQ module
327341 icqModule := icq .NewIBCModule (* appKeepers .ICQKeeper )
328342
329- // Add icq modules to IBC router
330- ibcRouter .AddRoute (icqtypes .ModuleName , icqModule )
343+ // Create static IBC router, add transfer route, then set and seal it
344+ ibcRouter := porttypes .NewRouter ()
345+ ibcRouter .AddRoute (icacontrollertypes .SubModuleName , icaControllerStack ).
346+ AddRoute (icahosttypes .SubModuleName , icaHostStack ).
347+ // The transferIBC module is replaced by rateLimitingTransferModule
348+ AddRoute (ibctransfertypes .ModuleName , appKeepers .TransferStack ).
349+ // Add icq modules to IBC router
350+ AddRoute (icqtypes .ModuleName , icqModule )
331351 // Note: the sealing is done after creating wasmd and wiring that up
332352
333353 // create evidence keeper with router
@@ -676,6 +696,7 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
676696 appKeepers .CapabilityKeeper = capabilitykeeper .NewKeeper (appCodec , appKeepers .keys [capabilitytypes .StoreKey ], appKeepers .memKeys [capabilitytypes .MemStoreKey ])
677697 appKeepers .ScopedIBCKeeper = appKeepers .CapabilityKeeper .ScopeToModule (ibchost .ModuleName )
678698 appKeepers .ScopedICAHostKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icahosttypes .SubModuleName )
699+ appKeepers .ScopedICAControllerKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
679700 appKeepers .ScopedTransferKeeper = appKeepers .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
680701 appKeepers .ScopedWasmKeeper = appKeepers .CapabilityKeeper .ScopeToModule (wasmtypes .ModuleName )
681702 appKeepers .ScopedICQKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icqtypes .ModuleName )
@@ -714,6 +735,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
714735 paramsKeeper .Subspace (ibctransfertypes .ModuleName )
715736 paramsKeeper .Subspace (ibchost .ModuleName )
716737 paramsKeeper .Subspace (icahosttypes .SubModuleName )
738+ paramsKeeper .Subspace (icacontrollertypes .SubModuleName ).WithKeyTable (icacontrollertypes .ParamKeyTable ())
717739 paramsKeeper .Subspace (incentivestypes .ModuleName )
718740 paramsKeeper .Subspace (lockuptypes .ModuleName )
719741 paramsKeeper .Subspace (poolincentivestypes .ModuleName )
@@ -827,6 +849,7 @@ func KVStoreKeys() []string {
827849 consensusparamtypes .StoreKey ,
828850 ibchost .StoreKey ,
829851 icahosttypes .StoreKey ,
852+ icacontrollertypes .StoreKey ,
830853 upgradetypes .StoreKey ,
831854 evidencetypes .StoreKey ,
832855 ibctransfertypes .StoreKey ,
0 commit comments