| 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
- type EndorserBlockHash = Hash HASH EraIndependentEbReferences
- newtype RankingBlockHash = MkRankingBlockHash {}
- toRankingBlockHash ∷ ConvertRawHash blk ⇒ Proxy blk → HeaderHash blk → RankingBlockHash
- type TxHash = Hash HASH EraIndependentTx
- newtype LeiosTx = MkLeiosTx {}
- encodeLeiosTx ∷ LeiosTx → Encoding
- decodeLeiosTx ∷ Decoder s LeiosTx
- 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 EndorserBlock
- type TxOffset = Int
- mkEndorserBlock ∷ [(TxHash, BytesSize)] → EndorserBlock
- endorserBlockFromTxBytes ∷ NonEmpty ByteString → EndorserBlock
- endorserBlockHash ∷ EndorserBlock → EndorserBlockHash
- endorserBlockReferences ∷ EndorserBlock → [(TxHash, BytesSize)]
- encodeEndorserBlock ∷ EndorserBlock → Encoding
- decodeEndorserBlock ∷ Decoder s (ByteString → EndorserBlock)
- sizeEndorserBlockReference ∷ ByteSize32 → ByteSize32
- encodeEndorserBlockSize ∷ EndorserBlock → BytesSize
- referencesCapacity ∷ BytesSize → BytesSize
- maxEndorserBlockBytesSize ∷ BytesSize
- maxTxsPerEndorserBlock ∷ Int
- milliseconds32ToNominalDiffTime ∷ Milliseconds32 → NominalDiffTime
- minCertificationSlot ∷ SlotLength → Milliseconds32 → Milliseconds32 → Milliseconds32 → SlotNo → SlotNo
Hashes
type EndorserBlockHash = Hash HASH EraIndependentEbReferences Source #
The hash of an endorser block, as ranking blocks announce it.
newtype RankingBlockHash Source #
The hash of a ranking block's header, which votes sign.
Ranking blocks are Praos blocks, whose HeaderHash depends on blk. Use
toRankingBlockHash to convert it to this monomorphic type.
Constructors
| MkRankingBlockHash | |
Instances
toRankingBlockHash ∷ ConvertRawHash blk ⇒ Proxy blk → HeaderHash blk → RankingBlockHash Source #
Convert a ranking block's HeaderHash. It must be the same length as a
RankingBlockHash, ie 32 bytes.
TODO Rule out a HeaderHash of another size at compile time, as Peras does
with HashSize blk ~ 32, without requiring it of every RunNode block.
type TxHash = Hash HASH EraIndependentTx Source #
The hash of a transaction an endorser block references. It hashes all of the
transaction's bytes, witnesses included, unlike the ledger's TxId and so
the mempool's GenTxId, which
hash only the transaction's body.
Transactions
A Leios transaction, as the CBOR bytes of the ledger's transaction.
Its codec wraps those bytes as CBOR-in-CBOR, so receiving a transaction does not decode it.
TODO ChainSel and Leios voting will need a way to actually decode the transaction: a per-block-type decoder that takes the ledger state resulting from the announcing ranking block, whose era is the one the endorser block was announced in.
Constructors
| MkLeiosTx | |
Fields | |
Points
data LeiosPoint Source #
Uniquely identifies an endorser block in Leios. Could use 'Block SlotNo EndorserBlockHash' eventually, but a dedicated type is better to explore.
Constructors
| MkLeiosPoint | |
Fields | |
Instances
| Eq LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| Ord LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods compare ∷ LeiosPoint → LeiosPoint → Ordering # (<) ∷ LeiosPoint → LeiosPoint → Bool # (<=) ∷ LeiosPoint → LeiosPoint → Bool # (>) ∷ LeiosPoint → LeiosPoint → Bool # (>=) ∷ LeiosPoint → LeiosPoint → Bool # max ∷ LeiosPoint → LeiosPoint → LeiosPoint # min ∷ LeiosPoint → LeiosPoint → LeiosPoint # | |||||
| Generic LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods showsPrec ∷ Int → LeiosPoint → ShowS # show ∷ LeiosPoint → String # showList ∷ [LeiosPoint] → ShowS # | |||||
| NoThunks LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| ShowProxy LeiosPoint Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods showProxy ∷ Proxy LeiosPoint → String # | |||||
| type Rep LeiosPoint Source # | |||||
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 EndorserBlockHash))) | |||||
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 RankingBlockHash) :*: (S1 ('MetaSel ('Just "voteSeatId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSeatId) :*: S1 ('MetaSel ('Just "voteSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeiosSignature)))) | |||||
Endorser blocks
data EndorserBlock Source #
An endorser block in the Leios overlay protocol. It endorses transactions
by naming a list of TxHash and BytesSize pairs. Construct using
mkEndorserBlock.
A compatibility layer over the ledger's EbReferences: consensus
sees only this module's functions, never the ledger's representation.
Instances
| NFData EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods rnf ∷ EndorserBlock → () # | |||||
| Eq EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| Generic EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Associated Types
| |||||
| Show EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods showsPrec ∷ Int → EndorserBlock → ShowS # show ∷ EndorserBlock → String # showList ∷ [EndorserBlock] → ShowS # | |||||
| NoThunks EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types | |||||
| ShowProxy EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types Methods | |||||
| type Rep EndorserBlock Source # | |||||
Defined in Ouroboros.Consensus.Leios.Types type Rep EndorserBlock = D1 ('MetaData "EndorserBlock" "Ouroboros.Consensus.Leios.Types" "ouroboros-consensus-5.0.0.0-inplace" 'True) (C1 ('MetaCons "MkEndorserBlock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EbReferences))) | |||||
mkEndorserBlock ∷ [(TxHash, BytesSize)] → EndorserBlock Source #
An endorser block naming these transactions, in this order.
endorserBlockFromTxBytes ∷ NonEmpty ByteString → EndorserBlock Source #
The endorser block naming the transactions with these bytes, in this
order. It names each by the TxHash and the length of its bytes.
endorserBlockHash ∷ EndorserBlock → EndorserBlockHash Source #
The hash ranking blocks announce for the endorser block: that of its encoding.
endorserBlockReferences ∷ EndorserBlock → [(TxHash, BytesSize)] Source #
The transactions an endorser block names, in order.
encodeEndorserBlock ∷ EndorserBlock → Encoding Source #
Encode an endorser block as the ledger does: a CBOR map from each transaction hash to the size of that transaction.
The mempool charges each transaction sizeEndorserBlockReference, and
referencesCapacity subtracts the framing around the references. If the
encoding changes, both must change with it.
decodeEndorserBlock ∷ Decoder s (ByteString → EndorserBlock) Source #
The inverse of encodeEndorserBlock, given the whole input it decoded
from, not just the endorser block's bytes: the ledger's annotator slices
them by the byte offsets of this decoder's run. Like the ledger, it rejects
an empty map of transaction references and one naming a transaction twice.
It also rejects one whose bytes exceed maxEndorserBlockBytesSize. It can
tell only after decoding them (if endorser blocks were wrapped as
CBOR-in-CBOR, it would know their length before decoding them, even from an
indefinite-length byte string), since a CBOR map gives its number of entries
rather than of bytes. So the byte limit of the message carrying it must keep
small the work it does before then, eg
byteLimitsLeiosFetch.
The endorser block keeps its slice of those bytes, so its hash and encoding are of the bytes received.
sizeEndorserBlockReference ∷ ByteSize32 → ByteSize32 Source #
The bytes one reference occupies for a transaction of the given size: the
hash and the size, exactly as encodeEndorserBlock 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.
encodeEndorserBlockSize ∷ EndorserBlock → BytesSize Source #
The size of encodeEndorserBlock: of the bytes the endorser block was
received in, or of the ledger's encoding of one this node built.
referencesCapacity ∷ BytesSize → BytesSize Source #
The references capacity a maxEndorserBlockReferencesSize parameter
yields: the parameter minus the framing encodeEndorserBlock 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".
maxEndorserBlockBytesSize ∷ BytesSize Source #
The design ceiling on an endorser block's encoding: what the node will forge, serve and size its buffers for.
TODO Nothing yet keeps the maxEndorserBlockReferencesSize protocol
parameter within it, so a larger value would let an honest peer send an
endorser block that decodeEndorserBlock rejects. Make it the
constitution's guardrail on that parameter, and refuse to run with a
parameter above it.
maxTxsPerEndorserBlock ∷ Int Source #
The most transactions an endorser block may name, given
maxEndorserBlockBytesSize. Each reference takes at least as many bytes as
sizeEndorserBlockReference charges a transaction of size 0, however it is
encoded.
It derives from the design ceiling and not from the protocol parameter, since the buffers it sizes are allocated before any ledger state is in reach.
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.