Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data HardForkEncoderException where
- class ( SingleEraBlock blk, SerialiseDiskConstraints blk, SerialiseNodeToNodeConstraints blk, SerialiseNodeToClientConstraints blk, HasNetworkProtocolVersion blk) => SerialiseConstraintsHFC blk
-
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
- encodeDiskHfcBlock :: CodecConfig ( HardForkBlock xs) -> HardForkBlock xs -> Encoding
- decodeDiskHfcBlock :: CodecConfig ( HardForkBlock xs) -> forall s. Decoder s ( ByteString -> HardForkBlock xs)
- reconstructHfcPrefixLen :: proxy ( Header ( HardForkBlock xs)) -> PrefixLen
- reconstructHfcNestedCtxt :: proxy ( Header ( HardForkBlock xs)) -> ShortByteString -> SizeInBytes -> SomeSecond ( NestedCtxt Header ) ( HardForkBlock xs)
- getHfcBinaryBlockInfo :: HardForkBlock xs -> BinaryBlockInfo
- estimateHfcBlockSize :: Header ( HardForkBlock xs) -> SizeInBytes
- disabledEraException :: forall blk. SingleEraBlock blk => Proxy blk -> HardForkEncoderException
- futureEraException :: SListI xs => NS SingleEraInfo xs -> HardForkEncoderException
- pSHFC :: Proxy SerialiseConstraintsHFC
- type family FirstEra (xs :: [ Type ]) where ...
- type family LaterEra (xs :: [ Type ]) where ...
- isFirstEra :: forall f xs. All SingleEraBlock xs => NS f xs -> Either ( NS SingleEraInfo ( LaterEra xs)) (f ( FirstEra xs))
- notFirstEra :: All SingleEraBlock xs => NS f xs -> NS SingleEraInfo xs
- data EraNodeToClientVersion blk
- data EraNodeToNodeVersion blk
- data HardForkNodeToClientVersion xs where
- data HardForkNodeToNodeVersion xs where
- data HardForkSpecificNodeToClientVersion
- data HardForkSpecificNodeToNodeVersion = HardForkSpecificNodeToNodeVersion1
- isHardForkNodeToClientEnabled :: HardForkNodeToClientVersion xs -> Bool
- isHardForkNodeToNodeEnabled :: HardForkNodeToNodeVersion xs -> Bool
-
data
AnnDecoder
f blk =
AnnDecoder
{
- annDecoder :: forall s. Decoder s ( ByteString -> f blk)
- decodeTelescope :: NP ( Decoder s :.: f) xs -> Decoder s ( HardForkState f xs)
- encodeTelescope :: SListI xs => NP (f -.-> K Encoding ) xs -> HardForkState f xs -> Encoding
- decodeAnnNS :: SListI xs => NP ( AnnDecoder f) xs -> forall s. Decoder s ( ByteString -> NS f xs)
- decodeNS :: SListI xs => NP ( Decoder s :.: f) xs -> Decoder s ( NS f xs)
- encodeNS :: SListI xs => NP (f -.-> K Encoding ) xs -> NS f xs -> Encoding
- decodeNested :: All ( DecodeDiskDep ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> NestedCtxt f ( HardForkBlock xs) a -> forall s. Decoder s ( ByteString -> a)
- decodeNestedCtxt :: All ( DecodeDiskDepIx ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> forall s. Decoder s ( SomeSecond ( NestedCtxt f) ( HardForkBlock xs))
- encodeNested :: All ( EncodeDiskDep ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> NestedCtxt f ( HardForkBlock xs) a -> a -> Encoding
- encodeNestedCtxt :: All ( EncodeDiskDepIx ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> SomeSecond ( NestedCtxt f) ( HardForkBlock xs) -> Encoding
- decodeEitherMismatch :: SListI xs => BlockNodeToClientVersion ( HardForkBlock xs) -> Decoder s a -> Decoder s ( Either ( MismatchEraInfo xs) a)
- encodeEitherMismatch :: forall xs a. SListI xs => BlockNodeToClientVersion ( HardForkBlock xs) -> (a -> Encoding ) -> Either ( MismatchEraInfo xs) a -> Encoding
- distribAnnTip :: SListI xs => AnnTip ( HardForkBlock xs) -> NS AnnTip xs
- distribQueryIfCurrent :: Some ( QueryIfCurrent xs) -> NS ( SomeSecond BlockQuery ) xs
- distribSerialisedHeader :: SerialisedHeader ( HardForkBlock xs) -> NS SerialisedHeader xs
- undistribAnnTip :: SListI xs => NS AnnTip xs -> AnnTip ( HardForkBlock xs)
- undistribQueryIfCurrent :: NS ( SomeSecond BlockQuery ) xs -> Some ( QueryIfCurrent xs)
- undistribSerialisedHeader :: NS SerialisedHeader xs -> SerialisedHeader ( HardForkBlock xs)
-
newtype
SerialiseNS
f xs =
SerialiseNS
{
- getSerialiseNS :: NS f xs
Conditions required by the HFC to support serialisation
data HardForkEncoderException where Source #
Exception thrown in the HFC encoders
HardForkEncoderFutureEra :: SingleEraInfo blk -> HardForkEncoderException |
HFC disabled, but we saw a value from an era other than the first |
HardForkEncoderDisabledEra :: SingleEraInfo blk -> HardForkEncoderException |
HFC enabled, but we saw a value from a disabled era |
HardForkEncoderQueryHfcDisabled :: HardForkEncoderException |
HFC disabled, but we saw a query that is only supported by the HFC |
HardForkEncoderQueryWrongVersion :: HardForkEncoderException |
HFC enabled, but we saw a HFC query that is not supported by the HFC-specific version used |
class ( SingleEraBlock blk, SerialiseDiskConstraints blk, SerialiseNodeToNodeConstraints blk, SerialiseNodeToClientConstraints blk, HasNetworkProtocolVersion blk) => SerialiseConstraintsHFC blk Source #
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:
- 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.
-
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
anddecodeDiskHfcBlock
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. -
The converse is NOT supported. Deployments that use the HFC from the start
should not use
HardForkNodeToNodeDisabled
and/orHardForkNodeToClientDisabled
. 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.
Nothing
encodeDiskHfcBlock :: CodecConfig ( HardForkBlock xs) -> HardForkBlock xs -> Encoding Source #
decodeDiskHfcBlock :: CodecConfig ( HardForkBlock xs) -> forall s. Decoder s ( ByteString -> HardForkBlock xs) Source #
reconstructHfcPrefixLen :: proxy ( Header ( HardForkBlock xs)) -> PrefixLen Source #
Used as the implementation of
reconstructPrefixLen
for
HardForkBlock
.
reconstructHfcNestedCtxt Source #
:: proxy ( Header ( HardForkBlock xs)) | |
-> ShortByteString |
First bytes (
|
-> SizeInBytes |
Block size |
-> SomeSecond ( NestedCtxt Header ) ( HardForkBlock xs) |
Used as the implementation of
reconstructNestedCtxt
for
HardForkBlock
.
getHfcBinaryBlockInfo :: HardForkBlock xs -> BinaryBlockInfo Source #
Used as the implementation of
getBinaryBlockInfo
for
HardForkBlock
.
estimateHfcBlockSize :: Header ( HardForkBlock xs) -> SizeInBytes Source #
Used as the implementation of
estimateBlockSize
for
HardForkBlock
.
disabledEraException :: forall blk. SingleEraBlock blk => Proxy blk -> HardForkEncoderException Source #
futureEraException :: SListI xs => NS SingleEraInfo xs -> HardForkEncoderException Source #
Distinguish first era from the rest
isFirstEra :: forall f xs. All SingleEraBlock xs => NS f xs -> Either ( NS SingleEraInfo ( LaterEra xs)) (f ( FirstEra xs)) Source #
:: All SingleEraBlock xs | |
=> NS f xs |
|
-> NS SingleEraInfo xs |
Used to construct
FutureEraException
Versioning
data EraNodeToClientVersion blk Source #
Instances
Eq ( BlockNodeToClientVersion blk) => Eq ( EraNodeToClientVersion blk) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common (==) :: EraNodeToClientVersion blk -> EraNodeToClientVersion blk -> Bool Source # (/=) :: EraNodeToClientVersion blk -> EraNodeToClientVersion blk -> Bool Source # |
|
Show ( BlockNodeToClientVersion blk) => Show ( EraNodeToClientVersion blk) Source # | |
data EraNodeToNodeVersion blk Source #
Instances
Eq ( BlockNodeToNodeVersion blk) => Eq ( EraNodeToNodeVersion blk) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common (==) :: EraNodeToNodeVersion blk -> EraNodeToNodeVersion blk -> Bool Source # (/=) :: EraNodeToNodeVersion blk -> EraNodeToNodeVersion blk -> Bool Source # |
|
Show ( BlockNodeToNodeVersion blk) => Show ( EraNodeToNodeVersion blk) Source # | |
data HardForkNodeToClientVersion xs where Source #
HardForkNodeToClientDisabled :: BlockNodeToClientVersion x -> HardForkNodeToClientVersion (x ': xs) |
Disable the HFC |
HardForkNodeToClientEnabled :: HardForkSpecificNodeToClientVersion -> NP EraNodeToClientVersion xs -> HardForkNodeToClientVersion xs |
Enable the HFC |
Instances
SerialiseHFC xs => Eq ( HardForkNodeToClientVersion xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common (==) :: HardForkNodeToClientVersion xs -> HardForkNodeToClientVersion xs -> Bool Source # (/=) :: HardForkNodeToClientVersion xs -> HardForkNodeToClientVersion xs -> Bool Source # |
|
SerialiseHFC xs => Show ( HardForkNodeToClientVersion xs) Source # | |
data HardForkNodeToNodeVersion xs where Source #
HardForkNodeToNodeDisabled :: BlockNodeToNodeVersion x -> HardForkNodeToNodeVersion (x ': xs) |
Disable the HFC
This means that only the first era (
|
HardForkNodeToNodeEnabled :: HardForkSpecificNodeToNodeVersion -> NP EraNodeToNodeVersion xs -> HardForkNodeToNodeVersion xs |
Enable the HFC
Each era can be enabled or disabled individually by passing
|
Instances
SerialiseHFC xs => Eq ( HardForkNodeToNodeVersion xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common (==) :: HardForkNodeToNodeVersion xs -> HardForkNodeToNodeVersion xs -> Bool Source # (/=) :: HardForkNodeToNodeVersion xs -> HardForkNodeToNodeVersion xs -> Bool Source # |
|
SerialiseHFC xs => Show ( HardForkNodeToNodeVersion xs) Source # | |
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.
HardForkSpecificNodeToClientVersion1 | |
HardForkSpecificNodeToClientVersion2 |
Enable the
|
Instances
data HardForkSpecificNodeToNodeVersion Source #
Versioning of the specific additions made by the HFC to the
NodeToNode
protocols, e.g., the era tag.
Instances
Dealing with annotations
data AnnDecoder f blk Source #
AnnDecoder | |
|
Serialisation of telescopes
decodeTelescope :: NP ( Decoder s :.: f) xs -> Decoder s ( HardForkState f xs) Source #
encodeTelescope :: SListI xs => NP (f -.-> K Encoding ) xs -> HardForkState f xs -> Encoding Source #
Serialisation of sums
decodeAnnNS :: SListI xs => NP ( AnnDecoder f) xs -> forall s. Decoder s ( ByteString -> NS f xs) Source #
Dependent serialisation
decodeNested :: All ( DecodeDiskDep ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> NestedCtxt f ( HardForkBlock xs) a -> forall s. Decoder s ( ByteString -> a) Source #
decodeNestedCtxt :: All ( DecodeDiskDepIx ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> forall s. Decoder s ( SomeSecond ( NestedCtxt f) ( HardForkBlock xs)) Source #
encodeNested :: All ( EncodeDiskDep ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> NestedCtxt f ( HardForkBlock xs) a -> a -> Encoding Source #
encodeNestedCtxt :: All ( EncodeDiskDepIx ( NestedCtxt f)) xs => CodecConfig ( HardForkBlock xs) -> SomeSecond ( NestedCtxt f) ( HardForkBlock xs) -> Encoding Source #
MismatchEraInfo
decodeEitherMismatch :: SListI xs => BlockNodeToClientVersion ( HardForkBlock xs) -> Decoder s a -> Decoder s ( Either ( MismatchEraInfo xs) a) Source #
encodeEitherMismatch :: forall xs a. SListI xs => BlockNodeToClientVersion ( HardForkBlock xs) -> (a -> Encoding ) -> Either ( MismatchEraInfo xs) a -> Encoding Source #
Distributive properties
distribAnnTip :: SListI xs => AnnTip ( HardForkBlock xs) -> NS AnnTip xs Source #
distribQueryIfCurrent :: Some ( QueryIfCurrent xs) -> NS ( SomeSecond BlockQuery ) xs Source #
distribSerialisedHeader :: SerialisedHeader ( HardForkBlock xs) -> NS SerialisedHeader xs Source #
undistribAnnTip :: SListI xs => NS AnnTip xs -> AnnTip ( HardForkBlock xs) Source #
undistribQueryIfCurrent :: NS ( SomeSecond BlockQuery ) xs -> Some ( QueryIfCurrent xs) Source #
undistribSerialisedHeader :: NS SerialisedHeader xs -> SerialisedHeader ( HardForkBlock xs) Source #
Deriving-via support for tests
newtype SerialiseNS f xs Source #
Used for deriving via
Example
deriving via SerialiseNS Header SomeEras instance Serialise (Header SomeSecond)
SerialiseNS | |
|
Instances
All ( Compose Serialise f) xs => Serialise ( SerialiseNS f xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common encode :: SerialiseNS f xs -> Encoding Source # decode :: Decoder s ( SerialiseNS f xs) Source # encodeList :: [ SerialiseNS f xs] -> Encoding Source # decodeList :: Decoder s [ SerialiseNS f xs] Source # |
Orphan instances
SerialiseHFC xs => HasNetworkProtocolVersion ( HardForkBlock xs) Source # | |
type BlockNodeToNodeVersion ( HardForkBlock xs) Source # type BlockNodeToClientVersion ( HardForkBlock xs) Source # |