compute shardExternalShare based on payableSigners overallpercent (#2904)

* compute shardExternalShare based on payableSigners overallpercent

* also do the same for beacon reward
pull/2905/head
Ganesha Upadhyaya 5 years ago committed by GitHub
parent 1546fa0479
commit 22b1e0cb50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      internal/chain/reward.go

@ -195,9 +195,11 @@ func AccumulateRewardsAndCountSigs(
return network.EmptyPayout, err return network.EmptyPayout, err
} }
beaconExternalShare := shard.Schedule.InstanceForEpoch( allSignersShare := numeric.ZeroDec()
headerE, for j := range payable {
).ExternalVotePercent() voterShare := votingPower.Voters[payable[j].BLSPublicKey].OverallPercent
allSignersShare = allSignersShare.Add(voterShare)
}
for beaconMember := range payable { for beaconMember := range payable {
// TODO Give out whatever leftover to the last voter/handle // TODO Give out whatever leftover to the last voter/handle
// what to do about share of those that didn't sign // what to do about share of those that didn't sign
@ -209,7 +211,7 @@ func AccumulateRewardsAndCountSigs(
return network.EmptyPayout, err return network.EmptyPayout, err
} }
due := defaultReward.Mul( due := defaultReward.Mul(
voter.OverallPercent.Quo(beaconExternalShare), voter.OverallPercent.Quo(allSignersShare),
).RoundInt() ).RoundInt()
newRewards.Add(newRewards, due) newRewards.Add(newRewards, due)
@ -294,14 +296,17 @@ func AccumulateRewardsAndCountSigs(
return network.EmptyPayout, err return network.EmptyPayout, err
} }
shardExternalShare := shard.Schedule.InstanceForEpoch( allSignersShare := numeric.ZeroDec()
epoch, for j := range payableSigners {
).ExternalVotePercent() voterShare := votingPower.Voters[payableSigners[j].BLSPublicKey].OverallPercent
allSignersShare = allSignersShare.Add(voterShare)
}
for j := range payableSigners { for j := range payableSigners {
voter := votingPower.Voters[payableSigners[j].BLSPublicKey] voter := votingPower.Voters[payableSigners[j].BLSPublicKey]
if !voter.IsHarmonyNode && !voter.OverallPercent.IsZero() { if !voter.IsHarmonyNode && !voter.OverallPercent.IsZero() {
due := defaultReward.Mul( due := defaultReward.Mul(
voter.OverallPercent.Quo(shardExternalShare), voter.OverallPercent.Quo(allSignersShare),
) )
allPayables = append(allPayables, slotPayable{ allPayables = append(allPayables, slotPayable{
Slot: payableSigners[j], Slot: payableSigners[j],

Loading…
Cancel
Save