| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- newtype EbHash = MkEbHash {}
- encodeEbHash ∷ EbHash → Encoding
- decodeEbHash ∷ Decoder s EbHash
- prettyEbHash ∷ EbHash → String
- newtype RbHash = MkRbHash {}
- encodeRbHash ∷ RbHash → Encoding
- decodeRbHash ∷ Decoder s RbHash
- prettyRbHash ∷ RbHash → String
- newtype TxHash = MkTxHash ByteString
- prettyTxHash ∷ TxHash → String
- data LeiosPoint = MkLeiosPoint {}
- encodeLeiosPoint ∷ LeiosPoint → Encoding
- decodeLeiosPoint ∷ Decoder s LeiosPoint
- prettyLeiosPoint ∷ LeiosPoint → String
- data ElectionId = ElectionId {}
- data LeiosVote = MkLeiosVote {}
- encodeLeiosVote ∷ LeiosVote → Encoding
- decodeLeiosVote ∷ Decoder s LeiosVote
- type BytesSize = Word32
- data LeiosEb = MkLeiosEb {
- leiosEbTxs ∷ !(Vector (TxHash, BytesSize))
- leiosEbBodyItems ∷ LeiosEb → [(Int, TxHash, BytesSize)]
- encodeLeiosEb ∷ LeiosEb → Encoding
- encodeLeiosEbItemSize ∷ ByteSize32 → ByteSize32
- encodeLeiosEbMaxFramingSize ∷ ByteSize32
- encodeLeiosEbSize ∷ LeiosEb → BytesSize
- leiosReferencesCapacity ∷ BytesSize → BytesSize
- milliseconds32ToNominalDiffTime ∷ Milliseconds32 → NominalDiffTime
- minCertificationSlot ∷ SlotLength → Milliseconds32 → Milliseconds32 → Milliseconds32 → SlotNo → SlotNo
Hashes
Hash of an Endorser Block
Constructors
| MkEbHash | |
Fields | |
Instances
| Eq EbHash Source # | |||||
| Ord EbHash Source # | |||||
| Generic EbHash Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show EbHash Source # | |||||
| NoThunks EbHash Source # | |||||
| Serialise EbHash Source # | |||||
| type Rep EbHash Source # | |||||
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))) | |||||
decodeEbHash ∷ Decoder s EbHash Source #
prettyEbHash ∷ EbHash → String 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 | |
Fields | |
Instances
| SignableRepresentation RbHash Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods | |||||
| Eq RbHash Source # | |||||
| Ord RbHash Source # | |||||
| Generic RbHash Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show RbHash Source # | |||||
| NoThunks RbHash Source # | |||||
| type Rep RbHash Source # | |||||
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))) | |||||
decodeRbHash ∷ Decoder s RbHash Source #
prettyRbHash ∷ RbHash → String Source #
Hash of a Leios transaction (the Blake2b-256 hash of its bytes).
Constructors
| MkTxHash ByteString |
Instances
| NFData TxHash Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| Eq TxHash Source # | |||||
| Ord TxHash Source # | |||||
| Generic TxHash Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show TxHash Source # | |||||
| NoThunks TxHash Source # | |||||
| type Rep TxHash Source # | |||||
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))) | |||||
prettyTxHash ∷ TxHash → String Source #
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 | |
Fields | |
Instances
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.
Constructors
| ElectionId | |
Fields
| |
Instances
| Eq ElectionId Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| Ord ElectionId Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods compare ∷ ElectionId → ElectionId → Ordering # (<) ∷ ElectionId → ElectionId → Bool # (<=) ∷ ElectionId → ElectionId → Bool # (>) ∷ ElectionId → ElectionId → Bool # (>=) ∷ ElectionId → ElectionId → Bool # max ∷ ElectionId → ElectionId → ElectionId # min ∷ ElectionId → ElectionId → ElectionId # | |||||
| Generic ElectionId Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show ElectionId Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods showsPrec ∷ Int → ElectionId → ShowS # show ∷ ElectionId → String # showList ∷ [ElectionId] → ShowS # | |||||
| NoThunks ElectionId Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| type Rep ElectionId Source # | |||||
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
A vote for a Leios announcement.
Constructors
| MkLeiosVote | |
Fields
| |
Instances
| Eq LeiosVote Source # | |||||
| Generic LeiosVote Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show LeiosVote Source # | |||||
| NoThunks LeiosVote Source # | |||||
| ShowProxy LeiosVote Source # | |||||
| type Rep LeiosVote Source # | |||||
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
An Endorser Block as it is submitted through the network. TODO: Keep track of the slot of an EB?
Constructors
| MkLeiosEb | |
Fields
| |
Instances
| Eq LeiosEb Source # | |||||
| Generic LeiosEb Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show LeiosEb Source # | |||||
| NoThunks LeiosEb Source # | |||||
| ShowProxy LeiosEb Source # | |||||
| type Rep LeiosEb Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
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.
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.
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.