cardano-ledger-shelley-0.1.0.0
Safe Haskell None
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

Documentation

data AccountState Source #

Instances

Instances details
Eq AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NFData AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

ToCBOR AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

FromCBOR AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Default AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep AccountState Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep AccountState = D1 (' MetaData "AccountState" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "AccountState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "_treasury") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 Coin ) :*: S1 (' MetaSel (' Just "_reserves") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 Coin )))

data DPState crypto Source #

The state associated with the current stake delegation.

Constructors

DPState

Fields

Instances

Instances details
Eq ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( DPState crypto) :: Type -> Type Source #

NFData ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Methods

rnf :: DPState crypto -> () Source #

Crypto crypto => ToCBOR ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromSharedCBOR ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( DPState crypto) Source #

Default ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( DPState crypto) = D1 (' MetaData "DPState" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "DPState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "dpsDState") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( DState crypto)) :*: S1 (' MetaSel (' Just "dpsPState") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( PState crypto))))
type Share ( DPState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

data DState crypto Source #

State of staking pool delegations and rewards

Constructors

DState

Fields

Instances

Instances details
Eq ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( DState crypto) :: Type -> Type Source #

NFData ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Methods

rnf :: DState crypto -> () Source #

Crypto crypto => ToCBOR ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromSharedCBOR ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( DState crypto) Source #

Default ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Share ( DState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

ptrsMap :: DState crypto -> Map Ptr ( Credential ' Staking crypto) Source #

get the actual ptrs map, we don't need a view

data EpochState era Source #

Constructors

EpochState

Fields

Instances

Instances details
( Crypto ( Crypto era), Eq ( TxOut era), Eq ( PParams era), Eq ( State ( EraRule "PPUP" era))) => Eq ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Crypto ( Crypto era), Show ( TxOut era), Show ( PParams era), Show ( State ( EraRule "PPUP" era))) => Show ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( EpochState era) :: Type -> Type Source #

( Era era, NFData ( TxOut era), NFData ( PParams era), NFData ( State ( EraRule "PPUP" era))) => NFData ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, ToCBOR ( TxOut era), ToCBOR ( PParams era), ToCBOR ( State ( EraRule "PPUP" era))) => ToCBOR ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( FromCBOR ( PParams era), TransValue FromCBOR era, HashAnnotated ( TxBody era) EraIndependentTxBody ( Crypto era), FromSharedCBOR ( TxOut era), Share ( TxOut era) ~ Interns ( Credential ' Staking ( Crypto era)), FromCBOR ( State ( EraRule "PPUP" era)), Era era) => FromCBOR ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Default ( LedgerState era), Default ( PParams era)) => Default ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, NoThunks ( TxOut era), NoThunks ( State ( EraRule "PPUP" era)), NoThunks ( Value era), NoThunks ( PParams era), ToCBOR ( TxBody era), ToCBOR ( TxOut era), ToCBOR ( Value era)) => NoThunks ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( EpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

data UpecState era Source #

Constructors

UpecState

Fields

data PulsingRewUpdate crypto Source #

The state used in the STS rules

Constructors

Pulsing !( RewardSnapShot crypto) !( Pulser crypto)
Complete !( RewardUpdate crypto)

Instances

Instances details
Eq ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Show ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Generic ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Associated Types

type Rep ( PulsingRewUpdate crypto) :: Type -> Type Source #

NFData ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Crypto crypto => ToCBOR ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Crypto crypto => FromCBOR ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Typeable crypto => NoThunks ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

type Rep ( PulsingRewUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

data FutureGenDeleg crypto Source #

Instances

Instances details
Eq ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Ord ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( FutureGenDeleg crypto) :: Type -> Type Source #

NFData ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => ToCBOR ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromCBOR ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( FutureGenDeleg crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( FutureGenDeleg crypto) = D1 (' MetaData "FutureGenDeleg" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "FutureGenDeleg" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "fGenDelegSlot") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 SlotNo ) :*: S1 (' MetaSel (' Just "fGenDelegGenKeyHash") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( KeyHash ' Genesis crypto))))

data InstantaneousRewards crypto 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

Instances

Instances details
Eq ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NFData ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => ToCBOR ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromSharedCBOR ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( InstantaneousRewards crypto) Source #

Default ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Share ( InstantaneousRewards crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type KeyPairs crypto = [( KeyPair ' Payment crypto, KeyPair ' Staking crypto)] Source #

Representation of a list of pairs of key pairs, e.g., pay and stake keys

data LedgerState era Source #

The state associated with a Ledger .

Constructors

LedgerState

Fields

Instances

Instances details
( Crypto ( Crypto era), Eq ( TxOut era), Eq ( State ( EraRule "PPUP" era))) => Eq ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Crypto ( Crypto era), Show ( TxOut era), Show ( State ( EraRule "PPUP" era))) => Show ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( LedgerState era) :: Type -> Type Source #

( Era era, NFData ( TxOut era), NFData ( State ( EraRule "PPUP" era))) => NFData ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, ToCBOR ( TxOut era), ToCBOR ( State ( EraRule "PPUP" era))) => ToCBOR ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, HashAnnotated ( TxBody era) EraIndependentTxBody ( Crypto era), FromCBOR ( Value era), FromSharedCBOR ( TxOut era), Share ( TxOut era) ~ Interns ( Credential ' Staking ( Crypto era)), FromCBOR ( State ( EraRule "PPUP" era))) => FromSharedCBOR ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( LedgerState era) Source #

Default ( UTxOState era) => Default ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, NoThunks ( TxOut era), NoThunks ( State ( EraRule "PPUP" era)), NoThunks ( Value era), ToCBOR ( TxBody era), ToCBOR ( TxOut era), ToCBOR ( Value era)) => NoThunks ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( LedgerState era) = D1 (' MetaData "LedgerState" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "LedgerState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "lsUTxOState") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( UTxOState era)) :*: S1 (' MetaSel (' Just "lsDPState") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( DPState ( Crypto era)))))
type Share ( LedgerState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

data PPUPState era Source #

Instances

Instances details
Eq ( PParamsDelta era) => Eq ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( PParamsDelta era) => Show ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( PPUPState era) :: Type -> Type Source #

NFData ( PParamsDelta era) => NFData ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Methods

rnf :: PPUPState era -> () Source #

( Era era, ToCBOR ( PParamsDelta era)) => ToCBOR ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, FromCBOR ( PParamsDelta era)) => FromCBOR ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Default ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( PParamsDelta era) => NoThunks ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( PPUPState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( PPUPState era) = D1 (' MetaData "PPUPState" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "PPUPState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "proposals") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( ProposedPPUpdates era)) :*: S1 (' MetaSel (' Just "futureProposals") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( ProposedPPUpdates era))))

data PState crypto Source #

Current state of staking pools and their certificate counters.

Constructors

PState

Fields

Instances

Instances details
Eq ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( PState crypto) :: Type -> Type Source #

NFData ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Methods

rnf :: PState crypto -> () Source #

Crypto crypto => ToCBOR ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromSharedCBOR ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( PState crypto) Source #

Default ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Share ( PState crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

data RewardUpdate crypto Source #

The ultiate goal of a reward update computation. Aggregating rewards for each staking credential.

Instances

Instances details
Eq ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Show ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Generic ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Associated Types

type Rep ( RewardUpdate crypto) :: Type -> Type Source #

NFData ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Methods

rnf :: RewardUpdate crypto -> () Source #

Crypto crypto => ToCBOR ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Crypto crypto => FromCBOR ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

NoThunks ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

type Rep ( RewardUpdate crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

data RewardSnapShot crypto Source #

To complete the reward update, we need a snap shot of the EpochState particular to this computation

Instances

Instances details
HasField "_protocolVersion" ( RewardSnapShot crypto) ProtVer Source #

RewardSnapShot can act as a Proxy for PParams when only the protocol version is needed.

Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Eq ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Show ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Generic ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Associated Types

type Rep ( RewardSnapShot crypto) :: Type -> Type Source #

NFData ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Crypto crypto => ToCBOR ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Crypto crypto => FromCBOR ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

Typeable crypto => NoThunks ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

type Rep ( RewardSnapShot crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.RewardUpdate

data UTxOState era Source #

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 carefull, wherever we update the UTxO, we carefully make INCREMENTAL changes to istake to maintain this invariant. This happens in the UTxO rule.

Instances

Instances details
( Crypto ( Crypto era), Eq ( TxOut era), Eq ( State ( EraRule "PPUP" era))) => Eq ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Crypto ( Crypto era), Show ( TxOut era), Show ( State ( EraRule "PPUP" era))) => Show ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( UTxOState era) :: Type -> Type Source #

( Era era, NFData ( TxOut era), NFData ( State ( EraRule "PPUP" era))) => NFData ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Methods

rnf :: UTxOState era -> () Source #

( Era era, ToCBOR ( TxOut era), ToCBOR ( State ( EraRule "PPUP" era))) => ToCBOR ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( TransValue FromCBOR era, FromCBOR ( State ( EraRule "PPUP" era)), FromSharedCBOR ( TxOut era), Share ( TxOut era) ~ Interns ( Credential ' Staking ( Crypto era)), HashAnnotated ( TxBody era) EraIndependentTxBody ( Crypto era)) => FromSharedCBOR ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( UTxOState era) Source #

( Default ( State ( EraRule "PPUP" era)), Crypto ( Crypto era)) => Default ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, NoThunks ( TxOut era), NoThunks ( State ( EraRule "PPUP" era)), NoThunks ( Value era), ToCBOR ( TxBody era), ToCBOR ( TxOut era), ToCBOR ( Value era)) => NoThunks ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Share ( UTxOState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

smartUTxOState :: Era era => UTxO era -> Coin -> Coin -> State ( EraRule "PPUP" era) -> UTxOState era Source #

A valid (or self-consistent) UTxOState{_utxo, _deposited, _fees, _ppups, _stakeDistro} maintains an invariant between the _utxo and _stakeDistro fields. the _stakeDistro 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 _stakeDistro from the _utxo. This is aways safe to do, but if the _utxo field is big, this can be very expensive, which defeats the purpose of memoizing the _stakeDistro field. So use of this function should be restricted to tests and initializations, where the invariant should be maintained.

data IncrementalStake crypto 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.

Instances

Instances details
Eq ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Ord ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( IncrementalStake crypto) :: Type -> Type Source #

Semigroup ( IncrementalStake c) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Monoid ( IncrementalStake c) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NFData ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => ToCBOR ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Crypto crypto => FromSharedCBOR ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Share ( IncrementalStake crypto) Source #

Default ( IncrementalStake c) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Group ( IncrementalStake c) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

NoThunks ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( IncrementalStake crypto) = D1 (' MetaData "IncrementalStake" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' False ) ( C1 (' MetaCons "IStake" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "credMap") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Map ( Credential ' Staking crypto) Coin )) :*: S1 (' MetaSel (' Just "ptrMap") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Map Ptr Coin ))))
type Share ( IncrementalStake crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

depositPoolChange :: HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))) => LedgerState era -> PParams era -> TxBody era -> Coin Source #

Calculate the change to the deposit pool for a given transaction.

availableAfterMIR :: MIRPot -> AccountState -> InstantaneousRewards crypto -> 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.

Genesis State

genesisState :: Default ( State ( EraRule "PPUP" era)) => Map ( KeyHash ' Genesis ( Crypto era)) ( GenDelegPair ( Crypto era)) -> UTxO era -> LedgerState era Source #

Creates the ledger state for an empty ledger which contains the specified transaction outputs.

Validation

newtype WitHashes crypto Source #

Instances

Instances details
Eq ( WitHashes crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Show ( WitHashes crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( WitHashes crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( WitHashes crypto) :: Type -> Type Source #

NoThunks ( WitHashes crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( WitHashes crypto) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( WitHashes crypto) = D1 (' MetaData "WitHashes" "Cardano.Ledger.Shelley.LedgerState" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" ' True ) ( C1 (' MetaCons "WitHashes" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "unWitHashes") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ( Set ( KeyHash ' Witness crypto)))))

nullWitHashes :: WitHashes crypto -> Bool Source #

Check if a set of witness hashes is empty.

diffWitHashes :: WitHashes crypto -> WitHashes crypto -> WitHashes crypto Source #

Extract the difference between two sets of witness hashes.

minfee :: ( HasField "_minfeeA" pp Natural , HasField "_minfeeB" pp Natural , HasField "txsize" tx Integer ) => pp -> tx -> Coin Source #

Minimum fee calculation

txsizeBound :: forall era out tx. ( HasField "outputs" ( TxBody era) ( StrictSeq out), HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "body" tx ( TxBody era), HasField "txsize" tx Integer ) => Proxy era -> tx -> Integer Source #

Convenience Function to bound the txsize function. | It can be helpful for coin selection.

produced :: forall era pp. ( Era era, HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "_keyDeposit" pp Coin , HasField "_poolDeposit" pp Coin ) => pp -> ( KeyHash ' StakePool ( Crypto era) -> Bool ) -> TxBody era -> Value era Source #

Compute the lovelace which are created by the transaction

consumed :: forall era pp. ( Era era, HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "_keyDeposit" pp Coin ) => pp -> UTxO era -> TxBody era -> Value era Source #

Compute the lovelace which are destroyed by the transaction

witsFromTxWitnesses :: ( Era era, HasField "addrWits" tx ( Set ( WitVKey ' Witness ( Crypto era))), HasField "bootWits" tx ( Set ( BootstrapWitness ( Crypto era)))) => tx -> WitHashes ( Crypto era) Source #

Extract the witness hashes from the Transaction.

propWits :: Maybe ( Update era) -> GenDelegs ( Crypto era) -> Set ( KeyHash ' Witness ( Crypto era)) Source #

Calculate the set of hash keys of the required witnesses for update proposals.

DelegationState

keyRefunds :: ( HasField "certs" txb ( StrictSeq ( DCert crypto)), HasField "_keyDeposit" pp Coin ) => pp -> txb -> Coin Source #

Compute the key deregistration refunds in a transaction

Epoch boundary

incrementalStakeDistr :: forall crypto. IncrementalStake crypto -> DState crypto -> PState crypto -> SnapShot crypto Source #

Compute the current state distribution by using the IncrementalStake,

This computes the stake distribution using IncrementalStake (which is an aggregate of the current UTxO) and UnifiedMap (which tracks Coin, Delegations, and Ptrs simultaneously). Note that logically: 1) IncrementalStake = (credStake, ptrStake) 2) UnifiedMap = (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 :: Era era => IncrementalStake ( Crypto era) -> UTxO era -> UTxO era -> IncrementalStake ( Crypto era) Source #

Incrementally add the inserts utxoAdd and the deletes utxoDel to the IncrementalStake.

applyRUpd :: HasField "_protocolVersion" ( PParams era) ProtVer => RewardUpdate ( Crypto era) -> EpochState era -> EpochState era Source #

Apply a reward update

createRUpd :: forall era. UsesPP era => EpochSize -> BlocksMade ( Crypto era) -> EpochState era -> Coin -> ActiveSlotCoeff -> Word64 -> ProvM ( RewardProvenance ( Crypto era)) ShelleyBase ( RewardUpdate ( Crypto 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 crypto -> ProvM ( RewardProvenance crypto) ShelleyBase ( RewardUpdate crypto, RewardEvent crypto) 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 :: forall era. UsesPP era => EpochSize -> BlocksMade ( Crypto era) -> EpochState era -> Coin -> ActiveSlotCoeff -> Word64 -> ( PulsingRewUpdate ( Crypto era), RewardProvenance ( Crypto era)) Source #

Assemble the components for, and then create, a Pulser.

pulseStep :: PulsingRewUpdate crypto -> ShelleyBase ( PulsingRewUpdate crypto, RewardEvent crypto) 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

Instances

Instances details
( Crypto ( Crypto era), Eq ( TxOut era), Eq ( PParams era), Eq ( State ( EraRule "PPUP" era)), Eq ( StashedAVVMAddresses era)) => Eq ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Crypto ( Crypto era), Show ( TxOut era), Show ( PParams era), Show ( State ( EraRule "PPUP" era)), Show ( StashedAVVMAddresses era)) => Show ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Generic ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

Associated Types

type Rep ( NewEpochState era) :: Type -> Type Source #

( Era era, NFData ( TxOut era), NFData ( PParams era), NFData ( State ( EraRule "PPUP" era)), NFData ( StashedAVVMAddresses era)) => NFData ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, ToCBOR ( TxOut era), ToCBOR ( PParams era), ToCBOR ( State ( EraRule "PPUP" era)), ToCBOR ( StashedAVVMAddresses era)) => ToCBOR ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, FromCBOR ( PParams era), FromSharedCBOR ( TxOut era), Share ( TxOut era) ~ Interns ( Credential ' Staking ( Crypto era)), FromCBOR ( Value era), FromCBOR ( State ( EraRule "PPUP" era)), FromCBOR ( StashedAVVMAddresses era)) => FromCBOR ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

( Era era, NoThunks ( TxOut era), NoThunks ( PParams era), NoThunks ( State ( EraRule "PPUP" era)), NoThunks ( Value era), NoThunks ( StashedAVVMAddresses era), ToCBOR ( TxBody era), ToCBOR ( TxOut era), ToCBOR ( Value era)) => NoThunks ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

type Rep ( NewEpochState era) Source #
Instance details

Defined in Cardano.Ledger.Shelley.LedgerState

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.

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