ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.HardFork.History.Summary

Synopsis

Bounds

data Bound Source #

Detailed information about the time bounds of an era

Constructors

Bound 

Fields

Instances

Instances details
Eq Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

(==) ∷ Bound → Bound → Bool #

(/=) ∷ Bound → Bound → Bool #

Generic Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Associated Types

type Rep Bound 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep Bound = D1 ('MetaData "Bound" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "Bound" 'PrefixI 'True) ((S1 ('MetaSel ('Just "boundTime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime) :*: S1 ('MetaSel ('Just "boundSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo)) :*: (S1 ('MetaSel ('Just "boundEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EpochNo) :*: S1 ('MetaSel ('Just "boundNextPerasRound") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PerasRoundNo))))

Methods

from ∷ Bound → Rep Bound x #

to ∷ Rep Bound x → Bound #

Show Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

showsPrec ∷ Int → Bound → ShowS #

show ∷ Bound → String #

showList ∷ [Bound] → ShowS #

NoThunks Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Serialise Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep Bound Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep Bound = D1 ('MetaData "Bound" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "Bound" 'PrefixI 'True) ((S1 ('MetaSel ('Just "boundTime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime) :*: S1 ('MetaSel ('Just "boundSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo)) :*: (S1 ('MetaSel ('Just "boundEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EpochNo) :*: S1 ('MetaSel ('Just "boundNextPerasRound") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PerasRoundNo))))

mkUpperBound Source #

Arguments

∷ HasCallStack 
⇒ EraParams 
→ Bound

Lower bound

→ EpochNo

Upper bound

→ Bound 

Compute upper bound given just the epoch number and era parameters

Per-era summary

data EraEnd Source #

Exclusive upper bound on the era

Constructors

EraEnd !Bound

Bounded era

EraUnbounded

Unbounded era

This arises from the use of UnsafeIndefiniteSafeZone.

Instances

Instances details
Eq EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

(==) ∷ EraEnd → EraEnd → Bool #

(/=) ∷ EraEnd → EraEnd → Bool #

Generic EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Associated Types

type Rep EraEnd 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraEnd = D1 ('MetaData "EraEnd" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EraEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound)) :+: C1 ('MetaCons "EraUnbounded" 'PrefixI 'False) (U1 ∷ Type → Type))

Methods

from ∷ EraEnd → Rep EraEnd x #

to ∷ Rep EraEnd x → EraEnd #

Show EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

showsPrec ∷ Int → EraEnd → ShowS #

show ∷ EraEnd → String #

showList ∷ [EraEnd] → ShowS #

NoThunks EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Serialise EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraEnd Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraEnd = D1 ('MetaData "EraEnd" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EraEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound)) :+: C1 ('MetaCons "EraUnbounded" 'PrefixI 'False) (U1 ∷ Type → Type))

data EraSummary Source #

Information about a specific era

The eraEnd of the final era in the summary will be determined by the safe zone considerations discussed above.

Let the start of the summary be (t, s, e) (time, slot epoch), and the end of the summary be (t', s', e'). We have one invariant relating epochs and slots:

INV-1a  e' == e + ((s' - s) / epochSize)
INV-1b: s' == s + ((e' - e) * epochSize)

And another invariant relating time and slots:

INV-2a: s' == s + ((t' - t) / slotLen)
INV-2b: t' == t + ((s' - s) * slotLen)

Note that these aren't really two sets of independent invariants. INV-1a follows from INV-1b:

      s'                   == s + ((e' - e) * epochSize)
      s' - s               ==     ((e' - e) * epochSize)
     (s' - s) / epochSize  ==       e' - e
e + ((s' - s) / epochSize) ==       e'

Similarly, INV-2a follows from INV-2b:

      t'                 == t + ((s' - s) * slotLen)
      t' - t             ==     ((s' - s) * slotLen)
     (t' - t) / slotLen  ==       s' - s
s + ((t' - t) / slotLen) ==       s'

Ouroboros Peras adds an invariant relating epoch size and Peras voting round lengths: > epochSize % perasRoundLength == 0 i.e. the round length should divide the epoch size

Constructors

EraSummary 

Fields

Instances

Instances details
Eq EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

(==) ∷ EraSummary → EraSummary → Bool #

(/=) ∷ EraSummary → EraSummary → Bool #

Generic EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Associated Types

type Rep EraSummary 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraSummary = D1 ('MetaData "EraSummary" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EraSummary" 'PrefixI 'True) (S1 ('MetaSel ('Just "eraStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound) :*: (S1 ('MetaSel ('Just "eraEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EraEnd) :*: S1 ('MetaSel ('Just "eraParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EraParams))))
Show EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

NoThunks EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Serialise EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraSummary Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

type Rep EraSummary = D1 ('MetaData "EraSummary" "Ouroboros.Consensus.HardFork.History.Summary" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EraSummary" 'PrefixI 'True) (S1 ('MetaSel ('Just "eraStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bound) :*: (S1 ('MetaSel ('Just "eraEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EraEnd) :*: S1 ('MetaSel ('Just "eraParams") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EraParams))))

mkEraEnd Source #

Arguments

∷ EraParams 
→ Bound

Lower bound

→ Maybe EpochNo

Upper bound

→ EraEnd 

Version of mkUpperBound when the upper bound may not be known

If passed Nothing, assumes EraUnbounded. This is NOT suitable for eras where the transition is simply unknown.

eraEndToBound ∷ EraEnd → Maybe Bound Source #

Convert EraEnd to 'Maybe Bound'

Overall summary

newtype Summary (xs ∷ [Type]) Source #

Summary of the confirmed part of the ledger

The summary zips Shape with Forks, and provides detailed information about the start and end of each era.

We have at most one summary for each era, and at least one

Constructors

Summary 

Instances

Instances details
Eq (Summary xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

(==) ∷ Summary xs → Summary xs → Bool #

(/=) ∷ Summary xs → Summary xs → Bool #

Show (Summary xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

showsPrec ∷ Int → Summary xs → ShowS #

show ∷ Summary xs → String #

showList ∷ [Summary xs] → ShowS #

NoThunks (Summary xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

SListI xs ⇒ Serialise (Summary xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Construction

summaryWithExactly ∷ ∀ x (xs ∷ [Type]). Exactly (x ': xs) EraSummary → Summary (x ': xs) Source #

Construct Summary with an exact number of EraSummary

Primarily useful for tests.

Summarize

newtype Shape (xs ∷ [Type]) Source #

The shape of the chain (old to new)

The shape determines how many hard forks we expect as well as the parameters for each era. The type argument is a type-level list containing one entry per era, emphasizing that this information is statically known.

The entry indices themselves are not used here, but the idea is that they look something like '[ByronBlock, ShelleyBlock, GoguenBlock] and do affect the hard fork combinator. So far this is a list of block types, since most of consensus is indexed by block types.

Constructors

Shape 

Fields

data Transitions (a ∷ [Type]) where Source #

The exact point of each confirmed hard fork transition (old to new)

Unlike the Shape of the chain, which is statically known, the Transitions are derived from the state of the ledger (hard fork transition points only become known after a voting procedure).

Any transition listed here must be "certain". How certainty is established is ledger dependent, but it should imply that this is no longer subject to rollback.

Constructors

Transitions ∷ ∀ (xs ∷ [Type]) x. AtMost xs EpochNo → Transitions (x ': xs)

If the indices are, say, '[Byron, Shelley, Goguen], then we can have have at most two transitions: one to Shelley, and one to Goguen. There cannot be a transition to the initial ledger.

Instances

Instances details
Show (Transitions xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Summary

Methods

showsPrec ∷ Int → Transitions xs → ShowS #

show ∷ Transitions xs → String #

showList ∷ [Transitions xs] → ShowS #

invariantShape ∷ ∀ (xs ∷ [Type]). Shape xs → Except String () Source #

Check Shape invariants

The only part of the Shape that must make sense is the safeBeforeEpoch values (they must be strictly increasing).

NOTE: We assume eras cannot be empty. This will be satisfied by any ledger we are interested in since transitions must be voted on (safe zones will be non-empty).

invariantSummary ∷ ∀ (xs ∷ [Type]). Summary xs → Except String () Source #

Check Summary invariants

singletonShape ∷ EraParams → Shape '[x] Source #

There is only one era

summarize Source #

Arguments

∷ ∀ (xs ∷ [Type]). WithOrigin SlotNo

Slot at the tip of the ledger

→ Shape xs 
→ Transitions xs 
→ Summary xs 

Construct hard fork Summary

NOTE (on epoch to slot translation). In order to translate SlotNo to EpochNo, we simply "line up" all slots. For example, suppose we have an initial EpochSize of 10, and then an EpochSize of 20 from EpochNo 3 onwards. We end up with something like

Epoch | 0      | 1        | 2        | 3        | 4        | ..
Slot  | 0 .. 9 | 10 .. 19 | 20 .. 29 | 30 .. 49 | 50 .. 69 | ..

We do this translation independent from the minimumPossibleSlotNo for a particular ledger. This means that for ledgers where the minimumPossibleSlotNo is not zero (e.g., some ledgers might set it to 1), the maximum number of blocks (aka filled slots) in an epoch is just 1 (or more) less than the other epochs.

transitionsUnknown ∷ ∀ x (xs ∷ [Type]). Transitions (x ': xs) Source #

No known transitions yet

Query

summaryBounds ∷ ∀ (xs ∷ [Type]). Summary xs → (Bound, EraEnd) Source #

Outer bounds of the summary

summaryPerasBounds ∷ ∀ (xs ∷ [Type]). Summary xs → PerasEnabled (PerasRoundNo, Maybe PerasRoundNo) Source #

Outer bounds of the summary for PerasRoundNo specifically.

Returns NoPerasEnabled if no era in the summary has Peras enabled.

Returns 'PerasEnabled (lo, mbHi)' if at least one era in the summary has Peras enabled, where: - lo is the lower bound of the first era with Peras enabled - mbHi is the upper bound of the last era with Peras enabled, or Nothing if the last era with PerasEnabled is unbounded.

summaryInit ∷ ∀ (xs ∷ [Type]). Summary xs → (Maybe (Summary xs), EraSummary) Source #

Analogue of init for Summary (i.e., split off the final era)

This is primarily useful for tests.