| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- data PerasQryException
- data PerasQry (xs ∷ [Type]) a
- runPerasQry ∷ ∀ (xs ∷ [Type]) a. Summary xs → PerasQry xs a → Either PerasQryException a
- perasRoundStart ∷ ∀ (xs ∷ [Type]). PerasRoundNo → PerasQry xs SlotNo
- perasChainAtCandidateBlock ∷ ∀ blk (xs ∷ [Type]). GetHeader blk ⇒ PerasBlockMinSlots → PerasRoundNo → AnchoredFragment (Header blk) → PerasQry xs (AnchoredFragment (Header blk))
- data LatestCertSeenView cert = LatestCertSeenView {}
- newtype LatestCertOnChainView cert = LatestCertOnChainView {
- lcocCert ∷ cert
- data PerasVotingView cert = PerasVotingView {
- perasParams ∷ PerasParams
- currRoundNo ∷ !PerasRoundNo
- latestCertSeen ∷ !(WithOrigin (LatestCertSeenView cert))
- latestCertOnChain ∷ !(WithOrigin (LatestCertOnChainView cert))
- mkPerasVotingView ∷ ∀ cert blk (xs ∷ [Type]). (cert ~ WithArrivalTime (ValidatedPerasCert blk), GetHeader blk) ⇒ PerasParams → PerasRoundNo → WithOrigin (WithBoostedBlockStatus cert) → WithOrigin cert → AnchoredFragment (Header blk) → PerasQry xs (PerasVotingView cert)
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. |
Instances
| Exception PerasQryException Source # | |
| Show PerasQryException Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.View Methods showsPrec ∷ Int → PerasQryException → ShowS # show ∷ PerasQryException → String # showList ∷ [PerasQryException] → ShowS # | |
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.
runPerasQry ∷ ∀ (xs ∷ [Type]) a. Summary xs → PerasQry xs a → Either PerasQryException a Source #
Run a PerasQry against a hard fork summary
perasRoundStart ∷ ∀ (xs ∷ [Type]). PerasRoundNo → PerasQry xs SlotNo Source #
Slot number at the start of a Peras round
perasChainAtCandidateBlock ∷ ∀ blk (xs ∷ [Type]). GetHeader blk ⇒ PerasBlockMinSlots → PerasRoundNo → AnchoredFragment (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
| Show cert ⇒ Show (LatestCertSeenView cert) Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.View Methods showsPrec ∷ Int → LatestCertSeenView cert → ShowS # show ∷ LatestCertSeenView cert → String # showList ∷ [LatestCertSeenView cert] → ShowS # | |
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
| |
Instances
| Show cert ⇒ Show (LatestCertOnChainView cert) Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.View Methods showsPrec ∷ Int → LatestCertOnChainView cert → ShowS # show ∷ LatestCertOnChainView cert → String # showList ∷ [LatestCertOnChainView cert] → ShowS # | |
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
| Show cert ⇒ Show (PerasVotingView cert) Source # | |
Defined in Ouroboros.Consensus.Peras.Voting.View Methods showsPrec ∷ Int → PerasVotingView cert → ShowS # show ∷ PerasVotingView cert → String # showList ∷ [PerasVotingView cert] → ShowS # | |
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.