Safe Haskell | None |
---|---|
Language | Haskell98 |
Shelley.Spec.Ledger.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
- data AccountState = AccountState {}
- data DPState era = DPState {}
- data DState era = DState {
- _rewards ∷ !(RewardAccounts era)
- _delegations ∷ !(Map (Credential 'Staking era) (KeyHash 'StakePool (Crypto era)))
- _ptrs ∷ !(Bimap Ptr (Credential 'Staking era))
- _fGenDelegs ∷ !(Map (FutureGenDeleg (Crypto era)) (GenDelegPair (Crypto era)))
- _genDelegs ∷ !(GenDelegs (Crypto era))
- _irwd ∷ !(InstantaneousRewards era)
- data EpochState era = EpochState {
- esAccountState ∷ !AccountState
- esSnapshots ∷ !(SnapShots era)
- esLState ∷ !(LedgerState era)
- esPrevPp ∷ !(PParams era)
- esPp ∷ !(PParams era)
- esNonMyopic ∷ !(NonMyopic era)
- data FutureGenDeleg crypto = FutureGenDeleg {
- fGenDelegSlot ∷ !SlotNo
- fGenDelegGenKeyHash ∷ !(KeyHash 'Genesis crypto)
- data InstantaneousRewards era = InstantaneousRewards {
- iRReserves ∷ !(Map (Credential 'Staking era) Coin)
- iRTreasury ∷ !(Map (Credential 'Staking era) Coin)
- type Ix = Natural
- type KeyPairs era = [(KeyPair 'Payment era, KeyPair 'Staking era)]
- data LedgerState era = LedgerState {
- _utxoState ∷ !(UTxOState era)
- _delegationState ∷ !(DPState era)
- data PPUPState era = PPUPState {
- proposals ∷ !(ProposedPPUpdates era)
- futureProposals ∷ !(ProposedPPUpdates era)
- data PState era = PState {}
- type RewardAccounts era = Map (Credential 'Staking era) Coin
- data RewardUpdate era = RewardUpdate {}
- data UTxOState era = UTxOState {}
- depositPoolChange ∷ HasField "certs" (TxBody era) (StrictSeq (DCert era)) ⇒ LedgerState era → PParams era → TxBody era → Coin
- emptyAccount ∷ AccountState
- emptyDPState ∷ DPState era
- emptyDState ∷ DState era
- emptyEpochState ∷ EpochState era
- emptyInstantaneousRewards ∷ InstantaneousRewards era
- emptyLedgerState ∷ LedgerState era
- emptyPPUPState ∷ PPUPState era
- emptyPState ∷ PState era
- emptyRewardUpdate ∷ RewardUpdate era
- emptyUTxOState ∷ UTxOState era
- pvCanFollow ∷ ProtVer → StrictMaybe ProtVer → Bool
- reapRewards ∷ RewardAccounts era → RewardAccounts era → RewardAccounts era
- totalInstantaneousReservesRewards ∷ InstantaneousRewards era → Coin
- updatePpup ∷ UTxOState era → PParams era → UTxOState era
- emptyDelegation ∷ DPState era
- genesisState ∷ Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era)) → UTxO era → LedgerState era
- newtype WitHashes era = WitHashes {
- unWitHashes ∷ Set (KeyHash 'Witness (Crypto era))
- nullWitHashes ∷ WitHashes era → Bool
- diffWitHashes ∷ WitHashes era → WitHashes era → WitHashes era
- minfee ∷ PParams era → Tx era → Coin
- minfeeBound ∷ ∀ era. (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "inputs" (TxBody era) (Set (TxIn era))) ⇒ PParams era → Tx era → Coin
- txsize ∷ Tx era → Integer
- txsizeBound ∷ ∀ era. (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "inputs" (TxBody era) (Set (TxIn era))) ⇒ Tx era → Integer
- produced ∷ (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "txfee" (TxBody era) Coin) ⇒ PParams era → Map (KeyHash 'StakePool (Crypto era)) (PoolParams era) → TxBody era → Value era
- consumed ∷ (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "inputs" (TxBody era) (Set (TxIn era)), HasField "wdrls" (TxBody era) (Wdrl era)) ⇒ PParams era → UTxO era → TxBody era → Value era
- verifiedWits ∷ (TxBodyConstraints era, AnnotatedData (Script era), DSignable (Crypto era) (Hash (Crypto era) EraIndependentTxBody)) ⇒ Tx era → Either [VKey 'Witness (Crypto era)] ()
- witsVKeyNeeded ∷ ∀ era. (ShelleyBased era, HasField "wdrls" (TxBody era) (Wdrl era), HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "inputs" (TxBody era) (Set (TxIn era)), HasField "update" (TxBody era) (StrictMaybe (Update era))) ⇒ UTxO era → Tx era → GenDelegs (Crypto era) → WitHashes era
- witsFromWitnessSet ∷ (Era era, AnnotatedData (Script era)) ⇒ WitnessSet era → WitHashes era
- keyRefunds ∷ HasField "certs" (TxBody era) (StrictSeq (DCert era)) ⇒ PParams era → TxBody era → Coin
- stakeDistr ∷ ∀ era. ShelleyBased era ⇒ UTxO era → DState era → PState era → SnapShot era
- applyRUpd ∷ RewardUpdate era → EpochState era → EpochState era
- createRUpd ∷ EpochSize → BlocksMade era → EpochState era → Coin → ShelleyBase (RewardUpdate era)
- data NewEpochState era = NewEpochState {
- nesEL ∷ !EpochNo
- nesBprev ∷ !(BlocksMade era)
- nesBcur ∷ !(BlocksMade era)
- nesEs ∷ !(EpochState era)
- nesRu ∷ !(StrictMaybe (RewardUpdate era))
- nesPd ∷ !(PoolDistr (Crypto era))
- getGKeys ∷ NewEpochState era → Set (KeyHash 'Genesis (Crypto era))
- updateNES ∷ NewEpochState era → BlocksMade era → LedgerState era → NewEpochState era
- circulation ∷ EpochState era → Coin → Coin
- decayFactor ∷ Float
- returnRedeemAddrsToReserves ∷ ShelleyBased era ⇒ EpochState era → EpochState era
Documentation
data AccountState Source #
Constructors
AccountState | |
Instances
The state associated with the current stake delegation.
Instances
Eq (DPState era) Source # | |
Show (DPState era) Source # | |
Generic (DPState era) Source # | |
NFData (DPState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState | |
(Era era, AnnotatedData (Script era)) ⇒ ToCBOR (DPState era) Source # | |
(Era era, AnnotatedData (Script era)) ⇒ FromCBOR (DPState era) Source # | |
NoThunks (DPState era) Source # | |
type Rep (DPState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState type Rep (DPState era) = D1 ('MetaData "DPState" "Shelley.Spec.Ledger.LedgerState" "shelley-spec-ledger-0.1.0.0-inplace" 'False) (C1 ('MetaCons "DPState" 'PrefixI 'True) (S1 ('MetaSel ('Just "_dstate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (DState era)) :*: S1 ('MetaSel ('Just "_pstate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PState era)))) |
State of staking pool delegations and rewards
Constructors
DState | |
Fields
|
Instances
data EpochState era Source #
Constructors
EpochState | |
Fields
|
Instances
data FutureGenDeleg crypto Source #
Constructors
FutureGenDeleg | |
Fields
|
Instances
data InstantaneousRewards era Source #
Constructors
InstantaneousRewards | |
Fields
|
Instances
type KeyPairs era = [(KeyPair 'Payment era, KeyPair 'Staking era)] 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
Constructors
PPUPState | |
Fields
|
Instances
Eq (PPUPState era) Source # | |
Show (PPUPState era) Source # | |
Generic (PPUPState era) Source # | |
NFData (PPUPState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState | |
Era era ⇒ ToCBOR (PPUPState era) Source # | |
Era era ⇒ FromCBOR (PPUPState era) Source # | |
NoThunks (PPUPState era) Source # | |
type Rep (PPUPState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState type Rep (PPUPState era) = D1 ('MetaData "PPUPState" "Shelley.Spec.Ledger.LedgerState" "shelley-spec-ledger-0.1.0.0-inplace" '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)))) |
Current state of staking pools and their certificate counters.
Constructors
PState | |
Fields
|
Instances
Eq (PState era) Source # | |
Show (PState era) Source # | |
Generic (PState era) Source # | |
NFData (PState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState | |
Era era ⇒ ToCBOR (PState era) Source # | |
Era era ⇒ FromCBOR (PState era) Source # | |
NoThunks (PState era) Source # | |
type Rep (PState era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState type Rep (PState era) = D1 ('MetaData "PState" "Shelley.Spec.Ledger.LedgerState" "shelley-spec-ledger-0.1.0.0-inplace" 'False) (C1 ('MetaCons "PState" 'PrefixI 'True) (S1 ('MetaSel ('Just "_pParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool (Crypto era)) (PoolParams era))) :*: (S1 ('MetaSel ('Just "_fPParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool (Crypto era)) (PoolParams era))) :*: S1 ('MetaSel ('Just "_retiring") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (KeyHash 'StakePool (Crypto era)) EpochNo))))) |
type RewardAccounts era = Map (Credential 'Staking era) Coin Source #
data RewardUpdate era Source #
Constructors
RewardUpdate | |
Instances
Constructors
UTxOState | |
Instances
depositPoolChange ∷ HasField "certs" (TxBody era) (StrictSeq (DCert era)) ⇒ LedgerState era → PParams era → TxBody era → Coin Source #
Calculate the change to the deposit pool for a given transaction.
emptyDPState ∷ DPState era Source #
emptyDState ∷ DState era Source #
emptyEpochState ∷ EpochState era Source #
emptyLedgerState ∷ LedgerState era Source #
emptyPPUPState ∷ PPUPState era Source #
emptyPState ∷ PState era Source #
emptyRewardUpdate ∷ RewardUpdate era Source #
emptyUTxOState ∷ UTxOState era Source #
pvCanFollow ∷ ProtVer → StrictMaybe ProtVer → Bool Source #
reapRewards ∷ RewardAccounts era → RewardAccounts era → RewardAccounts era Source #
updatePpup ∷ UTxOState era → PParams era → UTxOState era Source #
Update the protocol parameter updates by clearing out the proposals and making the future proposals become the new proposals, provided the new proposals can follow (otherwise reset them).
state transitions
emptyDelegation ∷ DPState era Source #
Genesis State
genesisState ∷ 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 era Source #
Instances
Eq (WitHashes era) Source # | |
Show (WitHashes era) Source # | |
Generic (WitHashes era) Source # | |
Era era ⇒ NoThunks (WitHashes era) Source # | |
type Rep (WitHashes era) Source # | |
Defined in Shelley.Spec.Ledger.LedgerState type Rep (WitHashes era) = D1 ('MetaData "WitHashes" "Shelley.Spec.Ledger.LedgerState" "shelley-spec-ledger-0.1.0.0-inplace" 'True) (C1 ('MetaCons "WitHashes" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWitHashes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set (KeyHash 'Witness (Crypto era)))))) |
nullWitHashes ∷ WitHashes era → Bool Source #
Check if a set of witness hashes is empty.
diffWitHashes ∷ WitHashes era → WitHashes era → WitHashes era Source #
Extract the difference between two sets of witness hashes.
minfeeBound ∷ ∀ era. (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "inputs" (TxBody era) (Set (TxIn era))) ⇒ PParams era → Tx era → Coin Source #
Minimum fee bound using txsizeBound
txsizeBound ∷ ∀ era. (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "inputs" (TxBody era) (Set (TxIn era))) ⇒ Tx era → Integer Source #
Convenience Function to bound the txsize function. | It can be helpful for coin selection.
produced ∷ (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "outputs" (TxBody era) (StrictSeq (TxOut era)), HasField "txfee" (TxBody era) Coin) ⇒ PParams era → Map (KeyHash 'StakePool (Crypto era)) (PoolParams era) → TxBody era → Value era Source #
Compute the lovelace which are created by the transaction
consumed ∷ (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "inputs" (TxBody era) (Set (TxIn era)), HasField "wdrls" (TxBody era) (Wdrl era)) ⇒ PParams era → UTxO era → TxBody era → Value era Source #
Compute the lovelace which are destroyed by the transaction TODO this is only correct for Shelley!
verifiedWits ∷ (TxBodyConstraints era, AnnotatedData (Script era), DSignable (Crypto era) (Hash (Crypto era) EraIndependentTxBody)) ⇒ Tx era → Either [VKey 'Witness (Crypto era)] () Source #
Given a ledger state, determine if the UTxO witnesses in a given transaction are correct.
witsVKeyNeeded ∷ ∀ era. (ShelleyBased era, HasField "wdrls" (TxBody era) (Wdrl era), HasField "certs" (TxBody era) (StrictSeq (DCert era)), HasField "inputs" (TxBody era) (Set (TxIn era)), HasField "update" (TxBody era) (StrictMaybe (Update era))) ⇒ UTxO era → Tx era → GenDelegs (Crypto era) → WitHashes era Source #
Collect the set of hashes of keys that needs to sign a given transaction. This set consists of the txin owners, certificate authors, and withdrawal reward accounts.
witsFromWitnessSet ∷ (Era era, AnnotatedData (Script era)) ⇒ WitnessSet era → WitHashes era Source #
Extract the witness hashes from the Witness set.
DelegationState
keyRefunds ∷ HasField "certs" (TxBody era) (StrictSeq (DCert era)) ⇒ PParams era → TxBody era → Coin Source #
Compute the key deregistration refunds in a transaction
Epoch boundary
stakeDistr ∷ ∀ era. ShelleyBased era ⇒ UTxO era → DState era → PState era → SnapShot era Source #
applyRUpd ∷ RewardUpdate era → EpochState era → EpochState era Source #
Apply a reward update
createRUpd ∷ EpochSize → BlocksMade era → EpochState era → Coin → ShelleyBase (RewardUpdate era) Source #
Create a reward update
data NewEpochState era Source #
New Epoch state and environment
Constructors
NewEpochState | |
Fields
|
Instances
updateNES ∷ NewEpochState era → BlocksMade 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 ∷ ShelleyBased era ⇒ EpochState era → EpochState era Source #