Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Ledger.SupportsMempool
Synopsis
- type family ApplyTxErr blk
- newtype ByteSize32 = ByteSize32 {}
- data ComputeDiffs
- class HasTxId tx ⇒ ConvertRawTxId tx where
- toRawTxIdHash ∷ TxId tx → ShortByteString
- data family GenTx blk
- type GenTxId blk = TxId (GenTx blk)
- class HasByteSize a where
- txMeasureByteSize ∷ a → ByteSize32
- class (Show (TxId tx), Ord (TxId tx), NoThunks (TxId tx)) ⇒ HasTxId tx where
- class HasTxs blk where
- extractTxs ∷ blk → [GenTx blk]
- newtype IgnoringOverflow a = IgnoringOverflow {}
- data Invalidated blk = Invalidated {
- getInvalidated ∷ !(Validated (GenTx blk))
- getReason ∷ !(ApplyTxErr blk)
- class (UpdateLedger blk, TxLimits blk, NoThunks (GenTx blk), NoThunks (Validated (GenTx blk)), Show (GenTx blk), Show (Validated (GenTx blk)), Show (ApplyTxErr blk)) ⇒ LedgerSupportsMempool blk where
- txInvariant ∷ GenTx blk → Bool
- applyTx ∷ LedgerConfig blk → WhetherToIntervene → SlotNo → GenTx blk → TickedLedgerState blk ValuesMK → Except (ApplyTxErr blk) (TickedLedgerState blk DiffMK, Validated (GenTx blk))
- reapplyTx ∷ ComputeDiffs → LedgerConfig blk → SlotNo → Validated (GenTx blk) → TickedLedgerState blk ValuesMK → Except (ApplyTxErr blk) (TickedLedgerState blk TrackingMK)
- reapplyTxs ∷ ComputeDiffs → LedgerConfig blk → SlotNo → [(Validated (GenTx blk), extra)] → TickedLedgerState blk ValuesMK → ReapplyTxsResult extra blk
- txForgetValidated ∷ Validated (GenTx blk) → GenTx blk
- getTransactionKeySets ∷ GenTx blk → LedgerTables (LedgerState blk) KeysMK
- prependMempoolDiffs ∷ TickedLedgerState blk DiffMK → TickedLedgerState blk DiffMK → TickedLedgerState blk DiffMK
- applyMempoolDiffs ∷ LedgerTables (LedgerState blk) ValuesMK → LedgerTables (LedgerState blk) KeysMK → TickedLedgerState blk DiffMK → TickedLedgerState blk ValuesMK
- data ReapplyTxsResult extra blk = ReapplyTxsResult {
- invalidatedTxs ∷ ![Invalidated blk]
- validatedTxs ∷ ![(Validated (GenTx blk), extra)]
- resultingState ∷ !(TickedLedgerState blk TrackingMK)
- data family TxId blk
- class (Measure (TxMeasure blk), HasByteSize (TxMeasure blk), NoThunks (TxMeasure blk), TxMeasureMetrics (TxMeasure blk), Show (TxMeasure blk)) ⇒ TxLimits blk where
- type TxMeasure blk
- txMeasure ∷ LedgerConfig blk → TickedLedgerState blk ValuesMK → GenTx blk → Except (ApplyTxErr blk) (TxMeasure blk)
- blockCapacityTxMeasure ∷ ∀ (mk ∷ MapKind). LedgerConfig blk → TickedLedgerState blk mk → TxMeasure blk
- class TxMeasureMetrics msr where
- data family Validated x
- data WhetherToIntervene
Documentation
type family ApplyTxErr blk Source #
Updating the ledger with a single transaction may result in a different error type as when updating it with a block
Instances
type ApplyTxErr (HardForkBlock xs) Source # | |
type ApplyTxErr (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
newtype ByteSize32 Source #
We intentionally do not declare a Num
instance! We prefer ByteSize32
to occur explicitly in the code where possible, for
legibility/perspicuousness. We also do not need nor want subtraction.
This data type measures the size of a transaction, the sum of the sizes of txs in a block, the sum of the sizes of the txs in the mempool, etc. None of those will ever need to represent gigabytes, so 32 bits suffice. But 16 bits would not.
This is modular arithmetic, so uses need to be concerned with overflow. For
example, see the related guard in
pureTryAddTx
. One important element is
anticipating the possibility of very large summands injected by the
adversary.
There is a temptation to use Natural
here, since it can never overflow.
However, some points in the interface do not easily handle Natural
s, such
as encoders. Thus Natural
would merely defer the overflow concern, and
even risks instilling a false sense that overflow need not be considered at
all.
Constructors
ByteSize32 | |
Fields |
Instances
data ComputeDiffs Source #
Whether to keep track of the diffs produced by applying the transactions.
When getting a mempool snapshot, we will revalidate all the transactions but we won't do anything useful with the resulting state. We can safely omit computing the differences in this case.
This optimization is worthwile as snapshotting is in the critical path of block minting, and we don't make use of the resulting state, only of the transactions that remain valid.
Eventually, the Ledger rules will construct the differences for us, so this optimization will no longer be needed. That's why we chose to go with a boolean isomorph instead of something fancier.
Constructors
ComputeDiffs | This option should be used when syncing the mempool with the LedgerDB, to store a useful state in the mempool. |
IgnoreDiffs | This option should be used only when snapshotting the mempool, as we discard the resulting state anyways. |
Instances
Show ComputeDiffs Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods showsPrec ∷ Int → ComputeDiffs → ShowS # show ∷ ComputeDiffs → String # showList ∷ [ComputeDiffs] → ShowS # |
class HasTxId tx ⇒ ConvertRawTxId tx where Source #
Extract the raw hash bytes from a TxId
.
Methods
toRawTxIdHash ∷ TxId tx → ShortByteString Source #
NOTE: The composition
must satisfy the same
properties as defined in the docs of toRawTxIdHash
. txId
txId
.
data family GenTx blk Source #
Generalized transaction
The mempool (and, accordingly, blocks) consist of "generalized transactions"; this could be "proper" transactions (transferring funds) but also other kinds of things such as update proposals, delegations, etc.
Instances
class HasByteSize a where Source #
Instances
HasByteSize ByteSize32 Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods | |
HasByteSize a ⇒ HasByteSize (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods txMeasureByteSize ∷ IgnoringOverflow a → ByteSize32 Source # |
class (Show (TxId tx), Ord (TxId tx), NoThunks (TxId tx)) ⇒ HasTxId tx where Source #
Transactions with an identifier
The mempool will use these to locate transactions, so two different transactions should have different identifiers.
Methods
NOTE: a TxId
must be unique up to ledger rules, i.e., two GenTx
s with
the same TxId
must be the same transaction according to the ledger.
However, we do not assume that a TxId
uniquely determines a GenTx
:
two GenTx
s with the same TxId
can differ in, e.g., witnesses.
Should be cheap as this will be called often.
Instances
CanHardFork xs ⇒ HasTxId (GenTx (HardForkBlock xs)) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods txId ∷ GenTx (HardForkBlock xs) → TxId (GenTx (HardForkBlock xs)) Source # | |
Bridge m a ⇒ HasTxId (GenTx (DualBlock m a)) Source # | |
class HasTxs blk where Source #
Collect all transactions from a block
This is used for tooling only. We don't require it as part of RunNode (and cannot, because we cannot give an instance for the dual ledger).
Methods
extractTxs ∷ blk → [GenTx blk] Source #
Return the transactions part of the given block in no particular order.
Instances
All HasTxs xs ⇒ HasTxs (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods extractTxs ∷ HardForkBlock xs → [GenTx (HardForkBlock xs)] Source # |
newtype IgnoringOverflow a Source #
has the same semantics as IgnoringOverflow
aa
, except it ignores
the fact that a
can overflow.
For example,
is not lawful, because overflow violates
the lattice-ordered monoid law. But Measure
Word32
is lawful, since it explicitly ignores that case.Measure
(IgnoringOverflow
Word32
)
WARNING: anywhere this type occurs is a very strong indicator that overflow will break assumptions, so overflow must therefore be guarded against.
TODO upstream this to the measure
package
Constructors
IgnoringOverflow | |
Fields |
Instances
NFData a ⇒ NFData (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods rnf ∷ IgnoringOverflow a → () # | |
Monoid a ⇒ Monoid (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods mempty ∷ IgnoringOverflow a # mappend ∷ IgnoringOverflow a → IgnoringOverflow a → IgnoringOverflow a # mconcat ∷ [IgnoringOverflow a] → IgnoringOverflow a # | |
Semigroup a ⇒ Semigroup (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods (<>) ∷ IgnoringOverflow a → IgnoringOverflow a → IgnoringOverflow a # sconcat ∷ NonEmpty (IgnoringOverflow a) → IgnoringOverflow a # stimes ∷ Integral b ⇒ b → IgnoringOverflow a → IgnoringOverflow a # | |
Show a ⇒ Show (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods showsPrec ∷ Int → IgnoringOverflow a → ShowS # show ∷ IgnoringOverflow a → String # showList ∷ [IgnoringOverflow a] → ShowS # | |
Eq a ⇒ Eq (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods (==) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # (/=) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # | |
Ord a ⇒ Ord (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods compare ∷ IgnoringOverflow a → IgnoringOverflow a → Ordering # (<) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # (<=) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # (>) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # (>=) ∷ IgnoringOverflow a → IgnoringOverflow a → Bool # max ∷ IgnoringOverflow a → IgnoringOverflow a → IgnoringOverflow a # min ∷ IgnoringOverflow a → IgnoringOverflow a → IgnoringOverflow a # | |
Measure (IgnoringOverflow ByteSize32) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods zero ∷ IgnoringOverflow ByteSize32 Source # plus ∷ IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 Source # min ∷ IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 Source # max ∷ IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 → IgnoringOverflow ByteSize32 Source # | |
NoThunks a ⇒ NoThunks (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool | |
HasByteSize a ⇒ HasByteSize (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods txMeasureByteSize ∷ IgnoringOverflow a → ByteSize32 Source # | |
TxMeasureMetrics a ⇒ TxMeasureMetrics (IgnoringOverflow a) Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool |
data Invalidated blk Source #
A transaction that was previously valid. Used to clarify the types on the
reapplyTxs
function.
Constructors
Invalidated | |
Fields
|
class (UpdateLedger blk, TxLimits blk, NoThunks (GenTx blk), NoThunks (Validated (GenTx blk)), Show (GenTx blk), Show (Validated (GenTx blk)), Show (ApplyTxErr blk)) ⇒ LedgerSupportsMempool blk where Source #
Minimal complete definition
applyTx, reapplyTx, txForgetValidated, getTransactionKeySets
Methods
txInvariant ∷ GenTx blk → Bool Source #
Check whether the internal invariants of the transaction hold.
Arguments
∷ LedgerConfig blk | |
→ WhetherToIntervene | |
→ SlotNo | Slot number of the block containing the tx |
→ GenTx blk | |
→ TickedLedgerState blk ValuesMK | Contain only the values for the tx to apply |
→ Except (ApplyTxErr blk) (TickedLedgerState blk DiffMK, Validated (GenTx blk)) |
Apply an unvalidated transaction
The mempool expects that the ledger checks the sanity of the transaction' size. The mempool implementation will add any valid transaction as long as there is at least one byte free in the mempool.
The resulting ledger state contains the diffs produced by applying this transaction alone.
Arguments
∷ ComputeDiffs | |
→ LedgerConfig blk | |
→ SlotNo | Slot number of the block containing the tx |
→ Validated (GenTx blk) | |
→ TickedLedgerState blk ValuesMK | Contains at least the values for the tx to reapply |
→ Except (ApplyTxErr blk) (TickedLedgerState blk TrackingMK) |
Apply a previously validated transaction to a potentially different ledger state
When we re-apply a transaction to a potentially different ledger state expensive checks such as cryptographic hashes can be skipped, but other checks (such as checking for double spending) must still be done.
The returned ledger state contains the resulting values too so that this function can be used to reapply a list of transactions, providing as a first state one that contains the values for all the transactions.
Arguments
∷ ComputeDiffs | |
→ LedgerConfig blk | |
→ SlotNo | Slot number of the block containing the tx |
→ [(Validated (GenTx blk), extra)] | |
→ TickedLedgerState blk ValuesMK | |
→ ReapplyTxsResult extra blk |
Apply a list of previously validated transactions to a new ledger state.
It is never the case that we reapply one single transaction, we always reapply a list of transactions (and even one transaction can just be lifted into the unary list).
When reapplying a list of transactions, in the hard-fork instance we want
to first project everything into the particular block instance and then we
can inject/project the ledger tables only once. For single era blocks, this
is by default implemented as a fold using reapplyTx
.
Notice: It is crucial that the list of validated transactions returned is
in the same order as they were given, as we will use those later on to
filter a list of TxTicket
s.
txForgetValidated ∷ Validated (GenTx blk) → GenTx blk Source #
Discard the evidence that transaction has been previously validated
getTransactionKeySets ∷ GenTx blk → LedgerTables (LedgerState blk) KeysMK Source #
Given a transaction, get the key-sets that we need to apply it to a ledger state. This is implemented in the Ledger. An example of non-obvious needed keys in Cardano are those of reference scripts for computing the transaction size.
prependMempoolDiffs ∷ TickedLedgerState blk DiffMK → TickedLedgerState blk DiffMK → TickedLedgerState blk DiffMK Source #
Prepend diffs on ledger states
applyMempoolDiffs ∷ LedgerTables (LedgerState blk) ValuesMK → LedgerTables (LedgerState blk) KeysMK → TickedLedgerState blk DiffMK → TickedLedgerState blk ValuesMK Source #
Apply diffs on ledger states
Instances
(CanHardFork xs, HasCanonicalTxIn xs, HasHardForkTxOut xs) ⇒ LedgerSupportsMempool (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods txInvariant ∷ GenTx (HardForkBlock xs) → Bool Source # applyTx ∷ LedgerConfig (HardForkBlock xs) → WhetherToIntervene → SlotNo → GenTx (HardForkBlock xs) → TickedLedgerState (HardForkBlock xs) ValuesMK → Except (ApplyTxErr (HardForkBlock xs)) (TickedLedgerState (HardForkBlock xs) DiffMK, Validated (GenTx (HardForkBlock xs))) Source # reapplyTx ∷ ComputeDiffs → LedgerConfig (HardForkBlock xs) → SlotNo → Validated (GenTx (HardForkBlock xs)) → TickedLedgerState (HardForkBlock xs) ValuesMK → Except (ApplyTxErr (HardForkBlock xs)) (TickedLedgerState (HardForkBlock xs) TrackingMK) Source # reapplyTxs ∷ ComputeDiffs → LedgerConfig (HardForkBlock xs) → SlotNo → [(Validated (GenTx (HardForkBlock xs)), extra)] → TickedLedgerState (HardForkBlock xs) ValuesMK → ReapplyTxsResult extra (HardForkBlock xs) Source # txForgetValidated ∷ Validated (GenTx (HardForkBlock xs)) → GenTx (HardForkBlock xs) Source # getTransactionKeySets ∷ GenTx (HardForkBlock xs) → LedgerTables (LedgerState (HardForkBlock xs)) KeysMK Source # prependMempoolDiffs ∷ TickedLedgerState (HardForkBlock xs) DiffMK → TickedLedgerState (HardForkBlock xs) DiffMK → TickedLedgerState (HardForkBlock xs) DiffMK Source # applyMempoolDiffs ∷ LedgerTables (LedgerState (HardForkBlock xs)) ValuesMK → LedgerTables (LedgerState (HardForkBlock xs)) KeysMK → TickedLedgerState (HardForkBlock xs) DiffMK → TickedLedgerState (HardForkBlock xs) ValuesMK Source # | |
Bridge m a ⇒ LedgerSupportsMempool (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods txInvariant ∷ GenTx (DualBlock m a) → Bool Source # applyTx ∷ LedgerConfig (DualBlock m a) → WhetherToIntervene → SlotNo → GenTx (DualBlock m a) → TickedLedgerState (DualBlock m a) ValuesMK → Except (ApplyTxErr (DualBlock m a)) (TickedLedgerState (DualBlock m a) DiffMK, Validated (GenTx (DualBlock m a))) Source # reapplyTx ∷ ComputeDiffs → LedgerConfig (DualBlock m a) → SlotNo → Validated (GenTx (DualBlock m a)) → TickedLedgerState (DualBlock m a) ValuesMK → Except (ApplyTxErr (DualBlock m a)) (TickedLedgerState (DualBlock m a) TrackingMK) Source # reapplyTxs ∷ ComputeDiffs → LedgerConfig (DualBlock m a) → SlotNo → [(Validated (GenTx (DualBlock m a)), extra)] → TickedLedgerState (DualBlock m a) ValuesMK → ReapplyTxsResult extra (DualBlock m a) Source # txForgetValidated ∷ Validated (GenTx (DualBlock m a)) → GenTx (DualBlock m a) Source # getTransactionKeySets ∷ GenTx (DualBlock m a) → LedgerTables (LedgerState (DualBlock m a)) KeysMK Source # prependMempoolDiffs ∷ TickedLedgerState (DualBlock m a) DiffMK → TickedLedgerState (DualBlock m a) DiffMK → TickedLedgerState (DualBlock m a) DiffMK Source # applyMempoolDiffs ∷ LedgerTables (LedgerState (DualBlock m a)) ValuesMK → LedgerTables (LedgerState (DualBlock m a)) KeysMK → TickedLedgerState (DualBlock m a) DiffMK → TickedLedgerState (DualBlock m a) ValuesMK Source # |
data ReapplyTxsResult extra blk Source #
Constructors
ReapplyTxsResult | |
Fields
|
A generalized transaction, GenTx
, identifier.
Instances
Typeable xs ⇒ ShowProxy (TxId (GenTx (HardForkBlock xs)) ∷ Type) Source # | |||||
(Typeable m, Typeable a) ⇒ ShowProxy (TxId (GenTx (DualBlock m a)) ∷ Type) Source # | |||||
Generic (TxId (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Associated Types
Methods from ∷ TxId (GenTx (HardForkBlock xs)) → Rep (TxId (GenTx (HardForkBlock xs))) x # to ∷ Rep (TxId (GenTx (HardForkBlock xs))) x → TxId (GenTx (HardForkBlock xs)) # | |||||
CanHardFork xs ⇒ Show (TxId (GenTx (HardForkBlock xs))) Source # | |||||
Show (GenTxId m) ⇒ Show (TxId (GenTx (DualBlock m a))) Source # | |||||
CanHardFork xs ⇒ Eq (TxId (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods (==) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # (/=) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # | |||||
Eq (GenTxId m) ⇒ Eq (TxId (GenTx (DualBlock m a))) Source # | |||||
CanHardFork xs ⇒ Ord (TxId (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods compare ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Ordering # (<) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # (<=) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # (>) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # (>=) ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → Bool # max ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) # min ∷ TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) → TxId (GenTx (HardForkBlock xs)) # | |||||
Ord (GenTxId m) ⇒ Ord (TxId (GenTx (DualBlock m a))) Source # | |||||
Defined in Ouroboros.Consensus.Ledger.Dual Methods compare ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → Ordering # (<) ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → Bool # (<=) ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → Bool # (>) ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → Bool # (>=) ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → Bool # max ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) # min ∷ TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) → TxId (GenTx (DualBlock m a)) # | |||||
CanHardFork xs ⇒ NoThunks (TxId (GenTx (HardForkBlock xs))) Source # | |||||
NoThunks (TxId (GenTx (DualBlock m a))) Source # | |||||
All CondenseConstraints xs ⇒ Condense (TxId (GenTx (HardForkBlock xs))) Source # | |||||
SerialiseHFC xs ⇒ SerialiseNodeToClient (HardForkBlock xs) (GenTxId (HardForkBlock xs)) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseNodeToClient Methods encodeNodeToClient ∷ CodecConfig (HardForkBlock xs) → BlockNodeToClientVersion (HardForkBlock xs) → GenTxId (HardForkBlock xs) → Encoding Source # decodeNodeToClient ∷ CodecConfig (HardForkBlock xs) → BlockNodeToClientVersion (HardForkBlock xs) → ∀ s. Decoder s (GenTxId (HardForkBlock xs)) Source # | |||||
SerialiseHFC xs ⇒ SerialiseNodeToNode (HardForkBlock xs) (GenTxId (HardForkBlock xs)) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseNodeToNode Methods encodeNodeToNode ∷ CodecConfig (HardForkBlock xs) → BlockNodeToNodeVersion (HardForkBlock xs) → GenTxId (HardForkBlock xs) → Encoding Source # decodeNodeToNode ∷ CodecConfig (HardForkBlock xs) → BlockNodeToNodeVersion (HardForkBlock xs) → ∀ s. Decoder s (GenTxId (HardForkBlock xs)) Source # | |||||
type Rep (TxId (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool type Rep (TxId (GenTx (HardForkBlock xs))) = D1 ('MetaData "TxId" "Ouroboros.Consensus.HardFork.Combinator.Mempool" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "HardForkGenTxId" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHardForkGenTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (OneEraGenTxId xs)))) | |||||
newtype TxId (GenTx (HardForkBlock xs)) Source # | |||||
newtype TxId (GenTx (DualBlock m a)) Source # | |||||
Defined in Ouroboros.Consensus.Ledger.Dual |
class (Measure (TxMeasure blk), HasByteSize (TxMeasure blk), NoThunks (TxMeasure blk), TxMeasureMetrics (TxMeasure blk), Show (TxMeasure blk)) ⇒ TxLimits blk where Source #
Each block has its limits of how many transactions it can hold. That limit is compared against the sum of measurements taken of each of the transactions in that block.
How we measure the transaction depends of the era that this transaction belongs to (more specifically it depends on the block type to which this transaction will be added). For initial eras (like Byron and initial generations of Shelley based eras) this measure was simply a byte size (block could not be bigger then given size - in bytes - specified by the ledger state). In subsequent eras (starting with Alonzo) this measure was a bit more complex as it had to take other factors into account (like execution units). For details please see the individual instances for the TxLimits.
Associated Types
The (possibly multi-dimensional) size of a transaction in a block.
Methods
Arguments
∷ LedgerConfig blk | used at least by HFC's composition logic |
→ TickedLedgerState blk ValuesMK | This state needs values as a transaction measure might depend on those. For example in Cardano they look at the reference scripts. |
→ GenTx blk | |
→ Except (ApplyTxErr blk) (TxMeasure blk) |
The various sizes (bytes, Plutus script ExUnits, etc) of a tx /when it's in a block/
This size is used to compute how many transaction we can put in a block when forging one.
The byte size component in particular might differ from the size of the serialisation used to send and receive the transaction across the network. For example, CBOR-in-CBOR could be used when sending the transaction across the network, requiring a few extra bytes compared to the actual in-block serialisation. Another example is the transaction of the hard-fork combinator which will include an envelope indicating its era when sent across the network. However, when embedded in the respective era's block, there is no need for such envelope. An example from upstream is that the Cardano ledger's "Segregated Witness" encoding scheme contributes to the encoding overhead.
INVARIANT Assuming no hash collisions, the size should be the same in any state in which the transaction is valid. For example, it's acceptable to simply omit the size of ref scripts that could not be found, since their absence implies the tx is invalid. In fact, that invalidity could be reported by this function, but it need not be.
INVARIANT Right x = txMeasure cfg st tx
implies @x <=
'blockCapacityTxMeasure cfg st'. Otherwise, the mempool could block
forever.
Returns an exception if and only if the transaction violates the per-tx limits.
blockCapacityTxMeasure Source #
Arguments
∷ ∀ (mk ∷ MapKind). LedgerConfig blk | at least for symmetry with |
→ TickedLedgerState blk mk | |
→ TxMeasure blk |
What is the allowed capacity for the txs in an individual block?
Instances
CanHardFork xs ⇒ TxLimits (HardForkBlock xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Associated Types
Methods txMeasure ∷ LedgerConfig (HardForkBlock xs) → TickedLedgerState (HardForkBlock xs) ValuesMK → GenTx (HardForkBlock xs) → Except (ApplyTxErr (HardForkBlock xs)) (TxMeasure (HardForkBlock xs)) Source # blockCapacityTxMeasure ∷ ∀ (mk ∷ MapKind). LedgerConfig (HardForkBlock xs) → TickedLedgerState (HardForkBlock xs) mk → TxMeasure (HardForkBlock xs) Source # | |||||
Bridge m a ⇒ TxLimits (DualBlock m a) Source # | |||||
Defined in Ouroboros.Consensus.Ledger.Dual Associated Types
Methods txMeasure ∷ LedgerConfig (DualBlock m a) → TickedLedgerState (DualBlock m a) ValuesMK → GenTx (DualBlock m a) → Except (ApplyTxErr (DualBlock m a)) (TxMeasure (DualBlock m a)) Source # blockCapacityTxMeasure ∷ ∀ (mk ∷ MapKind). LedgerConfig (DualBlock m a) → TickedLedgerState (DualBlock m a) mk → TxMeasure (DualBlock m a) Source # |
class TxMeasureMetrics msr where Source #
Methods
txMeasureMetricTxSizeBytes ∷ msr → ByteSize32 Source #
txMeasureMetricExUnitsMemory ∷ msr → Natural Source #
txMeasureMetricExUnitsSteps ∷ msr → Natural Source #
txMeasureMetricRefScriptsSizeBytes ∷ msr → ByteSize32 Source #
Instances
data family Validated x Source #
" Validated " transaction or block
The ledger defines how to validate transactions and blocks. It's possible the type before and after validation may be distinct (eg Alonzo transactions), which originally motivated this family.
We also gain the related benefit that certain interface functions, such as those that reapply blocks, can have a more precise type now. TODO
Similarly, the Node-to-Client mini protocols can explicitly indicate that the
client trusts the blocks from the local server, by having the server send
Validated
blocks to the client. TODO
Note that validation has different implications for a transaction than for a block. In particular, a validated transaction can be " reapplied " to different ledger states, whereas a validated block must only be " reapplied " to the exact same ledger state (eg as part of rebuilding from an on-disk ledger snapshot).
Since the ledger defines validation, see the ledger details for concrete
examples of what determines the validity (wrt to a LedgerState
) of a
transaction and/or block. Example properties include: a transaction's claimed
inputs exist and are still unspent, a block carries a sufficient
cryptographic signature, etc.
Instances
Generic (Validated (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Associated Types
Methods from ∷ Validated (GenTx (HardForkBlock xs)) → Rep (Validated (GenTx (HardForkBlock xs))) x # to ∷ Rep (Validated (GenTx (HardForkBlock xs))) x → Validated (GenTx (HardForkBlock xs)) # | |||||
CanHardFork xs ⇒ Show (Validated (GenTx (HardForkBlock xs))) Source # | |||||
Bridge m a ⇒ Show (Validated (GenTx (DualBlock m a))) Source # | |||||
CanHardFork xs ⇒ Eq (Validated (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool Methods (==) ∷ Validated (GenTx (HardForkBlock xs)) → Validated (GenTx (HardForkBlock xs)) → Bool # (/=) ∷ Validated (GenTx (HardForkBlock xs)) → Validated (GenTx (HardForkBlock xs)) → Bool # | |||||
CanHardFork xs ⇒ NoThunks (Validated (GenTx (HardForkBlock xs))) Source # | |||||
NoThunks (Validated (GenTx (DualBlock m a))) Source # | |||||
type Rep (Validated (GenTx (HardForkBlock xs))) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool type Rep (Validated (GenTx (HardForkBlock xs))) = D1 ('MetaData "Validated" "Ouroboros.Consensus.HardFork.Combinator.Mempool" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "HardForkValidatedGenTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHardForkValidatedGenTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (OneEraValidatedGenTx xs)))) | |||||
newtype Validated (GenTx (HardForkBlock xs)) Source # | |||||
data Validated (GenTx (DualBlock m a)) Source # | |||||
Defined in Ouroboros.Consensus.Ledger.Dual data Validated (GenTx (DualBlock m a)) = ValidatedDualGenTx {
|
data WhetherToIntervene Source #
A flag indicating whether the mempool should reject a valid-but-problematic transaction, in order to to protect its author from penalties etc
The primary example is that, as of the Alonzo ledger, a valid transaction can carry an invalid script. If a remote peer sends us such a transaction (over a Node-to-Node protocol), we include it in a block so that the ledger will penalize them them for the invalid script: they wasted our resources by forcing us to run the script to determine it's invalid. But if our local wallet -- which we trust by assumption -- sends us such a transaction (over a Node-to-Client protocol), we would be a good neighbor by rejecting that transaction: they must have made some sort of mistake, and we don't want the ledger to penalize them.
Constructors
DoNotIntervene | We do not trust remote peers, so if a problematic-yet-valid transaction arrives over NTN, we accept it; it will end up in a block and the ledger will penalize them for it. |
Intervene | We trust local clients, so if a problematic-yet-valid transaction arrives over NTC, we reject it in order to avoid the ledger penalizing them for it. |
Instances
Show WhetherToIntervene Source # | |
Defined in Ouroboros.Consensus.Ledger.SupportsMempool Methods showsPrec ∷ Int → WhetherToIntervene → ShowS # show ∷ WhetherToIntervene → String # showList ∷ [WhetherToIntervene] → ShowS # |