Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/hashicorp/g…
Browse files Browse the repository at this point in the history
…o-getter-1.7.4
  • Loading branch information
puneet2019 authored Jun 1, 2024
2 parents 7512ce7 + e3704ab commit 376783a
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 20 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_10_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.10.0"
v11_13_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.13.0"
"github.com/persistenceOne/persistenceCore/v11/client/docs"
)

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

Expand Down
4 changes: 3 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ func NewAppKeeper(
)
appKeepers.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
appKeepers.LiquidStakeIBCKeeper.NewEpochHooks(), appKeepers.RateSyncKeeper.EpochHooks(),
appKeepers.LiquidStakeIBCKeeper.NewEpochHooks(),
appKeepers.LiquidStakeKeeper.EpochHooks(),
appKeepers.RateSyncKeeper.EpochHooks(),
),
)

Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/testnet/v11.11.0-rc0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_11_0_rc0

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.11.0-rc0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
22 changes: 22 additions & 0 deletions app/upgrades/testnet/v11.11.0-rc0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v11_11_0_rc0

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 module migrations...")

err := args.Keepers.StakingKeeper.RefreshTotalLiquidStaked(ctx)
if err != nil {
ctx.Logger().Error("LSM failed to refresh total liquid staked", "error", err)
}

return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}
18 changes: 18 additions & 0 deletions app/upgrades/testnet/v11.12.0-rc0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_12_0_rc0

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.12.0-rc0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
53 changes: 53 additions & 0 deletions app/upgrades/testnet/v11.12.0-rc0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package v11_12_0_rc0

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
liquidstaketypes "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"

"github.com/persistenceOne/persistenceCore/v11/app/keepers"
"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...")

DelegateLiquidStakeRewards(ctx, args.Keepers)

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

func DelegateLiquidStakeRewards(ctx sdk.Context, k *keepers.AppKeepers) {
proxyAccBalance := k.LiquidStakeKeeper.GetProxyAccBalance(ctx, liquidstaketypes.LiquidStakeProxyAcc)
amountToDelegate := proxyAccBalance.Amount

whitelistedValidators := k.LiquidStakeKeeper.GetParams(ctx).WhitelistedValidators
whitelistedValsMap := liquidstaketypes.GetWhitelistedValsMap(whitelistedValidators)
activeLiquidVals := k.LiquidStakeKeeper.GetActiveLiquidValidators(ctx, whitelistedValsMap)

// currently auto compounding fee rate is zero, therefore fee logic is not added here.

err := k.LiquidStakeKeeper.LiquidDelegate(ctx, liquidstaketypes.LiquidStakeProxyAcc, activeLiquidVals, amountToDelegate, whitelistedValsMap)

// if liquid delegate fails then try to delegate to any one active validator
if err != nil {
ctx.Logger().Info("failed to liquid delegate, trying to delegate to any one validator...", "error", err.Error())

for _, lv := range activeLiquidVals {
val, _ := k.StakingKeeper.GetValidator(ctx, lv.GetOperator())
err2 := k.LiquidStakeKeeper.DelegateWithCap(ctx, liquidstaketypes.LiquidStakeProxyAcc, val, amountToDelegate)
if err2 != nil {
ctx.Logger().Info("failed to delegate", "validator", val.GetOperator(), "error", err2.Error())
// continue with next val
} else {
// successfully delegated, exit
return
}
}

ctx.Logger().Error("failed to delegate to any of active val set")
}
}
18 changes: 18 additions & 0 deletions app/upgrades/testnet/v11.13.0-rc0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_13_0_rc0

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.13.0-rc0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
15 changes: 15 additions & 0 deletions app/upgrades/testnet/v11.13.0-rc0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v11_13_0_rc0

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 module migrations...")
return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}
18 changes: 18 additions & 0 deletions app/upgrades/v11.11.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_11_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.11.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
22 changes: 22 additions & 0 deletions app/upgrades/v11.11.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v11_11_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 module migrations...")

err := args.Keepers.StakingKeeper.RefreshTotalLiquidStaked(ctx)
if err != nil {
ctx.Logger().Error("LSM failed to refresh total liquid staked", "error", err)
}

return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}
18 changes: 18 additions & 0 deletions app/upgrades/v11.12.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_12_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.12.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
53 changes: 53 additions & 0 deletions app/upgrades/v11.12.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package v11_12_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"
liquidstaketypes "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"

"github.com/persistenceOne/persistenceCore/v11/app/keepers"
"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...")

DelegateLiquidStakeRewards(ctx, args.Keepers)

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

func DelegateLiquidStakeRewards(ctx sdk.Context, k *keepers.AppKeepers) {
proxyAccBalance := k.LiquidStakeKeeper.GetProxyAccBalance(ctx, liquidstaketypes.LiquidStakeProxyAcc)
amountToDelegate := proxyAccBalance.Amount

whitelistedValidators := k.LiquidStakeKeeper.GetParams(ctx).WhitelistedValidators
whitelistedValsMap := liquidstaketypes.GetWhitelistedValsMap(whitelistedValidators)
activeLiquidVals := k.LiquidStakeKeeper.GetActiveLiquidValidators(ctx, whitelistedValsMap)

// currently auto compounding fee rate is zero, therefore fee logic is not added here.

err := k.LiquidStakeKeeper.LiquidDelegate(ctx, liquidstaketypes.LiquidStakeProxyAcc, activeLiquidVals, amountToDelegate, whitelistedValsMap)

// if liquid delegate fails then try to delegate to any one active validator
if err != nil {
ctx.Logger().Info("failed to liquid delegate, trying to delegate to any one validator...", "error", err.Error())

for _, lv := range activeLiquidVals {
val, _ := k.StakingKeeper.GetValidator(ctx, lv.GetOperator())
err2 := k.LiquidStakeKeeper.DelegateWithCap(ctx, liquidstaketypes.LiquidStakeProxyAcc, val, amountToDelegate)
if err2 != nil {
ctx.Logger().Info("failed to delegate", "validator", val.GetOperator(), "error", err2.Error())
// continue with next val
} else {
// successfully delegated, exit
return
}
}

ctx.Logger().Error("failed to delegate to any of active val set")
}
}
18 changes: 18 additions & 0 deletions app/upgrades/v11.13.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v11_13_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.13.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
16 changes: 16 additions & 0 deletions app/upgrades/v11.13.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package v11_13_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 module migrations...")
return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm)
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/cosmos/ibc-go/v7 v7.4.0
github.com/gorilla/mux v1.8.1
github.com/persistenceOne/persistence-sdk/v2 v2.2.0
github.com/persistenceOne/pstake-native/v2 v2.12.0
github.com/persistenceOne/pstake-native/v2 v2.15.0
github.com/prometheus/client_golang v1.16.0
github.com/skip-mev/pob v1.0.5
github.com/spf13/cast v1.6.0
Expand Down Expand Up @@ -61,7 +61,7 @@ require (
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down Expand Up @@ -1034,8 +1034,8 @@ github.com/persistenceOne/cosmos-sdk v0.47.10-lsm-rc0 h1:lbSQZUdaaKIpoSAznVESl0v
github.com/persistenceOne/cosmos-sdk v0.47.10-lsm-rc0/go.mod h1:Q/eHvXB0Awenk3NCh77NvjpeKGPigawFHIXlz2ayfos=
github.com/persistenceOne/persistence-sdk/v2 v2.2.0 h1:ZsBsy/HElkwjPXoASI7CptMFY9C3C/d27G+8bxFDzQw=
github.com/persistenceOne/persistence-sdk/v2 v2.2.0/go.mod h1:8VgozZWTPLMdlzsyiuGI0+vLo2fvGYSj/YKM9kiJwrI=
github.com/persistenceOne/pstake-native/v2 v2.12.0 h1:uuqZufMArylhtJvsLNVRWDhZRYUOz4xRmU+NVEryu6c=
github.com/persistenceOne/pstake-native/v2 v2.12.0/go.mod h1:mSAByOyYAXomcALxlwyVGKdFPwUkkyLOFs9OeTHKcuw=
github.com/persistenceOne/pstake-native/v2 v2.15.0 h1:GmsLLcAhkk71FqV2hwWH555MSLRsdFaR2kEnscUrKOE=
github.com/persistenceOne/pstake-native/v2 v2.15.0/go.mod h1:FcLbnTasZfKKKQJ6nzgzdkDqb3dUlIyraqcsj7DMTfE=
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
Expand Down
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.9.0"
upgradeName = "v11.10.0"
initialVersion = "v11.12.0"
upgradeName = "v11.13.0"
upgradeRepo = PersistenceCoreImage.Repository
upgradeBranchVersion = PersistenceCoreImage.Version
)
Expand Down
5 changes: 2 additions & 3 deletions interchaintest/liquidstake_stkxprt_globalcap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package interchaintest

import (
"context"
"encoding/json"
"testing"

"cosmossdk.io/math"
"encoding/json"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -15,6 +13,7 @@ import (
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
"github.com/stretchr/testify/require"
"testing"

"github.com/persistenceOne/persistenceCore/v11/interchaintest/helpers"
)
Expand Down
Loading

0 comments on commit 376783a

Please sign in to comment.