Skip to content

Commit

Permalink
Restrict voting during bootstrap phase
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Apr 29, 2024
1 parent 4014dd0 commit 4f04ba9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,21 @@ checkVotersAreValid currentEpoch committeeState votes =
DRepVoter {} -> isDRepVotingAllowed (gasAction gas)
StakePoolVoter {} -> isStakePoolVotingAllowed (gasAction gas)

checkBootstrapVotes ::
forall era.
EraPParams era =>
PParams era ->
[(Voter (EraCrypto era), GovActionState era)] ->
Test (ConwayGovPredFailure era)
checkBootstrapVotes pp votes
| HF.bootstrapPhase (pp ^. ppProtocolVersionL) =
checkDisallowedVotes votes DisallowedVotesDuringBootstrap $ \gas ->
\case
DRepVoter {} | gasAction gas == InfoAction -> True
DRepVoter {} -> False
_ -> isBootstrapAction $ gasAction gas
| otherwise = pure ()

actionWellFormed :: ConwayEraPParams era => GovAction era -> Test (ConwayGovPredFailure era)
actionWellFormed ga = failureUnless isWellFormed $ MalformedProposal ga
where
Expand Down Expand Up @@ -439,7 +454,9 @@ govTransition = do
([], [])
votingProcedures
curGovActionIds = proposalsActionsMap proposals

failOnNonEmpty unknownGovActionIds GovActionsDoNotExist
runTest $ checkBootstrapVotes pp knownVotes
runTest $ checkVotesAreNotForExpiredActions currentEpoch knownVotes
runTest $ checkVotersAreValid currentEpoch committeeState knownVotes

Expand Down Expand Up @@ -472,7 +489,6 @@ checkDisallowedVotes votes failure canBeVotedOnBy =
disallowedVotes =
[(voter, gasId gas) | (voter, gas) <- votes, not (gas `canBeVotedOnBy` voter)]


-- | If the GovAction is a HardFork, then return 3 things (if they exist)
-- 1) The (StrictMaybe GovPurposeId), pointed to by the HardFork proposal
-- 2) The proposed ProtVer
Expand Down

0 comments on commit 4f04ba9

Please sign in to comment.