Skip to content

Commit

Permalink
Revert "Remove controller, host-only mode"
Browse files Browse the repository at this point in the history
This reverts commit 38932b7.
  • Loading branch information
ethanfrey committed May 4, 2022
1 parent 38932b7 commit 9b8fb98
Showing 1 changed file with 58 additions and 25 deletions.
83 changes: 58 additions & 25 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9b8fb98

Please sign in to comment.