Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Interface to the Shelley ledger for the purposes of managing a Shelley mempool.
Synopsis
- applyTx ∷ (ApplyTx era, MonadError (ApplyTxError era) m) ⇒ Globals → MempoolEnv era → MempoolState era → Tx era → m (MempoolState era, Validated (Tx era))
- class (EraTx era, Eq (ApplyTxError era), Show (ApplyTxError era), Typeable (ApplyTxError era), STS (EraRule "LEDGER" era), BaseM (EraRule "LEDGER" era) ~ ShelleyBase, Environment (EraRule "LEDGER" era) ~ LedgerEnv era, State (EraRule "LEDGER" era) ~ MempoolState era, Signal (EraRule "LEDGER" era) ~ Tx era) ⇒ ApplyTx era where
- applyTxOpts ∷ ∀ ep m. (MonadError (ApplyTxError era) m, EventReturnTypeRep ep) ⇒ ApplySTSOpts ep → Globals → MempoolEnv era → MempoolState era → Tx era → m (EventReturnType ep (EraRule "LEDGER" era) (MempoolState era, Validated (Tx era)))
- reapplyTx ∷ MonadError (ApplyTxError era) m ⇒ Globals → MempoolEnv era → MempoolState era → Validated (Tx era) → m (MempoolState era)
- newtype ApplyTxError era = ApplyTxError (NonEmpty (PredicateFailure (EraRule "LEDGER" era)))
- data Validated tx
- extractTx ∷ Validated tx → tx
- coerceValidated ∷ Coercible a b ⇒ Validated a → Validated b
- translateValidated ∷ ∀ era f. TranslateEra era f ⇒ TranslationContext era → Validated (f (PreviousEra era)) → Except (TranslationError era f) (Validated (f era))
- type MempoolEnv era = LedgerEnv era
- type MempoolState era = LedgerState era
- unsafeMakeValidated ∷ tx → Validated tx
- mkMempoolEnv ∷ EraGov era ⇒ NewEpochState era → SlotNo → MempoolEnv era
- mkMempoolState ∷ NewEpochState era → MempoolState era
- overNewEpochState ∷ Functor f ⇒ (MempoolState era → f (MempoolState era)) → NewEpochState era → f (NewEpochState era)
Documentation
applyTx ∷ (ApplyTx era, MonadError (ApplyTxError era) m) ⇒ Globals → MempoolEnv era → MempoolState era → Tx era → m (MempoolState era, Validated (Tx era)) Source #
Validate a transaction against a mempool state using default STS options
and return both the new mempool state and a "validated" TxInBlock
.
The meaning of being "validated" depends on the era. In general, a
TxInBlock
has had all checks run, and can now only fail due to checks
which depend on the state; most notably, that UTxO inputs disappear.
class (EraTx era, Eq (ApplyTxError era), Show (ApplyTxError era), Typeable (ApplyTxError era), STS (EraRule "LEDGER" era), BaseM (EraRule "LEDGER" era) ~ ShelleyBase, Environment (EraRule "LEDGER" era) ~ LedgerEnv era, State (EraRule "LEDGER" era) ~ MempoolState era, Signal (EraRule "LEDGER" era) ~ Tx era) ⇒ ApplyTx era where Source #
Nothing
applyTxOpts ∷ ∀ ep m. (MonadError (ApplyTxError era) m, EventReturnTypeRep ep) ⇒ ApplySTSOpts ep → Globals → MempoolEnv era → MempoolState era → Tx era → m (EventReturnType ep (EraRule "LEDGER" era) (MempoolState era, Validated (Tx era))) Source #
Validate a transaction against a mempool state and for given STS options,
and return the new mempool state, a "validated" TxInBlock
and,
depending on the passed options, the emitted events.
reapplyTx ∷ MonadError (ApplyTxError era) m ⇒ Globals → MempoolEnv era → MempoolState era → Validated (Tx era) → m (MempoolState era) Source #
Reapply a previously validated Tx
.
This applies the (validated) transaction to a new mempool state. It may fail due to the mempool state changing (for example, a needed output having already been spent). It should not fail due to any static check (such as cryptographic checks).
Implementations of this function may optionally skip the performance of any static checks. This is not required, but strongly encouraged since this function will be called each time the mempool revalidates transactions against a new mempool state.
Instances
(EraPParams (ShelleyEra c), DSignable c (Hash c EraIndependentTxBody)) ⇒ ApplyTx (ShelleyEra c) Source # | |
Defined in Cardano.Ledger.Shelley.API.Mempool applyTxOpts ∷ ∀ (ep ∷ EventPolicy) m. (MonadError (ApplyTxError (ShelleyEra c)) m, EventReturnTypeRep ep) ⇒ ApplySTSOpts ep → Globals → MempoolEnv (ShelleyEra c) → MempoolState (ShelleyEra c) → Tx (ShelleyEra c) → m (EventReturnType ep (EraRule "LEDGER" (ShelleyEra c)) (MempoolState (ShelleyEra c), Validated (Tx (ShelleyEra c)))) Source # reapplyTx ∷ MonadError (ApplyTxError (ShelleyEra c)) m ⇒ Globals → MempoolEnv (ShelleyEra c) → MempoolState (ShelleyEra c) → Validated (Tx (ShelleyEra c)) → m (MempoolState (ShelleyEra c)) Source # |
newtype ApplyTxError era Source #
ApplyTxError (NonEmpty (PredicateFailure (EraRule "LEDGER" era))) |
Instances
A newtype which indicates that a transaction has been validated against some chain state.
translateValidated ∷ ∀ era f. TranslateEra era f ⇒ TranslationContext era → Validated (f (PreviousEra era)) → Except (TranslationError era f) (Validated (f era)) Source #
Translate a validated transaction across eras.
This is not a TranslateEra
instance since Validated
is not itself
era-parametrised.
Exports for testing
type MempoolEnv era = LedgerEnv era Source #
type MempoolState era = LedgerState era Source #
unsafeMakeValidated ∷ tx → Validated tx Source #
Exports for compatibility
mkMempoolEnv ∷ EraGov era ⇒ NewEpochState era → SlotNo → MempoolEnv era Source #
Construct the environment used to validate transactions from the full ledger state.
Note that this function also takes a slot. During slot validation, the slot given here is the slot of the block containing the transactions. This slot is used for quite a number of things, but in general these do not determine the validity of the transaction. There are two exceptions:
- Each transaction has a ttl (time-to-live) value. If the slot is beyond this value, then the transaction is invalid.
- If the transaction contains a protocol update proposal, then it may only be included until a certain number of slots before the end of the epoch. A protocol update proposal submitted after this is considered invalid.
mkMempoolState ∷ NewEpochState era → MempoolState era Source #
Construct a mempool state from the wider ledger state.
The given mempool state may then be evolved using applyTxs
, but should be
regenerated when the ledger state gets updated (e.g. through application of
a new block).
overNewEpochState ∷ Functor f ⇒ (MempoolState era → f (MempoolState era)) → NewEpochState era → f (NewEpochState era) Source #
Transform a function over mempool states to one over the full
NewEpochState
.