Skip to content

Commit

Permalink
remove ICA Host
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjoon-lee committed Feb 8, 2023
1 parent 006a9cb commit f9ee85f
Showing 1 changed file with 3 additions and 64 deletions.
67 changes: 3 additions & 64 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/cosmos/cosmos-sdk/x/authz"
icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
ibcfeekeeper "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
"github.com/medibloc/panacea-core/v2/x/oracle"
Expand Down Expand Up @@ -96,11 +95,6 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v4/modules/apps/29-fee"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
Expand Down Expand Up @@ -199,6 +193,7 @@ var (
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
ibcfee.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand All @@ -211,8 +206,6 @@ var (
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
datadeal.AppModuleBasic{},
ica.AppModuleBasic{},
ibcfee.AppModuleBasic{},
)

// module account permissions
Expand All @@ -225,7 +218,6 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
burntypes.ModuleName: {authtypes.Burner},
}
Expand Down Expand Up @@ -276,16 +268,14 @@ type App struct {
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
scopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper //TODO: need this? not used anywhere
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

Expand Down Expand Up @@ -342,7 +332,6 @@ func New(
wasm.StoreKey,
feegrant.StoreKey,
datadealtypes.StoreKey,
icahosttypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand All @@ -368,7 +357,6 @@ func New(

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)

Expand Down Expand Up @@ -441,17 +429,6 @@ func New(
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
Expand Down Expand Up @@ -534,12 +511,6 @@ func New(
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
var icaHostStack porttypes.IBCModule
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack porttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
Expand All @@ -549,7 +520,6 @@ func New(
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
ibcRouter.AddRoute(wasm.ModuleName, wasmStack)
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostStack)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -585,7 +555,6 @@ func New(
params.NewAppModule(app.ParamsKeeper),
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(nil, &app.ICAHostKeeper),
aol.NewAppModule(appCodec, app.aolKeeper),
did.NewAppModule(appCodec, app.didKeeper),
burn.NewAppModule(appCodec, app.burnKeeper),
Expand Down Expand Up @@ -613,7 +582,6 @@ func New(
paramstypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
authtypes.ModuleName,
aoltypes.ModuleName,
Expand Down Expand Up @@ -648,7 +616,6 @@ func New(
slashingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
aoltypes.ModuleName,
oracletypes.ModuleName,
Expand Down Expand Up @@ -679,7 +646,6 @@ func New(
feegrant.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
aoltypes.ModuleName,
didtypes.ModuleName,
Expand Down Expand Up @@ -752,7 +718,6 @@ func New(
}

app.ScopedIBCKeeper = scopedIBCKeeper
app.scopedICAHostKeeper = scopedICAHostKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedWasmKeeper = scopedWasmKeeper

Expand Down Expand Up @@ -916,8 +881,6 @@ func initParamsKeeper(appCodec codec.Codec, legacyAmino *codec.LegacyAmino, key,
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(aoltypes.ModuleName)
paramsKeeper.Subspace(didtypes.ModuleName)
paramsKeeper.Subspace(burntypes.ModuleName)
Expand Down Expand Up @@ -965,30 +928,6 @@ func (app *App) registerUpgradeHandlers() error {

// v2.1.0
app.UpgradeKeeper.SetUpgradeHandler("v2.1.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
////////////////////////////////////////////////
// To upgrade ibc-go from v2 to v3.0.0 with ICA

// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = app.mm.Modules[icatypes.ModuleName].ConsensusVersion()
// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{} // without enabling controller
// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{"*"},
}

ctx.Logger().Info("start to init interchain account module...")

// initialize ICS27 module
icaModule, correctTypecast := app.mm.Modules[icatypes.ModuleName].(ica.AppModule)
if !correctTypecast {
panic("mm.Modules[icatypes.ModuleName] is not of type ica.AppModule")
}
icaModule.InitModule(ctx, controllerParams, hostParams)

////////////////////////////////////////////////

// use custom genesis state for genesis oracle
fromVM["oracle"] = oracle.AppModule{}.ConsensusVersion()

Expand Down Expand Up @@ -1031,7 +970,7 @@ func (app *App) registerUpgradeHandlers() error {

if upgradeInfo.Name == "v2.1.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{icahosttypes.StoreKey, "datadeal", "oracle"},
Added: []string{"datadeal", "oracle"},
}

app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down

0 comments on commit f9ee85f

Please sign in to comment.