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

Merged
merged 13 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ func New(
app.StakingKeeper,
app.BankKeeper,
app.BundlesKeeper,
app.GlobalKeeper,
app.MultiCoinRewardsKeeper,
),
)

Expand Down
72 changes: 62 additions & 10 deletions app/upgrades/v2_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import (
"context"
"fmt"

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 +47,8 @@ func CreateUpgradeHandler(
stakingKeeper *stakingkeeper.Keeper,
bankKeeper bankkeeper.Keeper,
bundlesKeeper bundleskeeper.Keeper,
globalKeeper globalkeeper.Keeper,
multiCoinRewardsKeeper multicoinrewardskeeper.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 +60,13 @@ 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)

// TODO set withdraw address

// Run Bundles Merkle Roots migrations
bundlesKeeper.SetBundlesMigrationUpgradeHeight(sdkCtx, uint64(sdkCtx.BlockHeight()))
Expand All @@ -64,21 +77,58 @@ 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 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.SubmitBundleProposal",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
{
Type: "kyve.bundles.v1beta1.VoteBundleProposal",
Fraction: math.LegacyMustNewDecFromStr("0.95"),
},
{
Type: "kyve.bundles.v1beta1.SkipUploaderRole",
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,8 +139,10 @@ 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
}

Expand Down
44 changes: 22 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/KYVENetwork/chain

go 1.22.7
go 1.22.11

require (
cosmossdk.io/api v0.7.6
Expand All @@ -18,7 +18,7 @@ require (
cosmossdk.io/x/tx v0.13.7
cosmossdk.io/x/upgrade v0.1.4
github.com/bufbuild/buf v1.15.1
github.com/cometbft/cometbft v0.38.16
github.com/cometbft/cometbft v0.38.17
github.com/cosmos/cosmos-db v1.1.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.11
Expand All @@ -32,9 +32,9 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.2
google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a
google.golang.org/grpc v1.70.0
google.golang.org/protobuf v1.36.4
mvdan.cc/gofumpt v0.4.0
)

Expand All @@ -44,7 +44,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0
github.com/spf13/cast v1.7.1
github.com/spf13/pflag v1.0.5
golang.org/x/tools v0.22.0
golang.org/x/tools v0.23.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
)

Expand All @@ -54,7 +54,7 @@ require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/auth v0.6.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/iam v1.1.9 // indirect
cloud.google.com/go/storage v1.41.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
Expand Down Expand Up @@ -145,7 +145,7 @@ require (
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
Expand All @@ -162,7 +162,7 @@ require (
github.com/gofrs/uuid/v5 v5.0.0 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/glog v1.2.4 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
Expand Down Expand Up @@ -196,7 +196,7 @@ require (
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.3 // indirect
Expand Down Expand Up @@ -278,7 +278,7 @@ require (
github.com/polyfloyd/go-errorlint v1.4.5 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/quasilyte/go-ruleguard v0.4.0 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
Expand Down Expand Up @@ -335,27 +335,27 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.186.0 // indirect
google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading