Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cardano.Ledger.Shelley.Transition
Description
Besides capturing all configuration that is necessary to progress to a specific era, this interface also provides fast forward functionality that is used in testing and benchmarking in order to initilize a chain in a particular era without going through the trouble of generating all the history for preceeding eras.
Synopsis
- class (EraTxOut era, EraGov era, EraStake era, EraGenesis era, EraCertState era, Eq (TransitionConfig era), Show (TransitionConfig era), FromJSON (TransitionConfig era), Default (StashedAVVMAddresses era)) ⇒ EraTransition era where
- data TransitionConfig era ∷ Type
- mkTransitionConfig ∷ TranslationContext era → TransitionConfig (PreviousEra era) → TransitionConfig era
- injectIntoTestState ∷ TransitionConfig era → NewEpochState era → NewEpochState era
- tcPreviousEraConfigL ∷ EraTransition (PreviousEra era) ⇒ Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
- tcTranslationContextL ∷ Lens' (TransitionConfig era) (TranslationContext era)
- tcShelleyGenesisL ∷ Lens' (TransitionConfig era) ShelleyGenesis
- tcInitialPParamsG ∷ SimpleGetter (TransitionConfig era) (PParams era)
- tcInitialFundsL ∷ (HasCallStack, EraTransition era) ⇒ Lens' (TransitionConfig era) (ListMap Addr Coin)
- tcInitialStakingL ∷ (HasCallStack, EraTransition era) ⇒ Lens' (TransitionConfig era) ShelleyGenesisStaking
- mkShelleyTransitionConfig ∷ ShelleyGenesis → TransitionConfig ShelleyEra
- createInitialState ∷ ∀ era. (EraTransition era, HasCallStack) ⇒ TransitionConfig era → NewEpochState era
- shelleyRegisterInitialFundsThenStaking ∷ (EraTransition era, ShelleyEraAccounts era) ⇒ TransitionConfig era → NewEpochState era → NewEpochState era
- shelleyRegisterInitialAccounts ∷ ∀ era. (HasCallStack, ShelleyEraAccounts era, EraCertState era, EraGov era) ⇒ ShelleyGenesisStaking → NewEpochState era → NewEpochState era
- registerInitialStakePools ∷ ∀ era. EraCertState era ⇒ ShelleyGenesisStaking → NewEpochState era → NewEpochState era
- registerInitialFunds ∷ ∀ era. (EraTransition era, HasCallStack) ⇒ TransitionConfig era → NewEpochState era → NewEpochState era
- resetStakeDistribution ∷ (EraCertState era, EraStake era) ⇒ NewEpochState era → NewEpochState era
- toShelleyTransitionConfigPairs ∷ KeyValue e a ⇒ TransitionConfig ShelleyEra → [a]
- protectMainnet ∷ (HasCallStack, EraTransition era) ⇒ String → TransitionConfig era → (a → Bool) → a → a
- protectMainnetLens ∷ (HasCallStack, EraTransition era) ⇒ String → (a → Bool) → Lens' (TransitionConfig era) a → Lens' (TransitionConfig era) a
Documentation
class (EraTxOut era, EraGov era, EraStake era, EraGenesis era, EraCertState era, Eq (TransitionConfig era), Show (TransitionConfig era), FromJSON (TransitionConfig era), Default (StashedAVVMAddresses era)) ⇒ EraTransition era where Source #
Register the initial information in the NewEpochState
.
HERE BE DRAGONS! This interfaced is intended to help in testing.
In production, the genesis should not contain any initial information about accounts, stake pools or dreps.
Warning - Should only be used in testing and benchmarking. Will result in an error when NetworkId is set to Mainnet
Minimal complete definition
mkTransitionConfig, injectIntoTestState, tcPreviousEraConfigL, tcTranslationContextL
Associated Types
data TransitionConfig era ∷ Type Source #
Cumulative configuration that is needed to be able to start in a current era
Methods
Arguments
∷ TranslationContext era | Translation context necessary for advancing from previous era into the current one. This will usually be the contents of genesis file, if one exists for the current era |
→ TransitionConfig (PreviousEra era) | Transition configuration for the previous era. |
→ TransitionConfig era |
Arguments
∷ TransitionConfig era | Extract data from the given transition configuration and store it in the given state. Warning - Should only be used in testing and benchmarking. Will result in an error
when |
→ NewEpochState era | |
→ NewEpochState era |
tcPreviousEraConfigL ∷ EraTransition (PreviousEra era) ⇒ Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era)) Source #
In case when a previous era is available, we should always be able to access
TransitionConfig
for the previous era, from within the current era's
TransitionConfig
tcTranslationContextL ∷ Lens' (TransitionConfig era) (TranslationContext era) Source #
Lens for the TranslationContext
for the current era from the TransitionConfig
Translation context is a different name for the Genesis type for each era, they are
one and the same concept.
tcShelleyGenesisL ∷ Lens' (TransitionConfig era) ShelleyGenesis Source #
Lens for the ShelleyGenesis
from the TransitionConfig
. Default implementation
looks in the previous era's config
default tcShelleyGenesisL ∷ EraTransition (PreviousEra era) ⇒ Lens' (TransitionConfig era) ShelleyGenesis Source #
tcInitialPParamsG ∷ SimpleGetter (TransitionConfig era) (PParams era) Source #
Get the initial PParams for the current era from the TransitionConfig
. Note that
this is only useful for testing and fast forward functionality, because this function
assumes no on-chain changes to PParams through PParamsUpdate functionality.
Default implementation will use the PParams from the Previous era and the current
TranslationContext
to construct PParams for the current era.
Warning - Should only be used in testing and benchmarking
default tcInitialPParamsG ∷ (EraTransition (PreviousEra era), TranslateEra era PParams, TranslationError era PParams ~ Void) ⇒ SimpleGetter (TransitionConfig era) (PParams era) Source #
Instances
tcInitialFundsL ∷ (HasCallStack, EraTransition era) ⇒ Lens' (TransitionConfig era) (ListMap Addr Coin) Source #
Get the initial funds from the TransitionConfig
. This value must be non-empty
only during testing and benchmarking, it must never contain anything on a real system.
Warning - Should only be used in testing and benchmarking. Will result in an error when NetworkId is set to Mainnet
tcInitialStakingL ∷ (HasCallStack, EraTransition era) ⇒ Lens' (TransitionConfig era) ShelleyGenesisStaking Source #
Get the initial staking from the TransitionConfig
. This value must be non-empty
only during testing and benchmarking, it must never contain anything on a real system.
Warning - Should only be used in testing and benchmarking. Will result in an error when NetworkId is set to Mainnet
mkShelleyTransitionConfig ∷ ShelleyGenesis → TransitionConfig ShelleyEra Source #
Constructor for the base Shelley TransitionConfig
createInitialState ∷ ∀ era. (EraTransition era, HasCallStack) ⇒ TransitionConfig era → NewEpochState era Source #
Helper function for constructing the initial state for any era
Warning - Should only be used in testing and benchmarking. Will result in an error when NetworkId is set to Mainnet
This function does not register any initial funds or delegates.
shelleyRegisterInitialFundsThenStaking ∷ (EraTransition era, ShelleyEraAccounts era) ⇒ TransitionConfig era → NewEpochState era → NewEpochState era Source #
shelleyRegisterInitialAccounts ∷ ∀ era. (HasCallStack, ShelleyEraAccounts era, EraCertState era, EraGov era) ⇒ ShelleyGenesisStaking → NewEpochState era → NewEpochState era Source #
Register all staking credentials and apply delegations. Make sure StakePools that are bing
delegated to are already registered, which can be done with registerInitialStakePools
.
registerInitialStakePools ∷ ∀ era. EraCertState era ⇒ ShelleyGenesisStaking → NewEpochState era → NewEpochState era Source #
registerInitialFunds ∷ ∀ era. (EraTransition era, HasCallStack) ⇒ TransitionConfig era → NewEpochState era → NewEpochState era Source #
Register the initial funds in the NewEpochState
.
HERE BE DRAGONS! This function is intended to help in testing.
In production, the genesis should not contain any initial funds.
The given funds are added to the existing UTxO.
PRECONDITION: the given funds must not be part of the existing UTxO. > forall (addr, _) in initialFunds. > Map.notElem (initialFundsPseudoTxIn addr) existingUTxO
PROPERTY: > genesisUTxO genesis > == genesisUTxO' (sgInitialFunds genesis) > == extractUTxO (registerInitialFunds (sgInitialFunds genesis) > NewEpochState)
Warning - Should only be used in testing and benchmarking. Will result in an error when NetworkId is set to Mainnet
resetStakeDistribution ∷ (EraCertState era, EraStake era) ⇒ NewEpochState era → NewEpochState era Source #
Having initial funds, stake pools and accounts with delegations, we need to reset the stake distribution, otherwise those initial stake pools will not be able to produce blocks
toShelleyTransitionConfigPairs ∷ KeyValue e a ⇒ TransitionConfig ShelleyEra → [a] Source #
Deprecated: In favor of toKeyValuePairs
protectMainnet ∷ (HasCallStack, EraTransition era) ⇒ String → TransitionConfig era → (a → Bool) → a → a Source #
protectMainnetLens ∷ (HasCallStack, EraTransition era) ⇒ String → (a → Bool) → Lens' (TransitionConfig era) a → Lens' (TransitionConfig era) a Source #