diff --git a/app/app.go b/app/app.go index 211f7798da..732ddee2b2 100644 --- a/app/app.go +++ b/app/app.go @@ -94,6 +94,11 @@ import ( gravity "github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity" gravitykeeper "github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity/keeper" gravitytypes "github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity/types" + ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts" + icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types" ibctransfer "github.com/cosmos/ibc-go/v6/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" @@ -173,6 +178,9 @@ func init() { nftmodule.AppModuleBasic{}, ibc.AppModuleBasic{}, ibctransfer.AppModuleBasic{}, + ica.AppModuleBasic{}, + // intertx.AppModuleBasic{}, + // ibcfee.AppModuleBasic{}, gravity.AppModuleBasic{}, leverage.AppModuleBasic{}, oracle.AppModuleBasic{}, @@ -196,6 +204,7 @@ func init() { nft.ModuleName: nil, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + icatypes.ModuleName: nil, gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner}, oracletypes.ModuleName: nil, @@ -245,6 +254,7 @@ type UmeeApp struct { UIBCTransferKeeper uibctransferkeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAHostKeeper icahostkeeper.Keeper GravityKeeper gravitykeeper.Keeper LeverageKeeper leveragekeeper.Keeper OracleKeeper oraclekeeper.Keeper @@ -359,6 +369,7 @@ func New( // grant capabilities for the ibc and ibc-transfer modules app.ScopedIBCKeeper = app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) app.ScopedTransferKeeper = app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) app.initializeCustomScopedKeepers() @@ -497,6 +508,12 @@ func New( app.UpgradeKeeper, app.ScopedIBCKeeper, ) + app.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, // app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), + ) var ics4Wrapper ibcporttypes.ICS4Wrapper app.UIbcQuotaKeeper = uibcquotakeeper.NewKeeper( @@ -524,10 +541,10 @@ func New( app.UIBCTransferKeeper = uibctransferkeeper.New(ibcTransferKeeper, app.BankKeeper) // Create Transfer Stack - // SendPacket, since it is originating from the application to core IBC: + // SendPacket, originates from the application to an IBC channel: // transferKeeper.SendPacket -> uibcquota.SendPacket -> channel.SendPacket - // RecvPacket, message that originates from core IBC and goes down to app, the flow is the other way + // RecvPacket, message that originates from an IBC channel and goes down to app, the flow is the other way // channel.RecvPacket -> uibcquota.OnRecvPacket -> transfer.OnRecvPacket // transfer stack contains (from top to bottom): @@ -541,8 +558,18 @@ func New( ibctransfer.NewIBCModule(ibcTransferKeeper), app.UIBCTransferKeeper, ) + // transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) transferStack = uibcquota.NewIBCMiddleware(transferStack, app.UIbcQuotaKeeper, appCodec) + // Create Interchain Accounts Stack + // SendPacket, since it is originating from the application to core IBC: + // icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket + + // RecvPacket, message that originates from core IBC and goes down to app, the flow is: + // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket + var icaHostStack ibcporttypes.IBCModule = icahost.NewIBCModule(app.ICAHostKeeper) + // icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper) + /* Create fee enabled wasm ibc Stack var wasmStack ibcporttypes.IBCModule @@ -552,14 +579,14 @@ func New( // Create static IBC router, add app routes, then set and seal it ibcRouter := ibcporttypes.NewRouter(). - AddRoute(ibctransfertypes.ModuleName, transferStack) + AddRoute(ibctransfertypes.ModuleName, transferStack). + AddRoute(icahosttypes.SubModuleName, icaHostStack) /* // we will add cosmwasm IBC routing later AddRoute(wasm.ModuleName, wasmStack). // we don't integrate the controller now AddRoute(intertxtypes.ModuleName, icaControllerStack). AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). - AddRoute(icahosttypes.SubModuleName, icaHostStack) */ app.IBCKeeper.SetRouter(ibcRouter) @@ -611,7 +638,9 @@ func New( // must be passed by reference here. appModules := []module.AppModule{ genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + app.AccountKeeper, + app.StakingKeeper, + app.DeliverTx, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil), @@ -636,6 +665,8 @@ func New( nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ibctransfer.NewAppModule(ibcTransferKeeper), + // ibcfee.NewAppModule(app.IBCFeeKeeper), + ica.NewAppModule(nil, &app.ICAHostKeeper), gravity.NewAppModule(app.GravityKeeper, app.BankKeeper), leverage.NewAppModule(appCodec, app.LeverageKeeper, app.AccountKeeper, app.BankKeeper), oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), @@ -665,7 +696,9 @@ func New( nft.ModuleName, group.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, - // icatypes.ModuleName, ibcfeetypes.ModuleName, + ibchost.ModuleName, + icatypes.ModuleName, + // ibcfeetypes.ModuleName, leveragetypes.ModuleName, oracletypes.ModuleName, gravitytypes.ModuleName, @@ -683,7 +716,8 @@ func New( genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, - // icatypes.ModuleName, + ibchost.ModuleName, + icatypes.ModuleName, leveragetypes.ModuleName, gravitytypes.ModuleName, bech32ibctypes.ModuleName, @@ -700,7 +734,8 @@ func New( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, - authz.ModuleName, ibctransfertypes.ModuleName, // icatypes.ModuleName, + authz.ModuleName, + ibctransfertypes.ModuleName, ibchost.ModuleName, icatypes.ModuleName, // ibcfeetypes.ModuleName feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, @@ -715,7 +750,7 @@ func New( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, - authz.ModuleName, ibctransfertypes.ModuleName, // icatypes.ModuleName, + authz.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, // ibcfeetypes.ModuleName feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, @@ -757,10 +792,12 @@ func New( simStateModules := genmap.Pick( app.mm.Modules, - []string{stakingtypes.ModuleName, authtypes.ModuleName, oracletypes.ModuleName}, + []string{stakingtypes.ModuleName, authtypes.ModuleName, oracletypes.ModuleName, + ibchost.ModuleName}, ) // TODO: Ensure x/leverage implements simulator and add it here: - simTestModules := genmap.Pick(simStateModules, []string{oracletypes.ModuleName}) + simTestModules := genmap.Pick(simStateModules, + []string{oracletypes.ModuleName, ibchost.ModuleName}) app.StateSimulationManager = module.NewSimulationManagerFromAppModules(simStateModules, overrideModules) app.sm = module.NewSimulationManagerFromAppModules(simTestModules, nil) @@ -1026,7 +1063,7 @@ func initParamsKeeper( paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) // paramsKeeper.Subspace(icacontrollertypes.SubModuleName) - // paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(gravitytypes.ModuleName) paramsKeeper.Subspace(leveragetypes.ModuleName) paramsKeeper.Subspace(oracletypes.ModuleName)