diff --git a/app/app.go b/app/app.go index 57eb1d76..50a20200 100644 --- a/app/app.go +++ b/app/app.go @@ -2,11 +2,11 @@ package app import ( _ "embed" + v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4" "io" "os" "path/filepath" - v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4" bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper" delegationKeeper "github.com/KYVENetwork/chain/x/delegation/keeper" globalKeeper "github.com/KYVENetwork/chain/x/global/keeper" @@ -255,7 +255,7 @@ func NewKyveApp( app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...) // Register legacy modules - // app.registerIBCModules() + app.registerIBCModules() // load state streaming if enabled if _, _, err := streaming.LoadStreamingServices(app.App.BaseApp, appOpts, app.appCodec, logger, app.kvStoreKeys()); err != nil { @@ -265,8 +265,6 @@ func NewKyveApp( /**** Module Options ****/ - // app.RegisterLegacyModules() - app.ModuleManager.RegisterInvariants(app.CrisisKeeper) // add test gRPC service for testing gRPC queries in isolation @@ -301,8 +299,8 @@ func NewKyveApp( // app.ModuleManager, // app.Configurator(), // app.AppCodec(), - // app.ConsensusKeeper, - // app.GlobalKeeper, + // app.ConsensusParamsKeeper, + // *app.GlobalKeeper, // *app.GovKeeper, // *app.IBCKeeper, // app.ParamsKeeper, diff --git a/app/ibc.go b/app/ibc.go new file mode 100644 index 00000000..cf31c0ee --- /dev/null +++ b/app/ibc.go @@ -0,0 +1,164 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/x/upgrade" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + 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" + ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v7/modules/core" + ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" + ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + // this line is used by starport scaffolding # ibc/app/import +) + +func (app *App) registerIBCModules() { + // set up non depinject support modules store keys + app.keys = sdk.NewKVStoreKeys( + ibcexported.StoreKey, + ibctransfertypes.StoreKey, + ibcfeetypes.StoreKey, + icahosttypes.StoreKey, + icacontrollertypes.StoreKey, + ) + app.MountKVStores(app.keys) + + // set params subspaces + for _, m := range []string{ibctransfertypes.ModuleName, ibcexported.ModuleName, icahosttypes.SubModuleName, icacontrollertypes.SubModuleName} { + app.ParamsKeeper.Subspace(m) + } + + // add capability keeper and ScopeToModule for ibc module + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) + scopedIBCTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + + // Create IBC keeper + app.IBCKeeper = ibckeeper.NewKeeper( + app.appCodec, app.GetKey(ibcexported.StoreKey), app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + ) + + // Register the proposal types + // Deprecated: Avoid adding new handlers, instead use the new proposal flow + // by granting the governance module the right to execute the message. + // See: https://docs.cosmos.network/main/modules/gov#proposal-messages + govRouter := govv1beta1.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + + app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( + app.appCodec, app.GetKey(ibcfeetypes.StoreKey), + app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, + ) + + // Create IBC transfer keeper + app.IBCTransferKeeper = ibctransferkeeper.NewKeeper( + app.appCodec, + app.GetKey(ibctransfertypes.StoreKey), + app.GetSubspace(ibctransfertypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, + scopedIBCTransferKeeper, + ) + + // Create interchain account keepers + app.ICAHostKeeper = icahostkeeper.NewKeeper( + app.appCodec, + app.GetKey(icahosttypes.StoreKey), + app.GetSubspace(icahosttypes.SubModuleName), + app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + scopedICAHostKeeper, + app.MsgServiceRouter(), + ) + app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + app.appCodec, + app.GetKey(icacontrollertypes.StoreKey), + app.GetSubspace(icacontrollertypes.SubModuleName), + app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedICAControllerKeeper, + app.MsgServiceRouter(), + ) + app.GovKeeper.SetLegacyRouter(govRouter) + + // Create IBC modules with ibcfee middleware + transferIBCModule := ibcfee.NewIBCMiddleware(ibctransfer.NewIBCModule(app.IBCTransferKeeper), app.IBCFeeKeeper) + + // integration point for custom authentication modules + var noAuthzModule porttypes.IBCModule + icaControllerIBCModule := ibcfee.NewIBCMiddleware( + icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper), + app.IBCFeeKeeper, + ) + + icaHostIBCModule := ibcfee.NewIBCMiddleware(icahost.NewIBCModule(app.ICAHostKeeper), app.IBCFeeKeeper) + + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := porttypes.NewRouter(). + AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + + // this line is used by starport scaffolding # ibc/app/module + + app.IBCKeeper.SetRouter(ibcRouter) + + // NOTE: Any module instantiated in the module manager that is later modified + // must be passed by reference here. + legacyModules := []module.AppModule{ + ibc.NewAppModule(app.IBCKeeper), + ibctransfer.NewAppModule(app.IBCTransferKeeper), + ibcfee.NewAppModule(app.IBCFeeKeeper), + ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), + } + if err := app.RegisterModules(legacyModules...); err != nil { + panic(err) + } + + // TODO: do we need this? + //cfg := app.Configurator() + //for _, m := range legacyModules { + // if s, ok := m.(module.HasServices); ok { + // s.RegisterServices(cfg) + // } + //} + + // register additional types + ibctm.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) + solomachine.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) + + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper + app.ScopedICAHostKeeper = scopedICAHostKeeper + app.ScopedICAControllerKeeper = scopedICAControllerKeeper +} diff --git a/app/keepers.go b/app/keepers.go deleted file mode 100644 index 3959e0bb..00000000 --- a/app/keepers.go +++ /dev/null @@ -1,144 +0,0 @@ -package app - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storeTypes "github.com/cosmos/cosmos-sdk/store/types" - - // Auth - authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - // Authz - authzKeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - // Bank - bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" - // Bundles - bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper" - // Capability - capabilityKeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - // Consensus - consensusKeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - // Crisis - crisisKeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" - crisisTypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - // Delegation - delegationKeeper "github.com/KYVENetwork/chain/x/delegation/keeper" - // Distribution - distributionKeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distributionTypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - // Evidence - evidenceKeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - // FeeGrant - feeGrantKeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - // Global - globalKeeper "github.com/KYVENetwork/chain/x/global/keeper" - // Governance - govKeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" - // Group - groupKeeper "github.com/cosmos/cosmos-sdk/x/group/keeper" - // IBC Core - ibcExported "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibcKeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - // IBC Fee - ibcFeeKeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" - // IBC Transfer - ibcTransferKeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibcTransferTypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - // ICA 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" - // ICA 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" - // Mint - mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types" - // Parameters - paramsKeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - // PFM - pfmKeeper "github.com/strangelove-ventures/packet-forward-middleware/v7/router/keeper" - pfmTypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types" - // Pool - poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper" - // Query - queryKeeper "github.com/KYVENetwork/chain/x/query/keeper" - // Slashing - slashingKeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - slashingTypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - // Stakers - stakersKeeper "github.com/KYVENetwork/chain/x/stakers/keeper" - // Staking - stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" - // Team - teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" - // Upgrade - upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" -) - -type Keepers struct { - // Cosmos SDK - AccountKeeper authKeeper.AccountKeeper - AuthzKeeper authzKeeper.Keeper - BankKeeper bankKeeper.Keeper - CapabilityKeeper *capabilityKeeper.Keeper - ConsensusKeeper consensusKeeper.Keeper - CrisisKeeper *crisisKeeper.Keeper - DistributionKeeper distributionKeeper.Keeper - EvidenceKeeper *evidenceKeeper.Keeper - FeeGrantKeeper feeGrantKeeper.Keeper - GovKeeper *govKeeper.Keeper - GroupKeeper groupKeeper.Keeper - MintKeeper mintKeeper.Keeper - ParamsKeeper paramsKeeper.Keeper - SlashingKeeper slashingKeeper.Keeper - StakingKeeper *stakingKeeper.Keeper - UpgradeKeeper *upgradeKeeper.Keeper - - // IBC - IBCKeeper *ibcKeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCFeeKeeper ibcFeeKeeper.Keeper - IBCTransferKeeper ibcTransferKeeper.Keeper - ICAControllerKeeper icaControllerKeeper.Keeper - ICAHostKeeper icaHostKeeper.Keeper - PFMKeeper *pfmKeeper.Keeper - - // KYVE - BundlesKeeper bundlesKeeper.Keeper - DelegationKeeper delegationKeeper.Keeper - GlobalKeeper globalKeeper.Keeper - PoolKeeper poolKeeper.Keeper - QueryKeeper queryKeeper.Keeper - StakersKeeper stakersKeeper.Keeper - TeamKeeper teamKeeper.Keeper - - // ----- Scoped Keepers ----- - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilityKeeper.ScopedKeeper - ScopedIBCTransferKeeper capabilityKeeper.ScopedKeeper - ScopedICAControllerKeeper capabilityKeeper.ScopedKeeper - ScopedICAHostKeeper capabilityKeeper.ScopedKeeper -} - -// initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storeTypes.StoreKey) paramsKeeper.Keeper { - keeper := paramsKeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - keeper.Subspace(authTypes.ModuleName) - keeper.Subspace(bankTypes.ModuleName) - keeper.Subspace(crisisTypes.ModuleName) - keeper.Subspace(distributionTypes.ModuleName) - keeper.Subspace(govTypes.ModuleName) - keeper.Subspace(mintTypes.ModuleName) - keeper.Subspace(slashingTypes.ModuleName) - keeper.Subspace(stakingTypes.ModuleName) - - keeper.Subspace(ibcExported.ModuleName) - keeper.Subspace(ibcTransferTypes.ModuleName) - keeper.Subspace(icaControllerTypes.SubModuleName) - keeper.Subspace(icaHostTypes.SubModuleName) - keeper.Subspace(pfmTypes.ModuleName) - - return keeper -} diff --git a/app/legacy_modules.go b/app/legacy_modules.go deleted file mode 100644 index 874ac1de..00000000 --- a/app/legacy_modules.go +++ /dev/null @@ -1,176 +0,0 @@ -package app - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - // IBC Client - ibcClientSolomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" - ibcClientTendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - // IBC Core - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcPortTypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - ibcTypes "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibcKeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - // IBC Fee - ibcFee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" - ibcFeeKeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" - ibcFeeTypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" - // IBC Transfer - ibcTransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibcTransferKeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibcTransferTypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - // ICA - ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" - // ICA Controller - 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" - // ICA Host - 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" -) - -var ( - keys = sdk.NewKVStoreKeys( - ibcTypes.StoreKey, ibcFeeTypes.StoreKey, ibcTransferTypes.StoreKey, - icaControllerTypes.StoreKey, icaHostTypes.StoreKey, - ) - - memKeys = sdk.NewMemoryStoreKeys() - - subspaces = []string{ - ibcTypes.ModuleName, ibcFeeTypes.ModuleName, ibcTransferTypes.ModuleName, - icaControllerTypes.SubModuleName, icaHostTypes.SubModuleName, - } -) - -func (app *App) RegisterLegacyModules() { - // Register the additional keys. - app.MountKVStores(keys) - app.MountMemoryStores(memKeys) - - // Initialise the additional param subspaces. - for _, subspace := range subspaces { - app.ParamsKeeper.Subspace(subspace) - } - - // Keeper: IBC - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcTypes.ModuleName) - app.IBCKeeper = ibcKeeper.NewKeeper( - app.appCodec, - keys[ibcTypes.StoreKey], - app.GetSubspace(ibcTypes.ModuleName), - - app.StakingKeeper, - app.UpgradeKeeper, - scopedIBCKeeper, - ) - app.ScopedIBCKeeper = scopedIBCKeeper - - // Keeper: IBC Fee - app.IBCFeeKeeper = ibcFeeKeeper.NewKeeper( - app.appCodec, - keys[ibcFeeTypes.ModuleName], - - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - - app.AccountKeeper, - app.BankKeeper, - ) - - // Keeper: IBC Transfer - scopedIBCTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibcTransferTypes.ModuleName) - app.IBCTransferKeeper = ibcTransferKeeper.NewKeeper( - app.appCodec, - keys[ibcTransferTypes.StoreKey], - app.GetSubspace(ibcTransferTypes.ModuleName), - - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - - app.AccountKeeper, - app.BankKeeper, - scopedIBCTransferKeeper, - ) - app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper - - // Keeper: ICA Controller - scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icaControllerTypes.SubModuleName) - app.ICAControllerKeeper = icaControllerKeeper.NewKeeper( - app.appCodec, - keys[icaControllerTypes.StoreKey], - app.GetSubspace(icaControllerTypes.SubModuleName), - - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - - scopedICAControllerKeeper, - app.MsgServiceRouter(), - ) - app.ScopedICAControllerKeeper = scopedICAControllerKeeper - - // Keeper: ICA Host - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icaHostTypes.SubModuleName) - app.ICAHostKeeper = icaHostKeeper.NewKeeper( - app.appCodec, - keys[icaHostTypes.StoreKey], - app.GetSubspace(icaHostTypes.SubModuleName), - - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - - app.AccountKeeper, - scopedICAHostKeeper, - app.MsgServiceRouter(), - ) - app.ScopedICAHostKeeper = scopedICAHostKeeper - - // IBC: Create a router. - var ibcTransferStack ibcPortTypes.IBCModule - ibcTransferStack = ibcTransfer.NewIBCModule(app.IBCTransferKeeper) - ibcTransferStack = ibcFee.NewIBCMiddleware(ibcTransferStack, app.IBCFeeKeeper) - - var icaControllerStack ibcPortTypes.IBCModule - icaControllerStack = icaController.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper) - icaControllerStack = ibcFee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) - - var icaHostStack ibcPortTypes.IBCModule - icaHostStack = icaHost.NewIBCModule(app.ICAHostKeeper) - icaHostStack = ibcFee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper) - - ibcRouter := ibcPortTypes.NewRouter() - ibcRouter.AddRoute(ibcTransferTypes.ModuleName, ibcTransferStack). - AddRoute(icaControllerTypes.SubModuleName, icaControllerStack). - AddRoute(icaHostTypes.SubModuleName, icaHostStack) - app.IBCKeeper.SetRouter(ibcRouter) - - // TODO(rapha): fix this - // app.GovKeeper.SetProtocolStakingKeeper(app.StakersKeeper) - - // Register modules and interfaces/services. - legacyModules := []module.AppModule{ - ibc.NewAppModule(app.IBCKeeper), - ibcFee.NewAppModule(app.IBCFeeKeeper), - ibcTransfer.NewAppModule(app.IBCTransferKeeper), - ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), - } - if err := app.RegisterModules(legacyModules...); err != nil { - panic(err) - } - - for _, m := range legacyModules { - if s, ok := m.(module.HasServices); ok { - s.RegisterServices(app.Configurator()) - } - } - - ibcClientSolomachine.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) - ibcClientTendermint.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) -} diff --git a/x/global/abci_test.go b/x/global/abci_test.go index 54725ae9..b8823bc8 100644 --- a/x/global/abci_test.go +++ b/x/global/abci_test.go @@ -28,7 +28,7 @@ TEST CASES - DeductFeeDecorator var _ = Describe("AbciEndBlocker", Ordered, func() { s := i.NewCleanChain() encodingConfig := BuildEncodingConfig() - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) accountBalanceBefore := s.GetBalanceFromAddress(i.DUMMY[0]) totalSupplyBefore := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() @@ -43,7 +43,7 @@ var _ = Describe("AbciEndBlocker", Ordered, func() { accountBalanceBefore = s.GetBalanceFromAddress(i.DUMMY[0]) totalSupplyBefore = s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) }) AfterEach(func() { diff --git a/x/global/ante_test.go b/x/global/ante_test.go index 785407e7..2d045d99 100644 --- a/x/global/ante_test.go +++ b/x/global/ante_test.go @@ -42,7 +42,7 @@ TEST CASES - DeductFeeDecorator var _ = Describe("DeductFeeDecorator", Ordered, func() { s := i.NewCleanChain() encodingConfig := BuildEncodingConfig() - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) denom := s.App().StakingKeeper.BondDenom(s.Ctx()) accountBalanceBefore := s.GetBalanceFromAddress(i.DUMMY[0]) @@ -52,7 +52,7 @@ var _ = Describe("DeductFeeDecorator", Ordered, func() { s = i.NewCleanChain() encodingConfig = BuildEncodingConfig() denom = s.App().StakingKeeper.BondDenom(s.Ctx()) - dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) }) AfterEach(func() { @@ -61,7 +61,7 @@ var _ = Describe("DeductFeeDecorator", Ordered, func() { It("Invalid transaction.", func() { // ARRANGE - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) // ACT _, err := dfd.AnteHandle(s.Ctx(), &InvalidTx{}, false, AnteNextFn) @@ -72,7 +72,7 @@ var _ = Describe("DeductFeeDecorator", Ordered, func() { It("consensusGasPrice = 0.0; validatorGasPrice = 0.0 - deliverTX", func() { // ARRANGE - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) denom := s.App().StakingKeeper.BondDenom(s.Ctx()) tx := BuildTestTx(math.ZeroInt(), denom, i.DUMMY[0], encodingConfig) @@ -91,7 +91,7 @@ var _ = Describe("DeductFeeDecorator", Ordered, func() { It("consensusGasPrice = 0.0; validatorGasPrice = 0.0 - checkTX", func() { // ARRANGE - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) denom := s.App().StakingKeeper.BondDenom(s.Ctx()) tx := BuildTestTx(math.ZeroInt(), denom, i.DUMMY[0], encodingConfig) @@ -318,7 +318,7 @@ var _ = Describe("GasAdjustmentDecorator", Ordered, func() { txBuilder := encodingConfig.TxConfig.NewTxBuilder() tx := txBuilder.GetTx() - gad := global.NewGasAdjustmentDecorator(s.App().GlobalKeeper) + gad := global.NewGasAdjustmentDecorator(*s.App().GlobalKeeper) // ACT _, err := gad.AnteHandle(s.Ctx(), tx, false, AnteNextFn) @@ -336,7 +336,7 @@ var _ = Describe("GasAdjustmentDecorator", Ordered, func() { _ = txBuilder.SetMsgs(&msg) tx := txBuilder.GetTx() - gad := global.NewGasAdjustmentDecorator(s.App().GlobalKeeper) + gad := global.NewGasAdjustmentDecorator(*s.App().GlobalKeeper) // ACT _, err := gad.AnteHandle(s.Ctx(), tx, false, AnteNextFn) @@ -354,7 +354,7 @@ var _ = Describe("GasAdjustmentDecorator", Ordered, func() { _ = txBuilder.SetMsgs(&msg) tx := txBuilder.GetTx() - gad := global.NewGasAdjustmentDecorator(s.App().GlobalKeeper) + gad := global.NewGasAdjustmentDecorator(*s.App().GlobalKeeper) // ACT _, err := gad.AnteHandle(s.Ctx(), tx, false, AnteNextFn) @@ -373,7 +373,7 @@ var _ = Describe("GasAdjustmentDecorator", Ordered, func() { _ = txBuilder.SetMsgs(&firstMsg, &secondMsg) tx := txBuilder.GetTx() - gad := global.NewGasAdjustmentDecorator(s.App().GlobalKeeper) + gad := global.NewGasAdjustmentDecorator(*s.App().GlobalKeeper) // ACT _, err := gad.AnteHandle(s.Ctx(), tx, false, AnteNextFn) @@ -393,7 +393,7 @@ var _ = Describe("GasAdjustmentDecorator", Ordered, func() { _ = txBuilder.SetMsgs(&firstMsg, &secondMsg, &thirdMsg) tx := txBuilder.GetTx() - gad := global.NewGasAdjustmentDecorator(s.App().GlobalKeeper) + gad := global.NewGasAdjustmentDecorator(*s.App().GlobalKeeper) // ACT _, err := gad.AnteHandle(s.Ctx(), tx, false, AnteNextFn) diff --git a/x/global/post_test.go b/x/global/post_test.go index 09c51ab8..8676c5f4 100644 --- a/x/global/post_test.go +++ b/x/global/post_test.go @@ -31,8 +31,8 @@ TEST CASES - RefundFeeDecorator var _ = Describe("RefundFeeDecorator", Ordered, func() { s := i.NewCleanChain() encodingConfig := BuildEncodingConfig() - rfd := global.NewRefundFeeDecorator(s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper) - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + rfd := global.NewRefundFeeDecorator(s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper) + dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) denom := s.App().StakingKeeper.BondDenom(s.Ctx()) accountBalanceBefore := s.GetBalanceFromAddress(i.DUMMY[0]) @@ -41,8 +41,8 @@ var _ = Describe("RefundFeeDecorator", Ordered, func() { s = i.NewCleanChain() accountBalanceBefore = s.GetBalanceFromAddress(i.DUMMY[0]) - rfd = global.NewRefundFeeDecorator(s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper) - dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, *s.App().StakingKeeper) + rfd = global.NewRefundFeeDecorator(s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper) + dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, *s.App().GlobalKeeper, *s.App().StakingKeeper) denom = s.App().StakingKeeper.BondDenom(s.Ctx()) diff --git a/x/query/keeper/keeper.go b/x/query/keeper/keeper.go index 51f5653c..e83c346e 100644 --- a/x/query/keeper/keeper.go +++ b/x/query/keeper/keeper.go @@ -44,7 +44,6 @@ func NewKeeper( poolKeeper types.PoolKeeper, stakerKeeper types.StakersKeeper, delegationKeeper types.DelegationKeeper, - // bundleKeeper types.BundlesKeeper, globalKeeper types.GlobalKeeper, govKeeper types.GovKeeper, ) *Keeper { @@ -60,12 +59,15 @@ func NewKeeper( poolKeeper: poolKeeper, stakerKeeper: stakerKeeper, delegationKeeper: delegationKeeper, - // bundleKeeper: bundleKeeper, - globalKeeper: globalKeeper, - govKeeper: govKeeper, + globalKeeper: globalKeeper, + govKeeper: govKeeper, } } +func (k *Keeper) SetBundlesKeeper(bundlesKeeper types.BundlesKeeper) { + k.bundleKeeper = bundlesKeeper +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/query/module.go b/x/query/module.go index cf745a62..8235b0a6 100644 --- a/x/query/module.go +++ b/x/query/module.go @@ -3,6 +3,7 @@ package query import ( "context" "encoding/json" + "fmt" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" @@ -153,6 +154,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid func init() { appmodule.Register(&modulev1.Module{}, appmodule.Provide(ProvideModule), + appmodule.Invoke(InvokeSetBundlesKeeper), ) } @@ -201,6 +203,20 @@ func ProvideModule(in QueryInputs) QueryOutputs { return QueryOutputs{QueryKeeper: queryKeeper, Module: m} } +func InvokeSetBundlesKeeper( + keeper *keeper.Keeper, + bundlesKeeper types.BundlesKeeper, +) error { + if keeper == nil { + return fmt.Errorf("keeper is nil") + } + if bundlesKeeper == nil { + return fmt.Errorf("bundlesKeeper is nil") + } + keeper.SetBundlesKeeper(bundlesKeeper) + return nil +} + // TODO(rapha): cleanup //type SubspaceInputs struct { // depinject.In diff --git a/x/query/types/expected_keepers.go b/x/query/types/expected_keepers.go index 3601e42e..04c98559 100644 --- a/x/query/types/expected_keepers.go +++ b/x/query/types/expected_keepers.go @@ -20,11 +20,18 @@ type GovKeeper interface { type BundlesKeeper interface { AssertCanVote(sdk.Context, uint64, string, string, string) error AssertCanPropose(sdk.Context, uint64, string, string, uint64) error - GetBundleProposal(sdk.Context, uint64) (bundlesTypes.BundleProposal, bool) + //GetBundleProposal(sdk.Context, uint64) (bundlesTypes.BundleProposal, bool) GetBundleVersionMap(sdk.Context) bundlesTypes.BundleVersionMap - GetFinalizedBundle(sdk.Context, uint64, uint64) (bundlesTypes.FinalizedBundle, bool) - GetFinalizedBundleByHeight(sdk.Context, uint64, uint64) (FinalizedBundle, bool) + //GetFinalizedBundle(sdk.Context, uint64, uint64) (bundlesTypes.FinalizedBundle, bool) + //GetFinalizedBundleByHeight(sdk.Context, uint64, uint64) (FinalizedBundle, bool) GetFinalizedBundleByIndex(sdk.Context, uint64, uint64) (FinalizedBundle, bool) + //GetPaginatedFinalizedBundleQuery(sdk.Context, *query.PageRequest, uint64) ([]FinalizedBundle, *query.PageResponse, error) + //GetParams(sdk.Context) bundlesTypes.Params + //GetVoteDistribution(sdk.Context, uint64) bundlesTypes.VoteDistribution + + GetBundleProposal(sdk.Context, uint64) (bundlesTypes.BundleProposal, bool) + GetFinalizedBundle(sdk.Context, uint64, uint64) (bundlesTypes.FinalizedBundle, bool) + //GetFinalizedBundleByHeight(sdk.Context, uint64, uint64) (bundlesTypes.FinalizedBundle, bool) GetPaginatedFinalizedBundleQuery(sdk.Context, *query.PageRequest, uint64) ([]FinalizedBundle, *query.PageResponse, error) GetParams(sdk.Context) bundlesTypes.Params GetVoteDistribution(sdk.Context, uint64) bundlesTypes.VoteDistribution diff --git a/x/stakers/keeper/exported_functions_test.go b/x/stakers/keeper/exported_functions_test.go index 3bb9fa44..cf12c2af 100644 --- a/x/stakers/keeper/exported_functions_test.go +++ b/x/stakers/keeper/exported_functions_test.go @@ -45,7 +45,7 @@ var _ = Describe("Protocol Governance Voting", Ordered, func() { s = i.NewCleanChain() // Create a test proposal. - proposeTx := CreateTestProposal(s.Ctx(), s.App().Keepers) + proposeTx := CreateTestProposal(s.Ctx(), s.App()) _ = s.RunTxSuccess(proposeTx) // Initialise a protocol validator. @@ -165,8 +165,8 @@ var _ = Describe("Protocol Governance Voting", Ordered, func() { }) }) -func CreateTestProposal(ctx sdk.Context, keepers kyveApp.Keepers) sdk.Msg { - minDeposit := keepers.GovKeeper.GetParams(ctx).MinDeposit +func CreateTestProposal(ctx sdk.Context, app *kyveApp.App) sdk.Msg { + minDeposit := app.GovKeeper.GetParams(ctx).MinDeposit proposal, _ := govTypes.NewMsgSubmitProposal( []sdk.Msg{}, minDeposit, i.DUMMY[0], "metadata", "title", "summary",