Skip to content

Commit

Permalink
chore: prepare v11.14.0 (#339)
Browse files Browse the repository at this point in the history
* prepare v11.14.0

* lint

* interchain-test
  • Loading branch information
puneet2019 authored Jul 2, 2024
1 parent ee7ad6f commit 8d68d5e
Show file tree
Hide file tree
Showing 5 changed files with 107 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,13 +56,13 @@ import (

"github.com/persistenceOne/persistenceCore/v11/app/keepers"
"github.com/persistenceOne/persistenceCore/v11/app/upgrades"
v11_13_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.13.0"
v11_14_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.14.0"
"github.com/persistenceOne/persistenceCore/v11/client/docs"
)

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

Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v11.14.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_14_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.14.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
55 changes: 55 additions & 0 deletions app/upgrades/v11.14.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package v11_14_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/pstake-native/v2/x/liquidstakeibc/keeper"
liquidstakeibctypes "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/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 module migrations...")

RemoveStargazeUnbondedBalance(ctx, args.Keepers.LiquidStakeIBCKeeper)

return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}

func RemoveStargazeUnbondedBalance(ctx sdk.Context, liquidStakeIBCKeeper *keeper.Keeper) {
ctx.Logger().Info("starting to move tokens...")

// as per https://github.com/persistenceOne/pstake-native/issues/853
chainID := "stargaze-1"
epoch := int64(582)
stkAmt := sdk.NewCoin("stk/ustars", sdk.NewInt(60621412694))
unbondAmt := sdk.NewCoin("ustars", sdk.NewInt(62810179898))
refillerAddr := "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt"

ctx.Logger().Info("set user unbonding...")
liquidStakeIBCKeeper.SetUserUnbonding(ctx, &liquidstakeibctypes.UserUnbonding{
ChainId: chainID,
EpochNumber: epoch,
Address: refillerAddr,
StkAmount: stkAmt,
UnbondAmount: unbondAmt,
})

ctx.Logger().Info("set epoch unbonding...")
liquidStakeIBCKeeper.SetUnbonding(ctx, &liquidstakeibctypes.Unbonding{
ChainId: chainID,
EpochNumber: epoch,
MatureTime: ctx.BlockTime(),
BurnAmount: stkAmt,
UnbondAmount: unbondAmt,
IbcSequenceId: "",
State: 2,
})

ctx.Logger().Info("done remove stargaze unbonded balance...")

}
30 changes: 30 additions & 0 deletions app/upgrades/v11.14.0/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package v11_14_0_test

import (
"testing"

"github.com/CosmWasm/wasmd/x/wasm"
dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

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

func TestRemoveStargazeUnbondedBalance(t *testing.T) {
testApp := app.NewApplication(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(""), []wasm.Option{})
ctx := testApp.NewContext(true, tmproto.Header{})
v11_14_0.RemoveStargazeUnbondedBalance(ctx, testApp.LiquidStakeIBCKeeper)

unbonding, ok := testApp.LiquidStakeIBCKeeper.GetUnbonding(ctx, "stargaze-1", 582)
require.True(t, ok)
require.Equal(t, types.NewInt(62810179898), unbonding.UnbondAmount.Amount)

userUnbonding, ok := testApp.LiquidStakeIBCKeeper.GetUserUnbonding(ctx, "stargaze-1", "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt", 582)
require.True(t, ok)
require.Equal(t, types.NewInt(62810179898), userUnbonding.UnbondAmount.Amount)
}
4 changes: 2 additions & 2 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const (
func TestPersistenceUpgradeBasic(t *testing.T) {
var (
chainName = "persistence"
initialVersion = "v11.12.0"
upgradeName = "v11.13.0"
initialVersion = "v11.13.0"
upgradeName = "v11.14.0"
upgradeRepo = PersistenceCoreImage.Repository
upgradeBranchVersion = PersistenceCoreImage.Version
)
Expand Down

0 comments on commit 8d68d5e

Please sign in to comment.