Skip to content

Commit

Permalink
refactor: Remove useless stub BeginBlock/EndBlock methods (#853)
Browse files Browse the repository at this point in the history
* refactor: Remove useless stub BeginBlock/EndBlock methods

* refactor: add statement which is only effective when compiling to check implementation meets some interfaces

* chore: update changelog
  • Loading branch information
jaeseung-bae authored Jan 5, 2023
1 parent 06751bd commit a3d51b9
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 107 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (x/foundation) [#834](https://github.com/line/lbm-sdk/pull/834) Apply foundation audit

### Removed
* [\#853](https://github.com/line/lbm-sdk/pull/853) remove useless stub BeginBlock, EndBlock methods from modules below
* ibc, authz, collection, feegrant, ibc, token, wasm

### Breaking Changes
* (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API

Expand Down
2 changes: 0 additions & 2 deletions x/authz/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

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

// ____________________________________________________________________________

// AppModuleSimulation functions
Expand Down
5 changes: 5 additions & 0 deletions x/bankplus/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
"github.com/line/lbm-sdk/x/bankplus/keeper"
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleSimulation = AppModule{}
)

type AppModule struct {
bank.AppModule

Expand Down
21 changes: 0 additions & 21 deletions x/capability/abci.go

This file was deleted.

1 change: 1 addition & 0 deletions x/capability/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
)

// ----------------------------------------------------------------------------
Expand Down
8 changes: 0 additions & 8 deletions x/collection/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw

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

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

// EndBlock performs a no-op.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
5 changes: 3 additions & 2 deletions x/crisis/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import (
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.EndBlockAppModule = AppModule{}
)

// Module init related flags
Expand Down
3 changes: 1 addition & 2 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the distribution module.
Expand Down Expand Up @@ -166,8 +167,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
BeginBlocker(ctx, req, am.keeper)
}

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the distribution module.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
simulation.RandomizedGenState(simState)
Expand Down
1 change: 1 addition & 0 deletions x/evidence/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
)

// ----------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions x/feegrant/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

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

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the feegrant module.
Expand Down
9 changes: 6 additions & 3 deletions x/foundation/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import (
"github.com/line/lbm-sdk/x/foundation/keeper"
)

var _ module.AppModuleBasic = AppModuleBasic{}
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.BeginBlockAppModule = AppModule{}
_ module.EndBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the foundation module.
type AppModuleBasic struct{}
Expand Down Expand Up @@ -71,8 +76,6 @@ func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry

//____________________________________________________________________________

var _ module.AppModule = AppModule{}

// AppModule implements an application module for the foundation module.
type AppModule struct {
AppModuleBasic
Expand Down
1 change: 1 addition & 0 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.EndBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the gov module.
Expand Down
9 changes: 0 additions & 9 deletions x/ibc/applications/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw

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

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

// EndBlock implements the AppModule interface
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
9 changes: 0 additions & 9 deletions x/ibc/applications/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

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

// EndBlock implements the AppModule interface
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the transfer module.
Expand Down
6 changes: 0 additions & 6 deletions x/ibc/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
ibcclient.BeginBlocker(ctx, am.keeper.ClientKeeper)
}

// EndBlock returns the end blocker for the ibc module. It returns no validator
// updates.
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the ibc module.
Expand Down
9 changes: 0 additions & 9 deletions x/ibc/testing/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw

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

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

// EndBlock implements the AppModule interface
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
3 changes: 1 addition & 2 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the mint module.
type AppModuleBasic struct {
cdc codec.Codec
}

var _ module.AppModuleBasic = AppModuleBasic{}

// Name returns the mint module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
Expand Down
3 changes: 1 addition & 2 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the slashing module.
type AppModuleBasic struct {
cdc codec.Codec
}

var _ module.AppModuleBasic = AppModuleBasic{}

// Name returns the slashing module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
Expand Down
4 changes: 2 additions & 2 deletions x/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.BeginBlockAppModule = AppModule{}
_ module.EndBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the staking module.
type AppModuleBasic struct {
cdc codec.Codec
}

var _ module.AppModuleBasic = AppModuleBasic{}

// Name returns the staking module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
Expand Down
9 changes: 6 additions & 3 deletions x/stakingplus/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import (
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
)

var _ module.AppModuleBasic = AppModuleBasic{}
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.BeginBlockAppModule = AppModule{}
_ module.EndBlockAppModule = AppModule{}
)

// AppModuleBasic defines the basic application module used by the stakingplus module.
type AppModuleBasic struct {
Expand All @@ -33,8 +38,6 @@ func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry

//____________________________________________________________________________

var _ module.AppModule = AppModule{}

// AppModule implements an application module for the stakingplus module.
type AppModule struct {
AppModuleBasic
Expand Down
8 changes: 0 additions & 8 deletions x/token/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

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

// EndBlock performs a no-op.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

//____________________________________________________________________________

// AppModuleSimulation functions
Expand Down
5 changes: 3 additions & 2 deletions x/upgrade/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ func init() {
}

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.BeginBlockAppModule = AppModule{}
)

// AppModuleBasic implements the sdk.AppModuleBasic interface
Expand Down
14 changes: 3 additions & 11 deletions x/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
)

// Module init related flags
Expand Down Expand Up @@ -173,15 +174,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(gs)
}

// BeginBlock returns the begin blocker for the wasm module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

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

// ____________________________________________________________________________

// AppModuleSimulation functions
Expand Down

0 comments on commit a3d51b9

Please sign in to comment.