-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters