Skip to content

Commit

Permalink
Run Imp tests with non-zero DRep thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed May 8, 2024
1 parent bd69e9c commit 4b58806
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ spec ::
SpecWith (ImpTestState era)
spec =
describe "ENACT" $ do
relevantDuringBootstrapSpec
treasuryWithdrawalsSpec
noConfidenceSpec
constitutionSpec
Expand All @@ -61,8 +60,9 @@ relevantDuringBootstrapSpec ::
ConwayEraImp era =>
SpecWith (ImpTestState era)
relevantDuringBootstrapSpec = do
actionPrioritySpec
hardForkInitiationNoDRepsSpec
describe "ENACT (bootstrap phase)" $ do
actionPrioritySpec
hardForkInitiationNoDRepsSpec

treasuryWithdrawalsSpec ::
forall era.
Expand Down Expand Up @@ -402,10 +402,7 @@ actionPrioritySpec =
let val3 = Coin 1_000_003

it "proposals of same priority are enacted in order of submission" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
modifyPParams $ ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1

(committeeC :| _) <- registerInitialCommittee
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
Expand Down Expand Up @@ -435,10 +432,7 @@ actionPrioritySpec =
`shouldReturn` val3

it "only the first action of a transaction gets enacted" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
modifyPParams $ ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
(committeeC :| _) <- registerInitialCommittee
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
gaids <-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ import Test.Cardano.Ledger.Imp.Common

spec ::
forall era.
( ConwayEraImp era
, InjectRuleEvent "TICK" ConwayEpochEvent era
, Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era
, Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era
) =>
ConwayEraImp era =>
SpecWith (ImpTestState era)
spec =
describe "EPOCH" $ do
relevantDuringBootstrapSpec
proposalsSpec
dRepSpec
dRepVotingSpec
treasurySpec

Expand All @@ -63,9 +60,10 @@ relevantDuringBootstrapSpec ::
) =>
SpecWith (ImpTestState era)
relevantDuringBootstrapSpec = do
proposalsSpec
dRepSpec
eventsSpec
describe "EPOCH (bootstrap phase)" $ do
proposalsSpec
dRepSpec
eventsSpec

proposalsSpec ::
forall era.
Expand Down Expand Up @@ -215,12 +213,6 @@ dRepVotingSpec ::
dRepVotingSpec =
describe "DRep" $ do
it "proposal is accepted after two epochs" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL
.~ def
{ dvtPPEconomicGroup = 1 %! 1
}
let getParamValue = getsNES (nesEsL . curPParamsEpochStateL . ppMinFeeAL)
initialParamValue <- getParamValue

Expand Down Expand Up @@ -363,7 +355,6 @@ eventsSpec = describe "Events" $ do
modifyPParams $ \pp ->
pp
& ppGovActionLifetimeL .~ EpochInterval actionLifetime
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
propDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppGovActionDepositL
let
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,6 @@ votingSpec =
modifyPParams $ \pp ->
pp
& ppGovActionLifetimeL .~ EpochInterval 3
& ppDRepVotingThresholdsL
.~ def
{ dvtUpdateToConstitution = 1 %! 2
}
& ppCommitteeMinSizeL .~ 2
(dRepCred, _, _) <- setupSingleDRep 1_000_000
ccColdCred0 <- KeyHashObj <$> freshKeyHash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ spec ::
SpecWith (ImpTestState era)
spec =
describe "RATIFY" $ do
relevantDuringBootstrapSpec
votingSpec
delayingActionsSpec
spoVotesCommitteeUpdates
Expand All @@ -54,7 +53,8 @@ relevantDuringBootstrapSpec ::
ConwayEraImp era =>
SpecWith (ImpTestState era)
relevantDuringBootstrapSpec =
spoVotesForHardForkInitiation
describe "RATIFY (bootstrap phase)" $ do
spoVotesForHardForkInitiation

committeeExpiryResignationDiscountSpec ::
forall era.
Expand Down Expand Up @@ -132,12 +132,8 @@ paramChangeAffectsProposalsSpec =
smallerThreshold :: UnitInterval
smallerThreshold = 1 %! 2
describe "DRep" $ do
let setThreshold :: UnitInterval -> ImpTestM era ()
setThreshold threshold = do
drepVotingThresholds <- getsPParams ppDRepVotingThresholdsL
modifyPParams $
ppDRepVotingThresholdsL
.~ (drepVotingThresholds & dvtCommitteeNormalL .~ threshold)
let setThreshold threshold =
modifyPParams $ ppDRepVotingThresholdsL . dvtCommitteeNormalL .~ threshold
enactThreshold ::
UnitInterval ->
Credential 'DRepRole (EraCrypto era) ->
Expand Down
24 changes: 16 additions & 8 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,25 @@ instance
where
initConwayNES committee constitution nes =
let newNes =
(initAlonzoImpNES nes)
initAlonzoImpNES nes
& nesEsL . curPParamsEpochStateL . ppDRepActivityL .~ EpochInterval 100
& nesEsL . curPParamsEpochStateL . ppGovActionLifetimeL .~ EpochInterval 30
& nesEsL . curPParamsEpochStateL . ppGovActionDepositL .~ Coin 123
& nesEsL . curPParamsEpochStateL . ppCommitteeMaxTermLengthL .~ EpochInterval 20
& nesEsL . curPParamsEpochStateL . ppCommitteeMinSizeL .~ 1
& nesEsL . curPParamsEpochStateL . ppDRepVotingThresholdsL
%~ ( \dvt ->
dvt
{ dvtCommitteeNormal = 1 %! 1
, dvtCommitteeNoConfidence = 1 %! 2
, dvtUpdateToConstitution = 1 %! 2
}
)
.~ DRepVotingThresholds
{ dvtMotionNoConfidence = 51 %! 100
, dvtCommitteeNormal = 51 %! 100
, dvtCommitteeNoConfidence = 51 %! 100
, dvtUpdateToConstitution = 51 %! 100
, dvtHardForkInitiation = 51 %! 100
, dvtPPNetworkGroup = 51 %! 100
, dvtPPEconomicGroup = 51 %! 100
, dvtPPTechnicalGroup = 51 %! 100
, dvtPPGovGroup = 51 %! 100
, dvtTreasuryWithdrawal = 51 %! 100
}
& nesEsL . epochStateGovStateL . committeeGovStateL .~ SJust committee
& nesEsL . epochStateGovStateL . constitutionGovStateL .~ constitution
epochState = newNes ^. nesEsL
Expand Down Expand Up @@ -1195,6 +1200,9 @@ electBasicCommittee = do
submitYesVote_ (DRepVoter drep) gaidCommitteeProp
passEpoch
passEpoch
committeeMembers <- getCommitteeMembers
impAnn "The committee should be enacted" $
committeeMembers `shouldSatisfy` Set.member coldCommitteeC
hotCommitteeC <- registerCommitteeHotKey coldCommitteeC
pure (drep, hotCommitteeC, GovPurposeId gaidCommitteeProp)

Expand Down

0 comments on commit 4b58806

Please sign in to comment.