ouroboros-consensus-0.26.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.HardFork.Combinator.State

Description

Intended for qualified import

import Ouroboros.Consensus.HardFork.Combinator.State (HardForkState(..))
import qualified Ouroboros.Consensus.HardFork.Combinator.State as State
Synopsis

Documentation

Support for defining instances

getTip ∷ ∀ f (xs ∷ [Type]). CanHardFork xs ⇒ (∀ blk. SingleEraBlock blk ⇒ f blk → Point blk) → HardForkState f xs → Point (HardForkBlock xs) Source #

Serialisation support

recover ∷ ∀ (f ∷ TypeType) (xs ∷ [Type]). CanHardFork xs ⇒ Telescope (K PastTypeType) f xs → HardForkState f xs Source #

Recover HardForkState from partial information

The primary goal of this is to make sure that for the current state we really only need to store the underlying f. It is not strictly essential that this is possible but it helps with the unary hardfork case, and it may in general help with binary compatibility.

EpochInfo

epochInfoLedger ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → EpochInfo (Except PastHorizonException) Source #

Construct EpochInfo from the ledger state

NOTE: The resulting EpochInfo is a snapshot only, with a limited range. It should not be stored.

epochInfoPrecomputedTransitionInfo ∷ ∀ (xs ∷ [Type]) (f ∷ TypeType). Shape xs → TransitionInfoHardForkState f xs → EpochInfo (Except PastHorizonException) Source #

Construct EpochInfo given precomputed TransitionInfo

The transition and state arguments are acquired either from a ticked ledger state or a ledger view.

Ledger specific functionality

extendToSlot ∷ ∀ (xs ∷ [Type]). CanHardFork xs ⇒ HardForkLedgerConfig xs → SlotNoHardForkState (Flip LedgerState EmptyMK) xs → HardForkState (Flip LedgerState DiffMK) xs Source #

Extend the telescope until the specified slot is within the era at the tip.

Note that transitioning to a later era might create new values in the ledger tables, therefore the result of this function is a DiffMK.

If we are crossing no era boundaries, this whole function is a no-op that only creates an empty DiffMK, because the Telescope.extend function will do nothing.

If we are crossing one era boundary, the ledger tables might be populated with whatever translateLedgerStateWith returns.

If we are crossing multiple era boundaries, the diffs generated when crossing an era boundary will be prepended to the ones produced by later era boundaries and, in order to all match the resulting era, they will be translated to later eras.

This means in particular that if we extend from era1 to era3 going through era2, we will:

  1. translate the ledger state from era1 to era2, which produces a era2 ledger state together with a some set of differences.
  2. keep the era2 diffs aside, and translate the era2 ledger state without ledger tables, which produces a era3 ledger state together with a set of era3 differences.
  3. Translate the era2 diffs to era3 differences, and prepend them to the ones created in the step 2.
  4. Attach the diffs resulting from step 3 to the era3 ledger state from step 2, and return it.