Merge PR #3726: Cap(clip) reward to remaining coins in AllocateTokens
This commit is contained in:
committed by
Christopher Goes
parent
e78a6da2bf
commit
7e08b62f4e
@@ -48,10 +48,11 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower in
|
||||
for _, vote := range votes {
|
||||
validator := k.stakingKeeper.ValidatorByConsAddr(ctx, vote.Validator.Address)
|
||||
|
||||
// TODO likely we should only reward validators who actually signed the block.
|
||||
// TODO consider microslashing for missing votes.
|
||||
// ref https://github.com/cosmos/cosmos-sdk/issues/2525#issuecomment-430838701
|
||||
powerFraction := sdk.NewDec(vote.Validator.Power).QuoTruncate(sdk.NewDec(totalPower))
|
||||
reward := feesCollected.MulDecTruncate(voteMultiplier).MulDecTruncate(powerFraction)
|
||||
reward = reward.Cap(remaining)
|
||||
k.AllocateTokensToValidator(ctx, validator, reward)
|
||||
remaining = remaining.Sub(reward)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user