{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns        #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE PatternSynonyms       #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE TypeOperators         #-}
{-# OPTIONS_GHC -Wno-orphans
                -Wno-incomplete-patterns
                -Wno-incomplete-uni-patterns
                -Wno-incomplete-record-updates
                -Wno-overlapping-patterns #-}
module Ouroboros.Consensus.Cardano.Node (
    CardanoHardForkConstraints
  , MaxMajorProtVer (..)
  , ProtocolParamsAllegra (..)
  , ProtocolParamsMary (..)
  , ProtocolTransitionParamsShelleyBased (..)
  , TriggerHardFork (..)
  , protocolClientInfoCardano
  , protocolInfoCardano
    -- * SupportedNetworkProtocolVersion
  , pattern CardanoNodeToClientVersion1
  , pattern CardanoNodeToClientVersion2
  , pattern CardanoNodeToClientVersion3
  , pattern CardanoNodeToClientVersion4
  , pattern CardanoNodeToClientVersion5
  , pattern CardanoNodeToClientVersion6
  , pattern CardanoNodeToClientVersion7
  , pattern CardanoNodeToClientVersion8
  , pattern CardanoNodeToClientVersion9
  , pattern CardanoNodeToNodeVersion1
  , pattern CardanoNodeToNodeVersion2
  , pattern CardanoNodeToNodeVersion3
  , pattern CardanoNodeToNodeVersion4
  , pattern CardanoNodeToNodeVersion5
  , pattern CardanoNodeToNodeVersion6
  ) where

import qualified Codec.CBOR.Decoding as CBOR
import           Codec.CBOR.Encoding (Encoding)
import qualified Codec.CBOR.Encoding as CBOR
import           Control.Exception (assert)
import qualified Data.ByteString.Short as Short
import           Data.Functor.These (These1 (..))
import qualified Data.Map.Strict as Map
import           Data.SOP.Strict hiding (shape, shift)
import           Data.Word (Word16, Word64)

import           Cardano.Binary (DecoderError (..), enforceSize)
import           Cardano.Chain.Slotting (EpochSlots)
import           Cardano.Prelude (cborError)

import           Ouroboros.Consensus.Block
import           Ouroboros.Consensus.Config
import qualified Ouroboros.Consensus.HardFork.History as History
import           Ouroboros.Consensus.HeaderValidation
import           Ouroboros.Consensus.Ledger.Extended
import qualified Ouroboros.Consensus.Mempool.TxLimits as TxLimits
import           Ouroboros.Consensus.Node.NetworkProtocolVersion
import           Ouroboros.Consensus.Node.ProtocolInfo
import           Ouroboros.Consensus.Node.Run
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import           Ouroboros.Consensus.Storage.Serialisation
import           Ouroboros.Consensus.Util.Assert
import           Ouroboros.Consensus.Util.Counting
import           Ouroboros.Consensus.Util.IOLike
import           Ouroboros.Consensus.Util.OptNP (NonEmptyOptNP, OptNP (OptSkip))
import qualified Ouroboros.Consensus.Util.OptNP as OptNP
import           Ouroboros.Consensus.Util.SOP (Index (..))

import           Ouroboros.Consensus.HardFork.Combinator
import           Ouroboros.Consensus.HardFork.Combinator.Embed.Nary
import           Ouroboros.Consensus.HardFork.Combinator.Serialisation

import           Ouroboros.Consensus.Byron.Ledger (ByronBlock)
import qualified Ouroboros.Consensus.Byron.Ledger as Byron
import qualified Ouroboros.Consensus.Byron.Ledger.Conversions as Byron
import           Ouroboros.Consensus.Byron.Ledger.NetworkProtocolVersion
import           Ouroboros.Consensus.Byron.Node

import qualified Cardano.Protocol.TPraos.OCert as Absolute (KESPeriod (..),
                     ocertKESPeriod)

import qualified Cardano.Ledger.Era as Core
import qualified Cardano.Ledger.Shelley.API as SL

import           Ouroboros.Consensus.Protocol.TPraos (TPraos, TPraosParams (..))
import qualified Ouroboros.Consensus.Protocol.TPraos as Shelley
import           Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock)
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley
import           Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
import           Ouroboros.Consensus.Shelley.Node
import           Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto,
                     shelleyBlockIssuerVKey)

import qualified Cardano.Ledger.BaseTypes as SL
import           Cardano.Slotting.Time (SystemStart (SystemStart))
import           Ouroboros.Consensus.Cardano.Block
import           Ouroboros.Consensus.Cardano.CanHardFork
import           Ouroboros.Consensus.Cardano.ShelleyBased
import           Ouroboros.Consensus.Protocol.Praos (Praos, PraosParams (..))
import           Ouroboros.Consensus.Protocol.Praos.Common
                     (praosCanBeLeaderOpCert)
import           Ouroboros.Consensus.Shelley.Node.Praos
                     (ProtocolParamsBabbage (..))
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
import qualified Ouroboros.Consensus.Shelley.Node.TPraos as TPraos

{-------------------------------------------------------------------------------
  SerialiseHFC
-------------------------------------------------------------------------------}

instance SerialiseConstraintsHFC ByronBlock

-- | Important: we need to maintain binary compatibility with Byron blocks, as
-- they are already stored on disk.
--
-- We also want to be able to efficiently detect (without having to peek far
-- ahead) whether we're dealing with a Byron or Shelley block, so that we can
-- invoke the right decoder. We plan to have a few more hard forks after
-- Shelley (Goguen, Basho, Voltaire), so we want a future-proof envelope for
-- distinguishing the different block types, i.e., a byte indicating the era.
--
-- Byron does not provide such an envelope. However, a Byron block is a CBOR
-- 2-tuple with the first element being a tag ('Word': 0 = EBB; 1 = regular
-- block) and the second being the payload. We can easily extend this encoding
-- format with support for Shelley, Goguen, etc.
--
-- We encode a 'CardanoBlock' as the same CBOR 2-tuple as a Byron block, but
-- we use the tags after 1 for the hard forks after Byron:
--
-- 0. Byron EBB
-- 1. Byron regular block
-- 2. Shelley block
-- 3. Allegra block
-- 4. Mary block
-- 5. Goguen block
-- 6. etc.
--
-- For more details, see:
-- <https://github.com/input-output-hk/ouroboros-network/pull/1175#issuecomment-558147194>
instance CardanoHardForkConstraints c => SerialiseHFC (CardanoEras c) where
  encodeDiskHfcBlock :: CodecConfig (HardForkBlock (CardanoEras c))
-> HardForkBlock (CardanoEras c) -> Encoding
encodeDiskHfcBlock (CardanoCodecConfig CodecConfig ByronBlock
ccfgByron CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
ccfgShelley CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
ccfgAllegra CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
ccfgMary CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
ccfgAlonzo CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
ccfgBabbage) = \case
      -- We are backwards compatible with Byron and thus use the exact same
      -- encoding.
      BlockByron   ByronBlock
blockByron   ->                CodecConfig ByronBlock -> ByronBlock -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig ByronBlock
ccfgByron ByronBlock
blockByron
      -- For Shelley and later eras, we need to prepend the hard fork envelope.
      BlockShelley ShelleyBlock (TPraos c) (ShelleyEra c)
blockShelley -> Word -> Encoding -> Encoding
prependTag Word
2 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> ShelleyBlock (TPraos c) (ShelleyEra c) -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
ccfgShelley ShelleyBlock (TPraos c) (ShelleyEra c)
blockShelley
      BlockAllegra ShelleyBlock (TPraos c) (AllegraEra c)
blockAllegra -> Word -> Encoding -> Encoding
prependTag Word
3 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> ShelleyBlock (TPraos c) (AllegraEra c) -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
ccfgAllegra ShelleyBlock (TPraos c) (AllegraEra c)
blockAllegra
      BlockMary    ShelleyBlock (TPraos c) (MaryEra c)
blockMary    -> Word -> Encoding -> Encoding
prependTag Word
4 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> ShelleyBlock (TPraos c) (MaryEra c) -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
ccfgMary    ShelleyBlock (TPraos c) (MaryEra c)
blockMary
      BlockAlonzo  ShelleyBlock (TPraos c) (AlonzoEra c)
blockAlonzo  -> Word -> Encoding -> Encoding
prependTag Word
5 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> ShelleyBlock (TPraos c) (AlonzoEra c) -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
ccfgAlonzo  ShelleyBlock (TPraos c) (AlonzoEra c)
blockAlonzo
      BlockBabbage ShelleyBlock (Praos c) (BabbageEra c)
blockBabbage -> Word -> Encoding -> Encoding
prependTag Word
6 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> ShelleyBlock (Praos c) (BabbageEra c) -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
ccfgBabbage ShelleyBlock (Praos c) (BabbageEra c)
blockBabbage
  decodeDiskHfcBlock :: CodecConfig (HardForkBlock (CardanoEras c))
-> forall s.
   Decoder s (ByteString -> HardForkBlock (CardanoEras c))
decodeDiskHfcBlock (CardanoCodecConfig CodecConfig ByronBlock
ccfgByron CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
ccfgShelley CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
ccfgAllegra CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
ccfgMary CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
ccfgAlonzo CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
ccfgBabbage) = do
      Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
enforceSize Text
"CardanoBlock" Int
2
      Decoder s Word
forall s. Decoder s Word
CBOR.decodeWord Decoder s Word
-> (Word
    -> Decoder s (ByteString -> HardForkBlock (CardanoEras c)))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
        Word
0 -> (ByronBlock -> HardForkBlock (CardanoEras c))
-> (ByteString -> ByronBlock)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByronBlock -> HardForkBlock (CardanoEras c)
forall c. ByronBlock -> CardanoBlock c
BlockByron   ((ByteString -> ByronBlock)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ByronBlock)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EpochSlots -> Decoder s (ByteString -> ByronBlock)
forall s. EpochSlots -> Decoder s (ByteString -> ByronBlock)
Byron.decodeByronBoundaryBlock EpochSlots
epochSlots
        Word
1 -> (ByronBlock -> HardForkBlock (CardanoEras c))
-> (ByteString -> ByronBlock)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByronBlock -> HardForkBlock (CardanoEras c)
forall c. ByronBlock -> CardanoBlock c
BlockByron   ((ByteString -> ByronBlock)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ByronBlock)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EpochSlots -> Decoder s (ByteString -> ByronBlock)
forall s. EpochSlots -> Decoder s (ByteString -> ByronBlock)
Byron.decodeByronRegularBlock  EpochSlots
epochSlots
        -- We don't have to drop the first two bytes from the 'ByteString'
        -- passed to the decoder as slicing already takes care of this.
        Word
2 -> (ShelleyBlock (TPraos c) (ShelleyEra c)
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) (ShelleyEra c))
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) (ShelleyEra c)
-> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) (ShelleyEra c) -> CardanoBlock c
BlockShelley ((ByteString -> ShelleyBlock (TPraos c) (ShelleyEra c))
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) (ShelleyEra c))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) (ShelleyEra c))
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
ccfgShelley
        Word
3 -> (ShelleyBlock (TPraos c) (AllegraEra c)
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) (AllegraEra c))
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) (AllegraEra c)
-> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) (AllegraEra c) -> CardanoBlock c
BlockAllegra ((ByteString -> ShelleyBlock (TPraos c) (AllegraEra c))
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) (AllegraEra c))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) (AllegraEra c))
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
ccfgAllegra
        Word
4 -> (ShelleyBlock (TPraos c) (MaryEra c)
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) (MaryEra c))
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) (MaryEra c)
-> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) (MaryEra c) -> CardanoBlock c
BlockMary    ((ByteString -> ShelleyBlock (TPraos c) (MaryEra c))
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) (MaryEra c))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) (MaryEra c))
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
ccfgMary
        Word
5 -> (ShelleyBlock (TPraos c) (AlonzoEra c)
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) (AlonzoEra c))
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) (AlonzoEra c)
-> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) (AlonzoEra c) -> CardanoBlock c
BlockAlonzo  ((ByteString -> ShelleyBlock (TPraos c) (AlonzoEra c))
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) (AlonzoEra c))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) (AlonzoEra c))
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
ccfgAlonzo
        Word
6 -> (ShelleyBlock (Praos c) (BabbageEra c)
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (Praos c) (BabbageEra c))
-> ByteString
-> HardForkBlock (CardanoEras c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (Praos c) (BabbageEra c)
-> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (Praos c) (BabbageEra c) -> CardanoBlock c
BlockBabbage ((ByteString -> ShelleyBlock (Praos c) (BabbageEra c))
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (Praos c) (BabbageEra c))
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (Praos c) (BabbageEra c))
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
ccfgBabbage
        Word
t -> DecoderError
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall e s a. Buildable e => e -> Decoder s a
cborError (DecoderError
 -> Decoder s (ByteString -> HardForkBlock (CardanoEras c)))
-> DecoderError
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ Text -> Word8 -> DecoderError
DecoderErrorUnknownTag Text
"CardanoBlock" (Word -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
t)
    where
      epochSlots :: EpochSlots
epochSlots = CodecConfig ByronBlock -> EpochSlots
Byron.getByronEpochSlots CodecConfig ByronBlock
ccfgByron

  reconstructHfcPrefixLen :: proxy (Header (HardForkBlock (CardanoEras c))) -> PrefixLen
reconstructHfcPrefixLen proxy (Header (HardForkBlock (CardanoEras c)))
_ = Word8 -> PrefixLen
PrefixLen Word8
2

  reconstructHfcNestedCtxt :: proxy (Header (HardForkBlock (CardanoEras c)))
-> ShortByteString
-> SizeInBytes
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
reconstructHfcNestedCtxt proxy (Header (HardForkBlock (CardanoEras c)))
_ ShortByteString
prefix SizeInBytes
blockSize =
      case ShortByteString -> Int -> Word8
Short.index ShortByteString
prefix Int
1 of
        Word8
0 -> NestedCtxt
  Header (HardForkBlock (CardanoEras c)) (SlotNo, RawBoundaryHeader)
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header (HardForkBlock (CardanoEras c)) (SlotNo, RawBoundaryHeader)
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header (HardForkBlock (CardanoEras c)) (SlotNo, RawBoundaryHeader)
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c)) Header (SlotNo, RawBoundaryHeader)
-> NestedCtxt
     Header (HardForkBlock (CardanoEras c)) (SlotNo, RawBoundaryHeader)
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_ ByronBlock Header (SlotNo, RawBoundaryHeader)
-> NestedCtxt_
     (HardForkBlock (CardanoEras c)) Header (SlotNo, RawBoundaryHeader)
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ (SizeInBytes
-> NestedCtxt_ ByronBlock Header (SlotNo, RawBoundaryHeader)
Byron.CtxtByronBoundary SizeInBytes
blockSize))
        Word8
1 -> NestedCtxt
  Header (HardForkBlock (CardanoEras c)) (AHeader ByteString)
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header (HardForkBlock (CardanoEras c)) (AHeader ByteString)
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header (HardForkBlock (CardanoEras c)) (AHeader ByteString)
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c)) Header (AHeader ByteString)
-> NestedCtxt
     Header (HardForkBlock (CardanoEras c)) (AHeader ByteString)
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_ ByronBlock Header (AHeader ByteString)
-> NestedCtxt_
     (HardForkBlock (CardanoEras c)) Header (AHeader ByteString)
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ (SizeInBytes -> NestedCtxt_ ByronBlock Header (AHeader ByteString)
Byron.CtxtByronRegular  SizeInBytes
blockSize))
        Word8
2 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) (ShelleyEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (ShelleyEra c),
          ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) (ShelleyEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (ShelleyEra c)))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley))
        Word8
3 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (ShelleyEra c),
          ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) (AllegraEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) (AllegraEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (AllegraEra c)))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley)))
        Word8
4 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) (MaryEra c)))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (ShelleyEra c),
          ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) (MaryEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) (MaryEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (MaryEra c)))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley))))
        Word8
5 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (ShelleyEra c),
          ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) (AlonzoEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) (AlonzoEra c))
  Header
  (Header (ShelleyBlock (TPraos c) (AlonzoEra c)))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley)))))
        Word8
6 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (Praos c) (BabbageEra c)))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (ShelleyEra c),
          ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AllegraEra c),
          ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (MaryEra c),
          ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock '[ShelleyBlock (Praos c) (BabbageEra c)])
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) (AlonzoEra c),
          ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (Praos c) (BabbageEra c))
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
-> NestedCtxt_
     (HardForkBlock '[ShelleyBlock (Praos c) (BabbageEra c)])
     Header
     (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (Praos c) (BabbageEra c))
  Header
  (Header (ShelleyBlock (Praos c) (BabbageEra c)))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley))))))
        Word8
_ -> [Char]
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a. HasCallStack => [Char] -> a
error ([Char]
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> [Char]
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ [Char]
"CardanoBlock: invalid prefix " [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> ShortByteString -> [Char]
forall a. Show a => a -> [Char]
show ShortByteString
prefix

  getHfcBinaryBlockInfo :: HardForkBlock (CardanoEras c) -> BinaryBlockInfo
getHfcBinaryBlockInfo = \case
      BlockByron   ByronBlock
blockByron   ->
        ByronBlock -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ByronBlock
blockByron
      -- For Shelley and the later eras, we need to account for the two extra
      -- bytes of the envelope.
      BlockShelley ShelleyBlock (TPraos c) (ShelleyEra c)
blockShelley ->
        Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) (ShelleyEra c) -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) (ShelleyEra c)
blockShelley
      BlockAllegra ShelleyBlock (TPraos c) (AllegraEra c)
blockAllegra ->
        Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) (AllegraEra c) -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) (AllegraEra c)
blockAllegra
      BlockMary ShelleyBlock (TPraos c) (MaryEra c)
blockMary ->
        Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) (MaryEra c) -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) (MaryEra c)
blockMary
      BlockAlonzo ShelleyBlock (TPraos c) (AlonzoEra c)
blockAlonzo ->
        Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) (AlonzoEra c) -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) (AlonzoEra c)
blockAlonzo
      BlockBabbage ShelleyBlock (Praos c) (BabbageEra c)
blockBabbage ->
        Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (Praos c) (BabbageEra c) -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (Praos c) (BabbageEra c)
blockBabbage
    where
      shiftHeaderOffset :: Word16 -> BinaryBlockInfo -> BinaryBlockInfo
      shiftHeaderOffset :: Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
shift BinaryBlockInfo
binfo = BinaryBlockInfo
binfo {
            headerOffset :: Word16
headerOffset = BinaryBlockInfo -> Word16
headerOffset BinaryBlockInfo
binfo Word16 -> Word16 -> Word16
forall a. Num a => a -> a -> a
+ Word16
shift
          }

  estimateHfcBlockSize :: Header (HardForkBlock (CardanoEras c)) -> SizeInBytes
estimateHfcBlockSize = \case
      HeaderByron   Header ByronBlock
headerByron   -> Header ByronBlock -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header ByronBlock
headerByron
      -- For Shelley and later eras, we add two extra bytes, see the
      -- 'SerialiseHFC' instance.
      HeaderShelley Header (ShelleyBlock (TPraos c) (ShelleyEra c))
headerShelley -> Header (ShelleyBlock (TPraos c) (ShelleyEra c)) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) (ShelleyEra c))
headerShelley SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
      HeaderAllegra Header (ShelleyBlock (TPraos c) (AllegraEra c))
headerAllegra -> Header (ShelleyBlock (TPraos c) (AllegraEra c)) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) (AllegraEra c))
headerAllegra SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
      HeaderMary    Header (ShelleyBlock (TPraos c) (MaryEra c))
headerMary    -> Header (ShelleyBlock (TPraos c) (MaryEra c)) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) (MaryEra c))
headerMary    SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
      HeaderAlonzo  Header (ShelleyBlock (TPraos c) (AlonzoEra c))
headerAlonzo  -> Header (ShelleyBlock (TPraos c) (AlonzoEra c)) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) (AlonzoEra c))
headerAlonzo  SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
      HeaderBabbage Header (ShelleyBlock (Praos c) (BabbageEra c))
headerBabbage -> Header (ShelleyBlock (Praos c) (BabbageEra c)) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (Praos c) (BabbageEra c))
headerBabbage SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2

-- | Prepend the given tag by creating a CBOR 2-tuple with the tag as the
-- first element and the given 'Encoding' as the second.
prependTag :: Word -> Encoding -> Encoding
prependTag :: Word -> Encoding -> Encoding
prependTag Word
tag Encoding
payload = [Encoding] -> Encoding
forall a. Monoid a => [a] -> a
mconcat [
      Word -> Encoding
CBOR.encodeListLen Word
2
    , Word -> Encoding
CBOR.encodeWord Word
tag
    , Encoding
payload
    ]

{-------------------------------------------------------------------------------
  SupportedNetworkProtocolVersion instance
-------------------------------------------------------------------------------}

-- Note: we don't support all combinations, so we don't declare them as
-- COMPLETE

-- | We support only Byron V1 with the hard fork disabled, as no other
-- versions have been released before the hard fork
pattern CardanoNodeToNodeVersion1 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion1 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion1 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion1 =
    HardForkNodeToNodeDisabled ByronNodeToNodeVersion1

-- | The hard fork enabled with the latest Byron version and the Shelley era
-- enabled.
pattern CardanoNodeToNodeVersion2 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion2 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion2 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion2 =
    HardForkNodeToNodeEnabled
      HardForkSpecificNodeToNodeVersion1
      (  EraNodeToNodeEnabled ByronNodeToNodeVersion2
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* Nil
      )

-- | The hard fork enabled with the latest Byron version, the Shelley and
-- Allegra eras enabled.
pattern CardanoNodeToNodeVersion3 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion3 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion3 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion3 =
    HardForkNodeToNodeEnabled
      HardForkSpecificNodeToNodeVersion1
      (  EraNodeToNodeEnabled ByronNodeToNodeVersion2
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* Nil
      )

-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- and Mary eras enabled.
pattern CardanoNodeToNodeVersion4 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion4 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion4 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion4 =
    HardForkNodeToNodeEnabled
      HardForkSpecificNodeToNodeVersion1
      (  EraNodeToNodeEnabled ByronNodeToNodeVersion2
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeDisabled
      :* EraNodeToNodeDisabled
      :* Nil
      )

-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- Mary and Alonzo eras enabled.
pattern CardanoNodeToNodeVersion5 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion5 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion5 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion5 =
    HardForkNodeToNodeEnabled
      HardForkSpecificNodeToNodeVersion1
      (  EraNodeToNodeEnabled ByronNodeToNodeVersion2
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeDisabled
      :* Nil
      )

-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- Mary, Alonzo and Babbage eras enabled.
pattern CardanoNodeToNodeVersion6 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $bCardanoNodeToNodeVersion6 :: BlockNodeToNodeVersion (CardanoBlock c)
$mCardanoNodeToNodeVersion6 :: forall r c.
BlockNodeToNodeVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToNodeVersion6 =
    HardForkNodeToNodeEnabled
      HardForkSpecificNodeToNodeVersion1
      (  EraNodeToNodeEnabled ByronNodeToNodeVersion2
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
      :* Nil
      )


-- | We support the sole Byron version with the hard fork disabled.
pattern CardanoNodeToClientVersion1 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion1 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion1 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion1 =
    HardForkNodeToClientDisabled ByronNodeToClientVersion1

-- | The hard fork enabled and the Shelley era enabled.
pattern CardanoNodeToClientVersion2 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion2 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion2 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion2 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion1
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion1
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled and the Shelley era enabled, but using
-- 'ShelleyNodeToClientVersion2' and 'HardForkSpecificNodeToClientVersion2'.
pattern CardanoNodeToClientVersion3 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion3 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion3 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion3 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley and Allegra eras enabled.
--
-- We don't bother with 'ShelleyNodeToClientVersion1' and
-- 'HardForkSpecificNodeToClientVersion1'.
pattern CardanoNodeToClientVersion4 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion4 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion4 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion4 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, and Mary eras enabled.
--
-- We don't bother with 'ShelleyNodeToClientVersion1'.
pattern CardanoNodeToClientVersion5 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion5 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion5 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion5 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion2
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, and Mary eras enabled, but
-- using 'ShelleyNodeToClientVersion3' for the Shelley-based eras , which
-- enables new queries.
pattern CardanoNodeToClientVersion6 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion6 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion6 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion6 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion3
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion3
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion3
      :* EraNodeToClientDisabled
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary and Alonzo eras enabled
pattern CardanoNodeToClientVersion7 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion7 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion7 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion7 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion4
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion4
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion4
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion4
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary and Alonzo eras enabled
-- Using 'ShelleyNodeToClientVersion5' for the Shelley-based eras , which
-- enables new queries.
pattern CardanoNodeToClientVersion8 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion8 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion8 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion8 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientDisabled
      :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- eras enabled Using 'ShelleyNodeToClientVersion5' for the Shelley-based eras,
-- which enables new queries.
pattern CardanoNodeToClientVersion9 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $bCardanoNodeToClientVersion9 :: BlockNodeToClientVersion (CardanoBlock c)
$mCardanoNodeToClientVersion9 :: forall r c.
BlockNodeToClientVersion (CardanoBlock c)
-> (Void# -> r) -> (Void# -> r) -> r
CardanoNodeToClientVersion9 =
    HardForkNodeToClientEnabled
      HardForkSpecificNodeToClientVersion2
      (  EraNodeToClientEnabled ByronNodeToClientVersion1
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* EraNodeToClientEnabled ShelleyNodeToClientVersion5
      :* Nil
      )
instance CardanoHardForkConstraints c
      => SupportedNetworkProtocolVersion (CardanoBlock c) where
  supportedNodeToNodeVersions :: Proxy (CardanoBlock c)
-> Map NodeToNodeVersion (BlockNodeToNodeVersion (CardanoBlock c))
supportedNodeToNodeVersions Proxy (CardanoBlock c)
_ = [(NodeToNodeVersion,
  HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c))]
-> Map
     NodeToNodeVersion
     (HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(NodeToNodeVersion,
   HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c))]
 -> Map
      NodeToNodeVersion
      (HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c)))
-> [(NodeToNodeVersion,
     HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c))]
-> Map
     NodeToNodeVersion
     (HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c))
forall a b. (a -> b) -> a -> b
$
      [ (NodeToNodeVersion
NodeToNodeV_7, HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion5)
      , (NodeToNodeVersion
NodeToNodeV_8, HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion5)
      , (NodeToNodeVersion
NodeToNodeV_9, HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion6)
      , (NodeToNodeVersion
NodeToNodeV_10, HardForkNodeToNodeVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion6)
      ]

  supportedNodeToClientVersions :: Proxy (CardanoBlock c)
-> Map
     NodeToClientVersion (BlockNodeToClientVersion (CardanoBlock c))
supportedNodeToClientVersions Proxy (CardanoBlock c)
_ = [(NodeToClientVersion,
  HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c))]
-> Map
     NodeToClientVersion
     (HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(NodeToClientVersion,
   HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c))]
 -> Map
      NodeToClientVersion
      (HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)))
-> [(NodeToClientVersion,
     HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c))]
-> Map
     NodeToClientVersion
     (HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c))
forall a b. (a -> b) -> a -> b
$
      [ (NodeToClientVersion
NodeToClientV_9 , HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion7)
      , (NodeToClientVersion
NodeToClientV_10, HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion7)
      , (NodeToClientVersion
NodeToClientV_11, HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion8)
      , (NodeToClientVersion
NodeToClientV_12, HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion8)
      , (NodeToClientVersion
NodeToClientV_13, HardForkNodeToClientVersion (ByronBlock : CardanoShelleyEras c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion9)
      ]

  latestReleasedNodeVersion :: Proxy (CardanoBlock c)
-> (Maybe NodeToNodeVersion, Maybe NodeToClientVersion)
latestReleasedNodeVersion Proxy (CardanoBlock c)
_prx = (NodeToNodeVersion -> Maybe NodeToNodeVersion
forall a. a -> Maybe a
Just NodeToNodeVersion
NodeToNodeV_9, NodeToClientVersion -> Maybe NodeToClientVersion
forall a. a -> Maybe a
Just NodeToClientVersion
NodeToClientV_13)

{-------------------------------------------------------------------------------
  ProtocolInfo
-------------------------------------------------------------------------------}

-- | Parameters needed to transition to a Shelley era.
data ProtocolTransitionParamsShelleyBased era = ProtocolTransitionParamsShelleyBased {
      ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext :: Core.TranslationContext era
    , ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            :: TriggerHardFork
    }

-- | Create a 'ProtocolInfo' for 'CardanoBlock'
--
-- NOTE: the initial staking and funds in the 'ShelleyGenesis' are ignored,
-- /unless/ configured to skip the Byron era and hard fork to Shelley or a later
-- era from the start using @TriggerHardForkAtEpoch 0@ for testing purposes.
--
-- PRECONDITION: only a single set of Shelley credentials is allowed when used
-- for mainnet (check against @'SL.gNetworkId' 'shelleyBasedGenesis'@).
protocolInfoCardano ::
     forall c m. (IOLike m, CardanoHardForkConstraints c)
  => ProtocolParamsByron
  -> ProtocolParamsShelleyBased (ShelleyEra c)
  -> ProtocolParamsShelley c
  -> ProtocolParamsAllegra c
  -> ProtocolParamsMary    c
  -> ProtocolParamsAlonzo  c
  -> ProtocolParamsBabbage c
  -> ProtocolTransitionParamsShelleyBased (ShelleyEra c)
  -> ProtocolTransitionParamsShelleyBased (AllegraEra c)
  -> ProtocolTransitionParamsShelleyBased (MaryEra c)
  -> ProtocolTransitionParamsShelleyBased (AlonzoEra c)
  -> ProtocolTransitionParamsShelleyBased (BabbageEra c)
  -> ProtocolInfo m (CardanoBlock c)
protocolInfoCardano :: ProtocolParamsByron
-> ProtocolParamsShelleyBased (ShelleyEra c)
-> ProtocolParamsShelley c
-> ProtocolParamsAllegra c
-> ProtocolParamsMary c
-> ProtocolParamsAlonzo c
-> ProtocolParamsBabbage c
-> ProtocolTransitionParamsShelleyBased (ShelleyEra c)
-> ProtocolTransitionParamsShelleyBased (AllegraEra c)
-> ProtocolTransitionParamsShelleyBased (MaryEra c)
-> ProtocolTransitionParamsShelleyBased (AlonzoEra c)
-> ProtocolTransitionParamsShelleyBased (BabbageEra c)
-> ProtocolInfo m (CardanoBlock c)
protocolInfoCardano protocolParamsByron :: ProtocolParamsByron
protocolParamsByron@ProtocolParamsByron {
                        $sel:byronGenesis:ProtocolParamsByron :: ProtocolParamsByron -> Config
byronGenesis                = Config
genesisByron
                      , $sel:byronLeaderCredentials:ProtocolParamsByron :: ProtocolParamsByron -> Maybe ByronLeaderCredentials
byronLeaderCredentials      = Maybe ByronLeaderCredentials
mCredsByron
                      , $sel:byronMaxTxCapacityOverrides:ProtocolParamsByron :: ProtocolParamsByron -> Overrides ByronBlock
byronMaxTxCapacityOverrides = Overrides ByronBlock
maxTxCapacityOverridesByron
                      }
                    ProtocolParamsShelleyBased {
                        shelleyBasedGenesis :: forall era. ProtocolParamsShelleyBased era -> ShelleyGenesis era
shelleyBasedGenesis           = ShelleyGenesis (ShelleyEra c)
genesisShelley
                      , shelleyBasedInitialNonce :: forall era. ProtocolParamsShelleyBased era -> Nonce
shelleyBasedInitialNonce      = Nonce
initialNonceShelley
                      , shelleyBasedLeaderCredentials :: forall era.
ProtocolParamsShelleyBased era
-> [ShelleyLeaderCredentials (EraCrypto era)]
shelleyBasedLeaderCredentials = [ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased
                      }
                    ProtocolParamsShelley {
                        $sel:shelleyProtVer:ProtocolParamsShelley :: forall c. ProtocolParamsShelley c -> ProtVer
shelleyProtVer                = ProtVer
protVerShelley
                      , $sel:shelleyMaxTxCapacityOverrides:ProtocolParamsShelley :: forall c.
ProtocolParamsShelley c
-> Overrides (ShelleyBlock (TPraos c) (ShelleyEra c))
shelleyMaxTxCapacityOverrides = Overrides (ShelleyBlock (TPraos c) (ShelleyEra c))
maxTxCapacityOverridesShelley
                      }
                    ProtocolParamsAllegra {
                        $sel:allegraProtVer:ProtocolParamsAllegra :: forall c. ProtocolParamsAllegra c -> ProtVer
allegraProtVer                = ProtVer
protVerAllegra
                      , $sel:allegraMaxTxCapacityOverrides:ProtocolParamsAllegra :: forall c.
ProtocolParamsAllegra c
-> Overrides (ShelleyBlock (TPraos c) (AllegraEra c))
allegraMaxTxCapacityOverrides = Overrides (ShelleyBlock (TPraos c) (AllegraEra c))
maxTxCapacityOverridesAllegra
                      }
                    ProtocolParamsMary {
                        $sel:maryProtVer:ProtocolParamsMary :: forall c. ProtocolParamsMary c -> ProtVer
maryProtVer                = ProtVer
protVerMary
                      , $sel:maryMaxTxCapacityOverrides:ProtocolParamsMary :: forall c.
ProtocolParamsMary c
-> Overrides (ShelleyBlock (TPraos c) (MaryEra c))
maryMaxTxCapacityOverrides = Overrides (ShelleyBlock (TPraos c) (MaryEra c))
maxTxCapacityOverridesMary
                      }
                    ProtocolParamsAlonzo {
                        $sel:alonzoProtVer:ProtocolParamsAlonzo :: forall c. ProtocolParamsAlonzo c -> ProtVer
alonzoProtVer                = ProtVer
protVerAlonzo
                      , $sel:alonzoMaxTxCapacityOverrides:ProtocolParamsAlonzo :: forall c.
ProtocolParamsAlonzo c
-> Overrides (ShelleyBlock (TPraos c) (AlonzoEra c))
alonzoMaxTxCapacityOverrides = Overrides (ShelleyBlock (TPraos c) (AlonzoEra c))
maxTxCapacityOverridesAlonzo
                      }
                    ProtocolParamsBabbage {
                        babbageProtVer :: forall c. ProtocolParamsBabbage c -> ProtVer
babbageProtVer                = ProtVer
protVerBabbage
                      , babbageMaxTxCapacityOverrides :: forall c.
ProtocolParamsBabbage c
-> Overrides (ShelleyBlock (Praos c) (BabbageEra c))
babbageMaxTxCapacityOverrides = Overrides (ShelleyBlock (Praos c) (BabbageEra c))
maxTxCapacityOverridesBabbage
                      }
                    ProtocolTransitionParamsShelleyBased {
                        transitionTranslationContext :: forall era.
ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext = ()
                      , transitionTrigger :: forall era.
ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            = TriggerHardFork
triggerHardForkShelley
                      }
                    ProtocolTransitionParamsShelleyBased {
                        transitionTranslationContext :: forall era.
ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext = ()
                      , transitionTrigger :: forall era.
ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            = TriggerHardFork
triggerHardForkAllegra
                      }
                    ProtocolTransitionParamsShelleyBased {
                        transitionTranslationContext :: forall era.
ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext = ()
                      , transitionTrigger :: forall era.
ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            = TriggerHardFork
triggerHardForkMary
                      }
                    ProtocolTransitionParamsShelleyBased {
                        transitionTranslationContext :: forall era.
ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext = TranslationContext (AlonzoEra c)
transCtxtAlonzo
                      , transitionTrigger :: forall era.
ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            = TriggerHardFork
triggerHardForkAlonzo
                      }
                    ProtocolTransitionParamsShelleyBased {
                        transitionTranslationContext :: forall era.
ProtocolTransitionParamsShelleyBased era -> TranslationContext era
transitionTranslationContext = TranslationContext (BabbageEra c)
transCtxtBabbage
                      , transitionTrigger :: forall era.
ProtocolTransitionParamsShelleyBased era -> TriggerHardFork
transitionTrigger            = TriggerHardFork
triggerHardForkBabbage
                      }
  | Network
SL.Mainnet <- ShelleyGenesis (ShelleyEra c) -> Network
forall era. ShelleyGenesis era -> Network
SL.sgNetworkId ShelleyGenesis (ShelleyEra c)
genesisShelley
  , [ShelleyLeaderCredentials c] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1
  = [Char] -> ProtocolInfo m (CardanoBlock c)
forall a. HasCallStack => [Char] -> a
error [Char]
"Multiple Shelley-based credentials not allowed for mainnet"
  | Bool
otherwise
  = Either [Char] ()
-> ProtocolInfo m (CardanoBlock c)
-> ProtocolInfo m (CardanoBlock c)
forall a. HasCallStack => Either [Char] () -> a -> a
assertWithMsg (ShelleyGenesis (ShelleyEra c) -> Either [Char] ()
forall era.
ShelleyBasedEra era =>
ShelleyGenesis era -> Either [Char] ()
validateGenesis ShelleyGenesis (ShelleyEra c)
genesisShelley) (ProtocolInfo m (CardanoBlock c)
 -> ProtocolInfo m (CardanoBlock c))
-> ProtocolInfo m (CardanoBlock c)
-> ProtocolInfo m (CardanoBlock c)
forall a b. (a -> b) -> a -> b
$
    ProtocolInfo :: forall (m :: * -> *) b.
TopLevelConfig b
-> ExtLedgerState b -> m [BlockForging m b] -> ProtocolInfo m b
ProtocolInfo {
        pInfoConfig :: TopLevelConfig (CardanoBlock c)
pInfoConfig       = TopLevelConfig (CardanoBlock c)
cfg
      , pInfoInitLedger :: ExtLedgerState (CardanoBlock c)
pInfoInitLedger   = ExtLedgerState (CardanoBlock c)
initExtLedgerStateCardano
      , pInfoBlockForging :: m [BlockForging m (CardanoBlock c)]
pInfoBlockForging = m [BlockForging m (CardanoBlock c)]
blockForging
      }
  where
    -- The major protocol version of the last era is the maximum major protocol
    -- version we support.
    maxMajorProtVer :: MaxMajorProtVer
    maxMajorProtVer :: MaxMajorProtVer
maxMajorProtVer = Natural -> MaxMajorProtVer
MaxMajorProtVer (ProtVer -> Natural
pvMajor ProtVer
protVerBabbage)

    -- Byron

    ProtocolInfo {
        pInfoConfig :: forall (m :: * -> *) b. ProtocolInfo m b -> TopLevelConfig b
pInfoConfig = topLevelConfigByron :: TopLevelConfig ByronBlock
topLevelConfigByron@TopLevelConfig {
            topLevelConfigProtocol :: forall blk.
TopLevelConfig blk -> ConsensusConfig (BlockProtocol blk)
topLevelConfigProtocol = ConsensusConfig (BlockProtocol ByronBlock)
consensusConfigByron
          , topLevelConfigLedger :: forall blk. TopLevelConfig blk -> LedgerConfig blk
topLevelConfigLedger   = LedgerConfig ByronBlock
ledgerConfigByron
          , topLevelConfigBlock :: forall blk. TopLevelConfig blk -> BlockConfig blk
topLevelConfigBlock    = BlockConfig ByronBlock
blockConfigByron
          }
      , pInfoInitLedger :: forall (m :: * -> *) b. ProtocolInfo m b -> ExtLedgerState b
pInfoInitLedger = ExtLedgerState ByronBlock
initExtLedgerStateByron
      } = ProtocolParamsByron -> ProtocolInfo m ByronBlock
forall (m :: * -> *).
Monad m =>
ProtocolParamsByron -> ProtocolInfo m ByronBlock
protocolInfoByron @m ProtocolParamsByron
protocolParamsByron

    partialConsensusConfigByron :: PartialConsensusConfig (BlockProtocol ByronBlock)
    partialConsensusConfigByron :: PartialConsensusConfig (BlockProtocol ByronBlock)
partialConsensusConfigByron = PartialConsensusConfig (BlockProtocol ByronBlock)
ConsensusConfig (BlockProtocol ByronBlock)
consensusConfigByron

    partialLedgerConfigByron :: PartialLedgerConfig ByronBlock
    partialLedgerConfigByron :: PartialLedgerConfig ByronBlock
partialLedgerConfigByron = ByronPartialLedgerConfig :: LedgerConfig ByronBlock
-> TriggerHardFork -> ByronPartialLedgerConfig
ByronPartialLedgerConfig {
          byronLedgerConfig :: LedgerConfig ByronBlock
byronLedgerConfig    = LedgerConfig ByronBlock
ledgerConfigByron
        , byronTriggerHardFork :: TriggerHardFork
byronTriggerHardFork = TriggerHardFork
triggerHardForkShelley
        }

    kByron :: SecurityParam
    kByron :: SecurityParam
kByron = Config -> SecurityParam
Byron.genesisSecurityParam Config
genesisByron

    -- Shelley

    tpraosParams :: TPraosParams
    tpraosParams :: TPraosParams
tpraosParams =
        MaxMajorProtVer
-> Nonce -> ShelleyGenesis (ShelleyEra c) -> TPraosParams
forall era.
MaxMajorProtVer -> Nonce -> ShelleyGenesis era -> TPraosParams
Shelley.mkTPraosParams
          MaxMajorProtVer
maxMajorProtVer
          Nonce
initialNonceShelley
          ShelleyGenesis (ShelleyEra c)
genesisShelley

    TPraosParams { Word64
tpraosSlotsPerKESPeriod :: TPraosParams -> Word64
tpraosSlotsPerKESPeriod :: Word64
tpraosSlotsPerKESPeriod, Word64
tpraosMaxKESEvo :: TPraosParams -> Word64
tpraosMaxKESEvo :: Word64
tpraosMaxKESEvo } = TPraosParams
tpraosParams

    praosParams :: PraosParams
    praosParams :: PraosParams
praosParams = PraosParams :: Word64
-> ActiveSlotCoeff
-> SecurityParam
-> Word64
-> Word64
-> MaxMajorProtVer
-> Word64
-> Network
-> SystemStart
-> PraosParams
PraosParams
      { praosSlotsPerKESPeriod :: Word64
praosSlotsPerKESPeriod = ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgSlotsPerKESPeriod ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosLeaderF :: ActiveSlotCoeff
praosLeaderF = PositiveUnitInterval -> ActiveSlotCoeff
SL.mkActiveSlotCoeff (PositiveUnitInterval -> ActiveSlotCoeff)
-> PositiveUnitInterval -> ActiveSlotCoeff
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis (ShelleyEra c) -> PositiveUnitInterval
forall era. ShelleyGenesis era -> PositiveUnitInterval
SL.sgActiveSlotsCoeff ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosSecurityParam :: SecurityParam
praosSecurityParam = Word64 -> SecurityParam
SecurityParam (Word64 -> SecurityParam) -> Word64 -> SecurityParam
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgSecurityParam ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosMaxKESEvo :: Word64
praosMaxKESEvo = ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgMaxKESEvolutions ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosQuorum :: Word64
praosQuorum = ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgUpdateQuorum ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosMaxMajorPV :: MaxMajorProtVer
praosMaxMajorPV = MaxMajorProtVer
maxMajorProtVer,
        praosMaxLovelaceSupply :: Word64
praosMaxLovelaceSupply = ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgMaxLovelaceSupply ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosNetworkId :: Network
praosNetworkId = ShelleyGenesis (ShelleyEra c) -> Network
forall era. ShelleyGenesis era -> Network
SL.sgNetworkId ShelleyGenesis (ShelleyEra c)
genesisShelley,
        praosSystemStart :: SystemStart
praosSystemStart = UTCTime -> SystemStart
SystemStart (UTCTime -> SystemStart) -> UTCTime -> SystemStart
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis (ShelleyEra c) -> UTCTime
forall era. ShelleyGenesis era -> UTCTime
SL.sgSystemStart ShelleyGenesis (ShelleyEra c)
genesisShelley
      }

    PraosParams { Word64
praosSlotsPerKESPeriod :: Word64
praosSlotsPerKESPeriod :: PraosParams -> Word64
praosSlotsPerKESPeriod, Word64
praosMaxKESEvo :: Word64
praosMaxKESEvo :: PraosParams -> Word64
praosMaxKESEvo } = PraosParams
praosParams

    blockConfigShelley :: BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
    blockConfigShelley :: BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
blockConfigShelley =
        ProtVer
-> ShelleyGenesis (ShelleyEra c)
-> [VKey 'BlockIssuer (EraCrypto (ShelleyEra c))]
-> BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
forall era proto.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis era
-> [VKey 'BlockIssuer (EraCrypto era)]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
          ProtVer
protVerShelley
          ShelleyGenesis (ShelleyEra c)
genesisShelley
          (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased)

    partialConsensusConfigShelley ::
         PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c) (ShelleyEra c)))
    partialConsensusConfigShelley :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (ShelleyEra c)))
partialConsensusConfigShelley = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (ShelleyEra c)))
TPraosParams
tpraosParams

    partialLedgerConfigShelley :: PartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
    partialLedgerConfigShelley :: PartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
partialLedgerConfigShelley =
        ShelleyGenesis (ShelleyEra c)
-> TranslationContext (ShelleyEra c)
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any (ShelleyEra c))
forall era proto.
ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
          ShelleyGenesis (ShelleyEra c)
genesisShelley
          ()  -- trivial translation context
          MaxMajorProtVer
maxMajorProtVer
          TriggerHardFork
triggerHardForkAllegra

    kShelley :: SecurityParam
    kShelley :: SecurityParam
kShelley = Word64 -> SecurityParam
SecurityParam (Word64 -> SecurityParam) -> Word64 -> SecurityParam
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis (ShelleyEra c) -> Word64
forall era. ShelleyGenesis era -> Word64
sgSecurityParam ShelleyGenesis (ShelleyEra c)
genesisShelley

    -- Allegra

    genesisAllegra :: ShelleyGenesis (AllegraEra c)
    genesisAllegra :: ShelleyGenesis (AllegraEra c)
genesisAllegra = TranslationContext (AllegraEra c)
-> ShelleyGenesis (PreviousEra (AllegraEra c))
-> ShelleyGenesis (AllegraEra c)
forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
Core.translateEra' () ShelleyGenesis (PreviousEra (AllegraEra c))
ShelleyGenesis (ShelleyEra c)
genesisShelley

    blockConfigAllegra :: BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
    blockConfigAllegra :: BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
blockConfigAllegra =
        ProtVer
-> ShelleyGenesis (AllegraEra c)
-> [VKey 'BlockIssuer (EraCrypto (AllegraEra c))]
-> BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
forall era proto.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis era
-> [VKey 'BlockIssuer (EraCrypto era)]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
          ProtVer
protVerAllegra
          ShelleyGenesis (AllegraEra c)
genesisAllegra
          (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased)

    partialConsensusConfigAllegra ::
         PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c) (AllegraEra c)))
    partialConsensusConfigAllegra :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AllegraEra c)))
partialConsensusConfigAllegra = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AllegraEra c)))
TPraosParams
tpraosParams

    partialLedgerConfigAllegra :: PartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
    partialLedgerConfigAllegra :: PartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
partialLedgerConfigAllegra =
        ShelleyGenesis (AllegraEra c)
-> TranslationContext (AllegraEra c)
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any (AllegraEra c))
forall era proto.
ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
          ShelleyGenesis (AllegraEra c)
genesisAllegra
          ()  -- trivial translation context
          MaxMajorProtVer
maxMajorProtVer
          TriggerHardFork
triggerHardForkMary

    -- Mary

    genesisMary :: ShelleyGenesis (MaryEra c)
    genesisMary :: ShelleyGenesis (MaryEra c)
genesisMary = TranslationContext (MaryEra c)
-> ShelleyGenesis (PreviousEra (MaryEra c))
-> ShelleyGenesis (MaryEra c)
forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
Core.translateEra' () ShelleyGenesis (PreviousEra (MaryEra c))
ShelleyGenesis (AllegraEra c)
genesisAllegra

    blockConfigMary :: BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
    blockConfigMary :: BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
blockConfigMary =
        ProtVer
-> ShelleyGenesis (MaryEra c)
-> [VKey 'BlockIssuer (EraCrypto (MaryEra c))]
-> BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall era proto.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis era
-> [VKey 'BlockIssuer (EraCrypto era)]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
          ProtVer
protVerMary
          ShelleyGenesis (MaryEra c)
genesisMary
          (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased)

    partialConsensusConfigMary ::
         PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c) (MaryEra c)))
    partialConsensusConfigMary :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (MaryEra c)))
partialConsensusConfigMary = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (MaryEra c)))
TPraosParams
tpraosParams

    partialLedgerConfigMary :: PartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
    partialLedgerConfigMary :: PartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
partialLedgerConfigMary =
        ShelleyGenesis (MaryEra c)
-> TranslationContext (MaryEra c)
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any (MaryEra c))
forall era proto.
ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
          ShelleyGenesis (MaryEra c)
genesisMary
          ()  -- trivial translation context
          MaxMajorProtVer
maxMajorProtVer
          TriggerHardFork
triggerHardForkAlonzo

    -- Alonzo

    genesisAlonzo :: ShelleyGenesis (AlonzoEra c)
    genesisAlonzo :: ShelleyGenesis (AlonzoEra c)
genesisAlonzo = TranslationContext (AlonzoEra c)
-> ShelleyGenesis (PreviousEra (AlonzoEra c))
-> ShelleyGenesis (AlonzoEra c)
forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
Core.translateEra' TranslationContext (AlonzoEra c)
transCtxtAlonzo ShelleyGenesis (PreviousEra (AlonzoEra c))
ShelleyGenesis (MaryEra c)
genesisMary

    blockConfigAlonzo :: BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
    blockConfigAlonzo :: BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
blockConfigAlonzo =
        ProtVer
-> ShelleyGenesis (AlonzoEra c)
-> [VKey 'BlockIssuer (EraCrypto (AlonzoEra c))]
-> BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
forall era proto.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis era
-> [VKey 'BlockIssuer (EraCrypto era)]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
          ProtVer
protVerAlonzo
          ShelleyGenesis (AlonzoEra c)
genesisAlonzo
          (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased)

    partialConsensusConfigAlonzo ::
         PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c) (AlonzoEra c)))
    partialConsensusConfigAlonzo :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AlonzoEra c)))
partialConsensusConfigAlonzo = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AlonzoEra c)))
TPraosParams
tpraosParams

    partialLedgerConfigAlonzo :: PartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
    partialLedgerConfigAlonzo :: PartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
partialLedgerConfigAlonzo =
        ShelleyGenesis (AlonzoEra c)
-> TranslationContext (AlonzoEra c)
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any (AlonzoEra c))
forall era proto.
ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
          ShelleyGenesis (AlonzoEra c)
genesisAlonzo
          TranslationContext (AlonzoEra c)
transCtxtAlonzo
          MaxMajorProtVer
maxMajorProtVer
          TriggerHardFork
triggerHardForkBabbage

    -- Babbage

    genesisBabbage :: ShelleyGenesis (BabbageEra c)
    genesisBabbage :: ShelleyGenesis (BabbageEra c)
genesisBabbage = TranslationContext (BabbageEra c)
-> ShelleyGenesis (PreviousEra (BabbageEra c))
-> ShelleyGenesis (BabbageEra c)
forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
Core.translateEra' TranslationContext (BabbageEra c)
transCtxtBabbage ShelleyGenesis (AlonzoEra c)
ShelleyGenesis (PreviousEra (BabbageEra c))
genesisAlonzo

    blockConfigBabbage :: BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
    blockConfigBabbage :: BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
blockConfigBabbage =
        ProtVer
-> ShelleyGenesis (BabbageEra c)
-> [VKey 'BlockIssuer (EraCrypto (BabbageEra c))]
-> BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
forall era proto.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis era
-> [VKey 'BlockIssuer (EraCrypto era)]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
          ProtVer
protVerBabbage
          ShelleyGenesis (BabbageEra c)
genesisBabbage
          (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer c
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer c)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased)

    partialConsensusConfigBabbage ::
         PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
    partialConsensusConfigBabbage :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
partialConsensusConfigBabbage = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
PraosParams
praosParams

    partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
    partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
partialLedgerConfigBabbage =
        ShelleyGenesis (BabbageEra c)
-> TranslationContext (BabbageEra c)
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any (BabbageEra c))
forall era proto.
ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
          ShelleyGenesis (BabbageEra c)
genesisBabbage
          TranslationContext (BabbageEra c)
transCtxtBabbage
          MaxMajorProtVer
maxMajorProtVer
          TriggerHardFork
TriggerHardForkNever
    -- Cardano

    k :: SecurityParam
    k :: SecurityParam
k = Bool -> SecurityParam -> SecurityParam
forall a. HasCallStack => Bool -> a -> a
assert (SecurityParam
kByron SecurityParam -> SecurityParam -> Bool
forall a. Eq a => a -> a -> Bool
== SecurityParam
kShelley) SecurityParam
kByron

    shape :: History.Shape (CardanoEras c)
    shape :: Shape (CardanoEras c)
shape = Exactly (CardanoEras c) EraParams -> Shape (CardanoEras c)
forall (xs :: [*]). Exactly xs EraParams -> Shape xs
History.Shape (Exactly (CardanoEras c) EraParams -> Shape (CardanoEras c))
-> Exactly (CardanoEras c) EraParams -> Shape (CardanoEras c)
forall a b. (a -> b) -> a -> b
$ NP (K EraParams) (CardanoEras c)
-> Exactly (CardanoEras c) EraParams
forall (xs :: [*]) a. NP (K a) xs -> Exactly xs a
Exactly (NP (K EraParams) (CardanoEras c)
 -> Exactly (CardanoEras c) EraParams)
-> NP (K EraParams) (CardanoEras c)
-> Exactly (CardanoEras c) EraParams
forall a b. (a -> b) -> a -> b
$
           EraParams -> K EraParams ByronBlock
forall k a (b :: k). a -> K a b
K (Config -> EraParams
Byron.byronEraParams     Config
genesisByron)
        K EraParams ByronBlock
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP (K EraParams) (CardanoEras c)
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) (ShelleyEra c))
forall k a (b :: k). a -> K a b
K (ShelleyGenesis (ShelleyEra c) -> EraParams
forall era. ShelleyGenesis era -> EraParams
Shelley.shelleyEraParams ShelleyGenesis (ShelleyEra c)
genesisShelley)
        K EraParams (ShelleyBlock (TPraos c) (ShelleyEra c))
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) (AllegraEra c))
forall k a (b :: k). a -> K a b
K (ShelleyGenesis (AllegraEra c) -> EraParams
forall era. ShelleyGenesis era -> EraParams
Shelley.shelleyEraParams ShelleyGenesis (AllegraEra c)
genesisAllegra)
        K EraParams (ShelleyBlock (TPraos c) (AllegraEra c))
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) (MaryEra c))
forall k a (b :: k). a -> K a b
K (ShelleyGenesis (MaryEra c) -> EraParams
forall era. ShelleyGenesis era -> EraParams
Shelley.shelleyEraParams ShelleyGenesis (MaryEra c)
genesisMary)
        K EraParams (ShelleyBlock (TPraos c) (MaryEra c))
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) (AlonzoEra c))
forall k a (b :: k). a -> K a b
K (ShelleyGenesis (AlonzoEra c) -> EraParams
forall era. ShelleyGenesis era -> EraParams
Shelley.shelleyEraParams ShelleyGenesis (AlonzoEra c)
genesisAlonzo)
        K EraParams (ShelleyBlock (TPraos c) (AlonzoEra c))
-> NP (K EraParams) '[ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* EraParams -> K EraParams (ShelleyBlock (Praos c) (BabbageEra c))
forall k a (b :: k). a -> K a b
K (ShelleyGenesis (BabbageEra c) -> EraParams
forall era. ShelleyGenesis era -> EraParams
Shelley.shelleyEraParams ShelleyGenesis (BabbageEra c)
genesisBabbage)
        K EraParams (ShelleyBlock (Praos c) (BabbageEra c))
-> NP (K EraParams) '[]
-> NP (K EraParams) '[ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (K EraParams) '[]
forall k (a :: k -> *). NP a '[]
Nil

    cfg :: TopLevelConfig (CardanoBlock c)
    cfg :: TopLevelConfig (CardanoBlock c)
cfg = TopLevelConfig :: forall blk.
ConsensusConfig (BlockProtocol blk)
-> LedgerConfig blk
-> BlockConfig blk
-> CodecConfig blk
-> StorageConfig blk
-> TopLevelConfig blk
TopLevelConfig {
        topLevelConfigProtocol :: ConsensusConfig (BlockProtocol (CardanoBlock c))
topLevelConfigProtocol = HardForkConsensusConfig :: forall (xs :: [*]).
SecurityParam
-> Shape xs
-> PerEraConsensusConfig xs
-> ConsensusConfig (HardForkProtocol xs)
HardForkConsensusConfig {
            hardForkConsensusConfigK :: SecurityParam
hardForkConsensusConfigK      = SecurityParam
k
          , hardForkConsensusConfigShape :: Shape (CardanoEras c)
hardForkConsensusConfigShape  = Shape (CardanoEras c)
shape
          , hardForkConsensusConfigPerEra :: PerEraConsensusConfig (CardanoEras c)
hardForkConsensusConfigPerEra = NP WrapPartialConsensusConfig (CardanoEras c)
-> PerEraConsensusConfig (CardanoEras c)
forall (xs :: [*]).
NP WrapPartialConsensusConfig xs -> PerEraConsensusConfig xs
PerEraConsensusConfig
              (  PartialConsensusConfig (BlockProtocol ByronBlock)
-> WrapPartialConsensusConfig ByronBlock
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig (BlockProtocol ByronBlock)
partialConsensusConfigByron
              WrapPartialConsensusConfig ByronBlock
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP WrapPartialConsensusConfig (CardanoEras c)
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (ShelleyEra c)))
-> WrapPartialConsensusConfig
     (ShelleyBlock (TPraos c) (ShelleyEra c))
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (ShelleyEra c)))
partialConsensusConfigShelley
              WrapPartialConsensusConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AllegraEra c)))
-> WrapPartialConsensusConfig
     (ShelleyBlock (TPraos c) (AllegraEra c))
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AllegraEra c)))
partialConsensusConfigAllegra
              WrapPartialConsensusConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (MaryEra c)))
-> WrapPartialConsensusConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (MaryEra c)))
partialConsensusConfigMary
              WrapPartialConsensusConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AlonzoEra c)))
-> WrapPartialConsensusConfig
     (ShelleyBlock (TPraos c) (AlonzoEra c))
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) (AlonzoEra c)))
partialConsensusConfigAlonzo
              WrapPartialConsensusConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> NP
     WrapPartialConsensusConfig '[ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
-> WrapPartialConsensusConfig
     (ShelleyBlock (Praos c) (BabbageEra c))
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
partialConsensusConfigBabbage
              WrapPartialConsensusConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> NP WrapPartialConsensusConfig '[]
-> NP
     WrapPartialConsensusConfig '[ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP WrapPartialConsensusConfig '[]
forall k (a :: k -> *). NP a '[]
Nil
              )
          }
      , topLevelConfigLedger :: LedgerConfig (CardanoBlock c)
topLevelConfigLedger = HardForkLedgerConfig :: forall (xs :: [*]).
Shape xs -> PerEraLedgerConfig xs -> HardForkLedgerConfig xs
HardForkLedgerConfig {
            hardForkLedgerConfigShape :: Shape (CardanoEras c)
hardForkLedgerConfigShape  = Shape (CardanoEras c)
shape
          , hardForkLedgerConfigPerEra :: PerEraLedgerConfig (CardanoEras c)
hardForkLedgerConfigPerEra = NP WrapPartialLedgerConfig (CardanoEras c)
-> PerEraLedgerConfig (CardanoEras c)
forall (xs :: [*]).
NP WrapPartialLedgerConfig xs -> PerEraLedgerConfig xs
PerEraLedgerConfig
              (  PartialLedgerConfig ByronBlock
-> WrapPartialLedgerConfig ByronBlock
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig ByronBlock
partialLedgerConfigByron
              WrapPartialLedgerConfig ByronBlock
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP WrapPartialLedgerConfig (CardanoEras c)
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
partialLedgerConfigShelley
              WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
partialLedgerConfigAllegra
              WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
partialLedgerConfigMary
              WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
partialLedgerConfigAlonzo
              WrapPartialLedgerConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> NP
     WrapPartialLedgerConfig '[ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* PartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> WrapPartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
partialLedgerConfigBabbage
              WrapPartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> NP WrapPartialLedgerConfig '[]
-> NP
     WrapPartialLedgerConfig '[ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP WrapPartialLedgerConfig '[]
forall k (a :: k -> *). NP a '[]
Nil
              )
          }
      , topLevelConfigBlock :: BlockConfig (CardanoBlock c)
topLevelConfigBlock =
          BlockConfig ByronBlock
-> BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> BlockConfig (CardanoBlock c)
forall c.
BlockConfig ByronBlock
-> BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CardanoBlockConfig c
CardanoBlockConfig
            BlockConfig ByronBlock
blockConfigByron
            BlockConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
blockConfigShelley
            BlockConfig (ShelleyBlock (TPraos c) (AllegraEra c))
blockConfigAllegra
            BlockConfig (ShelleyBlock (TPraos c) (MaryEra c))
blockConfigMary
            BlockConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
blockConfigAlonzo
            BlockConfig (ShelleyBlock (Praos c) (BabbageEra c))
blockConfigBabbage
      , topLevelConfigCodec :: CodecConfig (CardanoBlock c)
topLevelConfigCodec =
          CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CodecConfig (CardanoBlock c)
forall c.
CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CardanoCodecConfig c
CardanoCodecConfig
            (TopLevelConfig ByronBlock -> CodecConfig ByronBlock
forall blk. TopLevelConfig blk -> CodecConfig blk
configCodec TopLevelConfig ByronBlock
topLevelConfigByron)
            CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
      , topLevelConfigStorage :: StorageConfig (CardanoBlock c)
topLevelConfigStorage =
          StorageConfig ByronBlock
-> StorageConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> StorageConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> StorageConfig (CardanoBlock c)
forall c.
StorageConfig ByronBlock
-> StorageConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> StorageConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> StorageConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CardanoStorageConfig c
CardanoStorageConfig
            (TopLevelConfig ByronBlock -> StorageConfig ByronBlock
forall blk. TopLevelConfig blk -> StorageConfig blk
configStorage TopLevelConfig ByronBlock
topLevelConfigByron)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) (AllegraEra c))
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (Praos c) (BabbageEra c))
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
      }

    -- When the initial ledger state is not in the Byron era, register the
    -- initial staking and initial funds (if provided in the genesis config) in
    -- the ledger state.
    initExtLedgerStateCardano :: ExtLedgerState (CardanoBlock c)
    initExtLedgerStateCardano :: ExtLedgerState (CardanoBlock c)
initExtLedgerStateCardano = ExtLedgerState :: forall blk.
LedgerState blk -> HeaderState blk -> ExtLedgerState blk
ExtLedgerState {
          headerState :: HeaderState (CardanoBlock c)
headerState = HeaderState (CardanoBlock c)
initHeaderState
        , ledgerState :: LedgerState (CardanoBlock c)
ledgerState = (forall era proto.
 (EraCrypto era ~ c, ShelleyCompatible proto era) =>
 LedgerState (ShelleyBlock proto era)
 -> LedgerState (ShelleyBlock proto era))
-> LedgerState (CardanoBlock c) -> LedgerState (CardanoBlock c)
forall c.
(PraosCrypto c, PraosCrypto c) =>
(forall era proto.
 (EraCrypto era ~ c, ShelleyCompatible proto era) =>
 LedgerState (ShelleyBlock proto era)
 -> LedgerState (ShelleyBlock proto era))
-> LedgerState (CardanoBlock c) -> LedgerState (CardanoBlock c)
overShelleyBasedLedgerState forall era proto.
(EraCrypto era ~ c, ShelleyCompatible proto era) =>
LedgerState (ShelleyBlock proto era)
-> LedgerState (ShelleyBlock proto era)
forall era proto.
(EraCrypto era ~ c, ShelleyBasedEra era) =>
LedgerState (ShelleyBlock proto era)
-> LedgerState (ShelleyBlock proto era)
register LedgerState (CardanoBlock c)
initLedgerState
        }
      where
        initHeaderState :: HeaderState (CardanoBlock c)
        initLedgerState :: LedgerState (CardanoBlock c)
        ExtLedgerState LedgerState (CardanoBlock c)
initLedgerState HeaderState (CardanoBlock c)
initHeaderState =
          TopLevelConfig (CardanoBlock c)
-> ExtLedgerState ByronBlock -> ExtLedgerState (CardanoBlock c)
forall x (xs :: [*]).
CanHardFork (x : xs) =>
TopLevelConfig (HardForkBlock (x : xs))
-> ExtLedgerState x -> ExtLedgerState (HardForkBlock (x : xs))
injectInitialExtLedgerState TopLevelConfig (CardanoBlock c)
cfg ExtLedgerState ByronBlock
initExtLedgerStateByron

        register ::
             (EraCrypto era ~ c, ShelleyBasedEra era)
          => LedgerState (ShelleyBlock proto era)
          -> LedgerState (ShelleyBlock proto era)
        register :: LedgerState (ShelleyBlock proto era)
-> LedgerState (ShelleyBlock proto era)
register LedgerState (ShelleyBlock proto era)
st = LedgerState (ShelleyBlock proto era)
R:LedgerStateShelleyBlock proto era
st {
              shelleyLedgerState :: NewEpochState era
Shelley.shelleyLedgerState =
                -- We must first register the initial funds, because the stake
                -- information depends on it.
                  ShelleyGenesisStaking (EraCrypto era)
-> NewEpochState era -> NewEpochState era
forall era.
ShelleyBasedEra era =>
ShelleyGenesisStaking (EraCrypto era)
-> NewEpochState era -> NewEpochState era
registerGenesisStaking
                    (ShelleyGenesis (ShelleyEra c)
-> ShelleyGenesisStaking (EraCrypto (ShelleyEra c))
forall era.
ShelleyGenesis era -> ShelleyGenesisStaking (Crypto era)
SL.sgStaking ShelleyGenesis (ShelleyEra c)
genesisShelley)
                (NewEpochState era -> NewEpochState era)
-> (NewEpochState era -> NewEpochState era)
-> NewEpochState era
-> NewEpochState era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map (Addr (EraCrypto era)) Coin
-> NewEpochState era -> NewEpochState era
forall era.
(ShelleyBasedEra era, HasCallStack) =>
Map (Addr (EraCrypto era)) Coin
-> NewEpochState era -> NewEpochState era
registerInitialFunds
                    (ShelleyGenesis (ShelleyEra c)
-> Map (Addr (EraCrypto (ShelleyEra c))) Coin
forall era. ShelleyGenesis era -> Map (Addr (Crypto era)) Coin
SL.sgInitialFunds ShelleyGenesis (ShelleyEra c)
genesisShelley)
                (NewEpochState era -> NewEpochState era)
-> NewEpochState era -> NewEpochState era
forall a b. (a -> b) -> a -> b
$ LedgerState (ShelleyBlock proto era) -> NewEpochState era
forall proto era.
LedgerState (ShelleyBlock proto era) -> NewEpochState era
Shelley.shelleyLedgerState LedgerState (ShelleyBlock proto era)
st
            }

    -- | For each element in the list, a block forging thread will be started.
    --
    -- When no credentials are passed, there will be no threads.
    --
    -- Typically, there will only be a single set of credentials for Shelley.
    --
    -- In case there are multiple credentials for Shelley, which is only done
    -- for testing/benchmarking purposes, we'll have a separate thread for each
    -- of them.
    --
    -- If Byron credentials are passed, we merge them with the Shelley
    -- credentials if possible, so that we only have a single thread running in
    -- the case we have Byron credentials and a single set of Shelley
    -- credentials. If there are multiple Shelley credentials, we merge the
    -- Byron credentials with the first Shelley one but still have separate
    -- threads for the remaining Shelley ones.
    blockForging :: m [BlockForging m (CardanoBlock c)]
    blockForging :: m [BlockForging m (CardanoBlock c)]
blockForging = do
        [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleyBased <- (ShelleyLeaderCredentials c
 -> m (NonEmptyOptNP (BlockForging m) (CardanoEras c)))
-> [ShelleyLeaderCredentials c]
-> m [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ShelleyLeaderCredentials c
-> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
blockForgingShelleyBased [ShelleyLeaderCredentials c]
[ShelleyLeaderCredentials (EraCrypto (ShelleyEra c))]
credssShelleyBased
        let blockForgings :: [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
            blockForgings :: [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
blockForgings = case (Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
mBlockForgingByron, [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleyBased) of
              (Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
Nothing,    [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleys)         -> [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleys
              (Just NonEmptyOptNP (BlockForging m) (CardanoEras c)
byron, [])               -> [NonEmptyOptNP (BlockForging m) (CardanoEras c)
byron]
              (Just NonEmptyOptNP (BlockForging m) (CardanoEras c)
byron, NonEmptyOptNP (BlockForging m) (CardanoEras c)
shelley:[NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleys) ->
                  (forall a.
 These1 (BlockForging m) (BlockForging m) a -> BlockForging m a)
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (xs :: [*]).
(forall a. These1 f g a -> h a)
-> NonEmptyOptNP f xs -> NonEmptyOptNP g xs -> NonEmptyOptNP h xs
OptNP.zipWith forall a.
These1 (BlockForging m) (BlockForging m) a -> BlockForging m a
forall (f :: * -> *) a. These1 f f a -> f a
merge NonEmptyOptNP (BlockForging m) (CardanoEras c)
byron NonEmptyOptNP (BlockForging m) (CardanoEras c)
shelley NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
-> [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
forall a. a -> [a] -> [a]
: [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
shelleys
                where
                  -- When merging Byron with Shelley-based eras, we should never
                  -- merge two from the same era.
                  merge :: These1 f f a -> f a
merge (These1 f a
_ f a
_) = [Char] -> f a
forall a. HasCallStack => [Char] -> a
error [Char]
"forgings of the same era"
                  merge (This1 f a
x)    = f a
x
                  merge (That1 f a
y)    = f a
y

        [BlockForging m (CardanoBlock c)]
-> m [BlockForging m (CardanoBlock c)]
forall (m :: * -> *) a. Monad m => a -> m a
return ([BlockForging m (CardanoBlock c)]
 -> m [BlockForging m (CardanoBlock c)])
-> [BlockForging m (CardanoBlock c)]
-> m [BlockForging m (CardanoBlock c)]
forall a b. (a -> b) -> a -> b
$ Text
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> BlockForging m (CardanoBlock c)
forall (m :: * -> *) (xs :: [*]).
(CanHardFork xs, Monad m) =>
Text
-> NonEmptyOptNP (BlockForging m) xs
-> BlockForging m (HardForkBlock xs)
hardForkBlockForging Text
"Cardano" (NonEmptyOptNP (BlockForging m) (CardanoEras c)
 -> BlockForging m (CardanoBlock c))
-> [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
-> [BlockForging m (CardanoBlock c)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [NonEmptyOptNP (BlockForging m) (CardanoEras c)]
blockForgings

    mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
    mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
mBlockForgingByron = do
        ByronLeaderCredentials
creds <- Maybe ByronLeaderCredentials
mCredsByron
        NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
forall (m :: * -> *) a. Monad m => a -> m a
return (NonEmptyOptNP (BlockForging m) (CardanoEras c)
 -> Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c)))
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ Overrides ByronBlock
-> ByronLeaderCredentials -> BlockForging m ByronBlock
forall (m :: * -> *).
Monad m =>
Overrides ByronBlock
-> ByronLeaderCredentials -> BlockForging m ByronBlock
byronBlockForging Overrides ByronBlock
maxTxCapacityOverridesByron ByronLeaderCredentials
creds BlockForging m ByronBlock
-> Index (CardanoEras c) ByronBlock
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
forall k (xs :: [k]) (f :: k -> *) (x :: k).
SListI xs =>
f x -> Index xs x -> NonEmptyOptNP f xs
`OptNP.at` Index (CardanoEras c) ByronBlock
forall a (x :: a) (xs1 :: [a]). Index (x : xs1) x
IZ

    blockForgingShelleyBased ::
         ShelleyLeaderCredentials c
      -> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
    blockForgingShelleyBased :: ShelleyLeaderCredentials c
-> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
blockForgingShelleyBased ShelleyLeaderCredentials c
credentials = do
        let ShelleyLeaderCredentials
              { shelleyLeaderCredentialsInitSignKey :: forall c. ShelleyLeaderCredentials c -> SignKeyKES c
shelleyLeaderCredentialsInitSignKey = SignKeyKES c
initSignKey
              , shelleyLeaderCredentialsCanBeLeader :: forall c. ShelleyLeaderCredentials c -> PraosCanBeLeader c
shelleyLeaderCredentialsCanBeLeader = PraosCanBeLeader c
canBeLeader
              } = ShelleyLeaderCredentials c
credentials

        HotKey c m
hotKey <- do
          let maxKESEvo :: Word64
              maxKESEvo :: Word64
maxKESEvo = Bool -> Word64 -> Word64
forall a. HasCallStack => Bool -> a -> a
assert (Word64
tpraosMaxKESEvo Word64 -> Word64 -> Bool
forall a. Eq a => a -> a -> Bool
== Word64
praosMaxKESEvo) Word64
praosMaxKESEvo

              startPeriod :: Absolute.KESPeriod
              startPeriod :: KESPeriod
startPeriod = OCert c -> KESPeriod
forall crypto. OCert crypto -> KESPeriod
Absolute.ocertKESPeriod (OCert c -> KESPeriod) -> OCert c -> KESPeriod
forall a b. (a -> b) -> a -> b
$ PraosCanBeLeader c -> OCert c
forall c. PraosCanBeLeader c -> OCert c
praosCanBeLeaderOpCert PraosCanBeLeader c
canBeLeader

          SignKeyKES c -> KESPeriod -> Word64 -> m (HotKey c m)
forall (m :: * -> *) c.
(Crypto c, IOLike m) =>
SignKeyKES c -> KESPeriod -> Word64 -> m (HotKey c m)
HotKey.mkHotKey @m @c SignKeyKES c
initSignKey KESPeriod
startPeriod Word64
maxKESEvo

        let slotToPeriod :: SlotNo -> Absolute.KESPeriod
            slotToPeriod :: SlotNo -> KESPeriod
slotToPeriod (SlotNo Word64
slot) = Bool -> KESPeriod -> KESPeriod
forall a. HasCallStack => Bool -> a -> a
assert (Word64
tpraosSlotsPerKESPeriod Word64 -> Word64 -> Bool
forall a. Eq a => a -> a -> Bool
== Word64
praosSlotsPerKESPeriod) (KESPeriod -> KESPeriod) -> KESPeriod -> KESPeriod
forall a b. (a -> b) -> a -> b
$
              Word -> KESPeriod
Absolute.KESPeriod (Word -> KESPeriod) -> Word -> KESPeriod
forall a b. (a -> b) -> a -> b
$ Word64 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Word) -> Word64 -> Word
forall a b. (a -> b) -> a -> b
$ Word64
slot Word64 -> Word64 -> Word64
forall a. Integral a => a -> a -> a
`div` Word64
praosSlotsPerKESPeriod

        let tpraos :: forall era.
                 ShelleyEraWithCrypto c (TPraos c) era
              => TxLimits.Overrides (ShelleyBlock (TPraos c) era)
              -> BlockForging m     (ShelleyBlock (TPraos c) era)
            tpraos :: Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos Overrides (ShelleyBlock (TPraos c) era)
maxTxCapacityOverrides =
              HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
forall (m :: * -> *) c era.
(PraosCrypto c, ShelleyEraWithCrypto c (TPraos c) era, IOLike m) =>
HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
TPraos.shelleySharedBlockForging HotKey c m
hotKey SlotNo -> KESPeriod
slotToPeriod ShelleyLeaderCredentials c
credentials Overrides (ShelleyBlock (TPraos c) era)
maxTxCapacityOverrides

        let praos :: forall era.
                 ShelleyEraWithCrypto c (Praos c) era
              => TxLimits.Overrides (ShelleyBlock (Praos c) era)
              -> BlockForging m     (ShelleyBlock (Praos c) era)
            praos :: Overrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
praos Overrides (ShelleyBlock (Praos c) era)
maxTxCapacityOverrides =
              HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> Overrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
forall (m :: * -> *) c era.
(ShelleyEraWithCrypto c (Praos c) era, IOLike m) =>
HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> Overrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
Praos.praosSharedBlockForging HotKey c m
hotKey SlotNo -> KESPeriod
slotToPeriod ShelleyLeaderCredentials c
credentials Overrides (ShelleyBlock (Praos c) era)
maxTxCapacityOverrides

        NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure
          (NonEmptyOptNP (BlockForging m) (CardanoEras c)
 -> m (NonEmptyOptNP (BlockForging m) (CardanoEras c)))
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
-> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ OptNP
  'False
  (BlockForging m)
  '[ShelleyBlock (TPraos c) (ShelleyEra c),
    ShelleyBlock (TPraos c) (AllegraEra c),
    ShelleyBlock (TPraos c) (MaryEra c),
    ShelleyBlock (TPraos c) (AlonzoEra c),
    ShelleyBlock (Praos c) (BabbageEra c)]
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
forall k (empty :: Bool) (f :: k -> *) (xs1 :: [k]) (x :: k).
OptNP empty f xs1 -> OptNP empty f (x : xs1)
OptSkip    -- Byron
          (OptNP
   'False
   (BlockForging m)
   '[ShelleyBlock (TPraos c) (ShelleyEra c),
     ShelleyBlock (TPraos c) (AllegraEra c),
     ShelleyBlock (TPraos c) (MaryEra c),
     ShelleyBlock (TPraos c) (AlonzoEra c),
     ShelleyBlock (Praos c) (BabbageEra c)]
 -> NonEmptyOptNP (BlockForging m) (CardanoEras c))
-> OptNP
     'False
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NonEmptyOptNP (BlockForging m) (CardanoEras c)
forall a b. (a -> b) -> a -> b
$ NP
  (BlockForging m)
  '[ShelleyBlock (TPraos c) (ShelleyEra c),
    ShelleyBlock (TPraos c) (AllegraEra c),
    ShelleyBlock (TPraos c) (MaryEra c),
    ShelleyBlock (TPraos c) (AlonzoEra c),
    ShelleyBlock (Praos c) (BabbageEra c)]
-> OptNP
     'False
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (f :: k -> *) (xs :: [k]).
IsNonEmpty xs =>
NP f xs -> NonEmptyOptNP f xs
OptNP.fromNonEmptyNP (NP
   (BlockForging m)
   '[ShelleyBlock (TPraos c) (ShelleyEra c),
     ShelleyBlock (TPraos c) (AllegraEra c),
     ShelleyBlock (TPraos c) (MaryEra c),
     ShelleyBlock (TPraos c) (AlonzoEra c),
     ShelleyBlock (Praos c) (BabbageEra c)]
 -> OptNP
      'False
      (BlockForging m)
      '[ShelleyBlock (TPraos c) (ShelleyEra c),
        ShelleyBlock (TPraos c) (AllegraEra c),
        ShelleyBlock (TPraos c) (MaryEra c),
        ShelleyBlock (TPraos c) (AlonzoEra c),
        ShelleyBlock (Praos c) (BabbageEra c)])
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> OptNP
     'False
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall a b. (a -> b) -> a -> b
$
            Overrides (ShelleyBlock (TPraos c) (ShelleyEra c))
-> BlockForging m (ShelleyBlock (TPraos c) (ShelleyEra c))
forall era.
ShelleyEraWithCrypto c (TPraos c) era =>
Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos Overrides (ShelleyBlock (TPraos c) (ShelleyEra c))
maxTxCapacityOverridesShelley BlockForging m (ShelleyBlock (TPraos c) (ShelleyEra c))
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (ShelleyEra c),
       ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:*
            Overrides (ShelleyBlock (TPraos c) (AllegraEra c))
-> BlockForging m (ShelleyBlock (TPraos c) (AllegraEra c))
forall era.
ShelleyEraWithCrypto c (TPraos c) era =>
Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos Overrides (ShelleyBlock (TPraos c) (AllegraEra c))
maxTxCapacityOverridesAllegra BlockForging m (ShelleyBlock (TPraos c) (AllegraEra c))
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (AllegraEra c),
       ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:*
            Overrides (ShelleyBlock (TPraos c) (MaryEra c))
-> BlockForging m (ShelleyBlock (TPraos c) (MaryEra c))
forall era.
ShelleyEraWithCrypto c (TPraos c) era =>
Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos Overrides (ShelleyBlock (TPraos c) (MaryEra c))
maxTxCapacityOverridesMary    BlockForging m (ShelleyBlock (TPraos c) (MaryEra c))
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (MaryEra c),
       ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:*
            Overrides (ShelleyBlock (TPraos c) (AlonzoEra c))
-> BlockForging m (ShelleyBlock (TPraos c) (AlonzoEra c))
forall era.
ShelleyEraWithCrypto c (TPraos c) era =>
Overrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos Overrides (ShelleyBlock (TPraos c) (AlonzoEra c))
maxTxCapacityOverridesAlonzo  BlockForging m (ShelleyBlock (TPraos c) (AlonzoEra c))
-> NP (BlockForging m) '[ShelleyBlock (Praos c) (BabbageEra c)]
-> NP
     (BlockForging m)
     '[ShelleyBlock (TPraos c) (AlonzoEra c),
       ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:*
            Overrides (ShelleyBlock (Praos c) (BabbageEra c))
-> BlockForging m (ShelleyBlock (Praos c) (BabbageEra c))
forall era.
ShelleyEraWithCrypto c (Praos c) era =>
Overrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
praos  Overrides (ShelleyBlock (Praos c) (BabbageEra c))
maxTxCapacityOverridesBabbage BlockForging m (ShelleyBlock (Praos c) (BabbageEra c))
-> NP (BlockForging m) '[]
-> NP (BlockForging m) '[ShelleyBlock (Praos c) (BabbageEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:*
            NP (BlockForging m) '[]
forall k (a :: k -> *). NP a '[]
Nil

protocolClientInfoCardano
  :: forall c.
     -- Byron
     EpochSlots
  -> ProtocolClientInfo (CardanoBlock c)
protocolClientInfoCardano :: EpochSlots -> ProtocolClientInfo (CardanoBlock c)
protocolClientInfoCardano EpochSlots
epochSlots = ProtocolClientInfo :: forall b. CodecConfig b -> ProtocolClientInfo b
ProtocolClientInfo {
      pClientInfoCodecConfig :: CodecConfig (CardanoBlock c)
pClientInfoCodecConfig =
        CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CodecConfig (CardanoBlock c)
forall c.
CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
-> CardanoCodecConfig c
CardanoCodecConfig
          (ProtocolClientInfo ByronBlock -> CodecConfig ByronBlock
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig (EpochSlots -> ProtocolClientInfo ByronBlock
protocolClientInfoByron EpochSlots
epochSlots))
          (ProtocolClientInfo (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (ShelleyEra c))
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) (ShelleyEra c))
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) (AllegraEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AllegraEra c))
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) (AllegraEra c))
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) (MaryEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (MaryEra c))
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) (MaryEra c))
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CodecConfig (ShelleyBlock (TPraos c) (AlonzoEra c))
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) (AlonzoEra c))
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (Praos c) (BabbageEra c))
-> CodecConfig (ShelleyBlock (Praos c) (BabbageEra c))
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (Praos c) (BabbageEra c))
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
    }

{-------------------------------------------------------------------------------
  Helpers
-------------------------------------------------------------------------------}

mkPartialLedgerConfigShelley ::
     ShelleyGenesis era
  -> Core.TranslationContext era
  -> MaxMajorProtVer
  -> TriggerHardFork
  -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley :: ShelleyGenesis era
-> TranslationContext era
-> MaxMajorProtVer
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
  ShelleyGenesis era
genesisShelley
  TranslationContext era
transCtxt
  MaxMajorProtVer
maxMajorProtVer
  TriggerHardFork
shelleyTriggerHardFork =
    ShelleyPartialLedgerConfig :: forall era.
ShelleyLedgerConfig era
-> TriggerHardFork -> ShelleyPartialLedgerConfig era
ShelleyPartialLedgerConfig {
          shelleyLedgerConfig :: ShelleyLedgerConfig era
shelleyLedgerConfig =
            ShelleyGenesis era
-> TranslationContext era
-> EpochInfo (Except PastHorizonException)
-> MaxMajorProtVer
-> ShelleyLedgerConfig era
forall era.
ShelleyGenesis era
-> TranslationContext era
-> EpochInfo (Except PastHorizonException)
-> MaxMajorProtVer
-> ShelleyLedgerConfig era
Shelley.mkShelleyLedgerConfig
              ShelleyGenesis era
genesisShelley
              TranslationContext era
transCtxt
              -- 'completeLedgerConfig' will replace the 'History.dummyEpochInfo'
              -- in the partial ledger config with the correct one.
              EpochInfo (Except PastHorizonException)
History.dummyEpochInfo
              MaxMajorProtVer
maxMajorProtVer
        , shelleyTriggerHardFork :: TriggerHardFork
shelleyTriggerHardFork = TriggerHardFork
shelleyTriggerHardFork
        }