Skip to content

Commit

Permalink
Made divisions that are supposed to fail on zero fail again
Browse files Browse the repository at this point in the history
  • Loading branch information
Soupstraw committed Jan 27, 2025
1 parent 28a4903 commit ffc46e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rewards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import Lens.Micro ((^.))
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)
import Quiet
import Data.Ratio ((%))

-- | StakeShare type
newtype StakeShare = StakeShare {unStakeShare :: Rational}
Expand Down Expand Up @@ -289,7 +290,9 @@ rewardOnePoolMember
pool = poolPs rewardInfo
sigma = poolRelativeStake rewardInfo
poolR = poolPot rewardInfo
stakeShare = StakeShare $ c %? unCoin totalStake
-- warning: totalStake could be zero!
stakeShare =
StakeShare $ c % unCoin totalStake
r = memberRew poolR pool stakeShare sigma

-- | Calculate single stake pool specific values for the reward computation.
Expand Down Expand Up @@ -332,7 +335,8 @@ mkPoolRewardInfo
-- intermediate values needed for the individual reward calculations.
Just blocksN ->
let Coin pledge = ppPledge pool
pledgeRelative = pledge %? unCoin totalStake
-- warning: totalStake could be zero!
pledgeRelative = pledge % unCoin totalStake
sigmaA = pstakeTot %? unCoin activeStake
Coin maxP =
if pledge <= ostake
Expand Down

0 comments on commit ffc46e9

Please sign in to comment.