Skip to content

Commit

Permalink
feat: maximum pool voting power (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler authored Dec 20, 2024
1 parent aab9233 commit 967b1d4
Show file tree
Hide file tree
Showing 26 changed files with 1,774 additions and 354 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ An '!' indicates a state machine breaking change.

- ! (`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.

### Bug Fixes

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 @@ -96,8 +96,14 @@ message EventSlash {
uint64 pool_id = 1;
// staker is the account address of the protocol node.
string staker = 2;
// amount ...
// amount is the total amount that got slashed
uint64 amount = 3;
// slash_type
// slash_type is the type of the protocol slash
SlashType slash_type = 4;
// stake_fraction is the percentage of how much of the validators total
// bonded amount was under risk for slashing
string stake_fraction = 5 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
4 changes: 2 additions & 2 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() {
for i := range poolsState {
bundleProposalState, _ := suite.App().BundlesKeeper.GetBundleProposal(suite.Ctx(), poolsState[i].Id)
stakersState := suite.App().StakersKeeper.GetAllStakerAddressesOfPool(suite.Ctx(), poolsState[i].Id)
totalDelegationState := suite.App().StakersKeeper.GetDelegationOfPool(suite.Ctx(), poolsState[i].Id)
totalDelegationState := suite.App().StakersKeeper.GetTotalStakeOfPool(suite.Ctx(), poolsState[i].Id)

Expect(poolsQuery[i].Id).To(Equal(poolsState[i].Id))
Expect(*poolsQuery[i].Data).To(Equal(poolsState[i]))
Expand Down Expand Up @@ -175,7 +175,7 @@ func (suite *KeeperTestSuite) VerifyStakersModuleAssetsIntegrity() {
func (suite *KeeperTestSuite) VerifyPoolTotalStake() {
for _, pool := range suite.App().PoolKeeper.GetAllPools(suite.Ctx()) {
expectedBalance := uint64(0)
actualBalance := suite.App().StakersKeeper.GetDelegationOfPool(suite.Ctx(), pool.Id)
actualBalance := suite.App().StakersKeeper.GetTotalStakeOfPool(suite.Ctx(), pool.Id)

for _, stakerAddress := range suite.App().StakersKeeper.GetAllStakerAddressesOfPool(suite.Ctx(), pool.Id) {
expectedBalance += suite.App().StakersKeeper.GetValidatorPoolStake(suite.Ctx(), stakerAddress, pool.Id)
Expand Down
12 changes: 12 additions & 0 deletions util/arrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ func ContainsString(array []string, match string) bool {
}
return false
}

func RemoveDuplicateStrings(strSlice []string) []string {
allKeys := make(map[string]bool)
list := []string{}
for _, item := range strSlice {
if _, value := allKeys[item]; !value {
allKeys[item] = true
list = append(list, item)
}
}
return list
}
Loading

0 comments on commit 967b1d4

Please sign in to comment.