ouroboros-consensus-1.0.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

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:

https://github.com/cardano-foundation/CIPs/blob/master/CIP-0140/README.md#rules-for-voting-in-a-round

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

Documentation

isPerasVotingAllowedHasPerasCertRound 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 PerasRoundNo parameter corresponds to the existential value c.

data PerasVotingRulesDecision Source #

Whether we are allowed to vote according to the rules.

This type additionally carries the evidence for the decision taken.

perasVR1AHasPerasCertRound 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.

perasVR1BPerasVotingView cert → Pred PerasVotingRule Source #

VR-1B: the block being voted upon extends the most recently certified one.

perasVR2AHasPerasCertRound 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.

perasVR2BHasPerasCertRound 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.

perasVR1HasPerasCertRound 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.

perasVR2HasPerasCertRound 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.

perasVotingRulesHasPerasCertRound cert ⇒ PerasVotingView cert → Pred PerasVotingRule Source #

Voting is allowed if either VR-1A and VR-1B hold, or VR-2A and VR-2B hold.