{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Ouroboros.Consensus.Cardano.Node
  ( CardanoHardForkConstraints
  , CardanoHardForkTrigger (..)
  , CardanoHardForkTriggers
    ( ..
    , CardanoHardForkTriggers'
    , triggerHardForkShelley
    , triggerHardForkAllegra
    , triggerHardForkMary
    , triggerHardForkAlonzo
    , triggerHardForkBabbage
    , triggerHardForkConway
    )
  , CardanoProtocolParams (..)
  , MaxMajorProtVer (..)
  , TriggerHardFork (..)
  , protocolClientInfoCardano
  , protocolInfoCardano

    -- * SupportedNetworkProtocolVersion
  , pattern CardanoNodeToClientVersion12
  , pattern CardanoNodeToClientVersion13
  , pattern CardanoNodeToClientVersion14
  , pattern CardanoNodeToClientVersion15
  , pattern CardanoNodeToClientVersion16
  , pattern CardanoNodeToNodeVersion1
  , pattern CardanoNodeToNodeVersion2
  ) where

import Cardano.Binary (DecoderError (..), enforceSize)
import Cardano.Chain.Slotting (EpochSlots)
import qualified Cardano.Ledger.Api.Era as L
import qualified Cardano.Ledger.Api.Transition as L
import qualified Cardano.Ledger.BaseTypes as SL
import qualified Cardano.Ledger.Shelley.API as SL
import Cardano.Prelude (cborError)
import qualified Cardano.Protocol.TPraos.OCert as Absolute
  ( KESPeriod (..)
  , ocertKESPeriod
  )
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.BasicFunctors
import Data.SOP.Counting
import Data.SOP.Functors (Flip (..))
import Data.SOP.Index
import Data.SOP.OptNP (NonEmptyOptNP, OptNP (OptSkip))
import qualified Data.SOP.OptNP as OptNP
import Data.SOP.Strict
import Data.Word (Word16, Word64)
import Lens.Micro ((^.))
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Byron.ByronHFC
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 Ouroboros.Consensus.Cardano.Block
import Ouroboros.Consensus.Cardano.CanHardFork
import Ouroboros.Consensus.Cardano.QueryHF ()
import Ouroboros.Consensus.Config
import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.Embed.Nary
import Ouroboros.Consensus.HardFork.Combinator.Serialisation
import qualified Ouroboros.Consensus.HardFork.History as History
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Extended
import Ouroboros.Consensus.Ledger.Tables
import Ouroboros.Consensus.Ledger.Tables.Utils (forgetLedgerTables)
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.Protocol.Praos (Praos, PraosParams (..))
import Ouroboros.Consensus.Protocol.Praos.Common
  ( praosCanBeLeaderOpCert
  )
import Ouroboros.Consensus.Protocol.TPraos (TPraos, TPraosParams (..))
import qualified Ouroboros.Consensus.Protocol.TPraos as Shelley
import Ouroboros.Consensus.Shelley.HFEras ()
import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock)
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley
import Ouroboros.Consensus.Shelley.Ledger.Block
  ( IsShelleyBlock
  , ShelleyBlockLedgerEra
  )
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
import Ouroboros.Consensus.Shelley.Node
import Ouroboros.Consensus.Shelley.Node.Common
  ( ShelleyEraWithCrypto
  , shelleyBlockIssuerVKey
  )
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
import qualified Ouroboros.Consensus.Shelley.Node.TPraos as TPraos
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util.Assert
import Ouroboros.Consensus.Util.IOLike

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

-- | 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/IntersectMBO/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)
ccfgShelley CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
ccfgAllegra CodecConfig (ShelleyBlock (TPraos c) MaryEra)
ccfgMary CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
ccfgAlonzo CodecConfig (ShelleyBlock (Praos c) BabbageEra)
ccfgBabbage CodecConfig (ShelleyBlock (Praos c) ConwayEra)
ccfgConway) = \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
blockShelley -> Word -> Encoding -> Encoding
prependTag Word
2 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> ShelleyBlock (TPraos c) ShelleyEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
ccfgShelley ShelleyBlock (TPraos c) ShelleyEra
blockShelley
    BlockAllegra ShelleyBlock (TPraos c) AllegraEra
blockAllegra -> Word -> Encoding -> Encoding
prependTag Word
3 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> ShelleyBlock (TPraos c) AllegraEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
ccfgAllegra ShelleyBlock (TPraos c) AllegraEra
blockAllegra
    BlockMary ShelleyBlock (TPraos c) MaryEra
blockMary -> Word -> Encoding -> Encoding
prependTag Word
4 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> ShelleyBlock (TPraos c) MaryEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) MaryEra)
ccfgMary ShelleyBlock (TPraos c) MaryEra
blockMary
    BlockAlonzo ShelleyBlock (TPraos c) AlonzoEra
blockAlonzo -> Word -> Encoding -> Encoding
prependTag Word
5 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> ShelleyBlock (TPraos c) AlonzoEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
ccfgAlonzo ShelleyBlock (TPraos c) AlonzoEra
blockAlonzo
    BlockBabbage ShelleyBlock (Praos c) BabbageEra
blockBabbage -> Word -> Encoding -> Encoding
prependTag Word
6 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> ShelleyBlock (Praos c) BabbageEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (Praos c) BabbageEra)
ccfgBabbage ShelleyBlock (Praos c) BabbageEra
blockBabbage
    BlockConway ShelleyBlock (Praos c) ConwayEra
blockConway -> Word -> Encoding -> Encoding
prependTag Word
7 (Encoding -> Encoding) -> Encoding -> Encoding
forall a b. (a -> b) -> a -> b
$ CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> ShelleyBlock (Praos c) ConwayEra -> Encoding
forall blk a. EncodeDisk blk a => CodecConfig blk -> a -> Encoding
encodeDisk CodecConfig (ShelleyBlock (Praos c) ConwayEra)
ccfgConway ShelleyBlock (Praos c) ConwayEra
blockConway
  decodeDiskHfcBlock :: CodecConfig (HardForkBlock (CardanoEras c))
-> forall s.
   Decoder s (ByteString -> HardForkBlock (CardanoEras c))
decodeDiskHfcBlock (CardanoCodecConfig CodecConfig ByronBlock
ccfgByron CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
ccfgShelley CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
ccfgAllegra CodecConfig (ShelleyBlock (TPraos c) MaryEra)
ccfgMary CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
ccfgAlonzo CodecConfig (ShelleyBlock (Praos c) BabbageEra)
ccfgBabbage CodecConfig (ShelleyBlock (Praos c) ConwayEra)
ccfgConway) = 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 a b. Decoder s a -> (a -> Decoder s b) -> Decoder s b
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 a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
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 a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
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
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) ShelleyEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) ShelleyEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) ShelleyEra -> CardanoBlock c
BlockShelley ((ByteString -> ShelleyBlock (TPraos c) ShelleyEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) ShelleyEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) ShelleyEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
ccfgShelley
      Word
3 -> (ShelleyBlock (TPraos c) AllegraEra
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) AllegraEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) AllegraEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) AllegraEra -> CardanoBlock c
BlockAllegra ((ByteString -> ShelleyBlock (TPraos c) AllegraEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) AllegraEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) AllegraEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
ccfgAllegra
      Word
4 -> (ShelleyBlock (TPraos c) MaryEra -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) MaryEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) MaryEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) MaryEra -> CardanoBlock c
BlockMary ((ByteString -> ShelleyBlock (TPraos c) MaryEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) MaryEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) MaryEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) MaryEra)
ccfgMary
      Word
5 -> (ShelleyBlock (TPraos c) AlonzoEra
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (TPraos c) AlonzoEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (TPraos c) AlonzoEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (TPraos c) AlonzoEra -> CardanoBlock c
BlockAlonzo ((ByteString -> ShelleyBlock (TPraos c) AlonzoEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (TPraos c) AlonzoEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (TPraos c) AlonzoEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
ccfgAlonzo
      Word
6 -> (ShelleyBlock (Praos c) BabbageEra
 -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (Praos c) BabbageEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (Praos c) BabbageEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (Praos c) BabbageEra -> CardanoBlock c
BlockBabbage ((ByteString -> ShelleyBlock (Praos c) BabbageEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (Praos c) BabbageEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (Praos c) BabbageEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (Praos c) BabbageEra)
ccfgBabbage
      Word
7 -> (ShelleyBlock (Praos c) ConwayEra -> HardForkBlock (CardanoEras c))
-> (ByteString -> ShelleyBlock (Praos c) ConwayEra)
-> ByteString
-> HardForkBlock (CardanoEras c)
forall a b. (a -> b) -> (ByteString -> a) -> ByteString -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShelleyBlock (Praos c) ConwayEra -> HardForkBlock (CardanoEras c)
forall c. ShelleyBlock (Praos c) ConwayEra -> CardanoBlock c
BlockConway ((ByteString -> ShelleyBlock (Praos c) ConwayEra)
 -> ByteString -> HardForkBlock (CardanoEras c))
-> Decoder s (ByteString -> ShelleyBlock (Praos c) ConwayEra)
-> Decoder s (ByteString -> HardForkBlock (CardanoEras c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> forall s.
   Decoder s (ByteString -> ShelleyBlock (Praos c) ConwayEra)
forall blk a.
DecodeDisk blk a =>
CodecConfig blk -> forall s. Decoder s a
decodeDisk CodecConfig (ShelleyBlock (Praos c) ConwayEra)
ccfgConway
      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 :: forall (proxy :: * -> *).
proxy (Header (HardForkBlock (CardanoEras c))) -> PrefixLen
reconstructHfcPrefixLen proxy (Header (HardForkBlock (CardanoEras c)))
_ = Word8 -> PrefixLen
PrefixLen Word8
2

  reconstructHfcNestedCtxt :: forall (proxy :: * -> *).
proxy (Header (HardForkBlock (CardanoEras c)))
-> ShortByteString
-> SizeInBytes
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
reconstructHfcNestedCtxt proxy (Header (HardForkBlock (CardanoEras c)))
_ ShortByteString
prefix SizeInBytes
blockSize =
    case HasCallStack => ShortByteString -> Int -> Word8
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 {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
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 {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
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))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) ShelleyEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) ShelleyEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) ShelleyEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) ShelleyEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) ShelleyEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) ShelleyEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) ShelleyEra)
  Header
  (Header (ShelleyBlock (TPraos c) ShelleyEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) ShelleyEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) ShelleyEra)
  Header
  (Header (ShelleyBlock (TPraos c) ShelleyEra))
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))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) AllegraEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) AllegraEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) AllegraEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) AllegraEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AllegraEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) AllegraEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AllegraEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AllegraEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) AllegraEra)
  Header
  (Header (ShelleyBlock (TPraos c) AllegraEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AllegraEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) AllegraEra)
  Header
  (Header (ShelleyBlock (TPraos c) AllegraEra))
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))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) MaryEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) MaryEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) MaryEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) MaryEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) MaryEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) MaryEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) MaryEra)
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) MaryEra,
          ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) MaryEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) MaryEra)
  Header
  (Header (ShelleyBlock (TPraos c) MaryEra))
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))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (TPraos c) AlonzoEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) MaryEra,
          ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (TPraos c) AlonzoEra)
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (TPraos c) AlonzoEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (TPraos c) AlonzoEra)
  Header
  (Header (ShelleyBlock (TPraos c) AlonzoEra))
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))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (Praos c) BabbageEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) BabbageEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) MaryEra,
          ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (Praos c) BabbageEra)
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) BabbageEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (Praos c) BabbageEra)
  Header
  (Header (ShelleyBlock (Praos c) BabbageEra))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley))))))
      Word8
7 -> NestedCtxt
  Header
  (HardForkBlock (CardanoEras c))
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall {k1} {k2} (f :: k1 -> k2 -> *) (a :: k1) (b :: k2).
f a b -> SomeSecond f a
SomeSecond (NestedCtxt
   Header
   (HardForkBlock (CardanoEras c))
   (Header (ShelleyBlock (Praos c) ConwayEra))
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) ConwayEra))
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ NestedCtxt_
  (HardForkBlock (CardanoEras c))
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt
     Header
     (HardForkBlock (CardanoEras c))
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) ShelleyEra,
       ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock (CardanoEras c))
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) ShelleyEra,
          ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AllegraEra,
          ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) MaryEra,
          ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (TPraos c) AlonzoEra,
          ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (HardForkBlock '[ShelleyBlock (Praos c) ConwayEra])
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock
        '[ShelleyBlock (Praos c) BabbageEra,
          ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall (xs1 :: [*]) (a :: * -> *) b x.
NestedCtxt_ (HardForkBlock xs1) a b
-> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCS (NestedCtxt_
  (ShelleyBlock (Praos c) ConwayEra)
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
-> NestedCtxt_
     (HardForkBlock '[ShelleyBlock (Praos c) ConwayEra])
     Header
     (Header (ShelleyBlock (Praos c) ConwayEra))
forall x (a :: * -> *) b (xs1 :: [*]).
NestedCtxt_ x a b -> NestedCtxt_ (HardForkBlock (x : xs1)) a b
NCZ NestedCtxt_
  (ShelleyBlock (Praos c) ConwayEra)
  Header
  (Header (ShelleyBlock (Praos c) ConwayEra))
forall proto era (f :: * -> *).
NestedCtxt_ (ShelleyBlock proto era) f (f (ShelleyBlock proto era))
Shelley.CtxtShelley)))))))
      Word8
_ -> String
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a. HasCallStack => String -> a
error (String
 -> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c)))
-> String
-> SomeSecond (NestedCtxt Header) (HardForkBlock (CardanoEras c))
forall a b. (a -> b) -> a -> b
$ String
"CardanoBlock: invalid prefix " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ShortByteString -> String
forall a. Show a => a -> String
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
blockShelley ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) ShelleyEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) ShelleyEra
blockShelley
    BlockAllegra ShelleyBlock (TPraos c) AllegraEra
blockAllegra ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) AllegraEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) AllegraEra
blockAllegra
    BlockMary ShelleyBlock (TPraos c) MaryEra
blockMary ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) MaryEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) MaryEra
blockMary
    BlockAlonzo ShelleyBlock (TPraos c) AlonzoEra
blockAlonzo ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (TPraos c) AlonzoEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (TPraos c) AlonzoEra
blockAlonzo
    BlockBabbage ShelleyBlock (Praos c) BabbageEra
blockBabbage ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (Praos c) BabbageEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (Praos c) BabbageEra
blockBabbage
    BlockConway ShelleyBlock (Praos c) ConwayEra
blockConway ->
      Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
2 (BinaryBlockInfo -> BinaryBlockInfo)
-> BinaryBlockInfo -> BinaryBlockInfo
forall a b. (a -> b) -> a -> b
$ ShelleyBlock (Praos c) ConwayEra -> BinaryBlockInfo
forall blk. HasBinaryBlockInfo blk => blk -> BinaryBlockInfo
getBinaryBlockInfo ShelleyBlock (Praos c) ConwayEra
blockConway
   where
    shiftHeaderOffset :: Word16 -> BinaryBlockInfo -> BinaryBlockInfo
    shiftHeaderOffset :: Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset Word16
shift BinaryBlockInfo
binfo =
      BinaryBlockInfo
binfo
        { headerOffset = headerOffset binfo + 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)
headerShelley -> Header (ShelleyBlock (TPraos c) ShelleyEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) ShelleyEra)
headerShelley SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
    HeaderAllegra Header (ShelleyBlock (TPraos c) AllegraEra)
headerAllegra -> Header (ShelleyBlock (TPraos c) AllegraEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) AllegraEra)
headerAllegra SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
    HeaderMary Header (ShelleyBlock (TPraos c) MaryEra)
headerMary -> Header (ShelleyBlock (TPraos c) MaryEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) MaryEra)
headerMary SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
    HeaderAlonzo Header (ShelleyBlock (TPraos c) AlonzoEra)
headerAlonzo -> Header (ShelleyBlock (TPraos c) AlonzoEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (TPraos c) AlonzoEra)
headerAlonzo SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
    HeaderBabbage Header (ShelleyBlock (Praos c) BabbageEra)
headerBabbage -> Header (ShelleyBlock (Praos c) BabbageEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (Praos c) BabbageEra)
headerBabbage SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
2
    HeaderConway Header (ShelleyBlock (Praos c) ConwayEra)
headerConway -> Header (ShelleyBlock (Praos c) ConwayEra) -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize Header (ShelleyBlock (Praos c) ConwayEra)
headerConway 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 $mCardanoNodeToNodeVersion1 :: forall {r} {c}.
BlockNodeToNodeVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToNodeVersion1 :: forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion1 =
  HardForkNodeToNodeDisabled ByronNodeToNodeVersion1

-- | The hard fork enabled using the latest version of Byron and Shelley for
-- each Byron and Shelley era.
pattern CardanoNodeToNodeVersion2 :: BlockNodeToNodeVersion (CardanoBlock c)
pattern $mCardanoNodeToNodeVersion2 :: forall {r} {c}.
BlockNodeToNodeVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToNodeVersion2 :: forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion2 =
  HardForkNodeToNodeEnabled
    HardForkSpecificNodeToNodeVersion1
    ( WrapNodeToNodeVersion ByronNodeToNodeVersion2
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* WrapNodeToNodeVersion ShelleyNodeToNodeVersion1
        :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion8' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion12 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $mCardanoNodeToClientVersion12 :: forall {r} {c}.
BlockNodeToClientVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToClientVersion12 :: forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion12 =
  HardForkNodeToClientEnabled
    HardForkSpecificNodeToClientVersion3
    ( EraNodeToClientEnabled ByronNodeToClientVersion1
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion8
        :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion9' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion13 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $mCardanoNodeToClientVersion13 :: forall {r} {c}.
BlockNodeToClientVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToClientVersion13 :: forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion13 =
  HardForkNodeToClientEnabled
    HardForkSpecificNodeToClientVersion3
    ( EraNodeToClientEnabled ByronNodeToClientVersion1
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion9
        :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion10' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion14 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $mCardanoNodeToClientVersion14 :: forall {r} {c}.
BlockNodeToClientVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToClientVersion14 :: forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion14 =
  HardForkNodeToClientEnabled
    HardForkSpecificNodeToClientVersion3
    ( EraNodeToClientEnabled ByronNodeToClientVersion1
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion10
        :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion11' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion15 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $mCardanoNodeToClientVersion15 :: forall {r} {c}.
BlockNodeToClientVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToClientVersion15 :: forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion15 =
  HardForkNodeToClientEnabled
    HardForkSpecificNodeToClientVersion3
    ( EraNodeToClientEnabled ByronNodeToClientVersion1
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion11
        :* Nil
      )

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion12' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion16 :: BlockNodeToClientVersion (CardanoBlock c)
pattern $mCardanoNodeToClientVersion16 :: forall {r} {c}.
BlockNodeToClientVersion (CardanoBlock c)
-> ((# #) -> r) -> ((# #) -> r) -> r
$bCardanoNodeToClientVersion16 :: forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion16 =
  HardForkNodeToClientEnabled
    HardForkSpecificNodeToClientVersion3
    ( EraNodeToClientEnabled ByronNodeToClientVersion1
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* EraNodeToClientEnabled ShelleyNodeToClientVersion12
        :* Nil
      )

instance
  CardanoHardForkConstraints c =>
  SupportedNetworkProtocolVersion (CardanoBlock c)
  where
  supportedNodeToNodeVersions :: Proxy (CardanoBlock c)
-> Map NodeToNodeVersion (BlockNodeToNodeVersion (CardanoBlock c))
supportedNodeToNodeVersions Proxy (CardanoBlock c)
_ =
    [(NodeToNodeVersion, BlockNodeToNodeVersion (CardanoBlock c))]
-> Map NodeToNodeVersion (BlockNodeToNodeVersion (CardanoBlock c))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(NodeToNodeVersion, BlockNodeToNodeVersion (CardanoBlock c))]
 -> Map NodeToNodeVersion (BlockNodeToNodeVersion (CardanoBlock c)))
-> [(NodeToNodeVersion, BlockNodeToNodeVersion (CardanoBlock c))]
-> Map NodeToNodeVersion (BlockNodeToNodeVersion (CardanoBlock c))
forall a b. (a -> b) -> a -> b
$
      [ (NodeToNodeVersion
NodeToNodeV_14, BlockNodeToNodeVersion (CardanoBlock c)
forall c. BlockNodeToNodeVersion (CardanoBlock c)
CardanoNodeToNodeVersion2)
      ]

  supportedNodeToClientVersions :: Proxy (CardanoBlock c)
-> Map
     NodeToClientVersion (BlockNodeToClientVersion (CardanoBlock c))
supportedNodeToClientVersions Proxy (CardanoBlock c)
_ =
    [(NodeToClientVersion, BlockNodeToClientVersion (CardanoBlock c))]
-> Map
     NodeToClientVersion (BlockNodeToClientVersion (CardanoBlock c))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(NodeToClientVersion, BlockNodeToClientVersion (CardanoBlock c))]
 -> Map
      NodeToClientVersion (BlockNodeToClientVersion (CardanoBlock c)))
-> [(NodeToClientVersion,
     BlockNodeToClientVersion (CardanoBlock c))]
-> Map
     NodeToClientVersion (BlockNodeToClientVersion (CardanoBlock c))
forall a b. (a -> b) -> a -> b
$
      [ (NodeToClientVersion
NodeToClientV_16, BlockNodeToClientVersion (CardanoBlock c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion12)
      , (NodeToClientVersion
NodeToClientV_17, BlockNodeToClientVersion (CardanoBlock c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion13)
      , (NodeToClientVersion
NodeToClientV_18, BlockNodeToClientVersion (CardanoBlock c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion14)
      , (NodeToClientVersion
NodeToClientV_19, BlockNodeToClientVersion (CardanoBlock c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion15)
      , (NodeToClientVersion
NodeToClientV_20, BlockNodeToClientVersion (CardanoBlock c)
forall c. BlockNodeToClientVersion (CardanoBlock c)
CardanoNodeToClientVersion16)
      ]

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

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

-- | When to trigger a hard fork to a Cardano era.
data CardanoHardForkTrigger blk
  = -- | Trigger the hard fork when the ledger protocol version is updated to
    -- the default for that era (@'L.eraProtVerLow' \@('ShelleyBlockLedgerEra'
    -- blk)@). Also see 'TriggerHardForkAtVersion'.
    CardanoTriggerHardForkAtDefaultVersion
  | -- | Trigger the hard fork at the given epoch. For testing only. Also see
    -- 'TriggerHardForkAtEpoch'.
    CardanoTriggerHardForkAtEpoch EpochNo
  deriving stock Int -> CardanoHardForkTrigger blk -> String -> String
[CardanoHardForkTrigger blk] -> String -> String
CardanoHardForkTrigger blk -> String
(Int -> CardanoHardForkTrigger blk -> String -> String)
-> (CardanoHardForkTrigger blk -> String)
-> ([CardanoHardForkTrigger blk] -> String -> String)
-> Show (CardanoHardForkTrigger blk)
forall blk. Int -> CardanoHardForkTrigger blk -> String -> String
forall blk. [CardanoHardForkTrigger blk] -> String -> String
forall blk. CardanoHardForkTrigger blk -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: forall blk. Int -> CardanoHardForkTrigger blk -> String -> String
showsPrec :: Int -> CardanoHardForkTrigger blk -> String -> String
$cshow :: forall blk. CardanoHardForkTrigger blk -> String
show :: CardanoHardForkTrigger blk -> String
$cshowList :: forall blk. [CardanoHardForkTrigger blk] -> String -> String
showList :: [CardanoHardForkTrigger blk] -> String -> String
Show

toTriggerHardFork ::
  forall blk.
  L.Era (ShelleyBlockLedgerEra blk) =>
  CardanoHardForkTrigger blk ->
  TriggerHardFork
toTriggerHardFork :: forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork = \case
  CardanoHardForkTrigger blk
CardanoTriggerHardForkAtDefaultVersion ->
    Word16 -> TriggerHardFork
TriggerHardForkAtVersion (Word16 -> TriggerHardFork) -> Word16 -> TriggerHardFork
forall a b. (a -> b) -> a -> b
$
      Version -> Word16
forall i. Integral i => Version -> i
SL.getVersion (forall era. Era era => Version
L.eraProtVerLow @(ShelleyBlockLedgerEra blk))
  CardanoTriggerHardForkAtEpoch EpochNo
epochNo ->
    EpochNo -> TriggerHardFork
TriggerHardForkAtEpoch EpochNo
epochNo

newtype CardanoHardForkTriggers = CardanoHardForkTriggers
  { CardanoHardForkTriggers
-> NP CardanoHardForkTrigger (CardanoShelleyEras StandardCrypto)
getCardanoHardForkTriggers ::
      NP CardanoHardForkTrigger (CardanoShelleyEras StandardCrypto)
  }

pattern CardanoHardForkTriggers' ::
  c ~ StandardCrypto =>
  CardanoHardForkTrigger (ShelleyBlock (TPraos c) ShelleyEra) ->
  CardanoHardForkTrigger (ShelleyBlock (TPraos c) AllegraEra) ->
  CardanoHardForkTrigger (ShelleyBlock (TPraos c) MaryEra) ->
  CardanoHardForkTrigger (ShelleyBlock (TPraos c) AlonzoEra) ->
  CardanoHardForkTrigger (ShelleyBlock (Praos c) BabbageEra) ->
  CardanoHardForkTrigger (ShelleyBlock (Praos c) ConwayEra) ->
  CardanoHardForkTriggers
pattern $mCardanoHardForkTriggers' :: forall {r} {c}.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> (CardanoHardForkTrigger (ShelleyBlock (TPraos c) ShelleyEra)
    -> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AllegraEra)
    -> CardanoHardForkTrigger (ShelleyBlock (TPraos c) MaryEra)
    -> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AlonzoEra)
    -> CardanoHardForkTrigger (ShelleyBlock (Praos c) BabbageEra)
    -> CardanoHardForkTrigger (ShelleyBlock (Praos c) ConwayEra)
    -> r)
-> ((# #) -> r)
-> r
$bCardanoHardForkTriggers' :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTrigger (ShelleyBlock (TPraos c) ShelleyEra)
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AllegraEra)
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) MaryEra)
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AlonzoEra)
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) BabbageEra)
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) ConwayEra)
-> CardanoHardForkTriggers
CardanoHardForkTriggers'
  { forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) ShelleyEra)
triggerHardForkShelley
  , forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AllegraEra)
triggerHardForkAllegra
  , forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) MaryEra)
triggerHardForkMary
  , forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AlonzoEra)
triggerHardForkAlonzo
  , forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) BabbageEra)
triggerHardForkBabbage
  , forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) ConwayEra)
triggerHardForkConway
  } =
  CardanoHardForkTriggers
    ( triggerHardForkShelley
        :* triggerHardForkAllegra
        :* triggerHardForkMary
        :* triggerHardForkAlonzo
        :* triggerHardForkBabbage
        :* triggerHardForkConway
        :* Nil
      )
{-# COMPLETE CardanoHardForkTriggers' #-}

-- | Parameters needed to run Cardano.
--
-- __On the relation between 'cardanoHardForkTriggers' and 'cardanoProtocolVersion'__:
--
-- The 'cardanoHardForkTriggers' can mention __ledger__ protocol
-- version versions at which the hard fork will occur. In principle
-- there is no relation between the versions mentioned in
-- 'cardanoProtocolVerson' (if any) and 'cardanoHardForkTriggers',
-- however their relationship might indicate experimental eras or
-- intra-era hard forks. For instance if the last era in the
-- 'CardanoHardForkTriggers' is set to @9 0@, ie:
--
-- > ... :* TriggerHardForkAtVersion (ProtVer (SL.natVersion @9) 0)
--
-- Setting 'cardanoProtocolVersion' to @ProtVer (SL.natVersion @8) 0@
-- will mark that last era as experimental because the obsolete node
-- checks determine that the highest version we support is @8 0@.
--
-- If, on the other hand, we would set 'cardanoProtocolVersion' to
-- @ProtVer (SL.natVersion @10) 0@, this indicates that the node is
-- ready to perform an intra-era hardfork (from version @9@ to version
-- @10@).
data CardanoProtocolParams c = CardanoProtocolParams
  { forall c. CardanoProtocolParams c -> ProtocolParamsByron
byronProtocolParams :: ProtocolParamsByron
  , forall c. CardanoProtocolParams c -> ProtocolParamsShelleyBased c
shelleyBasedProtocolParams :: ProtocolParamsShelleyBased c
  , forall c. CardanoProtocolParams c -> CardanoHardForkTriggers
cardanoHardForkTriggers :: CardanoHardForkTriggers
  , forall c. CardanoProtocolParams c -> TransitionConfig ConwayEra
cardanoLedgerTransitionConfig :: L.TransitionConfig L.LatestKnownEra
  , forall c.
CardanoProtocolParams c -> CheckpointsMap (CardanoBlock c)
cardanoCheckpoints :: CheckpointsMap (CardanoBlock c)
  , forall c. CardanoProtocolParams c -> ProtVer
cardanoProtocolVersion :: ProtVer
  -- ^ The greatest protocol version that this node's software and config
  -- files declare to handle correctly.
  --
  -- This parameter has two consequences. First, the blocks minted
  -- will include the protocol version in their header, but
  -- essentially only for public signaling (eg measuring the
  -- percentage of adoption of software updates).
  --
  -- Second, and more importantly, it's passed to the protocol logic. In
  -- particular, the node's envelope check will begin rejecting all blocks
  -- (actually, their headers) if the chain moves to a greater protocol
  -- version. This should never happen in a node that is using up-to-date
  -- software and config files. Note that the missing software update is
  -- not necessarily a 'HardForkBlock' era transition: it might be an
  -- /intra-era hard fork/ (ie conditionals in the ledger rules).
  }

-- | Create a 'ProtocolInfo' for 'CardanoBlock'
--
-- NOTE: For testing and benchmarking purposes, the genesis config can contain
-- certain data to be registered in the initial ledger state, like initial
-- staking and funds. These are registered /only if/ the given
-- 'CardanoHardForkTriggers' tell us to skip the Byron era and hard fork
-- directly to Shelley or a later era by using @TestXHardForkAtEpoch 0@. When
-- @'SL.gNetworkId' == 'SL.Mainnet'@, no such data must be present.
--
-- PRECONDITION: only a single set of Shelley credentials is allowed when used
-- for mainnet (check against @'SL.gNetworkId' == 'SL.Mainnet'@).
protocolInfoCardano ::
  forall c m.
  (IOLike m, CardanoHardForkConstraints c) =>
  CardanoProtocolParams c ->
  ( ProtocolInfo (CardanoBlock c)
  , m [BlockForging m (CardanoBlock c)]
  )
protocolInfoCardano :: forall c (m :: * -> *).
(IOLike m, CardanoHardForkConstraints c) =>
CardanoProtocolParams c
-> (ProtocolInfo (CardanoBlock c),
    m [BlockForging m (CardanoBlock c)])
protocolInfoCardano CardanoProtocolParams c
paramsCardano
  | Network
SL.Mainnet <- ShelleyGenesis -> Network
SL.sgNetworkId ShelleyGenesis
genesisShelley
  , [ShelleyLeaderCredentials c] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ShelleyLeaderCredentials c]
credssShelleyBased Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1 =
      String
-> (ProtocolInfo (HardForkBlock (CardanoEras c)),
    m [BlockForging m (HardForkBlock (CardanoEras c))])
forall a. HasCallStack => String -> a
error String
"Multiple Shelley-based credentials not allowed for mainnet"
  | Bool
otherwise =
      Either String ()
-> (ProtocolInfo (HardForkBlock (CardanoEras c)),
    m [BlockForging m (HardForkBlock (CardanoEras c))])
-> (ProtocolInfo (HardForkBlock (CardanoEras c)),
    m [BlockForging m (HardForkBlock (CardanoEras c))])
forall a. HasCallStack => Either String () -> a -> a
assertWithMsg
        (ShelleyGenesis -> Either String ()
validateGenesis ShelleyGenesis
genesisShelley)
        ( ProtocolInfo
            { pInfoConfig :: TopLevelConfig (HardForkBlock (CardanoEras c))
pInfoConfig = TopLevelConfig (HardForkBlock (CardanoEras c))
cfg
            , pInfoInitLedger :: ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK
pInfoInitLedger = ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK
initExtLedgerStateCardano
            }
        , m [BlockForging m (HardForkBlock (CardanoEras c))]
blockForging
        )
 where
  CardanoProtocolParams
    { ProtocolParamsByron
byronProtocolParams :: forall c. CardanoProtocolParams c -> ProtocolParamsByron
byronProtocolParams :: ProtocolParamsByron
byronProtocolParams
    , ProtocolParamsShelleyBased c
shelleyBasedProtocolParams :: forall c. CardanoProtocolParams c -> ProtocolParamsShelleyBased c
shelleyBasedProtocolParams :: ProtocolParamsShelleyBased c
shelleyBasedProtocolParams
    , cardanoHardForkTriggers :: forall c. CardanoProtocolParams c -> CardanoHardForkTriggers
cardanoHardForkTriggers =
      CardanoHardForkTriggers'
        { CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) ShelleyEra)
triggerHardForkShelley :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) ShelleyEra)
triggerHardForkShelley :: CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) ShelleyEra)
triggerHardForkShelley
        , CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AllegraEra)
triggerHardForkAllegra :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AllegraEra)
triggerHardForkAllegra :: CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AllegraEra)
triggerHardForkAllegra
        , CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) MaryEra)
triggerHardForkMary :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) MaryEra)
triggerHardForkMary :: CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) MaryEra)
triggerHardForkMary
        , CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AlonzoEra)
triggerHardForkAlonzo :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) AlonzoEra)
triggerHardForkAlonzo :: CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AlonzoEra)
triggerHardForkAlonzo
        , CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) BabbageEra)
triggerHardForkBabbage :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) BabbageEra)
triggerHardForkBabbage :: CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) BabbageEra)
triggerHardForkBabbage
        , CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) ConwayEra)
triggerHardForkConway :: forall c.
(c ~ StandardCrypto) =>
CardanoHardForkTriggers
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) ConwayEra)
triggerHardForkConway :: CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) ConwayEra)
triggerHardForkConway
        }
    , TransitionConfig ConwayEra
cardanoLedgerTransitionConfig :: forall c. CardanoProtocolParams c -> TransitionConfig ConwayEra
cardanoLedgerTransitionConfig :: TransitionConfig ConwayEra
cardanoLedgerTransitionConfig
    , CheckpointsMap (HardForkBlock (CardanoEras c))
cardanoCheckpoints :: forall c.
CardanoProtocolParams c -> CheckpointsMap (CardanoBlock c)
cardanoCheckpoints :: CheckpointsMap (HardForkBlock (CardanoEras c))
cardanoCheckpoints
    , ProtVer
cardanoProtocolVersion :: forall c. CardanoProtocolParams c -> ProtVer
cardanoProtocolVersion :: ProtVer
cardanoProtocolVersion
    } = CardanoProtocolParams c
paramsCardano

  genesisShelley :: ShelleyGenesis
genesisShelley = TransitionConfig ConwayEra
cardanoLedgerTransitionConfig TransitionConfig ConwayEra
-> Getting
     ShelleyGenesis (TransitionConfig ConwayEra) ShelleyGenesis
-> ShelleyGenesis
forall s a. s -> Getting a s a -> a
^. Getting ShelleyGenesis (TransitionConfig ConwayEra) ShelleyGenesis
forall era.
EraTransition era =>
Lens' (TransitionConfig era) ShelleyGenesis
Lens' (TransitionConfig ConwayEra) ShelleyGenesis
L.tcShelleyGenesisL

  ProtocolParamsByron
    { byronGenesis :: ProtocolParamsByron -> Config
byronGenesis = Config
genesisByron
    , byronLeaderCredentials :: ProtocolParamsByron -> Maybe ByronLeaderCredentials
byronLeaderCredentials = Maybe ByronLeaderCredentials
mCredsByron
    } = ProtocolParamsByron
byronProtocolParams
  ProtocolParamsShelleyBased
    { shelleyBasedInitialNonce :: forall c. ProtocolParamsShelleyBased c -> Nonce
shelleyBasedInitialNonce = Nonce
initialNonceShelley
    , shelleyBasedLeaderCredentials :: forall c.
ProtocolParamsShelleyBased c -> [ShelleyLeaderCredentials c]
shelleyBasedLeaderCredentials = [ShelleyLeaderCredentials c]
credssShelleyBased
    } = ProtocolParamsShelleyBased c
shelleyBasedProtocolParams

  transitionConfigShelley :: TransitionConfig ShelleyEra
transitionConfigShelley = TransitionConfig AllegraEra
transitionConfigAllegra TransitionConfig AllegraEra
-> Getting
     (TransitionConfig ShelleyEra)
     (TransitionConfig AllegraEra)
     (TransitionConfig ShelleyEra)
-> TransitionConfig ShelleyEra
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra AllegraEra)
 -> Const
      (TransitionConfig ShelleyEra)
      (TransitionConfig (PreviousEra AllegraEra)))
-> TransitionConfig AllegraEra
-> Const
     (TransitionConfig ShelleyEra) (TransitionConfig AllegraEra)
Getting
  (TransitionConfig ShelleyEra)
  (TransitionConfig AllegraEra)
  (TransitionConfig ShelleyEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
  (TransitionConfig AllegraEra)
  (TransitionConfig (PreviousEra AllegraEra))
L.tcPreviousEraConfigL
  transitionConfigAllegra :: TransitionConfig AllegraEra
transitionConfigAllegra = TransitionConfig MaryEra
transitionConfigMary TransitionConfig MaryEra
-> Getting
     (TransitionConfig AllegraEra)
     (TransitionConfig MaryEra)
     (TransitionConfig AllegraEra)
-> TransitionConfig AllegraEra
forall s a. s -> Getting a s a -> a
^. Getting
  (TransitionConfig AllegraEra)
  (TransitionConfig MaryEra)
  (TransitionConfig AllegraEra)
(TransitionConfig (PreviousEra MaryEra)
 -> Const
      (TransitionConfig AllegraEra)
      (TransitionConfig (PreviousEra MaryEra)))
-> TransitionConfig MaryEra
-> Const (TransitionConfig AllegraEra) (TransitionConfig MaryEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
  (TransitionConfig MaryEra) (TransitionConfig (PreviousEra MaryEra))
L.tcPreviousEraConfigL
  transitionConfigMary :: TransitionConfig MaryEra
transitionConfigMary = TransitionConfig AlonzoEra
transitionConfigAlonzo TransitionConfig AlonzoEra
-> Getting
     (TransitionConfig MaryEra)
     (TransitionConfig AlonzoEra)
     (TransitionConfig MaryEra)
-> TransitionConfig MaryEra
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra AlonzoEra)
 -> Const
      (TransitionConfig MaryEra)
      (TransitionConfig (PreviousEra AlonzoEra)))
-> TransitionConfig AlonzoEra
-> Const (TransitionConfig MaryEra) (TransitionConfig AlonzoEra)
Getting
  (TransitionConfig MaryEra)
  (TransitionConfig AlonzoEra)
  (TransitionConfig MaryEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
  (TransitionConfig AlonzoEra)
  (TransitionConfig (PreviousEra AlonzoEra))
L.tcPreviousEraConfigL
  transitionConfigAlonzo :: TransitionConfig AlonzoEra
transitionConfigAlonzo = TransitionConfig BabbageEra
transitionConfigBabbage TransitionConfig BabbageEra
-> Getting
     (TransitionConfig AlonzoEra)
     (TransitionConfig BabbageEra)
     (TransitionConfig AlonzoEra)
-> TransitionConfig AlonzoEra
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra BabbageEra)
 -> Const
      (TransitionConfig AlonzoEra)
      (TransitionConfig (PreviousEra BabbageEra)))
-> TransitionConfig BabbageEra
-> Const (TransitionConfig AlonzoEra) (TransitionConfig BabbageEra)
Getting
  (TransitionConfig AlonzoEra)
  (TransitionConfig BabbageEra)
  (TransitionConfig AlonzoEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
  (TransitionConfig BabbageEra)
  (TransitionConfig (PreviousEra BabbageEra))
L.tcPreviousEraConfigL
  transitionConfigBabbage :: TransitionConfig BabbageEra
transitionConfigBabbage = TransitionConfig ConwayEra
transitionConfigConway TransitionConfig ConwayEra
-> Getting
     (TransitionConfig BabbageEra)
     (TransitionConfig ConwayEra)
     (TransitionConfig BabbageEra)
-> TransitionConfig BabbageEra
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra ConwayEra)
 -> Const
      (TransitionConfig BabbageEra)
      (TransitionConfig (PreviousEra ConwayEra)))
-> TransitionConfig ConwayEra
-> Const (TransitionConfig BabbageEra) (TransitionConfig ConwayEra)
Getting
  (TransitionConfig BabbageEra)
  (TransitionConfig ConwayEra)
  (TransitionConfig BabbageEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
  (TransitionConfig ConwayEra)
  (TransitionConfig (PreviousEra ConwayEra))
L.tcPreviousEraConfigL
  transitionConfigConway :: TransitionConfig ConwayEra
transitionConfigConway = TransitionConfig ConwayEra
cardanoLedgerTransitionConfig

  -- The major protocol version of the last era is the maximum major protocol
  -- version we support.
  --
  maxMajorProtVer :: MaxMajorProtVer
  maxMajorProtVer :: MaxMajorProtVer
maxMajorProtVer = Version -> MaxMajorProtVer
MaxMajorProtVer (Version -> MaxMajorProtVer) -> Version -> MaxMajorProtVer
forall a b. (a -> b) -> a -> b
$ ProtVer -> Version
pvMajor ProtVer
cardanoProtocolVersion

  -- Byron

  ProtocolInfo
    { pInfoConfig :: forall b. ProtocolInfo 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 b. ProtocolInfo b -> ExtLedgerState b ValuesMK
pInfoInitLedger = ExtLedgerState ByronBlock ValuesMK
initExtLedgerStateByron
    } = ProtocolParamsByron -> ProtocolInfo ByronBlock
protocolInfoByron ProtocolParamsByron
byronProtocolParams

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

  partialLedgerConfigByron :: PartialLedgerConfig ByronBlock
  partialLedgerConfigByron :: PartialLedgerConfig ByronBlock
partialLedgerConfigByron =
    ByronPartialLedgerConfig
      { byronLedgerConfig :: LedgerConfig ByronBlock
byronLedgerConfig = LedgerConfig ByronBlock
ledgerConfigByron
      , byronTriggerHardFork :: TriggerHardFork
byronTriggerHardFork = CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) ShelleyEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) ShelleyEra)
triggerHardForkShelley
      }

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

  -- Shelley

  tpraosParams :: TPraosParams
  tpraosParams :: TPraosParams
tpraosParams =
    MaxMajorProtVer -> Nonce -> ShelleyGenesis -> TPraosParams
Shelley.mkTPraosParams
      MaxMajorProtVer
maxMajorProtVer
      Nonce
initialNonceShelley
      ShelleyGenesis
genesisShelley

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

  praosParams :: PraosParams
  praosParams :: PraosParams
praosParams =
    PraosParams
      { praosSlotsPerKESPeriod :: Word64
praosSlotsPerKESPeriod = ShelleyGenesis -> Word64
SL.sgSlotsPerKESPeriod ShelleyGenesis
genesisShelley
      , praosLeaderF :: ActiveSlotCoeff
praosLeaderF = PositiveUnitInterval -> ActiveSlotCoeff
SL.mkActiveSlotCoeff (PositiveUnitInterval -> ActiveSlotCoeff)
-> PositiveUnitInterval -> ActiveSlotCoeff
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis -> PositiveUnitInterval
SL.sgActiveSlotsCoeff ShelleyGenesis
genesisShelley
      , praosSecurityParam :: SecurityParam
praosSecurityParam = NonZero Word64 -> SecurityParam
SecurityParam (NonZero Word64 -> SecurityParam)
-> NonZero Word64 -> SecurityParam
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis -> NonZero Word64
SL.sgSecurityParam ShelleyGenesis
genesisShelley
      , praosMaxKESEvo :: Word64
praosMaxKESEvo = ShelleyGenesis -> Word64
SL.sgMaxKESEvolutions ShelleyGenesis
genesisShelley
      , praosMaxMajorPV :: MaxMajorProtVer
praosMaxMajorPV = MaxMajorProtVer
maxMajorProtVer
      , praosRandomnessStabilisationWindow :: Word64
praosRandomnessStabilisationWindow =
          -- This value is used for all Praos eras /except/ Babbage, see
          -- 'partialConsensusConfigBabbage'.
          Word64 -> ActiveSlotCoeff -> Word64
SL.computeRandomnessStabilisationWindow
            (NonZero Word64 -> Word64
forall a. NonZero a -> a
SL.unNonZero (NonZero Word64 -> Word64) -> NonZero Word64 -> Word64
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis -> NonZero Word64
SL.sgSecurityParam ShelleyGenesis
genesisShelley)
            (PositiveUnitInterval -> ActiveSlotCoeff
SL.mkActiveSlotCoeff (PositiveUnitInterval -> ActiveSlotCoeff)
-> PositiveUnitInterval -> ActiveSlotCoeff
forall a b. (a -> b) -> a -> b
$ ShelleyGenesis -> PositiveUnitInterval
SL.sgActiveSlotsCoeff ShelleyGenesis
genesisShelley)
      }

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

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

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

  partialLedgerConfigShelley :: PartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
  partialLedgerConfigShelley :: PartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
partialLedgerConfigShelley =
    TransitionConfig ShelleyEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any ShelleyEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig ShelleyEra
transitionConfigShelley
      (CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AllegraEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AllegraEra)
triggerHardForkAllegra)

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

  -- Allegra

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

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

  partialLedgerConfigAllegra :: PartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
  partialLedgerConfigAllegra :: PartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
partialLedgerConfigAllegra =
    TransitionConfig AllegraEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any AllegraEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig AllegraEra
transitionConfigAllegra
      (CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) MaryEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) MaryEra)
triggerHardForkMary)

  -- Mary

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

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

  partialLedgerConfigMary :: PartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
  partialLedgerConfigMary :: PartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
partialLedgerConfigMary =
    TransitionConfig MaryEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any MaryEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig MaryEra
transitionConfigMary
      (CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AlonzoEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (TPraos StandardCrypto) AlonzoEra)
triggerHardForkAlonzo)

  -- Alonzo

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

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

  partialLedgerConfigAlonzo :: PartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
  partialLedgerConfigAlonzo :: PartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
partialLedgerConfigAlonzo =
    TransitionConfig AlonzoEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any AlonzoEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig AlonzoEra
transitionConfigAlonzo
      (CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) BabbageEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) BabbageEra)
triggerHardForkBabbage)

  -- Babbage

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

  partialConsensusConfigBabbage ::
    PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) BabbageEra))
  partialConsensusConfigBabbage :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) BabbageEra))
partialConsensusConfigBabbage =
    PraosParams
praosParams
      { -- For Praos in Babbage (just as in all TPraos eras) we use the
        -- smaller (3k/f vs 4k/f slots) stability window here for
        -- backwards-compatibility. See erratum 17.3 in the Shelley ledger
        -- specs for context.
        praosRandomnessStabilisationWindow =
          SL.computeStabilityWindow
            (SL.unNonZero $ SL.sgSecurityParam genesisShelley)
            (SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesisShelley)
      }

  partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
  partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
partialLedgerConfigBabbage =
    TransitionConfig BabbageEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any BabbageEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig BabbageEra
transitionConfigBabbage
      (CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) ConwayEra)
-> TriggerHardFork
forall blk.
Era (ShelleyBlockLedgerEra blk) =>
CardanoHardForkTrigger blk -> TriggerHardFork
toTriggerHardFork CardanoHardForkTrigger
  (ShelleyBlock (Praos StandardCrypto) ConwayEra)
triggerHardForkConway)

  -- Conway

  blockConfigConway :: BlockConfig (ShelleyBlock (Praos c) ConwayEra)
  blockConfigConway :: BlockConfig (ShelleyBlock (Praos c) ConwayEra)
blockConfigConway =
    ProtVer
-> ShelleyGenesis
-> [VKey 'BlockIssuer]
-> BlockConfig (ShelleyBlock (Praos c) ConwayEra)
forall proto era.
ShelleyBasedEra era =>
ProtVer
-> ShelleyGenesis
-> [VKey 'BlockIssuer]
-> BlockConfig (ShelleyBlock proto era)
Shelley.mkShelleyBlockConfig
      ProtVer
cardanoProtocolVersion
      ShelleyGenesis
genesisShelley
      (ShelleyLeaderCredentials c -> VKey 'BlockIssuer
forall c. ShelleyLeaderCredentials c -> VKey 'BlockIssuer
shelleyBlockIssuerVKey (ShelleyLeaderCredentials c -> VKey 'BlockIssuer)
-> [ShelleyLeaderCredentials c] -> [VKey 'BlockIssuer]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ShelleyLeaderCredentials c]
credssShelleyBased)

  partialConsensusConfigConway ::
    PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) ConwayEra))
  partialConsensusConfigConway :: PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) ConwayEra))
partialConsensusConfigConway = PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) ConwayEra))
PraosParams
praosParams

  partialLedgerConfigConway :: PartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
  partialLedgerConfigConway :: PartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
partialLedgerConfigConway =
    TransitionConfig ConwayEra
-> TriggerHardFork
-> PartialLedgerConfig (ShelleyBlock Any ConwayEra)
forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley
      TransitionConfig ConwayEra
transitionConfigConway
      TriggerHardFork
TriggerHardForkNotDuringThisExecution

  -- 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) (CardanoShelleyEras c)
-> NP (K EraParams) (CardanoEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) ShelleyEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (TPraos c) ShelleyEra)
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP (K EraParams) (CardanoShelleyEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) AllegraEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (TPraos c) AllegraEra)
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) MaryEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (TPraos c) MaryEra)
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (TPraos c) AlonzoEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (TPraos c) AlonzoEra)
-> NP
     (K EraParams)
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     (K EraParams)
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (Praos c) BabbageEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (Praos c) BabbageEra)
-> NP (K EraParams) '[ShelleyBlock (Praos c) ConwayEra]
-> NP
     (K EraParams)
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* EraParams -> K EraParams (ShelleyBlock (Praos c) ConwayEra)
forall k a (b :: k). a -> K a b
K (ShelleyGenesis -> EraParams
Shelley.shelleyEraParams ShelleyGenesis
genesisShelley)
          K EraParams (ShelleyBlock (Praos c) ConwayEra)
-> NP (K EraParams) '[]
-> NP (K EraParams) '[ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* NP (K EraParams) '[]
forall {k} (f :: k -> *). NP f '[]
Nil

  cfg :: TopLevelConfig (CardanoBlock c)
  cfg :: TopLevelConfig (HardForkBlock (CardanoEras c))
cfg =
    TopLevelConfig
      { topLevelConfigProtocol :: ConsensusConfig (BlockProtocol (HardForkBlock (CardanoEras c)))
topLevelConfigProtocol =
          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 (CardanoShelleyEras c)
-> NP WrapPartialConsensusConfig (CardanoEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) ShelleyEra))
-> WrapPartialConsensusConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) ShelleyEra))
partialConsensusConfigShelley
                      WrapPartialConsensusConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP WrapPartialConsensusConfig (CardanoShelleyEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) AllegraEra))
-> WrapPartialConsensusConfig (ShelleyBlock (TPraos c) AllegraEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) AllegraEra))
partialConsensusConfigAllegra
                      WrapPartialConsensusConfig (ShelleyBlock (TPraos c) AllegraEra)
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) MaryEra))
-> WrapPartialConsensusConfig (ShelleyBlock (TPraos c) MaryEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) MaryEra))
partialConsensusConfigMary
                      WrapPartialConsensusConfig (ShelleyBlock (TPraos c) MaryEra)
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) AlonzoEra))
-> WrapPartialConsensusConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (TPraos c) AlonzoEra))
partialConsensusConfigAlonzo
                      WrapPartialConsensusConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) BabbageEra))
-> WrapPartialConsensusConfig (ShelleyBlock (Praos c) BabbageEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) BabbageEra))
partialConsensusConfigBabbage
                      WrapPartialConsensusConfig (ShelleyBlock (Praos c) BabbageEra)
-> NP
     WrapPartialConsensusConfig '[ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialConsensusConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) ConwayEra))
-> WrapPartialConsensusConfig (ShelleyBlock (Praos c) ConwayEra)
forall blk.
PartialConsensusConfig (BlockProtocol blk)
-> WrapPartialConsensusConfig blk
WrapPartialConsensusConfig PartialConsensusConfig
  (BlockProtocol (ShelleyBlock (Praos c) ConwayEra))
partialConsensusConfigConway
                      WrapPartialConsensusConfig (ShelleyBlock (Praos c) ConwayEra)
-> NP WrapPartialConsensusConfig '[]
-> NP
     WrapPartialConsensusConfig '[ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* NP WrapPartialConsensusConfig '[]
forall {k} (f :: k -> *). NP f '[]
Nil
                  )
            }
      , topLevelConfigLedger :: LedgerConfig (HardForkBlock (CardanoEras c))
topLevelConfigLedger =
          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 (CardanoShelleyEras c)
-> NP WrapPartialLedgerConfig (CardanoEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
partialLedgerConfigShelley
                      WrapPartialLedgerConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP WrapPartialLedgerConfig (CardanoShelleyEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
partialLedgerConfigAllegra
                      WrapPartialLedgerConfig (ShelleyBlock (TPraos c) AllegraEra)
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
partialLedgerConfigMary
                      WrapPartialLedgerConfig (ShelleyBlock (TPraos c) MaryEra)
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> WrapPartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
partialLedgerConfigAlonzo
                      WrapPartialLedgerConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
-> WrapPartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
partialLedgerConfigBabbage
                      WrapPartialLedgerConfig (ShelleyBlock (Praos c) BabbageEra)
-> NP WrapPartialLedgerConfig '[ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapPartialLedgerConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* PartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
-> WrapPartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
forall blk. PartialLedgerConfig blk -> WrapPartialLedgerConfig blk
WrapPartialLedgerConfig PartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
partialLedgerConfigConway
                      WrapPartialLedgerConfig (ShelleyBlock (Praos c) ConwayEra)
-> NP WrapPartialLedgerConfig '[]
-> NP WrapPartialLedgerConfig '[ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* NP WrapPartialLedgerConfig '[]
forall {k} (f :: k -> *). NP f '[]
Nil
                  )
            }
      , topLevelConfigBlock :: BlockConfig (HardForkBlock (CardanoEras c))
topLevelConfigBlock =
          BlockConfig ByronBlock
-> BlockConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> BlockConfig (ShelleyBlock (TPraos c) AllegraEra)
-> BlockConfig (ShelleyBlock (TPraos c) MaryEra)
-> BlockConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> BlockConfig (ShelleyBlock (Praos c) BabbageEra)
-> BlockConfig (ShelleyBlock (Praos c) ConwayEra)
-> BlockConfig (HardForkBlock (CardanoEras c))
forall c.
BlockConfig ByronBlock
-> BlockConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> BlockConfig (ShelleyBlock (TPraos c) AllegraEra)
-> BlockConfig (ShelleyBlock (TPraos c) MaryEra)
-> BlockConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> BlockConfig (ShelleyBlock (Praos c) BabbageEra)
-> BlockConfig (ShelleyBlock (Praos c) ConwayEra)
-> CardanoBlockConfig c
CardanoBlockConfig
            BlockConfig ByronBlock
blockConfigByron
            BlockConfig (ShelleyBlock (TPraos c) ShelleyEra)
blockConfigShelley
            BlockConfig (ShelleyBlock (TPraos c) AllegraEra)
blockConfigAllegra
            BlockConfig (ShelleyBlock (TPraos c) MaryEra)
blockConfigMary
            BlockConfig (ShelleyBlock (TPraos c) AlonzoEra)
blockConfigAlonzo
            BlockConfig (ShelleyBlock (Praos c) BabbageEra)
blockConfigBabbage
            BlockConfig (ShelleyBlock (Praos c) ConwayEra)
blockConfigConway
      , topLevelConfigCodec :: CodecConfig (HardForkBlock (CardanoEras c))
topLevelConfigCodec =
          CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> CodecConfig (HardForkBlock (CardanoEras c))
forall c.
CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> CardanoCodecConfig c
CardanoCodecConfig
            (TopLevelConfig ByronBlock -> CodecConfig ByronBlock
forall blk. TopLevelConfig blk -> CodecConfig blk
configCodec TopLevelConfig ByronBlock
topLevelConfigByron)
            CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) MaryEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (Praos c) BabbageEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
            CodecConfig (ShelleyBlock (Praos c) ConwayEra)
forall proto era. CodecConfig (ShelleyBlock proto era)
Shelley.ShelleyCodecConfig
      , topLevelConfigStorage :: StorageConfig (HardForkBlock (CardanoEras c))
topLevelConfigStorage =
          StorageConfig ByronBlock
-> StorageConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> StorageConfig (ShelleyBlock (TPraos c) AllegraEra)
-> StorageConfig (ShelleyBlock (TPraos c) MaryEra)
-> StorageConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> StorageConfig (ShelleyBlock (Praos c) BabbageEra)
-> StorageConfig (ShelleyBlock (Praos c) ConwayEra)
-> StorageConfig (HardForkBlock (CardanoEras c))
forall c.
StorageConfig ByronBlock
-> StorageConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> StorageConfig (ShelleyBlock (TPraos c) AllegraEra)
-> StorageConfig (ShelleyBlock (TPraos c) MaryEra)
-> StorageConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> StorageConfig (ShelleyBlock (Praos c) BabbageEra)
-> StorageConfig (ShelleyBlock (Praos c) ConwayEra)
-> CardanoStorageConfig c
CardanoStorageConfig
            (TopLevelConfig ByronBlock -> StorageConfig ByronBlock
forall blk. TopLevelConfig blk -> StorageConfig blk
configStorage TopLevelConfig ByronBlock
topLevelConfigByron)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) AllegraEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam -> StorageConfig (ShelleyBlock (TPraos c) MaryEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (Praos c) BabbageEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
            (Word64
-> SecurityParam
-> StorageConfig (ShelleyBlock (Praos c) ConwayEra)
forall proto era.
Word64 -> SecurityParam -> StorageConfig (ShelleyBlock proto era)
Shelley.ShelleyStorageConfig Word64
tpraosSlotsPerKESPeriod SecurityParam
k)
      , topLevelConfigCheckpoints :: CheckpointsMap (HardForkBlock (CardanoEras c))
topLevelConfigCheckpoints = CheckpointsMap (HardForkBlock (CardanoEras c))
cardanoCheckpoints
      }

  -- When the initial ledger state is not in the Byron era, register various
  -- data from the genesis config (if provided) in the ledger state. For
  -- example, this includes initial staking and initial funds (useful for
  -- testing/benchmarking).
  initExtLedgerStateCardano :: ExtLedgerState (CardanoBlock c) ValuesMK
  initExtLedgerStateCardano :: ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK
initExtLedgerStateCardano =
    ExtLedgerState
      { headerState :: HeaderState (HardForkBlock (CardanoEras c))
headerState = HeaderState (HardForkBlock (CardanoEras c))
initHeaderState
      , ledgerState :: LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
ledgerState = LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
-> LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
overShelleyBasedLedgerState LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
initLedgerState
      }
   where
    overShelleyBasedLedgerState :: LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
-> LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
overShelleyBasedLedgerState (HardForkLedgerState HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
st) =
      HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
-> LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
forall (xs :: [*]) (mk :: MapKind).
HardForkState (Flip LedgerState mk) xs
-> LedgerState (HardForkBlock xs) mk
HardForkLedgerState (HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
 -> LedgerState (HardForkBlock (CardanoEras c)) ValuesMK)
-> HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
-> LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
forall a b. (a -> b) -> a -> b
$ Prod
  HardForkState
  (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
  (CardanoEras c)
-> HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
-> HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
forall k l (h :: (k -> *) -> l -> *) (f :: k -> *) (g :: k -> *)
       (xs :: l).
HAp h =>
Prod h (f -.-> g) xs -> h f xs -> h g xs
forall (f :: * -> *) (g :: * -> *) (xs :: [*]).
Prod HardForkState (f -.-> g) xs
-> HardForkState f xs -> HardForkState g xs
hap ((Flip LedgerState ValuesMK ByronBlock
 -> Flip LedgerState ValuesMK ByronBlock)
-> (-.->)
     (Flip LedgerState ValuesMK) (Flip LedgerState ValuesMK) ByronBlock
forall {k} (f :: k -> *) (a :: k) (f' :: k -> *).
(f a -> f' a) -> (-.->) f f' a
fn Flip LedgerState ValuesMK ByronBlock
-> Flip LedgerState ValuesMK ByronBlock
forall a. a -> a
id (-.->)
  (Flip LedgerState ValuesMK) (Flip LedgerState ValuesMK) ByronBlock
-> NP
     (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
     (CardanoShelleyEras c)
-> NP
     (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
     (CardanoEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* NP
  (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
  (CardanoShelleyEras c)
registerAny) HardForkState (Flip LedgerState ValuesMK) (CardanoEras c)
st

    initHeaderState :: HeaderState (CardanoBlock c)
    initLedgerState :: LedgerState (CardanoBlock c) ValuesMK
    ExtLedgerState LedgerState (HardForkBlock (CardanoEras c)) ValuesMK
initLedgerState HeaderState (HardForkBlock (CardanoEras c))
initHeaderState =
      TopLevelConfig (HardForkBlock (CardanoEras c))
-> ExtLedgerState ByronBlock ValuesMK
-> ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK
forall x (xs :: [*]).
(CanHardFork (x : xs),
 HasLedgerTables (LedgerState (HardForkBlock (x : xs)))) =>
TopLevelConfig (HardForkBlock (x : xs))
-> ExtLedgerState x ValuesMK
-> ExtLedgerState (HardForkBlock (x : xs)) ValuesMK
injectInitialExtLedgerState TopLevelConfig (HardForkBlock (CardanoEras c))
cfg (ExtLedgerState ByronBlock ValuesMK
 -> ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK)
-> ExtLedgerState ByronBlock ValuesMK
-> ExtLedgerState (HardForkBlock (CardanoEras c)) ValuesMK
forall a b. (a -> b) -> a -> b
$
        ExtLedgerState ByronBlock ValuesMK
initExtLedgerStateByron

    registerAny :: NP (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK) (CardanoShelleyEras c)
    registerAny :: NP
  (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
  (CardanoShelleyEras c)
registerAny =
      Proxy IsShelleyBlock
-> (forall a.
    IsShelleyBlock a =>
    WrapTransitionConfig a
    -> (-.->)
         (Flip LedgerState ValuesMK) (Flip LedgerState ValuesMK) a)
-> NP WrapTransitionConfig (CardanoShelleyEras c)
-> NP
     (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
     (CardanoShelleyEras c)
forall {k} {l} (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (forall {k} (t :: k). Proxy t
forall (t :: * -> Constraint). Proxy t
Proxy @IsShelleyBlock) WrapTransitionConfig a
-> (-.->) (Flip LedgerState ValuesMK) (Flip LedgerState ValuesMK) a
WrapTransitionConfig
  (ShelleyBlock (BlockProtocol a) (ShelleyBlockLedgerEra a))
-> (-.->)
     (Flip LedgerState ValuesMK)
     (Flip LedgerState ValuesMK)
     (ShelleyBlock (BlockProtocol a) (ShelleyBlockLedgerEra a))
forall a.
IsShelleyBlock a =>
WrapTransitionConfig a
-> (-.->) (Flip LedgerState ValuesMK) (Flip LedgerState ValuesMK) a
forall era proto.
ShelleyBasedEra era =>
WrapTransitionConfig (ShelleyBlock proto era)
-> (-.->)
     (Flip LedgerState ValuesMK)
     (Flip LedgerState ValuesMK)
     (ShelleyBlock proto era)
injectIntoTestState (NP WrapTransitionConfig (CardanoShelleyEras c)
 -> NP
      (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
      (CardanoShelleyEras c))
-> NP WrapTransitionConfig (CardanoShelleyEras c)
-> NP
     (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK)
     (CardanoShelleyEras c)
forall a b. (a -> b) -> a -> b
$
        TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) ShelleyEra))
-> WrapTransitionConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig ShelleyEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) ShelleyEra))
transitionConfigShelley
          WrapTransitionConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP WrapTransitionConfig (CardanoShelleyEras c)
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) AllegraEra))
-> WrapTransitionConfig (ShelleyBlock (TPraos c) AllegraEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig AllegraEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) AllegraEra))
transitionConfigAllegra
          WrapTransitionConfig (ShelleyBlock (TPraos c) AllegraEra)
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) AllegraEra,
       ShelleyBlock (TPraos c) MaryEra, ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) MaryEra))
-> WrapTransitionConfig (ShelleyBlock (TPraos c) MaryEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig MaryEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) MaryEra))
transitionConfigMary
          WrapTransitionConfig (ShelleyBlock (TPraos c) MaryEra)
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) MaryEra,
       ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) AlonzoEra))
-> WrapTransitionConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig AlonzoEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (TPraos c) AlonzoEra))
transitionConfigAlonzo
          WrapTransitionConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (TPraos c) AlonzoEra,
       ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (Praos c) BabbageEra))
-> WrapTransitionConfig (ShelleyBlock (Praos c) BabbageEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig BabbageEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (Praos c) BabbageEra))
transitionConfigBabbage
          WrapTransitionConfig (ShelleyBlock (Praos c) BabbageEra)
-> NP WrapTransitionConfig '[ShelleyBlock (Praos c) ConwayEra]
-> NP
     WrapTransitionConfig
     '[ShelleyBlock (Praos c) BabbageEra,
       ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (Praos c) ConwayEra))
-> WrapTransitionConfig (ShelleyBlock (Praos c) ConwayEra)
forall blk.
TransitionConfig (ShelleyBlockLedgerEra blk)
-> WrapTransitionConfig blk
WrapTransitionConfig TransitionConfig ConwayEra
TransitionConfig
  (ShelleyBlockLedgerEra (ShelleyBlock (Praos c) ConwayEra))
transitionConfigConway
          WrapTransitionConfig (ShelleyBlock (Praos c) ConwayEra)
-> NP WrapTransitionConfig '[]
-> NP WrapTransitionConfig '[ShelleyBlock (Praos c) ConwayEra]
forall {k} (f :: k -> *) (x :: k) (xs1 :: [k]).
f x -> NP f xs1 -> NP f (x : xs1)
:* NP WrapTransitionConfig '[]
forall {k} (f :: k -> *). NP f '[]
Nil

    injectIntoTestState ::
      ShelleyBasedEra era =>
      WrapTransitionConfig (ShelleyBlock proto era) ->
      (Flip LedgerState ValuesMK -.-> Flip LedgerState ValuesMK) (ShelleyBlock proto era)
    injectIntoTestState :: forall era proto.
ShelleyBasedEra era =>
WrapTransitionConfig (ShelleyBlock proto era)
-> (-.->)
     (Flip LedgerState ValuesMK)
     (Flip LedgerState ValuesMK)
     (ShelleyBlock proto era)
injectIntoTestState (WrapTransitionConfig TransitionConfig (ShelleyBlockLedgerEra (ShelleyBlock proto era))
tcfg) = (Flip LedgerState ValuesMK (ShelleyBlock proto era)
 -> Flip LedgerState ValuesMK (ShelleyBlock proto era))
-> (-.->)
     (Flip LedgerState ValuesMK)
     (Flip LedgerState ValuesMK)
     (ShelleyBlock proto era)
forall {k} (f :: k -> *) (a :: k) (f' :: k -> *).
(f a -> f' a) -> (-.->) f f' a
fn ((Flip LedgerState ValuesMK (ShelleyBlock proto era)
  -> Flip LedgerState ValuesMK (ShelleyBlock proto era))
 -> (-.->)
      (Flip LedgerState ValuesMK)
      (Flip LedgerState ValuesMK)
      (ShelleyBlock proto era))
-> (Flip LedgerState ValuesMK (ShelleyBlock proto era)
    -> Flip LedgerState ValuesMK (ShelleyBlock proto era))
-> (-.->)
     (Flip LedgerState ValuesMK)
     (Flip LedgerState ValuesMK)
     (ShelleyBlock proto era)
forall a b. (a -> b) -> a -> b
$ \(Flip LedgerState (ShelleyBlock proto era) ValuesMK
st) ->
      -- We need to unstow the injected values
      LedgerState (ShelleyBlock proto era) ValuesMK
-> Flip LedgerState ValuesMK (ShelleyBlock proto era)
forall x y (f :: x -> y -> *) (x1 :: y) (y1 :: x).
f y1 x1 -> Flip f x1 y1
Flip (LedgerState (ShelleyBlock proto era) ValuesMK
 -> Flip LedgerState ValuesMK (ShelleyBlock proto era))
-> LedgerState (ShelleyBlock proto era) ValuesMK
-> Flip LedgerState ValuesMK (ShelleyBlock proto era)
forall a b. (a -> b) -> a -> b
$
        LedgerState (ShelleyBlock proto era) EmptyMK
-> LedgerState (ShelleyBlock proto era) ValuesMK
forall (l :: LedgerStateKind).
CanStowLedgerTables l =>
l EmptyMK -> l ValuesMK
unstowLedgerTables (LedgerState (ShelleyBlock proto era) EmptyMK
 -> LedgerState (ShelleyBlock proto era) ValuesMK)
-> LedgerState (ShelleyBlock proto era) EmptyMK
-> LedgerState (ShelleyBlock proto era) ValuesMK
forall a b. (a -> b) -> a -> b
$
          LedgerState (ShelleyBlock proto era) ValuesMK
-> LedgerState (ShelleyBlock proto era) EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables (LedgerState (ShelleyBlock proto era) ValuesMK
 -> LedgerState (ShelleyBlock proto era) EmptyMK)
-> LedgerState (ShelleyBlock proto era) ValuesMK
-> LedgerState (ShelleyBlock proto era) EmptyMK
forall a b. (a -> b) -> a -> b
$
            LedgerState (ShelleyBlock proto era) ValuesMK
st
              { Shelley.shelleyLedgerState =
                  L.injectIntoTestState
                    tcfg
                    (Shelley.shelleyLedgerState $ stowLedgerTables 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 (HardForkBlock (CardanoEras c))]
blockForging = do
    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)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ShelleyLeaderCredentials c
-> m (NonEmptyOptNP (BlockForging m) (CardanoEras c))
blockForgingShelleyBased [ShelleyLeaderCredentials c]
credssShelleyBased
    let 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 These1 (BlockForging m) (BlockForging m) a -> BlockForging m a
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
_) = String -> f a
forall a. HasCallStack => String -> a
error String
"forgings of the same era"
            merge (This1 f a
x) = f a
x
            merge (That1 f a
y) = f a
y

    return $ hardForkBlockForging "Cardano" <$> blockForgings

  mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
  mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
mBlockForgingByron = do
    creds <- Maybe ByronLeaderCredentials
mCredsByron
    return $ byronBlockForging creds `OptNP.at` 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 -> UnsoundPureSignKeyKES (KES c)
shelleyLeaderCredentialsInitSignKey = UnsoundPureSignKeyKES (KES c)
initSignKey
          , shelleyLeaderCredentialsCanBeLeader :: forall c. ShelleyLeaderCredentials c -> PraosCanBeLeader c
shelleyLeaderCredentialsCanBeLeader = PraosCanBeLeader c
canBeLeader
          } = ShelleyLeaderCredentials c
credentials

    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 c. OCert c -> 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

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

    let slotToPeriod :: SlotNo -> Absolute.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 =>
          BlockForging m (ShelleyBlock (TPraos c) era)
        tpraos =
          HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> BlockForging m (ShelleyBlock (TPraos c) era)
forall (m :: * -> *) c era.
(ShelleyEraWithCrypto c (TPraos c) era, IOLike m) =>
HotKey c m
-> (SlotNo -> KESPeriod)
-> ShelleyLeaderCredentials c
-> BlockForging m (ShelleyBlock (TPraos c) era)
TPraos.shelleySharedBlockForging HotKey c m
hotKey SlotNo -> KESPeriod
slotToPeriod ShelleyLeaderCredentials c
credentials

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

    pure $
      OptSkip $ -- Byron
        OptNP.fromNonEmptyNP $
          tpraos
            :* tpraos
            :* tpraos
            :* tpraos
            :* praos
            :* praos
            :* Nil

protocolClientInfoCardano ::
  forall c.
  -- Byron
  EpochSlots ->
  ProtocolClientInfo (CardanoBlock c)
protocolClientInfoCardano :: forall c. EpochSlots -> ProtocolClientInfo (CardanoBlock c)
protocolClientInfoCardano EpochSlots
epochSlots =
  ProtocolClientInfo
    { pClientInfoCodecConfig :: CodecConfig (CardanoBlock c)
pClientInfoCodecConfig =
        CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> CodecConfig (CardanoBlock c)
forall c.
CodecConfig ByronBlock
-> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
-> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
-> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
-> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
-> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
-> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
-> 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)
-> CodecConfig (ShelleyBlock (TPraos c) ShelleyEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) ShelleyEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) AllegraEra)
-> CodecConfig (ShelleyBlock (TPraos c) AllegraEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) AllegraEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) MaryEra)
-> CodecConfig (ShelleyBlock (TPraos c) MaryEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) MaryEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (TPraos c) AlonzoEra)
-> CodecConfig (ShelleyBlock (TPraos c) AlonzoEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (TPraos c) AlonzoEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (Praos c) BabbageEra)
-> CodecConfig (ShelleyBlock (Praos c) BabbageEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (Praos c) BabbageEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
          (ProtocolClientInfo (ShelleyBlock (Praos c) ConwayEra)
-> CodecConfig (ShelleyBlock (Praos c) ConwayEra)
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig ProtocolClientInfo (ShelleyBlock (Praos c) ConwayEra)
forall proto era. ProtocolClientInfo (ShelleyBlock proto era)
protocolClientInfoShelley)
    }

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

mkPartialLedgerConfigShelley ::
  L.EraTransition era =>
  L.TransitionConfig era ->
  TriggerHardFork ->
  PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley :: forall era proto.
EraTransition era =>
TransitionConfig era
-> TriggerHardFork -> PartialLedgerConfig (ShelleyBlock proto era)
mkPartialLedgerConfigShelley TransitionConfig era
transitionConfig TriggerHardFork
shelleyTriggerHardFork =
  ShelleyPartialLedgerConfig
    { shelleyLedgerConfig :: ShelleyLedgerConfig era
shelleyLedgerConfig =
        ShelleyGenesis
-> TranslationContext era
-> EpochInfo (Except PastHorizonException)
-> ShelleyLedgerConfig era
forall era.
ShelleyGenesis
-> TranslationContext era
-> EpochInfo (Except PastHorizonException)
-> ShelleyLedgerConfig era
Shelley.mkShelleyLedgerConfig
          (TransitionConfig era
transitionConfig TransitionConfig era
-> Getting ShelleyGenesis (TransitionConfig era) ShelleyGenesis
-> ShelleyGenesis
forall s a. s -> Getting a s a -> a
^. Getting ShelleyGenesis (TransitionConfig era) ShelleyGenesis
forall era.
EraTransition era =>
Lens' (TransitionConfig era) ShelleyGenesis
Lens' (TransitionConfig era) ShelleyGenesis
L.tcShelleyGenesisL)
          (TransitionConfig era
transitionConfig TransitionConfig era
-> Getting
     (TranslationContext era)
     (TransitionConfig era)
     (TranslationContext era)
-> TranslationContext era
forall s a. s -> Getting a s a -> a
^. Getting
  (TranslationContext era)
  (TransitionConfig era)
  (TranslationContext era)
forall era.
EraTransition era =>
Lens' (TransitionConfig era) (TranslationContext era)
Lens' (TransitionConfig era) (TranslationContext era)
L.tcTranslationContextL)
          -- 'completeLedgerConfig' will replace the 'History.dummyEpochInfo'
          -- in the partial ledger config with the correct one.
          EpochInfo (Except PastHorizonException)
History.dummyEpochInfo
    , shelleyTriggerHardFork :: TriggerHardFork
shelleyTriggerHardFork = TriggerHardFork
shelleyTriggerHardFork
    }

-- | We need this wrapper to partially apply a 'TransitionConfig' in an NP.
newtype WrapTransitionConfig blk
  = WrapTransitionConfig (L.TransitionConfig (ShelleyBlockLedgerEra blk))