refactor: modules should implement appmodule.AppModule (backport #18252) (#18255)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2023-10-25 12:55:55 +00:00 committed by GitHub
parent ef43d02a8d
commit 301ceca874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 11 deletions

View File

@ -207,29 +207,29 @@ func (mr *MockTxSelectorMockRecorder) Clear() *gomock.Call {
}
// SelectTxForProposal mocks base method.
func (m *MockTxSelector) SelectTxForProposal(maxTxBytes, maxBlockGas uint64, memTx types.Tx, txBz []byte) bool {
func (m *MockTxSelector) SelectTxForProposal(ctx context.Context, maxTxBytes, maxBlockGas uint64, memTx types.Tx, txBz []byte) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SelectTxForProposal", maxTxBytes, maxBlockGas, memTx, txBz)
ret := m.ctrl.Call(m, "SelectTxForProposal", ctx, maxTxBytes, maxBlockGas, memTx, txBz)
ret0, _ := ret[0].(bool)
return ret0
}
// SelectTxForProposal indicates an expected call of SelectTxForProposal.
func (mr *MockTxSelectorMockRecorder) SelectTxForProposal(maxTxBytes, maxBlockGas, memTx, txBz interface{}) *gomock.Call {
func (mr *MockTxSelectorMockRecorder) SelectTxForProposal(ctx, maxTxBytes, maxBlockGas, memTx, txBz interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectTxForProposal", reflect.TypeOf((*MockTxSelector)(nil).SelectTxForProposal), maxTxBytes, maxBlockGas, memTx, txBz)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectTxForProposal", reflect.TypeOf((*MockTxSelector)(nil).SelectTxForProposal), ctx, maxTxBytes, maxBlockGas, memTx, txBz)
}
// SelectedTxs mocks base method.
func (m *MockTxSelector) SelectedTxs() [][]byte {
func (m *MockTxSelector) SelectedTxs(ctx context.Context) [][]byte {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SelectedTxs")
ret := m.ctrl.Call(m, "SelectedTxs", ctx)
ret0, _ := ret[0].([][]byte)
return ret0
}
// SelectedTxs indicates an expected call of SelectedTxs.
func (mr *MockTxSelectorMockRecorder) SelectedTxs() *gomock.Call {
func (mr *MockTxSelectorMockRecorder) SelectedTxs(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectedTxs", reflect.TypeOf((*MockTxSelector)(nil).SelectedTxs))
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectedTxs", reflect.TypeOf((*MockTxSelector)(nil).SelectedTxs), ctx)
}

View File

@ -112,6 +112,30 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) InitGenesis(arg0, arg1, ar
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensions)(nil).InitGenesis), arg0, arg1, arg2)
}
// IsAppModule mocks base method.
func (m *MockAppModuleWithAllExtensions) IsAppModule() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsAppModule")
}
// IsAppModule indicates an expected call of IsAppModule.
func (mr *MockAppModuleWithAllExtensionsMockRecorder) IsAppModule() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAppModule", reflect.TypeOf((*MockAppModuleWithAllExtensions)(nil).IsAppModule))
}
// IsOnePerModuleType mocks base method.
func (m *MockAppModuleWithAllExtensions) IsOnePerModuleType() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsOnePerModuleType")
}
// IsOnePerModuleType indicates an expected call of IsOnePerModuleType.
func (mr *MockAppModuleWithAllExtensionsMockRecorder) IsOnePerModuleType() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOnePerModuleType", reflect.TypeOf((*MockAppModuleWithAllExtensions)(nil).IsOnePerModuleType))
}
// Name mocks base method.
func (m *MockAppModuleWithAllExtensions) Name() string {
m.ctrl.T.Helper()
@ -294,6 +318,30 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) InitGenesis(arg0, arg1
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).InitGenesis), arg0, arg1, arg2)
}
// IsAppModule mocks base method.
func (m *MockAppModuleWithAllExtensionsABCI) IsAppModule() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsAppModule")
}
// IsAppModule indicates an expected call of IsAppModule.
func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) IsAppModule() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAppModule", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).IsAppModule))
}
// IsOnePerModuleType mocks base method.
func (m *MockAppModuleWithAllExtensionsABCI) IsOnePerModuleType() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsOnePerModuleType")
}
// IsOnePerModuleType indicates an expected call of IsOnePerModuleType.
func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) IsOnePerModuleType() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOnePerModuleType", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).IsOnePerModuleType))
}
// Name mocks base method.
func (m *MockAppModuleWithAllExtensionsABCI) Name() string {
m.ctrl.T.Helper()

View File

@ -359,6 +359,30 @@ func (m *MockAppModule) EXPECT() *MockAppModuleMockRecorder {
return m.recorder
}
// IsAppModule mocks base method.
func (m *MockAppModule) IsAppModule() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsAppModule")
}
// IsAppModule indicates an expected call of IsAppModule.
func (mr *MockAppModuleMockRecorder) IsAppModule() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAppModule", reflect.TypeOf((*MockAppModule)(nil).IsAppModule))
}
// IsOnePerModuleType mocks base method.
func (m *MockAppModule) IsOnePerModuleType() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsOnePerModuleType")
}
// IsOnePerModuleType indicates an expected call of IsOnePerModuleType.
func (mr *MockAppModuleMockRecorder) IsOnePerModuleType() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOnePerModuleType", reflect.TypeOf((*MockAppModule)(nil).IsOnePerModuleType))
}
// Name mocks base method.
func (m *MockAppModule) Name() string {
m.ctrl.T.Helper()
@ -554,6 +578,30 @@ func (mr *MockHasABCIEndBlockMockRecorder) EndBlock(arg0 interface{}) *gomock.Ca
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlock", reflect.TypeOf((*MockHasABCIEndBlock)(nil).EndBlock), arg0)
}
// IsAppModule mocks base method.
func (m *MockHasABCIEndBlock) IsAppModule() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsAppModule")
}
// IsAppModule indicates an expected call of IsAppModule.
func (mr *MockHasABCIEndBlockMockRecorder) IsAppModule() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAppModule", reflect.TypeOf((*MockHasABCIEndBlock)(nil).IsAppModule))
}
// IsOnePerModuleType mocks base method.
func (m *MockHasABCIEndBlock) IsOnePerModuleType() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IsOnePerModuleType")
}
// IsOnePerModuleType indicates an expected call of IsOnePerModuleType.
func (mr *MockHasABCIEndBlockMockRecorder) IsOnePerModuleType() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOnePerModuleType", reflect.TypeOf((*MockHasABCIEndBlock)(nil).IsOnePerModuleType))
}
// Name mocks base method.
func (m *MockHasABCIEndBlock) Name() string {
m.ctrl.T.Helper()

View File

@ -18,20 +18,26 @@ import (
)
var (
_ appmodule.AppModule = coreAppModuleBasicAdaptor{}
_ AppModuleBasic = coreAppModuleBasicAdaptor{}
_ HasABCIGenesis = coreAppModuleBasicAdaptor{}
_ HasServices = coreAppModuleBasicAdaptor{}
)
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version
// of the SDK can use.
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModuleBasic {
// CoreAppModuleAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
func CoreAppModuleAdaptor(name string, module appmodule.AppModule) AppModule {
return coreAppModuleBasicAdaptor{
name: name,
module: module,
}
}
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModule {
return CoreAppModuleAdaptor(name, module)
}
type coreAppModuleBasicAdaptor struct {
name string
module appmodule.AppModule
@ -194,3 +200,7 @@ func (c coreAppModuleBasicAdaptor) RegisterServices(cfg Configurator) {
}
}
}
func (c coreAppModuleBasicAdaptor) IsOnePerModuleType() {}
func (c coreAppModuleBasicAdaptor) IsAppModule() {}

View File

@ -199,6 +199,8 @@ type HasABCIGenesis interface {
// its functionality has been moved to extension interfaces.
// Deprecated: use appmodule.AppModule with a combination of extension interfaes interfaces instead.
type AppModule interface {
appmodule.AppModule
AppModuleBasic
}
@ -288,6 +290,10 @@ func NewManager(modules ...AppModule) *Manager {
modulesStr := make([]string, 0, len(modules))
preBlockModulesStr := make([]string, 0)
for _, module := range modules {
if _, ok := module.(appmodule.AppModule); !ok {
panic(fmt.Sprintf("module %s does not implement appmodule.AppModule", module.Name()))
}
moduleMap[module.Name()] = module
modulesStr = append(modulesStr, module.Name())
if _, ok := module.(appmodule.HasPreBlocker); ok {