ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Block.SupportsPeras

Synopsis

Voting committee types for Peras

type PerasVotingCommittee blk = VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk) Source #

Voting committee for Peras indexed by block type

type PerasVotingCommitteeError blk = VotingCommitteeError (PerasCrypto blk) (PerasVotingCommitteeScheme blk) Source #

Error type for Peras voting committee errors

type PerasVotingCommitteeInput blk = VotingCommitteeInput (PerasCrypto blk) (PerasVotingCommitteeScheme blk) Source #

Input needed to build a Peras voting committee

Epoch-dependent context for Peras

data PerasEpochContext blk Source #

Epoch-dependent context used for forging and validation of objects.

Instances

Instances details
(Typeable blk, FromCBOR (PerasVotingCommittee blk)) ⇒ FromCBOR (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(Typeable blk, ToCBOR (PerasVotingCommittee blk)) ⇒ ToCBOR (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Methods

toCBOR ∷ PerasEpochContext blk → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (PerasEpochContext blk) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [PerasEpochContext blk] → Size Source #

Eq (PerasVotingCommittee blk) ⇒ Eq (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Generic (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Associated Types

type Rep (PerasEpochContext blk) 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasEpochContext blk) = D1 ('MetaData "PerasEpochContext" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasEpochContext" 'PrefixI 'True) (S1 ('MetaSel ('Just "pecCommittee") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PerasVotingCommittee blk)) :*: S1 ('MetaSel ('Just "pecParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PerasParams blk))))

Methods

from ∷ PerasEpochContext blk → Rep (PerasEpochContext blk) x #

to ∷ Rep (PerasEpochContext blk) x → PerasEpochContext blk #

Show (PerasVotingCommittee blk) ⇒ Show (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

NoThunks (PerasVotingCommittee blk) ⇒ NoThunks (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasEpochContext blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasEpochContext blk) = D1 ('MetaData "PerasEpochContext" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasEpochContext" 'PrefixI 'True) (S1 ('MetaSel ('Just "pecCommittee") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PerasVotingCommittee blk)) :*: S1 ('MetaSel ('Just "pecParams") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PerasParams blk))))

BlockSupportsPeras class

class (StandardHash blk, Typeable blk, Typeable (PerasVote blk), Show (PerasVote blk), Eq (PerasVote blk), NoThunks (PerasVote blk), IsPerasVote (PerasVote blk) blk, Typeable (BoostedBlock (PerasVote blk)), Show (BoostedBlock (PerasVote blk)), Eq (BoostedBlock (PerasVote blk)), NoThunks (BoostedBlock (PerasVote blk)), Typeable (PerasCert blk), Show (PerasCert blk), Eq (PerasCert blk), NoThunks (PerasCert blk), IsPerasCert (PerasCert blk) blk, Typeable (BoostedBlock (PerasCert blk)), Show (BoostedBlock (PerasCert blk)), Eq (BoostedBlock (PerasCert blk)), NoThunks (BoostedBlock (PerasCert blk)), Typeable (PerasError blk), Show (PerasError blk), Eq (PerasError blk), NoThunks (PerasError blk), IsPerasError (PerasError blk) blk, Exception (PerasError blk), Typeable (PerasVotingCommittee blk), Show (PerasVotingCommittee blk), Eq (PerasVotingCommittee blk), NoThunks (PerasVotingCommittee blk), Typeable (PerasEpochContext blk), Show (PerasEpochContext blk), Eq (PerasEpochContext blk), NoThunks (PerasEpochContext blk), Show (PerasCrypto blk), Eq (PerasCrypto blk), Typeable (PerasCrypto blk), NoThunks (PerasCrypto blk), Show (PerasVotingCommitteeScheme blk), Eq (PerasVotingCommitteeScheme blk), Typeable (PerasVotingCommitteeScheme blk), NoThunks (PerasVotingCommitteeScheme blk), ElectionId (PerasCrypto blk) ~ PerasRoundNo, VoteCandidate (PerasCrypto blk) ~ BoostedBlock (PerasVote blk), VoteCandidate (PerasCrypto blk) ~ BoostedBlock (PerasCert blk)) ⇒ BlockSupportsPeras blk where Source #

Associated Types

type PerasVote blk = (vote ∷ Type) | vote → blk Source #

The concrete Peras vote type for this block type.

type PerasCert blk = (cert ∷ Type) | cert → blk Source #

The concrete Peras certificate type for this block type.

type PerasError blk = (err ∷ Type) | err → blk Source #

The concrete Peras error type for this block type.

type PerasCrypto blk Source #

The crypto scheme used for Peras votes and certificates.

Used to dispatch a block type to a its corresponding voting crypto scheme.

type PerasVotingCommitteeScheme blk Source #

The voting committee scheme used for Peras.

Used to dispatch a block type to a its corresponding voting committee scheme.

Methods

forgePerasVoteIfEligible ∷ PerasEpochContext blk → PoolId → PrivateKey (PerasCrypto blk) → PerasRoundNo → Point blk → Either (PerasError blk) (Maybe (ValidatedPerasVote blk)) Source #

Forge a Peras vote if the given pool is eligible to vote in the given round.

verifyPerasVote ∷ PerasEpochContext blk → PerasVote blk → Either (PerasError blk) (ValidatedPerasVote blk) Source #

Verify a Peras vote and return its weight if valid.

forgePerasCert ∷ PerasEpochContext blk → PerasVoteCollectionWithQuorum blk → Either (PerasError blk) (ValidatedPerasCert blk) Source #

Forge a Peras certificate from a collection of votes reaching quorum.

verifyPerasCert ∷ PerasEpochContext blk → PerasCert blk → Either (PerasError blk) (ValidatedPerasCert blk) Source #

Verify a Peras certificate and return its boost if valid.

getPerasCertInBlock ∷ blk → Either (PerasError blk) (Maybe (PerasCert blk)) Source #

Extract a Peras certificate optionally stored in a block.

Returns Nothing if the block does not contain a Peras certificate, or if the block is from an era that does not support Peras certificates.

Instances

Instances details
(StandardHash (HardForkBlock xs), HashSize (HardForkBlock xs) ~ HashSizeOfHead xs, CanHardFork xs) ⇒ BlockSupportsPeras (HardForkBlock xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

(StandardHash m, Typeable m, Typeable a) ⇒ BlockSupportsPeras (DualBlock m a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Associated Types

type PerasVote (DualBlock m a) 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type PerasCert (DualBlock m a) 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type PerasError (DualBlock m a) 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type PerasCrypto (DualBlock m a) 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type PerasVotingCommitteeScheme (DualBlock m a) 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Validated types

data ValidatedPerasVote blk Source #

Constructors

ValidatedPerasVote 

Fields

Instances

Instances details
Eq (PerasVote blk) ⇒ Eq (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Ord (PerasVote blk) ⇒ Ord (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Generic (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Associated Types

type Rep (ValidatedPerasVote blk) 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasVote blk) = D1 ('MetaData "ValidatedPerasVote" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedPerasVote" 'PrefixI 'True) (S1 ('MetaSel ('Just "vpvVote") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasVote blk)) :*: S1 ('MetaSel ('Just "vpvVoteWeight") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VoteWeight)))
Show (PerasVote blk) ⇒ Show (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

NoThunks (PerasVote blk) ⇒ NoThunks (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(IsPerasVote (PerasVote blk) blk, BoostedBlockCompatibleWithPoint (BoostedBlock (PerasVote blk)) blk) ⇒ IsPerasVote (ValidatedPerasVote blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasVote blk) = D1 ('MetaData "ValidatedPerasVote" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedPerasVote" 'PrefixI 'True) (S1 ('MetaSel ('Just "vpvVote") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasVote blk)) :*: S1 ('MetaSel ('Just "vpvVoteWeight") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VoteWeight)))
type BoostedBlock (ValidatedPerasVote blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

data ValidatedPerasCert blk Source #

Constructors

ValidatedPerasCert 

Fields

Instances

Instances details
Eq (PerasCert blk) ⇒ Eq (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Ord (PerasCert blk) ⇒ Ord (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Generic (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Associated Types

type Rep (ValidatedPerasCert blk) 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasCert blk) = D1 ('MetaData "ValidatedPerasCert" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedPerasCert" 'PrefixI 'True) (S1 ('MetaSel ('Just "vpcCert") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasCert blk)) :*: S1 ('MetaSel ('Just "vpcCertBoost") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PerasWeight)))
Show (PerasCert blk) ⇒ Show (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

NoThunks (PerasCert blk) ⇒ NoThunks (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(IsPerasCert (PerasCert blk) blk, BoostedBlockCompatibleWithPoint (BoostedBlock (PerasCert blk)) blk) ⇒ IsPerasCert (ValidatedPerasCert blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (ValidatedPerasCert blk) = D1 ('MetaData "ValidatedPerasCert" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedPerasCert" 'PrefixI 'True) (S1 ('MetaSel ('Just "vpcCert") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasCert blk)) :*: S1 ('MetaSel ('Just "vpcCertBoost") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PerasWeight)))
type BoostedBlock (ValidatedPerasCert blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Peras error types

class IsPerasError err blk | err → blk where Source #

Error types that support injecting certain types of Peras errors

Instances

Instances details
IsPerasError (MockPerasError blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Error.Mock

IsPerasError (PerasError blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Error.V1

IsPerasError (VoidPerasError blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

IsPerasError (PerasError blk) blk ⇒ IsPerasError (WrapPerasError blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.TypeFamilyWrappers

CanHardFork xs ⇒ IsPerasError (HardForkPerasError xs) (HardForkBlock xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

Types and functions related to Peras vote collection and quorum checking

data PerasVoteCollection blk Source #

Collection of Peras votes for a given target.

NOTE: votes in this collection are uniquely identified by their vote ID.

Instances

Instances details
(StandardHash blk, Eq (PerasVote blk), Eq (PerasCert blk)) ⇒ Eq (PerasVoteCollection blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Generic (PerasVoteCollection blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Associated Types

type Rep (PerasVoteCollection blk) 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasVoteCollection blk) = D1 ('MetaData "PerasVoteCollection" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasVoteCollection" 'PrefixI 'True) (S1 ('MetaSel ('Just "pvcTarget") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasVoteTarget blk)) :*: (S1 ('MetaSel ('Just "pvcVotes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NE (Map PerasVoteId (WithArrivalTime (ValidatedPerasVote blk))))) :*: S1 ('MetaSel ('Just "pvcTotalWeight") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VoteWeight))))
(StandardHash blk, Show (PerasVote blk), Show (PerasCert blk)) ⇒ Show (PerasVoteCollection blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(StandardHash blk, NoThunks (PerasVote blk), NoThunks (PerasCert blk)) ⇒ NoThunks (PerasVoteCollection blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasVoteCollection blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasVoteCollection blk) = D1 ('MetaData "PerasVoteCollection" "Ouroboros.Consensus.Block.SupportsPeras" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasVoteCollection" 'PrefixI 'True) (S1 ('MetaSel ('Just "pvcTarget") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasVoteTarget blk)) :*: (S1 ('MetaSel ('Just "pvcVotes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NE (Map PerasVoteId (WithArrivalTime (ValidatedPerasVote blk))))) :*: S1 ('MetaSel ('Just "pvcTotalWeight") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VoteWeight))))

perasVoteCollectionAddVote ∷ (StandardHash blk, IsPerasVote (PerasVote blk) blk) ⇒ WithArrivalTime (ValidatedPerasVote blk) → PerasVoteCollection blk → PerasVoteCollection blk Source #

Add a vote to an existing vote collection if it isn't already present, and update the total weight accordingly.

PRECONDITION: the vote's target must match the collection's target.

unsafePerasVoteCollection ∷ (IsPerasVote (PerasVote blk) blk, StandardHash blk) ⇒ NE (Map PerasVoteId (WithArrivalTime (ValidatedPerasVote blk))) → PerasVoteCollection blk Source #

Unsafe constructor for PerasVoteCollection.

The only recorded use at the moment is in the HFC implementation, to turn an existing PerasVoteCollection for the HardForkBlock into a PerasVoteCollection of a concrete era.

data PerasVoteCollectionWithQuorum blk Source #

A collection of Peras votes for a given target that has reached quorum

Instances

Instances details
(StandardHash blk, Eq (PerasVote blk), Eq (PerasCert blk)) ⇒ Eq (PerasVoteCollectionWithQuorum blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

Generic (PerasVoteCollectionWithQuorum blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(StandardHash blk, Show (PerasVote blk), Show (PerasCert blk)) ⇒ Show (PerasVoteCollectionWithQuorum blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

(StandardHash blk, NoThunks (PerasVote blk), NoThunks (PerasCert blk)) ⇒ NoThunks (PerasVoteCollectionWithQuorum blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

type Rep (PerasVoteCollectionWithQuorum blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Block.SupportsPeras

unsafeAssumeQuorum ∷ PerasVoteCollection blk → PerasVoteCollectionWithQuorum blk Source #

Transforms a PerasVoteCollection into a PerasVoteCollectionWithQuorum without actually checking the quorum condition.

NOTE: the only recorded use at the moment is in the HFC implementation, to turn an existing PerasVoteCollectionWithQuorum for the HardForkBlock into a PerasVoteCollectionWithQuorum of a concrete era.

toUniqueVotesWithSameTarget ∷ (vote ~ PerasVote blk, crypto ~ PerasCrypto blk, committee ~ PerasVotingCommitteeScheme blk, ElectionId crypto ~ PerasRoundNo, CryptoSupportsVotingCommittee crypto committee, PerasVoteCompatibleWithVotingCommittee vote crypto committee, Eq (VoteCandidate crypto)) ⇒ PerasVoteCollectionWithQuorum blk → Either PerasConversionError (UniqueVotesWithSameTarget (PerasCrypto blk) (PerasVotingCommitteeScheme blk)) Source #

Convert a collection of Peras votes that has reached quorum into the corresponding abstract representation of votes used by the voting committee to forge certificates.

UniqueVotesWithSameTarget and PerasVoteCollection enforce the same invariants, which are: - The collection is not empty - All votes have the same target - All votes have a unique vote ID (or unique seat index, which is equivalent assuming they also have the same target, see second point) In addition to that, PerasVoteCollectionWithQuorum guarantees that the total weight of the votes is above the threshold.

Helpers

weightAboveThreshold ∷ PerasParams blk → VoteWeight → Bool Source #

Check whether a given vote weight is above the quorum threshold.

NOTE: this function assumes that the VoteWeight and the quorum threshold used in PerasParams are expressed in the same units. That is, both are either absolute or relative (normalized) values. Under the current current implementation of PerasParams, this function only makes sense when both values are relative (normalized) values.

Convenience re-exports