Skip to content

Commit

Permalink
Set DRep threshold to 0 during bootstrap phase for param change action
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed May 8, 2024
1 parent 6c780d7 commit bd69e9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,17 @@ toRatifyStatePairs cg@(RatifyState _ _ _ _) =
pparamsUpdateThreshold ::
forall era.
ConwayEraPParams era =>
PParams era ->
DRepVotingThresholds ->
PParamsUpdate era ->
UnitInterval
pparamsUpdateThreshold pp ppu =
pparamsUpdateThreshold thresholds ppu =
let thresholdLens = \case
NetworkGroup -> dvtPPNetworkGroupL
GovGroup -> dvtPPGovGroupL
TechnicalGroup -> dvtPPTechnicalGroupL
EconomicGroup -> dvtPPEconomicGroupL
lookupGroupThreshold (PPGroups grp _) =
pp ^. ppDRepVotingThresholdsL . thresholdLens grp
thresholds ^. thresholdLens grp
in Set.foldr' max minBound $
Set.map lookupGroupThreshold $
modifiedPPGroups @era ppu
Expand Down Expand Up @@ -497,7 +497,7 @@ votingDRepThresholdInternal ::
GovAction era ->
VotingThreshold
votingDRepThresholdInternal pp isElectedCommittee action =
let DRepVotingThresholds
let thresholds@DRepVotingThresholds
{ dvtCommitteeNoConfidence
, dvtCommitteeNormal
, dvtUpdateToConstitution
Expand All @@ -515,7 +515,7 @@ votingDRepThresholdInternal pp isElectedCommittee action =
else dvtCommitteeNoConfidence
NewConstitution {} -> VotingThreshold dvtUpdateToConstitution
HardForkInitiation {} -> VotingThreshold dvtHardForkInitiation
ParameterChange _ ppu _ -> VotingThreshold $ pparamsUpdateThreshold pp ppu
ParameterChange _ ppu _ -> VotingThreshold $ pparamsUpdateThreshold thresholds ppu
TreasuryWithdrawals {} -> VotingThreshold dvtTreasuryWithdrawal
InfoAction {} -> NoVotingThreshold

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import qualified Data.Map.Strict as Map
import Data.Ratio ((%))
import qualified Data.Set as Set
import Data.Word (Word64)
import Lens.Micro
import Test.Cardano.Ledger.Common
import Test.Cardano.Ledger.Conway.Arbitrary ()
import Test.Cardano.Ledger.Core.Arbitrary ()
Expand All @@ -63,13 +62,12 @@ spec = do
correctThresholdsProp ::
forall era.
( ConwayEraPParams era
, Arbitrary (PParams era)
, Arbitrary (PParamsUpdate era)
) =>
Spec
correctThresholdsProp = do
prop "PParamsUpdateThreshold always selects a threshold" $ \(pp :: PParams era) ppu -> do
let DRepVotingThresholds {..} = pp ^. ppDRepVotingThresholdsL
prop "PParamsUpdateThreshold always selects a threshold" $ \thresholds ppu -> do
let DRepVotingThresholds {..} = thresholds
allDRepThresholds =
Set.fromList
[ dvtPPNetworkGroup
Expand All @@ -78,8 +76,8 @@ correctThresholdsProp = do
, dvtPPGovGroup
]
when (ppu /= emptyPParamsUpdate) $
pparamsUpdateThreshold pp ppu `shouldSatisfy` (`Set.member` allDRepThresholds)
pparamsUpdateThreshold pp emptyPParamsUpdate `shouldBe` (0 %! 1)
pparamsUpdateThreshold @era thresholds ppu `shouldSatisfy` (`Set.member` allDRepThresholds)
pparamsUpdateThreshold @era thresholds emptyPParamsUpdate `shouldBe` (0 %! 1)

acceptedRatioProp :: forall era. Era era => Spec
acceptedRatioProp = do
Expand Down

0 comments on commit bd69e9c

Please sign in to comment.