Skip to content

Commit

Permalink
Fix type signature of computeDRepDistr
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketd committed May 3, 2024
1 parent e27f1c4 commit ec7d9d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 10 additions & 12 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import Data.Kind (Type)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
import Data.Proxy (Proxy (Proxy))
import Data.Pulse (Pulsable (..), pulse)
import Data.Sequence.Strict (StrictSeq (..))
import qualified Data.Sequence.Strict as SS
Expand Down Expand Up @@ -173,15 +172,14 @@ instance EraPParams era => FromCBOR (PulsingSnapshot era) where
-- (b) is the size of the StakeDistr, and
-- (c) is the size of the DRepDistr, this grows as the accumulator
computeDRepDistr ::
forall era.
Proxy era ->
Map (Credential 'Staking (EraCrypto era)) (CompactForm Coin) ->
Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era)) ->
Map (Credential 'Staking (EraCrypto era)) (CompactForm Coin) ->
Map (DRep (EraCrypto era)) (CompactForm Coin) ->
Map (Credential 'Staking (EraCrypto era)) (UMElem (EraCrypto era)) ->
Map (DRep (EraCrypto era)) (CompactForm Coin)
computeDRepDistr _ stakeDistr regDReps proposalDeposits dRepDistr uMapChunk =
forall c.
Map (Credential 'Staking c) (CompactForm Coin) ->
Map (Credential 'DRepRole c) (DRepState c) ->
Map (Credential 'Staking c) (CompactForm Coin) ->
Map (DRep c) (CompactForm Coin) ->
Map (Credential 'Staking c) (UMElem c) ->
Map (DRep c) (CompactForm Coin)
computeDRepDistr stakeDistr regDReps proposalDeposits dRepDistr uMapChunk =
Map.foldlWithKey' go dRepDistr uMapChunk
where
go accum stakeCred umElem =
Expand Down Expand Up @@ -250,7 +248,7 @@ instance Pulsable (DRepPulser era) where
| done pulser = pure pulser {dpIndex = 0}
| otherwise =
let !chunk = Map.take dpPulseSize $ Map.drop dpIndex $ UMap.umElems dpUMap
dRepDistr = computeDRepDistr (Proxy @era) dpStakeDistr dpDRepState dpProposalDeposits dpDRepDistr chunk
dRepDistr = computeDRepDistr dpStakeDistr dpDRepState dpProposalDeposits dpDRepDistr chunk
in pure (pulser {dpIndex = dpIndex + dpPulseSize, dpDRepDistr = dRepDistr})

completeM x@(DRepPulser {}) = pure (snd $ finishDRepPulser @era (DRPulsing x))
Expand Down Expand Up @@ -324,7 +322,7 @@ finishDRepPulser (DRPulsing (DRepPulser {..})) =
(PulsingSnapshot dpProposals finalDRepDistr dpDRepState, ratifyState')
where
!leftOver = Map.drop dpIndex $ umElems dpUMap
!finalDRepDistr = computeDRepDistr (Proxy @era) dpStakeDistr dpDRepState dpProposalDeposits dpDRepDistr leftOver
!finalDRepDistr = computeDRepDistr dpStakeDistr dpDRepState dpProposalDeposits dpDRepDistr leftOver
!ratifyEnv =
RatifyEnv
{ reStakeDistr = dpStakeDistr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import qualified Cardano.Ledger.UMap as UMap
import Data.Foldable (toList)
import qualified Data.Map.Strict as Map
import Data.Maybe.Strict (StrictMaybe (..))
import Data.Proxy (Proxy (Proxy))
import qualified Data.Set as Set
import Debug.Trace (trace)
import Lens.Micro
Expand Down Expand Up @@ -222,7 +221,7 @@ bruteForceDRepDistr ::
ConwayEraGov era =>
NewEpochState era ->
Map.Map (DRep (EraCrypto era)) (CompactForm Coin)
bruteForceDRepDistr nes = computeDRepDistr (Proxy @era) incstk dreps propDeps Map.empty $ UMap.umElems umap
bruteForceDRepDistr nes = computeDRepDistr incstk dreps propDeps Map.empty $ UMap.umElems umap
where
ls = esLState (nesEs nes)
propDeps = proposalsDeposits $ ls ^. lsUTxOStateL . utxosGovStateL . proposalsGovStateL
Expand Down

0 comments on commit ec7d9d5

Please sign in to comment.