Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data AccountState = AccountState {
- asTreasury ∷ !Coin
- asReserves ∷ !Coin
- data CertState era = CertState {
- certVState ∷ !(VState era)
- certPState ∷ !(PState era)
- certDState ∷ !(DState era)
- data DState era = DState {
- dsUnified ∷ !(UMap (EraCrypto era))
- dsFutureGenDelegs ∷ !(Map (FutureGenDeleg (EraCrypto era)) (GenDelegPair (EraCrypto era)))
- dsGenDelegs ∷ !(GenDelegs (EraCrypto era))
- dsIRewards ∷ !(InstantaneousRewards (EraCrypto era))
- data VState era = VState {
- vsDReps ∷ !(Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era)))
- vsCommitteeState ∷ !(CommitteeState era)
- vsNumDormantEpochs ∷ !EpochNo
- rewards ∷ DState era → UView (EraCrypto era) (Credential 'Staking (EraCrypto era)) RDPair
- delegations ∷ DState era → UView (EraCrypto era) (Credential 'Staking (EraCrypto era)) (KeyHash 'StakePool (EraCrypto era))
- ptrsMap ∷ DState era → Map Ptr (Credential 'Staking (EraCrypto era))
- data EpochState era = EpochState {
- esAccountState ∷ !AccountState
- esLState ∷ !(LedgerState era)
- esSnapshots ∷ !(SnapShots (EraCrypto era))
- esNonMyopic ∷ !(NonMyopic (EraCrypto era))
- data PulsingRewUpdate c
- = Pulsing !(RewardSnapShot c) !(Pulser c)
- | Complete !(RewardUpdate c)
- data FutureGenDeleg c = FutureGenDeleg {
- fGenDelegSlot ∷ !SlotNo
- fGenDelegGenKeyHash ∷ !(KeyHash 'Genesis c)
- data InstantaneousRewards c = InstantaneousRewards {
- iRReserves ∷ !(Map (Credential 'Staking c) Coin)
- iRTreasury ∷ !(Map (Credential 'Staking c) Coin)
- deltaReserves ∷ !DeltaCoin
- deltaTreasury ∷ !DeltaCoin
- data LedgerState era = LedgerState {
- lsUTxOState ∷ !(UTxOState era)
- lsCertState ∷ !(CertState era)
- data PState era = PState {
- psStakePoolParams ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- psFutureStakePoolParams ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- psRetiring ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) EpochNo)
- psDeposits ∷ !(Map (KeyHash 'StakePool (EraCrypto era)) Coin)
- type RewardAccounts c = Map (Credential 'Staking c) Coin
- data RewardUpdate c = RewardUpdate {}
- data RewardSnapShot c = RewardSnapShot {
- rewFees ∷ !Coin
- rewProtocolVersion ∷ !ProtVer
- rewNonMyopic ∷ !(NonMyopic c)
- rewDeltaR1 ∷ !Coin
- rewR ∷ !Coin
- rewDeltaT1 ∷ !Coin
- rewLikelihoods ∷ !(Map (KeyHash 'StakePool c) Likelihood)
- rewLeaders ∷ !(Map (Credential 'Staking c) (Set (Reward c)))
- data UTxOState era = UTxOState {
- utxosUtxo ∷ !(UTxO era)
- utxosDeposited ∷ Coin
- utxosFees ∷ !Coin
- utxosGovState ∷ !(GovState era)
- utxosStakeDistr ∷ !(IncrementalStake (EraCrypto era))
- utxosDonation ∷ !Coin
- smartUTxOState ∷ EraTxOut era ⇒ PParams era → UTxO era → Coin → Coin → GovState era → Coin → UTxOState era
- data IncrementalStake c = IStake {
- credMap ∷ !(Map (Credential 'Staking c) (CompactForm Coin))
- ptrMap ∷ !(Map Ptr (CompactForm Coin))
- genesisState ∷ ∀ era. EraGov era ⇒ Map (KeyHash 'Genesis (EraCrypto era)) (GenDelegPair (EraCrypto era)) → UTxO era → LedgerState era
- consumed ∷ EraUTxO era ⇒ PParams era → CertState era → UTxO era → TxBody era → Value era
- produced ∷ EraUTxO era ⇒ PParams era → CertState era → TxBody era → Value era
- payPoolDeposit ∷ EraPParams era ⇒ KeyHash 'StakePool (EraCrypto era) → PParams era → PState era → PState era
- refundPoolDeposit ∷ KeyHash 'StakePool (EraCrypto era) → PState era → (Coin, PState era)
- totalObligation ∷ EraGov era ⇒ CertState era → GovState era → Coin
- allObligations ∷ EraGov era ⇒ CertState era → GovState era → Obligations
- incrementalStakeDistr ∷ ∀ era. EraPParams era ⇒ PParams era → IncrementalStake (EraCrypto era) → DState era → PState era → SnapShot (EraCrypto era)
- updateStakeDistribution ∷ EraTxOut era ⇒ PParams era → IncrementalStake (EraCrypto era) → UTxO era → UTxO era → IncrementalStake (EraCrypto era)
- applyRUpd ∷ EraGov era ⇒ RewardUpdate (EraCrypto era) → EpochState era → EpochState era
- applyRUpdFiltered ∷ EraGov era ⇒ RewardUpdate (EraCrypto era) → EpochState era → (EpochState era, FilteredRewards era)
- filterAllRewards ∷ EraGov era ⇒ Map (Credential 'Staking (EraCrypto era)) (Set (Reward (EraCrypto era))) → EpochState era → FilteredRewards era
- data FilteredRewards era = FilteredRewards {
- frRegistered ∷ !(Map (Credential 'Staking (EraCrypto era)) (Set (Reward (EraCrypto era))))
- frShelleyIgnored ∷ Map (Credential 'Staking (EraCrypto era)) (Set (Reward (EraCrypto era)))
- frUnregistered ∷ Set (Credential 'Staking (EraCrypto era))
- frTotalUnregistered ∷ Coin
- createRUpd ∷ ∀ era. EraGov era ⇒ EpochSize → BlocksMade (EraCrypto era) → EpochState era → Coin → ActiveSlotCoeff → Word64 → ShelleyBase (RewardUpdate (EraCrypto era))
- completeRupd ∷ PulsingRewUpdate c → ShelleyBase (RewardUpdate c, RewardEvent c)
- startStep ∷ ∀ era. EraGov era ⇒ EpochSize → BlocksMade (EraCrypto era) → EpochState era → Coin → ActiveSlotCoeff → Word64 → PulsingRewUpdate (EraCrypto era)
- pulseStep ∷ PulsingRewUpdate c → ShelleyBase (PulsingRewUpdate c, RewardEvent c)
- completeStep ∷ PulsingRewUpdate c → ShelleyBase (PulsingRewUpdate c, RewardEvent c)
- data NewEpochState era = NewEpochState !EpochNo !(BlocksMade (EraCrypto era)) !(BlocksMade (EraCrypto era)) !(EpochState era) !(StrictMaybe (PulsingRewUpdate (EraCrypto era))) !(PoolDistr (EraCrypto era)) !(StashedAVVMAddresses era)
- type family StashedAVVMAddresses era where ...
- stashedAVVMAddresses ∷ NewEpochState era → StashedAVVMAddresses era
- getGKeys ∷ NewEpochState era → Set (KeyHash 'Genesis (EraCrypto era))
- updateNES ∷ EraGov era ⇒ NewEpochState era → BlocksMade (EraCrypto era) → LedgerState era → NewEpochState era
- circulation ∷ EpochState era → Coin → Coin
- decayFactor ∷ Float
- returnRedeemAddrsToReserves ∷ ∀ era. EraTxOut era ⇒ EpochState era → EpochState era
- updateNonMyopic ∷ NonMyopic c → Coin → Map (KeyHash 'StakePool c) Likelihood → NonMyopic c
- emptyRewardUpdate ∷ RewardUpdate c
- pvCanFollow ∷ ProtVer → ProtVer → Bool
- availableAfterMIR ∷ MIRPot → AccountState → InstantaneousRewards c → 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 (EraCrypto era))
- nesEsL ∷ Lens' (NewEpochState era) (EpochState era)
- unifiedL ∷ Lens' (NewEpochState era) (UMap (EraCrypto era))
- nesELL ∷ Lens' (NewEpochState era) EpochNo
- nesBprevL ∷ Lens' (NewEpochState era) (Map (KeyHash 'StakePool (EraCrypto era)) Natural)
- nesBcurL ∷ Lens' (NewEpochState era) (Map (KeyHash 'StakePool (EraCrypto era)) Natural)
- nesRuL ∷ Lens' (NewEpochState era) (StrictMaybe (PulsingRewUpdate (EraCrypto era)))
- nesStashedAVVMAddressesL ∷ Lens' (NewEpochState era) (StashedAVVMAddresses era)
- nesEpochStateL ∷ Lens' (NewEpochState era) (EpochState era)
- esAccountStateL ∷ Lens' (EpochState era) AccountState
- esSnapshotsL ∷ Lens' (EpochState era) (SnapShots (EraCrypto era))
- esLStateL ∷ Lens' (EpochState era) (LedgerState era)
- esNonMyopicL ∷ Lens' (EpochState era) (NonMyopic (EraCrypto era))
- 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 (EraCrypto era))
- utxosDonationL ∷ Lens' (UTxOState era) Coin
- epochStateGovStateL ∷ Lens' (EpochState era) (GovState era)
- epochStateStakeDistrL ∷ Lens' (EpochState era) (VMap VB VP (Credential 'Staking (EraCrypto era)) (CompactForm Coin))
- epochStateUMapL ∷ Lens' (EpochState era) (UMap (EraCrypto era))
- epochStatePoolParamsL ∷ Lens' (EpochState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- epochStateRegDrepL ∷ Lens' (EpochState era) (Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era)))
- epochStateIncrStakeDistrL ∷ Lens' (EpochState era) (Map (Credential 'Staking (EraCrypto era)) (CompactForm Coin))
- epochStateDonationL ∷ Lens' (EpochState era) Coin
- newEpochStateGovStateL ∷ Lens' (NewEpochState era) (GovState era)
- epochStateTreasuryL ∷ Lens' (EpochState era) Coin
- certDStateL ∷ Lens' (CertState era) (DState era)
- certPStateL ∷ Lens' (CertState era) (PState era)
- certVStateL ∷ Lens' (CertState era) (VState era)
- dsUnifiedL ∷ Lens' (DState era) (UMap (EraCrypto era))
- dsGenDelegsL ∷ Lens' (DState era) (GenDelegs (EraCrypto era))
- dsIRewardsL ∷ Lens' (DState era) (InstantaneousRewards (EraCrypto era))
- dsFutureGenDelegsL ∷ Lens' (DState era) (Map (FutureGenDeleg (EraCrypto era)) (GenDelegPair (EraCrypto era)))
- psStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- psFutureStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)))
- psRetiringL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) EpochNo)
- psDepositsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) Coin)
- vsDRepsL ∷ Lens' (VState era) (Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era)))
- vsCommitteeStateL ∷ Lens' (VState era) (CommitteeState era)
- credMapL ∷ Lens' (IncrementalStake c) (Map (Credential 'Staking c) (CompactForm Coin))
- ptrMapL ∷ Lens' (IncrementalStake c) (Map Ptr (CompactForm Coin))
- ssStakeMarkL ∷ Lens' (SnapShots c) (SnapShot c)
- ssStakeMarkPoolDistrL ∷ Lens' (SnapShots c) (PoolDistr c)
- ssStakeSetL ∷ Lens' (SnapShots c) (SnapShot c)
- ssStakeGoL ∷ Lens' (SnapShots c) (SnapShot c)
- ssFeeL ∷ Lens' (SnapShots c) Coin
- ssStakeL ∷ Lens' (SnapShot c) (Stake c)
- ssStakeDistrL ∷ Lens' (SnapShot c) (VMap VB VP (Credential 'Staking c) (CompactForm Coin))
- ssDelegationsL ∷ Lens' (SnapShot c) (VMap VB VB (Credential 'Staking c) (KeyHash 'StakePool c))
- ssPoolParamsL ∷ Lens' (SnapShot c) (VMap VB VB (KeyHash 'StakePool c) (PoolParams c))
Documentation
data AccountState Source #
AccountState | |
|
Instances
The state associated with the DELPL rule, which combines the DELEG rule and the POOL rule.
CertState | |
|
Instances
Era era ⇒ ToJSON (CertState era) | |
Generic (CertState era) | |
Show (CertState era) | |
Era era ⇒ DecShareCBOR (CertState era) | |
Era era ⇒ EncCBOR (CertState era) | |
Default (CertState era) | |
Defined in Cardano.Ledger.CertState | |
Era era ⇒ NFData (CertState era) | |
Defined in Cardano.Ledger.CertState | |
Eq (CertState era) | |
Typeable (EraCrypto era) ⇒ NoThunks (CertState era) | |
type Rep (CertState era) | |
Defined in Cardano.Ledger.CertState type Rep (CertState era) = D1 ('MetaData "CertState" "Cardano.Ledger.CertState" "cardano-ledger-core-1.16.0.0-inplace" 'False) (C1 ('MetaCons "CertState" 'PrefixI 'True) (S1 ('MetaSel ('Just "certVState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VState era)) :*: (S1 ('MetaSel ('Just "certPState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PState era)) :*: S1 ('MetaSel ('Just "certDState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (DState era))))) | |
type Share (CertState era) | |
The state used by the DELEG rule, which roughly tracks stake delegation and some governance features.
DState | |
|
Instances
The state that tracks the voting entities (DReps and Constitutional Committee
members). In the formal ledger specification this type is called GState
VState | |
|
Instances
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 | |
Era era ⇒ NFData (VState era) | |
Defined in Cardano.Ledger.CertState | |
Eq (VState era) | |
Typeable (EraCrypto 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.16.0.0-inplace" 'False) (C1 ('MetaCons "VState" 'PrefixI 'True) (S1 ('MetaSel ('Just "vsDReps") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era)))) :*: (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 (EraCrypto era) (Credential 'Staking (EraCrypto era)) (KeyHash 'StakePool (EraCrypto era)) Source #
ptrsMap ∷ DState era → Map Ptr (Credential 'Staking (EraCrypto era)) Source #
get the actual ptrs map, we don't need a view
data EpochState era Source #
EpochState | |
|
Instances
data PulsingRewUpdate c Source #
The state used in the STS rules
Pulsing !(RewardSnapShot c) !(Pulser c) | |
Complete !(RewardUpdate c) |
Instances
data FutureGenDeleg c Source #
Instances
data InstantaneousRewards c 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
InstantaneousRewards | |
|
Instances
data LedgerState era Source #
The state associated with a Ledger
.
LedgerState | |
|
Instances
The state used by the POOL rule, which tracks stake pool information.
PState | |
|
Instances
type RewardAccounts c = Map (Credential 'Staking c) Coin Source #
data RewardUpdate c Source #
The ultimate goal of a reward update computation. Aggregating rewards for each staking credential.
Instances
data RewardSnapShot c Source #
To complete the reward update, we need a snap shot of the EpochState particular to this computation
RewardSnapShot | |
|
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.
UTxOState | |
|
Instances
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 c 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.
IStake | |
|
Instances
Genesis State
genesisState ∷ ∀ era. EraGov era ⇒ Map (KeyHash 'Genesis (EraCrypto era)) (GenDelegPair (EraCrypto era)) → UTxO era → LedgerState era Source #
Creates the ledger state for an empty ledger which contains the specified transaction outputs.
Validation
consumed ∷ EraUTxO 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 ⇒ 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 (EraCrypto era) → 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.
allObligations ∷ EraGov era ⇒ CertState era → GovState era → Obligations Source #
Epoch boundary
incrementalStakeDistr ∷ ∀ era. EraPParams era ⇒ PParams era → IncrementalStake (EraCrypto era) → DState era → PState era → SnapShot (EraCrypto era) 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 (EraCrypto era) → UTxO era → UTxO era → IncrementalStake (EraCrypto era) Source #
Incrementally add the inserts utxoAdd
and the deletes utxoDel
to the IncrementalStake.
applyRUpd ∷ EraGov era ⇒ RewardUpdate (EraCrypto era) → 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 ⇒ RewardUpdate (EraCrypto era) → EpochState era → (EpochState era, FilteredRewards era) Source #
filterAllRewards ∷ EraGov era ⇒ Map (Credential 'Staking (EraCrypto era)) (Set (Reward (EraCrypto era))) → EpochState era → FilteredRewards era Source #
data FilteredRewards era Source #
FilteredRewards | |
|
Instances
NFData (FilteredRewards era) Source # | |
Defined in Cardano.Ledger.Shelley.LedgerState.IncrementalStake rnf ∷ FilteredRewards era → () Source # |
createRUpd ∷ ∀ era. EraGov era ⇒ EpochSize → BlocksMade (EraCrypto era) → EpochState era → Coin → ActiveSlotCoeff → Word64 → ShelleyBase (RewardUpdate (EraCrypto era)) Source #
To create a reward update, run all 3 phases This function is not used in the rules, so it ignores RewardEvents
completeRupd ∷ PulsingRewUpdate c → ShelleyBase (RewardUpdate c, RewardEvent c) 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 ⇒ EpochSize → BlocksMade (EraCrypto era) → EpochState era → Coin → ActiveSlotCoeff → Word64 → PulsingRewUpdate (EraCrypto era) Source #
pulseStep ∷ PulsingRewUpdate c → ShelleyBase (PulsingRewUpdate c, RewardEvent c) Source #
Run the pulser for a bit. If is has nothing left to do, complete it.
completeStep ∷ PulsingRewUpdate c → ShelleyBase (PulsingRewUpdate c, RewardEvent c) Source #
data NewEpochState era Source #
New Epoch state and environment
NewEpochState !EpochNo !(BlocksMade (EraCrypto era)) !(BlocksMade (EraCrypto era)) !(EpochState era) !(StrictMaybe (PulsingRewUpdate (EraCrypto era))) !(PoolDistr (EraCrypto era)) !(StashedAVVMAddresses era) |
Instances
type family StashedAVVMAddresses era where ... Source #
StashedAVVMAddresses (ShelleyEra c) = UTxO (ShelleyEra c) | |
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.
updateNES ∷ EraGov era ⇒ NewEpochState era → BlocksMade (EraCrypto era) → 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 c → Coin → Map (KeyHash 'StakePool c) Likelihood → NonMyopic c Source #
Check whether the new protocol version is a legitimate version bump with respect to the previous one.
availableAfterMIR ∷ MIRPot → AccountState → InstantaneousRewards c → 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 #
ShelleyGovState | |
|
Instances
Lenses from Types
nesEsL ∷ Lens' (NewEpochState era) (EpochState era) Source #
nesRuL ∷ Lens' (NewEpochState era) (StrictMaybe (PulsingRewUpdate (EraCrypto era))) 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 (EraCrypto era)) Source #
esLStateL ∷ Lens' (EpochState era) (LedgerState era) Source #
esNonMyopicL ∷ Lens' (EpochState era) (NonMyopic (EraCrypto era)) 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 #
utxosStakeDistrL ∷ Lens' (UTxOState era) (IncrementalStake (EraCrypto era)) Source #
epochStateGovStateL ∷ Lens' (EpochState era) (GovState era) Source #
epochStateStakeDistrL ∷ Lens' (EpochState era) (VMap VB VP (Credential 'Staking (EraCrypto era)) (CompactForm Coin)) Source #
epochStateUMapL ∷ Lens' (EpochState era) (UMap (EraCrypto era)) Source #
epochStatePoolParamsL ∷ Lens' (EpochState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era))) Source #
epochStateRegDrepL ∷ Lens' (EpochState era) (Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era))) Source #
epochStateIncrStakeDistrL ∷ Lens' (EpochState era) (Map (Credential 'Staking (EraCrypto era)) (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 (EraCrypto era)) Source #
dsFutureGenDelegsL ∷ Lens' (DState era) (Map (FutureGenDeleg (EraCrypto era)) (GenDelegPair (EraCrypto era))) Source #
psStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era))) Source #
psFutureStakePoolParamsL ∷ Lens' (PState era) (Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era))) Source #
vsDRepsL ∷ Lens' (VState era) (Map (Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era))) Source #
vsCommitteeStateL ∷ Lens' (VState era) (CommitteeState era) Source #
credMapL ∷ Lens' (IncrementalStake c) (Map (Credential 'Staking c) (CompactForm Coin)) Source #
ptrMapL ∷ Lens' (IncrementalStake c) (Map Ptr (CompactForm Coin)) Source #
Lenses from SnapShot(s)
ssStakeDistrL ∷ Lens' (SnapShot c) (VMap VB VP (Credential 'Staking c) (CompactForm Coin)) Source #