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

fix: RewardBallotWinners determinism #1433

Merged
merged 3 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion x/oracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) error {
int64(params.VotePeriod),
int64(params.RewardDistributionWindow),
voteTargetDenoms,
validatorClaimMap,
claimSlice,
)

// Clear the ballot
Expand Down
3 changes: 2 additions & 1 deletion x/oracle/keeper/reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (k Keeper) RewardBallotWinners(
votePeriod int64,
rewardDistributionWindow int64,
voteTargets []string,
ballotWinners map[string]types.Claim,
ballotWinners []types.Claim,
) {
rewardDenoms := make([]string, len(voteTargets)+1)
rewardDenoms[0] = types.UmeeDenom
Expand Down Expand Up @@ -57,6 +57,7 @@ func (k Keeper) RewardBallotWinners(

// distribute rewards
var distributedReward sdk.Coins

for _, winner := range ballotWinners {
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
receiverVal := k.StakingKeeper.Validator(ctx, winner.Recipient)
// in case absence of the validator, we just skip distribution
Expand Down
9 changes: 5 additions & 4 deletions x/oracle/keeper/reward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
// Test the reward giving mechanism
func (s *IntegrationTestSuite) TestRewardBallotWinners() {
// Add claim pools
claims := map[string]types.Claim{
valAddr.String(): types.NewClaim(10, 10, 0, valAddr),
valAddr2.String(): types.NewClaim(20, 20, 0, valAddr2),
claims := []types.Claim{
types.NewClaim(10, 10, 0, valAddr),
types.NewClaim(20, 20, 0, valAddr2),
}

// Prepare reward pool
Expand All @@ -38,7 +38,8 @@ func (s *IntegrationTestSuite) TestRewardBallotWinners() {
}

func (s *IntegrationTestSuite) TestRewardBallotWinnersZeroPower() {
s.app.OracleKeeper.RewardBallotWinners(s.ctx, 0, 0, []string{}, map[string]types.Claim{valAddr.String(): {}})
zeroClaim := types.NewClaim(0, 0, 0, valAddr)
s.app.OracleKeeper.RewardBallotWinners(s.ctx, 0, 0, []string{}, []types.Claim{zeroClaim})
outstandingRewardsDec := s.app.DistrKeeper.GetValidatorOutstandingRewardsCoins(s.ctx, valAddr)
s.Require().Equal("", outstandingRewardsDec.String())
}