Skip to content

Commit

Permalink
Merge pull request #990 from public-awesome/spoorthi/ica-controller
Browse files Browse the repository at this point in the history
adding ica controller module
  • Loading branch information
jhernandezb authored Mar 18, 2024
2 parents 9129439 + a171f12 commit 8689452
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ steps:
password:
from_secret: docker_password
tags:
- 13.0.0-beta.7
- 13.0.0-beta.9
when:
event:
- push
branch:
- jhernandezb/bump-pfm-module
- spoorthi/ica-controller
- name: docker_release
image: plugins/docker
settings:
Expand Down Expand Up @@ -351,7 +351,7 @@ steps:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: always
image: publicawesome/stargaze:13.0.0-beta.7
image: publicawesome/stargaze:13.0.0-beta.9
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand All @@ -370,7 +370,7 @@ steps:
- http://icad:26657
- name: check-params
pull: always
image: publicawesome/stargaze:13.0.0-beta.7
image: publicawesome/stargaze:13.0.0-beta.9
commands:
- starsd q mint params --node http://stargaze-upgraded:26657
- starsd q alloc params --node http://stargaze-upgraded:26657
Expand Down Expand Up @@ -420,6 +420,6 @@ volumes:

---
kind: signature
hmac: 0af94ca948b2acd8e09bb12c8d57e9805b26b12ea8ee85dca746cf461de65c00
hmac: 5731053a92a730984ac3a569c36c712eb78d3c917641f67cf733ddbf9db91a35

...
39 changes: 32 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ import (

// ica
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"

stargazerest "github.com/public-awesome/stargaze/v13/internal/rest"

sgappparams "github.com/public-awesome/stargaze/v13/app/params"
Expand Down Expand Up @@ -284,14 +288,16 @@ type App struct {
ContractKeeper *wasmkeeper.PermissionedKeeper

// IBC
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
ICAHostKeeper icahostkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
ICAHostKeeper icahostkeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// stargaze modules
AllocKeeper allocmodulekeeper.Keeper
Expand Down Expand Up @@ -347,6 +353,7 @@ func NewStargazeApp(
cronmoduletypes.StoreKey,
tokenfactorytypes.StoreKey,
icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
globalfeemoduletypes.StoreKey,
ibchookstypes.StoreKey,
packetforwardtypes.StoreKey,
Expand Down Expand Up @@ -385,6 +392,7 @@ func NewStargazeApp(
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
app.CapabilityKeeper.Seal()
// this line is used by starport scaffolding # stargate/app/scopedKeeper

Expand Down Expand Up @@ -560,11 +568,26 @@ func NewStargazeApp(

icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
app.keys[icacontrollertypes.StoreKey],
app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper,
app.MsgServiceRouter(),
)

var icaControllerStack ibcporttypes.IBCModule
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)

// Create static IBC router, add transfer route, then set and seal it

ibcRouter := ibcporttypes.NewRouter()
ibcRouter.
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(ibctransfertypes.ModuleName, transferStack)

// this line is used by starport scaffolding # ibc/app/router
Expand Down Expand Up @@ -703,7 +726,7 @@ func NewStargazeApp(
upgrade.NewAppModule(&app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
ica.NewAppModule(nil, &app.ICAHostKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
params.NewAppModule(app.ParamsKeeper),
transfer.NewAppModule(app.TransferKeeper),
allocModule,
Expand Down Expand Up @@ -871,6 +894,7 @@ func NewStargazeApp(
}

app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedIBCKeeper = scopedWasmKeeper
Expand Down Expand Up @@ -1048,6 +1072,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(cronmoduletypes.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
paramsKeeper.Subspace(globalfeemoduletypes.ModuleName)
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
// this line is used by starport scaffolding # stargate/app/paramSubspace
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
return nil, err
}

// since params where never initialized start with enabled
icaParams := icacontrollertypes.DefaultParams()
icaParams.ControllerEnabled = true
app.ICAControllerKeeper.SetParams(ctx, icaParams)

return migrations, nil
})

Expand All @@ -135,6 +140,7 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
Added: []string{
consensustypes.ModuleName,
crisistypes.ModuleName,
icacontrollertypes.StoreKey,
},
Deleted: []string{
claimModuleName,
Expand Down

0 comments on commit 8689452

Please sign in to comment.