ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Peras.Cert.Inclusion

Description

This module defines the logic needed to evaluate when a Peras certificate must be included in a block.

NOTE: in this file, we use uncommon variable names such as _A 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

data LatestCertSeenView cert Source #

View of the latest certificate seen by the voter

Constructors

LatestCertSeenView 

Fields

Instances

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

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

data LatestCertOnChainView cert Source #

View of the latest certificate present in our preferred chain

Constructors

LatestCertOnChainView 

Fields

Instances

Instances details
Show (LatestCertOnChainView cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

data PerasCertInclusionView cert blk Source #

Interface needed to evaluate the Peras cert inclusion rules

Constructors

PerasCertInclusionView 

Fields

Instances

Instances details
Show cert ⇒ Show (PerasCertInclusionView cert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

Methods

showsPrecIntPerasCertInclusionView cert blk → ShowS #

showPerasCertInclusionView cert blk → String #

showList ∷ [PerasCertInclusionView cert blk] → ShowS #

mkPerasCertInclusionView Source #

Arguments

HasPerasCertRound cert 
PerasParams

Peras protocol parameters

PerasRoundNo

Current Peras round number

WithOrigin cert

Most recent certificate seen by the voter

WithOrigin PerasRoundNo

Round number of the latest certificate present in our preferred chain

PerasCertSnapshot blk

Snapshot of the certificates we have in our database

Maybe (PerasCertInclusionView cert blk)

Constructed certificate inclusion view

Construct a PerasCertInclusionView from the given inputs.

Returns Nothing if we are trying to construct the view without having a latest certificate seen, which is a precondition to being able to include it in the block we are building.

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

data PerasCertInclusionRule Source #

Certificate inclusion rules.

Each constructor corresponds to one of the members in the conjunction defined in needCert per CIP-0140.

Constructors

NoCertsFromTwoRoundsAgo 

Fields

LatestCertSeenIsNotExpired 

Fields

  • PerasRoundNo

    The round number of the latest certificate seen by the voter

LatestCertSeenIsNewerThanLatestCertOnChain 

Fields

  • PerasRoundNo

    The round number of the latest certificate seen by the voter

  • (WithOrigin PerasRoundNo)

    The round number of the latest certificate present in our preferred chain, if it exists

data PerasCertInclusionRulesDecision cert Source #

Whether we are expected to add a certificate to the block we are building according to the inclusion rules.

These rules are taken as verbatim as possible from the Peras CIP-0140: https://github.com/cardano-foundation/CIPs/blob/master/CIP-0140/README.md#block-creation

This type additionally carries the evidence for the decision taken.

needCertPerasCertInclusionView cert blk → PerasCertInclusionRulesDecision cert Source #

Evaluate whether we need to include a certificate in the block we are building.

noCertsFromTwoRoundsAgoPerasCertInclusionView cert blk → Pred PerasCertInclusionRule Source #

noCertsFromTwoRoundsAgo: we haven't seen a certificate from two rounds ago

needCertRulesPerasCertInclusionView cert blk → Pred PerasCertInclusionRule Source #

We need to include a certificate in the block we are building if all the rules in this conjunction are satisfied.