diff --git a/types/module/configurator.go b/types/module/configurator.go index 36092d7b5a98..0e766df2a13d 100644 --- a/types/module/configurator.go +++ b/types/module/configurator.go @@ -24,6 +24,12 @@ type Configurator interface { // RegisterMigration registers an in-place store migration for a module. The // handler is a migration script to perform in-place migrations from version // `forVersion` to version `forVersion+1`. + // + // EACH TIME a module's ConsensusVersion increments, a new migration MUST + // be registered using this function. If a migration handler is missing for + // a particular function, the upgrade logic (see RunMigrations function) + // will panic. If the ConsensusVersion bump does not introduce any store + // changes, then a no-op function must be registered here. RegisterMigration(moduleName string, forVersion uint64, handler MigrationHandler) error } @@ -79,9 +85,6 @@ func (c configurator) RegisterMigration(moduleName string, forVersion uint64, ha // version to another version. func (c configurator) runModuleMigrations(ctx sdk.Context, moduleName string, fromVersion, toVersion uint64) error { // No-op if toVersion is the initial version. - // Some modules don't have a store key (e.g. vesting), in this case, their - // ConsensusVersion will always stay at 1, and running migrations on - // those modules will be skipped on this line. if toVersion <= 1 { return nil } diff --git a/types/module/module_test.go b/types/module/module_test.go index 9dafb37566c2..630c57619245 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/golang/mock/gomock" "github.com/gorilla/mux" @@ -169,7 +168,6 @@ func TestManager_RegisterRoutes(t *testing.T) { func TestManager_RegisterQueryServices(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) - encCfg := simapp.MakeTestEncodingConfig() mockAppModule1 := mocks.NewMockAppModule(mockCtrl) mockAppModule2 := mocks.NewMockAppModule(mockCtrl) @@ -181,7 +179,7 @@ func TestManager_RegisterQueryServices(t *testing.T) { msgRouter := mocks.NewMockServer(mockCtrl) queryRouter := mocks.NewMockServer(mockCtrl) - cfg := module.NewConfigurator(encCfg.Marshaler, msgRouter, queryRouter, nil) + cfg := module.NewConfigurator(msgRouter, queryRouter) mockAppModule1.EXPECT().RegisterServices(cfg).Times(1) mockAppModule2.EXPECT().RegisterServices(cfg).Times(1)