Skip to content

Commit a3d51b9

Browse files
authored
refactor: Remove useless stub BeginBlock/EndBlock methods (#853)
* 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
1 parent 06751bd commit a3d51b9

File tree

23 files changed

+38
-107
lines changed

23 files changed

+38
-107
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
5050

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

53+
### Removed
54+
* [\#853](https://github.com/line/lbm-sdk/pull/853) remove useless stub BeginBlock, EndBlock methods from modules below
55+
* ibc, authz, collection, feegrant, ibc, token, wasm
56+
5357
### Breaking Changes
5458
* (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API
5559

x/authz/module/module.go

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
153153
// ConsensusVersion implements AppModule/ConsensusVersion.
154154
func (AppModule) ConsensusVersion() uint64 { return 1 }
155155

156-
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}
157-
158156
// ____________________________________________________________________________
159157

160158
// AppModuleSimulation functions

x/bankplus/module.go

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
"github.com/line/lbm-sdk/x/bankplus/keeper"
1313
)
1414

15+
var (
16+
_ module.AppModule = AppModule{}
17+
_ module.AppModuleSimulation = AppModule{}
18+
)
19+
1520
type AppModule struct {
1621
bank.AppModule
1722

x/capability/abci.go

-21
This file was deleted.

x/capability/module.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
_ module.AppModule = AppModule{}
2828
_ module.AppModuleBasic = AppModuleBasic{}
2929
_ module.AppModuleSimulation = AppModule{}
30+
_ module.BeginBlockAppModule = AppModule{}
3031
)
3132

3233
// ----------------------------------------------------------------------------

x/collection/module/module.go

-8
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
136136

137137
// ConsensusVersion implements AppModule/ConsensusVersion.
138138
func (AppModule) ConsensusVersion() uint64 { return 1 }
139-
140-
// BeginBlock performs a no-op.
141-
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
142-
143-
// EndBlock performs a no-op.
144-
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
145-
return []abci.ValidatorUpdate{}
146-
}

x/crisis/module.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import (
2121
)
2222

2323
var (
24-
_ module.AppModule = AppModule{}
25-
_ module.AppModuleBasic = AppModuleBasic{}
24+
_ module.AppModule = AppModule{}
25+
_ module.AppModuleBasic = AppModuleBasic{}
26+
_ module.EndBlockAppModule = AppModule{}
2627
)
2728

2829
// Module init related flags

x/distribution/module.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
_ module.AppModule = AppModule{}
2828
_ module.AppModuleBasic = AppModuleBasic{}
2929
_ module.AppModuleSimulation = AppModule{}
30+
_ module.BeginBlockAppModule = AppModule{}
3031
)
3132

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

169-
// AppModuleSimulation functions
170-
171170
// GenerateGenesisState creates a randomized GenState of the distribution module.
172171
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
173172
simulation.RandomizedGenState(simState)

x/evidence/module.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
_ module.AppModule = AppModule{}
3030
_ module.AppModuleBasic = AppModuleBasic{}
3131
_ module.AppModuleSimulation = AppModule{}
32+
_ module.BeginBlockAppModule = AppModule{}
3233
)
3334

3435
// ----------------------------------------------------------------------------

x/feegrant/module/module.go

-6
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
171171
// ConsensusVersion implements AppModule/ConsensusVersion.
172172
func (AppModule) ConsensusVersion() uint64 { return 1 }
173173

174-
// EndBlock returns the end blocker for the feegrant module. It returns no validator
175-
// updates.
176-
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
177-
return []abci.ValidatorUpdate{}
178-
}
179-
180174
// AppModuleSimulation functions
181175

182176
// GenerateGenesisState creates a randomized GenState of the feegrant module.

x/foundation/module/module.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import (
1919
"github.com/line/lbm-sdk/x/foundation/keeper"
2020
)
2121

22-
var _ module.AppModuleBasic = AppModuleBasic{}
22+
var (
23+
_ module.AppModule = AppModule{}
24+
_ module.AppModuleBasic = AppModuleBasic{}
25+
_ module.BeginBlockAppModule = AppModule{}
26+
_ module.EndBlockAppModule = AppModule{}
27+
)
2328

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

7277
//____________________________________________________________________________
7378

74-
var _ module.AppModule = AppModule{}
75-
7679
// AppModule implements an application module for the foundation module.
7780
type AppModule struct {
7881
AppModuleBasic

x/gov/module.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var (
3030
_ module.AppModule = AppModule{}
3131
_ module.AppModuleBasic = AppModuleBasic{}
3232
_ module.AppModuleSimulation = AppModule{}
33+
_ module.EndBlockAppModule = AppModule{}
3334
)
3435

3536
// AppModuleBasic defines the basic application module used by the gov module.

x/ibc/applications/27-interchain-accounts/module.go

-9
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
188188

189189
// ConsensusVersion implements AppModule/ConsensusVersion.
190190
func (AppModule) ConsensusVersion() uint64 { return 1 }
191-
192-
// BeginBlock implements the AppModule interface
193-
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
194-
}
195-
196-
// EndBlock implements the AppModule interface
197-
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
198-
return []abci.ValidatorUpdate{}
199-
}

x/ibc/applications/transfer/module.go

-9
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
139139
// ConsensusVersion implements AppModule/ConsensusVersion.
140140
func (AppModule) ConsensusVersion() uint64 { return 1 }
141141

142-
// BeginBlock implements the AppModule interface
143-
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
144-
}
145-
146-
// EndBlock implements the AppModule interface
147-
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
148-
return []abci.ValidatorUpdate{}
149-
}
150-
151142
// AppModuleSimulation functions
152143

153144
// GenerateGenesisState creates a randomized GenState of the transfer module.

x/ibc/core/module.go

-6
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
170170
ibcclient.BeginBlocker(ctx, am.keeper.ClientKeeper)
171171
}
172172

173-
// EndBlock returns the end blocker for the ibc module. It returns no validator
174-
// updates.
175-
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
176-
return []abci.ValidatorUpdate{}
177-
}
178-
179173
// AppModuleSimulation functions
180174

181175
// GenerateGenesisState creates a randomized GenState of the ibc module.

x/ibc/testing/mock/mock.go

-9
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
138138

139139
// ConsensusVersion implements AppModule/ConsensusVersion.
140140
func (AppModule) ConsensusVersion() uint64 { return 1 }
141-
142-
// BeginBlock implements the AppModule interface
143-
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
144-
}
145-
146-
// EndBlock implements the AppModule interface
147-
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
148-
return []abci.ValidatorUpdate{}
149-
}

x/mint/module.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ var (
2626
_ module.AppModule = AppModule{}
2727
_ module.AppModuleBasic = AppModuleBasic{}
2828
_ module.AppModuleSimulation = AppModule{}
29+
_ module.BeginBlockAppModule = AppModule{}
2930
)
3031

3132
// AppModuleBasic defines the basic application module used by the mint module.
3233
type AppModuleBasic struct {
3334
cdc codec.Codec
3435
}
3536

36-
var _ module.AppModuleBasic = AppModuleBasic{}
37-
3837
// Name returns the mint module's name.
3938
func (AppModuleBasic) Name() string {
4039
return types.ModuleName

x/slashing/module.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ var (
2828
_ module.AppModule = AppModule{}
2929
_ module.AppModuleBasic = AppModuleBasic{}
3030
_ module.AppModuleSimulation = AppModule{}
31+
_ module.BeginBlockAppModule = AppModule{}
3132
)
3233

3334
// AppModuleBasic defines the basic application module used by the slashing module.
3435
type AppModuleBasic struct {
3536
cdc codec.Codec
3637
}
3738

38-
var _ module.AppModuleBasic = AppModuleBasic{}
39-
4039
// Name returns the slashing module's name.
4140
func (AppModuleBasic) Name() string {
4241
return types.ModuleName

x/staking/module.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ var (
2727
_ module.AppModule = AppModule{}
2828
_ module.AppModuleBasic = AppModuleBasic{}
2929
_ module.AppModuleSimulation = AppModule{}
30+
_ module.BeginBlockAppModule = AppModule{}
31+
_ module.EndBlockAppModule = AppModule{}
3032
)
3133

3234
// AppModuleBasic defines the basic application module used by the staking module.
3335
type AppModuleBasic struct {
3436
cdc codec.Codec
3537
}
3638

37-
var _ module.AppModuleBasic = AppModuleBasic{}
38-
3939
// Name returns the staking module's name.
4040
func (AppModuleBasic) Name() string {
4141
return types.ModuleName

x/stakingplus/module/module.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import (
1919
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
2020
)
2121

22-
var _ module.AppModuleBasic = AppModuleBasic{}
22+
var (
23+
_ module.AppModule = AppModule{}
24+
_ module.AppModuleBasic = AppModuleBasic{}
25+
_ module.BeginBlockAppModule = AppModule{}
26+
_ module.EndBlockAppModule = AppModule{}
27+
)
2328

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

3439
//____________________________________________________________________________
3540

36-
var _ module.AppModule = AppModule{}
37-
3841
// AppModule implements an application module for the stakingplus module.
3942
type AppModule struct {
4043
AppModuleBasic

x/token/module/module.go

-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
136136
// ConsensusVersion implements AppModule/ConsensusVersion.
137137
func (AppModule) ConsensusVersion() uint64 { return 1 }
138138

139-
// BeginBlock performs a no-op.
140-
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
141-
142-
// EndBlock performs a no-op.
143-
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
144-
return []abci.ValidatorUpdate{}
145-
}
146-
147139
//____________________________________________________________________________
148140

149141
// AppModuleSimulation functions

x/upgrade/module.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ func init() {
2323
}
2424

2525
var (
26-
_ module.AppModule = AppModule{}
27-
_ module.AppModuleBasic = AppModuleBasic{}
26+
_ module.AppModule = AppModule{}
27+
_ module.AppModuleBasic = AppModuleBasic{}
28+
_ module.BeginBlockAppModule = AppModule{}
2829
)
2930

3031
// AppModuleBasic implements the sdk.AppModuleBasic interface

x/wasm/module.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
)
2828

2929
var (
30-
_ module.AppModule = AppModule{}
31-
_ module.AppModuleBasic = AppModuleBasic{}
30+
_ module.AppModule = AppModule{}
31+
_ module.AppModuleBasic = AppModuleBasic{}
32+
_ module.AppModuleSimulation = AppModule{}
3233
)
3334

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

176-
// BeginBlock returns the begin blocker for the wasm module.
177-
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
178-
179-
// EndBlock returns the end blocker for the wasm module. It returns no validator
180-
// updates.
181-
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
182-
return []abci.ValidatorUpdate{}
183-
}
184-
185177
// ____________________________________________________________________________
186178

187179
// AppModuleSimulation functions

0 commit comments

Comments
 (0)