ouroboros-consensus-0.1.0.2: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
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

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 EraNodeToNodeVersion) xs, All (Compose Eq EraNodeToNodeVersion) xs, All (Compose Show EraNodeToClientVersion) xs, All (Compose Eq EraNodeToClientVersion) 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

Methods

encodeDiskHfcBlockCodecConfig (HardForkBlock xs) → HardForkBlock xs → Encoding Source #

decodeDiskHfcBlockCodecConfig (HardForkBlock xs) → ∀ s. Decoder s (ByteStringHardForkBlock xs) Source #

reconstructHfcPrefixLen ∷ proxy (Header (HardForkBlock xs)) → PrefixLen Source #

Used as the implementation of reconstructPrefixLen for HardForkBlock.

reconstructHfcNestedCtxt Source #

Arguments

∷ proxy (Header (HardForkBlock xs)) 
ShortByteString

First bytes (reconstructPrefixLen) of the block

SizeInBytes

Block size

SomeSecond (NestedCtxt Header) (HardForkBlock xs) 

Used as the implementation of reconstructNestedCtxt for HardForkBlock.

getHfcBinaryBlockInfoHardForkBlock xs → BinaryBlockInfo Source #

Used as the implementation of getBinaryBlockInfo for HardForkBlock.

estimateHfcBlockSizeHeader (HardForkBlock xs) → SizeInBytes Source #

Used as the implementation of estimateBlockSize for HardForkBlock.

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 EraNodeToNodeVersion xs → HardForkNodeToNodeVersion xs

Enable the HFC

Each era can be enabled or disabled individually by passing EraNodeToNodeDisabled as its configuration, but serialised values will always include tags inserted by the HFC to distinguish one era from another. We also 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

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

Show 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

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

Show 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

decodeTelescopeNP (Decoder s :.: f) xs → Decoder s (HardForkState f xs) Source #

encodeTelescopeSListI xs ⇒ NP (f -.-> K Encoding) xs → HardForkState f xs → Encoding Source #

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

decodeNestedAll (DecodeDiskDep (NestedCtxt f)) xs ⇒ CodecConfig (HardForkBlock xs) → NestedCtxt f (HardForkBlock xs) a → ∀ s. Decoder s (ByteString → a) Source #

encodeNestedAll (EncodeDiskDep (NestedCtxt f)) xs ⇒ CodecConfig (HardForkBlock xs) → NestedCtxt f (HardForkBlock xs) a → a → Encoding Source #

MismatchEraInfo

decodeEitherMismatchSListI xs ⇒ BlockNodeToClientVersion (HardForkBlock xs) → Decoder s a → Decoder s (Either (MismatchEraInfo xs) a) Source #

encodeEitherMismatch ∷ ∀ xs a. SListI xs ⇒ BlockNodeToClientVersion (HardForkBlock xs) → (a → Encoding) → Either (MismatchEraInfo xs) a → Encoding Source #

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

Instances

Instances details
All (Compose Serialise f) xs ⇒ Serialise (SerialiseNS f xs) Source # 
Instance details

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

Methods

encodeSerialiseNS f xs → Encoding

decode ∷ Decoder s (SerialiseNS f xs)

encodeList ∷ [SerialiseNS f xs] → Encoding

decodeList ∷ Decoder s [SerialiseNS f xs]

Orphan instances