Skip to content

Commit

Permalink
feat: support multiple coins for funding in stakers module (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler authored May 14, 2024
1 parent 4d19e01 commit 1303bc2
Show file tree
Hide file tree
Showing 27 changed files with 955 additions and 420 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ An '!' indicates a state machine breaking change.

### Features

- ! (`x/stakers`) [#185](https://github.com/KYVENetwork/chain/pull/185) Support multiple coins in stakers module.
- ! (`x/bundles`) [#184](https://github.com/KYVENetwork/chain/pull/184) Support multiple coins in bundles module.
- ! (`x/funders`) [#179](https://github.com/KYVENetwork/chain/pull/179) Support multiple coins for funding.
- ! (`x/bundles`) [#177](https://github.com/KYVENetwork/chain/pull/177) Add end-key to pool.
Expand Down
138 changes: 114 additions & 24 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,26 @@ paths:
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -3928,11 +3943,26 @@ paths:
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -6290,11 +6320,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.
NOTE: The amount field is an Int which implements
the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through commission
and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down Expand Up @@ -6733,11 +6778,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.
NOTE: The amount field is an Int which implements
the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through
commission and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down Expand Up @@ -7282,11 +7342,26 @@ paths:
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -7774,11 +7849,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.
NOTE: The amount field is an Int which implements
the custom method
signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through
commission and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down
8 changes: 6 additions & 2 deletions proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ message StakerMetadata {
// if they not agree with the new commission.
CommissionChangeEntry pending_commission_change = 7;

// commission_rewards are the rewards in $KYVE earned through commission
uint64 commission_rewards = 8;
// commission_rewards are the rewards through commission and storage cost
repeated cosmos.base.v1beta1.Coin commission_rewards = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// CommissionChangeEntry shows when the old commission
Expand Down
10 changes: 8 additions & 2 deletions proto/kyve/stakers/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "kyve/stakers/v1beta1/params.proto";

Expand Down Expand Up @@ -66,8 +68,12 @@ message EventUpdateCommission {
message EventClaimCommissionRewards {
// staker is the account address of the protocol node.
string staker = 1;
// amount ...
uint64 amount = 2;
// amount is the amount of the commission rewards claimed
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// EventJoinPool ...
Expand Down
10 changes: 8 additions & 2 deletions proto/kyve/stakers/v1beta1/stakers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/KYVENetwork/chain/x/stakers/types";
Expand All @@ -26,8 +28,12 @@ message Staker {
string security_contact = 6;
// details are some additional notes the staker finds important
string details = 7;
// commission_rewards are the rewards in $KYVE earned through commission
uint64 commission_rewards = 8;
// commission_rewards are the rewards through commission and storage cost
repeated cosmos.base.v1beta1.Coin commission_rewards = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// Valaccount gets authorized by a staker to
Expand Down
8 changes: 7 additions & 1 deletion proto/kyve/stakers/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand Down Expand Up @@ -88,7 +90,11 @@ message MsgClaimCommissionRewards {
// creator ...
string creator = 1;
// amount ...
uint64 amount = 2;
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgClaimCommissionRewardsResponse ...
Expand Down
9 changes: 4 additions & 5 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,16 @@ func (suite *KeeperTestSuite) VerifyPoolGenesisImportExport() {
// =====================

func (suite *KeeperTestSuite) VerifyStakersModuleAssetsIntegrity() {
expectedBalance := uint64(0)
actualBalance := uint64(0)
expectedBalance := sdk.NewCoins()

for _, staker := range suite.App().StakersKeeper.GetAllStakers(suite.Ctx()) {
expectedBalance += staker.CommissionRewards
expectedBalance = expectedBalance.Add(staker.CommissionRewards...)
}

moduleAcc := suite.App().AccountKeeper.GetModuleAccount(suite.Ctx(), stakerstypes.ModuleName).GetAddress()
actualBalance = suite.App().BankKeeper.GetBalance(suite.Ctx(), moduleAcc, globalTypes.Denom).Amount.Uint64()
actualBalance := suite.App().BankKeeper.GetAllBalances(suite.Ctx(), moduleAcc)

Expect(actualBalance).To(Equal(expectedBalance))
Expect(actualBalance.String()).To(Equal(expectedBalance.String()))
}

func (suite *KeeperTestSuite) VerifyPoolTotalStake() {
Expand Down
Loading

0 comments on commit 1303bc2

Please sign in to comment.