cardano-ledger-shelley-1.19.0.0: Shelley Ledger Executable Model
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Shelley.API.Mempool

Description

Interface to the Shelley ledger for the purposes of managing a Shelley mempool.

Synopsis

Documentation

applyTxApplyTx era ⇒ GlobalsMempoolEnv era → MempoolState era → Tx 'TopTx era → Either (ApplyTxError era) (MempoolState era, Validated (Tx 'TopTx era)) Source #

Deprecated: Use applyTxWithFullValidation instead.

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.

applyTxWithFullValidationApplyTx era ⇒ GlobalsMempoolEnv era → MempoolState era → Tx 'TopTx era → Either (ApplyTxError era) (MempoolState era, ValidatedTx era) Source #

Validate a transaction against a mempool state and return the new mempool state together with a ValidatedTx

reapplyValidatedTx ∷ (ApplyTx era, EraGov era) ⇒ GlobalsMempoolEnv era → MempoolState era → ValidatedTx era → Either (ApplyTxError era) (MempoolState era) Source #

Reapply a previously validated transaction, skipping static checks. Use the state-derived annotations in StAnnTx if the current protocol version matches the one in ValidatedTx, otherwise reconstruct `StAnnTx. If major protocol version has changed from when ValidatedTx was constructed, then full validation is triggered again.

reapplyTxApplyTx era ⇒ GlobalsMempoolEnv era → MempoolState era → Validated (Tx 'TopTx era) → Either (ApplyTxError era) (MempoolState era) Source #

Deprecated: Use reapplyValidatedTx instead.

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 does not fail due to any static check (such as cryptographic checks).

class (EraTx era, Eq (ApplyTxError era), Show (ApplyTxError era), Typeable (ApplyTxError era), Semigroup (ApplyTxError era), EncCBOR (ApplyTxError era), DecCBOR (ApplyTxError era)) ⇒ ApplyTx era where Source #

Associated Types

data ApplyTxError era Source #

Methods

mkStAnnTxEpochInfo (Either Text) → SystemStartPParams era → UTxO era → Tx 'TopTx era → StAnnTx 'TopTx era Source #

internalApplyTxWithValidationValidationPolicyGlobalsMempoolEnv era → MempoolState era → Tx 'TopTx era → Either (ApplyTxError era) (MempoolState era, ValidatedTx era) Source #

Validate a transaction against a mempool state for given STS options.

Warning - This function is only safe when ValidateAll policy is supplied, otherwise invariant for ValidatedTx could be violated. It will always be safer to use applyTxWithFullValidation instead.

internalReapplyValidatedTxGlobalsMempoolEnv era → MempoolState era → ValidatedTx era → Either (ApplyTxError era) (MempoolState era) Source #

Reapply a previously validated transaction.

Warning - Should not be used directly. reapplyValidatedTx should be used instead.

applyTxValidationValidationPolicyGlobalsMempoolEnv era → MempoolState era → StAnnTx 'TopTx era → Either (ApplyTxError era) (MempoolState era, Validated (Tx 'TopTx era)) Source #

Deprecated: Use internalApplyTxWithValidation instead.

Validate a transaction against a mempool state for given STS options, and return the new mempool state, a "validated" 'TxInBlock

data family ApplyTxError era Source #

Instances

Instances details
DecCBOR (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

EncCBOR (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Semigroup (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Generic (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Show (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Eq (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

newtype ApplyTxError ShelleyEra Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

type Rep (ApplyTxError ShelleyEra) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

data Validated tx Source #

Deprecated: Use ValidatedTx instead.

A newtype which indicates that a transaction has been validated against some chain state.

Instances

Instances details
NFData tx ⇒ NFData (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

rnfValidated tx → () #

Show tx ⇒ Show (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

showsPrecIntValidated tx → ShowS #

showValidated tx → String #

showList ∷ [Validated tx] → ShowS #

Eq tx ⇒ Eq (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

(==)Validated tx → Validated tx → Bool #

(/=)Validated tx → Validated tx → Bool #

NoThunks tx ⇒ NoThunks (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

data ValidatedTx era Source #

A transaction that has been validated against some chain state.

Instances

Instances details
NFData (StAnnTx 'TopTx era) ⇒ NFData (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

rnfValidatedTx era → () #

Generic (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Associated Types

type Rep (ValidatedTx era) 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

type Rep (ValidatedTx era) = D1 ('MetaData "ValidatedTx" "Cardano.Ledger.Shelley.API.Mempool" "cardano-ledger-shelley-1.19.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "vtStAnnTx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StAnnTx 'TopTx era)) :*: (S1 ('MetaSel ('Just "vtProtocolVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProtVer) :*: S1 ('MetaSel ('Just "vtSlotNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo))))

Methods

fromValidatedTx era → Rep (ValidatedTx era) x #

toRep (ValidatedTx era) x → ValidatedTx era #

Show (StAnnTx 'TopTx era) ⇒ Show (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

showsPrecIntValidatedTx era → ShowS #

showValidatedTx era → String #

showList ∷ [ValidatedTx era] → ShowS #

Eq (StAnnTx 'TopTx era) ⇒ Eq (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

(==)ValidatedTx era → ValidatedTx era → Bool #

(/=)ValidatedTx era → ValidatedTx era → Bool #

NoThunks (StAnnTx 'TopTx era) ⇒ NoThunks (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

type Rep (ValidatedTx era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

type Rep (ValidatedTx era) = D1 ('MetaData "ValidatedTx" "Cardano.Ledger.Shelley.API.Mempool" "cardano-ledger-shelley-1.19.0.0-inplace" 'False) (C1 ('MetaCons "ValidatedTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "vtStAnnTx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StAnnTx 'TopTx era)) :*: (S1 ('MetaSel ('Just "vtProtocolVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProtVer) :*: S1 ('MetaSel ('Just "vtSlotNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo))))

extractTxValidated tx → tx Source #

Deprecated: Use extractValidatedTx

Extract the underlying unvalidated Tx.

coerceValidatedCoercible a b ⇒ Validated a → Validated b Source #

Deprecated: Validated is deprecated; switch to ValidatedTx.

translateValidatedTranslateEra era f ⇒ TranslationContext era → Validated (f (PreviousEra era)) → Except (TranslationError era f) (Validated (f era)) Source #

Deprecated: Translation of Validated does not make sense. It must be fully re-validated in a new era

Translate a validated transaction across eras.

This is not a TranslateEra instance since Validated is not itself era-parametrised.

ruleApplyTxValidation ∷ ∀ (rule ∷ Symbol) era. (EraTx era, STS (EraRule rule era), BaseM (EraRule rule era) ~ ShelleyBase, Environment (EraRule rule era) ~ LedgerEnv era, State (EraRule rule era) ~ MempoolState era, Signal (EraRule rule era) ~ StAnnTx 'TopTx era) ⇒ ValidationPolicyGlobalsMempoolEnv era → MempoolState era → StAnnTx 'TopTx era → Either (NonEmpty (PredicateFailure (EraRule rule era))) (MempoolState era, ValidatedTx era) Source #

defaultApplyTxWithValidation ∷ ∀ (rule ∷ Symbol) era. (ApplyTx era, STS (EraRule rule era), BaseM (EraRule rule era) ~ ShelleyBase, Environment (EraRule rule era) ~ LedgerEnv era, State (EraRule rule era) ~ MempoolState era, Signal (EraRule rule era) ~ StAnnTx 'TopTx era) ⇒ (NonEmpty (PredicateFailure (EraRule rule era)) → ApplyTxError era) → ValidationPolicyGlobalsMempoolEnv era → MempoolState era → Tx 'TopTx era → Either (ApplyTxError era) (MempoolState era, ValidatedTx era) Source #

A default implementation for internalApplyTxWithValidation, parameterised by the STS rule to run and a wrapper that lifts predicate failures into the era's ApplyTxError.

defaultReapplyValidatedTx ∷ ∀ (rule ∷ Symbol) era. (ApplyTx era, STS (EraRule rule era), BaseM (EraRule rule era) ~ ShelleyBase, Environment (EraRule rule era) ~ LedgerEnv era, State (EraRule rule era) ~ MempoolState era, Signal (EraRule rule era) ~ StAnnTx 'TopTx era) ⇒ (NonEmpty (PredicateFailure (EraRule rule era)) → ApplyTxError era) → GlobalsMempoolEnv era → MempoolState era → ValidatedTx era → Either (ApplyTxError era) (MempoolState era) Source #

A default implementation for internalReapplyValidatedTx, parameterised by the STS rule to run and a wrapper that lifts predicate failures into the era's ApplyTxError.

Exports for testing

type MempoolEnv era = LedgerEnv era Source #

unsafeMakeValidated ∷ tx → Validated tx Source #

Deprecated: Use unsafeMakeValidatedTx instead.

unsafeMakeValidatedTxApplyTx era ⇒ GlobalsMempoolEnv era → MempoolState era → Tx 'TopTx era → ValidatedTx era Source #

Build a ValidatedTx without running the LEDGER rule - should only be used for testing.

Exports for compatibility

mkMempoolEnvEraGov era ⇒ NewEpochState era → SlotNoMempoolEnv 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.

mkMempoolStateNewEpochState 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).

overNewEpochStateFunctor f ⇒ (MempoolState era → f (MempoolState era)) → NewEpochState era → f (NewEpochState era) Source #

Transform a function over mempool states to one over the full NewEpochState.