diff --git a/app/app.go b/app/app.go index aa92bc8617..d37a86e0ce 100644 --- a/app/app.go +++ b/app/app.go @@ -75,6 +75,9 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" @@ -233,29 +236,31 @@ type WasmApp struct { memKeys map[string]*sdk.MemoryStoreKey // keepers - accountKeeper authkeeper.AccountKeeper - bankKeeper bankkeeper.Keeper - capabilityKeeper *capabilitykeeper.Keeper - stakingKeeper stakingkeeper.Keeper - slashingKeeper slashingkeeper.Keeper - mintKeeper mintkeeper.Keeper - distrKeeper distrkeeper.Keeper - govKeeper govkeeper.Keeper - crisisKeeper crisiskeeper.Keeper - upgradeKeeper upgradekeeper.Keeper - paramsKeeper paramskeeper.Keeper - evidenceKeeper evidencekeeper.Keeper - ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - icaHostKeeper icahostkeeper.Keeper - transferKeeper ibctransferkeeper.Keeper - feeGrantKeeper feegrantkeeper.Keeper - authzKeeper authzkeeper.Keeper - wasmKeeper wasm.Keeper - - scopedIBCKeeper capabilitykeeper.ScopedKeeper - scopedICAHostKeeper capabilitykeeper.ScopedKeeper - scopedTransferKeeper capabilitykeeper.ScopedKeeper - scopedWasmKeeper capabilitykeeper.ScopedKeeper + accountKeeper authkeeper.AccountKeeper + bankKeeper bankkeeper.Keeper + capabilityKeeper *capabilitykeeper.Keeper + stakingKeeper stakingkeeper.Keeper + slashingKeeper slashingkeeper.Keeper + mintKeeper mintkeeper.Keeper + distrKeeper distrkeeper.Keeper + govKeeper govkeeper.Keeper + crisisKeeper crisiskeeper.Keeper + upgradeKeeper upgradekeeper.Keeper + paramsKeeper paramskeeper.Keeper + evidenceKeeper evidencekeeper.Keeper + ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + icaControllerKeeper icacontrollerkeeper.Keeper + icaHostKeeper icahostkeeper.Keeper + transferKeeper ibctransferkeeper.Keeper + feeGrantKeeper feegrantkeeper.Keeper + authzKeeper authzkeeper.Keeper + wasmKeeper wasm.Keeper + + scopedIBCKeeper capabilitykeeper.ScopedKeeper + scopedICAHostKeeper capabilitykeeper.ScopedKeeper + scopedICAControllerKeeper capabilitykeeper.ScopedKeeper + scopedTransferKeeper capabilitykeeper.ScopedKeeper + scopedWasmKeeper capabilitykeeper.ScopedKeeper // the module manager mm *module.Manager @@ -295,7 +300,7 @@ func NewWasmApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, - feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey, + feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -329,6 +334,7 @@ func NewWasmApp( ) scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedICAHostKeeper := app.capabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + scopedICAControllerKeeper := app.capabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.capabilityKeeper.ScopeToModule(wasm.ModuleName) app.capabilityKeeper.Seal() @@ -454,9 +460,28 @@ func NewWasmApp( scopedICAHostKeeper, app.MsgServiceRouter(), ) - icaModule := ica.NewAppModule(nil, &app.icaHostKeeper) + app.icaControllerKeeper = icacontrollerkeeper.NewKeeper( + appCodec, + keys[icacontrollertypes.StoreKey], + app.getSubspace(icacontrollertypes.SubModuleName), + app.ibcKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee + app.ibcKeeper.ChannelKeeper, + &app.ibcKeeper.PortKeeper, + scopedICAControllerKeeper, + app.MsgServiceRouter(), + ) + icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper) icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper) + // FIXME: this came from PR #793, but I don't like testing "mocks" in a real app + // icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper)) + + // TODO: clarify how to build icaAuthModule or remove icaController support? + // See https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/integration.md + // "Note: No `icaauth` exists, this must be substituted with an actual Interchain Accounts authentication module" + var icaAuthModule porttypes.IBCModule + icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, icaAuthModule) + // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, @@ -505,7 +530,13 @@ func NewWasmApp( ibcRouter. AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.ibcKeeper.ChannelKeeper)). AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + + // FIXME: these are for ICA later + // AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack) + // AddRoute(ibcmock.ModuleName, mockIBCModule) + app.ibcKeeper.SetRouter(ibcRouter) app.govKeeper = govkeeper.NewKeeper( @@ -713,6 +744,7 @@ func NewWasmApp( app.scopedTransferKeeper = scopedTransferKeeper app.scopedWasmKeeper = scopedWasmKeeper app.scopedICAHostKeeper = scopedICAHostKeeper + app.scopedICAControllerKeeper = scopedICAControllerKeeper if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -861,6 +893,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName) paramsKeeper.Subspace(wasm.ModuleName) return paramsKeeper