diff --git a/ante/gov_ante_test.go b/ante/gov_ante_test.go index 9f3b0ceb9d1..79a147f200e 100644 --- a/ante/gov_ante_test.go +++ b/ante/gov_ante_test.go @@ -70,7 +70,7 @@ func (s *GovAnteHandlerTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { {"Failing proposal", "the purpose of this proposal is to fail", govv1beta1.ProposalTypeText, testAddr, insufficientCoins, false}, } - decorator := ante.NewGovPreventSpamDecorator(s.app.AppCodec(), &s.app.GovKeeper) + decorator := ante.NewGovPreventSpamDecorator(s.app.AppCodec(), s.app.GovKeeper) for _, tc := range tests { content, _ := govv1beta1.ContentFromProposalType(tc.title, tc.description, tc.proposalType) diff --git a/app/app.go b/app/app.go index 8ed48e7eb1a..6f1831cdebf 100644 --- a/app/app.go +++ b/app/app.go @@ -225,7 +225,7 @@ func NewGaiaApp( }, Codec: appCodec, IBCkeeper: app.IBCKeeper, - GovKeeper: &app.GovKeeper, + GovKeeper: app.GovKeeper, GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), StakingKeeper: app.StakingKeeper, // If TxFeeChecker is nil the default ante TxFeeChecker is used diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index b96ab415553..966fc1beca5 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -89,7 +89,7 @@ type AppKeepers struct { SlashingKeeper slashingkeeper.Keeper MintKeeper mintkeeper.Keeper DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper + GovKeeper *govkeeper.Keeper CrisisKeeper *crisiskeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper @@ -286,35 +286,9 @@ func NewAppKeeper( appKeepers.ScopedIBCKeeper, ) - // EvidenceKeeper must be created before ProviderKeeper - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, - appKeepers.keys[evidencetypes.StoreKey], - appKeepers.StakingKeeper, - appKeepers.SlashingKeeper, - ) - // If evidence needs to be handled for the app, set routes in router here and seal - appKeepers.EvidenceKeeper = *evidenceKeeper - - // 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(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)). - AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper)) - + // provider depends on gov, so gov must be registered first govConfig := govtypes.DefaultConfig() - /* - Example of setting gov params: - govConfig.MaxMetadataLen = 10000 - */ - - govKeeper := govkeeper.NewKeeper( + appKeepers.GovKeeper = govkeeper.NewKeeper( appCodec, appKeepers.keys[govtypes.StoreKey], appKeepers.AccountKeeper, @@ -325,16 +299,6 @@ func NewAppKeeper( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // Set legacy router for backwards compatibility with gov v1beta1 - govKeeper.SetLegacyRouter(govRouter) - - // appKeepers.GovKeeper = *govKeeper - appKeepers.GovKeeper = *govKeeper.SetHooks( - govtypes.NewMultiGovHooks( - // register the governance hooks - ), - ) - appKeepers.ProviderKeeper = ibcproviderkeeper.NewKeeper( appCodec, appKeepers.keys[providertypes.StoreKey], @@ -355,6 +319,35 @@ func NewAppKeeper( appKeepers.ProviderModule = ibcprovider.NewAppModule(&appKeepers.ProviderKeeper, appKeepers.GetSubspace(providertypes.ModuleName)) + // 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(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)). + AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper)) + + // Set legacy router for backwards compatibility with gov v1beta1 + appKeepers.GovKeeper.SetLegacyRouter(govRouter) + + // appKeepers.GovKeeper = *govKeeper + appKeepers.GovKeeper = appKeepers.GovKeeper.SetHooks( + appKeepers.ProviderKeeper.Hooks(), + ) + + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + appKeepers.keys[evidencetypes.StoreKey], + appKeepers.StakingKeeper, + appKeepers.SlashingKeeper, + ) + // If evidence needs to be handled for the app, set routes in router here and seal + appKeepers.EvidenceKeeper = *evidenceKeeper + // ICA Host keeper appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, diff --git a/app/modules.go b/app/modules.go index 23620359bc2..ba3be8ab087 100644 --- a/app/modules.go +++ b/app/modules.go @@ -131,7 +131,7 @@ func appModules( bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), - gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), @@ -164,7 +164,7 @@ func simulationModules( bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),