Skip to content

Commit 03f586a

Browse files
committed
added ica controller
1 parent 900c0a0 commit 03f586a

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

app/keepers/keepers.go

Lines changed: 40 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,25 @@ 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+
var icaHostStack porttypes.IBCModule
326+
icaHostStack = icahost.NewIBCModule(*appKeepers.ICAHostKeeper)
312327

313328
// ICQ Keeper
314329
icqKeeper := icqkeeper.NewKeeper(
@@ -326,8 +341,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
326341
// Create Async ICQ module
327342
icqModule := icq.NewIBCModule(*appKeepers.ICQKeeper)
328343

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

333354
// create evidence keeper with router
@@ -676,6 +697,7 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
676697
appKeepers.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, appKeepers.keys[capabilitytypes.StoreKey], appKeepers.memKeys[capabilitytypes.MemStoreKey])
677698
appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
678699
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
700+
appKeepers.ScopedICAControllerKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
679701
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
680702
appKeepers.ScopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
681703
appKeepers.ScopedICQKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
@@ -714,6 +736,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
714736
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
715737
paramsKeeper.Subspace(ibchost.ModuleName)
716738
paramsKeeper.Subspace(icahosttypes.SubModuleName)
739+
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
717740
paramsKeeper.Subspace(incentivestypes.ModuleName)
718741
paramsKeeper.Subspace(lockuptypes.ModuleName)
719742
paramsKeeper.Subspace(poolincentivestypes.ModuleName)
@@ -827,6 +850,7 @@ func KVStoreKeys() []string {
827850
consensusparamtypes.StoreKey,
828851
ibchost.StoreKey,
829852
icahosttypes.StoreKey,
853+
icacontrollertypes.StoreKey,
830854
upgradetypes.StoreKey,
831855
evidencetypes.StoreKey,
832856
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/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)