Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app)!: add ICA Host module with enabled false #1441

Merged
merged 10 commits into from
Sep 1, 2022
Prev Previous commit
Next Next commit
feat(app): force ICA host and controller to be disabled
  • Loading branch information
tyler authored and tyler committed Aug 31, 2022
commit 7a5cb0239fd2a0ff7f50915fb510e88e45dd7ed9
34 changes: 33 additions & 1 deletion app/stable_appconfig.go → app/appconfig.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package app

import (
"fmt"

"github.com/cosmos/cosmos-sdk/client"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/group"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"

"github.com/regen-network/regen-ledger/x/data"
"github.com/regen-network/regen-ledger/x/ecocredit"
Expand All @@ -18,12 +23,39 @@ func (app *RegenApp) registerUpgradeHandlers() {
upgradeName := "v5.0"
app.UpgradeKeeper.SetUpgradeHandler(upgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

// set regen module consensus version
fromVM[ecocredit.ModuleName] = 2
fromVM[data.ModuleName] = 1
app.UpgradeKeeper.SetModuleVersionMap(ctx, fromVM)

// manually set the ICA params
// the ICA module's default genesis has host and controller enabled.
// we want these to be enabled via gov param change.

// Add Interchain Accounts host module
// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = app.ModuleManager.Modules[icatypes.ModuleName].ConsensusVersion()

// create ICS27 Controller submodule params, controller module not enabled.
controllerParams := icacontrollertypes.Params{ControllerEnabled: false}

// create ICS27 Host submodule params, host module not enabled.
hostParams := icahosttypes.Params{
HostEnabled: false,
AllowMessages: []string{},
}

mod, found := app.ModuleManager.Modules[icatypes.ModuleName]
if !found {
panic(fmt.Sprintf("module %s is not in the module manager", icatypes.ModuleName))
}

icaMod, ok := mod.(ica.AppModule)
if !ok {
panic(fmt.Sprintf("expected module %s to be type %T, got %T", icatypes.ModuleName, ica.AppModule{}, mod))
}
icaMod.InitModule(ctx, controllerParams, hostParams)

// transfer module consensus version has been bumped to 2
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
})
Expand Down