Skip to content

Commit

Permalink
Replace updateDRepExpiry in GOVCERT with computeDRepExpiry
Browse files Browse the repository at this point in the history
for more flexible use
  • Loading branch information
teodanciu committed Aug 15, 2024
1 parent 72fe246 commit f49e155
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Version history for `cardano-ledger-conway`

## 1.16.1.0
## 1.17.0.0

* Replace GOVCERT `updateDRepExpiry` with `computeDRepExpiry`
* Added `Eq`, `Show`, `NFData` and `Generic` instances for `CertsEnv`
* Add `delegateToDRep` and `redelegateDRep`

Expand Down
7 changes: 5 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Certs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Cardano.Ledger.Conway.Governance (
)
import Cardano.Ledger.Conway.Rules.Cert (CertEnv (CertEnv), ConwayCertEvent, ConwayCertPredFailure)
import Cardano.Ledger.Conway.Rules.Deleg (ConwayDelegPredFailure)
import Cardano.Ledger.Conway.Rules.GovCert (ConwayGovCertPredFailure, updateDRepExpiry)
import Cardano.Ledger.Conway.Rules.GovCert (ConwayGovCertPredFailure, computeDRepExpiry)
import Cardano.Ledger.DRep (drepExpiryL)
import Cardano.Ledger.Shelley.API (
CertState (..),
Expand Down Expand Up @@ -236,7 +236,10 @@ conwayCertsTransition = do
Map.foldlWithKey'
( \dreps voter _ -> case voter of
DRepVoter cred ->
Map.adjust (updateDRepExpiry drepActivity currentEpoch numDormantEpochs) cred dreps
Map.adjust
(drepExpiryL .~ computeDRepExpiry drepActivity currentEpoch numDormantEpochs)
cred
dreps
_ -> dreps
)
vsDReps
Expand Down
30 changes: 15 additions & 15 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/GovCert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Cardano.Ledger.Conway.Rules.GovCert (
ConwayGOVCERT,
ConwayGovCertPredFailure (..),
ConwayGovCertEnv (..),
updateDRepExpiry,
computeDRepExpiry,
)
where

Expand Down Expand Up @@ -253,11 +253,13 @@ conwayGovCertTransition = do
{ vsDReps =
Map.adjust
( \drepState ->
updateDRepExpiry
ppDRepActivity
cgceCurrentEpoch
(vState ^. vsNumDormantEpochsL)
$ drepState & drepAnchorL .~ mAnchor
drepState
& drepExpiryL
.~ computeDRepExpiry
ppDRepActivity
cgceCurrentEpoch
(vState ^. vsNumDormantEpochsL)
& drepAnchorL .~ mAnchor
)
cred
vsDReps
Expand All @@ -272,18 +274,16 @@ conwayGovCertTransition = do
UpdateCommittee _ _ newMembers _ -> Map.member coldCred newMembers
_ -> False

updateDRepExpiry ::
computeDRepExpiry ::
-- | DRepActivity PParam
EpochInterval ->
-- | Current epoch
EpochNo ->
-- | The count of the dormant epochs
EpochNo ->
DRepState c ->
DRepState c
updateDRepExpiry ppDRepActivity currentEpoch numDormantEpochs =
drepExpiryL
.~ binOpEpochNo
(-)
(addEpochInterval currentEpoch ppDRepActivity)
numDormantEpochs
-- | Computed expiry
EpochNo
computeDRepExpiry ppDRepActivity currentEpoch =
binOpEpochNo
(-)
(addEpochInterval currentEpoch ppDRepActivity)
2 changes: 1 addition & 1 deletion libs/cardano-ledger-api/cardano-ledger-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
cardano-ledger-alonzo >=1.9 && <1.11,
cardano-ledger-babbage ^>=1.9,
cardano-ledger-binary ^>=1.3,
cardano-ledger-conway >=1.13 && <1.17,
cardano-ledger-conway >=1.13 && <1.18,
cardano-ledger-core ^>=1.14,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.13,
Expand Down

0 comments on commit f49e155

Please sign in to comment.