Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Current f blk = Current {
- currentStart ∷ !Bound
- currentState ∷ !(f blk)
- newtype HardForkState f xs = HardForkState {
- getHardForkState ∷ Telescope (K Past) (Current f) xs
- data Past = Past {}
- sequenceHardForkState ∷ ∀ m f xs. (All Top xs, Functor m) ⇒ HardForkState (m :.: f) xs → m (HardForkState f xs)
- newtype CrossEraForecaster state view x y = CrossEraForecaster {
- crossEraForecastWith ∷ Bound → SlotNo → state x → Except OutsideForecastRange (view y)
- data TransitionInfo
- newtype Translate f x y = Translate {
- translateWith ∷ EpochNo → f x → f y
Main types
Information about the current era
Current | |
|
Instances
Generic (Current f blk) Source # | |
Show (f blk) ⇒ Show (Current f blk) Source # | |
Eq (f blk) ⇒ Eq (Current f blk) Source # | |
NoThunks (f blk) ⇒ NoThunks (Current f blk) Source # | |
Serialise (f blk) ⇒ Serialise (Current f blk) Source # | |
type Rep (Current f blk) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types type Rep (Current f blk) = D1 ('MetaData "Current" "Ouroboros.Consensus.HardFork.Combinator.State.Types" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "Current" 'PrefixI 'True) (S1 ('MetaSel ('Just "currentStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound) :*: S1 ('MetaSel ('Just "currentState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (f blk)))) |
newtype HardForkState f xs Source #
Generic hard fork state
This is used both for the consensus state and the ledger state.
By using a telescope with f ~ LedgerState
, we will keep track of Past
information for eras before the current one:
TZ currentByronState TZ pastByronState $ TZ currentShelleyState TZ pastByronState $ TS pastShelleyState $ TZ currentAllegraState ...
These are some intuitions on how the Telescope operations behave for this type:
extend
Suppose we have a telescope containing the ledger state. The "how to extend" argument would take, say, the final Byron state to the initial Shelley state; and "where to extend from" argument would indicate when we want to extend: when the current slot number has gone past the end of the Byron era.
retract
Suppose we have a telescope containing the consensus state. When we rewind
the consensus state, we might cross a hard fork transition point. So we first
retract the telescope to the era containing the slot number that we want
to rewind to, and only then call rewindChainDepState
on that era. Of course,
retraction may fail (we might not have past consensus state to rewind to
anymore); this failure would require a choice for a particular monad m
.
align
Suppose we have one telescope containing the already-ticked ledger state, and
another telescope containing the consensus state. Since the ledger state has
already been ticked, it might have been advanced to the next era. If this
happens, we should then align the consensus state with the ledger state,
moving it also to the next era, before we can do the consensus header
validation check. Note that in this particular example, the ledger state will
always be ahead of the consensus state, never behind; alignExtend
can be
used in this case.
HardForkState | |
|
Instances
Information about a past era
Instances
Generic Past Source # | |
Show Past Source # | |
Eq Past Source # | |
NoThunks Past Source # | |
Serialise Past Source # | |
type Rep Past Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types type Rep Past = D1 ('MetaData "Past" "Ouroboros.Consensus.HardFork.Combinator.State.Types" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "Past" 'PrefixI 'True) (S1 ('MetaSel ('Just "pastStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound) :*: S1 ('MetaSel ('Just "pastEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound))) |
sequenceHardForkState ∷ ∀ m f xs. (All Top xs, Functor m) ⇒ HardForkState (m :.: f) xs → m (HardForkState f xs) Source #
Thin wrapper around sequence
Supporting types
newtype CrossEraForecaster state view x y Source #
Forecast a view y
from a state x
across an era transition.
In addition to the Bound
of the transition, this is also told the
SlotNo
we're constructing a forecast for. This enables the translation
function to take into account any scheduled changes that the final ledger
view in the preceding era might have.
CrossEraForecaster | |
|
data TransitionInfo Source #
Knowledge in a particular era of the transition to the next era
TransitionUnknown !(WithOrigin SlotNo) | No transition is yet known for this era We instead record the ledger tip (which must be in this era) NOTE: If we are forecasting, this will be set to the slot number of the
(past) ledger state in which the forecast was created. This means that
when we construct an |
TransitionKnown !EpochNo | Transition to the next era is known to happen at this |
TransitionImpossible | The transition is impossible This can be due to one of two reasons:
|