Skip to content

Commit

Permalink
chore: prepare v11.16.0 (#356)
Browse files Browse the repository at this point in the history
prepare v11.16.0
  • Loading branch information
puneet2019 authored Nov 28, 2024
1 parent 0eac5ea commit 5bde46d
Show file tree
Hide file tree
Showing 5 changed files with 109 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_15_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.15.0"
v11_16_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.16.0"
"github.com/persistenceOne/persistenceCore/v11/client/docs"
)

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

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

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
55 changes: 55 additions & 0 deletions app/upgrades/v11.16.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package v11_16_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 upgrade instructions...")
RemoveUnbondedBalance(ctx, args.Keepers.LiquidStakeIBCKeeper,
"cosmoshub-4", 636,
sdk.NewInt64Coin("stk/uatom", 1), sdk.NewInt64Coin("uatom", 3244853),
"persistence1dedp3sl7tu79s50ksfss42tddzh6w3xqzee4nt")
RemoveUnbondedBalance(ctx, args.Keepers.LiquidStakeIBCKeeper,
"chihuahua-1", 704,
sdk.NewInt64Coin("stk/uhuahua", 1), sdk.NewInt64Coin("uhuahua", 4445702485942),
"persistence174tktspp3r6x3ew9806tw8s9sx5ver87p6qdq9")

ctx.Logger().Info("completed upgrade instructions...")
ctx.Logger().Info("running module migrations...")
return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}

// as per https://github.com/persistenceOne/pstake-native/issues/853
func RemoveUnbondedBalance(ctx sdk.Context, liquidStakeIBCKeeper *keeper.Keeper,
chainID string, epoch int64, stkAmt sdk.Coin, unbondAmt sdk.Coin, refillerAddr string) {
ctx.Logger().Info("unbonding for", "chain-id", chainID, "epoch", epoch,
"unbondAmount", unbondAmt.String(), "refillerAddr", refillerAddr)
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,
})
}
32 changes: 32 additions & 0 deletions app/upgrades/v11.16.0/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v11_16_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"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

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

func TestRemoveUnbondedBalance(t *testing.T) {
testApp := app.NewApplication(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(""), []wasm.Option{})
ctx := testApp.NewContext(true, tmproto.Header{})
v11_16_0.RemoveUnbondedBalance(ctx, testApp.LiquidStakeIBCKeeper,
"chihuahua-1", 704, sdk.NewInt64Coin("stk/uhuahua", 5000000), sdk.NewInt64Coin("uhuahua", 5010101), "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt")

unbonding, ok := testApp.LiquidStakeIBCKeeper.GetUnbonding(ctx, "chihuahua-1", 704)
require.True(t, ok)
require.Equal(t, types.NewInt(5010101), unbonding.UnbondAmount.Amount)

userUnbonding, ok := testApp.LiquidStakeIBCKeeper.GetUserUnbonding(ctx, "chihuahua-1", "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt", 704)
require.True(t, ok)
require.Equal(t, types.NewInt(5010101), 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.14.0"
upgradeName = "v11.15.0"
initialVersion = "v11.15.0"
upgradeName = "v11.16.0"
upgradeRepo = PersistenceCoreImage.Repository
upgradeBranchVersion = PersistenceCoreImage.Version
)
Expand Down

0 comments on commit 5bde46d

Please sign in to comment.