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

Ouroboros.Consensus.Peras.Voting.View

Description

Pure Peras voting rules

This module implements some machinery to abstract away the impure inputs needed to evaluate the Peras voting rules in a pure fashion.

NOTE: most of the code in this module returns values over PerasEnabled to reflect the fact that some of the computations performed here require querying a hard fork summary to map timestamps and slot numbers to their corresponding Peras round numbers. This may not be possible if Peras was not enabled at the relevant points in time, and such a case should be handled appropriately by the caller.

Synopsis

Documentation

data PerasQryException Source #

Exceptions thrown when querying Peras-related historical information

Constructors

PerasQryExceptionPastHorizon PastHorizonException

The hard fork summary does not cover the needed point in time.

PerasQryExceptionPerasDisabled

Peras is not enabled at the needed point in time.

data PerasQry (xs ∷ [Type]) a Source #

Monad for querying Peras-related information from a hard fork summary.

This covers two possible error cases: 1. the hard fork summary does not cover the needed point in time, or 2. Peras is not enabled at the needed point in time.

Instances

Instances details
Applicative (PerasQry xs) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

Methods

pure ∷ a → PerasQry xs a #

(<*>)PerasQry xs (a → b) → PerasQry xs a → PerasQry xs b #

liftA2 ∷ (a → b → c) → PerasQry xs a → PerasQry xs b → PerasQry xs c #

(*>)PerasQry xs a → PerasQry xs b → PerasQry xs b #

(<*)PerasQry xs a → PerasQry xs b → PerasQry xs a #

Functor (PerasQry xs) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

Methods

fmap ∷ (a → b) → PerasQry xs a → PerasQry xs b #

(<$) ∷ a → PerasQry xs b → PerasQry xs a #

Monad (PerasQry xs) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

Methods

(>>=)PerasQry xs a → (a → PerasQry xs b) → PerasQry xs b #

(>>)PerasQry xs a → PerasQry xs b → PerasQry xs b #

return ∷ a → PerasQry xs a #

runPerasQry ∷ ∀ (xs ∷ [Type]) a. Summary xs → PerasQry xs a → Either PerasQryException a Source #

Run a PerasQry against a hard fork summary

perasRoundStart ∷ ∀ (xs ∷ [Type]). PerasRoundNoPerasQry xs SlotNo Source #

Slot number at the start of a Peras round

perasChainAtCandidateBlock ∷ ∀ blk (xs ∷ [Type]). GetHeader blk ⇒ PerasBlockMinSlotsPerasRoundNoAnchoredFragment (Header blk) → PerasQry xs (AnchoredFragment (Header blk)) Source #

Chain prefix leading to the candidate block.

This corresponds to the last block before the candidate slot horizon, defined as the slot that is at least blockMinSlots (L) old from the start of the current round.

NOTE: this is where the candidate is determined according to CIP-0140. This function may evolve in the future if the candidate block selection becomes more complex.

data LatestCertSeenView cert Source #

View of the latest certificate seen by the voter

NOTE: the voting rules depend on the candidate block indirectly. This is reflected in the fact that the voting view does not contain the candidate block or its point, but only whether the candidate block extends the block boosted by the most recent certificate seen by the voter, which is provided to the rules via lcsCandidateBlockExtendsCert here.

Constructors

LatestCertSeenView 

Fields

Instances

Instances details
Show cert ⇒ Show (LatestCertSeenView cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

newtype LatestCertOnChainView cert Source #

View of the latest certificate present in our preferred chain

NOTE: if we add more fields here in the future, do not forget to add strictness annotations as needed.

Constructors

LatestCertOnChainView 

Fields

  • lcocCert ∷ cert

    Latest certificate present in our preferred chain

Instances

Instances details
Show cert ⇒ Show (LatestCertOnChainView cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

data PerasVotingView cert Source #

Interface needed to evaluate the Peras voting rules

NOTE: the voting rules depend on the candidate block indirectly. This is reflected in the fact that the voting view does not contain the candidate block or its point, but only whether the candidate block extends the block boosted by the most recent certificate seen by the voter, which is provided to the rules via lcsCandidateBlockExtendsCert inside latestCertSeen.

Constructors

PerasVotingView 

Fields

Instances

Instances details
Show cert ⇒ Show (PerasVotingView cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Voting.View

Methods

showsPrecIntPerasVotingView cert → ShowS #

showPerasVotingView cert → String #

showList ∷ [PerasVotingView cert] → ShowS #

mkPerasVotingView Source #

Arguments

∷ ∀ cert blk (xs ∷ [Type]). (cert ~ WithArrivalTime (ValidatedPerasCert blk), GetHeader blk) 
PerasParams

Peras protocol parameters

PerasRoundNo

Current Peras round number

WithOrigin (WithBoostedBlockStatus cert)

Most recent certificate seen by the voter

WithOrigin cert

Most recent certificate included in some block in our preferred chain

AnchoredFragment (Header blk)

Prefix leading to the candidate block in the volatile suffix of our preferred chain

PerasQry xs (PerasVotingView cert)

Constructed voting view

Construct a PerasVotingView.

NOTE: this assumes that the client code computes all the needed inputs within the same STM transaction, or the results may be inconsistent.