Skip to content

Commit

Permalink
Merge branch 'main' into feat/round-robin
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreithecker committed Jul 6, 2023
2 parents 9b941a8 + 4ff6ac3 commit 7e7a0ab
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 13 deletions.
14 changes: 1 addition & 13 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# https://help.github.com/articles/about-codeowners

* @johnletey @mbreithecker

# CODEOWNERS for x/bundles

/x/bundles @johnletey @troykessler @mbreithecker

# CODEOWNERS for x/pool

/x/pool @johnletey @troykessler @mbreithecker

# CODEOWNERS for x/team

/x/team @johnletey @troykessler @mbreithecker
* @johnletey @mbreithecker @troykessler
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
- (`x/pool`) [#74](https://github.com/KYVENetwork/chain/pull/74) Improve parameter validation in pool proposals.
- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Allow protocol validator commission rewards to be claimed.

### Bug Fixes

- [#96](https://github.com/KYVENetwork/chain/pull/96) Track investor delegation inside auth module.

### Client Breaking

- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Include `MsgClaimCommissionRewards` for claiming commission rewards.
Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ func NewKYVEApp(
v1p3.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
),
)

Expand Down
39 changes: 39 additions & 0 deletions app/upgrades/v1_3/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,42 @@ const TestnetChainID = "kaon-1"

// MainnetChainID is the Chain ID of the KYVE mainnet.
const MainnetChainID = "kyve-1"

// InvestorAccounts is a list of accounts from our second funding round.
var InvestorAccounts = []string{
"kyve1lmmvd34rn05uuxyzyajyht5eykksvas9gpz9ln",
"kyve10ucfmct7epngs7k3y77qrfpvjlsgfv2qqjytm4",
"kyve10we97qv6nujhx4eyzskw9p23s0qfnr5rq6uadp",
"kyve1z2d4fvcv8gf72zvdp23x6ryswywh0ptrjrkdhp",
"kyve1hae0u8jqfedpm7u5ng6k464xsxx32tvluqus8t",
"kyve1gcz2tjuel4w6q3v4ec92eu4nvey6fkgnyfcavm",
"kyve1matxpxlw4cna4xr77jaqqmst74j35puy0nf87f",
"kyve1946pdjdg6dqxfd5et4g3k6glkkvt8l9r5zqmp9",
"kyve1ag2mctnvgwqea7au0lh92xd4ncfysw8gs94r6v",
"kyve1e7rmpdrrnjeuypn733c9lt2vg2cvkj788pvtvr",
"kyve1ewy2yfxr8aw3v9jv2kjgt4z6tj9ved3a9qyjh2",
"kyve1u26sz6kydnmpr5zq6nureav4xhasak8nu5q8d8",
"kyve194rvm2rjxhe0gfnv2095z6k5tnyszxh9sdyzhy",
"kyve1j7p7jg4cuw9ww6zyjf2gvpjxgseffjuhaj4qcq",
"kyve1kcmdhddxnwvmnekrsejnr4n87xqyxq9tlqlyqn",
"kyve13agpsm0r2sr3wl0yqqfxdncl7mxla0nh6jteum",
"kyve1jp7tv4g2ks855spj4cppmdnx4jtx26h5u5y3x2",
"kyve1hlsaz3fegeze2mk6a9f7mh93y72edfmxuq2as7",
"kyve1a9zlytywun0sq8gxjkqhsc4knzm8zw3tprq4x8",
"kyve1uqm9n8a769nvwagz7gmpx5x52nmqn3z05gdrqe",
"kyve1tmjvtgv6a447dewwhd4j2ehqsm8x4d2ttm053n",
"kyve1xlg7pgptqujg72csewpx7rytr4f0sgngqrj3gu",
"kyve1th6v7yygmxsfm2x2uwsp582eagnrcrjywwaf7f",
"kyve159ufwz58rzkcvjk94wkxv5uyz877pwpf6h7xy2",
"kyve1z73v6kqhutr5fq5eem2256l5a45empuk0xkxxm",
"kyve17rdl2fadf82qx4r0wd2ehtqyy3qsazeqyun9dd",
"kyve1tp5uz49gvvl5kys795re80e3mf9w9up0yzhzq7",
"kyve18d8t7nj9jqyyrzr76wea38u7er3ljzzqqys5nl",
"kyve14l2zxt75ylgnumjevxxans20uapctnke698vq2",
"kyve17zfy84an63jqdmm632th7sp2tj2tmh82hrysn9",
"kyve1m297tfaystezangz7wrm9j5s55a3j8xz7g5nkp",
"kyve1yxt5u93an2as4csf2xqv8sw96rgm2y3rrzmj2g",
"kyve1eddmugm8k5eyaa96v7e3rwrw97040q8awmkwdy",
"kyve1uxarsjawzcu3xjvydnmlgmceq3eldx2yas2djf",
"kyve1rtx3akgca36lrevmzal050ehxpxnwtn9xv7taz",
}
57 changes: 57 additions & 0 deletions app/upgrades/v1_3/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,73 @@
package v1_3

import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/tendermint/tendermint/libs/log"

// Auth
authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
vestingExported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
// Staking
stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
// Upgrade
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
accountKeeper authKeeper.AccountKeeper,
bankKeeper bankKeeper.Keeper,
stakingKeeper stakingKeeper.Keeper,
) upgradeTypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

if ctx.ChainID() == MainnetChainID {
for _, address := range InvestorAccounts {
TrackInvestorDelegation(ctx, logger, sdk.MustAccAddressFromBech32(address), accountKeeper, bankKeeper, stakingKeeper)
}
}

return mm.RunMigrations(ctx, configurator, vm)
}
}

// TrackInvestorDelegation performs a correction of the delegation tracking inside the vesting account.
// The correction is done by performing a full untracking and then tracking the actual total delegated amount
// (including slashed amounts).
func TrackInvestorDelegation(ctx sdk.Context, logger log.Logger, address sdk.AccAddress, ak authKeeper.AccountKeeper, bk bankKeeper.Keeper, sk stakingKeeper.Keeper) {
denom := sk.BondDenom(ctx)
account, _ := ak.GetAccount(ctx, address).(vestingExported.VestingAccount)

// Obtain total delegation of address
totalDelegation := sdk.NewInt(0)
for _, delegation := range sk.GetAllDelegatorDelegations(ctx, address) {
// We take the shares as the total delegation as this is the amount which is
// tracked inside the vesting account. (slashes are ignored, which is correct)
totalDelegation = totalDelegation.Add(delegation.GetShares().TruncateInt())
}

// Fetch current balance.
balanceCoin := bk.GetBalance(ctx, address, denom)

// This is the balance a user would have if all tokens are unbonded (even the ones which got slashed).
maxPossibleBalance := balanceCoin.Amount.Add(totalDelegation)
maxPossibleBalanceCoins := sdk.NewCoins().Add(sdk.NewCoin(denom, maxPossibleBalance))

if totalDelegation.GT(sdk.ZeroInt()) {

// Untrack entire vesting delegation using maximum amount. This will set both `delegated_free`
// and `delegated_vesting` back to zero.
account.TrackUndelegation(sdk.NewCoins(sdk.NewCoin("ukyve", maxPossibleBalance)))

// Track the delegation using the total delegation
account.TrackDelegation(ctx.BlockTime(), maxPossibleBalanceCoins, sdk.NewCoins(sdk.NewCoin("ukyve", totalDelegation)))

logger.Info(fmt.Sprintf("tracked delegation of %s with %s", address.String(), totalDelegation.String()))
ak.SetAccount(ctx, account)
}
}

0 comments on commit 7e7a0ab

Please sign in to comment.