Merge PR #3836: Fix WithdrawValidatorCommission
This commit is contained in:
parent
db421fc0a6
commit
b316c477c1
|
@ -44,11 +44,13 @@
|
|||
* #3808 `gaiad` and `gaiacli` integration tests use ./build/ binaries.
|
||||
|
||||
### SDK
|
||||
|
||||
* #3801 `baseapp` saftey improvements
|
||||
|
||||
### Tendermint
|
||||
|
||||
### CI/CD
|
||||
|
||||
* [\198](https://github.com/cosmos/cosmos-sdk/pull/3832)
|
||||
|
||||
<!--------------------------------- BUG FIXES -------------------------------->
|
||||
|
@ -63,4 +65,7 @@
|
|||
|
||||
### SDK
|
||||
|
||||
* [\#3837] Fix `WithdrawValidatorCommission` to properly set the validator's
|
||||
remaining commission.
|
||||
|
||||
### Tendermint
|
||||
|
|
|
@ -179,7 +179,9 @@ func (coins DecCoins) TruncateDecimal() (Coins, DecCoins) {
|
|||
for i, coin := range coins {
|
||||
truncated, change := coin.TruncateDecimal()
|
||||
out[i] = truncated
|
||||
changeSum = changeSum.Add(DecCoins{change})
|
||||
if !change.IsZero() {
|
||||
changeSum = changeSum.Add(DecCoins{change})
|
||||
}
|
||||
}
|
||||
|
||||
return out, changeSum
|
||||
|
|
|
@ -79,9 +79,7 @@ func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddr
|
|||
}
|
||||
|
||||
coins, remainder := commission.TruncateDecimal()
|
||||
|
||||
// leave remainder to withdraw later
|
||||
k.SetValidatorAccumulatedCommission(ctx, valAddr, remainder)
|
||||
k.SetValidatorAccumulatedCommission(ctx, valAddr, remainder) // leave remainder to withdraw later
|
||||
|
||||
// update outstanding
|
||||
outstanding := k.GetValidatorOutstandingRewards(ctx, valAddr)
|
||||
|
|
|
@ -237,9 +237,16 @@ func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAd
|
|||
|
||||
// set accumulated commission for a validator
|
||||
func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) {
|
||||
var bz []byte
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(commission)
|
||||
store.Set(GetValidatorAccumulatedCommissionKey(val), b)
|
||||
if commission.IsZero() {
|
||||
bz = k.cdc.MustMarshalBinaryLengthPrefixed(types.InitialValidatorAccumulatedCommission())
|
||||
} else {
|
||||
bz = k.cdc.MustMarshalBinaryLengthPrefixed(commission)
|
||||
}
|
||||
|
||||
store.Set(GetValidatorAccumulatedCommissionKey(val), bz)
|
||||
}
|
||||
|
||||
// delete accumulated commission for a validator
|
||||
|
|
Loading…
Reference in New Issue