Add sanity checks

This commit is contained in:
Christopher Goes
2018-10-19 21:58:05 +02:00
parent 4f719d60cd
commit 6c9ad8c031
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -40,6 +40,10 @@ func SimulateDeductFee(m auth.AccountMapper, f auth.FeeCollectionKeeper) simulat
panic(err)
}
m.SetAccount(ctx, stored)
if !coins.IsNotNegative() {
panic("setting negative fees")
}
f.AddCollectedFees(ctx, coins)
event(fmt.Sprintf("auth/SimulateDeductFee/true"))
+3
View File
@@ -45,6 +45,9 @@ func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBo
blocks := height - vi.FeePoolWithdrawalHeight
vi.FeePoolWithdrawalHeight = height
accum := vdTokens.MulInt(sdk.NewInt(blocks))
if accum.GT(fp.ValAccum.Accum) {
panic("individual accum should never be greater than the total")
}
withdrawalTokens := fp.Pool.MulDec(accum).QuoDec(fp.ValAccum.Accum)
remainingTokens := fp.Pool.Minus(withdrawalTokens)