Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Definition of common types used in Ouroboros.Consensus.Mempool.Init, Ouroboros.Consensus.Mempool.Update and Ouroboros.Consensus.Mempool.Query.
Synopsis
- data InternalState blk = IS {
- isTxs ∷ !(TxSeq (TxMeasure blk) (Validated (GenTx blk)))
- isTxIds ∷ !(Set (GenTxId blk))
- isLedgerState ∷ !(TickedLedgerState blk)
- isTip ∷ !(ChainHash blk)
- isSlotNo ∷ !SlotNo
- isLastTicketNo ∷ !TicketNo
- isCapacity ∷ !(TxMeasure blk)
- isMempoolSize ∷ TxLimits blk ⇒ InternalState blk → MempoolSize
- data MempoolEnv m blk = MempoolEnv {
- mpEnvLedger ∷ LedgerInterface m blk
- mpEnvLedgerCfg ∷ LedgerConfig blk
- mpEnvStateVar ∷ StrictTVar m (InternalState blk)
- mpEnvAddTxsRemoteFifo ∷ MVar m ()
- mpEnvAddTxsAllFifo ∷ MVar m ()
- mpEnvTracer ∷ Tracer m (TraceEventMempool blk)
- mpEnvCapacityOverride ∷ MempoolCapacityBytesOverride
- initMempoolEnv ∷ (IOLike m, NoThunks (GenTxId blk), LedgerSupportsMempool blk, ValidateEnvelope blk) ⇒ LedgerInterface m blk → LedgerConfig blk → MempoolCapacityBytesOverride → Tracer m (TraceEventMempool blk) → m (MempoolEnv m blk)
- data LedgerInterface m blk = LedgerInterface {
- getCurrentLedgerState ∷ STM m (LedgerState blk)
- chainDBLedgerInterface ∷ (IOLike m, IsLedger (LedgerState blk)) ⇒ ChainDB m blk → LedgerInterface m blk
- data ValidationResult invalidTx blk = ValidationResult {
- vrBeforeTip ∷ ChainHash blk
- vrSlotNo ∷ SlotNo
- vrBeforeCapacity ∷ TxMeasure blk
- vrValid ∷ TxSeq (TxMeasure blk) (Validated (GenTx blk))
- vrValidTxIds ∷ Set (GenTxId blk)
- vrNewValid ∷ Maybe (Validated (GenTx blk))
- vrAfter ∷ TickedLedgerState blk
- vrInvalid ∷ [(invalidTx, ApplyTxErr blk)]
- vrLastTicketNo ∷ TicketNo
- extendVRNew ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) ⇒ LedgerConfig blk → WhetherToIntervene → GenTx blk → ValidationResult (GenTx blk) blk → Either (ApplyTxErr blk) (Validated (GenTx blk), ValidationResult (GenTx blk) blk)
- extendVRPrevApplied ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) ⇒ LedgerConfig blk → TxTicket (TxMeasure blk) (Validated (GenTx blk)) → ValidationResult (Validated (GenTx blk)) blk → ValidationResult (Validated (GenTx blk)) blk
- revalidateTxsFor ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) ⇒ MempoolCapacityBytesOverride → LedgerConfig blk → SlotNo → TickedLedgerState blk → TicketNo → [TxTicket (TxMeasure blk) (Validated (GenTx blk))] → ValidationResult (Validated (GenTx blk)) blk
- validateStateFor ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk), ValidateEnvelope blk) ⇒ MempoolCapacityBytesOverride → LedgerConfig blk → ForgeLedgerState blk → InternalState blk → ValidationResult (Validated (GenTx blk)) blk
- data TraceEventMempool blk
- = TraceMempoolAddedTx (Validated (GenTx blk)) MempoolSize MempoolSize
- | TraceMempoolRejectedTx (GenTx blk) (ApplyTxErr blk) MempoolSize
- | TraceMempoolRemoveTxs [(Validated (GenTx blk), ApplyTxErr blk)] MempoolSize
- | TraceMempoolManuallyRemovedTxs [GenTxId blk] [Validated (GenTx blk)] MempoolSize
- | TraceMempoolSynced EnclosingTimed
- internalStateFromVR ∷ ValidationResult invalidTx blk → InternalState blk
- snapshotFromIS ∷ ∀ blk. (HasTxId (GenTx blk), TxLimits blk) ⇒ InternalState blk → MempoolSnapshot blk
- validationResultFromIS ∷ InternalState blk → ValidationResult invalidTx blk
- tickLedgerState ∷ ∀ blk. (UpdateLedger blk, ValidateEnvelope blk) ⇒ LedgerConfig blk → ForgeLedgerState blk → (SlotNo, TickedLedgerState blk)
Internal state
data InternalState blk Source #
Internal state in the mempool
IS | |
|
Instances
isMempoolSize ∷ TxLimits blk ⇒ InternalState blk → MempoolSize Source #
\( O(1) \). Return the number of transactions in the internal state of the Mempool paired with their total size in bytes.
Mempool environment
data MempoolEnv m blk Source #
The mempool environment captures all the associated variables wrt the Mempool and is accessed by the Mempool interface on demand to perform the different operations.
MempoolEnv | |
|
initMempoolEnv ∷ (IOLike m, NoThunks (GenTxId blk), LedgerSupportsMempool blk, ValidateEnvelope blk) ⇒ LedgerInterface m blk → LedgerConfig blk → MempoolCapacityBytesOverride → Tracer m (TraceEventMempool blk) → m (MempoolEnv m blk) Source #
Ledger interface
data LedgerInterface m blk Source #
Abstract interface needed to run a Mempool.
LedgerInterface | |
|
chainDBLedgerInterface ∷ (IOLike m, IsLedger (LedgerState blk)) ⇒ ChainDB m blk → LedgerInterface m blk Source #
Create a LedgerInterface
from a ChainDB
.
Validation
data ValidationResult invalidTx blk Source #
ValidationResult | |
|
extendVRNew ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) ⇒ LedgerConfig blk → WhetherToIntervene → GenTx blk → ValidationResult (GenTx blk) blk → Either (ApplyTxErr blk) (Validated (GenTx blk), ValidationResult (GenTx blk) blk) Source #
Extend ValidationResult
with a new transaction (one which we have not
previously validated) that may or may not be valid in this ledger state.
PRECONDITION: vrNewValid
is Nothing
. In other words: new transactions
should be validated one-by-one, not by calling extendVRNew
on its result
again.
extendVRPrevApplied ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) ⇒ LedgerConfig blk → TxTicket (TxMeasure blk) (Validated (GenTx blk)) → ValidationResult (Validated (GenTx blk)) blk → ValidationResult (Validated (GenTx blk)) blk Source #
Extend ValidationResult
with a previously validated transaction that
may or may not be valid in this ledger state
n.b. Even previously validated transactions may not be valid in a different
ledger state; it is still useful to indicate whether we have previously
validated this transaction because, if we have, we can utilize reapplyTx
rather than applyTx
and, therefore, skip things like cryptographic
signatures.
∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk)) | |
⇒ MempoolCapacityBytesOverride | |
→ LedgerConfig blk | |
→ SlotNo | |
→ TickedLedgerState blk | |
→ TicketNo | |
→ [TxTicket (TxMeasure blk) (Validated (GenTx blk))] | |
→ ValidationResult (Validated (GenTx blk)) blk |
validateStateFor ∷ (LedgerSupportsMempool blk, HasTxId (GenTx blk), ValidateEnvelope blk) ⇒ MempoolCapacityBytesOverride → LedgerConfig blk → ForgeLedgerState blk → InternalState blk → ValidationResult (Validated (GenTx blk)) blk Source #
Given a (valid) internal state, validate it against the given ledger
state and BlockSlot
.
When these match the internal state's isTip
and isSlotNo
, this is very
cheap, as the given internal state will already be valid against the given
inputs.
When these don't match, the transaction in the internal state will be
revalidated (revalidateTxsFor
).
Tracing
data TraceEventMempool blk Source #
Events traced by the Mempool.
TraceMempoolAddedTx | |
| |
TraceMempoolRejectedTx | |
| |
TraceMempoolRemoveTxs | |
| |
TraceMempoolManuallyRemovedTxs | |
| |
TraceMempoolSynced | Emitted when the mempool is adjusted after the tip has changed. |
|
Instances
(Show (GenTx blk), Show (Validated (GenTx blk)), Show (GenTxId blk), Show (ApplyTxErr blk)) ⇒ Show (TraceEventMempool blk) Source # | |
Defined in Ouroboros.Consensus.Mempool.Impl.Common showsPrec ∷ Int → TraceEventMempool blk → ShowS # show ∷ TraceEventMempool blk → String # showList ∷ [TraceEventMempool blk] → ShowS # | |
(Eq (GenTx blk), Eq (Validated (GenTx blk)), Eq (GenTxId blk), Eq (ApplyTxErr blk)) ⇒ Eq (TraceEventMempool blk) Source # | |
Defined in Ouroboros.Consensus.Mempool.Impl.Common (==) ∷ TraceEventMempool blk → TraceEventMempool blk → Bool # (/=) ∷ TraceEventMempool blk → TraceEventMempool blk → Bool # |
Conversions
internalStateFromVR ∷ ValidationResult invalidTx blk → InternalState blk Source #
Construct internal state from ValidationResult
Discards information about invalid and newly valid transactions
snapshotFromIS ∷ ∀ blk. (HasTxId (GenTx blk), TxLimits blk) ⇒ InternalState blk → MempoolSnapshot blk Source #
Create a Mempool Snapshot from a given Internal State of the mempool.
validationResultFromIS ∷ InternalState blk → ValidationResult invalidTx blk Source #
Construct a ValidationResult
from internal state.
Ticking a ledger state
tickLedgerState ∷ ∀ blk. (UpdateLedger blk, ValidateEnvelope blk) ⇒ LedgerConfig blk → ForgeLedgerState blk → (SlotNo, TickedLedgerState blk) Source #
Tick the LedgerState
using the given BlockSlot
.