From 4b74173807bada10ac7bddf477a40446e004f099 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Mon, 14 Sep 2020 14:33:19 +0200 Subject: [PATCH] Renaming some function arguments to more clearly separate supply, total stake, active stake. --- .../src/Shelley/Spec/Ledger/LedgerState.hs | 4 ++-- .../src/Shelley/Spec/Ledger/Rewards.hs | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/LedgerState.hs b/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/LedgerState.hs index 374d0a7bf83..1a78d253ad4 100644 --- a/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/LedgerState.hs +++ b/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/LedgerState.hs @@ -919,7 +919,7 @@ createRUpd :: EpochState era -> Coin -> ShelleyBase (RewardUpdate era) -createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) total = do +createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) maxSupply = do asc <- asks activeSlotCoeff let SnapShot stake' delegs' poolParams = _pstakeGo ss Coin reserves = _reserves acnt @@ -938,7 +938,7 @@ createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) to Coin rPot = _feeSS ss <> deltaR1 deltaT1 = floor $ intervalValue (_tau pr) * fromIntegral rPot _R = Coin $ rPot - deltaT1 - totalStake = circulation es total + totalStake = circulation es maxSupply (rs_, newLikelihoods) = reward pr b _R (Map.keysSet $ _rewards ds) poolParams stake' delegs' totalStake asc slotsPerEpoch deltaR2 = _R Val.~~ (Map.foldr (<>) mempty rs_) diff --git a/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Rewards.hs b/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Rewards.hs index e31e13cf09a..98d7489d261 100644 --- a/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Rewards.hs +++ b/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Rewards.hs @@ -248,7 +248,7 @@ desirability :: PerformanceEstimate -> Coin -> Double -desirability pp r pool (PerformanceEstimate p) (Coin total) = +desirability pp r pool (PerformanceEstimate p) (Coin totalStake) = if fTilde <= cost then 0 else (fTilde - cost) * (1 - margin) @@ -258,7 +258,7 @@ desirability pp r pool (PerformanceEstimate p) (Coin total) = fTildeDenom = fromRational $ 1 + a0 cost = (fromRational . coinToRational . _poolCost) pool margin = (fromRational . unitIntervalToRational . _poolMargin) pool - tot = max 1 (fromIntegral total) + tot = max 1 (fromIntegral totalStake) Coin pledge = _poolPledge pool s = fromIntegral pledge % tot a0 = _a0 pp @@ -274,15 +274,15 @@ getTopRankedPools :: Map (KeyHash 'StakePool era) (PoolParams era) -> Map (KeyHash 'StakePool era) PerformanceEstimate -> Set (KeyHash 'StakePool era) -getTopRankedPools rPot total pp poolParams aps = Set.fromList $ fmap fst $ take (fromIntegral $ _nOpt pp) (sortBy (flip compare `on` snd) rankings) +getTopRankedPools rPot totalStake pp poolParams aps = where pdata = Map.toList $ Map.intersectionWith (,) poolParams aps rankings = [ ( hk, - desirability pp rPot pool ap total + desirability pp rPot pool ap totalStake ) | (hk, (pool, ap)) <- pdata ] @@ -350,7 +350,7 @@ rewardOnePool :: Coin -> Set (Credential 'Staking era) -> Map (Credential 'Staking era) Coin -rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin total) addrsRew = +rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin totalStake) addrsRew = rewards' where Coin ostake = @@ -359,14 +359,14 @@ rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin tot mempty (_poolOwners pool) Coin pledge = _poolPledge pool - pr = fromIntegral pledge % fromIntegral total + pr = fromIntegral pledge % fromIntegral totalStake (Coin maxP) = if pledge <= ostake then maxPool pp r sigma pr else mempty appPerf = mkApparentPerformance (_d pp) sigmaA blocksN blocksTotal poolR = rationalToCoinViaFloor (appPerf * fromIntegral maxP) - tot = fromIntegral total + tot = fromIntegral totalStake mRewards = Map.fromList [ ( hk, @@ -401,16 +401,16 @@ reward poolParams stake delegs - (Coin total) + (Coin totalStake) asc slotsPerEpoch = (rewards', hs) where totalBlocks = sum b - Coin totalActive = fold . unStake $ stake + Coin activeStake = fold . unStake $ stake results = do (hk, pparams) <- Map.toList poolParams - let sigma = fromIntegral pstake % fromIntegral total - sigmaA = fromIntegral pstake % fromIntegral totalActive + let sigma = fromIntegral pstake % fromIntegral totalStake + sigmaA = fromIntegral pstake % fromIntegral activeStake blocksProduced = Map.lookup hk b actgr@(Stake s) = poolStake hk delegs stake Coin pstake = fold s @@ -427,7 +427,7 @@ reward actgr sigma sigmaA - (Coin total) + (Coin totalStake) addrsRew ls = likelihood