| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Peras.Voting.Rules
Description
Pure Peras voting rules
This module implements the Peras voting rules in a pure fashion. These are translated as verbatim as possible from:
NOTE: in this file, we use uncommon variable names such as _L or _X
because that is their name in the CIP-0140, and we can't have variable names
starting with capital letters. Contrary to typical Haskell conventions, those
do not denote ignored variables.
Synopsis
- isPerasVotingAllowed ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → PerasVotingRulesDecision
- data PerasVotingRule
- = VR1A
- | VR1B
- | VR2A
- | VR2B PerasRoundNo
- data PerasVotingRulesDecision
- perasVR1A ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
- perasVR1B ∷ PerasVotingView cert → Pred PerasVotingRule
- perasVR2A ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
- perasVR2B ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
- perasVR1 ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
- perasVR2 ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
- perasVotingRules ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule
Documentation
isPerasVotingAllowed ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → PerasVotingRulesDecision Source #
Evaluate whether voting is allowed or not according to the voting rules
data PerasVotingRule Source #
Voting rules
Each constructor corresponds to a voting rule as per CIP-0140.
- VR1x correspond to the "happy" path, i.e., when nodes proceed to vote normally, whereas
- VR2x correspond to the "cooldown" path, i.e., when nodes are exiting a cooldown period.
Constructors
| VR1A | The voter has seen the certificate for the previous round, and the certificate was received in the first X slots after the start of the round |
| VR1B | The block being voted upon extends the most recently certified one. |
| VR2A | The last certificate a party has seen is from a round at least R rounds ago |
| VR2B PerasRoundNo | The last certificate included in our preferred chain is from a round exactly c⋅K rounds ago for some c ∈ ℕ with c ≥ 0. The |
Instances
| Show PerasVotingRule Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.Rules Methods showsPrec ∷ Int → PerasVotingRule → ShowS # show ∷ PerasVotingRule → String # showList ∷ [PerasVotingRule] → ShowS # | |
| Eq PerasVotingRule Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.Rules Methods (==) ∷ PerasVotingRule → PerasVotingRule → Bool # (/=) ∷ PerasVotingRule → PerasVotingRule → Bool # | |
| Explainable PerasVotingRule Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.Rules Methods explain ∷ ExplanationMode → PerasVotingRule → String Source # explainPrec ∷ Int → ExplanationMode → PerasVotingRule → String Source # | |
data PerasVotingRulesDecision Source #
Whether we are allowed to vote according to the rules.
This type additionally carries the evidence for the decision taken.
Constructors
| Vote (Evidence 'True PerasVotingRule) | |
| NoVote (Evidence 'False PerasVotingRule) |
Instances
| Show PerasVotingRulesDecision Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.Rules Methods showsPrec ∷ Int → PerasVotingRulesDecision → ShowS # | |
| Explainable PerasVotingRulesDecision Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.Rules Methods explain ∷ ExplanationMode → PerasVotingRulesDecision → String Source # explainPrec ∷ Int → ExplanationMode → PerasVotingRulesDecision → String Source # | |
perasVR1A ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
VR-1A: the voter has seen the certificate for the previous round, and the certificate was received in the first X slots after the start of the round.
perasVR1B ∷ PerasVotingView cert → Pred PerasVotingRule Source #
VR-1B: the block being voted upon extends the most recently certified one.
perasVR2A ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
VR-2A: the last certificate a party has seen is from a round at least R rounds ago.
This enforces the chain-healing period that must occur before leaving a cooldown period.
perasVR2B ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
VR-2B: the last certificate included in our preferred chain is from a round exactly c⋅K rounds ago for some c ∈ ℕ with c ≥ 0.
This enforces chain quality and common prefix before leaving a cooldown period.
perasVR1 ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
Both VR-1A and VR-1B hold, which is the situation typically occurring when the voting has regularly occurred in preceding rounds.
perasVR2 ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
Both VR-2A and VR-2B hold, which is the situation typically occurring when the chain is about to exit a cooldown period.
perasVotingRules ∷ HasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #
Voting is allowed if either VR-1A and VR-1B hold, or VR-2A and VR-2B hold.