Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module exports implementations of many of the functions outlined in the Alonzo specification. The link to source of the specification https://github.com/intersectmbo/cardano-ledger/tree/master/eras/alonzo/formal-spec The most recent version of the document can be found here: https://github.com/intersectmbo/cardano-ledger/releases/latest/download/alonzo-ledger.pdf The functions can be found in Figures in that document, and sections of this code refer to those figures.
Synopsis
- data CostModel
- getLanguageView ∷ AlonzoEraPParams era ⇒ PParams era → Language → LangDepView
- data Data era
- type DataHash c = SafeHash c EraIndependentData
- newtype IsValid = IsValid Bool
- hashData ∷ Era era ⇒ Data era → DataHash (EraCrypto era)
- nonNativeLanguages ∷ [Language]
- hashScriptIntegrity ∷ ∀ era. AlonzoEraScript era ⇒ Set LangDepView → Redeemers era → TxDats era → StrictMaybe (ScriptIntegrityHash (EraCrypto era))
- getCoin ∷ EraTxOut era ⇒ TxOut era → Coin
- data EraIndependentScriptIntegrity
- data ScriptIntegrity era = ScriptIntegrity !(Redeemers era) !(TxDats era) !(Set LangDepView)
- type ScriptIntegrityHash c = SafeHash c EraIndependentScriptIntegrity
- data AlonzoTx era = AlonzoTx {
- body ∷ !(TxBody era)
- wits ∷ !(TxWits era)
- isValid ∷ !IsValid
- auxiliaryData ∷ !(StrictMaybe (TxAuxData era))
- class (EraTx era, AlonzoEraTxBody era, AlonzoEraTxWits era, AlonzoEraScript era) ⇒ AlonzoEraTx era where
- isValidTxL ∷ Lens' (Tx era) IsValid
- mkBasicAlonzoTx ∷ Monoid (TxWits era) ⇒ TxBody era → AlonzoTx era
- bodyAlonzoTxL ∷ Lens' (AlonzoTx era) (TxBody era)
- witsAlonzoTxL ∷ Lens' (AlonzoTx era) (TxWits era)
- auxDataAlonzoTxL ∷ Lens' (AlonzoTx era) (StrictMaybe (TxAuxData era))
- sizeAlonzoTxF ∷ ∀ era. EraTx era ⇒ SimpleGetter (AlonzoTx era) Integer
- wireSizeAlonzoTxF ∷ ∀ era. EraTx era ⇒ SimpleGetter (AlonzoTx era) Word32
- isValidAlonzoTxL ∷ Lens' (AlonzoTx era) IsValid
- txdats' ∷ Era era ⇒ AlonzoTxWits era → TxDats era
- txscripts' ∷ Era era ⇒ AlonzoTxWits era → Map (ScriptHash (EraCrypto era)) (Script era)
- txrdmrs ∷ AlonzoEraScript era ⇒ AlonzoTxWits era → Redeemers era
- data AlonzoTxBody era where
- pattern AlonzoTxBody ∷ (EraTxOut era, EraTxCert era) ⇒ Set (TxIn (EraCrypto era)) → Set (TxIn (EraCrypto era)) → StrictSeq (TxOut era) → StrictSeq (TxCert era) → Withdrawals (EraCrypto era) → Coin → ValidityInterval → StrictMaybe (Update era) → Set (KeyHash 'Witness (EraCrypto era)) → MultiAsset (EraCrypto era) → StrictMaybe (ScriptIntegrityHash (EraCrypto era)) → StrictMaybe (AuxiliaryDataHash (EraCrypto era)) → StrictMaybe Network → AlonzoTxBody era
- totExUnits ∷ (EraTx era, AlonzoEraTxWits era) ⇒ Tx era → ExUnits
- alonzoMinFeeTx ∷ (EraTx era, AlonzoEraTxWits era, AlonzoEraPParams era) ⇒ PParams era → Tx era → Coin
- minfee ∷ (EraTx era, AlonzoEraTxWits era, AlonzoEraPParams era) ⇒ PParams era → Tx era → Coin
- isTwoPhaseScriptAddressFromMap ∷ ∀ era. AlonzoEraScript era ⇒ Map (ScriptHash (EraCrypto era)) (Script era) → Addr (EraCrypto era) → Bool
- txouts ∷ EraTxBody era ⇒ TxBody era → UTxO era
- indexRedeemers ∷ (AlonzoEraTxWits era, EraTx era) ⇒ Tx era → PlutusPurpose AsIxItem era → Maybe (Data era, ExUnits)
- getMapFromValue ∷ MaryValue c → Map (PolicyID c) (Map AssetName Integer)
- alonzoSegwitTx ∷ AlonzoEraTx era ⇒ Annotator (TxBody era) → Annotator (TxWits era) → IsValid → Maybe (Annotator (TxAuxData era)) → Annotator (Tx era)
- toCBORForSizeComputation ∷ (EncCBOR (TxBody era), EncCBOR (TxWits era), EncCBOR (TxAuxData era)) ⇒ AlonzoTx era → Encoding
- toCBORForMempoolSubmission ∷ (EncCBOR (TxBody era), EncCBOR (TxWits era), EncCBOR (TxAuxData era)) ⇒ AlonzoTx era → Encoding
- alonzoEqTxRaw ∷ AlonzoEraTx era ⇒ Tx era → Tx era → Bool
Documentation
A language dependent cost model for the Plutus evaluator.
Note that the EvaluationContext
is entirely dependent on the
cost model parameters (ie the Map
Text
Integer
) and that
this type uses the smart constructor mkCostModel
to hide the evaluation context.
Instances
ToJSON CostModel | |
Generic CostModel | |
Show CostModel | |
NFData CostModel | |
Defined in Cardano.Ledger.Plutus.CostModels | |
Eq CostModel | Note that this Eq instance ignores the evaluation context, which is
entirely dependent on the cost model parameters and is guarded by the
smart constructor |
Ord CostModel | Note that this Ord instance ignores the evaluation context, which is
entirely dependent on the cost model parameters and is guarded by the
smart constructor |
Defined in Cardano.Ledger.Plutus.CostModels | |
NoThunks CostModel | |
type Rep CostModel | |
Defined in Cardano.Ledger.Plutus.CostModels type Rep CostModel = D1 ('MetaData "CostModel" "Cardano.Ledger.Plutus.CostModels" "cardano-ledger-core-1.15.0.0-inplace" 'False) (C1 ('MetaCons "CostModel" 'PrefixI 'True) (S1 ('MetaSel ('Just "cmLanguage") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Language) :*: (S1 ('MetaSel ('Just "cmValues") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Int64]) :*: S1 ('MetaSel ('Just "cmEvalCtx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EvaluationContext)))) |
getLanguageView ∷ AlonzoEraPParams era ⇒ PParams era → Language → LangDepView Source #
Instances
type DataHash c = SafeHash c EraIndependentData Source #
Tag indicating whether non-native scripts in this transaction are expected to validate. This is added by the block creator when constructing the block.
Instances
ToJSON IsValid Source # | |
Generic IsValid Source # | |
Show IsValid Source # | |
ToCBOR IsValid Source # | |
DecCBOR IsValid Source # | |
EncCBOR IsValid Source # | |
NFData IsValid Source # | |
Defined in Cardano.Ledger.Alonzo.Tx | |
Eq IsValid Source # | |
NoThunks IsValid Source # | |
type Rep IsValid Source # | |
Defined in Cardano.Ledger.Alonzo.Tx |
hashScriptIntegrity ∷ ∀ era. AlonzoEraScript era ⇒ Set LangDepView → Redeemers era → TxDats era → StrictMaybe (ScriptIntegrityHash (EraCrypto era)) Source #
data EraIndependentScriptIntegrity Source #
Instances
(Era era, c ~ EraCrypto era) ⇒ HashAnnotated (ScriptIntegrity era) EraIndependentScriptIntegrity c Source # | |
data ScriptIntegrity era Source #
A ScriptIntegrityHash is the hash of three things. The first two come from the witnesses and the last comes from the Protocol Parameters.
ScriptIntegrity !(Redeemers era) !(TxDats era) !(Set LangDepView) |
Instances
AlonzoTx | |
|
Instances
class (EraTx era, AlonzoEraTxBody era, AlonzoEraTxWits era, AlonzoEraScript era) ⇒ AlonzoEraTx era where Source #
Instances
Crypto c ⇒ AlonzoEraTx (AlonzoEra c) Source # | |
Defined in Cardano.Ledger.Alonzo.Tx |
auxDataAlonzoTxL ∷ Lens' (AlonzoTx era) (StrictMaybe (TxAuxData era)) Source #
sizeAlonzoTxF ∷ ∀ era. EraTx era ⇒ SimpleGetter (AlonzoTx era) Integer Source #
txsize computes the length of the serialised bytes (for estimations)
wireSizeAlonzoTxF ∷ ∀ era. EraTx era ⇒ SimpleGetter (AlonzoTx era) Word32 Source #
txsize computes the length of the serialised bytes (actual size)
txscripts' ∷ Era era ⇒ AlonzoTxWits era → Map (ScriptHash (EraCrypto era)) (Script era) Source #
txrdmrs ∷ AlonzoEraScript era ⇒ AlonzoTxWits era → Redeemers era Source #
data AlonzoTxBody era where Source #
pattern AlonzoTxBody ∷ (EraTxOut era, EraTxCert era) ⇒ Set (TxIn (EraCrypto era)) → Set (TxIn (EraCrypto era)) → StrictSeq (TxOut era) → StrictSeq (TxCert era) → Withdrawals (EraCrypto era) → Coin → ValidityInterval → StrictMaybe (Update era) → Set (KeyHash 'Witness (EraCrypto era)) → MultiAsset (EraCrypto era) → StrictMaybe (ScriptIntegrityHash (EraCrypto era)) → StrictMaybe (AuxiliaryDataHash (EraCrypto era)) → StrictMaybe Network → AlonzoTxBody era |
Instances
totExUnits ∷ (EraTx era, AlonzoEraTxWits era) ⇒ Tx era → ExUnits Source #
alonzoMinFeeTx ∷ (EraTx era, AlonzoEraTxWits era, AlonzoEraPParams era) ⇒ PParams era → Tx era → Coin Source #
minfee ∷ (EraTx era, AlonzoEraTxWits era, AlonzoEraPParams era) ⇒ PParams era → Tx era → Coin Source #
Deprecated: In favor of getMinFeeTx
isTwoPhaseScriptAddressFromMap ∷ ∀ era. AlonzoEraScript era ⇒ Map (ScriptHash (EraCrypto era)) (Script era) → Addr (EraCrypto era) → Bool Source #
Deprecated: No longer used. Inline implementation if you need it
Compute if an Addr has the hash of a TwoPhaseScript, we can tell what kind of Script from the Hash, by looking it up in the Map
txouts ∷ EraTxBody era ⇒ TxBody era → UTxO era Source #
Compute the transaction outputs of a transaction.
indexRedeemers ∷ (AlonzoEraTxWits era, EraTx era) ⇒ Tx era → PlutusPurpose AsIxItem era → Maybe (Data era, ExUnits) Source #
Deprecated: As no longer needed
Find the Data and ExUnits assigned to a plutus script.
getMapFromValue ∷ MaryValue c → Map (PolicyID c) (Map AssetName Integer) Source #
Deprecated: No longer used
alonzoSegwitTx ∷ AlonzoEraTx era ⇒ Annotator (TxBody era) → Annotator (TxWits era) → IsValid → Maybe (Annotator (TxAuxData era)) → Annotator (Tx era) Source #
Construct an annotated Alonzo style transaction.
toCBORForSizeComputation ∷ (EncCBOR (TxBody era), EncCBOR (TxWits era), EncCBOR (TxAuxData era)) ⇒ AlonzoTx era → Encoding Source #
This ensures that the size of transactions from Mary is unchanged. The individual components all store their bytes; the only work we do in this function is concatenating
toCBORForMempoolSubmission ∷ (EncCBOR (TxBody era), EncCBOR (TxWits era), EncCBOR (TxAuxData era)) ⇒ AlonzoTx era → Encoding Source #
Encode to CBOR for the purposes of transmission from node to node, or from wallet to node.
Note that this serialisation is neither the serialisation used on-chain
(where Txs are deconstructed using segwit), nor the serialisation used for
computing the transaction size (which omits the IsValid
field for
compatibility with Mary - see toCBORForSizeComputation
).
alonzoEqTxRaw ∷ AlonzoEraTx era ⇒ Tx era → Tx era → Bool Source #
Orphan instances
Crypto c ⇒ EraTx (AlonzoEra c) Source # | |
mkBasicTx ∷ TxBody (AlonzoEra c) → Tx (AlonzoEra c) Source # bodyTxL ∷ Lens' (Tx (AlonzoEra c)) (TxBody (AlonzoEra c)) Source # witsTxL ∷ Lens' (Tx (AlonzoEra c)) (TxWits (AlonzoEra c)) Source # auxDataTxL ∷ Lens' (Tx (AlonzoEra c)) (StrictMaybe (AuxiliaryData (AlonzoEra c))) Source # sizeTxF ∷ SimpleGetter (Tx (AlonzoEra c)) Integer Source # wireSizeTxF ∷ SimpleGetter (Tx (AlonzoEra c)) Word32 Source # validateNativeScript ∷ Tx (AlonzoEra c) → NativeScript (AlonzoEra c) → Bool Source # getMinFeeTx ∷ PParams (AlonzoEra c) → Tx (AlonzoEra c) → Int → Coin Source # upgradeTx ∷ Tx (PreviousEra (AlonzoEra c)) → Either (TxUpgradeError (AlonzoEra c)) (Tx (AlonzoEra c)) Source # |