Skip to content

Commit

Permalink
Merge pull request #747 from comdex-official/v10handlertest
Browse files Browse the repository at this point in the history
test net v0.10.1 upgrade handler
  • Loading branch information
dheerajkd30 authored Apr 19, 2023
2 parents 5bec412 + d81992c commit e1885d3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 53 deletions.
57 changes: 4 additions & 53 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/gorilla/mux"
"github.com/spf13/cast"

icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
"github.com/rakyll/statik/fs"

ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
Expand Down Expand Up @@ -166,12 +165,7 @@ import (

cwasm "github.com/comdex-official/comdex/app/wasm"

mv10 "github.com/comdex-official/comdex/app/upgrades/mainnet/v10"
mv5 "github.com/comdex-official/comdex/app/upgrades/mainnet/v5"
mv6 "github.com/comdex-official/comdex/app/upgrades/mainnet/v6"
mv7 "github.com/comdex-official/comdex/app/upgrades/mainnet/v7"
mv8 "github.com/comdex-official/comdex/app/upgrades/mainnet/v8"
mv9 "github.com/comdex-official/comdex/app/upgrades/mainnet/v9"
tv10 "github.com/comdex-official/comdex/app/upgrades/testnet/v10"
)

const (
Expand Down Expand Up @@ -1218,8 +1212,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {

func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
mv10.UpgradeName,
mv10.CreateUpgradeHandlerV10(a.mm, a.configurator, a.LiquidityKeeper, a.AssetKeeper, a.BankKeeper, a.AccountKeeper, a.Rewardskeeper, a.ICAHostKeeper),
tv10.UpgradeName,
tv10.CreateUpgradeHandlerV10(a.mm, a.configurator),
)
// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand All @@ -1241,51 +1235,8 @@ func (a *App) registerUpgradeHandlers() {

func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *storetypes.StoreUpgrades) *storetypes.StoreUpgrades {
switch {
// prepare store for main net upgrade v5.0.0
case upgradeInfo.Name == mv5.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{
assettypes.ModuleName,
auctiontypes.ModuleName,
bandoraclemoduletypes.ModuleName,
collectortypes.ModuleName,
esmtypes.ModuleName,
liquidationtypes.ModuleName,
liquiditytypes.ModuleName,
lockertypes.ModuleName,
markettypes.ModuleName,
rewardstypes.ModuleName,
tokenminttypes.ModuleName,
vaulttypes.ModuleName,
feegrant.ModuleName,
icacontrollertypes.StoreKey,
icahosttypes.StoreKey,
authz.ModuleName,
},
}
case upgradeInfo.Name == mv6.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{"lendV1"},
Added: []string{
lendtypes.ModuleName,
},
}
case upgradeInfo.Name == mv7.UpgradeName700 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == mv8.UpgradeName800 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == mv8.UpgradeName810 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == mv8.UpgradeName811 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == mv9.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == mv10.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
case upgradeInfo.Name == tv10.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}
}

Expand Down
15 changes: 15 additions & 0 deletions app/upgrades/testnet/v10/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v10

const (
UpgradeName = "v10.1.0"
UpgradeHeight = ""
UpgradeInfo = `'{
"binaries": {
"darwin/arm64":"",
"darwin/x86_64":"",
"linux/arm64":"",
"linux/x86_64":"",
"windows/x86_64":""
}
}'`
)
21 changes: 21 additions & 0 deletions app/upgrades/testnet/v10/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package v10

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 CreateUpgradeHandlerV10(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
vm, err := mm.RunMigrations(ctx, configurator, fromVM)

if err != nil {
return vm, err
}
return vm, err
}
}

0 comments on commit e1885d3

Please sign in to comment.