Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.HardFork.Combinator.State.Types
Contents
Synopsis
- data Current (f ∷ Type → Type) blk = Current {
- currentStart ∷ !Bound
- currentState ∷ !(f blk)
- newtype HardForkState (f ∷ Type → Type) (xs ∷ [Type]) = HardForkState {}
- data Past = Past {}
- sequenceHardForkState ∷ ∀ m (f ∷ Type → Type) (xs ∷ [Type]). (All (Top ∷ Type → Constraint) xs, Functor m) ⇒ HardForkState (m :.: f) xs → m (HardForkState f xs)
- newtype CrossEraForecaster (state ∷ Type → (Type → Type → Type) → Type) (view ∷ Type → Type) x y = CrossEraForecaster {
- crossEraForecastWith ∷ Bound → SlotNo → state x EmptyMK → Except OutsideForecastRange (view y)
- data TransitionInfo
- newtype Translate (f ∷ Type → Type) x y = Translate {
- translateWith ∷ EpochNo → f x → f y
- newtype TranslateLedgerState x y = TranslateLedgerState {}
- data TranslateLedgerTables x y = TranslateLedgerTables {
- translateTxInWith ∷ !(TxIn (LedgerState x) → TxIn (LedgerState y))
- translateTxOutWith ∷ !(TxOut (LedgerState x) → TxOut (LedgerState y))
- newtype TranslateTxOut x y = TranslateTxOut (TxOut (LedgerState x) → TxOut (LedgerState y))
- translateLedgerTablesWith ∷ Ord (TxIn (LedgerState y)) ⇒ TranslateLedgerTables x y → LedgerTables (LedgerState x) DiffMK → LedgerTables (LedgerState y) DiffMK
Main types
data Current (f ∷ Type → Type) blk Source #
Information about the current era
Constructors
Current | |
Fields
|
Instances
newtype HardForkState (f ∷ Type → Type) (xs ∷ [Type]) 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.
Constructors
HardForkState | |
Instances
HAp HardForkState Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods hap ∷ ∀ (f ∷ Type → Type) (g ∷ Type → Type) (xs ∷ [Type]). Prod HardForkState (f -.-> g) xs → HardForkState f xs → HardForkState g xs Source # | |||||
HCollapse HardForkState Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods hcollapse ∷ ∀ (xs ∷ [Type]) a. SListIN HardForkState xs ⇒ HardForkState (K a ∷ Type → Type) xs → CollapseTo HardForkState a Source # | |||||
HSequence HardForkState Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods hsequence' ∷ ∀ (xs ∷ [Type]) f (g ∷ Type → Type). (SListIN HardForkState xs, Applicative f) ⇒ HardForkState (f :.: g) xs → f (HardForkState g xs) Source # hctraverse' ∷ ∀ c (xs ∷ [Type]) g proxy f f'. (AllN HardForkState c xs, Applicative g) ⇒ proxy c → (∀ a. c a ⇒ f a → g (f' a)) → HardForkState f xs → g (HardForkState f' xs) Source # htraverse' ∷ ∀ (xs ∷ [Type]) g f f'. (SListIN HardForkState xs, Applicative g) ⇒ (∀ a. f a → g (f' a)) → HardForkState f xs → g (HardForkState f' xs) Source # | |||||
HTrans HardForkState HardForkState Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods htrans ∷ ∀ c (xs ∷ [Type]) (ys ∷ [Type]) proxy f g. AllZipN (Prod HardForkState) c xs ys ⇒ proxy c → (∀ x y. c x y ⇒ f x → g y) → HardForkState f xs → HardForkState g ys Source # hcoerce ∷ ∀ (f ∷ Type → Type) (g ∷ Type → Type) (xs ∷ [Type]) (ys ∷ [Type]). AllZipN (Prod HardForkState) (LiftedCoercible f g) xs ys ⇒ HardForkState f xs → HardForkState g ys Source # | |||||
SerialiseHFC xs ⇒ DecodeDisk (HardForkBlock xs) (HardForkChainDepState xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseDisk Methods decodeDisk ∷ CodecConfig (HardForkBlock xs) → ∀ s. Decoder s (HardForkChainDepState xs) Source # | |||||
SerialiseHFC xs ⇒ EncodeDisk (HardForkBlock xs) (HardForkChainDepState xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseDisk Methods encodeDisk ∷ CodecConfig (HardForkBlock xs) → HardForkChainDepState xs → Encoding Source # | |||||
Generic (HardForkState f xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types Associated Types
Methods from ∷ HardForkState f xs → Rep (HardForkState f xs) x # to ∷ Rep (HardForkState f xs) x → HardForkState f xs # | |||||
(All SingleEraBlock xs, ∀ blk. SingleEraBlock blk ⇒ Show (f blk)) ⇒ Show (HardForkState f xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods showsPrec ∷ Int → HardForkState f xs → ShowS # show ∷ HardForkState f xs → String # showList ∷ [HardForkState f xs] → ShowS # | |||||
(All SingleEraBlock xs, ∀ blk. SingleEraBlock blk ⇒ Eq (f blk)) ⇒ Eq (HardForkState f xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Instances Methods (==) ∷ HardForkState f xs → HardForkState f xs → Bool # (/=) ∷ HardForkState f xs → HardForkState f xs → Bool # | |||||
(All SingleEraBlock xs, ∀ blk. SingleEraBlock blk ⇒ NoThunks (f blk)) ⇒ NoThunks (HardForkState f xs) Source # | |||||
data Ticked (HardForkChainDepState xs ∷ Type) Source # | |||||
type Prod HardForkState Source # | |||||
type SListIN HardForkState Source # | |||||
type CollapseTo HardForkState a Source # | |||||
type AllN HardForkState (c ∷ Type → Constraint) Source # | |||||
type Same HardForkState Source # | |||||
type Rep (HardForkState f xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types type Rep (HardForkState f xs) = D1 ('MetaData "HardForkState" "Ouroboros.Consensus.HardFork.Combinator.State.Types" "ouroboros-consensus-0.25.0.0-inplace" 'True) (C1 ('MetaCons "HardForkState" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHardForkState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Telescope (K Past ∷ Type → Type) (Current f) xs)))) |
Information about a past era
Instances
Generic Past Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types Associated Types
| |||||
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.25.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 ∷ Type → Type) (xs ∷ [Type]). (All (Top ∷ Type → Constraint) xs, Functor m) ⇒ HardForkState (m :.: f) xs → m (HardForkState f xs) Source #
Thin wrapper around sequence
Supporting types
newtype CrossEraForecaster (state ∷ Type → (Type → Type → Type) → Type) (view ∷ Type → Type) 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.
Constructors
CrossEraForecaster | |
Fields
|
data TransitionInfo Source #
Knowledge in a particular era of the transition to the next era
Constructors
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:
|
Instances
Generic TransitionInfo Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types Associated Types
| |||||
Show TransitionInfo Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types Methods showsPrec ∷ Int → TransitionInfo → ShowS # show ∷ TransitionInfo → String # showList ∷ [TransitionInfo] → ShowS # | |||||
NoThunks TransitionInfo Source # | |||||
type Rep TransitionInfo Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.State.Types type Rep TransitionInfo = D1 ('MetaData "TransitionInfo" "Ouroboros.Consensus.HardFork.Combinator.State.Types" "ouroboros-consensus-0.25.0.0-inplace" 'False) (C1 ('MetaCons "TransitionUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (WithOrigin SlotNo))) :+: (C1 ('MetaCons "TransitionKnown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EpochNo)) :+: C1 ('MetaCons "TransitionImpossible" 'PrefixI 'False) (U1 ∷ Type → Type))) |
newtype Translate (f ∷ Type → Type) x y Source #
Translate f x
to f y
across an era transition
Typically f
will be LedgerState
or WrapChainDepState
.
Constructors
Translate | |
Fields
|
newtype TranslateLedgerState x y Source #
Translate a LedgerState
across an era transition.
Constructors
TranslateLedgerState | |
Fields
|
data TranslateLedgerTables x y Source #
Transate a LedgerTables
across an era transition.
Constructors
TranslateLedgerTables | |
Fields
|
newtype TranslateTxOut x y Source #
Constructors
TranslateTxOut (TxOut (LedgerState x) → TxOut (LedgerState y)) |
translateLedgerTablesWith ∷ Ord (TxIn (LedgerState y)) ⇒ TranslateLedgerTables x y → LedgerTables (LedgerState x) DiffMK → LedgerTables (LedgerState y) DiffMK Source #
Translate a LedgerTables
across an era transition.
To translate LedgerTable
s, it's sufficient to know how to translate
TxIn
s and TxOut
s. Use translateLedgerTablesWith
to translate
LedgerTable
s using translateTxInWith
and translateTxOutWith
.
This is a rather technical subtlety. When performing a ledger state
translation, the provided input ledger state will be initially populated with
a emptyLedgerTables
. This step is required so that the operation provided
to extend
is an automorphism.
If we only extend by one era, this function is a no-op, as the input will be empty ledger states. However, if we extend across multiple eras, previous eras might populate tables thus creating values that now need to be translated to newer eras. This function fills that hole and allows us to promote tables from one era into tables from the next era.
NOTE: If either translateTxInWith
or translateTxOutWith
is a no-op (id
),
mapping over the diff with those functions is also equivalent to a
no-op. However, we are still traversing the map in both cases.
NOTE: This function is only used on ticking, to prepend differences from
previous eras, so it will be called only when crossing era boundaries,
therefore the translation won't be equivalent to id
.