Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prepare v2 upgrade #245

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ An '!' indicates a state machine breaking change.

### Features

- ! (`x/bundles`) [#236](https://github.com/KYVENetwork/chain/pull/236) merkle_root bundles migration
- ! (`x/stakers`) [#209](https://github.com/KYVENetwork/chain/pull/209) Shared Staking: Consensus-validator stake is now used for the protocol.
- ! (`x/stakers`) [#210](https://github.com/KYVENetwork/chain/pull/210) Shared Staking: Pool specific commission and stake fraction.
- ! (`x/stakers`) [#211](https://github.com/KYVENetwork/chain/pull/211) Shared Staking: Maximum voting power per pool.

### Improvements

- (`x/stakers`) [#232](https://github.com/KYVENetwork/chain/pull/232) Shared Staking: Update stakers queries
- (deps) [#213](https://github.com/KYVENetwork/chain/pull/213) Bump to CosmosSDK v0.50.11 and cleanup deps.

### Bug Fixes
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ COMMIT := $(shell git log -1 --format='%H')
GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2)

# VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := v1.5.0
VERSION := v2.0.0

BUILD_TIME := 202407040800.00 # format [[CC]YY]MMDDhhmm[.ss]
BUILD_TIME := 202502100800.00 # format [[CC]YY]MMDDhhmm[.ss]

TEAM_ALLOCATION := 165000000000000
ifeq ($(ENV),kaon)
Expand All @@ -30,7 +30,8 @@ ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=kyve \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_FOUNDATION_STRING=$(TEAM_FOUNDATION_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_BCP_STRING=$(TEAM_BCP_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_ALLOCATION_STRING=$(TEAM_ALLOCATION) \
-X github.com/KYVENetwork/chain/x/team/types.TGE_STRING=$(TEAM_TGE)
-X github.com/KYVENetwork/chain/x/team/types.TGE_STRING=$(TEAM_TGE) \
-w -s
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -ldflags '$(ldflags)' -tags 'ledger' -trimpath -buildvcs=false
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
| Version | Supported |
|---------|--------------------|
| main | :white_check_mark: |
| v1.4.x | :white_check_mark: |
| < v1.4 | :x: |
| v1.5.x | :white_check_mark: |
| < v1.5 | :x: |

## Reporting a Vulnerability

Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ func New(
app.StakingKeeper,
app.BankKeeper,
app.BundlesKeeper,
app.GlobalKeeper,
app.MultiCoinRewardsKeeper,
app.PoolKeeper,
),
)

Expand Down
157 changes: 147 additions & 10 deletions app/upgrades/v2_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ package v2_0
import (
"context"
"fmt"
poolkeeper "github.com/KYVENetwork/chain/x/pool/keeper"

multicoinrewardskeeper "github.com/KYVENetwork/chain/x/multi_coin_rewards/keeper"
multicoinrewardstypes "github.com/KYVENetwork/chain/x/multi_coin_rewards/types"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"

bundleskeeper "github.com/KYVENetwork/chain/x/bundles/keeper"

"cosmossdk.io/math"

globalkeeper "github.com/KYVENetwork/chain/x/global/keeper"

"github.com/KYVENetwork/chain/x/stakers/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand Down Expand Up @@ -42,6 +48,9 @@ func CreateUpgradeHandler(
stakingKeeper *stakingkeeper.Keeper,
bankKeeper bankkeeper.Keeper,
bundlesKeeper bundleskeeper.Keeper,
globalKeeper globalkeeper.Keeper,
multiCoinRewardsKeeper multicoinrewardskeeper.Keeper,
poolKeeper *poolkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
Expand All @@ -53,7 +62,18 @@ func CreateUpgradeHandler(

// Run KYVE migrations
migrateProtocolStakers(sdkCtx, delegationKeeper, stakersKeeper, stakingKeeper, bankKeeper)
EnsureMultiCoinDistributionAccount(sdkCtx, accountKeeper)
EnsureMultiCoinDistributionAccount(sdkCtx, accountKeeper, multicoinrewardstypes.ModuleName)
EnsureMultiCoinDistributionAccount(sdkCtx, accountKeeper, multicoinrewardstypes.MultiCoinRewardsRedistributionAccountName)
AdjustGasConfig(sdkCtx, globalKeeper)

SetMultiCoinRewardsParams(sdkCtx, multiCoinRewardsKeeper)
if err := SetMultiCoinRewardsPolicy(sdkCtx, multiCoinRewardsKeeper); err != nil {
return migratedVersionMap, err
}

SetPoolParams(sdkCtx, poolKeeper)

// TODO set withdraw address

// Run Bundles Merkle Roots migrations
bundlesKeeper.SetBundlesMigrationUpgradeHeight(sdkCtx, uint64(sdkCtx.BlockHeight()))
Expand All @@ -64,21 +84,134 @@ func CreateUpgradeHandler(
}
}

func EnsureMultiCoinDistributionAccount(ctx sdk.Context, ak authkeeper.AccountKeeper) {
address := authTypes.NewModuleAddress(multicoinrewardstypes.MultiCoinRewardsRedistributionAccountName)
func SetMultiCoinRewardsParams(ctx sdk.Context, multiCoinRewardsKeeper multicoinrewardskeeper.Keeper) {
params := multiCoinRewardsKeeper.GetParams(ctx)
params.MultiCoinDistributionPendingTime = 60 * 60 * 24 * 14
// KYVE Public Good Funding address
params.MultiCoinDistributionPolicyAdminAddress = "kyve1t0uez3nn28ljnzlwndzxffyjuhean3edhtjee8"
multiCoinRewardsKeeper.SetParams(ctx, params)
}

func SetMultiCoinRewardsPolicy(ctx sdk.Context, multiCoinRewardsKeeper multicoinrewardskeeper.Keeper) error {
if ctx.ChainID() == "kyve-1" {
return multiCoinRewardsKeeper.MultiCoinDistributionPolicy.Set(ctx, multicoinrewardstypes.MultiCoinDistributionPolicy{
Entries: []*multicoinrewardstypes.MultiCoinDistributionDenomEntry{
{
Denom: "ibc/A59C9E368C043E72968615DE82D4AD4BC88E34E6F353262B6769781C07390E8A", // andromeda
PoolWeights: []*multicoinrewardstypes.MultiCoinDistributionPoolWeightEntry{
{
PoolId: 14,
Weight: math.LegacyMustNewDecFromStr("1"),
},
},
},
{
Denom: "ibc/F4E5517A3BA2E77906A0847014EBD39E010E28BEB4181378278144D22442DB91", // source
PoolWeights: []*multicoinrewardstypes.MultiCoinDistributionPoolWeightEntry{
{
PoolId: 11,
Weight: math.LegacyMustNewDecFromStr("1"),
},
{
PoolId: 12,
Weight: math.LegacyMustNewDecFromStr("1"),
},
},
},
{
Denom: "ibc/D0C5DCA29836D2FD5937714B21206DD8243E5E76B1D0F180741CCB43DCAC1584", // dydx
PoolWeights: []*multicoinrewardstypes.MultiCoinDistributionPoolWeightEntry{
{
PoolId: 13,
Weight: math.LegacyMustNewDecFromStr("1"),
},
},
},
{
Denom: "ibc/506478E08FB0A2D3B12D493E3B182572A3B0D7BD5DCBE71610D2F393DEDDF4CA", // xion
PoolWeights: []*multicoinrewardstypes.MultiCoinDistributionPoolWeightEntry{
{
PoolId: 16,
Weight: math.LegacyMustNewDecFromStr("1"),
},
{
PoolId: 17,
Weight: math.LegacyMustNewDecFromStr("1"),
},
},
},
{
Denom: "ibc/7D5A9AE91948931279BA58A04FBEB9BF4F7CA059F7D4BDFAC6C3C43705973E1E", // lava
PoolWeights: []*multicoinrewardstypes.MultiCoinDistributionPoolWeightEntry{
{
PoolId: 18,
Weight: math.LegacyMustNewDecFromStr("1"),
},
},
},
},
})
}

return nil
}

func SetPoolParams(ctx sdk.Context, poolKeeper *poolkeeper.Keeper) {
params := poolKeeper.GetParams(ctx)

// TODO: set new mainnet inflation split

poolKeeper.SetParams(ctx, params)
}

func AdjustGasConfig(ctx sdk.Context, globalKeeper globalkeeper.Keeper) {
params := globalKeeper.GetParams(ctx)
params.MinGasPrice = math.LegacyMustNewDecFromStr("2")
params.GasAdjustments = []globalTypes.GasAdjustment{
{
Type: "/cosmos.staking.v1beta1.MsgCreateValidator",
Amount: 50000000,
},
{
Type: "/kyve.funders.v1beta1.MsgCreateFunder",
Amount: 50000000,
},
}
params.GasRefunds = []globalTypes.GasRefund{
{
Type: "kyve.bundles.v1beta1.MsgSubmitBundleProposal",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
{
Type: "kyve.bundles.v1beta1.MsgVoteBundleProposal",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
{
Type: "kyve.bundles.v1beta1.MsgSkipUploaderRole",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
{
Type: "kyve.bundles.v1beta1.MsgClaimUploaderRole",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
}
globalKeeper.SetParams(ctx, params)
}

func EnsureMultiCoinDistributionAccount(ctx sdk.Context, ak authkeeper.AccountKeeper, name string) {
address := authTypes.NewModuleAddress(name)
account := ak.GetAccount(ctx, address)

if account == nil {
// account doesn't exist, initialise a new module account.
newAcc := authTypes.NewEmptyModuleAccount(multicoinrewardstypes.MultiCoinRewardsRedistributionAccountName)
account = ak.NewAccountWithAddress(ctx, newAcc.GetAddress())
account = authTypes.NewEmptyModuleAccount(name)
ak.NewAccount(ctx, account)
} else {
// account exists, adjust it to a module account.
baseAccount := authTypes.NewBaseAccount(address, nil, account.GetAccountNumber(), 0)
account = authTypes.NewModuleAccount(baseAccount, multicoinrewardstypes.MultiCoinRewardsRedistributionAccountName)
account = authTypes.NewModuleAccount(baseAccount, name)
ak.SetAccount(ctx, account)
}

ak.SetAccount(ctx, account)
}

func migrateProtocolStakers(ctx sdk.Context, delegationKeeper delegationkeeper.Keeper,
Expand All @@ -89,9 +222,13 @@ func migrateProtocolStakers(ctx sdk.Context, delegationKeeper delegationkeeper.K
// Process current unbonding queue
delegationKeeper.FullyProcessDelegatorUnbondingQueue(ctx)

validatorMapping := ValidatorMappingsMainnet
if ctx.ChainID() == "kaon-1" {
var validatorMapping []ValidatorMapping
if ctx.ChainID() == "kyve-1" {
validatorMapping = ValidatorMappingsMainnet
} else if ctx.ChainID() == "kaon-1" {
validatorMapping = ValidatorMappingsKaon
} else if ctx.ChainID() == "korellia-2" {
validatorMapping = ValidatorMappingsKorellia
}

totalMigratedStake := uint64(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Validator-EU",
"consensus_address": "kyvevaloper1ghpmzfuggm7vcruyhfzrczl4aczy8gas8guslh",
"protocol_address": "kyve1zxlk3x50re5rhz985gcx8pm73whqnutg8ptnkz",
"proof_1": "A7A27728A03B1052B4B32D802920BBDB1E7B8FB549000A8ECE571F554513B59E",
"proof_2": "11B9EFAA0F3BF895F5E6D0FB4EAD66422552A31BADC1AE51C850AA1B8F59F518"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Validator-OVH",
"consensus_address": "kyvevaloper1af699xwpa6z6hek648p2c08hupd4j2knz22atl",
"protocol_address": "kyve1zuzyh0c0zvxry42dpqc79gu3ssukpfzg47uzrc",
"proof_1": "3131A86723482046AEA2034D23D4E125BDC749D72C00F16D47E99AD78CF6971A",
"proof_2": "54B6CC415720BD3FF573ACCC412043EF40399D5E1954ADA948F5044729B5436F"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Validator-US",
"consensus_address": "kyvevaloper1p6ctexlukvllyruwnyfhh2cvdwqggz95yzqxe9",
"protocol_address": "kyve1tg9rc2rwzu3ytvkdjh4mpe4k46n2eykpdv46nw",
"proof_1": "C05CBE4E1FB1006C9FCF12713889D69012532C436C5CD3B96715143F8C5191B0",
"proof_2": "56C4CCDA3953388FCB26B7C8841B9F4D1718DA571B833E54FF6523B959A15C55"
}
3 changes: 3 additions & 0 deletions app/upgrades/v2_0/validator_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {

ValidatorMappingsMainnet = parseDirectory("validator-proofs/mainnet")
ValidatorMappingsKaon = parseDirectory("validator-proofs/kaon")
ValidatorMappingsKorellia = parseDirectory("validator-proofs/korellia")
}

type ValidatorMapping struct {
Expand All @@ -47,3 +48,5 @@ type ValidatorMapping struct {
var ValidatorMappingsMainnet []ValidatorMapping

var ValidatorMappingsKaon []ValidatorMapping

var ValidatorMappingsKorellia []ValidatorMapping
Loading