ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.HardFork.Combinator.Abstract.CanHardFork

Synopsis

Documentation

class (All (Top ∷ Type → Constraint) xs, All SingleEraBlock xs, All (EqualHashSizeOfHead xs) xs, KnownNat (HashSizeOfHead xs), Typeable xs, IsNonEmpty xs, Measure (HardForkTxMeasurePhase1 xs), HasByteSize (HardForkTxMeasurePhase1 xs), NoThunks (HardForkTxMeasurePhase1 xs), Show (HardForkTxMeasurePhase1 xs), TxMeasurePhase1Metrics (HardForkTxMeasurePhase1 xs), Measure (HardForkTxMeasurePhase2 xs), NoThunks (HardForkTxMeasurePhase2 xs), Show (HardForkTxMeasurePhase2 xs), TxMeasurePhase2Metrics (HardForkTxMeasurePhase2 xs)) ⇒ CanHardFork (xs ∷ [Type]) where Source #

Associated Types

type HardForkTxMeasurePhase1 (xs ∷ [Type]) Source #

A measure that can accurately represent the TxMeasure of any era.

Usually, this can simply be the union of the sets of components of each individual era's TxMeasure. (Which is too awkward of a type to express in Haskell.)

type HardForkTxMeasurePhase2 (xs ∷ [Type]) Source #

Methods

hardForkEraTranslation ∷ EraTranslation xs Source #

hardForkChainSel ∷ Tails AcrossEraTiebreaker xs Source #

hardForkInjTxMeasurePhase1 ∷ NS WrapTxMeasurePhase1 xs → HardForkTxMeasurePhase1 xs Source #

This is ideally exact.

If that's not possible, the result must not be too small, since this is relied upon to determine which prefix of the mempool's txs will fit in a valid block.

hardForkInjTxMeasurePhase2 ∷ NS WrapTxMeasurePhase2 xs → HardForkTxMeasurePhase2 xs Source #

hardForkEqGenTxId ∷ NS WrapGenTxId xs → NS WrapGenTxId xs → Bool Source #

Whether two transaction ids of xs are equal, ignoring which era each sits in. Two txids in different eras can be equal; see the OneEraGenTxId Eq instance.

Runs on every mempool lookup, so instances should avoid allocation. rawHashNS is the reference implementation and allocates; the Cardano instance overrides it with an allocation-free walk. There is no class default: every instance names its body explicitly.

hardForkCompareGenTxId ∷ NS WrapGenTxId xs → NS WrapGenTxId xs → Ordering Source #

Order two transaction ids of xs. See hardForkEqGenTxId.

type family HashSizeOfHead (xs ∷ [Type]) ∷ Nat where ... Source #

The hash size shared by all eras of a hard fork, represented by that of the first era.

See EqualHashSizeOfHead superclass constraint in CanHardFork and the ConvertRawHash (HardForkBlock xs) instance.

Equations

HashSizeOfHead (x ': _1) = HashSize x 

class HashSize blk ~ HashSizeOfHead xs ⇒ EqualHashSizeOfHead (xs ∷ [Type]) blk Source #

Witnesses that the hash size of blk coincides with HashSizeOfHead of xs, i.e. with the hash size of the first era.

CanHardFork requires All (EqualHashSizeOfHead xs) xs, which statically guarantees that all eras of a hard fork use the same hash size. This lets the ConvertRawHash (HardForkBlock xs) instance enforce HashSize (HardForkBlock xs) = HashSizeOfHead xs without any runtime check.

Instances

Instances details
HashSize blk ~ HashSizeOfHead xs ⇒ EqualHashSizeOfHead xs blk Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Abstract.CanHardFork

rawHashNS ∷ ∀ (xs ∷ [Type]). All SingleEraBlock xs ⇒ NS WrapGenTxId xs → ShortByteString Source #

The raw hash of an era sum, era ignored.

The reference comparison for transaction ids. Non-optimizing CanHardFork instances implement hardForkEqGenTxId/hardForkCompareGenTxId by comparing this hash. It serialises each id via toRawTxIdHash, which allocates.