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

IsPerasCert cert blk 
PerasParams blk

Peras protocol parameters

PerasRoundNo

Current Peras round number

→ cert

Most recent certificate seen by the voter

WithOrigin PerasRoundNo

Round number of the latest certificate present in our preferred chain

Set PerasRoundNo

Set of certificates (by their round number) present in our database

PerasCertInclusionView cert blk

Constructed certificate inclusion view

Construct a PerasCertInclusionView from the given inputs.

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

newtype PerasCertInclusionViewHandle (m ∷ TypeType) blk Source #

Handle for querying the Peras certificate inclusion rules via STM.

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.

Instances

Instances details
Eq cert ⇒ Eq (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

Generic (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

Associated Types

type Rep (PerasCertInclusionRulesDecision cert) 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

type Rep (PerasCertInclusionRulesDecision cert) = D1 ('MetaData "PerasCertInclusionRulesDecision" "Ouroboros.Consensus.Peras.Cert.Inclusion" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "IncludeCert" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Evidence 'True PerasCertInclusionRule)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 cert)) :+: C1 ('MetaCons "DoNotIncludeCert" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Evidence 'False PerasCertInclusionRule))))
Show cert ⇒ Show (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

NoThunks cert ⇒ NoThunks (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

IsPerasCert cert blk ⇒ Explainable (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

type Rep (PerasCertInclusionRulesDecision cert) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Cert.Inclusion

type Rep (PerasCertInclusionRulesDecision cert) = D1 ('MetaData "PerasCertInclusionRulesDecision" "Ouroboros.Consensus.Peras.Cert.Inclusion" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "IncludeCert" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Evidence 'True PerasCertInclusionRule)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 cert)) :+: C1 ('MetaCons "DoNotIncludeCert" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Evidence 'False PerasCertInclusionRule))))

needCertPerasCertInclusionView cert blk → PerasCertInclusionRulesDecision cert Source #

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

needCertWithHandle ∷ ∀ (m ∷ TypeType) blk. MonadSTM m ⇒ PerasCertInclusionViewHandle m blk → PerasRoundNoSTM m (Maybe (PerasCertInclusionRulesDecision (WithArrivalTime (ValidatedPerasCert blk)))) Source #

Query the Peras certificate inclusion rules via STM.

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.