From 792dcd3a2bfd201c5e172127fa9b56619b56d9a7 Mon Sep 17 00:00:00 2001 From: emidev98 <49301655+emidev98@users.noreply.github.com> Date: Tue, 23 May 2023 15:09:14 +0200 Subject: [PATCH] feat: migration and version chaning (#135) * feat: migration and version chaning * Update const.go * chore: release name * Update chain-upgrade.sh change version name in upgrade test --------- Co-authored-by: Greg Junge --- app/app.go | 5 +++++ app/config/const.go | 1 + app/upgrades/v2.4/upgrade.go | 14 ++++++++++++++ client/docs/config.json | 4 ++-- client/docs/swagger-ui/swagger.yaml | 4 ++-- scripts/chain-upgrade-tester/chain-upgrade.sh | 4 ++-- 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 app/upgrades/v2.4/upgrade.go diff --git a/app/app.go b/app/app.go index 704f8034..f07323b1 100644 --- a/app/app.go +++ b/app/app.go @@ -157,6 +157,7 @@ import ( v2_2_0 "github.com/terra-money/core/v2/app/upgrades/v2.2.0" v2_3_0 "github.com/terra-money/core/v2/app/upgrades/v2.3.0" + v2_4 "github.com/terra-money/core/v2/app/upgrades/v2.4" // unnamed import of statik for swagger UI support _ "github.com/terra-money/core/v2/client/docs/statik" @@ -1007,6 +1008,10 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) { terraappconfig.Upgrade2_3_0, v2_3_0.CreateUpgradeHandler(app.mm, app.configurator, app.TokenFactoryKeeper), ) + app.UpgradeKeeper.SetUpgradeHandler( + terraappconfig.Upgrade2_4, + v2_4.CreateUpgradeHandler(app.mm, app.configurator), + ) } // RegisterSwaggerAPI registers swagger route with API Server diff --git a/app/config/const.go b/app/config/const.go index 7952ea46..8ca434ef 100644 --- a/app/config/const.go +++ b/app/config/const.go @@ -43,4 +43,5 @@ const ( // UpgradeName gov proposal name Upgrade2_2_0 = "2.2.0" Upgrade2_3_0 = "2.3.0" + Upgrade2_4 = "v2.4" ) diff --git a/app/upgrades/v2.4/upgrade.go b/app/upgrades/v2.4/upgrade.go new file mode 100644 index 00000000..8add2f0c --- /dev/null +++ b/app/upgrades/v2.4/upgrade.go @@ -0,0 +1,14 @@ +package v2_4 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func CreateUpgradeHandler(mm *module.Manager, + cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } +} diff --git a/client/docs/config.json b/client/docs/config.json index 50ac0d52..0561e758 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -2,8 +2,8 @@ "swagger": "2.0", "info": { "title": "Terra Core Rest API", - "description": "Rest Interface for Terra Core v2.3.1 https://github.com/terra-money/core", - "version": "2.3.1" + "description": "Rest Interface for Terra Core v2.4 https://github.com/terra-money/core", + "version": "2.4" }, "apis": [ { diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 1806b819..dfb42616 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -1,8 +1,8 @@ swagger: '2.0' info: title: Terra Core Rest API - description: Rest Interface for Terra Core v2.3.1 https://github.com/terra-money/core - version: 2.3.1 + description: Rest Interface for Terra Core v2.4 https://github.com/terra-money/core + version: 2.4.0 paths: /terra/alliances: get: diff --git a/scripts/chain-upgrade-tester/chain-upgrade.sh b/scripts/chain-upgrade-tester/chain-upgrade.sh index cd57776b..423969a1 100644 --- a/scripts/chain-upgrade-tester/chain-upgrade.sh +++ b/scripts/chain-upgrade-tester/chain-upgrade.sh @@ -6,7 +6,7 @@ CHAIN_ID=pisco-1 CHAIN_HOME=.testnet ROOT=$(pwd) DENOM=uluna -SOFTWARE_UPGRADE_NAME="2.3.1" +SOFTWARE_UPGRADE_NAME="v2.4" GOV_PERIOD="10s" VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" @@ -90,4 +90,4 @@ done sleep 5 # ## run new node -$NEW_BINARY start --home $CHAIN_HOME \ No newline at end of file +$NEW_BINARY start --home $CHAIN_HOME