cardano-ledger-core-1.14.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Core

Description

This module defines core type families which we know to vary from era to era.

Families in this module should be indexed on era.

It is intended for qualified import: > import qualified Cardano.Ledger.Core as Core

Synopsis

Era-changing types

class (EraTxBody era, EraTxWits era, EraTxAuxData era, EraPParams era, NoThunks (Tx era), DecCBOR (Annotator (Tx era)), EncCBOR (Tx era), ToCBOR (Tx era), Show (Tx era), Eq (Tx era), EqRaw (Tx era)) ⇒ EraTx era where Source #

A transaction.

Associated Types

type Tx era = (r ∷ Type) | r → era Source #

type TxUpgradeError era ∷ Type Source #

type TxUpgradeError era = Void

Methods

mkBasicTxTxBody era → Tx era Source #

bodyTxLLens' (Tx era) (TxBody era) Source #

witsTxLLens' (Tx era) (TxWits era) Source #

auxDataTxLLens' (Tx era) (StrictMaybe (AuxiliaryData era)) Source #

sizeTxFSimpleGetter (Tx era) Integer Source #

validateNativeScriptTx era → NativeScript era → Bool Source #

Using information from the transaction validate the supplied native script.

getMinFeeTx Source #

Arguments

PParams era 
Tx era 
Int

Size in bytes of reference scripts present in this transaction

Coin 

Minimum fee calculation excluding witnesses

upgradeTxEraTx (PreviousEra era) ⇒ Tx (PreviousEra era) → Either (TxUpgradeError era) (Tx era) Source #

txIdTxEraTx era ⇒ Tx era → TxId (EraCrypto era) Source #

class (Val (Value era), ToJSON (TxOut era), DecCBOR (Value era), DecCBOR (CompactForm (Value era)), EncCBOR (Value era), ToCBOR (TxOut era), FromCBOR (TxOut era), EncCBOR (TxOut era), DecCBOR (TxOut era), DecShareCBOR (TxOut era), Share (TxOut era) ~ Interns (Credential 'Staking (EraCrypto era)), NoThunks (TxOut era), NFData (TxOut era), Show (TxOut era), Eq (TxOut era), EraPParams era) ⇒ EraTxOut era where Source #

Abstract interface into specific fields of a TxOut

Associated Types

type TxOut era = (r ∷ Type) | r → era Source #

The output of a UTxO for a particular era

Methods

mkBasicTxOutHasCallStackAddr (EraCrypto era) → Value era → TxOut era Source #

upgradeTxOutEraTxOut (PreviousEra era) ⇒ TxOut (PreviousEra era) → TxOut era Source #

Every era, except Shelley, must be able to upgrade a TxOut from a previous era.

valueTxOutLLens' (TxOut era) (Value era) Source #

compactValueTxOutLHasCallStackLens' (TxOut era) (CompactForm (Value era)) Source #

valueEitherTxOutLLens' (TxOut era) (Either (Value era) (CompactForm (Value era))) Source #

Lens for getting and setting in TxOut either an address or its compact version by doing the least amount of work.

addrTxOutLLens' (TxOut era) (Addr (EraCrypto era)) Source #

compactAddrTxOutLLens' (TxOut era) (CompactAddr (EraCrypto era)) Source #

addrEitherTxOutLLens' (TxOut era) (Either (Addr (EraCrypto era)) (CompactAddr (EraCrypto era))) Source #

Lens for getting and setting in TxOut either an address or its compact version by doing the least amount of work.

The utility of this function comes from the fact that TxOut usually stores the address in either one of two forms: compacted or unpacked. In order to avoid extroneous conversions in getTxOutAddr and getTxOutCompactAddr we can define just this functionality. Also sometimes it is crucial to know at the callsite which form of address we have readily available without any conversions (eg. searching millions of TxOuts for a particular address)

getMinCoinSizedTxOutPParams era → Sized (TxOut era) → Coin Source #

Produce the minimum lovelace that a given transaction output must contain. Information about the size of the TxOut is required in some eras. Use getMinCoinTxOut if you don't have the size readily available to you.

getMinCoinTxOutPParams era → TxOut era → Coin Source #

Same as getMinCoinSizedTxOut, except information about the size of TxOut will be computed by serializing the TxOut. If the size turns out to be not needed, then serialization will have no overhead, since it is computed lazily.

isAdaOnlyTxOutFEraTxOut era ⇒ SimpleGetter (TxOut era) Bool Source #

This is a getter that implements an efficient way to check whether TxOut contains ADA only.

class (EraTxOut era, EraTxCert era, EraPParams era, HashAnnotated (TxBody era) EraIndependentTxBody (EraCrypto era), DecCBOR (Annotator (TxBody era)), EncCBOR (TxBody era), ToCBOR (TxBody era), NoThunks (TxBody era), NFData (TxBody era), Show (TxBody era), Eq (TxBody era), EqRaw (TxBody era)) ⇒ EraTxBody era where Source #

Associated Types

type TxBody era = (r ∷ Type) | r → era Source #

The body of a transaction.

type TxBodyUpgradeError era ∷ Type Source #

Methods

mkBasicTxBodyTxBody era Source #

inputsTxBodyLLens' (TxBody era) (Set (TxIn (EraCrypto era))) Source #

outputsTxBodyLLens' (TxBody era) (StrictSeq (TxOut era)) Source #

feeTxBodyLLens' (TxBody era) Coin Source #

withdrawalsTxBodyLLens' (TxBody era) (Withdrawals (EraCrypto era)) Source #

auxDataHashTxBodyLLens' (TxBody era) (StrictMaybe (AuxiliaryDataHash (EraCrypto era))) Source #

spendableInputsTxBodyFSimpleGetter (TxBody era) (Set (TxIn (EraCrypto era))) Source #

This getter will produce all inputs from the UTxO map that this transaction might spend, which ones will depend on the validity of the transaction itself. Starting in Alonzo this will include collateral inputs.

allInputsTxBodyFSimpleGetter (TxBody era) (Set (TxIn (EraCrypto era))) Source #

This getter will produce all inputs from the UTxO map that this transaction is referencing, even if some of them cannot be spent by the transaction. For example starting with Babbage era it will also include reference inputs.

certsTxBodyLLens' (TxBody era) (StrictSeq (TxCert era)) Source #

getTotalDepositsTxBody Source #

Arguments

PParams era 
→ (KeyHash 'StakePool (EraCrypto era) → Bool)

Check whether stake pool is registered or not

TxBody era 
Coin 

Compute the total deposits from the certificates in a TxBody.

This is the contribution of a TxBody towards the consumed amount by the transaction

getTotalRefundsTxBody Source #

Arguments

PParams era 
→ (Credential 'Staking (EraCrypto era) → Maybe Coin)

Lookup current deposit for Staking credential if one is registered

→ (Credential 'DRepRole (EraCrypto era) → Maybe Coin)

Lookup current deposit for DRep credential if one is registered

TxBody era 
Coin 

Compute the total refunds from the Certs of a TxBody.

This is the contribution of a TxBody towards produced amount by the transaction

getGenesisKeyHashCountTxBodyTxBody era → Int Source #

This function is not used in the ledger rules. It is only used by the downstream tooling to figure out how many witnesses should be supplied for Genesis keys.

upgradeTxBodyEraTxBody (PreviousEra era) ⇒ TxBody (PreviousEra era) → Either (TxBodyUpgradeError era) (TxBody era) Source #

Upgrade the transaction body from the previous era.

This can fail where elements of the transaction body are deprecated. Compare this to translateEraThroughCBOR: - upgradeTxBody will use the Haskell representation, but will not preserve the serialised form. However, it will be suitable for iterated translation through eras. - translateEraThroughCBOR will preserve the binary representation, but is not guaranteed to work through multiple eras - that is, the serialised representation from era n is guaranteed valid in era n + 1, but not necessarily in era n + 2.

txIdTxBodyEraTxBody era ⇒ TxBody era → TxId (EraCrypto era) Source #

class (Era era, Eq (TxAuxData era), EqRaw (TxAuxData era), Show (TxAuxData era), NoThunks (TxAuxData era), ToCBOR (TxAuxData era), EncCBOR (TxAuxData era), DecCBOR (Annotator (TxAuxData era)), HashAnnotated (TxAuxData era) EraIndependentTxAuxData (EraCrypto era)) ⇒ EraTxAuxData era where Source #

TxAuxData which may be attached to a transaction

Associated Types

type TxAuxData era = (r ∷ Type) | r → era Source #

Methods

mkBasicTxAuxDataTxAuxData era Source #

metadataTxAuxDataLLens' (TxAuxData era) (Map Word64 Metadatum) Source #

upgradeTxAuxDataEraTxAuxData (PreviousEra era) ⇒ TxAuxData (PreviousEra era) → TxAuxData era Source #

Every era, except Shelley, must be able to upgrade a TxAuxData from a previous era.

Warning - Important to note that any memoized binary representation will not be preserved. If you need to retain underlying bytes you can use translateEraThroughCBOR

hashTxAuxDataTxAuxData era → AuxiliaryDataHash (EraCrypto era) Source #

validateTxAuxDataProtVerTxAuxData era → Bool Source #

class (EraScript era, Eq (TxWits era), EqRaw (TxWits era), Show (TxWits era), Monoid (TxWits era), NoThunks (TxWits era), ToCBOR (TxWits era), EncCBOR (TxWits era), DecCBOR (Annotator (TxWits era))) ⇒ EraTxWits era where Source #

A collection of witnesses in a Tx

Associated Types

type TxWits era = (r ∷ Type) | r → era Source #

class (Era era, Show (Script era), Eq (Script era), EqRaw (Script era), ToCBOR (Script era), EncCBOR (Script era), DecCBOR (Annotator (Script era)), NoThunks (Script era), SafeToHash (Script era), Eq (NativeScript era), Show (NativeScript era), NFData (NativeScript era), NoThunks (NativeScript era), EncCBOR (NativeScript era), DecCBOR (Annotator (NativeScript era))) ⇒ EraScript era where Source #

Typeclass for script data types. Allows for script validation and hashing. You must understand the role of SafeToHash and scriptPrefixTag to make new instances. scriptPrefixTag is a magic number representing the tag of the script language. For each new script language defined, a new tag is chosen and the tag is included in the script hash for a script. The safeToHash constraint ensures that Scripts are never reserialised.

Associated Types

type Script era = (r ∷ Type) | r → era Source #

Scripts which may lock transaction outputs in this era

type NativeScript era = (r ∷ Type) | r → era Source #

Methods

upgradeScriptEraScript (PreviousEra era) ⇒ Script (PreviousEra era) → Script era Source #

Every era, except Shelley, must be able to upgrade a Script from a previous era.

Warning - Important to note that any memoized binary representation will not be preserved, you need to retain underlying bytes you can use translateEraThroughCBOR

scriptPrefixTagScript era → ByteString Source #

getNativeScriptScript era → Maybe (NativeScript era) Source #

fromNativeScriptNativeScript era → Script era Source #

hashScript ∷ ∀ era. EraScript era ⇒ Script era → ScriptHash (EraCrypto era) Source #

Compute ScriptHash of a Script for a particular era.

hashScriptTxWitsLEraTxWits era ⇒ Lens (TxWits era) (TxWits era) (Map (ScriptHash (EraCrypto era)) (Script era)) [Script era] Source #

This is a helper lens that will hash the scripts when adding as witnesses.

type family Value era ∷ Type Source #

A value is something which quantifies a transaction output.

class (Era era, Eq (PParamsHKD Identity era), Ord (PParamsHKD Identity era), Show (PParamsHKD Identity era), NFData (PParamsHKD Identity era), EncCBOR (PParamsHKD Identity era), DecCBOR (PParamsHKD Identity era), ToCBOR (PParamsHKD Identity era), FromCBOR (PParamsHKD Identity era), NoThunks (PParamsHKD Identity era), ToJSON (PParamsHKD Identity era), FromJSON (PParamsHKD Identity era), Eq (PParamsHKD StrictMaybe era), Ord (PParamsHKD StrictMaybe era), Show (PParamsHKD StrictMaybe era), NFData (PParamsHKD StrictMaybe era), EncCBOR (PParamsHKD StrictMaybe era), DecCBOR (PParamsHKD StrictMaybe era), ToCBOR (PParamsHKD StrictMaybe era), FromCBOR (PParamsHKD StrictMaybe era), NoThunks (PParamsHKD StrictMaybe era), ToJSON (PParamsHKD StrictMaybe era)) ⇒ EraPParams era where Source #

Associated Types

type PParamsHKD (f ∷ TypeType) era = (r ∷ Type) | r → era Source #

Protocol parameters where the fields are represented with a HKD

type UpgradePParams (f ∷ TypeType) era ∷ Type Source #

 

type DowngradePParams (f ∷ TypeType) era ∷ Type Source #

Methods

applyPPUpdatesPParams era → PParamsUpdate era → PParams era Source #

Applies a protocol parameters update

default applyPPUpdates ∷ ∀ a u. (Generic (PParamsHKD Identity era), Generic (PParamsHKD StrictMaybe era), Updatable (Rep (PParamsHKD Identity era) a) (Rep (PParamsHKD StrictMaybe era) u)) ⇒ PParams era → PParamsUpdate era → PParams era Source #

emptyPParamsIdentityPParamsHKD Identity era Source #

emptyPParamsStrictMaybePParamsHKD StrictMaybe era Source #

upgradePParamsHKD ∷ (HKDApplicative f, EraPParams (PreviousEra era)) ⇒ UpgradePParams f era → PParamsHKD f (PreviousEra era) → PParamsHKD f era Source #

Upgrade PParams from previous era to the current one

downgradePParamsHKD ∷ (HKDFunctor f, EraPParams (PreviousEra era)) ⇒ DowngradePParams f era → PParamsHKD f era → PParamsHKD f (PreviousEra era) Source #

Downgrade PParams from the current era to the previous one

hkdMinFeeALHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

The linear factor for the minimum fee calculation

hkdMinFeeBLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

The constant factor for the minimum fee calculation

hkdMaxBBSizeLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Word32) Source #

Maximal block body size

hkdMaxTxSizeLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Word32) Source #

Maximal transaction size

hkdMaxBHSizeLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Word16) Source #

Maximal block header size

hkdKeyDepositLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

The amount of a key registration deposit

hkdPoolDepositLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

The amount of a pool registration deposit

hkdEMaxLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f EpochInterval) Source #

epoch bound on pool retirement

hkdNOptLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Natural) Source #

Desired number of pools

hkdA0LHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f NonNegativeInterval) Source #

Pool influence

hkdRhoLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f UnitInterval) Source #

Monetary expansion

hkdTauLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f UnitInterval) Source #

Treasury expansion

hkdDL ∷ (HKDFunctor f, ProtVerAtMost era 6) ⇒ Lens' (PParamsHKD f era) (HKD f UnitInterval) Source #

Decentralization parameter

ppDGSimpleGetter (PParams era) UnitInterval Source #

Decentralization parameter getter

hkdExtraEntropyL ∷ (HKDFunctor f, ProtVerAtMost era 6) ⇒ Lens' (PParamsHKD f era) (HKD f Nonce) Source #

Extra entropy

hkdProtocolVersionL ∷ (HKDFunctor f, ProtVerAtMost era 8) ⇒ Lens' (PParamsHKD f era) (HKD f ProtVer) Source #

Protocol version

ppProtocolVersionLLens' (PParams era) ProtVer Source #

ppuProtocolVersionLProtVerAtMost era 8 ⇒ Lens' (PParamsUpdate era) (StrictMaybe ProtVer) Source #

PParamsUpdate Protocol version

hkdMinUTxOValueLHKDFunctor f ⇒ ProtVerAtMost era 4 ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

Minimum UTxO value

hkdMinPoolCostLHKDFunctor f ⇒ Lens' (PParamsHKD f era) (HKD f Coin) Source #

Minimum Stake Pool Cost

mkCoinTxOutEraTxOut era ⇒ Addr (EraCrypto era) → CoinTxOut era Source #

Era

  • Segregated Witness

The idea of segregated witnessing is to alter the encoding of transactions in a block such that the witnesses (the information needed to verify the validity of the transactions) can be stored separately from the body (the information needed to update the ledger state). In this way, a node which only cares about replaying transactions need not even decode the witness information.

In order to do this, we introduce two concepts: - A TxSeq, which represents the decoded structure of a sequence of transactions as represented in the encoded block; that is, with witnessing, metadata and other non-body parts split separately.

class (EraTx era, Eq (TxSeq era), Show (TxSeq era), EncCBORGroup (TxSeq era), DecCBOR (Annotator (TxSeq era))) ⇒ EraSegWits era where Source #

Indicates that an era supports segregated witnessing.

This class embodies an isomorphism between 'TxSeq era' and 'StrictSeq (Tx era)', witnessed by fromTxSeq and toTxSeq.

Associated Types

type TxSeq era = (r ∷ Type) | r → era Source #

Methods

fromTxSeqTxSeq era → StrictSeq (Tx era) Source #

toTxSeqStrictSeq (Tx era) → TxSeq era Source #

hashTxSeqTxSeq era → Hash (HASH (EraCrypto era)) EraIndependentBlockBody Source #

Get the block body hash from the TxSeq. Note that this is not a regular "hash the stored bytes" function since the block body hash forms a small Merkle tree.

numSegComponentsWord64 Source #

The number of segregated components

bBodySize ∷ ∀ era. EraSegWits era ⇒ ProtVerTxSeq era → Int Source #

Rewards

data RewardType Source #

The staking rewards in Cardano are all either:

  • member rewards - rewards given to a registered stake credential which has delegated to a stake pool, or
  • leader rewards - rewards given to a registered stake pool (in particular, given to the stake credential in the stake pool registration certificate).

See Figure 47, "Functions used in the Reward Splitting", of the formal specification for more details.

Constructors

MemberReward 
LeaderReward 

Instances

Instances details
ToJSON RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Bounded RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Enum RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Generic RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Associated Types

type Rep RewardTypeTypeType Source #

Show RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

DecCBOR RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

EncCBOR RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

encCBORRewardTypeEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy RewardTypeSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [RewardType] → Size Source #

NFData RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

rnfRewardType → () Source #

Eq RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Ord RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

NoThunks RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep RewardType Source # 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep RewardType = D1 ('MetaData "RewardType" "Cardano.Ledger.Rewards" "cardano-ledger-core-1.14.0.0-inplace" 'False) (C1 ('MetaCons "MemberReward" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "LeaderReward" 'PrefixI 'False) (U1TypeType))

data Reward c Source #

The Reward type captures:

  • if the reward is a member or leader reward
  • the stake pool ID associated with the reward
  • the number of Lovelace in the reward

Constructors

Reward 

Instances

Instances details
Crypto c ⇒ ToJSON (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Generic (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Associated Types

type Rep (Reward c) ∷ TypeType Source #

Methods

fromReward c → Rep (Reward c) x Source #

toRep (Reward c) x → Reward c Source #

Show (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

showsPrecIntReward c → ShowS Source #

showReward c → String Source #

showList ∷ [Reward c] → ShowS Source #

Crypto c ⇒ DecCBOR (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

decCBORDecoder s (Reward c) Source #

dropCBORProxy (Reward c) → Decoder s () Source #

labelProxy (Reward c) → Text Source #

Crypto c ⇒ EncCBOR (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

encCBORReward c → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (Reward c) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Reward c] → Size Source #

NFData (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

rnfReward c → () Source #

Eq (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

(==)Reward c → Reward c → Bool Source #

(/=)Reward c → Reward c → Bool Source #

Ord (Reward c) Source #

Note that this Ord instance is chosen to align precisely with the Allegra reward aggregation, as given by the function aggregateRewards so that findMax returns the expected value.

Instance details

Defined in Cardano.Ledger.Rewards

Methods

compareReward c → Reward c → Ordering Source #

(<)Reward c → Reward c → Bool Source #

(<=)Reward c → Reward c → Bool Source #

(>)Reward c → Reward c → Bool Source #

(>=)Reward c → Reward c → Bool Source #

maxReward c → Reward c → Reward c Source #

minReward c → Reward c → Reward c Source #

NoThunks (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep (Reward c) Source # 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep (Reward c) = D1 ('MetaData "Reward" "Cardano.Ledger.Rewards" "cardano-ledger-core-1.14.0.0-inplace" 'False) (C1 ('MetaCons "Reward" 'PrefixI 'True) (S1 ('MetaSel ('Just "rewardType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RewardType) :*: (S1 ('MetaSel ('Just "rewardPool") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool c)) :*: S1 ('MetaSel ('Just "rewardAmount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin))))

Re-exports

Deprecations

hashAuxiliaryDataEraTxAuxData era ⇒ TxAuxData era → AuxiliaryDataHash (EraCrypto era) Source #

Deprecated: Use hashTxAuxData instead

validateAuxiliaryDataEraTxAuxData era ⇒ ProtVerTxAuxData era → Bool Source #

Deprecated: Use validateTxAuxData instead