Skip to content

Commit f0ccafc

Browse files
victorgesyondonfu
authored andcommitted
contracts/bm: Add assertions before updating rewards/fees
Should hopefully prevent any other similar accounting problems from allowing exploiting the minter balance.
1 parent 3428014 commit f0ccafc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contracts/bonding/BondingManager.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
364364
delegatorsRewards.add(totalStake)
365365
);
366366
}
367+
// Make sure there's no accounting error on transcoder rewards state
368+
assert(activeCumulativeRewards < totalStake);
367369

368370
uint256 delegatorsFees = MathUtils.percOf(_fees, earningsPool.transcoderFeeShare);
369371
uint256 transcoderCommissionFees = _fees.sub(delegatorsFees);
@@ -1487,6 +1489,8 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
14871489

14881490
t.activeCumulativeRewards = t.cumulativeRewards;
14891491

1492+
// Make sure there's no accounting error on transcoder rewards state
1493+
assert(t.activeCumulativeRewards < earningsPool.totalStake);
14901494
uint256 transcoderCommissionRewards = MathUtils.percOf(_rewards, earningsPool.transcoderRewardCut);
14911495
uint256 delegatorsRewards = _rewards.sub(transcoderCommissionRewards);
14921496
// Calculate the rewards earned by the transcoder's earned rewards

0 commit comments

Comments
 (0)