Skip to content

Commit

Permalink
Address another set of review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketd committed May 9, 2024
1 parent a3fe7b6 commit 7a877b2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ computeDRepDistr stakeDistr regDReps proposalDeposits poolDistr dRepDistr uMapCh
, addToPoolDistr spo proposalDeposit poolAccum
)
addToPoolDistr spo proposalDeposit distr = fromMaybe distr $ do
-- Avoid adding the proposal deposits to anything other than the numerator
-- and denominator in order not to interfere with rewards calculation,
-- although this is an isolated copy inside the DRepPulser, we want to
-- just be sure we do not confuse ourselves over which representations are
-- used where.
guard (proposalDeposit /= mempty)
ips <- Map.lookup spo $ distr ^. poolDistrDistrL
pure $
Expand Down Expand Up @@ -365,7 +360,7 @@ finishDRepPulser (DRPulsing (DRepPulser {..})) =
(PulsingSnapshot dpProposals finalDRepDistr dpDRepState, ratifyState')
where
!leftOver = Map.drop dpIndex $ umElems dpUMap
(!finalDRepDistr, !finalStakePoolDistr) =
(finalDRepDistr, finalStakePoolDistr) =
computeDRepDistr dpStakeDistr dpDRepState dpProposalDeposits dpStakePoolDistr dpDRepDistr leftOver
!ratifyEnv =
RatifyEnv
Expand Down
16 changes: 8 additions & 8 deletions libs/cardano-ledger-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## 1.12.0.0

* Add `UMap.umElemDelegations` to extract SPO, DRep and rewards for a given stake credential. #4324
* Add `sumAllStakeCompact` and redefine `sumAllStake` as a composition of it.
* Change `computeDRepPulser` to also process proposal-deposits for SPOs.
* Add `pdTotalActiveStake` field to `PoolDistr`, to hold the total active stake delegated to pools, including proposal deposits.
* Add `individualTotalPoolStake` to `IndividualPoolStake` to hold the delegated stake as an absolute number, including proposal deposits.
* Add lenses:
* `individualTotalPoolStakeL`
* `poolDistrTotalL`
* Change `computeDRepPulser` to also process proposal-deposits for SPOs. #4324
* Add `sumAllStakeCompact`.
* Add `UMap.umElemDelegations` to extract SPO, DRep and rewards for a given stake credential.
* Add `pdTotalActiveStake` field to `PoolDistr`, to hold the total active stake delegated to pools, including proposal deposits.
* Add `individualTotalPoolStake` to `IndividualPoolStake` to hold the delegated stake as an absolute number, including proposal deposits.
* Add lenses:
* `individualTotalPoolStakeL`
* `poolDistrTotalL`
* Add lenses to `RewardAccount`. #4309
* `rewardAccountCredentialL`
* `rewardAccountNetworkL`
Expand Down
4 changes: 1 addition & 3 deletions libs/cardano-ledger-core/src/Cardano/Ledger/PoolDistr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ import NoThunks.Class (NoThunks (..))
-- delegated to a registered stake pool.
data IndividualPoolStake c = IndividualPoolStake
{ individualPoolStake :: !Rational
-- ^ Pool stake distribution. This is a ratio of
-- (individualTotalPoolStake - proposal deposits) to
-- (pdTotalActiveStake - proposal deposits)
-- ^ Pool stake distribution. This is a ratio of `individualTotalPoolStake`/`pdTotalActiveStake`
, individualTotalPoolStake :: !(CompactForm Coin)
-- ^ Total stake delegated to this pool. In addition to all the stake that
-- is part of `individualPoolStake` we also add proposal-deposits to this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import Cardano.Ledger.Keys.WitVKey (WitVKey (..))
import Cardano.Ledger.Mary.Value (AssetName (..), MaryValue (..), MultiAsset (..), PolicyID (..))
import Cardano.Ledger.Plutus (ExUnits (..))
import Cardano.Ledger.Plutus.Data (Data (..), Datum (..))
import Cardano.Ledger.PoolDistr (IndividualPoolStake (..), PoolDistr (..))
import Cardano.Ledger.PoolDistr (IndividualPoolStake (..), PoolDistr (..), poolDistrDistrL)
import Cardano.Ledger.PoolParams (PoolParams)
import Cardano.Ledger.SafeHash (SafeHash)
import Cardano.Ledger.Shelley.Governance (FuturePParams (..), futureProposalsL, proposalsL)
Expand Down Expand Up @@ -677,10 +677,7 @@ markPoolDistr = Var (V "markPoolDistr" (MapR PoolHashR IPoolStakeR) No)

markPoolDistrL ::
NELens era (Map (KeyHash 'StakePool (EraCrypto era)) (IndividualPoolStake (EraCrypto era)))
markPoolDistrL = nesEsL . esSnapshotsL . ssStakeMarkPoolDistrL . pooldistrHelpL

pooldistrHelpL :: Lens' (PoolDistr c) (Map (KeyHash 'StakePool c) (IndividualPoolStake c))
pooldistrHelpL = lens unPoolDistr (\x y -> x {unPoolDistr = y})
markPoolDistrL = nesEsL . esSnapshotsL . ssStakeMarkPoolDistrL . poolDistrDistrL

snapShotFee :: Era era => Term era Coin
snapShotFee = Var (V "snapShotFee" CoinR No)
Expand All @@ -690,7 +687,7 @@ snapShotsT ::
snapShotsT =
Invert "SnapShots" (typeRep @(SnapShots (EraCrypto era))) shotsfun
:$ Shift markSnapShotT ssStakeMarkL
:$ Lensed markPoolDistr (ssStakeMarkPoolDistrL . pooldistrHelpL)
:$ Lensed markPoolDistr (ssStakeMarkPoolDistrL . poolDistrDistrL)
:$ Shift setSnapShotT ssStakeSetL
:$ Shift goSnapShotT ssStakeGoL
:$ Lensed snapShotFee ssFeeL
Expand Down

0 comments on commit 7a877b2

Please sign in to comment.