Skip to content

Commit

Permalink
feat: migration and version chaning (#135)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
emidev98 and Greg Junge authored May 23, 2023
1 parent 458ba8a commit 792dcd3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
14 changes: 14 additions & 0 deletions app/upgrades/v2.4/upgrade.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
4 changes: 2 additions & 2 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/chain-upgrade-tester/chain-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -90,4 +90,4 @@ done
sleep 5
#
## run new node
$NEW_BINARY start --home $CHAIN_HOME
$NEW_BINARY start --home $CHAIN_HOME

0 comments on commit 792dcd3

Please sign in to comment.