From 162f75579de1fca344cbd7e3f445aebf71560476 Mon Sep 17 00:00:00 2001 From: nghuyenthevinh2000 Date: Sat, 14 Jan 2023 09:17:11 +0700 Subject: [PATCH 1/3] move version map register to begin block --- .gitignore | 2 +- app/app.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c99f73ecc..433484e57 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ # Build bin -build +_build vendor .vendor-new build diff --git a/app/app.go b/app/app.go index 120332705..894433379 100644 --- a/app/app.go +++ b/app/app.go @@ -626,6 +626,12 @@ func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) a } } + // check if version map in upgrade keeper is nil + vm := app.UpgradeKeeper.GetModuleVersionMap(ctx) + if len(vm) == 0 { + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + } + return app.mm.BeginBlock(ctx, req) } @@ -640,7 +646,6 @@ func (app *TerraApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abc if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } From 24eb873f22b609d92dbaae9aaf491413e62b4671 Mon Sep 17 00:00:00 2001 From: Inon Man <121477599+inon-man@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:35:00 +0900 Subject: [PATCH 2/3] add UpgradeKeeper.SetModuleVersionMap to InitChainer again --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index 894433379..3dc5032c4 100644 --- a/app/app.go +++ b/app/app.go @@ -646,6 +646,7 @@ func (app *TerraApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abc if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } From 6bf1a7e8f2e6c048b2fe56a13b1edb9aa48fa557 Mon Sep 17 00:00:00 2001 From: Edward Kim Date: Tue, 17 Jan 2023 15:53:09 -0500 Subject: [PATCH 3/3] Added block height guards for the version map update --- app/app.go | 5 ++--- types/alias.go | 1 + types/fork/height.go | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 3dc5032c4..6fa9b6865 100644 --- a/app/app.go +++ b/app/app.go @@ -626,9 +626,8 @@ func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) a } } - // check if version map in upgrade keeper is nil - vm := app.UpgradeKeeper.GetModuleVersionMap(ctx) - if len(vm) == 0 { + // trigger SetModuleVersionMap in upgrade keeper at the VersionMapEnableHeight + if ctx.BlockHeight() == core.VersionMapEnableHeight { app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) } diff --git a/types/alias.go b/types/alias.go index 6a1b1ff7e..4268b523d 100644 --- a/types/alias.go +++ b/types/alias.go @@ -40,6 +40,7 @@ const ( BombayChainID = "bombay-12" SwapDisableForkHeight = fork.SwapDisableForkHeight SwapEnableForkHeight = fork.SwapEnableForkHeight + VersionMapEnableHeight = fork.VersionMapEnableHeight ) // functions aliases diff --git a/types/fork/height.go b/types/fork/height.go index 6b120d17f..332252cd7 100644 --- a/types/fork/height.go +++ b/types/fork/height.go @@ -4,3 +4,5 @@ package fork const SwapDisableForkHeight = 7607790 // SwapEnableForkHeight - renable IBC only, block height is approximately December 5th, 2022 const SwapEnableForkHeight = 10542500 +// VersionMapEnableHeight - set the version map to enable software upgrades, approximately February 14, 2023 +const VersionMapEnableHeight = 11543150