ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Leios.Types

Description

The Leios types that the storage layer needs: hashes, points, endorser block bodies and their sizes.

This is the slice of the Leios prototype's types that Ouroboros.Consensus.Storage.LeiosDB depends on. The rest of the Leios machinery (announcements, fetch, voting, certificates) extends this module as it lands.

Synopsis

Hashes

newtype EbHash Source #

Hash of an Endorser Block

Constructors

MkEbHash 

Instances

Instances details
Eq EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ EbHash → EbHash → Bool #

(/=) ∷ EbHash → EbHash → Bool #

Ord EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

compare ∷ EbHash → EbHash → Ordering #

(<) ∷ EbHash → EbHash → Bool #

(<=) ∷ EbHash → EbHash → Bool #

(>) ∷ EbHash → EbHash → Bool #

(>=) ∷ EbHash → EbHash → Bool #

max ∷ EbHash → EbHash → EbHash #

min ∷ EbHash → EbHash → EbHash #

Generic EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep EbHash 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep EbHash = D1 ('MetaData "EbHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkEbHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "ebHashBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from ∷ EbHash → Rep EbHash x #

to ∷ Rep EbHash x → EbHash #

Show EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showsPrec ∷ Int → EbHash → ShowS #

show ∷ EbHash → String #

showList ∷ [EbHash] → ShowS #

NoThunks EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Serialise EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep EbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep EbHash = D1 ('MetaData "EbHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkEbHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "ebHashBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype RbHash Source #

Hash of a Ranking Block

A Ranking Block is the Praos Block. While the regular Praos headers are parameterised over blk, we choose to keep RbHash monomorphic. Use the ConvertRawHash type class to convert between this type and HeaderHash.

Constructors

MkRbHash 

Instances

Instances details
SignableRepresentation RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Eq RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ RbHash → RbHash → Bool #

(/=) ∷ RbHash → RbHash → Bool #

Ord RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

compare ∷ RbHash → RbHash → Ordering #

(<) ∷ RbHash → RbHash → Bool #

(<=) ∷ RbHash → RbHash → Bool #

(>) ∷ RbHash → RbHash → Bool #

(>=) ∷ RbHash → RbHash → Bool #

max ∷ RbHash → RbHash → RbHash #

min ∷ RbHash → RbHash → RbHash #

Generic RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep RbHash 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep RbHash = D1 ('MetaData "RbHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkRbHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "rbHashBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from ∷ RbHash → Rep RbHash x #

to ∷ Rep RbHash x → RbHash #

Show RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showsPrec ∷ Int → RbHash → ShowS #

show ∷ RbHash → String #

showList ∷ [RbHash] → ShowS #

NoThunks RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep RbHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep RbHash = D1 ('MetaData "RbHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkRbHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "rbHashBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype TxHash Source #

Hash of a Leios transaction (the Blake2b-256 hash of its bytes).

Constructors

MkTxHash ByteString 

Instances

Instances details
NFData TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

rnf ∷ TxHash → () #

Eq TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ TxHash → TxHash → Bool #

(/=) ∷ TxHash → TxHash → Bool #

Ord TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

compare ∷ TxHash → TxHash → Ordering #

(<) ∷ TxHash → TxHash → Bool #

(<=) ∷ TxHash → TxHash → Bool #

(>) ∷ TxHash → TxHash → Bool #

(>=) ∷ TxHash → TxHash → Bool #

max ∷ TxHash → TxHash → TxHash #

min ∷ TxHash → TxHash → TxHash #

Generic TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep TxHash 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep TxHash = D1 ('MetaData "TxHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkTxHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from ∷ TxHash → Rep TxHash x #

to ∷ Rep TxHash x → TxHash #

Show TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showsPrec ∷ Int → TxHash → ShowS #

show ∷ TxHash → String #

showList ∷ [TxHash] → ShowS #

NoThunks TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep TxHash Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep TxHash = D1 ('MetaData "TxHash" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkTxHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Points

data LeiosPoint Source #

Uniquely identifies an endorser block in Leios. Could use 'Block SlotNo EbHash' eventually, but a dedicated type is better to explore.

Constructors

MkLeiosPoint 

Instances

Instances details
SignableRepresentation LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Eq LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ LeiosPoint → LeiosPoint → Bool #

(/=) ∷ LeiosPoint → LeiosPoint → Bool #

Ord LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Generic LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep LeiosPoint 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosPoint = D1 ('MetaData "LeiosPoint" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosPoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "pointSlotNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "pointEbHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EbHash)))
Show LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

NoThunks LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

ShowProxy LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosPoint Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosPoint = D1 ('MetaData "LeiosPoint" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosPoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "pointSlotNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "pointEbHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EbHash)))

Elections

data ElectionId Source #

A ranking block leadership election: a slot and the pool it elected.

This is unrelated to the ElectionId type family, which identifies an election of a voting committee. We do not anticipate a module using both.

The derived Ord orders by slot first, which pruning relies on.

Instances

Instances details
Eq ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ ElectionId → ElectionId → Bool #

(/=) ∷ ElectionId → ElectionId → Bool #

Ord ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Generic ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep ElectionId 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep ElectionId = D1 ('MetaData "ElectionId" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "ElectionId" 'PrefixI 'True) (S1 ('MetaSel ('Just "electionSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "electionElectee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'BlockIssuer))))
Show ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

NoThunks ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep ElectionId Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep ElectionId = D1 ('MetaData "ElectionId" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "ElectionId" 'PrefixI 'True) (S1 ('MetaSel ('Just "electionSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "electionElectee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'BlockIssuer))))

Votes

data LeiosVote Source #

A vote for a Leios announcement.

Constructors

MkLeiosVote 

Fields

Instances

Instances details
Eq LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ LeiosVote → LeiosVote → Bool #

(/=) ∷ LeiosVote → LeiosVote → Bool #

Generic LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep LeiosVote 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosVote = D1 ('MetaData "LeiosVote" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosVote" 'PrefixI 'True) (S1 ('MetaSel ('Just "voteAnnouncingRbHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RbHash) :*: (S1 ('MetaSel ('Just "voteSeatId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSeatId) :*: S1 ('MetaSel ('Just "voteSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSignature))))

Methods

from ∷ LeiosVote → Rep LeiosVote x #

to ∷ Rep LeiosVote x → LeiosVote #

Show LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showsPrec ∷ Int → LeiosVote → ShowS #

show ∷ LeiosVote → String #

showList ∷ [LeiosVote] → ShowS #

NoThunks LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

ShowProxy LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosVote Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosVote = D1 ('MetaData "LeiosVote" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosVote" 'PrefixI 'True) (S1 ('MetaSel ('Just "voteAnnouncingRbHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RbHash) :*: (S1 ('MetaSel ('Just "voteSeatId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSeatId) :*: S1 ('MetaSel ('Just "voteSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSignature))))

Endorser blocks

data LeiosEb Source #

An Endorser Block as it is submitted through the network. TODO: Keep track of the slot of an EB?

Constructors

MkLeiosEb 

Fields

Instances

Instances details
Eq LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

(==) ∷ LeiosEb → LeiosEb → Bool #

(/=) ∷ LeiosEb → LeiosEb → Bool #

Generic LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Associated Types

type Rep LeiosEb 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosEb = D1 ('MetaData "LeiosEb" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosEb" 'PrefixI 'True) (S1 ('MetaSel ('Just "leiosEbTxs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector (TxHash, BytesSize)))))

Methods

from ∷ LeiosEb → Rep LeiosEb x #

to ∷ Rep LeiosEb x → LeiosEb #

Show LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showsPrec ∷ Int → LeiosEb → ShowS #

show ∷ LeiosEb → String #

showList ∷ [LeiosEb] → ShowS #

NoThunks LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

ShowProxy LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

Methods

showProxy ∷ Proxy LeiosEb → String #

type Rep LeiosEb Source # 
Instance details

Defined in Ouroboros.Consensus.Leios.Types

type Rep LeiosEb = D1 ('MetaData "LeiosEb" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosEb" 'PrefixI 'True) (S1 ('MetaSel ('Just "leiosEbTxs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector (TxHash, BytesSize)))))

encodeLeiosEb ∷ LeiosEb → Encoding Source #

Encode a LeiosEb as a CBOR map from each transaction hash to the size of that transaction. Must not add more overhead than encodeLeiosEbMaxFramingSize, and the encoding of each reference must match encodeLeiosEbItemSize.

The mempool charges each transaction encodeLeiosEbItemSize, and the endorser-block capacity subtracts encodeLeiosEbMaxFramingSize. If the encoding changes, both sizes must change with it.

Endorser blocks are on chain, so peers on every node-to-node version must write the same bytes. This encoding has no version yet. When an era after Dijkstra changes it, the ProtVer of that era will select the encoding.

encodeLeiosEbItemSize ∷ ByteSize32 → ByteSize32 Source #

The bytes one reference occupies for a transaction of the given size: the hash and the size itself, exactly as the EB's CBOR encoding writes them.

Also used on the Dijkstra transaction measure, so the mempool charges a transaction what it will actually cost in the reference list rather than an approximation of it.

encodeLeiosEbMaxFramingSize ∷ ByteSize32 Source #

The widest the framing encodeLeiosEb writes around the references can get: the map header. CBOR map headers have the same widths as cborIntBytesSize, and the reference count fits BytesSize.

A capacity expressed in references (encodeLeiosEbItemSize each) subtracts this once at the block level; no single transaction can be charged for it.

encodeLeiosEbSize ∷ LeiosEb → BytesSize Source #

Compute the size of a LeiosEb in its CBOR encoding.

leiosReferencesCapacity ∷ BytesSize → BytesSize Source #

The references capacity a maxEndorserBlockReferencesSize parameter yields: the parameter minus the framing encodeLeiosEb writes ahead of the references. A parameter smaller than the framing exhausts the capacity, so no reference fits, rather than wrapping around to "no limit".

Header checks

milliseconds32ToNominalDiffTime ∷ Milliseconds32 → NominalDiffTime Source #

A duration the ledger gives in milliseconds.

minCertificationSlot Source #

Arguments

∷ SlotLength 
→ Milliseconds32

Announcement period length

→ Milliseconds32

Vote period length

→ Milliseconds32

Diffusion period length

→ SlotNo

Slot of the announcing block

→ SlotNo 

The earliest slot at which a block may certify an endorser block announced in the given slot.

The announcement, voting and diffusion periods must all have elapsed. They are wall-clock durations, so the gap rounds up to whole slots: a block is forged at its slot's onset, so the answer is the first slot whose onset is far enough after the announcement.