Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Integration between the Shelley ledger and its corresponding (Transitional Praos) protocol.
In particular, this code supports extracting the components of the ledger state needed for protocol execution, both now and in a 2k-slot window.
Synopsis
- class (Crypto c, DSignable c (OCertSignable c), KESignable c (BHBody c), VRFSignable c Seed) ⇒ PraosCrypto c
- class (Eq (ChainTransitionError (EraCrypto era)), Show (ChainTransitionError (EraCrypto era)), Show (LedgerView (EraCrypto era)), Show (FutureLedgerViewError era), STS (EraRule "TICKF" era), BaseM (EraRule "TICKF" era) ~ ShelleyBase, Environment (EraRule "TICKF" era) ~ (), State (EraRule "TICKF" era) ~ NewEpochState era, Signal (EraRule "TICKF" era) ~ SlotNo, EraGov era) ⇒ GetLedgerView era where
- currentLedgerView ∷ NewEpochState era → LedgerView (EraCrypto era)
- futureLedgerView ∷ MonadError (FutureLedgerViewError era) m ⇒ Globals → NewEpochState era → SlotNo → m (LedgerView (EraCrypto era))
- data LedgerView c = LedgerView {}
- mkInitialShelleyLedgerView ∷ Crypto c ⇒ FromByronTranslationContext c → LedgerView c
- newtype FutureLedgerViewError era = FutureLedgerViewError (NonEmpty (PredicateFailure (EraRule "TICKF" era)))
- data ChainDepState c = ChainDepState {
- csProtocol ∷ !(PrtclState c)
- csTickn ∷ !TicknState
- csLabNonce ∷ !Nonce
- newtype ChainTransitionError c = ChainTransitionError (NonEmpty (PredicateFailure (PRTCL c)))
- tickChainDepState ∷ Globals → LedgerView c → Bool → ChainDepState c → ChainDepState c
- updateChainDepState ∷ ∀ c m. (PraosCrypto c, MonadError (ChainTransitionError c) m) ⇒ Globals → LedgerView c → BHeader c → ChainDepState c → m (ChainDepState c)
- reupdateChainDepState ∷ ∀ c. PraosCrypto c ⇒ Globals → LedgerView c → BHeader c → ChainDepState c → ChainDepState c
- initialChainDepState ∷ Nonce → Map (KeyHash 'Genesis c) (GenDelegPair c) → ChainDepState c
- checkLeaderValue ∷ ∀ v. VRFAlgorithm v ⇒ OutputVRF v → Rational → ActiveSlotCoeff → Bool
- getLeaderSchedule ∷ (EraPParams era, Signable (VRF (EraCrypto era)) Seed) ⇒ Globals → NewEpochState era → ChainDepState (EraCrypto era) → KeyHash 'StakePool (EraCrypto era) → SignKeyVRF (EraCrypto era) → PParams era → Set SlotNo
Documentation
class (Crypto c, DSignable c (OCertSignable c), KESignable c (BHBody c), VRFSignable c Seed) ⇒ PraosCrypto c Source #
Instances
PraosCrypto StandardCrypto Source # | |
Defined in Cardano.Protocol.TPraos.API |
class (Eq (ChainTransitionError (EraCrypto era)), Show (ChainTransitionError (EraCrypto era)), Show (LedgerView (EraCrypto era)), Show (FutureLedgerViewError era), STS (EraRule "TICKF" era), BaseM (EraRule "TICKF" era) ~ ShelleyBase, Environment (EraRule "TICKF" era) ~ (), State (EraRule "TICKF" era) ~ NewEpochState era, Signal (EraRule "TICKF" era) ~ SlotNo, EraGov era) ⇒ GetLedgerView era where Source #
Nothing
currentLedgerView ∷ NewEpochState era → LedgerView (EraCrypto era) Source #
default currentLedgerView ∷ ProtVerAtMost era 6 ⇒ NewEpochState era → LedgerView (EraCrypto era) Source #
futureLedgerView ∷ MonadError (FutureLedgerViewError era) m ⇒ Globals → NewEpochState era → SlotNo → m (LedgerView (EraCrypto era)) Source #
default futureLedgerView ∷ (MonadError (FutureLedgerViewError era) m, ProtVerAtMost era 6) ⇒ Globals → NewEpochState era → SlotNo → m (LedgerView (EraCrypto era)) Source #
Instances
data LedgerView c Source #
Data required by the Transitional Praos protocol from the Shelley ledger.
Instances
mkInitialShelleyLedgerView ∷ Crypto c ⇒ FromByronTranslationContext c → LedgerView c Source #
We construct a LedgerView
using the Shelley genesis config in the same
way as translateToShelleyLedgerState
.
newtype FutureLedgerViewError era Source #
FutureLedgerViewError (NonEmpty (PredicateFailure (EraRule "TICKF" era))) |
Instances
Show (PredicateFailure (EraRule "TICKF" era)) ⇒ Show (FutureLedgerViewError era) Source # | |
Defined in Cardano.Protocol.TPraos.API | |
Eq (PredicateFailure (EraRule "TICKF" era)) ⇒ Eq (FutureLedgerViewError era) Source # | |
Defined in Cardano.Protocol.TPraos.API (==) ∷ FutureLedgerViewError era → FutureLedgerViewError era → Bool Source # (/=) ∷ FutureLedgerViewError era → FutureLedgerViewError era → Bool Source # |
Chain state operations
The chain state is an amalgam of the protocol state and the ticked nonce.
data ChainDepState c Source #
ChainDepState | |
|
Instances
newtype ChainTransitionError c Source #
Instances
∷ Globals | |
→ LedgerView c | |
→ Bool | Are we in a new epoch? |
→ ChainDepState c | |
→ ChainDepState c |
Tick the chain state to a new epoch.
updateChainDepState ∷ ∀ c m. (PraosCrypto c, MonadError (ChainTransitionError c) m) ⇒ Globals → LedgerView c → BHeader c → ChainDepState c → m (ChainDepState c) Source #
Update the chain state based upon a new block header.
This also updates the last applied block hash.
reupdateChainDepState ∷ ∀ c. PraosCrypto c ⇒ Globals → LedgerView c → BHeader c → ChainDepState c → ChainDepState c Source #
Re-update the chain state based upon a new block header.
This function does no validation of whether the header is internally valid or consistent with the chain it is being applied to; the caller must ensure that this is valid through having previously applied it.
initialChainDepState ∷ Nonce → Map (KeyHash 'Genesis c) (GenDelegPair c) → ChainDepState c Source #
Construct an initial chain state given an initial nonce and a set of genesis delegates.
checkLeaderValue ∷ ∀ v. VRFAlgorithm v ⇒ OutputVRF v → Rational → ActiveSlotCoeff → Bool Source #
Check that the certified VRF output, when used as a natural, is valid for being slot leader.
getLeaderSchedule ∷ (EraPParams era, Signable (VRF (EraCrypto era)) Seed) ⇒ Globals → NewEpochState era → ChainDepState (EraCrypto era) → KeyHash 'StakePool (EraCrypto era) → SignKeyVRF (EraCrypto era) → PParams era → Set SlotNo Source #
Get the (private) leader schedule for this epoch.
Given a private VRF key, returns the set of slots in which this node is eligible to lead.