Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- updateStakeDistribution ∷ EraTxOut era ⇒ PParams era → IncrementalStake (EraCrypto era) → UTxO era → UTxO era → IncrementalStake (EraCrypto era)
- incrementalStakeDistr ∷ ∀ era. EraPParams era ⇒ PParams era → IncrementalStake (EraCrypto era) → DState era → PState era → SnapShot (EraCrypto era)
- applyRUpd ∷ EraGov era ⇒ RewardUpdate (EraCrypto era) → EpochState era → EpochState era
- applyRUpdFiltered ∷ EraGov era ⇒ RewardUpdate (EraCrypto era) → EpochState era → (EpochState era, FilteredRewards era)
- smartUTxOState ∷ EraTxOut era ⇒ PParams era → UTxO era → Coin → Coin → GovState era → Coin → UTxOState 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
Documentation
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.
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.
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 #
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
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 # |