Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (backport #12603) #12638

Merged
merged 4 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove conflicts
  • Loading branch information
tac0turtle committed Jul 19, 2022
commit 99943f44c42f61885047465cd86c910a499a8d7f
44 changes: 0 additions & 44 deletions x/authz/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,50 +155,6 @@ func (AppModule) ConsensusVersion() uint64 { return 1 }

func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}

<<<<<<< HEAD
// EndBlock does nothing
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
=======
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(
provideModuleBasic,
provideModule,
),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type authzInputs struct {
depinject.In

Key *store.KVStoreKey
Cdc codec.Codec
AccountKeeper authz.AccountKeeper
BankKeeper authz.BankKeeper
Registry cdctypes.InterfaceRegistry
MsgServiceRouter *baseapp.MsgServiceRouter
}

type authzOutputs struct {
depinject.Out

AuthzKeeper keeper.Keeper
Module runtime.AppModuleWrapper
}

func provideModule(in authzInputs) authzOutputs {
k := keeper.NewKeeper(in.Key, in.Cdc, in.MsgServiceRouter, in.AccountKeeper)
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry)
return authzOutputs{AuthzKeeper: k, Module: runtime.WrapAppModule(m)}
>>>>>>> b65f3fe07 (feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (#12603))
}

// ____________________________________________________________________________

// AppModuleSimulation functions
Expand Down
73 changes: 0 additions & 73 deletions x/params/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,76 +139,3 @@ func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONCodec) json.RawMess

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

<<<<<<< HEAD
// BeginBlock performs a no-op.
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

// EndBlock performs a no-op.
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
=======
//
// New App Wiring Setup
//

func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(
provideModuleBasic,
provideModule,
provideSubspace,
))
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type paramsInputs struct {
depinject.In

KvStoreKey *store.KVStoreKey
TransientStoreKey *store.TransientStoreKey
Cdc codec.Codec
LegacyAmino *codec.LegacyAmino
}

type paramsOutputs struct {
depinject.Out

ParamsKeeper keeper.Keeper
BaseAppOption runtime.BaseAppOption
Module runtime.AppModuleWrapper
GovHandler govv1beta1.HandlerRoute
}

func provideModule(in paramsInputs) paramsOutputs {
k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.KvStoreKey, in.TransientStoreKey)
baseappOpt := func(app *baseapp.BaseApp) {
app.SetParamStore(k.Subspace(baseapp.Paramspace).WithKeyTable(types.ConsensusParamsKeyTable()))
}
m := runtime.WrapAppModule(NewAppModule(k))
govHandler := govv1beta1.HandlerRoute{RouteKey: proposal.RouterKey, Handler: NewParamChangeProposalHandler(k)}

return paramsOutputs{ParamsKeeper: k, BaseAppOption: baseappOpt, Module: m, GovHandler: govHandler}
}

type subspaceInputs struct {
depinject.In

Key depinject.ModuleKey
Keeper keeper.Keeper
KeyTables map[string]types.KeyTable
}

func provideSubspace(in subspaceInputs) types.Subspace {
moduleName := in.Key.Name()
kt, exists := in.KeyTables[moduleName]
if !exists {
return in.Keeper.Subspace(moduleName)
} else {
return in.Keeper.Subspace(moduleName).WithKeyTable(kt)
}
>>>>>>> b65f3fe07 (feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (#12603))
}
59 changes: 0 additions & 59 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,65 +167,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
BeginBlocker(ctx, req, am.keeper)
}

<<<<<<< HEAD
// EndBlock returns the end blocker for the slashing module. It returns no validator
// updates.
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

=======
// _____________________________________________________________________________________

func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(
provideModuleBasic,
provideModule,
),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type slashingInputs struct {
depinject.In

Key *store.KVStoreKey
Cdc codec.Codec
LegacyAmino *codec.LegacyAmino
AccountKeeper types.AccountKeeper `key:"cosmos.auth.v1.AccountKeeper"`
BankKeeper types.BankKeeper `key:"cosmos.bank.v1.Keeper"`
StakingKeeper types.StakingKeeper `key:"cosmos.staking.v1.Keeper"`

// LegacySubspace is used solely for migration of x/params managed parameters
LegacySubspace exported.Subspace
}

type slashingOutputs struct {
depinject.Out

Keeper keeper.Keeper
Module runtime.AppModuleWrapper
Hooks staking.StakingHooksWrapper
}

func provideModule(in slashingInputs) slashingOutputs {
k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.Key, in.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String())
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.LegacySubspace)
return slashingOutputs{
Keeper: k,
Module: runtime.WrapAppModule(m),
Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()},
}
}

// _____________________________________________________________________________________

>>>>>>> b65f3fe07 (feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (#12603))
// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the slashing module.
Expand Down
60 changes: 0 additions & 60 deletions x/upgrade/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,63 +129,3 @@ func (AppModule) ConsensusVersion() uint64 { return 1 }
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
BeginBlocker(am.keeper, ctx, req)
}

<<<<<<< HEAD
// EndBlock does nothing
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
=======
//
// New App Wiring Setup
//

func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(provideModuleBasic, provideModule),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type upgradeInputs struct {
depinject.In

Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec

AppOpts servertypes.AppOptions `optional:"true"`
}

type upgradeOutputs struct {
depinject.Out

UpgradeKeeper keeper.Keeper
Module runtime.AppModuleWrapper
GovHandler govv1beta1.HandlerRoute
}

func provideModule(in upgradeInputs) upgradeOutputs {
var (
homePath string
skipUpgradeHeights = make(map[int64]bool)
)

if in.AppOpts != nil {
for _, h := range cast.ToIntSlice(in.AppOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}

homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome))
}

// set the governance module account as the authority for conducting upgrades
k := keeper.NewKeeper(skipUpgradeHeights, in.Key, in.Cdc, homePath, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String())
m := NewAppModule(k)
gh := govv1beta1.HandlerRoute{RouteKey: types.RouterKey, Handler: NewSoftwareUpgradeProposalHandler(k)}

return upgradeOutputs{UpgradeKeeper: k, Module: runtime.WrapAppModule(m), GovHandler: gh}
>>>>>>> b65f3fe07 (feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces (#12603))
}