Safe Haskell  None 

Language  Haskell2010 
Synopsis
 data Bound = Bound {}
 initBound ∷ Bound
 mkUpperBound ∷ HasCallStack ⇒ EraParams → Bound → EpochNo → Bound
 slotToEpochBound ∷ EraParams → Bound → SlotNo → EpochNo
 data EraEnd
 = EraEnd !Bound
  EraUnbounded
 data EraSummary = EraSummary {}
 mkEraEnd ∷ EraParams → Bound → Maybe EpochNo → EraEnd
 newtype Summary xs = Summary {
 getSummary ∷ NonEmpty xs EraSummary
 neverForksSummary ∷ EpochSize → SlotLength → Summary '[x]
 summaryWithExactly ∷ Exactly (x ': xs) EraSummary → Summary (x ': xs)
 newtype Shape xs = Shape {}
 data Transitions ∷ [Type] → Type where
 Transitions ∷ AtMost xs EpochNo → Transitions (x ': xs)
 invariantShape ∷ Shape xs → Except String ()
 invariantSummary ∷ Summary xs → Except String ()
 singletonShape ∷ EraParams → Shape '[x]
 summarize ∷ WithOrigin SlotNo → Shape xs → Transitions xs → Summary xs
 transitionsUnknown ∷ Transitions (x ': xs)
 summaryBounds ∷ Summary xs → (Bound, EraEnd)
 summaryInit ∷ Summary xs → (Maybe (Summary xs), EraSummary)
Bounds
Detailed information about the time bounds of an era
Bound  

Instances
Eq Bound Source #  
Show Bound Source #  
Generic Bound Source #  
Serialise Bound Source #  
Defined in Ouroboros.Consensus.HardFork.History.Summary  
NoThunks Bound Source #  
type Rep Bound Source #  
Defined in Ouroboros.Consensus.HardFork.History.Summary type Rep Bound = D1 ('MetaData "Bound" "Ouroboros.Consensus.HardFork.History.Summary" "ouroborosconsensus0.3.1.0inplace" '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)))) 
∷ HasCallStack  
⇒ EraParams  
→ Bound  Lower bound 
→ EpochNo  Upper bound 
→ Bound 
Compute upper bound given just the epoch number and era parameters
Perera summary
Exclusive upper bound on the era
EraEnd !Bound  Bounded era 
EraUnbounded  Unbounded era This arises from the use of 
Instances
Eq EraEnd Source #  
Show EraEnd Source #  
Generic EraEnd Source #  
Serialise EraEnd Source #  
Defined in Ouroboros.Consensus.HardFork.History.Summary  
NoThunks EraEnd Source #  
type Rep EraEnd Source #  
Defined in Ouroboros.Consensus.HardFork.History.Summary type Rep EraEnd = D1 ('MetaData "EraEnd" "Ouroboros.Consensus.HardFork.History.Summary" "ouroborosconsensus0.3.1.0inplace" '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:
INV1a e' == e + ((s'  s) / epochSize) INV1b: s' == s + ((e'  e) * epochSize)
And another invariant relating time and slots:
INV2a: s' == s + ((t'  t) / slotLen) INV2b: t' == t + ((s'  s) * slotLen)
Note that these aren't really two sets of independent invariants. INV1a
follows from INV1b
:
s' == s + ((e'  e) * epochSize) s'  s == ((e'  e) * epochSize) (s'  s) / epochSize == e'  e e + ((s'  s) / epochSize) == e'
Similarly, INV2a
follows from INV2b
:
t' == t + ((s'  s) * slotLen) t'  t == ((s'  s) * slotLen) (t'  t) / slotLen == s'  s s + ((t'  t) / slotLen) == s'
Instances
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.
Overall summary
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
Construction
neverForksSummary ∷ EpochSize → SlotLength → Summary '[x] Source #
Summary
for a ledger that never forks
summaryWithExactly ∷ Exactly (x ': xs) EraSummary → Summary (x ': xs) Source #
Construct Summary
with an exact number of EraSummary
Primarily useful for tests.
Summarize
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 typelevel 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.
data Transitions ∷ [Type] → 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.
Transitions ∷ AtMost xs EpochNo → Transitions (x ': xs)  If the indices are, say, 
Instances
Show (Transitions xs) Source #  
Defined in Ouroboros.Consensus.HardFork.History.Summary 
singletonShape ∷ EraParams → Shape '[x] Source #
There is only one era
∷ 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 ∷ Transitions (x ': xs) Source #
No known transitions yet
Query
summaryInit ∷ Summary xs → (Maybe (Summary xs), EraSummary) Source #