| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Leios.TxCache.API
Description
The LeiosTxCache interface: the handle type and the small set of types shared by every implementation. See Ouroboros.Consensus.Leios.TxCache for the overview.
Synopsis
- data LeiosTxCache (m ∷ Type → Type) a v b = LeiosTxCache {
- evictOlderThanFoldl' ∷ ∀ w. SlotNo → w → (w → TxHash → w) → m (Set LeiosPoint, w)
- insertBodyAndFoldl' ∷ ∀ w. LeiosPoint → b → w → (w → TxOffset → TxHash → BytesSize → Maybe TxLocation → w) → m (Maybe LeiosTxCacheInsertBodySummary, w)
- insertLandedTxs ∷ LeiosPoint → [LandedTx a v] → m FetchArrivalBytes
- withLookupTx ∷ ∀ r. (∀ (n ∷ Type → Type). Monad n ⇒ (TxHash → n (StrictMaybe (TxState a v))) → n r) → m r
- evictOlderThan ∷ Functor m ⇒ LeiosTxCache m a v b → SlotNo → m ()
- insertBody ∷ Functor m ⇒ LeiosTxCache m a v b → LeiosPoint → b → m (Maybe LeiosTxCacheInsertBodySummary)
- class ReferencesTxsByHash b where
- foldTxReferences ∷ (r → TxHash → BytesSize → r) → r → b → r
- data PackedEndorserBlock
- packEndorserBlock ∷ EndorserBlock → PackedEndorserBlock
- data TxState a v
- = TxInserted !a
- | TxValidated !v
- data LandedTx a v = MkLandedTx {}
- maxLeiosPointCount ∷ Int
- data LeiosTxCacheInsertBodySummary = MkLeiosTxCacheInsertBodySummary {
- ibsTxsInEb ∷ !Int
- ibsAcquired ∷ !Int
- ibsValidated ∷ !Int
- ibsCacheTxCount ∷ !Int
- ibsCacheCapacity ∷ !Int
- defaultLeiosTxCacheShift ∷ Int
- worstCaseCacheTxCount ∷ Int
- data TxArrivalPrior
- bucketTxArrival ∷ TxArrivalPrior → BytesSize → FetchArrivalBytes
Handle
data LeiosTxCache (m ∷ Type → Type) a v b Source #
A handle on the LeiosTxCache. Its operations are atomic with respect to each other: each holds the handle's lock while it runs, including any continuation it is given.
The cache holds a tx for as long as it retains a point that the tx landed at
(insertLandedTxs), or whose body it took in while holding the tx
(insertBodyAndFoldl'). It evicts points oldest first, so it tracks only
each tx's youngest such point, its youngest reference, and forgets the tx
when it evicts that point. Evicting a point also forgets the locations at it.
Constructors
| LeiosTxCache | |
Fields
| |
evictOlderThan ∷ Functor m ⇒ LeiosTxCache m a v b → SlotNo → m () Source #
evictOlderThanFoldl', for a caller that needs nothing back.
insertBody ∷ Functor m ⇒ LeiosTxCache m a v b → LeiosPoint → b → m (Maybe LeiosTxCacheInsertBodySummary) Source #
insertBodyAndFoldl', for a caller that needs only the summary.
Body payloads
class ReferencesTxsByHash b where Source #
A body b from which the referenced txs can be enumerated, each paired with
its on-the-wire size, in body order.
Visiting in body order lets a consumer recover each tx's offset from its position in the fold.
Methods
foldTxReferences ∷ (r → TxHash → BytesSize → r) → r → b → r Source #
Instances
| ReferencesTxsByHash PackedEndorserBlock Source # | |
Defined in Ouroboros.Consensus.Leios.TxCache.API Methods foldTxReferences ∷ (r → TxHash → BytesSize → r) → r → PackedEndorserBlock → r Source # | |
data PackedEndorserBlock Source #
The node's body payload: each referenced tx's hash and size, in body order,
the hashes in one byte string and the sizes in an unboxed vector, at 36 bytes
per tx, about as much as the body's own encoding takes. The cache retains up
to maxLeiosPointCount (128) of them, of up to
maxEndorserBlockBytesSize (600 kB) each, so
about 77 MB at worst; a decoded EndorserBlock would cost several times
more.
Instances
| ReferencesTxsByHash PackedEndorserBlock Source # | |
Defined in Ouroboros.Consensus.Leios.TxCache.API Methods foldTxReferences ∷ (r → TxHash → BytesSize → r) → r → PackedEndorserBlock → r Source # | |
Tx states
Whether a tx the cache holds was applied, and what it records of the tx.
Constructors
| TxInserted !a | The tx is inserted (fetched) but not yet applied, neither by the Mempool nor the LeiosVoting thread. |
| TxValidated !v | The tx has been applied. |
A tx a write landed at a point.
Bounds
maxLeiosPointCount ∷ Int Source #
The maximum number of points the cache retains, each one at which a body was taken in. Retaining one more evicts the oldest.
It is chosen to be:
- small enough that the cache's RAM cost stays tolerable even in the worst
case, where every retained point's EB references
maxTxsPerEndorserBlock(about 17 thousand) distinct txs: thatworstCaseCacheTxCount(about 2.2 million) fills the capacity the node's cache is sized for (defaultLeiosTxCacheShift) to a load factor of only about half; and - large enough that a "significant" portion of stake is likely to be elected again before its previous EB has been evicted from a recipient node's LeiosTxCache.
Insert-body observability summary
data LeiosTxCacheInsertBodySummary Source #
Summary of an EB body inserted into the LeiosTxCache, for observability.
The counts nest: ibsTxsInEb >= ibsAcquired >= ibsValidated.
Constructors
| MkLeiosTxCacheInsertBodySummary | |
Fields
| |
Instances
defaultLeiosTxCacheShift ∷ Int Source #
The capacity the node's Leios tx cache is sized for: 2 ^ this many
txs, which it reports as ibsCacheCapacity. It covers
worstCaseCacheTxCount about twice over.
worstCaseCacheTxCount ∷ Int Source #
The worst-case number of txs the cache can be asked to hold: a full
maxLeiosPointCount window of points, each of its own EB referencing the maximum
maxTxsPerEndorserBlock distinct txs.
Arrival classification
data TxArrivalPrior Source #
What the cache held of a tx before it landed, by which insertLandedTxs
classifies the tx's bytes (bucketTxArrival).
Constructors
| TxEvicted | The cache does not retain the point the tx landed at: it has evicted that point, or ignored its body as older than what it retains. |
| TxWasAbsent | The cache did not hold the tx (the expected case). |
| TxWasHeld | The cache already held the tx, so this arrival is redundant. |
Instances
| Eq TxArrivalPrior Source # | |
Defined in Ouroboros.Consensus.Leios.TxCache.API Methods (==) ∷ TxArrivalPrior → TxArrivalPrior → Bool # (/=) ∷ TxArrivalPrior → TxArrivalPrior → Bool # | |
| Show TxArrivalPrior Source # | |
Defined in Ouroboros.Consensus.Leios.TxCache.API Methods showsPrec ∷ Int → TxArrivalPrior → ShowS # show ∷ TxArrivalPrior → String # showList ∷ [TxArrivalPrior] → ShowS # | |
bucketTxArrival ∷ TxArrivalPrior → BytesSize → FetchArrivalBytes Source #
Bucket an arriving tx's bytes by its prior state (for FetchArrivalBytes).