{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Chain.Update.ProtocolParameters
  ( ProtocolParameters (..),
    upAdptThd,
    isBootstrapEraPP,
  )
where

import Cardano.Binary (FromCBOR (..), ToCBOR (..), encodeListLen, enforceSize)
import Cardano.Chain.Common
  ( LovelacePortion,
    TxFeePolicy,
    lovelacePortionToRational,
  )
import Cardano.Chain.Slotting (EpochNumber, SlotNumber (..), isBootstrapEra)
import Cardano.Chain.Update.SoftforkRule
import Cardano.Prelude
import Formatting (Format, bprint, build, bytes, shortest)
import qualified Formatting.Buildable as B
import NoThunks.Class (NoThunks (..))
import Text.JSON.Canonical (FromJSON (..), ToJSON (..), fromJSField, mkObject)

-- | Data which is associated with 'BlockVersion'
data ProtocolParameters = ProtocolParameters
  { ProtocolParameters -> Word16
ppScriptVersion :: !Word16,
    -- | Milliseconds.
    ProtocolParameters -> Natural
ppSlotDuration :: !Natural,
    ProtocolParameters -> Natural
ppMaxBlockSize :: !Natural,
    ProtocolParameters -> Natural
ppMaxHeaderSize :: !Natural,
    ProtocolParameters -> Natural
ppMaxTxSize :: !Natural,
    ProtocolParameters -> Natural
ppMaxProposalSize :: !Natural,
    ProtocolParameters -> LovelacePortion
ppMpcThd :: !LovelacePortion,
    ProtocolParameters -> LovelacePortion
ppHeavyDelThd :: !LovelacePortion,
    ProtocolParameters -> LovelacePortion
ppUpdateVoteThd :: !LovelacePortion,
    ProtocolParameters -> LovelacePortion
ppUpdateProposalThd :: !LovelacePortion,
    -- | Time to live for a protocol update proposal. This used to be the number
    -- of slots after which the system made a decision regarding an update
    -- proposal confirmation, when a majority of votes was not reached in the
    -- given number of slots. If there were more positive than negative votes the
    -- proposal became confirmed, otherwise it was rejected. Since in the
    -- Byron-Shelley bridge we do not have negative votes, and we aim at
    -- simplifying the update mechanism, 'ppUpdateProposalTTL' is re-interpreted as
    -- the number of slots a proposal has to gather a majority of votes. If a
    -- majority of votes has not been reached before this period, then the
    -- proposal is rejected.
    --
    -- -- TODO: it seems this should be a slot count.
    ProtocolParameters -> SlotNumber
ppUpdateProposalTTL :: !SlotNumber,
    ProtocolParameters -> SoftforkRule
ppSoftforkRule :: !SoftforkRule,
    ProtocolParameters -> TxFeePolicy
ppTxFeePolicy :: !TxFeePolicy,
    ProtocolParameters -> EpochNumber
ppUnlockStakeEpoch :: !EpochNumber
  }
  deriving (Int -> ProtocolParameters -> ShowS
[ProtocolParameters] -> ShowS
ProtocolParameters -> String
(Int -> ProtocolParameters -> ShowS)
-> (ProtocolParameters -> String)
-> ([ProtocolParameters] -> ShowS)
-> Show ProtocolParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtocolParameters] -> ShowS
$cshowList :: [ProtocolParameters] -> ShowS
show :: ProtocolParameters -> String
$cshow :: ProtocolParameters -> String
showsPrec :: Int -> ProtocolParameters -> ShowS
$cshowsPrec :: Int -> ProtocolParameters -> ShowS
Show, ProtocolParameters -> ProtocolParameters -> Bool
(ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> Eq ProtocolParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtocolParameters -> ProtocolParameters -> Bool
$c/= :: ProtocolParameters -> ProtocolParameters -> Bool
== :: ProtocolParameters -> ProtocolParameters -> Bool
$c== :: ProtocolParameters -> ProtocolParameters -> Bool
Eq, Eq ProtocolParameters
Eq ProtocolParameters
-> (ProtocolParameters -> ProtocolParameters -> Ordering)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> ProtocolParameters)
-> (ProtocolParameters -> ProtocolParameters -> ProtocolParameters)
-> Ord ProtocolParameters
ProtocolParameters -> ProtocolParameters -> Bool
ProtocolParameters -> ProtocolParameters -> Ordering
ProtocolParameters -> ProtocolParameters -> ProtocolParameters
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ProtocolParameters -> ProtocolParameters -> ProtocolParameters
$cmin :: ProtocolParameters -> ProtocolParameters -> ProtocolParameters
max :: ProtocolParameters -> ProtocolParameters -> ProtocolParameters
$cmax :: ProtocolParameters -> ProtocolParameters -> ProtocolParameters
>= :: ProtocolParameters -> ProtocolParameters -> Bool
$c>= :: ProtocolParameters -> ProtocolParameters -> Bool
> :: ProtocolParameters -> ProtocolParameters -> Bool
$c> :: ProtocolParameters -> ProtocolParameters -> Bool
<= :: ProtocolParameters -> ProtocolParameters -> Bool
$c<= :: ProtocolParameters -> ProtocolParameters -> Bool
< :: ProtocolParameters -> ProtocolParameters -> Bool
$c< :: ProtocolParameters -> ProtocolParameters -> Bool
compare :: ProtocolParameters -> ProtocolParameters -> Ordering
$ccompare :: ProtocolParameters -> ProtocolParameters -> Ordering
$cp1Ord :: Eq ProtocolParameters
Ord, (forall x. ProtocolParameters -> Rep ProtocolParameters x)
-> (forall x. Rep ProtocolParameters x -> ProtocolParameters)
-> Generic ProtocolParameters
forall x. Rep ProtocolParameters x -> ProtocolParameters
forall x. ProtocolParameters -> Rep ProtocolParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProtocolParameters x -> ProtocolParameters
$cfrom :: forall x. ProtocolParameters -> Rep ProtocolParameters x
Generic)
  deriving anyclass (ProtocolParameters -> ()
(ProtocolParameters -> ()) -> NFData ProtocolParameters
forall a. (a -> ()) -> NFData a
rnf :: ProtocolParameters -> ()
$crnf :: ProtocolParameters -> ()
NFData, Context -> ProtocolParameters -> IO (Maybe ThunkInfo)
Proxy ProtocolParameters -> String
(Context -> ProtocolParameters -> IO (Maybe ThunkInfo))
-> (Context -> ProtocolParameters -> IO (Maybe ThunkInfo))
-> (Proxy ProtocolParameters -> String)
-> NoThunks ProtocolParameters
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy ProtocolParameters -> String
$cshowTypeOf :: Proxy ProtocolParameters -> String
wNoThunks :: Context -> ProtocolParameters -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> ProtocolParameters -> IO (Maybe ThunkInfo)
noThunks :: Context -> ProtocolParameters -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> ProtocolParameters -> IO (Maybe ThunkInfo)
NoThunks)

instance B.Buildable ProtocolParameters where
  build :: ProtocolParameters -> Builder
build ProtocolParameters
pp =
    Format
  Builder
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Word16
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> SlotNumber
-> SoftforkRule
-> TxFeePolicy
-> EpochNumber
-> Builder
forall a. Format Builder a -> a
bprint
      ( Format
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
"{ script version: " Format
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Word16
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Word16
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Word16
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Word16
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", slot duration: "
          Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall r. Format r (Natural -> r)
bytes'
          Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", block size limit: "
          Format
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall r. Format r (Natural -> r)
bytes'
          Format
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", header size limit: "
          Format
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall r. Format r (Natural -> r)
bytes'
          Format
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", tx size limit: "
          Format
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall r. Format r (Natural -> r)
bytes'
          Format
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", proposal size limit: "
          Format
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall r. Format r (Natural -> r)
bytes'
          Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", mpc threshold: "
          Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", heavyweight delegation threshold: "
          Format
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", update vote threshold: "
          Format
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
", update proposal threshold: "
          Format
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> Builder)
-> Format
     Builder
     (SlotNumber
      -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder
     (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
", update implicit period: "
          Format
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder
     (SlotNumber
      -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder
     (SlotNumber
      -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SlotNumber
   -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder
     (SlotNumber
      -> SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
" slots"
          Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
", softfork rule: "
          Format
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (TxFeePolicy -> EpochNumber -> Builder)
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
-> Format Builder (TxFeePolicy -> EpochNumber -> Builder)
-> Format
     Builder (SoftforkRule -> TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (TxFeePolicy -> EpochNumber -> Builder)
  (TxFeePolicy -> EpochNumber -> Builder)
", tx fee policy: "
          Format
  (TxFeePolicy -> EpochNumber -> Builder)
  (TxFeePolicy -> EpochNumber -> Builder)
-> Format Builder (TxFeePolicy -> EpochNumber -> Builder)
-> Format Builder (TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format
  (EpochNumber -> Builder) (TxFeePolicy -> EpochNumber -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format
  (EpochNumber -> Builder) (TxFeePolicy -> EpochNumber -> Builder)
-> Format Builder (EpochNumber -> Builder)
-> Format Builder (TxFeePolicy -> EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format (EpochNumber -> Builder) (EpochNumber -> Builder)
", unlock stake epoch: "
          Format (EpochNumber -> Builder) (EpochNumber -> Builder)
-> Format Builder (EpochNumber -> Builder)
-> Format Builder (EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format Builder (EpochNumber -> Builder)
forall a r. Buildable a => Format r (a -> r)
build
          Format Builder (EpochNumber -> Builder)
-> Format Builder Builder
-> Format Builder (EpochNumber -> Builder)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format Builder Builder
" }"
      )
      (ProtocolParameters -> Word16
ppScriptVersion ProtocolParameters
pp)
      (ProtocolParameters -> Natural
ppSlotDuration ProtocolParameters
pp)
      (ProtocolParameters -> Natural
ppMaxBlockSize ProtocolParameters
pp)
      (ProtocolParameters -> Natural
ppMaxHeaderSize ProtocolParameters
pp)
      (ProtocolParameters -> Natural
ppMaxTxSize ProtocolParameters
pp)
      (ProtocolParameters -> Natural
ppMaxProposalSize ProtocolParameters
pp)
      (ProtocolParameters -> LovelacePortion
ppMpcThd ProtocolParameters
pp)
      (ProtocolParameters -> LovelacePortion
ppHeavyDelThd ProtocolParameters
pp)
      (ProtocolParameters -> LovelacePortion
ppUpdateVoteThd ProtocolParameters
pp)
      (ProtocolParameters -> LovelacePortion
ppUpdateProposalThd ProtocolParameters
pp)
      (ProtocolParameters -> SlotNumber
ppUpdateProposalTTL ProtocolParameters
pp)
      (ProtocolParameters -> SoftforkRule
ppSoftforkRule ProtocolParameters
pp)
      (ProtocolParameters -> TxFeePolicy
ppTxFeePolicy ProtocolParameters
pp)
      (ProtocolParameters -> EpochNumber
ppUnlockStakeEpoch ProtocolParameters
pp)
    where
      bytes' :: Format r (Natural -> r)
      bytes' :: Format r (Natural -> r)
bytes' = Format Builder (Double -> Builder) -> Format r (Natural -> r)
forall f a r.
(Ord f, Integral a, Fractional f) =>
Format Builder (f -> Builder) -> Format r (a -> r)
bytes (forall r. Real Double => Format r (Double -> r)
forall a r. Real a => Format r (a -> r)
shortest @Double)

instance Monad m => ToJSON m ProtocolParameters where
  toJSON :: ProtocolParameters -> m JSValue
toJSON ProtocolParameters
pp =
    [(JSString, m JSValue)] -> m JSValue
forall (m :: * -> *).
Monad m =>
[(JSString, m JSValue)] -> m JSValue
mkObject
      [ (JSString
"scriptVersion", Word16 -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Word16 -> m JSValue) -> Word16 -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Word16
ppScriptVersion ProtocolParameters
pp),
        (JSString
"slotDuration", Natural -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Natural -> m JSValue) -> Natural -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Natural
ppSlotDuration ProtocolParameters
pp),
        (JSString
"maxBlockSize", Natural -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Natural -> m JSValue) -> Natural -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Natural
ppMaxBlockSize ProtocolParameters
pp),
        (JSString
"maxHeaderSize", Natural -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Natural -> m JSValue) -> Natural -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Natural
ppMaxHeaderSize ProtocolParameters
pp),
        (JSString
"maxTxSize", Natural -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Natural -> m JSValue) -> Natural -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Natural
ppMaxTxSize ProtocolParameters
pp),
        (JSString
"maxProposalSize", Natural -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (Natural -> m JSValue) -> Natural -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> Natural
ppMaxProposalSize ProtocolParameters
pp),
        (JSString
"mpcThd", LovelacePortion -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (LovelacePortion -> m JSValue) -> LovelacePortion -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> LovelacePortion
ppMpcThd ProtocolParameters
pp),
        (JSString
"heavyDelThd", LovelacePortion -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (LovelacePortion -> m JSValue) -> LovelacePortion -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> LovelacePortion
ppHeavyDelThd ProtocolParameters
pp),
        (JSString
"updateVoteThd", LovelacePortion -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (LovelacePortion -> m JSValue) -> LovelacePortion -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> LovelacePortion
ppUpdateVoteThd ProtocolParameters
pp),
        (JSString
"updateProposalThd", LovelacePortion -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (LovelacePortion -> m JSValue) -> LovelacePortion -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> LovelacePortion
ppUpdateProposalThd ProtocolParameters
pp),
        (JSString
"updateImplicit", SlotNumber -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (SlotNumber -> m JSValue) -> SlotNumber -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> SlotNumber
ppUpdateProposalTTL ProtocolParameters
pp),
        (JSString
"softforkRule", SoftforkRule -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (SoftforkRule -> m JSValue) -> SoftforkRule -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> SoftforkRule
ppSoftforkRule ProtocolParameters
pp),
        (JSString
"txFeePolicy", TxFeePolicy -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (TxFeePolicy -> m JSValue) -> TxFeePolicy -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> TxFeePolicy
ppTxFeePolicy ProtocolParameters
pp),
        (JSString
"unlockStakeEpoch", EpochNumber -> m JSValue
forall (m :: * -> *) a. ToJSON m a => a -> m JSValue
toJSON (EpochNumber -> m JSValue) -> EpochNumber -> m JSValue
forall a b. (a -> b) -> a -> b
$ ProtocolParameters -> EpochNumber
ppUnlockStakeEpoch ProtocolParameters
pp)
      ]

instance MonadError SchemaError m => FromJSON m ProtocolParameters where
  fromJSON :: JSValue -> m ProtocolParameters
fromJSON JSValue
obj =
    Word16
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> SlotNumber
-> SoftforkRule
-> TxFeePolicy
-> EpochNumber
-> ProtocolParameters
ProtocolParameters
      (Word16
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> LovelacePortion
 -> LovelacePortion
 -> LovelacePortion
 -> LovelacePortion
 -> SlotNumber
 -> SoftforkRule
 -> TxFeePolicy
 -> EpochNumber
 -> ProtocolParameters)
-> m Word16
-> m (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> JSValue -> JSString -> m Word16
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"scriptVersion"
      m (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m Natural
-> m (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m Natural
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"slotDuration"
      m (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m Natural
-> m (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m Natural
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"maxBlockSize"
      m (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m Natural
-> m (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m Natural
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"maxHeaderSize"
      m (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m Natural
-> m (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m Natural
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"maxTxSize"
      m (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m Natural
-> m (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m Natural
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"maxProposalSize"
      m (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m LovelacePortion
-> m (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m LovelacePortion
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"mpcThd"
      m (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m LovelacePortion
-> m (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m LovelacePortion
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"heavyDelThd"
      m (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m LovelacePortion
-> m (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m LovelacePortion
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"updateVoteThd"
      m (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m LovelacePortion
-> m (SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m LovelacePortion
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"updateProposalThd"
      m (SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> m SlotNumber
-> m (SoftforkRule
      -> TxFeePolicy -> EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m SlotNumber
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"updateImplicit"
      m (SoftforkRule
   -> TxFeePolicy -> EpochNumber -> ProtocolParameters)
-> m SoftforkRule
-> m (TxFeePolicy -> EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m SoftforkRule
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"softforkRule"
      m (TxFeePolicy -> EpochNumber -> ProtocolParameters)
-> m TxFeePolicy -> m (EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m TxFeePolicy
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"txFeePolicy"
      m (EpochNumber -> ProtocolParameters)
-> m EpochNumber -> m ProtocolParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> JSValue -> JSString -> m EpochNumber
forall (m :: * -> *) a.
(ReportSchemaErrors m, FromJSON m a) =>
JSValue -> JSString -> m a
fromJSField JSValue
obj JSString
"unlockStakeEpoch"

instance ToCBOR ProtocolParameters where
  toCBOR :: ProtocolParameters -> Encoding
toCBOR ProtocolParameters
pp =
    Word -> Encoding
encodeListLen Word
14
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word16 -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Word16
ppScriptVersion ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Natural
ppSlotDuration ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Natural
ppMaxBlockSize ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Natural
ppMaxHeaderSize ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Natural
ppMaxTxSize ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> Natural
ppMaxProposalSize ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> LovelacePortion -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> LovelacePortion
ppMpcThd ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> LovelacePortion -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> LovelacePortion
ppHeavyDelThd ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> LovelacePortion -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> LovelacePortion
ppUpdateVoteThd ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> LovelacePortion -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> LovelacePortion
ppUpdateProposalThd ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> SlotNumber -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> SlotNumber
ppUpdateProposalTTL ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> SoftforkRule -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> SoftforkRule
ppSoftforkRule ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> TxFeePolicy -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> TxFeePolicy
ppTxFeePolicy ProtocolParameters
pp)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> EpochNumber -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtocolParameters -> EpochNumber
ppUnlockStakeEpoch ProtocolParameters
pp)

instance FromCBOR ProtocolParameters where
  fromCBOR :: Decoder s ProtocolParameters
fromCBOR = do
    Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
enforceSize Text
"ProtocolParameters" Int
14
    Word16
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> LovelacePortion
-> SlotNumber
-> SoftforkRule
-> TxFeePolicy
-> EpochNumber
-> ProtocolParameters
ProtocolParameters
      (Word16
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> LovelacePortion
 -> LovelacePortion
 -> LovelacePortion
 -> LovelacePortion
 -> SlotNumber
 -> SoftforkRule
 -> TxFeePolicy
 -> EpochNumber
 -> ProtocolParameters)
-> Decoder s Word16
-> Decoder
     s
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s Word16
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (Natural
   -> Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (Natural
   -> Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (Natural
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s Natural
-> Decoder
     s
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s LovelacePortion
-> Decoder
     s
     (LovelacePortion
      -> LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s LovelacePortion
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (LovelacePortion
   -> LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s LovelacePortion
-> Decoder
     s
     (LovelacePortion
      -> LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s LovelacePortion
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (LovelacePortion
   -> LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s LovelacePortion
-> Decoder
     s
     (LovelacePortion
      -> SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s LovelacePortion
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (LovelacePortion
   -> SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s LovelacePortion
-> Decoder
     s
     (SlotNumber
      -> SoftforkRule
      -> TxFeePolicy
      -> EpochNumber
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s LovelacePortion
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (SlotNumber
   -> SoftforkRule
   -> TxFeePolicy
   -> EpochNumber
   -> ProtocolParameters)
-> Decoder s SlotNumber
-> Decoder
     s
     (SoftforkRule -> TxFeePolicy -> EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s SlotNumber
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (SoftforkRule -> TxFeePolicy -> EpochNumber -> ProtocolParameters)
-> Decoder s SoftforkRule
-> Decoder s (TxFeePolicy -> EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s SoftforkRule
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (TxFeePolicy -> EpochNumber -> ProtocolParameters)
-> Decoder s TxFeePolicy
-> Decoder s (EpochNumber -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s TxFeePolicy
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (EpochNumber -> ProtocolParameters)
-> Decoder s EpochNumber -> Decoder s ProtocolParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s EpochNumber
forall a s. FromCBOR a => Decoder s a
fromCBOR

-- | Version of 'isBootstrapEra' which takes 'ProtocolParameters' instead of
--   unlock stake epoch
isBootstrapEraPP :: ProtocolParameters -> EpochNumber -> Bool
isBootstrapEraPP :: ProtocolParameters -> EpochNumber -> Bool
isBootstrapEraPP ProtocolParameters
adoptedPP = EpochNumber -> EpochNumber -> Bool
isBootstrapEra (ProtocolParameters -> EpochNumber
ppUnlockStakeEpoch ProtocolParameters
adoptedPP)

-- | In Byron we do not have a @upAdptThd@ protocol parameter, so we have to
--   use the existing ones.
--
--   @lovelacePortionToRational . srMinThd . ppSoftforkRule@ will give us the
--   ratio (in the interval @[0, 1]@) of the total stake that has to endorse a
--   protocol version to become adopted. In genesis configuration, this ratio
--   will evaluate to @0.6@, so if we have 7 genesis keys, @upAdptThd = 4@.
upAdptThd :: Word8 -> ProtocolParameters -> Int
upAdptThd :: Word8 -> ProtocolParameters -> Int
upAdptThd Word8
numGenKeys ProtocolParameters
pps =
  Ratio Integer -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor (Ratio Integer -> Int) -> Ratio Integer -> Int
forall a b. (a -> b) -> a -> b
$ Ratio Integer
stakeRatio Ratio Integer -> Ratio Integer -> Ratio Integer
forall a. Num a => a -> a -> a
* Word8 -> Ratio Integer
forall a. Real a => a -> Ratio Integer
toRational Word8
numGenKeys
  where
    stakeRatio :: Ratio Integer
stakeRatio = LovelacePortion -> Ratio Integer
lovelacePortionToRational (LovelacePortion -> Ratio Integer)
-> (ProtocolParameters -> LovelacePortion)
-> ProtocolParameters
-> Ratio Integer
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SoftforkRule -> LovelacePortion
srMinThd (SoftforkRule -> LovelacePortion)
-> (ProtocolParameters -> SoftforkRule)
-> ProtocolParameters
-> LovelacePortion
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ProtocolParameters -> SoftforkRule
ppSoftforkRule (ProtocolParameters -> Ratio Integer)
-> ProtocolParameters -> Ratio Integer
forall a b. (a -> b) -> a -> b
$ ProtocolParameters
pps