@@ -22,7 +22,7 @@ module Cardano.Ledger.Shelley.Rules.PoolReap (
2222
2323import Cardano.Ledger.Address (RewardAccount , raCredential )
2424import Cardano.Ledger.BaseTypes (ShelleyBase )
25- import Cardano.Ledger.Coin (Coin )
25+ import Cardano.Ledger.Coin (Coin , CompactForm )
2626import Cardano.Ledger.Core
2727import Cardano.Ledger.Credential (Credential )
2828import Cardano.Ledger.PoolParams (ppRewardAccount )
@@ -35,7 +35,7 @@ import Cardano.Ledger.Shelley.LedgerState (
3535import Cardano.Ledger.Shelley.LedgerState.Types (potEqualsObligation )
3636import Cardano.Ledger.Slot (EpochNo (.. ))
3737import Cardano.Ledger.State
38- import Cardano.Ledger.UMap (UView (RewDepUView , SPoolUView ), compactCoinOrError )
38+ import Cardano.Ledger.UMap (UView (RewDepUView , SPoolUView ), compactCoinOrError , fromCompact )
3939import qualified Cardano.Ledger.UMap as UM
4040import Cardano.Ledger.Val ((<+>) , (<->) )
4141import Control.DeepSeq (NFData )
@@ -49,6 +49,7 @@ import Control.State.Transition (
4949 judgmentContext ,
5050 tellEvent ,
5151 )
52+ import Data.Bifunctor (Bifunctor (.. ))
5253import Data.Default (Default , def )
5354import Data.Foldable (fold )
5455import qualified Data.Map.Strict as Map
@@ -74,9 +75,9 @@ instance NFData (ShelleyPoolreapPredFailure era)
7475
7576data ShelleyPoolreapEvent era = RetiredPools
7677 { refundPools ::
77- Map. Map (Credential 'Staking) (Map. Map (KeyHash 'StakePool) Coin )
78+ Map. Map (Credential 'Staking) (Map. Map (KeyHash 'StakePool) ( CompactForm Coin ) )
7879 , unclaimedPools ::
79- Map. Map (Credential 'Staking) (Map. Map (KeyHash 'StakePool) Coin )
80+ Map. Map (Credential 'Staking) (Map. Map (KeyHash 'StakePool) ( CompactForm Coin ) )
8081 , epochNo :: EpochNo
8182 }
8283 deriving (Generic )
@@ -136,18 +137,19 @@ poolReapTransition = do
136137 retired :: Set (KeyHash 'StakePool)
137138 retired = eval (dom (psRetiring ps ▷ setSingleton e))
138139 -- The Map of pools (retiring this epoch) to their deposits
139- retiringDeposits , remainingDeposits :: Map. Map (KeyHash 'StakePool) Coin
140+ retiringDeposits , remainingDeposits :: Map. Map (KeyHash 'StakePool) ( CompactForm Coin )
140141 (retiringDeposits, remainingDeposits) =
141142 Map. partitionWithKey (\ k _ -> Set. member k retired) (psDeposits ps)
142143 rewardAccounts :: Map. Map (KeyHash 'StakePool) RewardAccount
143144 rewardAccounts = Map. map ppRewardAccount $ eval (retired ◁ psStakePoolParams ps)
144145 rewardAccounts_ ::
145- Map. Map (KeyHash 'StakePool) (RewardAccount , Coin )
146+ Map. Map (KeyHash 'StakePool) (RewardAccount , CompactForm Coin )
146147 rewardAccounts_ = Map. intersectionWith (,) rewardAccounts retiringDeposits
147148 rewardAccounts' :: Map. Map RewardAccount Coin
148149 rewardAccounts' =
149150 Map. fromListWith (<+>)
150151 . Map. elems
152+ . fmap (second fromCompact)
151153 $ rewardAccounts_
152154 refunds :: Map. Map (Credential 'Staking) Coin
153155 mRefunds :: Map. Map (Credential 'Staking) Coin
@@ -187,7 +189,7 @@ poolReapTransition = do
187189 & certPStateL . psStakePoolParamsL %~ (eval . (retired ⋪ ))
188190 & certPStateL . psFutureStakePoolParamsL %~ (eval . (retired ⋪ ))
189191 & certPStateL . psRetiringL %~ (eval . (retired ⋪ ))
190- & certPStateL . psDepositsL .~ remainingDeposits
192+ & certPStateL . psDepositsCompactL .~ remainingDeposits
191193 )
192194
193195renderPoolReapViolation ::
0 commit comments