Skip to content

Commit

Permalink
Rename committeeQuorum to committeeThreshold
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketd committed Feb 7, 2024
1 parent b547c77 commit a1f6961
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.13.0.0

* Rename `committeeQuorum` to `committeeThreshold` #4053
* Changed `GovActionState` to have 1 field (`gasProposalProcedure`) rather than 3 (`gasDeposit`, `gasAction`, `gasReturnAddr`)
* the old field names (`gasDeposit`, `gasAction`, `gasReturnAddr`) become functions, and the lenses
* (`gasDepositL`, `gasActionL`, `gasReturnAddrL`) have the same type, but behave differently.
Expand Down
6 changes: 3 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Cardano.Ledger.Conway.Governance (
ConwayGovState (..),
Committee (..),
committeeMembersL,
committeeQuorumL,
committeeThresholdL,
GovAction (..),
GovActionState (..),
GovActionIx (..),
Expand Down Expand Up @@ -667,7 +667,7 @@ ensCommitteeMembers ::
EnactState era ->
Maybe (Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo, UnitInterval)
ensCommitteeMembers ens = case ens ^. ensCommitteeL of
SJust Committee {..} -> Just (committeeMembers, committeeQuorum)
SJust Committee {..} -> Just (committeeMembers, committeeThreshold)
SNothing -> Nothing

class EraGov era => ConwayEraGov era where
Expand Down Expand Up @@ -813,7 +813,7 @@ votingCommitteeThresholdInternal pp committee = \case
InfoAction {} -> NoVotingThreshold
where
threshold =
case committeeQuorum <$> committee of
case committeeThreshold <$> committee of
-- if the committee size is smaller than the mnimimum given in pparams,
-- we treat it as if we had no committe
SJust t | committeeSize >= minSize -> VotingThreshold t
Expand Down
20 changes: 10 additions & 10 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Procedures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Cardano.Ledger.Conway.Governance.Procedures (
pProcReturnAddrL,
pProcAnchorL,
committeeMembersL,
committeeQuorumL,
committeeThresholdL,
gasDRepVotesL,
gasStakePoolVotesL,
gasCommitteeVotesL,
Expand Down Expand Up @@ -546,8 +546,8 @@ toProposalProcedurePairs proposalProcedure@(ProposalProcedure _ _ _ _) =
data Committee era = Committee
{ committeeMembers :: !(Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo)
-- ^ Committee members with epoch number when each of them expires
, committeeQuorum :: !UnitInterval
-- ^ Quorum of the committee that is necessary for a successful vote
, committeeThreshold :: !UnitInterval
-- ^ Threshold of the committee that is necessary for a successful vote
}
deriving (Eq, Show, Generic)

Expand All @@ -561,8 +561,8 @@ instance Default (Committee era) where
committeeMembersL :: Lens' (Committee era) (Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo)
committeeMembersL = lens committeeMembers (\c m -> c {committeeMembers = m})

committeeQuorumL :: Lens' (Committee era) UnitInterval
committeeQuorumL = lens committeeQuorum (\c q -> c {committeeQuorum = q})
committeeThresholdL :: Lens' (Committee era) UnitInterval
committeeThresholdL = lens committeeThreshold (\c q -> c {committeeThreshold = q})

instance Era era => DecCBOR (Committee era) where
decCBOR =
Expand All @@ -573,11 +573,11 @@ instance Era era => DecCBOR (Committee era) where
{-# INLINE decCBOR #-}

instance Era era => EncCBOR (Committee era) where
encCBOR Committee {committeeMembers, committeeQuorum} =
encCBOR Committee {committeeMembers, committeeThreshold} =
encode $
Rec (Committee @era)
!> To committeeMembers
!> To committeeQuorum
!> To committeeThreshold

instance EraPParams era => ToJSON (Committee era) where
toJSON = object . toCommitteePairs
Expand All @@ -589,13 +589,13 @@ instance Era era => FromJSON (Committee era) where
parseCommittee o =
Committee
<$> (forceElemsToWHNF <$> o .: "members")
<*> o .: "quorum"
<*> o .: "threshold"

toCommitteePairs :: (KeyValue e a, EraPParams era) => Committee era -> [a]
toCommitteePairs committee@(Committee _ _) =
let Committee {..} = committee
in [ "members" .= committeeMembers
, "quorum" .= committeeQuorum
, "threshold" .= committeeThreshold
]

data GovActionPurpose
Expand Down Expand Up @@ -802,7 +802,7 @@ data GovAction era
!(Set (Credential 'ColdCommitteeRole (EraCrypto era)))
-- | Constitutional committee members to be added
!(Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo)
-- | New quorum
-- | New Threshold
!UnitInterval
| NewConstitution
-- | Previous governance action id of `NewConstitution` type, which corresponds to
Expand Down
10 changes: 5 additions & 5 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Enact.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ enactmentTransition = do
st
& ensCommitteeL .~ SNothing
& ensPrevCommitteeL .~ SJust (GovPurposeId govActionId)
UpdateCommittee _ membersToRemove membersToAdd newQuorum -> do
UpdateCommittee _ membersToRemove membersToAdd newThreshold -> do
st
& ensCommitteeL %~ SJust . updatedCommittee membersToRemove membersToAdd newQuorum
& ensCommitteeL %~ SJust . updatedCommittee membersToRemove membersToAdd newThreshold
& ensPrevCommitteeL .~ SJust (GovPurposeId govActionId)
NewConstitution _ c ->
st
Expand All @@ -106,14 +106,14 @@ updatedCommittee ::
UnitInterval ->
StrictMaybe (Committee era) ->
Committee era
updatedCommittee membersToRemove membersToAdd newQuorum committee =
updatedCommittee membersToRemove membersToAdd newThreshold committee =
case committee of
SNothing -> Committee membersToAdd newQuorum
SNothing -> Committee membersToAdd newThreshold
SJust (Committee currentMembers _) ->
let newCommitteeMembers =
Map.union
membersToAdd
(currentMembers `Map.withoutKeys` membersToRemove)
in Committee
newCommitteeMembers
newQuorum
newThreshold
4 changes: 2 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,12 @@ transGovAction proxy = \case
(transMap transRewardAccount transCoinToLovelace withdrawals)
(transGovPolicy govPolicy)
NoConfidence pGovActionId -> PV3.NoConfidence (transPrevGovActionId pGovActionId)
UpdateCommittee pGovActionId ccToRemove ccToAdd quorum ->
UpdateCommittee pGovActionId ccToRemove ccToAdd threshold ->
PV3.UpdateCommittee
(transPrevGovActionId pGovActionId)
(map (PV3.ColdCommitteeCredential . transCred) $ Set.toList ccToRemove)
(transMap (PV3.ColdCommitteeCredential . transCred) transEpochNo ccToAdd)
(transBoundedRational quorum)
(transBoundedRational threshold)
NewConstitution pGovActionId constitution ->
PV3.NewConstitution
(transPrevGovActionId pGovActionId)
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/test/data/conway-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"keyHash-4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a": 1,
"scriptHash-4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a": 2
},
"quorum": 0.5
"threshold": 0.5
},
"delegs": {
"keyHash-4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a": {
Expand Down
4 changes: 2 additions & 2 deletions libs/cardano-ledger-api/src/Cardano/Ledger/Api/State/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ queryCommitteeMembersState ::
NewEpochState era ->
Maybe (CommitteeMembersState (EraCrypto era))
queryCommitteeMembersState coldCredsFilter hotCredsFilter statusFilter nes = do
(comMembers, comQuorum) <- getCommitteeMembers nes
(comMembers, comThreshold) <- getCommitteeMembers (queryGovState nes)
let nextComMembers =
maybe Map.empty fst (getNextEpochCommitteeMembers (queryGovState nes))
let comStateMembers =
Expand Down Expand Up @@ -260,7 +260,7 @@ queryCommitteeMembersState coldCredsFilter hotCredsFilter statusFilter nes = do
pure
CommitteeMembersState
{ csCommittee = cms
, csQuorum = comQuorum
, csThreshold = comThreshold
, csEpochNo = currentEpoch
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ toCommitteeMemberStatePairs c@(CommitteeMemberState _ _ _ _) =

data CommitteeMembersState c = CommitteeMembersState
{ csCommittee :: !(Map (Credential 'ColdCommitteeRole c) (CommitteeMemberState c))
, csQuorum :: !UnitInterval
, csThreshold :: !UnitInterval
, csEpochNo :: !EpochNo
-- ^ Current epoch number. This is necessary to interpret committee member states
}
Expand All @@ -162,7 +162,7 @@ instance Crypto c => EncCBOR (CommitteeMembersState c) where
in encode $
Rec (CommitteeMembersState @c)
!> To csCommittee
!> To csQuorum
!> To csThreshold
!> To csEpochNo

instance Crypto c => DecCBOR (CommitteeMembersState c) where
Expand All @@ -181,6 +181,6 @@ toCommitteeMembersStatePairs :: (KeyValue e a, Crypto c) => CommitteeMembersStat
toCommitteeMembersStatePairs c@(CommitteeMembersState _ _ _) =
let CommitteeMembersState {..} = c
in [ "committee" .= csCommittee
, "quorum" .= csQuorum
, "threshold" .= csThreshold
, "epoch" .= csEpochNo
]
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ propActiveAuthorized ::
Expectation
propActiveAuthorized nes = do
withCommitteeInfo nes $
\(Committee comMembers comQuorum) (CommitteeState comStateMembers) _ noFilterResult -> do
\(Committee comMembers comThreshold) (CommitteeState comStateMembers) _ noFilterResult -> do
let activeAuthorized =
Map.mapMaybe
( \case
Expand All @@ -243,7 +243,7 @@ propActiveAuthorized nes = do
Map.intersection comStateMembers activeAuthorized
`shouldSatisfy` all isJust
csEpochNo noFilterResult `shouldBe` epochNo
csQuorum noFilterResult `shouldBe` comQuorum
csThreshold noFilterResult `shouldBe` comThreshold

propFilters ::
forall era.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ committeeT :: forall era. Era era => RootTarget era (Committee era) (Committee e
committeeT =
Invert "Committee" (typeRep @(Committee era)) Committee
:$ Lensed commMembers committeeMembersL
:$ Lensed commQuorum committeeQuorumL
:$ Lensed commQuorum committeeThresholdL

{-
prevGovActionIdsT =
Expand Down

0 comments on commit a1f6961

Please sign in to comment.