cardano-ledger-shelley- Shelley Ledger Executable Model
Safe HaskellSafe-Inferred




updateStakeDistributionEraTxOut 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.

applyRUpdEraGov 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

smartUTxOStateEraTxOut era ⇒ PParams era → UTxO era → CoinCoinGovState era → CoinUTxOState 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 FilteredRewards era Source #





Instances details
NFData (FilteredRewards era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState.IncrementalStake


rnfFilteredRewards era → () Source #