From e53d49a7dc98289716ee01abfdf7ad059f9823ca Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 23 Nov 2021 11:36:22 +0100 Subject: [PATCH 1/2] fix: delete new modules from fromVM map to not skip init genesis --- app/app.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/app.go b/app/app.go index 82ed694217..b2c8f56914 100644 --- a/app/app.go +++ b/app/app.go @@ -573,11 +573,10 @@ func NewGaiaApp( for moduleName := range app.mm.Modules { fromVM[moduleName] = 1 } - // override versions for _new_ modules as to not skip InitGenesis - fromVM[authz.ModuleName] = 0 - fromVM[feegrant.ModuleName] = 0 - fromVM[routertypes.ModuleName] = 0 - + // delete new modules from the map, for _new_ modules as to not skip InitGenesis + delete(fromVM, authz.ModuleName) + delete(fromVM, feegrant.ModuleName) + delete(fromVM, routertypes.ModuleName) return app.mm.RunMigrations(ctx, app.configurator, fromVM) }, ) From 0dd70958a10b24703c09c43745611779f0e7970f Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 23 Nov 2021 11:45:18 +0100 Subject: [PATCH 2/2] fix: migrate auth module after staking --- app/app.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index b2c8f56914..7671528556 100644 --- a/app/app.go +++ b/app/app.go @@ -577,7 +577,20 @@ func NewGaiaApp( delete(fromVM, authz.ModuleName) delete(fromVM, feegrant.ModuleName) delete(fromVM, routertypes.ModuleName) - return app.mm.RunMigrations(ctx, app.configurator, fromVM) + + // make fromVM[authtypes.ModuleName] = 2 to skip the first RunMigrations for auth (because from version 2 to migration version 2 will not migrate) + fromVM[authtypes.ModuleName] = 2 + + // the first RunMigrations, which will migrate all the old modules except auth module + newVM, err := app.mm.RunMigrations(ctx, app.configurator, fromVM) + if err != nil { + return nil, err + } + // now update auth version back to 1, to make the second RunMigrations includes only auth + newVM[authtypes.ModuleName] = 1 + + // RunMigrations twice is just a way to make auth module's migrates after staking + return app.mm.RunMigrations(ctx, app.configurator, newVM) }, )