Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cardano.Ledger.Shelley.LedgerState
Description
This module implements the operation rules for treating UTxO transactions (Tx
)
as state transformations on a ledger state (LedgerState
),
as specified in A Simplified Formal Specification of a UTxO Ledger.
Synopsis
- newtype UTxO era = UTxO {}
- class CanGetUTxO (t ∷ Type → Type) where
- utxoG ∷ SimpleGetter (t era) (UTxO era)
- class CanGetUTxO t ⇒ CanSetUTxO (t ∷ Type → Type) where
- data AccountState = AccountState {
- asTreasury ∷ !Coin
- asReserves ∷ !Coin
- class (Era era, ToJSON (CertState era), EncCBOR (CertState era), DecShareCBOR (CertState era), Share (CertState era) ~ (Interns (Credential 'Staking), Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole), Interns (Credential 'HotCommitteeRole)), Default (CertState era), NoThunks (CertState era), NFData (CertState era), Show (CertState era), Eq (CertState era), Generic (CertState era)) ⇒ EraCertState era where
- type CertState era = (r ∷ Type) | r → era
- mkCertState ∷ VState era → PState era → DState era → CertState era
- upgradeCertState ∷ CertState (PreviousEra era) → CertState era
- certDStateL ∷ Lens' (CertState era) (DState era)
- certPStateL ∷ Lens' (CertState era) (PState era)
- certVStateL ∷ Lens' (CertState era) (VState era)
- obligationCertState ∷ CertState era → Obligations
- certsTotalDepositsTxBody ∷ PParams era → CertState era → TxBody era → Coin
- certsTotalRefundsTxBody ∷ PParams era → CertState era → TxBody era → Coin
- data DState era = DState {}
- data VState era = VState {
- vsDReps ∷ !(Map (Credential 'DRepRole) DRepState)
- vsCommitteeState ∷ !(CommitteeState era)
- vsNumDormantEpochs ∷ !EpochNo
- rewards ∷ DState era → UView (Credential 'Staking) RDPair
- delegations ∷ DState era → UView (Credential 'Staking) (KeyHash 'StakePool)
- ptrsMap ∷ DState era → Map Ptr (Credential 'Staking)
- data EpochState era = EpochState {
- esAccountState ∷ !AccountState
- esLState ∷ !(LedgerState era)
- esSnapshots ∷ !SnapShots
- esNonMyopic ∷ !NonMyopic
- data PulsingRewUpdate
- data FutureGenDeleg = FutureGenDeleg {}
- data InstantaneousRewards = InstantaneousRewards {
- iRReserves ∷ !(Map (Credential 'Staking) Coin)
- iRTreasury ∷ !(Map (Credential 'Staking) Coin)
- deltaReserves ∷ !DeltaCoin
- deltaTreasury ∷ !DeltaCoin
- data LedgerState era = LedgerState {
- lsUTxOState ∷ !(UTxOState era)
- lsCertState ∷ !(CertState era)
- data PState era = PState {
- psStakePoolParams ∷ !(Map (KeyHash 'StakePool) PoolParams)
- psFutureStakePoolParams ∷ !(Map (KeyHash 'StakePool) PoolParams)
- psRetiring ∷ !(Map (KeyHash 'StakePool) EpochNo)
- psDeposits ∷ !(Map (KeyHash 'StakePool) Coin)
- type RewardAccounts = Map (Credential 'Staking) Coin
- data RewardUpdate = RewardUpdate {}
- data RewardSnapShot = RewardSnapShot {
- rewFees ∷ !Coin
- rewProtocolVersion ∷ !ProtVer
- rewNonMyopic ∷ !NonMyopic
- rewDeltaR1 ∷ !Coin
- rewR ∷ !Coin
- rewDeltaT1 ∷ !Coin
- rewLikelihoods ∷ !(Map (KeyHash 'StakePool) Likelihood)
- rewLeaders ∷ !(Map (Credential 'Staking) (Set Reward))
- data UTxOState era = UTxOState {
- utxosUtxo ∷ !(UTxO era)
- utxosDeposited ∷ !Coin
- utxosFees ∷ !Coin
- utxosGovState ∷ !(GovState era)
- utxosStakeDistr ∷ !IncrementalStake
- utxosDonation ∷ !Coin
- smartUTxOState ∷ EraTxOut era ⇒ PParams era → UTxO era → Coin → Coin → GovState era → Coin → UTxOState era
- data IncrementalStake = IStake {
- credMap ∷ !(Map (Credential 'Staking) (CompactForm Coin))
- ptrMap ∷ !(Map Ptr (CompactForm Coin))
- genesisState ∷ ∀ era. (EraGov era, EraCertState era) ⇒ Map (KeyHash 'Genesis) GenDelegPair → UTxO era → LedgerState era
- consumed ∷ (EraUTxO era, EraCertState era) ⇒ PParams era → CertState era → UTxO era → TxBody era → Value era
- produced ∷ (EraUTxO era, EraCertState era) ⇒ PParams era → CertState era → TxBody era → Value era
- payPoolDeposit ∷ EraPParams era ⇒ KeyHash 'StakePool → PParams era → PState era → PState era
- refundPoolDeposit ∷ KeyHash 'StakePool → PState era → (Coin, PState era)
- totalObligation ∷ (EraGov era, EraCertState era) ⇒ CertState era → GovState era → Coin
- allObligations ∷ (EraGov era, EraCertState era) ⇒ CertState era → GovState era → Obligations
- incrementalStakeDistr ∷ ∀ era. EraPParams era ⇒ PParams era → IncrementalStake → DState era → PState era → SnapShot
- updateStakeDistribution ∷ EraTxOut era ⇒ PParams era → IncrementalStake → UTxO era → UTxO era → IncrementalStake
- applyRUpd ∷ (EraGov era, EraCertState era) ⇒ RewardUpdate → EpochState era → EpochState era
- applyRUpdFiltered ∷ (EraGov era, EraCertState era) ⇒ RewardUpdate → EpochState era → (EpochState era, FilteredRewards era)
- filterAllRewards ∷ (EraGov era, EraCertState era) ⇒ Map (Credential 'Staking) (Set Reward) → EpochState era → FilteredRewards era
- data FilteredRewards era = FilteredRewards {
- frRegistered ∷ !(Map (Credential 'Staking) (Set Reward))
- frShelleyIgnored ∷ Map (Credential 'Staking) (Set Reward)
- frUnregistered ∷ Set (Credential 'Staking)
- frTotalUnregistered ∷ Coin
- createRUpd ∷ ∀ era. (EraGov era, EraCertState era) ⇒ EpochSize → BlocksMade → EpochState era → Coin → ActiveSlotCoeff → NonZero Word64 → ShelleyBase RewardUpdate
- completeRupd ∷ PulsingRewUpdate → ShelleyBase (RewardUpdate, RewardEvent)
- startStep ∷ ∀ era. (EraGov era, EraCertState era) ⇒ EpochSize → BlocksMade → EpochState era → Coin → ActiveSlotCoeff → NonZero Word64 → PulsingRewUpdate
- pulseStep ∷ PulsingRewUpdate → ShelleyBase (PulsingRewUpdate, RewardEvent)
- completeStep ∷ PulsingRewUpdate → ShelleyBase (PulsingRewUpdate, RewardEvent)
- data NewEpochState era = NewEpochState !EpochNo !BlocksMade !BlocksMade !(EpochState era) !(StrictMaybe PulsingRewUpdate) !PoolDistr !(StashedAVVMAddresses era)
- type family StashedAVVMAddresses era where ...
- stashedAVVMAddresses ∷ NewEpochState era → StashedAVVMAddresses era
- getGKeys ∷ EraCertState era ⇒ NewEpochState era → Set (KeyHash 'Genesis)
- updateNES ∷ EraGov era ⇒ NewEpochState era → BlocksMade → LedgerState era → NewEpochState era
- circulation ∷ EpochState era → Coin → Coin
- decayFactor ∷ Float
- returnRedeemAddrsToReserves ∷ ∀ era. EraTxOut era ⇒ EpochState era → EpochState era
- updateNonMyopic ∷ NonMyopic → Coin → Map (KeyHash 'StakePool) Likelihood → NonMyopic
- emptyRewardUpdate ∷ RewardUpdate
- pvCanFollow ∷ ProtVer → ProtVer → Bool
- availableAfterMIR ∷ MIRPot → AccountState → InstantaneousRewards → Coin
- data ShelleyGovState era = ShelleyGovState {
- sgsCurProposals ∷ !(ProposedPPUpdates era)
- sgsFutureProposals ∷ !(ProposedPPUpdates era)
- sgsCurPParams ∷ !(PParams era)
- sgsPrevPParams ∷ !(PParams era)
- sgsFuturePParams ∷ !(FuturePParams era)
- nesPdL ∷ Lens' (NewEpochState era) PoolDistr
- nesEsL ∷ Lens' (NewEpochState era) (EpochState era)
- unifiedL ∷ EraCertState era ⇒ Lens' (NewEpochState era) UMap
- nesELL ∷ Lens' (NewEpochState era) EpochNo
- nesBprevL ∷ Lens' (NewEpochState era) (Map (KeyHash 'StakePool) Natural)
- nesBcurL ∷ Lens' (NewEpochState era) (Map (KeyHash 'StakePool) Natural)
- nesRuL ∷ Lens' (NewEpochState era) (StrictMaybe PulsingRewUpdate)
- nesStashedAVVMAddressesL ∷ Lens' (NewEpochState era) (StashedAVVMAddresses era)
- nesEpochStateL ∷ Lens' (NewEpochState era) (EpochState era)
- esAccountStateL ∷ Lens' (EpochState era) AccountState
- esSnapshotsL ∷ Lens' (EpochState era) SnapShots
- esLStateL ∷ Lens' (EpochState era) (LedgerState era)
- esNonMyopicL ∷ Lens' (EpochState era) NonMyopic
- curPParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (PParams era)
- prevPParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (PParams era)
- futurePParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (FuturePParams era)
- asTreasuryL ∷ Lens' AccountState Coin
- asReservesL ∷ Lens' AccountState Coin
- lsUTxOStateL ∷ Lens' (LedgerState era) (UTxOState era)
- lsCertStateL ∷ Lens' (LedgerState era) (CertState era)
- utxosUtxoL ∷ Lens' (UTxOState era) (UTxO era)
- utxosDepositedL ∷ Lens' (UTxOState era) Coin
- utxosFeesL ∷ Lens' (UTxOState era) Coin
- utxosGovStateL ∷ Lens' (UTxOState era) (GovState era)
- utxosStakeDistrL ∷ Lens' (UTxOState era) IncrementalStake
- utxosDonationL ∷ Lens' (UTxOState era) Coin
- epochStateGovStateL ∷ Lens' (EpochState era) (GovState era)
- epochStateStakeDistrL ∷ Lens' (EpochState era) (VMap VB VP (Credential 'Staking) (CompactForm Coin))
- epochStateUMapL ∷ EraCertState era ⇒ Lens' (EpochState era) UMap
- epochStatePoolParamsL ∷ EraCertState era ⇒ Lens' (EpochState era) (Map (KeyHash 'StakePool) PoolParams)
- epochStateRegDrepL ∷ EraCertState era ⇒ Lens' (EpochState era) (Map (Credential 'DRepRole) DRepState)
- epochStateIncrStakeDistrL ∷ Lens' (EpochState era) (Map (Credential 'Staking) (CompactForm Coin))
- epochStateDonationL ∷ Lens' (EpochState era) Coin
- newEpochStateGovStateL ∷ Lens' (NewEpochState era) (GovState era)
- epochStateTreasuryL ∷ Lens' (EpochState era) Coin
- dsUnifiedL ∷ Lens' (DState era) UMap
- dsGenDelegsL ∷ Lens' (DState era) GenDelegs
- dsIRewardsL ∷ Lens' (DState era) InstantaneousRewards
- dsFutureGenDelegsL ∷ Lens' (DState era) (Map FutureGenDeleg GenDelegPair)
- psStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) PoolParams)
- psFutureStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) PoolParams)
- psRetiringL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) EpochNo)
- psDepositsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) Coin)
- vsDRepsL ∷ Lens' (VState era) (Map (Credential 'DRepRole) DRepState)
- vsCommitteeStateL ∷ Lens' (VState era) (CommitteeState era)
- credMapL ∷ Lens' IncrementalStake (Map (Credential 'Staking) (CompactForm Coin))
- ptrMapL ∷ Lens' IncrementalStake (Map Ptr (CompactForm Coin))
- ssStakeMarkL ∷ Lens' SnapShots SnapShot
- ssStakeMarkPoolDistrL ∷ Lens' SnapShots PoolDistr
- ssStakeSetL ∷ Lens' SnapShots SnapShot
- ssStakeGoL ∷ Lens' SnapShots SnapShot
- ssFeeL ∷ Lens' SnapShots Coin
- ssStakeL ∷ Lens' SnapShot Stake
- ssStakeDistrL ∷ Lens' SnapShot (VMap VB VP (Credential 'Staking) (CompactForm Coin))
- ssDelegationsL ∷ Lens' SnapShot (VMap VB VB (Credential 'Staking) (KeyHash 'StakePool))
- ssPoolParamsL ∷ Lens' SnapShot (VMap VB VB (KeyHash 'StakePool) PoolParams)
UTxO
The unspent transaction outputs.
Instances
CanGetUTxO UTxO | |
Defined in Cardano.Ledger.State.UTxO | |
CanSetUTxO UTxO | |
ToJSON (TxOut era) ⇒ ToJSON (UTxO era) | |
Era era ⇒ Monoid (UTxO era) | |
Semigroup (UTxO era) | |
Generic (UTxO era) | |
Show (TxOut era) ⇒ Show (UTxO era) | |
(DecCBOR (TxOut era), Era era) ⇒ FromCBOR (UTxO era) | |
(EncCBOR (TxOut era), Era era) ⇒ ToCBOR (UTxO era) | |
(Era era, DecCBOR (TxOut era)) ⇒ DecCBOR (UTxO era) | |
(DecShareCBOR (TxOut era), Share (TxOut era) ~ Interns (Credential 'Staking)) ⇒ DecShareCBOR (UTxO era) | |
(Era era, EncCBOR (TxOut era)) ⇒ EncCBOR (UTxO era) | |
Default (UTxO era) | |
Defined in Cardano.Ledger.State.UTxO | |
(Era era, NFData (TxOut era)) ⇒ NFData (UTxO era) | |
Defined in Cardano.Ledger.State.UTxO | |
(Era era, Eq (TxOut era)) ⇒ Eq (UTxO era) | |
NoThunks (TxOut era) ⇒ NoThunks (UTxO era) | |
type Rep (UTxO era) | |
Defined in Cardano.Ledger.State.UTxO | |
type Share (UTxO era) | |
class CanGetUTxO (t ∷ Type → Type) where Source #
Minimal complete definition
Nothing
Methods
utxoG ∷ SimpleGetter (t era) (UTxO era) Source #
Instances
CanGetUTxO UTxO | |
Defined in Cardano.Ledger.State.UTxO | |
CanGetUTxO EpochState Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types Methods utxoG ∷ SimpleGetter (EpochState era) (UTxO era) Source # | |
CanGetUTxO LedgerState Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types Methods utxoG ∷ SimpleGetter (LedgerState era) (UTxO era) Source # | |
CanGetUTxO NewEpochState Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types Methods utxoG ∷ SimpleGetter (NewEpochState era) (UTxO era) Source # | |
CanGetUTxO UTxOState Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types |
class CanGetUTxO t ⇒ CanSetUTxO (t ∷ Type → Type) where Source #
Instances
Others to organize
data AccountState Source #
Constructors
AccountState | |
Fields
|
Instances
class (Era era, ToJSON (CertState era), EncCBOR (CertState era), DecShareCBOR (CertState era), Share (CertState era) ~ (Interns (Credential 'Staking), Interns (KeyHash 'StakePool), Interns (Credential 'DRepRole), Interns (Credential 'HotCommitteeRole)), Default (CertState era), NoThunks (CertState era), NFData (CertState era), Show (CertState era), Eq (CertState era), Generic (CertState era)) ⇒ EraCertState era where Source #
The state associated with the DELPL rule, which combines the DELEG rule and the POOL rule.
Methods
mkCertState ∷ VState era → PState era → DState era → CertState era Source #
upgradeCertState ∷ CertState (PreviousEra era) → CertState era Source #
certDStateL ∷ Lens' (CertState era) (DState era) Source #
certPStateL ∷ Lens' (CertState era) (PState era) Source #
certVStateL ∷ Lens' (CertState era) (VState era) Source #
obligationCertState ∷ CertState era → Obligations Source #
Calculate total possible refunds in the system that are related to certificates
There is an invariant that the sum of all the fields should be the same as the utxosDeposited field of the UTxOState. Note that this does not depend upon the current values of the Key and Pool deposits of the PParams.
certsTotalDepositsTxBody ∷ PParams era → CertState era → TxBody era → Coin Source #
Compute the total deposits from the Certs of a TxBody.
This is the contribution of a TxBody towards the deposit pot (utxosDeposit field of the UTxOState) of the system
certsTotalRefundsTxBody ∷ PParams era → CertState era → TxBody era → Coin Source #
Compute the total refunds from the Certs of a TxBody.
This is the contribution of a TxBody towards the total Obligations
of the system
See Obligations
and obligationCertState
for more information.
Instances
EraCertState ShelleyEra Source # | |
Defined in Cardano.Ledger.Shelley.CertState Associated Types type CertState ShelleyEra = (r ∷ Type) Source # Methods mkCertState ∷ VState ShelleyEra → PState ShelleyEra → DState ShelleyEra → CertState ShelleyEra Source # upgradeCertState ∷ CertState (PreviousEra ShelleyEra) → CertState ShelleyEra Source # certDStateL ∷ Lens' (CertState ShelleyEra) (DState ShelleyEra) Source # certPStateL ∷ Lens' (CertState ShelleyEra) (PState ShelleyEra) Source # certVStateL ∷ Lens' (CertState ShelleyEra) (VState ShelleyEra) Source # obligationCertState ∷ CertState ShelleyEra → Obligations Source # certsTotalDepositsTxBody ∷ PParams ShelleyEra → CertState ShelleyEra → TxBody ShelleyEra → Coin Source # certsTotalRefundsTxBody ∷ PParams ShelleyEra → CertState ShelleyEra → TxBody ShelleyEra → Coin Source # |
The state used by the DELEG rule, which roughly tracks stake delegation and some governance features.
Constructors
DState | |
Fields
|
Instances
ToJSON (DState era) | |
Generic (DState era) | |
Show (DState era) | |
DecShareCBOR (DState era) | |
Era era ⇒ EncCBOR (DState era) | |
Default (DState era) | |
Defined in Cardano.Ledger.CertState | |
NFData (DState era) | |
Defined in Cardano.Ledger.CertState | |
Eq (DState era) | |
NoThunks (DState era) | |
type Rep (DState era) | |
Defined in Cardano.Ledger.CertState type Rep (DState era) = D1 ('MetaData "DState" "Cardano.Ledger.CertState" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "DState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dsUnified") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 UMap) :*: S1 ('MetaSel ('Just "dsFutureGenDelegs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map FutureGenDeleg GenDelegPair))) :*: (S1 ('MetaSel ('Just "dsGenDelegs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 GenDelegs) :*: S1 ('MetaSel ('Just "dsIRewards") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 InstantaneousRewards)))) | |
type Share (DState era) | |
The state that tracks the voting entities (DReps and Constitutional Committee
members). In the formal ledger specification this type is called GState
Constructors
VState | |
Fields
|
Instances
ToJSON (VState era) | |
Generic (VState era) | |
Show (VState era) | |
Era era ⇒ DecCBOR (VState era) | |
Era era ⇒ DecShareCBOR (VState era) | |
Era era ⇒ EncCBOR (VState era) | |
Default (VState era) | |
Defined in Cardano.Ledger.CertState | |
NFData (VState era) | |
Defined in Cardano.Ledger.CertState | |
Eq (VState era) | |
NoThunks (VState era) | |
type Rep (VState era) | |
Defined in Cardano.Ledger.CertState type Rep (VState era) = D1 ('MetaData "VState" "Cardano.Ledger.CertState" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "VState" 'PrefixI 'True) (S1 ('MetaSel ('Just "vsDReps") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (Credential 'DRepRole) DRepState)) :*: (S1 ('MetaSel ('Just "vsCommitteeState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (CommitteeState era)) :*: S1 ('MetaSel ('Just "vsNumDormantEpochs") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 EpochNo)))) | |
type Share (VState era) | |
delegations ∷ DState era → UView (Credential 'Staking) (KeyHash 'StakePool) Source #
ptrsMap ∷ DState era → Map Ptr (Credential 'Staking) Source #
get the actual ptrs map, we don't need a view
data EpochState era Source #
Constructors
EpochState | |
Fields
|
Instances
data PulsingRewUpdate Source #
The state used in the STS rules
Constructors
Pulsing !RewardSnapShot !Pulser | |
Complete !RewardUpdate |
Instances
data FutureGenDeleg Source #
Constructors
FutureGenDeleg | |
Fields
|
Instances
data InstantaneousRewards Source #
InstantaneousRewards captures the pending changes to the ledger state caused by MIR certificates. It consists of two mappings, the rewards which will be paid out from the reserves and the rewards which will be paid out from the treasury. It also consists of two coin values which represent the transfer of coins from one pot to the other pot. NOTE that the following property should always hold: deltaReserves + deltaTreasury = 0
Constructors
InstantaneousRewards | |
Fields
|
Instances
data LedgerState era Source #
The state associated with a Ledger
.
Constructors
LedgerState | |
Fields
|
Instances
The state used by the POOL rule, which tracks stake pool information.
Constructors
PState | |
Fields
|
Instances
ToJSON (PState era) | |
Generic (PState era) | |
Show (PState era) | |
(Era era, DecShareCBOR (PState era)) ⇒ DecCBOR (PState era) | |
DecShareCBOR (PState era) | |
Era era ⇒ EncCBOR (PState era) | |
Default (PState era) | |
Defined in Cardano.Ledger.CertState | |
NFData (PState era) | |
Defined in Cardano.Ledger.CertState | |
Eq (PState era) | |
NoThunks (PState era) | |
type Rep (PState era) | |
Defined in Cardano.Ledger.CertState type Rep (PState era) = D1 ('MetaData "PState" "Cardano.Ledger.CertState" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "PState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "psStakePoolParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool) PoolParams)) :*: S1 ('MetaSel ('Just "psFutureStakePoolParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool) PoolParams))) :*: (S1 ('MetaSel ('Just "psRetiring") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool) EpochNo)) :*: S1 ('MetaSel ('Just "psDeposits") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool) Coin))))) | |
type Share (PState era) | |
type RewardAccounts = Map (Credential 'Staking) Coin Source #
Deprecated: In favor of Map
(Credential
Staking
) Coin
data RewardUpdate Source #
The ultimate goal of a reward update computation. Aggregating rewards for each staking credential.
Constructors
RewardUpdate | |
Instances
data RewardSnapShot Source #
To complete the reward update, we need a snap shot of the EpochState particular to this computation
Constructors
RewardSnapShot | |
Fields
|
Instances
There is a serious invariant that we must maintain in the UTxOState. Given (UTxOState utxo _ _ _ istake) it must be the case that istake == (updateStakeDistribution (UTxO Map.empty) (UTxO Map.empty) utxo) Of course computing the RHS of the above equality can be very expensive, so we only use this route in the testing function smartUTxO. But we are very careful, wherever we update the UTxO, we carefully make INCREMENTAL changes to istake to maintain this invariant. This happens in the UTxO rule.
Constructors
UTxOState | |
Fields
|
Instances
CanGetUTxO UTxOState Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types | |
CanSetUTxO UTxOState Source # | |
(EraTxOut era, EraGov era) ⇒ ToJSON (UTxOState era) Source # | |
Generic (UTxOState era) Source # | |
(EraTxOut era, Show (GovState era)) ⇒ Show (UTxOState era) Source # | |
(EraTxOut era, EraGov era) ⇒ FromCBOR (UTxOState era) Source # | |
(EraTxOut era, EraGov era) ⇒ ToCBOR (UTxOState era) Source # | |
(EraTxOut era, EraGov era) ⇒ DecShareCBOR (UTxOState era) Source # | |
(EraTxOut era, EncCBOR (GovState era)) ⇒ EncCBOR (UTxOState era) Source # | |
EraGov era ⇒ Default (UTxOState era) Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types | |
(EraTxOut era, NFData (GovState era)) ⇒ NFData (UTxOState era) Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types | |
(EraTxOut era, Eq (GovState era)) ⇒ Eq (UTxOState era) Source # | |
(NoThunks (UTxO era), NoThunks (GovState era)) ⇒ NoThunks (UTxOState era) Source # | |
type Rep (UTxOState era) Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.Types type Rep (UTxOState era) = D1 ('MetaData "UTxOState" "Cardano.Ledger.Shelley.LedgerState.Types" "cardano-ledger-shelley-1.16.0.0-inplace" 'False) (C1 ('MetaCons "UTxOState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "utxosUtxo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (UTxO era)) :*: (S1 ('MetaSel ('Just "utxosDeposited") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin) :*: S1 ('MetaSel ('Just "utxosFees") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin))) :*: (S1 ('MetaSel ('Just "utxosGovState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (GovState era)) :*: (S1 ('MetaSel ('Just "utxosStakeDistr") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IncrementalStake) :*: S1 ('MetaSel ('Just "utxosDonation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin))))) | |
type Share (UTxOState era) Source # | |
smartUTxOState ∷ EraTxOut era ⇒ PParams era → UTxO era → Coin → Coin → GovState era → Coin → UTxOState era Source #
A valid (or self-consistent) UTxOState{utxosUtxo, utxosDeposited , utxosFees , utxosPpups , utxosStakeDistr} maintains an invariant between the utxosUtxo and utxosStakeDistr fields. the utxosStakeDistr field is the aggregation of Coin over the StakeReferences in the UTxO. It can be computed by a pure function from the _utxo field. In some situations, mostly unit or example tests, or when initializing a small UTxO, we want to create a UTxOState that computes the utxosStakeDistr from the utxosUtxo. This is aways safe to do, but if the utxosUtxo field is big, this can be very expensive, which defeats the purpose of memoizing the utxosStakeDistr field. So use of this function should be restricted to tests and initializations, where the invariant should be maintained.
TO IncrementalStake
data IncrementalStake Source #
Incremental Stake, Stake along with possible missed coins from danging Ptrs.
Transactions can use Ptrs to refer to a stake credential in a TxOut. The Ptr
does not have to point to anything until the epoch boundary, when we compute
rewards and aggregate staking information for ranking. This is unusual but legal.
In a non incremental system, we use whatever legal
Ptrs exist at the epoch
boundary. Here we are computing things incrementally, so we need to remember Ptrs
that might point to something by the time the epoch boundary is reached. When
the epoch boundary is reached we resolve
these pointers, to see if any have
become non-dangling since the time they were first used in the incremental computation.
Constructors
IStake | |
Fields
|
Instances
Genesis State
genesisState ∷ ∀ era. (EraGov era, EraCertState era) ⇒ Map (KeyHash 'Genesis) GenDelegPair → UTxO era → LedgerState era Source #
Creates the ledger state for an empty ledger which contains the specified transaction outputs.
Validation
consumed ∷ (EraUTxO era, EraCertState era) ⇒ PParams era → CertState era → UTxO era → TxBody era → Value era Source #
For eras before Conway, VState is expected to have an empty Map for vsDReps, and so deposit summed up is zero.
produced ∷ (EraUTxO era, EraCertState era) ⇒ PParams era → CertState era → TxBody era → Value era Source #
Compute the lovelace which are created by the transaction For eras before Conway, VState is expected to have an empty Map for vsDReps, and so deposit summed up is zero.
DelegationState
payPoolDeposit ∷ EraPParams era ⇒ KeyHash 'StakePool → PParams era → PState era → PState era Source #
One only pays a deposit on the initial pool registration. So return the the Deposits unchanged if the keyhash already exists. There are legal situations where a pool may be registered multiple times.
totalObligation ∷ (EraGov era, EraCertState era) ⇒ CertState era → GovState era → Coin Source #
allObligations ∷ (EraGov era, EraCertState era) ⇒ CertState era → GovState era → Obligations Source #
Epoch boundary
incrementalStakeDistr ∷ ∀ era. EraPParams era ⇒ PParams era → IncrementalStake → DState era → PState era → SnapShot Source #
This computes a Snapshot using IncrementalStake (which is an aggregate of the current UTxO) and UMap (which tracks Coin, SPoolUView, and Ptrs simultaneously). Note that logically: 1) IncrementalStake = (credStake, ptrStake) 2) UMap = (rewards, activeDelegs, ptrmap :: Map ptr cred)
Using this scheme the logic can do 3 things in one go, without touching the UTxO. 1) Resolve Pointers 2) Throw away things not actively delegated 3) Add up the coin
The Stake distribution function (Map cred coin) (the first component of a SnapShot) is defined by this SetAlgebra expression: (dom activeDelegs) ◁ (aggregate+ (credStake ∪ ptrStake ∪ rewards))
We can apply meaning preserving operations to get equivalent expressions
(dom activeDelegs) ◁ (aggregate+ (credStake ∪ ptrStake ∪ rewards)) aggregate+ (dom activeDelegs ◁ (credStake ∪ ptrStake ∪ rewards)) aggregate+ ((dom activeDelegs ◁ credStake) ∪ (dom activeDelegs ◁ ptrStake) ∪ (dom activeDelegs ◁ rewards))
We will compute this in several steps
step1 = (dom activeDelegs ◁ credStake) ∪ (dom activeDelegs ◁ ptrStake)
step2 = aggregate (dom activeDelegs ◁ rewards) step1
This function has a non-incremental analog, stakeDistr
, mosty used in tests, which does use the UTxO.
updateStakeDistribution ∷ EraTxOut era ⇒ PParams era → IncrementalStake → UTxO era → UTxO era → IncrementalStake Source #
Incrementally add the inserts utxoAdd
and the deletes utxoDel
to the IncrementalStake.
applyRUpd ∷ (EraGov era, EraCertState era) ⇒ RewardUpdate → EpochState era → EpochState era Source #
Apply a RewardUpdate to the EpochState. Does several things 1) Adds reward coins to Rewards component of the UMap field of the DState, for actively delegated Stake 2) Adds to the Treasury of the AccountState for non-actively delegated stake 3) Adds fees to the UTxOState
applyRUpdFiltered ∷ (EraGov era, EraCertState era) ⇒ RewardUpdate → EpochState era → (EpochState era, FilteredRewards era) Source #
filterAllRewards ∷ (EraGov era, EraCertState era) ⇒ Map (Credential 'Staking) (Set Reward) → EpochState era → FilteredRewards era Source #
data FilteredRewards era Source #
Constructors
FilteredRewards | |
Fields
|
Instances
NFData (FilteredRewards era) Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.IncrementalStake Methods rnf ∷ FilteredRewards era → () # |
createRUpd ∷ ∀ era. (EraGov era, EraCertState era) ⇒ EpochSize → BlocksMade → EpochState era → Coin → ActiveSlotCoeff → NonZero Word64 → ShelleyBase RewardUpdate Source #
To create a reward update, run all 3 phases This function is not used in the rules, so it ignores RewardEvents
completeRupd ∷ PulsingRewUpdate → ShelleyBase (RewardUpdate, RewardEvent) Source #
Phase 3 of reward update has several parts a) completeM the pulser (in case there are still computions to run) b) Combine the pulser provenance with the RewardProvenance c) Construct the final RewardUpdate d) Add the leader rewards to both the events and the computed Rewards
startStep ∷ ∀ era. (EraGov era, EraCertState era) ⇒ EpochSize → BlocksMade → EpochState era → Coin → ActiveSlotCoeff → NonZero Word64 → PulsingRewUpdate Source #
pulseStep ∷ PulsingRewUpdate → ShelleyBase (PulsingRewUpdate, RewardEvent) Source #
Run the pulser for a bit. If is has nothing left to do, complete it.
data NewEpochState era Source #
New Epoch state and environment
Constructors
NewEpochState !EpochNo !BlocksMade !BlocksMade !(EpochState era) !(StrictMaybe PulsingRewUpdate) !PoolDistr !(StashedAVVMAddresses era) |
Instances
type family StashedAVVMAddresses era where ... Source #
Equations
StashedAVVMAddresses ShelleyEra = UTxO ShelleyEra | |
StashedAVVMAddresses _ = () |
stashedAVVMAddresses ∷ NewEpochState era → StashedAVVMAddresses era Source #
AVVM addresses to be removed at the end of the Shelley era. Note that the existence of this field is a hack, related to the transition of UTxO to disk. We remove AVVM addresses from the UTxO on the Shelley/Allegra boundary. However, by this point the UTxO will be moved to disk, and hence doing a scan of the UTxO for AVVM addresses will be expensive. Our solution to this is to do a scan of the UTxO on the Byron/Shelley boundary (since Byron UTxO are still on disk), stash the results here, and then remove them at the Shelley/Allegra boundary.
This is very much an awkward implementation hack, and hence we hide it from as many places as possible.
getGKeys ∷ EraCertState era ⇒ NewEpochState era → Set (KeyHash 'Genesis) Source #
updateNES ∷ EraGov era ⇒ NewEpochState era → BlocksMade → LedgerState era → NewEpochState era Source #
Update new epoch state
circulation ∷ EpochState era → Coin → Coin Source #
Calculate the current circulation
This is used in the rewards calculation, and for API endpoints for pool ranking.
Decay
Remove Bootstrap Redeem Addresses
returnRedeemAddrsToReserves ∷ ∀ era. EraTxOut era ⇒ EpochState era → EpochState era Source #
updateNonMyopic ∷ NonMyopic → Coin → Map (KeyHash 'StakePool) Likelihood → NonMyopic Source #
Check whether the new protocol version is a legitimate version bump with respect to the previous one.
availableAfterMIR ∷ MIRPot → AccountState → InstantaneousRewards → Coin Source #
This function returns the coin balance of a given pot, either the reserves or the treasury, after the instantaneous rewards and pot transfers are accounted for.
data ShelleyGovState era Source #
Constructors
ShelleyGovState | |
Fields
|
Instances
Lenses from Types
nesEsL ∷ Lens' (NewEpochState era) (EpochState era) Source #
unifiedL ∷ EraCertState era ⇒ Lens' (NewEpochState era) UMap Source #
nesRuL ∷ Lens' (NewEpochState era) (StrictMaybe PulsingRewUpdate) Source #
nesStashedAVVMAddressesL ∷ Lens' (NewEpochState era) (StashedAVVMAddresses era) Source #
nesEpochStateL ∷ Lens' (NewEpochState era) (EpochState era) Source #
esAccountStateL ∷ Lens' (EpochState era) AccountState Source #
esSnapshotsL ∷ Lens' (EpochState era) SnapShots Source #
esLStateL ∷ Lens' (EpochState era) (LedgerState era) Source #
esNonMyopicL ∷ Lens' (EpochState era) NonMyopic Source #
curPParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (PParams era) Source #
prevPParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (PParams era) Source #
futurePParamsEpochStateL ∷ EraGov era ⇒ Lens' (EpochState era) (FuturePParams era) Source #
lsUTxOStateL ∷ Lens' (LedgerState era) (UTxOState era) Source #
lsCertStateL ∷ Lens' (LedgerState era) (CertState era) Source #
epochStateGovStateL ∷ Lens' (EpochState era) (GovState era) Source #
epochStateStakeDistrL ∷ Lens' (EpochState era) (VMap VB VP (Credential 'Staking) (CompactForm Coin)) Source #
epochStateUMapL ∷ EraCertState era ⇒ Lens' (EpochState era) UMap Source #
epochStatePoolParamsL ∷ EraCertState era ⇒ Lens' (EpochState era) (Map (KeyHash 'StakePool) PoolParams) Source #
epochStateRegDrepL ∷ EraCertState era ⇒ Lens' (EpochState era) (Map (Credential 'DRepRole) DRepState) Source #
epochStateIncrStakeDistrL ∷ Lens' (EpochState era) (Map (Credential 'Staking) (CompactForm Coin)) Source #
epochStateDonationL ∷ Lens' (EpochState era) Coin Source #
newEpochStateGovStateL ∷ Lens' (NewEpochState era) (GovState era) Source #
epochStateTreasuryL ∷ Lens' (EpochState era) Coin Source #
Lenses from CertState
dsIRewardsL ∷ Lens' (DState era) InstantaneousRewards Source #
dsFutureGenDelegsL ∷ Lens' (DState era) (Map FutureGenDeleg GenDelegPair) Source #
psStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) PoolParams) Source #
psFutureStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool) PoolParams) Source #
vsCommitteeStateL ∷ Lens' (VState era) (CommitteeState era) Source #
credMapL ∷ Lens' IncrementalStake (Map (Credential 'Staking) (CompactForm Coin)) Source #
ptrMapL ∷ Lens' IncrementalStake (Map Ptr (CompactForm Coin)) Source #
Lenses from SnapShot(s)
ssStakeDistrL ∷ Lens' SnapShot (VMap VB VP (Credential 'Staking) (CompactForm Coin)) Source #