Skip to content

Commit

Permalink
chore: pStake migration (#281)
Browse files Browse the repository at this point in the history
migration
  • Loading branch information
kruspy authored Jan 26, 2024
1 parent 1b5c9c8 commit ed9082f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ import (

"github.com/persistenceOne/persistenceCore/v11/app/keepers"
"github.com/persistenceOne/persistenceCore/v11/app/upgrades"
v11_2_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.2.0"
v11_3_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.3.0"
)

var (
DefaultNodeHome string
Upgrades = []upgrades.Upgrade{v11_2_0.Upgrade}
Upgrades = []upgrades.Upgrade{v11_3_0.Upgrade}
ModuleBasics = module.NewBasicManager(keepers.AppModuleBasics...)
)

Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/v11.3.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v11_3_0

import (
store "github.com/cosmos/cosmos-sdk/store/types"

"github.com/persistenceOne/persistenceCore/v11/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v11.3.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
},
}
64 changes: 64 additions & 0 deletions app/upgrades/v11.3.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package v11_3_0

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/persistenceOne/persistenceCore/v11/app/upgrades"
)

func CreateUpgradeHandler(args upgrades.UpgradeHandlerArgs) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("running upgrade handler")

for _, hc := range args.Keepers.LiquidStakeIBCKeeper.GetAllHostChains(ctx) {
switch hc.ChainId {
case "cosmoshub-4":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.80")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

case "osmosis-1":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.97")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

case "theta-testnet-001":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.9")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

case "osmo-test-5":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.95")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

case "dydx-test-4":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.95")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

case "gaia-1":
upperLimit, _ := sdk.NewDecFromStr("1.01")
lowerLimit, _ := sdk.NewDecFromStr("0.95")
hc.Params.UpperCValueLimit = upperLimit
hc.Params.LowerCValueLimit = lowerLimit
args.Keepers.LiquidStakeIBCKeeper.SetHostChain(ctx, hc)

}
}

return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}
4 changes: 2 additions & 2 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func TestPersistenceUpgradeBasic(t *testing.T) {
var (
chainName = "persistence"
upgradeRepo = PersistenceCoreImage.Repository
initialVersion = "v11.1.0"
initialVersion = "v11.2.0"
upgradeBranchVersion = PersistenceCoreImage.Version
upgradeName = "v11.2.0"
upgradeName = "v11.3.0"
)

CosmosChainUpgradeTest(
Expand Down

0 comments on commit ed9082f

Please sign in to comment.