Skip to content

Commit 3306d54

Browse files
nicolaslaramergify[bot]
authored andcommitted
Add ICA controller (#7839)
* added ica controller * lint * added store upgrade * changelog (cherry picked from commit 2f409fd)
1 parent 053de0c commit 3306d54

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7575
* [#7768](https://github.com/osmosis-labs/osmosis/pull/7768) Allow governance module account to transfer any CL position
7676
* [#7746](https://github.com/osmosis-labs/osmosis/pull/7746) Make forfeited incentives redeposit into the pool instead of sending to community pool
7777
* [#7785](https://github.com/osmosis-labs/osmosis/pull/7785) Remove reward claiming during position transfers
78+
* [#7839](https://github.com/osmosis-labs/osmosis/pull/7839) Add ICA controller
7879
* [#7527](https://github.com/osmosis-labs/osmosis/pull/7527) Add 30M gas limit to CW pool contract calls
7980

8081
### SDK

app/keepers/keepers.go

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ import (
3838
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
3939
icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
4040
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
41-
41+
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
42+
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
43+
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
4244
appparams "github.com/osmosis-labs/osmosis/v23/app/params"
4345
"github.com/osmosis-labs/osmosis/v23/x/cosmwasmpool"
4446
cosmwasmpooltypes "github.com/osmosis-labs/osmosis/v23/x/cosmwasmpool/types"
@@ -126,11 +128,12 @@ type AppKeepers struct {
126128
ConsensusParamsKeeper *consensusparamkeeper.Keeper
127129

128130
// make scoped keepers public for test purposes
129-
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
130-
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
131-
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
132-
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
133-
ScopedICQKeeper capabilitykeeper.ScopedKeeper
131+
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
132+
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
133+
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
134+
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
135+
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
136+
ScopedICQKeeper capabilitykeeper.ScopedKeeper
134137

135138
// "Normal" keepers
136139
AccountKeeper *authkeeper.AccountKeeper
@@ -143,6 +146,7 @@ type AppKeepers struct {
143146
IBCKeeper *ibckeeper.Keeper
144147
IBCHooksKeeper *ibchookskeeper.Keeper
145148
ICAHostKeeper *icahostkeeper.Keeper
149+
ICAControllerKeeper *icacontrollerkeeper.Keeper
146150
ICQKeeper *icqkeeper.Keeper
147151
TransferKeeper *ibctransferkeeper.Keeper
148152
IBCWasmClientKeeper *ibcwasmkeeper.Keeper
@@ -292,7 +296,6 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
292296
icaHostKeeper := icahostkeeper.NewKeeper(
293297
appCodec, appKeepers.keys[icahosttypes.StoreKey],
294298
appKeepers.GetSubspace(icahosttypes.SubModuleName),
295-
// UNFORKINGNOTE: I think it is correct to use rate limiting wrapper here
296299
appKeepers.RateLimitingICS4Wrapper,
297300
appKeepers.IBCKeeper.ChannelKeeper,
298301
&appKeepers.IBCKeeper.PortKeeper,
@@ -302,13 +305,24 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
302305
)
303306
appKeepers.ICAHostKeeper = &icaHostKeeper
304307

305-
icaHostIBCModule := icahost.NewIBCModule(*appKeepers.ICAHostKeeper)
306-
// Create static IBC router, add transfer route, then set and seal it
307-
ibcRouter := porttypes.NewRouter()
308-
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
309-
// The transferIBC module is replaced by rateLimitingTransferModule
310-
AddRoute(ibctransfertypes.ModuleName, appKeepers.TransferStack)
311-
// Note: the sealing is done after creating wasmd and wiring that up
308+
icaControllerKeeper := icacontrollerkeeper.NewKeeper(
309+
appCodec, appKeepers.keys[icacontrollertypes.StoreKey],
310+
appKeepers.GetSubspace(icacontrollertypes.SubModuleName),
311+
appKeepers.RateLimitingICS4Wrapper,
312+
appKeepers.IBCKeeper.ChannelKeeper,
313+
&appKeepers.IBCKeeper.PortKeeper,
314+
appKeepers.ScopedICAControllerKeeper,
315+
bApp.MsgServiceRouter(),
316+
)
317+
appKeepers.ICAControllerKeeper = &icaControllerKeeper
318+
319+
// initialize ICA module with mock module as the authentication module on the controller side
320+
var icaControllerStack porttypes.IBCModule
321+
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, *appKeepers.ICAControllerKeeper)
322+
323+
// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
324+
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
325+
icaHostStack := icahost.NewIBCModule(*appKeepers.ICAHostKeeper)
312326

313327
// ICQ Keeper
314328
icqKeeper := icqkeeper.NewKeeper(
@@ -326,8 +340,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
326340
// Create Async ICQ module
327341
icqModule := icq.NewIBCModule(*appKeepers.ICQKeeper)
328342

329-
// Add icq modules to IBC router
330-
ibcRouter.AddRoute(icqtypes.ModuleName, icqModule)
343+
// Create static IBC router, add transfer route, then set and seal it
344+
ibcRouter := porttypes.NewRouter()
345+
ibcRouter.AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
346+
AddRoute(icahosttypes.SubModuleName, icaHostStack).
347+
// The transferIBC module is replaced by rateLimitingTransferModule
348+
AddRoute(ibctransfertypes.ModuleName, appKeepers.TransferStack).
349+
// Add icq modules to IBC router
350+
AddRoute(icqtypes.ModuleName, icqModule)
331351
// Note: the sealing is done after creating wasmd and wiring that up
332352

333353
// create evidence keeper with router
@@ -676,6 +696,7 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
676696
appKeepers.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, appKeepers.keys[capabilitytypes.StoreKey], appKeepers.memKeys[capabilitytypes.MemStoreKey])
677697
appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
678698
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
699+
appKeepers.ScopedICAControllerKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
679700
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
680701
appKeepers.ScopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
681702
appKeepers.ScopedICQKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
@@ -714,6 +735,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
714735
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
715736
paramsKeeper.Subspace(ibchost.ModuleName)
716737
paramsKeeper.Subspace(icahosttypes.SubModuleName)
738+
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
717739
paramsKeeper.Subspace(incentivestypes.ModuleName)
718740
paramsKeeper.Subspace(lockuptypes.ModuleName)
719741
paramsKeeper.Subspace(poolincentivestypes.ModuleName)
@@ -827,6 +849,7 @@ func KVStoreKeys() []string {
827849
consensusparamtypes.StoreKey,
828850
ibchost.StoreKey,
829851
icahosttypes.StoreKey,
852+
icacontrollertypes.StoreKey,
830853
upgradetypes.StoreKey,
831854
evidencetypes.StoreKey,
832855
ibctransfertypes.StoreKey,

app/modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func appModules(
165165
authzmodule.NewAppModule(appCodec, *app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
166166
ibc.NewAppModule(app.IBCKeeper),
167167
ibcwasm.NewAppModule(*app.IBCWasmClientKeeper),
168-
ica.NewAppModule(nil, app.ICAHostKeeper),
168+
ica.NewAppModule(app.ICAControllerKeeper, app.ICAHostKeeper),
169169
params.NewAppModule(*app.ParamsKeeper),
170170
consensus.NewAppModule(appCodec, *app.AppKeepers.ConsensusParamsKeeper),
171171
app.RawIcs20TransferAppModule,

app/upgrades/v24/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v24
22

33
import (
44
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
5+
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
56
"github.com/osmosis-labs/osmosis/v23/app/upgrades"
67

78
store "github.com/cosmos/cosmos-sdk/store/types"
@@ -14,7 +15,7 @@ var Upgrade = upgrades.Upgrade{
1415
UpgradeName: UpgradeName,
1516
CreateUpgradeHandler: CreateUpgradeHandler,
1617
StoreUpgrades: store.StoreUpgrades{
17-
Added: []string{ibcwasmtypes.StoreKey},
18+
Added: []string{ibcwasmtypes.StoreKey, icacontrollertypes.StoreKey},
1819
Deleted: []string{},
1920
},
2021
}

app/upgrades/v24/upgrades.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
"github.com/cosmos/cosmos-sdk/types/module"
66
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7+
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
78

89
"github.com/osmosis-labs/osmosis/v23/app/keepers"
910
"github.com/osmosis-labs/osmosis/v23/app/upgrades"
@@ -46,6 +47,9 @@ func CreateUpgradeHandler(
4647
// https://www.mintscan.io/osmosis/proposals/733
4748
keepers.IncentivesKeeper.SetParam(ctx, incentivestypes.KeyMinValueForDistr, incentivestypes.DefaultMinValueForDistr)
4849

50+
// Enable ICA controllers
51+
keepers.ICAControllerKeeper.SetParams(ctx, icacontrollertypes.DefaultParams())
52+
4953
return migrations, nil
5054
}
5155
}

0 commit comments

Comments
 (0)