ouroboros-consensus-0.21.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Synopsis

Conditions required by the HFC to support serialisation

data HardForkEncoderException where Source #

Exception thrown in the HFC encoders

Constructors

HardForkEncoderFutureEraSingleEraInfo blk → HardForkEncoderException

HFC disabled, but we saw a value from an era other than the first

HardForkEncoderDisabledEraSingleEraInfo blk → HardForkEncoderException

HFC enabled, but we saw a value from a disabled era

This is only thrown by the Node-to-Client codec. Two nodes' negotiated version does not constrain how the distributed chain will evolve, so the Node-to-Node communication does not need this. The MaxMajorProtVer check will enforce it appropriately and incur explanatory log messages on the node that needs to be updated in order to handle the latest hard fork.

See HardForkNodeToClientEnabled for the use case.

HardForkEncoderQueryHfcDisabledHardForkEncoderException

HFC disabled, but we saw a query that is only supported by the HFC

HardForkEncoderQueryWrongVersionHardForkEncoderException

HFC enabled, but we saw a HFC query that is not supported by the HFC-specific version used

class (CanHardFork xs, All SerialiseConstraintsHFC xs, All (Compose Show EraNodeToClientVersion) xs, All (Compose Eq EraNodeToClientVersion) xs, All (Compose Show WrapNodeToNodeVersion) xs, All (Compose Eq WrapNodeToNodeVersion) xs, All (EncodeDiskDepIx (NestedCtxt Header)) xs, All (DecodeDiskDepIx (NestedCtxt Header)) xs, All HasBinaryBlockInfo xs) ⇒ SerialiseHFC xs where Source #

Conditions required by the HFC to provide serialisation

NOTE: Compatibility between HFC enabled and disabled:

  1. Node-to-node and node-to-client communication is versioned. When the HFC is disabled, we default to the instances for the first era, and so compatibility is preserved by construction.
  2. On-disk storage is not versioned, and here we make no attempt to be compatible between non-HFC and HFC deployments, except for blocks: we define two methods encodeDiskHfcBlock and decodeDiskHfcBlock which are used for on-disk serialisation of blocks. These methods have defaults which can and probably should be used for deployments that use the HFC from the get-go, but for deployments that only later change to use the HFC these functions can be overriden to provide an on-disk storage format for HFC blocks that is compatible with the on-disk storage of blocks from the first era.
  3. The converse is NOT supported. Deployments that use the HFC from the start should not use HardForkNodeToNodeDisabled and/or HardForkNodeToClientDisabled. Doing so would result in opposite compatibility problems: the on-disk block would include the HFC tag, but sending blocks with the HFC disabled suggests that that tag is unexpected. This would then lead to problems with binary streaming, and we do not currently provide any provisions to resolve these.

Minimal complete definition

Nothing

Distinguish first era from the rest

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

Equations

FirstEra (x ': xs) = x 

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

Equations

LaterEra (x ': xs) = xs 

isFirstEra ∷ ∀ f xs. All SingleEraBlock xs ⇒ NS f xs → Either (NS SingleEraInfo (LaterEra xs)) (f (FirstEra xs)) Source #

notFirstEra Source #

Arguments

All SingleEraBlock xs 
NS f xs

NS intended to be from a future era

NS SingleEraInfo xs 

Used to construct FutureEraException

Versioning

data HardForkNodeToNodeVersion xs where Source #

Constructors

HardForkNodeToNodeDisabledBlockNodeToNodeVersion x → HardForkNodeToNodeVersion (x ': xs)

Disable the HFC

This means that only the first era (x) is supported, and moreover, is compatible with serialisation used if the HFC would not be present at all.

HardForkNodeToNodeEnabledHardForkSpecificNodeToNodeVersionNP WrapNodeToNodeVersion xs → HardForkNodeToNodeVersion xs

Enable the HFC

Serialised values will always include tags inserted by the HFC to distinguish one era from another. We version the hard-fork specific parts with HardForkSpecificNodeToNodeVersion.

data HardForkSpecificNodeToClientVersion Source #

Versioning of the specific additions made by the HFC to the NodeToClient protocols, e.g., the era tag or the hard-fork specific queries.

Instances

Instances details
Bounded HardForkSpecificNodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Enum HardForkSpecificNodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Show HardForkSpecificNodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Eq HardForkSpecificNodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Ord HardForkSpecificNodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

data HardForkSpecificNodeToNodeVersion Source #

Versioning of the specific additions made by the HFC to the NodeToNode protocols, e.g., the era tag.

Instances

Instances details
Bounded HardForkSpecificNodeToNodeVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Enum HardForkSpecificNodeToNodeVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Show HardForkSpecificNodeToNodeVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Eq HardForkSpecificNodeToNodeVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Ord HardForkSpecificNodeToNodeVersion Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Dealing with annotations

data AnnDecoder f blk Source #

Constructors

AnnDecoder 

Fields

Serialisation of telescopes

Serialisation of sums

decodeAnnNSSListI xs ⇒ NP (AnnDecoder f) xs → ∀ s. Decoder s (ByteStringNS f xs) Source #

decodeNSSListI xs ⇒ NP (Decoder s :.: f) xs → Decoder s (NS f xs) Source #

encodeNSSListI xs ⇒ NP (f -.-> K Encoding) xs → NS f xs → Encoding Source #

Dependent serialisation

MismatchEraInfo

Distributive properties

Deriving-via support for tests

newtype SerialiseNS f xs Source #

Used for deriving via

Example

deriving via SerialiseNS Header SomeEras
         instance Serialise (Header SomeSecond)

Constructors

SerialiseNS 

Fields

Orphan instances