@@ -30,6 +30,7 @@ module Cardano.Ledger.Conway.PParams (
3030 ppCommitteeMinSize ,
3131 ppDRepActivity ,
3232 ppDRepDeposit ,
33+ ppDRepDepositCompactL ,
3334 ppDRepVotingThresholds ,
3435 ppGovActionDeposit ,
3536 ppGovActionLifetime ,
@@ -87,6 +88,7 @@ module Cardano.Ledger.Conway.PParams (
8788 asNaturalHKD ,
8889 asBoundedIntegralHKD ,
8990 ppGroup ,
91+ asCompactCoinHKD ,
9092) where
9193
9294import Cardano.Ledger.Alonzo.PParams
@@ -119,7 +121,8 @@ import Cardano.Ledger.Binary (
119121 encodeListLen ,
120122 )
121123import Cardano.Ledger.Binary.Coders
122- import Cardano.Ledger.Coin (Coin (Coin ), CompactForm (.. ))
124+ import Cardano.Ledger.Coin (Coin (Coin ), CompactForm (.. ), compactCoinOrError , partialCompactCoinL )
125+ import Cardano.Ledger.Compactible (partialCompactFL )
123126import Cardano.Ledger.Conway.Era (ConwayEra , hardforkConwayBootstrapPhase )
124127import Cardano.Ledger.Core (EraPParams (.. ))
125128import Cardano.Ledger.HKD (
@@ -180,7 +183,7 @@ class BabbageEraPParams era => ConwayEraPParams era where
180183 hkdCommitteeMaxTermLengthL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f EpochInterval )
181184 hkdGovActionLifetimeL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f EpochInterval )
182185 hkdGovActionDepositL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f Coin )
183- hkdDRepDepositL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f Coin )
186+ hkdDRepDepositCompactL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f ( CompactForm Coin ) )
184187 hkdDRepActivityL :: HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f EpochInterval )
185188 hkdMinFeeRefScriptCostPerByteL ::
186189 HKDFunctor f => Lens' (PParamsHKD f era ) (HKD f NonNegativeInterval )
@@ -233,8 +236,11 @@ ppGovActionLifetimeL = ppLensHKD . hkdGovActionLifetimeL @era @Identity
233236ppGovActionDepositL :: forall era . ConwayEraPParams era => Lens' (PParams era ) Coin
234237ppGovActionDepositL = ppLensHKD . hkdGovActionDepositL @ era @ Identity
235238
236- ppDRepDepositL :: forall era . ConwayEraPParams era => Lens' (PParams era ) Coin
237- ppDRepDepositL = ppLensHKD . hkdDRepDepositL @ era @ Identity
239+ ppDRepDepositCompactL :: forall era . ConwayEraPParams era => Lens' (PParams era ) (CompactForm Coin )
240+ ppDRepDepositCompactL = ppLensHKD . hkdDRepDepositCompactL @ era @ Identity
241+
242+ ppDRepDepositL :: ConwayEraPParams era => Lens' (PParams era ) Coin
243+ ppDRepDepositL = ppDRepDepositCompactL . partialCompactCoinL
238244
239245ppDRepActivityL :: forall era . ConwayEraPParams era => Lens' (PParams era ) EpochInterval
240246ppDRepActivityL = ppLensHKD . hkdDRepActivityL @ era @ Identity
@@ -267,9 +273,13 @@ ppuGovActionDepositL ::
267273 forall era . ConwayEraPParams era => Lens' (PParamsUpdate era ) (StrictMaybe Coin )
268274ppuGovActionDepositL = ppuLensHKD . hkdGovActionDepositL @ era @ StrictMaybe
269275
276+ ppuDRepDepositCompactL ::
277+ forall era . ConwayEraPParams era => Lens' (PParamsUpdate era ) (StrictMaybe (CompactForm Coin ))
278+ ppuDRepDepositCompactL = ppuLensHKD . hkdDRepDepositCompactL @ era @ StrictMaybe
279+
270280ppuDRepDepositL ::
271281 forall era . ConwayEraPParams era => Lens' (PParamsUpdate era ) (StrictMaybe Coin )
272- ppuDRepDepositL = ppuLensHKD . hkdDRepDepositL @ era @ StrictMaybe
282+ ppuDRepDepositL = ppuDRepDepositCompactL . partialCompactFL
273283
274284ppuDRepActivityL ::
275285 forall era . ConwayEraPParams era => Lens' (PParamsUpdate era ) (StrictMaybe EpochInterval )
@@ -678,7 +688,7 @@ data ConwayPParams f era = ConwayPParams
678688 -- ^ Gov action lifetime in number of Epochs
679689 , cppGovActionDeposit :: ! (THKD ('PPGroups 'GovGroup 'SecurityGroup) f Coin )
680690 -- ^ The amount of the Gov Action deposit
681- , cppDRepDeposit :: ! (THKD ('PPGroups 'GovGroup 'NoStakePoolGroup) f Coin )
691+ , cppDRepDeposit :: ! (THKD ('PPGroups 'GovGroup 'NoStakePoolGroup) f ( CompactForm Coin ) )
682692 -- ^ The amount of a DRep registration deposit
683693 , cppDRepActivity :: ! (THKD ('PPGroups 'GovGroup 'NoStakePoolGroup) f EpochInterval )
684694 -- ^ The number of Epochs that a DRep can perform no activity without losing their @Active@ status.
@@ -945,7 +955,7 @@ instance ConwayEraPParams ConwayEra where
945955 lens (unTHKD . cppGovActionLifetime) $ \ pp x -> pp {cppGovActionLifetime = THKD x}
946956 hkdGovActionDepositL =
947957 lens (unTHKD . cppGovActionDeposit) $ \ pp x -> pp {cppGovActionDeposit = THKD x}
948- hkdDRepDepositL =
958+ hkdDRepDepositCompactL =
949959 lens (unTHKD . cppDRepDeposit) $ \ pp x -> pp {cppDRepDeposit = THKD x}
950960 hkdDRepActivityL =
951961 lens (unTHKD . cppDRepActivity) $ \ pp x -> pp {cppDRepActivity = THKD x}
@@ -989,7 +999,7 @@ emptyConwayPParams =
989999 , cppCommitteeMaxTermLength = THKD (EpochInterval 0 )
9901000 , cppGovActionLifetime = THKD (EpochInterval 0 )
9911001 , cppGovActionDeposit = THKD (Coin 0 )
992- , cppDRepDeposit = THKD (Coin 0 )
1002+ , cppDRepDeposit = THKD (CompactCoin 0 )
9931003 , cppDRepActivity = THKD (EpochInterval 0 )
9941004 , cppMinFeeRefScriptCostPerByte = THKD minBound
9951005 }
@@ -1121,7 +1131,7 @@ upgradeConwayPParams UpgradeConwayPParams {..} BabbagePParams {..} =
11211131 , cppCommitteeMaxTermLength = THKD ucppCommitteeMaxTermLength
11221132 , cppGovActionLifetime = THKD ucppGovActionLifetime
11231133 , cppGovActionDeposit = THKD ucppGovActionDeposit
1124- , cppDRepDeposit = THKD ucppDRepDeposit
1134+ , cppDRepDeposit = THKD $ asCompactCoinHKD @ f ucppDRepDeposit
11251135 , cppDRepActivity = THKD ucppDRepActivity
11261136 , cppMinFeeRefScriptCostPerByte = THKD ucppMinFeeRefScriptCostPerByte
11271137 }
@@ -1235,6 +1245,9 @@ instance CollectModifiedPPGroups (K1 i (NoUpdate a) p) where
12351245instance CollectModifiedPPGroups (a u ) => CollectModifiedPPGroups (M1 i c a u ) where
12361246 collectModifiedPPGroups (M1 x) = collectModifiedPPGroups x
12371247
1248+ asCompactCoinHKD :: forall f . HKDFunctor f => HKD f Coin -> HKD f (CompactForm Coin )
1249+ asCompactCoinHKD = hkdMap (Proxy @ f ) compactCoinOrError
1250+
12381251-- | Care should be taken to not apply this function to signed values, otherwise it will result in
12391252-- an `ArithmeticUnderflow` exception for negative numbers.
12401253asNaturalHKD :: forall f i . (HKDFunctor f , Integral i ) => HKD f i -> HKD f Natural
0 commit comments