{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}

-- | Peras protocol parameters
module Ouroboros.Consensus.Peras.Params
  ( -- * Protocol parameters
    PerasIgnoranceRounds (..)
  , PerasCooldownRounds (..)
  , PerasBlockMinSlots (..)
  , PerasCertMaxRounds (..)
  , PerasCertArrivalThreshold (..)
  , PerasRoundLength (..)
  , PerasWeight (..)
  , PerasQuorumWeightThreshold (..)
  , PerasQuorumWeightThresholdSafetyMargin (..)

    -- * Protocol parameters bundle
  , PerasParams (..)
  , castPerasParams
  , defaultPerasParams

    -- * Era-dependent default values
  , dijkstraPerasRoundLength

    -- * 'PerasEnabled' wrapper
  , PerasEnabled
  , pattern PerasEnabled
  , pattern NoPerasEnabled
  , PerasEnabledT (..)
  , fromPerasEnabled
  , perasEnabledToMaybe

    -- * Convenience re-exports
  , Committee.TargetCommitteeSize (..)
  )
where

import Cardano.Binary
  ( FromCBOR (..)
  , ToCBOR (..)
  , decodeListLenOf
  , encodeListLen
  )
import Control.Monad (ap, liftM)
import Control.Monad.Trans.Class
import Data.Coerce (coerce)
import Data.Semigroup (Sum (..))
import Data.Typeable (Typeable)
import Data.Word (Word64)
import GHC.Generics (Generic)
import qualified Ouroboros.Consensus.Committee.Types as Committee
import Ouroboros.Consensus.Util.Condense (Condense (..))
import Ouroboros.Consensus.Util.IOLike (NoThunks)
import Quiet (Quiet (..))

-- * Protocol parameters

-- | Number of rounds for which to ignore certificates after entering a
-- cooldown period.
newtype PerasIgnoranceRounds
  = PerasIgnoranceRounds {PerasIgnoranceRounds -> Word64
unPerasIgnoranceRounds :: Word64}
  deriving Int -> PerasIgnoranceRounds -> ShowS
[PerasIgnoranceRounds] -> ShowS
PerasIgnoranceRounds -> String
(Int -> PerasIgnoranceRounds -> ShowS)
-> (PerasIgnoranceRounds -> String)
-> ([PerasIgnoranceRounds] -> ShowS)
-> Show PerasIgnoranceRounds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasIgnoranceRounds -> ShowS
showsPrec :: Int -> PerasIgnoranceRounds -> ShowS
$cshow :: PerasIgnoranceRounds -> String
show :: PerasIgnoranceRounds -> String
$cshowList :: [PerasIgnoranceRounds] -> ShowS
showList :: [PerasIgnoranceRounds] -> ShowS
Show via Quiet PerasIgnoranceRounds
  deriving stock (forall x. PerasIgnoranceRounds -> Rep PerasIgnoranceRounds x)
-> (forall x. Rep PerasIgnoranceRounds x -> PerasIgnoranceRounds)
-> Generic PerasIgnoranceRounds
forall x. Rep PerasIgnoranceRounds x -> PerasIgnoranceRounds
forall x. PerasIgnoranceRounds -> Rep PerasIgnoranceRounds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasIgnoranceRounds -> Rep PerasIgnoranceRounds x
from :: forall x. PerasIgnoranceRounds -> Rep PerasIgnoranceRounds x
$cto :: forall x. Rep PerasIgnoranceRounds x -> PerasIgnoranceRounds
to :: forall x. Rep PerasIgnoranceRounds x -> PerasIgnoranceRounds
Generic
  deriving newtype (Int -> PerasIgnoranceRounds
PerasIgnoranceRounds -> Int
PerasIgnoranceRounds -> [PerasIgnoranceRounds]
PerasIgnoranceRounds -> PerasIgnoranceRounds
PerasIgnoranceRounds
-> PerasIgnoranceRounds -> [PerasIgnoranceRounds]
PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> [PerasIgnoranceRounds]
(PerasIgnoranceRounds -> PerasIgnoranceRounds)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds)
-> (Int -> PerasIgnoranceRounds)
-> (PerasIgnoranceRounds -> Int)
-> (PerasIgnoranceRounds -> [PerasIgnoranceRounds])
-> (PerasIgnoranceRounds
    -> PerasIgnoranceRounds -> [PerasIgnoranceRounds])
-> (PerasIgnoranceRounds
    -> PerasIgnoranceRounds -> [PerasIgnoranceRounds])
-> (PerasIgnoranceRounds
    -> PerasIgnoranceRounds
    -> PerasIgnoranceRounds
    -> [PerasIgnoranceRounds])
-> Enum PerasIgnoranceRounds
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasIgnoranceRounds -> PerasIgnoranceRounds
succ :: PerasIgnoranceRounds -> PerasIgnoranceRounds
$cpred :: PerasIgnoranceRounds -> PerasIgnoranceRounds
pred :: PerasIgnoranceRounds -> PerasIgnoranceRounds
$ctoEnum :: Int -> PerasIgnoranceRounds
toEnum :: Int -> PerasIgnoranceRounds
$cfromEnum :: PerasIgnoranceRounds -> Int
fromEnum :: PerasIgnoranceRounds -> Int
$cenumFrom :: PerasIgnoranceRounds -> [PerasIgnoranceRounds]
enumFrom :: PerasIgnoranceRounds -> [PerasIgnoranceRounds]
$cenumFromThen :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> [PerasIgnoranceRounds]
enumFromThen :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> [PerasIgnoranceRounds]
$cenumFromTo :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> [PerasIgnoranceRounds]
enumFromTo :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> [PerasIgnoranceRounds]
$cenumFromThenTo :: PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> [PerasIgnoranceRounds]
enumFromThenTo :: PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> PerasIgnoranceRounds
-> [PerasIgnoranceRounds]
Enum, PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
(PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> Eq PerasIgnoranceRounds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
== :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
$c/= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
/= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
Eq, Eq PerasIgnoranceRounds
Eq PerasIgnoranceRounds =>
(PerasIgnoranceRounds -> PerasIgnoranceRounds -> Ordering)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> (PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool)
-> (PerasIgnoranceRounds
    -> PerasIgnoranceRounds -> PerasIgnoranceRounds)
-> (PerasIgnoranceRounds
    -> PerasIgnoranceRounds -> PerasIgnoranceRounds)
-> Ord PerasIgnoranceRounds
PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
PerasIgnoranceRounds -> PerasIgnoranceRounds -> Ordering
PerasIgnoranceRounds
-> PerasIgnoranceRounds -> PerasIgnoranceRounds
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
$ccompare :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Ordering
compare :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Ordering
$c< :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
< :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
$c<= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
<= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
$c> :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
> :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
$c>= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
>= :: PerasIgnoranceRounds -> PerasIgnoranceRounds -> Bool
$cmax :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> PerasIgnoranceRounds
max :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> PerasIgnoranceRounds
$cmin :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> PerasIgnoranceRounds
min :: PerasIgnoranceRounds
-> PerasIgnoranceRounds -> PerasIgnoranceRounds
Ord, Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo)
Proxy PerasIgnoranceRounds -> String
(Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo))
-> (Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo))
-> (Proxy PerasIgnoranceRounds -> String)
-> NoThunks PerasIgnoranceRounds
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasIgnoranceRounds -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasIgnoranceRounds -> String
showTypeOf :: Proxy PerasIgnoranceRounds -> String
NoThunks, PerasIgnoranceRounds -> String
(PerasIgnoranceRounds -> String) -> Condense PerasIgnoranceRounds
forall a. (a -> String) -> Condense a
$ccondense :: PerasIgnoranceRounds -> String
condense :: PerasIgnoranceRounds -> String
Condense, Typeable PerasIgnoranceRounds
Typeable PerasIgnoranceRounds =>
(forall s. Decoder s PerasIgnoranceRounds)
-> (Proxy PerasIgnoranceRounds -> Text)
-> FromCBOR PerasIgnoranceRounds
Proxy PerasIgnoranceRounds -> Text
forall s. Decoder s PerasIgnoranceRounds
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasIgnoranceRounds
fromCBOR :: forall s. Decoder s PerasIgnoranceRounds
$clabel :: Proxy PerasIgnoranceRounds -> Text
label :: Proxy PerasIgnoranceRounds -> Text
FromCBOR, Typeable PerasIgnoranceRounds
Typeable PerasIgnoranceRounds =>
(PerasIgnoranceRounds -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasIgnoranceRounds -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasIgnoranceRounds] -> Size)
-> ToCBOR PerasIgnoranceRounds
PerasIgnoranceRounds -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasIgnoranceRounds] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasIgnoranceRounds -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasIgnoranceRounds -> Encoding
toCBOR :: PerasIgnoranceRounds -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasIgnoranceRounds -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasIgnoranceRounds -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasIgnoranceRounds] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasIgnoranceRounds] -> Size
ToCBOR)

-- | Minimum number of rounds to wait before voting again after a cooldown
-- period starts.
newtype PerasCooldownRounds
  = PerasCooldownRounds {PerasCooldownRounds -> Word64
unPerasCooldownRounds :: Word64}
  deriving Int -> PerasCooldownRounds -> ShowS
[PerasCooldownRounds] -> ShowS
PerasCooldownRounds -> String
(Int -> PerasCooldownRounds -> ShowS)
-> (PerasCooldownRounds -> String)
-> ([PerasCooldownRounds] -> ShowS)
-> Show PerasCooldownRounds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasCooldownRounds -> ShowS
showsPrec :: Int -> PerasCooldownRounds -> ShowS
$cshow :: PerasCooldownRounds -> String
show :: PerasCooldownRounds -> String
$cshowList :: [PerasCooldownRounds] -> ShowS
showList :: [PerasCooldownRounds] -> ShowS
Show via Quiet PerasCooldownRounds
  deriving stock (forall x. PerasCooldownRounds -> Rep PerasCooldownRounds x)
-> (forall x. Rep PerasCooldownRounds x -> PerasCooldownRounds)
-> Generic PerasCooldownRounds
forall x. Rep PerasCooldownRounds x -> PerasCooldownRounds
forall x. PerasCooldownRounds -> Rep PerasCooldownRounds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasCooldownRounds -> Rep PerasCooldownRounds x
from :: forall x. PerasCooldownRounds -> Rep PerasCooldownRounds x
$cto :: forall x. Rep PerasCooldownRounds x -> PerasCooldownRounds
to :: forall x. Rep PerasCooldownRounds x -> PerasCooldownRounds
Generic
  deriving newtype (Int -> PerasCooldownRounds
PerasCooldownRounds -> Int
PerasCooldownRounds -> [PerasCooldownRounds]
PerasCooldownRounds -> PerasCooldownRounds
PerasCooldownRounds -> PerasCooldownRounds -> [PerasCooldownRounds]
PerasCooldownRounds
-> PerasCooldownRounds
-> PerasCooldownRounds
-> [PerasCooldownRounds]
(PerasCooldownRounds -> PerasCooldownRounds)
-> (PerasCooldownRounds -> PerasCooldownRounds)
-> (Int -> PerasCooldownRounds)
-> (PerasCooldownRounds -> Int)
-> (PerasCooldownRounds -> [PerasCooldownRounds])
-> (PerasCooldownRounds
    -> PerasCooldownRounds -> [PerasCooldownRounds])
-> (PerasCooldownRounds
    -> PerasCooldownRounds -> [PerasCooldownRounds])
-> (PerasCooldownRounds
    -> PerasCooldownRounds
    -> PerasCooldownRounds
    -> [PerasCooldownRounds])
-> Enum PerasCooldownRounds
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasCooldownRounds -> PerasCooldownRounds
succ :: PerasCooldownRounds -> PerasCooldownRounds
$cpred :: PerasCooldownRounds -> PerasCooldownRounds
pred :: PerasCooldownRounds -> PerasCooldownRounds
$ctoEnum :: Int -> PerasCooldownRounds
toEnum :: Int -> PerasCooldownRounds
$cfromEnum :: PerasCooldownRounds -> Int
fromEnum :: PerasCooldownRounds -> Int
$cenumFrom :: PerasCooldownRounds -> [PerasCooldownRounds]
enumFrom :: PerasCooldownRounds -> [PerasCooldownRounds]
$cenumFromThen :: PerasCooldownRounds -> PerasCooldownRounds -> [PerasCooldownRounds]
enumFromThen :: PerasCooldownRounds -> PerasCooldownRounds -> [PerasCooldownRounds]
$cenumFromTo :: PerasCooldownRounds -> PerasCooldownRounds -> [PerasCooldownRounds]
enumFromTo :: PerasCooldownRounds -> PerasCooldownRounds -> [PerasCooldownRounds]
$cenumFromThenTo :: PerasCooldownRounds
-> PerasCooldownRounds
-> PerasCooldownRounds
-> [PerasCooldownRounds]
enumFromThenTo :: PerasCooldownRounds
-> PerasCooldownRounds
-> PerasCooldownRounds
-> [PerasCooldownRounds]
Enum, PerasCooldownRounds -> PerasCooldownRounds -> Bool
(PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> (PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> Eq PerasCooldownRounds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
== :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
$c/= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
/= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
Eq, Eq PerasCooldownRounds
Eq PerasCooldownRounds =>
(PerasCooldownRounds -> PerasCooldownRounds -> Ordering)
-> (PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> (PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> (PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> (PerasCooldownRounds -> PerasCooldownRounds -> Bool)
-> (PerasCooldownRounds
    -> PerasCooldownRounds -> PerasCooldownRounds)
-> (PerasCooldownRounds
    -> PerasCooldownRounds -> PerasCooldownRounds)
-> Ord PerasCooldownRounds
PerasCooldownRounds -> PerasCooldownRounds -> Bool
PerasCooldownRounds -> PerasCooldownRounds -> Ordering
PerasCooldownRounds -> PerasCooldownRounds -> PerasCooldownRounds
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
$ccompare :: PerasCooldownRounds -> PerasCooldownRounds -> Ordering
compare :: PerasCooldownRounds -> PerasCooldownRounds -> Ordering
$c< :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
< :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
$c<= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
<= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
$c> :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
> :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
$c>= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
>= :: PerasCooldownRounds -> PerasCooldownRounds -> Bool
$cmax :: PerasCooldownRounds -> PerasCooldownRounds -> PerasCooldownRounds
max :: PerasCooldownRounds -> PerasCooldownRounds -> PerasCooldownRounds
$cmin :: PerasCooldownRounds -> PerasCooldownRounds -> PerasCooldownRounds
min :: PerasCooldownRounds -> PerasCooldownRounds -> PerasCooldownRounds
Ord, Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo)
Proxy PerasCooldownRounds -> String
(Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo))
-> (Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo))
-> (Proxy PerasCooldownRounds -> String)
-> NoThunks PerasCooldownRounds
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasCooldownRounds -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasCooldownRounds -> String
showTypeOf :: Proxy PerasCooldownRounds -> String
NoThunks, PerasCooldownRounds -> String
(PerasCooldownRounds -> String) -> Condense PerasCooldownRounds
forall a. (a -> String) -> Condense a
$ccondense :: PerasCooldownRounds -> String
condense :: PerasCooldownRounds -> String
Condense, Typeable PerasCooldownRounds
Typeable PerasCooldownRounds =>
(forall s. Decoder s PerasCooldownRounds)
-> (Proxy PerasCooldownRounds -> Text)
-> FromCBOR PerasCooldownRounds
Proxy PerasCooldownRounds -> Text
forall s. Decoder s PerasCooldownRounds
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasCooldownRounds
fromCBOR :: forall s. Decoder s PerasCooldownRounds
$clabel :: Proxy PerasCooldownRounds -> Text
label :: Proxy PerasCooldownRounds -> Text
FromCBOR, Typeable PerasCooldownRounds
Typeable PerasCooldownRounds =>
(PerasCooldownRounds -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasCooldownRounds -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasCooldownRounds] -> Size)
-> ToCBOR PerasCooldownRounds
PerasCooldownRounds -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCooldownRounds] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCooldownRounds -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasCooldownRounds -> Encoding
toCBOR :: PerasCooldownRounds -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCooldownRounds -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCooldownRounds -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCooldownRounds] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCooldownRounds] -> Size
ToCBOR)

-- | Minimum age in slots of a block before it can be voted for in order to get
-- a boost.
newtype PerasBlockMinSlots
  = PerasBlockMinSlots {PerasBlockMinSlots -> Word64
unPerasBlockMinSlots :: Word64}
  deriving Int -> PerasBlockMinSlots -> ShowS
[PerasBlockMinSlots] -> ShowS
PerasBlockMinSlots -> String
(Int -> PerasBlockMinSlots -> ShowS)
-> (PerasBlockMinSlots -> String)
-> ([PerasBlockMinSlots] -> ShowS)
-> Show PerasBlockMinSlots
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasBlockMinSlots -> ShowS
showsPrec :: Int -> PerasBlockMinSlots -> ShowS
$cshow :: PerasBlockMinSlots -> String
show :: PerasBlockMinSlots -> String
$cshowList :: [PerasBlockMinSlots] -> ShowS
showList :: [PerasBlockMinSlots] -> ShowS
Show via Quiet PerasBlockMinSlots
  deriving stock (forall x. PerasBlockMinSlots -> Rep PerasBlockMinSlots x)
-> (forall x. Rep PerasBlockMinSlots x -> PerasBlockMinSlots)
-> Generic PerasBlockMinSlots
forall x. Rep PerasBlockMinSlots x -> PerasBlockMinSlots
forall x. PerasBlockMinSlots -> Rep PerasBlockMinSlots x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasBlockMinSlots -> Rep PerasBlockMinSlots x
from :: forall x. PerasBlockMinSlots -> Rep PerasBlockMinSlots x
$cto :: forall x. Rep PerasBlockMinSlots x -> PerasBlockMinSlots
to :: forall x. Rep PerasBlockMinSlots x -> PerasBlockMinSlots
Generic
  deriving newtype (Int -> PerasBlockMinSlots
PerasBlockMinSlots -> Int
PerasBlockMinSlots -> [PerasBlockMinSlots]
PerasBlockMinSlots -> PerasBlockMinSlots
PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
PerasBlockMinSlots
-> PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
(PerasBlockMinSlots -> PerasBlockMinSlots)
-> (PerasBlockMinSlots -> PerasBlockMinSlots)
-> (Int -> PerasBlockMinSlots)
-> (PerasBlockMinSlots -> Int)
-> (PerasBlockMinSlots -> [PerasBlockMinSlots])
-> (PerasBlockMinSlots
    -> PerasBlockMinSlots -> [PerasBlockMinSlots])
-> (PerasBlockMinSlots
    -> PerasBlockMinSlots -> [PerasBlockMinSlots])
-> (PerasBlockMinSlots
    -> PerasBlockMinSlots
    -> PerasBlockMinSlots
    -> [PerasBlockMinSlots])
-> Enum PerasBlockMinSlots
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasBlockMinSlots -> PerasBlockMinSlots
succ :: PerasBlockMinSlots -> PerasBlockMinSlots
$cpred :: PerasBlockMinSlots -> PerasBlockMinSlots
pred :: PerasBlockMinSlots -> PerasBlockMinSlots
$ctoEnum :: Int -> PerasBlockMinSlots
toEnum :: Int -> PerasBlockMinSlots
$cfromEnum :: PerasBlockMinSlots -> Int
fromEnum :: PerasBlockMinSlots -> Int
$cenumFrom :: PerasBlockMinSlots -> [PerasBlockMinSlots]
enumFrom :: PerasBlockMinSlots -> [PerasBlockMinSlots]
$cenumFromThen :: PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
enumFromThen :: PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
$cenumFromTo :: PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
enumFromTo :: PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
$cenumFromThenTo :: PerasBlockMinSlots
-> PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
enumFromThenTo :: PerasBlockMinSlots
-> PerasBlockMinSlots -> PerasBlockMinSlots -> [PerasBlockMinSlots]
Enum, PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
(PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> Eq PerasBlockMinSlots
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
== :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
$c/= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
/= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
Eq, Eq PerasBlockMinSlots
Eq PerasBlockMinSlots =>
(PerasBlockMinSlots -> PerasBlockMinSlots -> Ordering)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> Bool)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots)
-> (PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots)
-> Ord PerasBlockMinSlots
PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
PerasBlockMinSlots -> PerasBlockMinSlots -> Ordering
PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots
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
$ccompare :: PerasBlockMinSlots -> PerasBlockMinSlots -> Ordering
compare :: PerasBlockMinSlots -> PerasBlockMinSlots -> Ordering
$c< :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
< :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
$c<= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
<= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
$c> :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
> :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
$c>= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
>= :: PerasBlockMinSlots -> PerasBlockMinSlots -> Bool
$cmax :: PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots
max :: PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots
$cmin :: PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots
min :: PerasBlockMinSlots -> PerasBlockMinSlots -> PerasBlockMinSlots
Ord, Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo)
Proxy PerasBlockMinSlots -> String
(Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo))
-> (Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo))
-> (Proxy PerasBlockMinSlots -> String)
-> NoThunks PerasBlockMinSlots
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasBlockMinSlots -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasBlockMinSlots -> String
showTypeOf :: Proxy PerasBlockMinSlots -> String
NoThunks, PerasBlockMinSlots -> String
(PerasBlockMinSlots -> String) -> Condense PerasBlockMinSlots
forall a. (a -> String) -> Condense a
$ccondense :: PerasBlockMinSlots -> String
condense :: PerasBlockMinSlots -> String
Condense, Typeable PerasBlockMinSlots
Typeable PerasBlockMinSlots =>
(forall s. Decoder s PerasBlockMinSlots)
-> (Proxy PerasBlockMinSlots -> Text)
-> FromCBOR PerasBlockMinSlots
Proxy PerasBlockMinSlots -> Text
forall s. Decoder s PerasBlockMinSlots
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasBlockMinSlots
fromCBOR :: forall s. Decoder s PerasBlockMinSlots
$clabel :: Proxy PerasBlockMinSlots -> Text
label :: Proxy PerasBlockMinSlots -> Text
FromCBOR, Typeable PerasBlockMinSlots
Typeable PerasBlockMinSlots =>
(PerasBlockMinSlots -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasBlockMinSlots -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasBlockMinSlots] -> Size)
-> ToCBOR PerasBlockMinSlots
PerasBlockMinSlots -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasBlockMinSlots] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasBlockMinSlots -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasBlockMinSlots -> Encoding
toCBOR :: PerasBlockMinSlots -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasBlockMinSlots -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasBlockMinSlots -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasBlockMinSlots] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasBlockMinSlots] -> Size
ToCBOR)

-- | Maximum age for a certificate to be included in a block, in rounds.
newtype PerasCertMaxRounds
  = PerasCertMaxRounds {PerasCertMaxRounds -> Word64
unPerasCertMaxRounds :: Word64}
  deriving Int -> PerasCertMaxRounds -> ShowS
[PerasCertMaxRounds] -> ShowS
PerasCertMaxRounds -> String
(Int -> PerasCertMaxRounds -> ShowS)
-> (PerasCertMaxRounds -> String)
-> ([PerasCertMaxRounds] -> ShowS)
-> Show PerasCertMaxRounds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasCertMaxRounds -> ShowS
showsPrec :: Int -> PerasCertMaxRounds -> ShowS
$cshow :: PerasCertMaxRounds -> String
show :: PerasCertMaxRounds -> String
$cshowList :: [PerasCertMaxRounds] -> ShowS
showList :: [PerasCertMaxRounds] -> ShowS
Show via Quiet PerasCertMaxRounds
  deriving stock (forall x. PerasCertMaxRounds -> Rep PerasCertMaxRounds x)
-> (forall x. Rep PerasCertMaxRounds x -> PerasCertMaxRounds)
-> Generic PerasCertMaxRounds
forall x. Rep PerasCertMaxRounds x -> PerasCertMaxRounds
forall x. PerasCertMaxRounds -> Rep PerasCertMaxRounds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasCertMaxRounds -> Rep PerasCertMaxRounds x
from :: forall x. PerasCertMaxRounds -> Rep PerasCertMaxRounds x
$cto :: forall x. Rep PerasCertMaxRounds x -> PerasCertMaxRounds
to :: forall x. Rep PerasCertMaxRounds x -> PerasCertMaxRounds
Generic
  deriving newtype (Int -> PerasCertMaxRounds
PerasCertMaxRounds -> Int
PerasCertMaxRounds -> [PerasCertMaxRounds]
PerasCertMaxRounds -> PerasCertMaxRounds
PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
PerasCertMaxRounds
-> PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
(PerasCertMaxRounds -> PerasCertMaxRounds)
-> (PerasCertMaxRounds -> PerasCertMaxRounds)
-> (Int -> PerasCertMaxRounds)
-> (PerasCertMaxRounds -> Int)
-> (PerasCertMaxRounds -> [PerasCertMaxRounds])
-> (PerasCertMaxRounds
    -> PerasCertMaxRounds -> [PerasCertMaxRounds])
-> (PerasCertMaxRounds
    -> PerasCertMaxRounds -> [PerasCertMaxRounds])
-> (PerasCertMaxRounds
    -> PerasCertMaxRounds
    -> PerasCertMaxRounds
    -> [PerasCertMaxRounds])
-> Enum PerasCertMaxRounds
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasCertMaxRounds -> PerasCertMaxRounds
succ :: PerasCertMaxRounds -> PerasCertMaxRounds
$cpred :: PerasCertMaxRounds -> PerasCertMaxRounds
pred :: PerasCertMaxRounds -> PerasCertMaxRounds
$ctoEnum :: Int -> PerasCertMaxRounds
toEnum :: Int -> PerasCertMaxRounds
$cfromEnum :: PerasCertMaxRounds -> Int
fromEnum :: PerasCertMaxRounds -> Int
$cenumFrom :: PerasCertMaxRounds -> [PerasCertMaxRounds]
enumFrom :: PerasCertMaxRounds -> [PerasCertMaxRounds]
$cenumFromThen :: PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
enumFromThen :: PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
$cenumFromTo :: PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
enumFromTo :: PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
$cenumFromThenTo :: PerasCertMaxRounds
-> PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
enumFromThenTo :: PerasCertMaxRounds
-> PerasCertMaxRounds -> PerasCertMaxRounds -> [PerasCertMaxRounds]
Enum, PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
(PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> Eq PerasCertMaxRounds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
== :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
$c/= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
/= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
Eq, Eq PerasCertMaxRounds
Eq PerasCertMaxRounds =>
(PerasCertMaxRounds -> PerasCertMaxRounds -> Ordering)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> Bool)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds)
-> (PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds)
-> Ord PerasCertMaxRounds
PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
PerasCertMaxRounds -> PerasCertMaxRounds -> Ordering
PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds
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
$ccompare :: PerasCertMaxRounds -> PerasCertMaxRounds -> Ordering
compare :: PerasCertMaxRounds -> PerasCertMaxRounds -> Ordering
$c< :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
< :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
$c<= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
<= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
$c> :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
> :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
$c>= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
>= :: PerasCertMaxRounds -> PerasCertMaxRounds -> Bool
$cmax :: PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds
max :: PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds
$cmin :: PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds
min :: PerasCertMaxRounds -> PerasCertMaxRounds -> PerasCertMaxRounds
Ord, Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo)
Proxy PerasCertMaxRounds -> String
(Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo))
-> (Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo))
-> (Proxy PerasCertMaxRounds -> String)
-> NoThunks PerasCertMaxRounds
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasCertMaxRounds -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasCertMaxRounds -> String
showTypeOf :: Proxy PerasCertMaxRounds -> String
NoThunks, PerasCertMaxRounds -> String
(PerasCertMaxRounds -> String) -> Condense PerasCertMaxRounds
forall a. (a -> String) -> Condense a
$ccondense :: PerasCertMaxRounds -> String
condense :: PerasCertMaxRounds -> String
Condense, Typeable PerasCertMaxRounds
Typeable PerasCertMaxRounds =>
(forall s. Decoder s PerasCertMaxRounds)
-> (Proxy PerasCertMaxRounds -> Text)
-> FromCBOR PerasCertMaxRounds
Proxy PerasCertMaxRounds -> Text
forall s. Decoder s PerasCertMaxRounds
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasCertMaxRounds
fromCBOR :: forall s. Decoder s PerasCertMaxRounds
$clabel :: Proxy PerasCertMaxRounds -> Text
label :: Proxy PerasCertMaxRounds -> Text
FromCBOR, Typeable PerasCertMaxRounds
Typeable PerasCertMaxRounds =>
(PerasCertMaxRounds -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasCertMaxRounds -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasCertMaxRounds] -> Size)
-> ToCBOR PerasCertMaxRounds
PerasCertMaxRounds -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertMaxRounds] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertMaxRounds -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasCertMaxRounds -> Encoding
toCBOR :: PerasCertMaxRounds -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertMaxRounds -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertMaxRounds -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertMaxRounds] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertMaxRounds] -> Size
ToCBOR)

-- | Maximum number of slots to wait for after the start of a round to consider
-- a certificate valid for voting.
newtype PerasCertArrivalThreshold
  = PerasCertArrivalThreshold {PerasCertArrivalThreshold -> Word64
unPerasCertArrivalThreshold :: Word64}
  deriving Int -> PerasCertArrivalThreshold -> ShowS
[PerasCertArrivalThreshold] -> ShowS
PerasCertArrivalThreshold -> String
(Int -> PerasCertArrivalThreshold -> ShowS)
-> (PerasCertArrivalThreshold -> String)
-> ([PerasCertArrivalThreshold] -> ShowS)
-> Show PerasCertArrivalThreshold
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasCertArrivalThreshold -> ShowS
showsPrec :: Int -> PerasCertArrivalThreshold -> ShowS
$cshow :: PerasCertArrivalThreshold -> String
show :: PerasCertArrivalThreshold -> String
$cshowList :: [PerasCertArrivalThreshold] -> ShowS
showList :: [PerasCertArrivalThreshold] -> ShowS
Show via Quiet PerasCertArrivalThreshold
  deriving stock (forall x.
 PerasCertArrivalThreshold -> Rep PerasCertArrivalThreshold x)
-> (forall x.
    Rep PerasCertArrivalThreshold x -> PerasCertArrivalThreshold)
-> Generic PerasCertArrivalThreshold
forall x.
Rep PerasCertArrivalThreshold x -> PerasCertArrivalThreshold
forall x.
PerasCertArrivalThreshold -> Rep PerasCertArrivalThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
PerasCertArrivalThreshold -> Rep PerasCertArrivalThreshold x
from :: forall x.
PerasCertArrivalThreshold -> Rep PerasCertArrivalThreshold x
$cto :: forall x.
Rep PerasCertArrivalThreshold x -> PerasCertArrivalThreshold
to :: forall x.
Rep PerasCertArrivalThreshold x -> PerasCertArrivalThreshold
Generic
  deriving newtype (Int -> PerasCertArrivalThreshold
PerasCertArrivalThreshold -> Int
PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
PerasCertArrivalThreshold -> PerasCertArrivalThreshold
PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> [PerasCertArrivalThreshold]
(PerasCertArrivalThreshold -> PerasCertArrivalThreshold)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold)
-> (Int -> PerasCertArrivalThreshold)
-> (PerasCertArrivalThreshold -> Int)
-> (PerasCertArrivalThreshold -> [PerasCertArrivalThreshold])
-> (PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold])
-> (PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold])
-> (PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold
    -> [PerasCertArrivalThreshold])
-> Enum PerasCertArrivalThreshold
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold
succ :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold
$cpred :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold
pred :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold
$ctoEnum :: Int -> PerasCertArrivalThreshold
toEnum :: Int -> PerasCertArrivalThreshold
$cfromEnum :: PerasCertArrivalThreshold -> Int
fromEnum :: PerasCertArrivalThreshold -> Int
$cenumFrom :: PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
enumFrom :: PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
$cenumFromThen :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
enumFromThen :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
$cenumFromTo :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
enumFromTo :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> [PerasCertArrivalThreshold]
$cenumFromThenTo :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> [PerasCertArrivalThreshold]
enumFromThenTo :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> PerasCertArrivalThreshold
-> [PerasCertArrivalThreshold]
Enum, PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
(PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> Eq PerasCertArrivalThreshold
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
== :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
$c/= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
/= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
Eq, Eq PerasCertArrivalThreshold
Eq PerasCertArrivalThreshold =>
(PerasCertArrivalThreshold
 -> PerasCertArrivalThreshold -> Ordering)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> (PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool)
-> (PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold -> PerasCertArrivalThreshold)
-> (PerasCertArrivalThreshold
    -> PerasCertArrivalThreshold -> PerasCertArrivalThreshold)
-> Ord PerasCertArrivalThreshold
PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Ordering
PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> PerasCertArrivalThreshold
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
$ccompare :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Ordering
compare :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Ordering
$c< :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
< :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
$c<= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
<= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
$c> :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
> :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
$c>= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
>= :: PerasCertArrivalThreshold -> PerasCertArrivalThreshold -> Bool
$cmax :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> PerasCertArrivalThreshold
max :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> PerasCertArrivalThreshold
$cmin :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> PerasCertArrivalThreshold
min :: PerasCertArrivalThreshold
-> PerasCertArrivalThreshold -> PerasCertArrivalThreshold
Ord, Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo)
Proxy PerasCertArrivalThreshold -> String
(Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo))
-> (Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo))
-> (Proxy PerasCertArrivalThreshold -> String)
-> NoThunks PerasCertArrivalThreshold
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasCertArrivalThreshold -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasCertArrivalThreshold -> String
showTypeOf :: Proxy PerasCertArrivalThreshold -> String
NoThunks, PerasCertArrivalThreshold -> String
(PerasCertArrivalThreshold -> String)
-> Condense PerasCertArrivalThreshold
forall a. (a -> String) -> Condense a
$ccondense :: PerasCertArrivalThreshold -> String
condense :: PerasCertArrivalThreshold -> String
Condense, Typeable PerasCertArrivalThreshold
Typeable PerasCertArrivalThreshold =>
(forall s. Decoder s PerasCertArrivalThreshold)
-> (Proxy PerasCertArrivalThreshold -> Text)
-> FromCBOR PerasCertArrivalThreshold
Proxy PerasCertArrivalThreshold -> Text
forall s. Decoder s PerasCertArrivalThreshold
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasCertArrivalThreshold
fromCBOR :: forall s. Decoder s PerasCertArrivalThreshold
$clabel :: Proxy PerasCertArrivalThreshold -> Text
label :: Proxy PerasCertArrivalThreshold -> Text
FromCBOR, Typeable PerasCertArrivalThreshold
Typeable PerasCertArrivalThreshold =>
(PerasCertArrivalThreshold -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasCertArrivalThreshold -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasCertArrivalThreshold] -> Size)
-> ToCBOR PerasCertArrivalThreshold
PerasCertArrivalThreshold -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertArrivalThreshold] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertArrivalThreshold -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasCertArrivalThreshold -> Encoding
toCBOR :: PerasCertArrivalThreshold -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertArrivalThreshold -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasCertArrivalThreshold -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertArrivalThreshold] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasCertArrivalThreshold] -> Size
ToCBOR)

-- | Length of a Peras round in slots.
newtype PerasRoundLength
  = PerasRoundLength {PerasRoundLength -> Word64
unPerasRoundLength :: Word64}
  deriving Int -> PerasRoundLength -> ShowS
[PerasRoundLength] -> ShowS
PerasRoundLength -> String
(Int -> PerasRoundLength -> ShowS)
-> (PerasRoundLength -> String)
-> ([PerasRoundLength] -> ShowS)
-> Show PerasRoundLength
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasRoundLength -> ShowS
showsPrec :: Int -> PerasRoundLength -> ShowS
$cshow :: PerasRoundLength -> String
show :: PerasRoundLength -> String
$cshowList :: [PerasRoundLength] -> ShowS
showList :: [PerasRoundLength] -> ShowS
Show via Quiet PerasRoundLength
  deriving stock (forall x. PerasRoundLength -> Rep PerasRoundLength x)
-> (forall x. Rep PerasRoundLength x -> PerasRoundLength)
-> Generic PerasRoundLength
forall x. Rep PerasRoundLength x -> PerasRoundLength
forall x. PerasRoundLength -> Rep PerasRoundLength x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasRoundLength -> Rep PerasRoundLength x
from :: forall x. PerasRoundLength -> Rep PerasRoundLength x
$cto :: forall x. Rep PerasRoundLength x -> PerasRoundLength
to :: forall x. Rep PerasRoundLength x -> PerasRoundLength
Generic
  deriving newtype (Int -> PerasRoundLength
PerasRoundLength -> Int
PerasRoundLength -> [PerasRoundLength]
PerasRoundLength -> PerasRoundLength
PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
PerasRoundLength
-> PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
(PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength)
-> (Int -> PerasRoundLength)
-> (PerasRoundLength -> Int)
-> (PerasRoundLength -> [PerasRoundLength])
-> (PerasRoundLength -> PerasRoundLength -> [PerasRoundLength])
-> (PerasRoundLength -> PerasRoundLength -> [PerasRoundLength])
-> (PerasRoundLength
    -> PerasRoundLength -> PerasRoundLength -> [PerasRoundLength])
-> Enum PerasRoundLength
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasRoundLength -> PerasRoundLength
succ :: PerasRoundLength -> PerasRoundLength
$cpred :: PerasRoundLength -> PerasRoundLength
pred :: PerasRoundLength -> PerasRoundLength
$ctoEnum :: Int -> PerasRoundLength
toEnum :: Int -> PerasRoundLength
$cfromEnum :: PerasRoundLength -> Int
fromEnum :: PerasRoundLength -> Int
$cenumFrom :: PerasRoundLength -> [PerasRoundLength]
enumFrom :: PerasRoundLength -> [PerasRoundLength]
$cenumFromThen :: PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
enumFromThen :: PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
$cenumFromTo :: PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
enumFromTo :: PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
$cenumFromThenTo :: PerasRoundLength
-> PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
enumFromThenTo :: PerasRoundLength
-> PerasRoundLength -> PerasRoundLength -> [PerasRoundLength]
Enum, PerasRoundLength -> PerasRoundLength -> Bool
(PerasRoundLength -> PerasRoundLength -> Bool)
-> (PerasRoundLength -> PerasRoundLength -> Bool)
-> Eq PerasRoundLength
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasRoundLength -> PerasRoundLength -> Bool
== :: PerasRoundLength -> PerasRoundLength -> Bool
$c/= :: PerasRoundLength -> PerasRoundLength -> Bool
/= :: PerasRoundLength -> PerasRoundLength -> Bool
Eq, Eq PerasRoundLength
Eq PerasRoundLength =>
(PerasRoundLength -> PerasRoundLength -> Ordering)
-> (PerasRoundLength -> PerasRoundLength -> Bool)
-> (PerasRoundLength -> PerasRoundLength -> Bool)
-> (PerasRoundLength -> PerasRoundLength -> Bool)
-> (PerasRoundLength -> PerasRoundLength -> Bool)
-> (PerasRoundLength -> PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength -> PerasRoundLength)
-> Ord PerasRoundLength
PerasRoundLength -> PerasRoundLength -> Bool
PerasRoundLength -> PerasRoundLength -> Ordering
PerasRoundLength -> PerasRoundLength -> PerasRoundLength
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
$ccompare :: PerasRoundLength -> PerasRoundLength -> Ordering
compare :: PerasRoundLength -> PerasRoundLength -> Ordering
$c< :: PerasRoundLength -> PerasRoundLength -> Bool
< :: PerasRoundLength -> PerasRoundLength -> Bool
$c<= :: PerasRoundLength -> PerasRoundLength -> Bool
<= :: PerasRoundLength -> PerasRoundLength -> Bool
$c> :: PerasRoundLength -> PerasRoundLength -> Bool
> :: PerasRoundLength -> PerasRoundLength -> Bool
$c>= :: PerasRoundLength -> PerasRoundLength -> Bool
>= :: PerasRoundLength -> PerasRoundLength -> Bool
$cmax :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
max :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
$cmin :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
min :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
Ord, Context -> PerasRoundLength -> IO (Maybe ThunkInfo)
Proxy PerasRoundLength -> String
(Context -> PerasRoundLength -> IO (Maybe ThunkInfo))
-> (Context -> PerasRoundLength -> IO (Maybe ThunkInfo))
-> (Proxy PerasRoundLength -> String)
-> NoThunks PerasRoundLength
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasRoundLength -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasRoundLength -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasRoundLength -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasRoundLength -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasRoundLength -> String
showTypeOf :: Proxy PerasRoundLength -> String
NoThunks, PerasRoundLength -> String
(PerasRoundLength -> String) -> Condense PerasRoundLength
forall a. (a -> String) -> Condense a
$ccondense :: PerasRoundLength -> String
condense :: PerasRoundLength -> String
Condense, Typeable PerasRoundLength
Typeable PerasRoundLength =>
(forall s. Decoder s PerasRoundLength)
-> (Proxy PerasRoundLength -> Text) -> FromCBOR PerasRoundLength
Proxy PerasRoundLength -> Text
forall s. Decoder s PerasRoundLength
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasRoundLength
fromCBOR :: forall s. Decoder s PerasRoundLength
$clabel :: Proxy PerasRoundLength -> Text
label :: Proxy PerasRoundLength -> Text
FromCBOR, Typeable PerasRoundLength
Typeable PerasRoundLength =>
(PerasRoundLength -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasRoundLength -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasRoundLength] -> Size)
-> ToCBOR PerasRoundLength
PerasRoundLength -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasRoundLength] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasRoundLength -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasRoundLength -> Encoding
toCBOR :: PerasRoundLength -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasRoundLength -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasRoundLength -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasRoundLength] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasRoundLength] -> Size
ToCBOR)

-- | Weight assigned to a block when boosted by a Peras certificate.
newtype PerasWeight
  = PerasWeight {PerasWeight -> Word64
unPerasWeight :: Word64}
  deriving Int -> PerasWeight -> ShowS
[PerasWeight] -> ShowS
PerasWeight -> String
(Int -> PerasWeight -> ShowS)
-> (PerasWeight -> String)
-> ([PerasWeight] -> ShowS)
-> Show PerasWeight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasWeight -> ShowS
showsPrec :: Int -> PerasWeight -> ShowS
$cshow :: PerasWeight -> String
show :: PerasWeight -> String
$cshowList :: [PerasWeight] -> ShowS
showList :: [PerasWeight] -> ShowS
Show via Quiet PerasWeight
  deriving stock (forall x. PerasWeight -> Rep PerasWeight x)
-> (forall x. Rep PerasWeight x -> PerasWeight)
-> Generic PerasWeight
forall x. Rep PerasWeight x -> PerasWeight
forall x. PerasWeight -> Rep PerasWeight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasWeight -> Rep PerasWeight x
from :: forall x. PerasWeight -> Rep PerasWeight x
$cto :: forall x. Rep PerasWeight x -> PerasWeight
to :: forall x. Rep PerasWeight x -> PerasWeight
Generic
  deriving newtype (Int -> PerasWeight
PerasWeight -> Int
PerasWeight -> [PerasWeight]
PerasWeight -> PerasWeight
PerasWeight -> PerasWeight -> [PerasWeight]
PerasWeight -> PerasWeight -> PerasWeight -> [PerasWeight]
(PerasWeight -> PerasWeight)
-> (PerasWeight -> PerasWeight)
-> (Int -> PerasWeight)
-> (PerasWeight -> Int)
-> (PerasWeight -> [PerasWeight])
-> (PerasWeight -> PerasWeight -> [PerasWeight])
-> (PerasWeight -> PerasWeight -> [PerasWeight])
-> (PerasWeight -> PerasWeight -> PerasWeight -> [PerasWeight])
-> Enum PerasWeight
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasWeight -> PerasWeight
succ :: PerasWeight -> PerasWeight
$cpred :: PerasWeight -> PerasWeight
pred :: PerasWeight -> PerasWeight
$ctoEnum :: Int -> PerasWeight
toEnum :: Int -> PerasWeight
$cfromEnum :: PerasWeight -> Int
fromEnum :: PerasWeight -> Int
$cenumFrom :: PerasWeight -> [PerasWeight]
enumFrom :: PerasWeight -> [PerasWeight]
$cenumFromThen :: PerasWeight -> PerasWeight -> [PerasWeight]
enumFromThen :: PerasWeight -> PerasWeight -> [PerasWeight]
$cenumFromTo :: PerasWeight -> PerasWeight -> [PerasWeight]
enumFromTo :: PerasWeight -> PerasWeight -> [PerasWeight]
$cenumFromThenTo :: PerasWeight -> PerasWeight -> PerasWeight -> [PerasWeight]
enumFromThenTo :: PerasWeight -> PerasWeight -> PerasWeight -> [PerasWeight]
Enum, PerasWeight -> PerasWeight -> Bool
(PerasWeight -> PerasWeight -> Bool)
-> (PerasWeight -> PerasWeight -> Bool) -> Eq PerasWeight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasWeight -> PerasWeight -> Bool
== :: PerasWeight -> PerasWeight -> Bool
$c/= :: PerasWeight -> PerasWeight -> Bool
/= :: PerasWeight -> PerasWeight -> Bool
Eq, Eq PerasWeight
Eq PerasWeight =>
(PerasWeight -> PerasWeight -> Ordering)
-> (PerasWeight -> PerasWeight -> Bool)
-> (PerasWeight -> PerasWeight -> Bool)
-> (PerasWeight -> PerasWeight -> Bool)
-> (PerasWeight -> PerasWeight -> Bool)
-> (PerasWeight -> PerasWeight -> PerasWeight)
-> (PerasWeight -> PerasWeight -> PerasWeight)
-> Ord PerasWeight
PerasWeight -> PerasWeight -> Bool
PerasWeight -> PerasWeight -> Ordering
PerasWeight -> PerasWeight -> PerasWeight
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
$ccompare :: PerasWeight -> PerasWeight -> Ordering
compare :: PerasWeight -> PerasWeight -> Ordering
$c< :: PerasWeight -> PerasWeight -> Bool
< :: PerasWeight -> PerasWeight -> Bool
$c<= :: PerasWeight -> PerasWeight -> Bool
<= :: PerasWeight -> PerasWeight -> Bool
$c> :: PerasWeight -> PerasWeight -> Bool
> :: PerasWeight -> PerasWeight -> Bool
$c>= :: PerasWeight -> PerasWeight -> Bool
>= :: PerasWeight -> PerasWeight -> Bool
$cmax :: PerasWeight -> PerasWeight -> PerasWeight
max :: PerasWeight -> PerasWeight -> PerasWeight
$cmin :: PerasWeight -> PerasWeight -> PerasWeight
min :: PerasWeight -> PerasWeight -> PerasWeight
Ord, Context -> PerasWeight -> IO (Maybe ThunkInfo)
Proxy PerasWeight -> String
(Context -> PerasWeight -> IO (Maybe ThunkInfo))
-> (Context -> PerasWeight -> IO (Maybe ThunkInfo))
-> (Proxy PerasWeight -> String)
-> NoThunks PerasWeight
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasWeight -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasWeight -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasWeight -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasWeight -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasWeight -> String
showTypeOf :: Proxy PerasWeight -> String
NoThunks, PerasWeight -> String
(PerasWeight -> String) -> Condense PerasWeight
forall a. (a -> String) -> Condense a
$ccondense :: PerasWeight -> String
condense :: PerasWeight -> String
Condense, Typeable PerasWeight
Typeable PerasWeight =>
(forall s. Decoder s PerasWeight)
-> (Proxy PerasWeight -> Text) -> FromCBOR PerasWeight
Proxy PerasWeight -> Text
forall s. Decoder s PerasWeight
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasWeight
fromCBOR :: forall s. Decoder s PerasWeight
$clabel :: Proxy PerasWeight -> Text
label :: Proxy PerasWeight -> Text
FromCBOR, Typeable PerasWeight
Typeable PerasWeight =>
(PerasWeight -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasWeight -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasWeight] -> Size)
-> ToCBOR PerasWeight
PerasWeight -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasWeight] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasWeight -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasWeight -> Encoding
toCBOR :: PerasWeight -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasWeight -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasWeight -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasWeight] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasWeight] -> Size
ToCBOR)

deriving via Sum Word64 instance Semigroup PerasWeight
deriving via Sum Word64 instance Monoid PerasWeight

-- | Total vote weight needed to forge a Peras certificate.
newtype PerasQuorumWeightThreshold
  = PerasQuorumWeightThreshold {PerasQuorumWeightThreshold -> Rational
unPerasQuorumWeightThreshold :: Rational}
  deriving Int -> PerasQuorumWeightThreshold -> ShowS
[PerasQuorumWeightThreshold] -> ShowS
PerasQuorumWeightThreshold -> String
(Int -> PerasQuorumWeightThreshold -> ShowS)
-> (PerasQuorumWeightThreshold -> String)
-> ([PerasQuorumWeightThreshold] -> ShowS)
-> Show PerasQuorumWeightThreshold
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasQuorumWeightThreshold -> ShowS
showsPrec :: Int -> PerasQuorumWeightThreshold -> ShowS
$cshow :: PerasQuorumWeightThreshold -> String
show :: PerasQuorumWeightThreshold -> String
$cshowList :: [PerasQuorumWeightThreshold] -> ShowS
showList :: [PerasQuorumWeightThreshold] -> ShowS
Show via Quiet PerasQuorumWeightThreshold
  deriving stock (forall x.
 PerasQuorumWeightThreshold -> Rep PerasQuorumWeightThreshold x)
-> (forall x.
    Rep PerasQuorumWeightThreshold x -> PerasQuorumWeightThreshold)
-> Generic PerasQuorumWeightThreshold
forall x.
Rep PerasQuorumWeightThreshold x -> PerasQuorumWeightThreshold
forall x.
PerasQuorumWeightThreshold -> Rep PerasQuorumWeightThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
PerasQuorumWeightThreshold -> Rep PerasQuorumWeightThreshold x
from :: forall x.
PerasQuorumWeightThreshold -> Rep PerasQuorumWeightThreshold x
$cto :: forall x.
Rep PerasQuorumWeightThreshold x -> PerasQuorumWeightThreshold
to :: forall x.
Rep PerasQuorumWeightThreshold x -> PerasQuorumWeightThreshold
Generic
  deriving newtype (PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
(PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> Bool)
-> Eq PerasQuorumWeightThreshold
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
== :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
$c/= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
/= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
Eq, Eq PerasQuorumWeightThreshold
Eq PerasQuorumWeightThreshold =>
(PerasQuorumWeightThreshold
 -> PerasQuorumWeightThreshold -> Ordering)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> Bool)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> Bool)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> Bool)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> Bool)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold)
-> (PerasQuorumWeightThreshold
    -> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold)
-> Ord PerasQuorumWeightThreshold
PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> Ordering
PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold
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
$ccompare :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> Ordering
compare :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> Ordering
$c< :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
< :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
$c<= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
<= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
$c> :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
> :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
$c>= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
>= :: PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold -> Bool
$cmax :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold
max :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold
$cmin :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold
min :: PerasQuorumWeightThreshold
-> PerasQuorumWeightThreshold -> PerasQuorumWeightThreshold
Ord, Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo)
Proxy PerasQuorumWeightThreshold -> String
(Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo))
-> (Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo))
-> (Proxy PerasQuorumWeightThreshold -> String)
-> NoThunks PerasQuorumWeightThreshold
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasQuorumWeightThreshold -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasQuorumWeightThreshold -> String
showTypeOf :: Proxy PerasQuorumWeightThreshold -> String
NoThunks, PerasQuorumWeightThreshold -> String
(PerasQuorumWeightThreshold -> String)
-> Condense PerasQuorumWeightThreshold
forall a. (a -> String) -> Condense a
$ccondense :: PerasQuorumWeightThreshold -> String
condense :: PerasQuorumWeightThreshold -> String
Condense, Typeable PerasQuorumWeightThreshold
Typeable PerasQuorumWeightThreshold =>
(forall s. Decoder s PerasQuorumWeightThreshold)
-> (Proxy PerasQuorumWeightThreshold -> Text)
-> FromCBOR PerasQuorumWeightThreshold
Proxy PerasQuorumWeightThreshold -> Text
forall s. Decoder s PerasQuorumWeightThreshold
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasQuorumWeightThreshold
fromCBOR :: forall s. Decoder s PerasQuorumWeightThreshold
$clabel :: Proxy PerasQuorumWeightThreshold -> Text
label :: Proxy PerasQuorumWeightThreshold -> Text
FromCBOR, Typeable PerasQuorumWeightThreshold
Typeable PerasQuorumWeightThreshold =>
(PerasQuorumWeightThreshold -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasQuorumWeightThreshold -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasQuorumWeightThreshold] -> Size)
-> ToCBOR PerasQuorumWeightThreshold
PerasQuorumWeightThreshold -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThreshold] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThreshold -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasQuorumWeightThreshold -> Encoding
toCBOR :: PerasQuorumWeightThreshold -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThreshold -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThreshold -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThreshold] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThreshold] -> Size
ToCBOR)

-- | Safety margin needed on top of the quorum vote weight threshold.
--
-- NOTE: this is needed to account for an extremely unlikely local sortition
-- where not enough honest non-persistent parties decide to vote in a round.
-- This mostly depend on the expected size of the voting committee.
newtype PerasQuorumWeightThresholdSafetyMargin
  = PerasQuorumWeightThresholdSafetyMargin {PerasQuorumWeightThresholdSafetyMargin -> Rational
unPerasQuorumWeightThresholdSafetyMargin :: Rational}
  deriving Int -> PerasQuorumWeightThresholdSafetyMargin -> ShowS
[PerasQuorumWeightThresholdSafetyMargin] -> ShowS
PerasQuorumWeightThresholdSafetyMargin -> String
(Int -> PerasQuorumWeightThresholdSafetyMargin -> ShowS)
-> (PerasQuorumWeightThresholdSafetyMargin -> String)
-> ([PerasQuorumWeightThresholdSafetyMargin] -> ShowS)
-> Show PerasQuorumWeightThresholdSafetyMargin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasQuorumWeightThresholdSafetyMargin -> ShowS
showsPrec :: Int -> PerasQuorumWeightThresholdSafetyMargin -> ShowS
$cshow :: PerasQuorumWeightThresholdSafetyMargin -> String
show :: PerasQuorumWeightThresholdSafetyMargin -> String
$cshowList :: [PerasQuorumWeightThresholdSafetyMargin] -> ShowS
showList :: [PerasQuorumWeightThresholdSafetyMargin] -> ShowS
Show via Quiet PerasQuorumWeightThresholdSafetyMargin
  deriving stock (forall x.
 PerasQuorumWeightThresholdSafetyMargin
 -> Rep PerasQuorumWeightThresholdSafetyMargin x)
-> (forall x.
    Rep PerasQuorumWeightThresholdSafetyMargin x
    -> PerasQuorumWeightThresholdSafetyMargin)
-> Generic PerasQuorumWeightThresholdSafetyMargin
forall x.
Rep PerasQuorumWeightThresholdSafetyMargin x
-> PerasQuorumWeightThresholdSafetyMargin
forall x.
PerasQuorumWeightThresholdSafetyMargin
-> Rep PerasQuorumWeightThresholdSafetyMargin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
PerasQuorumWeightThresholdSafetyMargin
-> Rep PerasQuorumWeightThresholdSafetyMargin x
from :: forall x.
PerasQuorumWeightThresholdSafetyMargin
-> Rep PerasQuorumWeightThresholdSafetyMargin x
$cto :: forall x.
Rep PerasQuorumWeightThresholdSafetyMargin x
-> PerasQuorumWeightThresholdSafetyMargin
to :: forall x.
Rep PerasQuorumWeightThresholdSafetyMargin x
-> PerasQuorumWeightThresholdSafetyMargin
Generic
  deriving newtype (PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
(PerasQuorumWeightThresholdSafetyMargin
 -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> Eq PerasQuorumWeightThresholdSafetyMargin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
== :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
$c/= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
/= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
Eq, Eq PerasQuorumWeightThresholdSafetyMargin
Eq PerasQuorumWeightThresholdSafetyMargin =>
(PerasQuorumWeightThresholdSafetyMargin
 -> PerasQuorumWeightThresholdSafetyMargin -> Ordering)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin -> Bool)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin)
-> (PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin
    -> PerasQuorumWeightThresholdSafetyMargin)
-> Ord PerasQuorumWeightThresholdSafetyMargin
PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Ordering
PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
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
$ccompare :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Ordering
compare :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Ordering
$c< :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
< :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
$c<= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
<= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
$c> :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
> :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
$c>= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
>= :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin -> Bool
$cmax :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
max :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
$cmin :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
min :: PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
-> PerasQuorumWeightThresholdSafetyMargin
Ord, Context
-> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo)
Proxy PerasQuorumWeightThresholdSafetyMargin -> String
(Context
 -> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo))
-> (Context
    -> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo))
-> (Proxy PerasQuorumWeightThresholdSafetyMargin -> String)
-> NoThunks PerasQuorumWeightThresholdSafetyMargin
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context
-> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo)
noThunks :: Context
-> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context
-> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo)
wNoThunks :: Context
-> PerasQuorumWeightThresholdSafetyMargin -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasQuorumWeightThresholdSafetyMargin -> String
showTypeOf :: Proxy PerasQuorumWeightThresholdSafetyMargin -> String
NoThunks, PerasQuorumWeightThresholdSafetyMargin -> String
(PerasQuorumWeightThresholdSafetyMargin -> String)
-> Condense PerasQuorumWeightThresholdSafetyMargin
forall a. (a -> String) -> Condense a
$ccondense :: PerasQuorumWeightThresholdSafetyMargin -> String
condense :: PerasQuorumWeightThresholdSafetyMargin -> String
Condense, Typeable PerasQuorumWeightThresholdSafetyMargin
Typeable PerasQuorumWeightThresholdSafetyMargin =>
(forall s. Decoder s PerasQuorumWeightThresholdSafetyMargin)
-> (Proxy PerasQuorumWeightThresholdSafetyMargin -> Text)
-> FromCBOR PerasQuorumWeightThresholdSafetyMargin
Proxy PerasQuorumWeightThresholdSafetyMargin -> Text
forall s. Decoder s PerasQuorumWeightThresholdSafetyMargin
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PerasQuorumWeightThresholdSafetyMargin
fromCBOR :: forall s. Decoder s PerasQuorumWeightThresholdSafetyMargin
$clabel :: Proxy PerasQuorumWeightThresholdSafetyMargin -> Text
label :: Proxy PerasQuorumWeightThresholdSafetyMargin -> Text
FromCBOR, Typeable PerasQuorumWeightThresholdSafetyMargin
Typeable PerasQuorumWeightThresholdSafetyMargin =>
(PerasQuorumWeightThresholdSafetyMargin -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PerasQuorumWeightThresholdSafetyMargin -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasQuorumWeightThresholdSafetyMargin] -> Size)
-> ToCBOR PerasQuorumWeightThresholdSafetyMargin
PerasQuorumWeightThresholdSafetyMargin -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThresholdSafetyMargin] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThresholdSafetyMargin -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PerasQuorumWeightThresholdSafetyMargin -> Encoding
toCBOR :: PerasQuorumWeightThresholdSafetyMargin -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThresholdSafetyMargin -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy PerasQuorumWeightThresholdSafetyMargin -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThresholdSafetyMargin] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasQuorumWeightThresholdSafetyMargin] -> Size
ToCBOR)

-- * Protocol parameters bundle

-- | Peras protocol parameters.
--
-- These are documented in the section 2.1 of the Peras design report:
-- https://tweag.github.io/cardano-peras/peras-design.pdf#section.2.1
--
-- TODO: make fields strict when we have concrete default values for them.
data PerasParams blk = PerasParams
  { forall blk. PerasParams blk -> PerasIgnoranceRounds
perasIgnoranceRounds :: !PerasIgnoranceRounds
  , forall blk. PerasParams blk -> PerasCooldownRounds
perasCooldownRounds :: !PerasCooldownRounds
  , forall blk. PerasParams blk -> PerasBlockMinSlots
perasBlockMinSlots :: !PerasBlockMinSlots
  , forall blk. PerasParams blk -> PerasCertMaxRounds
perasCertMaxRounds :: !PerasCertMaxRounds
  , forall blk. PerasParams blk -> PerasCertArrivalThreshold
perasCertArrivalThreshold :: !PerasCertArrivalThreshold
  , forall blk. PerasParams blk -> PerasWeight
perasWeight :: !PerasWeight
  , forall blk. PerasParams blk -> PerasQuorumWeightThreshold
perasQuorumWeightThreshold :: !PerasQuorumWeightThreshold
  , forall blk.
PerasParams blk -> PerasQuorumWeightThresholdSafetyMargin
perasQuorumWeightThresholdSafetyMargin :: !PerasQuorumWeightThresholdSafetyMargin
  , forall blk. PerasParams blk -> TargetCommitteeSize
perasTargetCommitteeSize :: !Committee.TargetCommitteeSize
  }
  deriving (Int -> PerasParams blk -> ShowS
[PerasParams blk] -> ShowS
PerasParams blk -> String
(Int -> PerasParams blk -> ShowS)
-> (PerasParams blk -> String)
-> ([PerasParams blk] -> ShowS)
-> Show (PerasParams blk)
forall blk. Int -> PerasParams blk -> ShowS
forall blk. [PerasParams blk] -> ShowS
forall blk. PerasParams blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasParams blk -> ShowS
showsPrec :: Int -> PerasParams blk -> ShowS
$cshow :: forall blk. PerasParams blk -> String
show :: PerasParams blk -> String
$cshowList :: forall blk. [PerasParams blk] -> ShowS
showList :: [PerasParams blk] -> ShowS
Show, PerasParams blk -> PerasParams blk -> Bool
(PerasParams blk -> PerasParams blk -> Bool)
-> (PerasParams blk -> PerasParams blk -> Bool)
-> Eq (PerasParams blk)
forall blk. PerasParams blk -> PerasParams blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. PerasParams blk -> PerasParams blk -> Bool
== :: PerasParams blk -> PerasParams blk -> Bool
$c/= :: forall blk. PerasParams blk -> PerasParams blk -> Bool
/= :: PerasParams blk -> PerasParams blk -> Bool
Eq, (forall x. PerasParams blk -> Rep (PerasParams blk) x)
-> (forall x. Rep (PerasParams blk) x -> PerasParams blk)
-> Generic (PerasParams blk)
forall x. Rep (PerasParams blk) x -> PerasParams blk
forall x. PerasParams blk -> Rep (PerasParams blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasParams blk) x -> PerasParams blk
forall blk x. PerasParams blk -> Rep (PerasParams blk) x
$cfrom :: forall blk x. PerasParams blk -> Rep (PerasParams blk) x
from :: forall x. PerasParams blk -> Rep (PerasParams blk) x
$cto :: forall blk x. Rep (PerasParams blk) x -> PerasParams blk
to :: forall x. Rep (PerasParams blk) x -> PerasParams blk
Generic, Context -> PerasParams blk -> IO (Maybe ThunkInfo)
Proxy (PerasParams blk) -> String
(Context -> PerasParams blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasParams blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasParams blk) -> String)
-> NoThunks (PerasParams blk)
forall blk. Context -> PerasParams blk -> IO (Maybe ThunkInfo)
forall blk. Proxy (PerasParams blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk. Context -> PerasParams blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasParams blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk. Context -> PerasParams blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasParams blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. Proxy (PerasParams blk) -> String
showTypeOf :: Proxy (PerasParams blk) -> String
NoThunks)

instance Typeable blk => FromCBOR (PerasParams blk) where
  fromCBOR :: forall s. Decoder s (PerasParams blk)
fromCBOR = do
    Int -> Decoder s ()
forall s. Int -> Decoder s ()
decodeListLenOf Int
9
    PerasIgnoranceRounds
-> PerasCooldownRounds
-> PerasBlockMinSlots
-> PerasCertMaxRounds
-> PerasCertArrivalThreshold
-> PerasWeight
-> PerasQuorumWeightThreshold
-> PerasQuorumWeightThresholdSafetyMargin
-> TargetCommitteeSize
-> PerasParams blk
forall blk.
PerasIgnoranceRounds
-> PerasCooldownRounds
-> PerasBlockMinSlots
-> PerasCertMaxRounds
-> PerasCertArrivalThreshold
-> PerasWeight
-> PerasQuorumWeightThreshold
-> PerasQuorumWeightThresholdSafetyMargin
-> TargetCommitteeSize
-> PerasParams blk
PerasParams
      (PerasIgnoranceRounds
 -> PerasCooldownRounds
 -> PerasBlockMinSlots
 -> PerasCertMaxRounds
 -> PerasCertArrivalThreshold
 -> PerasWeight
 -> PerasQuorumWeightThreshold
 -> PerasQuorumWeightThresholdSafetyMargin
 -> TargetCommitteeSize
 -> PerasParams blk)
-> Decoder s PerasIgnoranceRounds
-> Decoder
     s
     (PerasCooldownRounds
      -> PerasBlockMinSlots
      -> PerasCertMaxRounds
      -> PerasCertArrivalThreshold
      -> PerasWeight
      -> PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s PerasIgnoranceRounds
forall s. Decoder s PerasIgnoranceRounds
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasCooldownRounds
   -> PerasBlockMinSlots
   -> PerasCertMaxRounds
   -> PerasCertArrivalThreshold
   -> PerasWeight
   -> PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasCooldownRounds
-> Decoder
     s
     (PerasBlockMinSlots
      -> PerasCertMaxRounds
      -> PerasCertArrivalThreshold
      -> PerasWeight
      -> PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasCooldownRounds
forall s. Decoder s PerasCooldownRounds
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasBlockMinSlots
   -> PerasCertMaxRounds
   -> PerasCertArrivalThreshold
   -> PerasWeight
   -> PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasBlockMinSlots
-> Decoder
     s
     (PerasCertMaxRounds
      -> PerasCertArrivalThreshold
      -> PerasWeight
      -> PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasBlockMinSlots
forall s. Decoder s PerasBlockMinSlots
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasCertMaxRounds
   -> PerasCertArrivalThreshold
   -> PerasWeight
   -> PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasCertMaxRounds
-> Decoder
     s
     (PerasCertArrivalThreshold
      -> PerasWeight
      -> PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasCertMaxRounds
forall s. Decoder s PerasCertMaxRounds
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasCertArrivalThreshold
   -> PerasWeight
   -> PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasCertArrivalThreshold
-> Decoder
     s
     (PerasWeight
      -> PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasCertArrivalThreshold
forall s. Decoder s PerasCertArrivalThreshold
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasWeight
   -> PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasWeight
-> Decoder
     s
     (PerasQuorumWeightThreshold
      -> PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize
      -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasWeight
forall s. Decoder s PerasWeight
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasQuorumWeightThreshold
   -> PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize
   -> PerasParams blk)
-> Decoder s PerasQuorumWeightThreshold
-> Decoder
     s
     (PerasQuorumWeightThresholdSafetyMargin
      -> TargetCommitteeSize -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasQuorumWeightThreshold
forall s. Decoder s PerasQuorumWeightThreshold
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder
  s
  (PerasQuorumWeightThresholdSafetyMargin
   -> TargetCommitteeSize -> PerasParams blk)
-> Decoder s PerasQuorumWeightThresholdSafetyMargin
-> Decoder s (TargetCommitteeSize -> PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PerasQuorumWeightThresholdSafetyMargin
forall s. Decoder s PerasQuorumWeightThresholdSafetyMargin
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (TargetCommitteeSize -> PerasParams blk)
-> Decoder s TargetCommitteeSize -> Decoder s (PerasParams blk)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s TargetCommitteeSize
forall s. Decoder s TargetCommitteeSize
forall a s. FromCBOR a => Decoder s a
fromCBOR

instance Typeable blk => ToCBOR (PerasParams blk) where
  toCBOR :: PerasParams blk -> Encoding
toCBOR PerasParams blk
params =
    Word -> Encoding
encodeListLen Word
9
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasIgnoranceRounds -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasIgnoranceRounds
forall blk. PerasParams blk -> PerasIgnoranceRounds
perasIgnoranceRounds PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasCooldownRounds -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasCooldownRounds
forall blk. PerasParams blk -> PerasCooldownRounds
perasCooldownRounds PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasBlockMinSlots -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasBlockMinSlots
forall blk. PerasParams blk -> PerasBlockMinSlots
perasBlockMinSlots PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasCertMaxRounds -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasCertMaxRounds
forall blk. PerasParams blk -> PerasCertMaxRounds
perasCertMaxRounds PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasCertArrivalThreshold -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasCertArrivalThreshold
forall blk. PerasParams blk -> PerasCertArrivalThreshold
perasCertArrivalThreshold PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasWeight -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasWeight
forall blk. PerasParams blk -> PerasWeight
perasWeight PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasQuorumWeightThreshold -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasQuorumWeightThreshold
forall blk. PerasParams blk -> PerasQuorumWeightThreshold
perasQuorumWeightThreshold PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasQuorumWeightThresholdSafetyMargin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> PerasQuorumWeightThresholdSafetyMargin
forall blk.
PerasParams blk -> PerasQuorumWeightThresholdSafetyMargin
perasQuorumWeightThresholdSafetyMargin PerasParams blk
params)
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> TargetCommitteeSize -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PerasParams blk -> TargetCommitteeSize
forall blk. PerasParams blk -> TargetCommitteeSize
perasTargetCommitteeSize PerasParams blk
params)

-- | Retag a 'PerasParams' with a new phantom @blk@ type.
castPerasParams :: forall blk' blk. PerasParams blk -> PerasParams blk'
castPerasParams :: forall blk' blk. PerasParams blk -> PerasParams blk'
castPerasParams = PerasParams blk -> PerasParams blk'
forall a b. Coercible a b => a -> b
coerce

-- | Instantiate default Peras protocol parameters.
--
-- NOTE: in the future this will depend on a concrete 'BlockConfig'.
defaultPerasParams :: PerasParams blk
defaultPerasParams :: forall blk. PerasParams blk
defaultPerasParams =
  -- Many of these parameters are provided with sensible default values for now,
  -- waiting for a final decision (in a future stage of the project) on the
  -- exact values to use. See https://github.com/tweag/cardano-peras/issues/97.
  --
  -- We set tentatively T_heal to 2B/asc = 600 slots, as the CIP suggests a
  -- bigO(B/asc) for that value so that sufficiently many blocks are produced to
  -- overcome an adversarially boosted block.
  --
  -- We also set tentatively perasCertArrivalThreshold (= X in the formal spec)
  -- to 30 slots (it must be strictly smaller than perasRoundLength)
  -- See https://github.com/tweag/cardano-peras/issues/88 and
  -- https://github.com/tweag/cardano-peras/issues/99 for more information on
  -- this parameter.
  --
  -- We also have T_cp = 129_600 and T_cq = 43_200 as per the design document
  PerasParams
    { -- ceil(T_heal + T_cq) / perasRoundLength) as per the design document
      perasIgnoranceRounds :: PerasIgnoranceRounds
perasIgnoranceRounds =
        Word64 -> PerasIgnoranceRounds
PerasIgnoranceRounds Word64
487
    , -- ceil(T_heal + T_cq + T_cp) / perasRoundLength) + 1 as per the design document
      perasCooldownRounds :: PerasCooldownRounds
perasCooldownRounds =
        Word64 -> PerasCooldownRounds
PerasCooldownRounds Word64
1928
    , -- must be between 30 and 900 as per the design document
      perasBlockMinSlots :: PerasBlockMinSlots
perasBlockMinSlots =
        Word64 -> PerasBlockMinSlots
PerasBlockMinSlots Word64
90
    , -- equal to perasIgnoranceRounds as per the design document
      perasCertMaxRounds :: PerasCertMaxRounds
perasCertMaxRounds =
        Word64 -> PerasCertMaxRounds
PerasCertMaxRounds Word64
487
    , perasCertArrivalThreshold :: PerasCertArrivalThreshold
perasCertArrivalThreshold =
        Word64 -> PerasCertArrivalThreshold
PerasCertArrivalThreshold Word64
30
    , perasWeight :: PerasWeight
perasWeight =
        Word64 -> PerasWeight
PerasWeight Word64
15
    , perasQuorumWeightThreshold :: PerasQuorumWeightThreshold
perasQuorumWeightThreshold =
        Rational -> PerasQuorumWeightThreshold
PerasQuorumWeightThreshold (Rational
3 Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Rational
4)
    , perasQuorumWeightThresholdSafetyMargin :: PerasQuorumWeightThresholdSafetyMargin
perasQuorumWeightThresholdSafetyMargin =
        Rational -> PerasQuorumWeightThresholdSafetyMargin
PerasQuorumWeightThresholdSafetyMargin (Rational
2 Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Rational
100)
    , perasTargetCommitteeSize :: TargetCommitteeSize
perasTargetCommitteeSize =
        Word64 -> TargetCommitteeSize
Committee.TargetCommitteeSize Word64
800
    }

-- * Era-dependent default values

-- | Default value for 'PerasRoundLength' in the Dijkstra eras.
dijkstraPerasRoundLength :: PerasEnabled PerasRoundLength
dijkstraPerasRoundLength :: PerasEnabled PerasRoundLength
dijkstraPerasRoundLength = PerasRoundLength -> PerasEnabled PerasRoundLength
forall a. a -> PerasEnabled a
PerasEnabled (Word64 -> PerasRoundLength
PerasRoundLength Word64
90)

-- * 'PerasEnabled' wrapper

-- | A marker for Peras-specific values that are not present in all eras
newtype PerasEnabled a = MkPerasEnabled (Maybe a)
  deriving stock (Int -> PerasEnabled a -> ShowS
[PerasEnabled a] -> ShowS
PerasEnabled a -> String
(Int -> PerasEnabled a -> ShowS)
-> (PerasEnabled a -> String)
-> ([PerasEnabled a] -> ShowS)
-> Show (PerasEnabled a)
forall a. Show a => Int -> PerasEnabled a -> ShowS
forall a. Show a => [PerasEnabled a] -> ShowS
forall a. Show a => PerasEnabled a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> PerasEnabled a -> ShowS
showsPrec :: Int -> PerasEnabled a -> ShowS
$cshow :: forall a. Show a => PerasEnabled a -> String
show :: PerasEnabled a -> String
$cshowList :: forall a. Show a => [PerasEnabled a] -> ShowS
showList :: [PerasEnabled a] -> ShowS
Show, PerasEnabled a -> PerasEnabled a -> Bool
(PerasEnabled a -> PerasEnabled a -> Bool)
-> (PerasEnabled a -> PerasEnabled a -> Bool)
-> Eq (PerasEnabled a)
forall a. Eq a => PerasEnabled a -> PerasEnabled a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => PerasEnabled a -> PerasEnabled a -> Bool
== :: PerasEnabled a -> PerasEnabled a -> Bool
$c/= :: forall a. Eq a => PerasEnabled a -> PerasEnabled a -> Bool
/= :: PerasEnabled a -> PerasEnabled a -> Bool
Eq, Eq (PerasEnabled a)
Eq (PerasEnabled a) =>
(PerasEnabled a -> PerasEnabled a -> Ordering)
-> (PerasEnabled a -> PerasEnabled a -> Bool)
-> (PerasEnabled a -> PerasEnabled a -> Bool)
-> (PerasEnabled a -> PerasEnabled a -> Bool)
-> (PerasEnabled a -> PerasEnabled a -> Bool)
-> (PerasEnabled a -> PerasEnabled a -> PerasEnabled a)
-> (PerasEnabled a -> PerasEnabled a -> PerasEnabled a)
-> Ord (PerasEnabled a)
PerasEnabled a -> PerasEnabled a -> Bool
PerasEnabled a -> PerasEnabled a -> Ordering
PerasEnabled a -> PerasEnabled a -> PerasEnabled a
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
forall a. Ord a => Eq (PerasEnabled a)
forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Bool
forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Ordering
forall a.
Ord a =>
PerasEnabled a -> PerasEnabled a -> PerasEnabled a
$ccompare :: forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Ordering
compare :: PerasEnabled a -> PerasEnabled a -> Ordering
$c< :: forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Bool
< :: PerasEnabled a -> PerasEnabled a -> Bool
$c<= :: forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Bool
<= :: PerasEnabled a -> PerasEnabled a -> Bool
$c> :: forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Bool
> :: PerasEnabled a -> PerasEnabled a -> Bool
$c>= :: forall a. Ord a => PerasEnabled a -> PerasEnabled a -> Bool
>= :: PerasEnabled a -> PerasEnabled a -> Bool
$cmax :: forall a.
Ord a =>
PerasEnabled a -> PerasEnabled a -> PerasEnabled a
max :: PerasEnabled a -> PerasEnabled a -> PerasEnabled a
$cmin :: forall a.
Ord a =>
PerasEnabled a -> PerasEnabled a -> PerasEnabled a
min :: PerasEnabled a -> PerasEnabled a -> PerasEnabled a
Ord, (forall x. PerasEnabled a -> Rep (PerasEnabled a) x)
-> (forall x. Rep (PerasEnabled a) x -> PerasEnabled a)
-> Generic (PerasEnabled a)
forall x. Rep (PerasEnabled a) x -> PerasEnabled a
forall x. PerasEnabled a -> Rep (PerasEnabled a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (PerasEnabled a) x -> PerasEnabled a
forall a x. PerasEnabled a -> Rep (PerasEnabled a) x
$cfrom :: forall a x. PerasEnabled a -> Rep (PerasEnabled a) x
from :: forall x. PerasEnabled a -> Rep (PerasEnabled a) x
$cto :: forall a x. Rep (PerasEnabled a) x -> PerasEnabled a
to :: forall x. Rep (PerasEnabled a) x -> PerasEnabled a
Generic)
  deriving anyclass Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
Proxy (PerasEnabled a) -> String
(Context -> PerasEnabled a -> IO (Maybe ThunkInfo))
-> (Context -> PerasEnabled a -> IO (Maybe ThunkInfo))
-> (Proxy (PerasEnabled a) -> String)
-> NoThunks (PerasEnabled a)
forall a.
NoThunks a =>
Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Proxy (PerasEnabled a) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall a.
NoThunks a =>
Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall a.
NoThunks a =>
Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasEnabled a -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall a. NoThunks a => Proxy (PerasEnabled a) -> String
showTypeOf :: Proxy (PerasEnabled a) -> String
NoThunks
  deriving newtype ((forall a b. (a -> b) -> PerasEnabled a -> PerasEnabled b)
-> (forall a b. a -> PerasEnabled b -> PerasEnabled a)
-> Functor PerasEnabled
forall a b. a -> PerasEnabled b -> PerasEnabled a
forall a b. (a -> b) -> PerasEnabled a -> PerasEnabled b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> PerasEnabled a -> PerasEnabled b
fmap :: forall a b. (a -> b) -> PerasEnabled a -> PerasEnabled b
$c<$ :: forall a b. a -> PerasEnabled b -> PerasEnabled a
<$ :: forall a b. a -> PerasEnabled b -> PerasEnabled a
Functor, Functor PerasEnabled
Functor PerasEnabled =>
(forall a. a -> PerasEnabled a)
-> (forall a b.
    PerasEnabled (a -> b) -> PerasEnabled a -> PerasEnabled b)
-> (forall a b c.
    (a -> b -> c)
    -> PerasEnabled a -> PerasEnabled b -> PerasEnabled c)
-> (forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b)
-> (forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled a)
-> Applicative PerasEnabled
forall a. a -> PerasEnabled a
forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled a
forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
forall a b.
PerasEnabled (a -> b) -> PerasEnabled a -> PerasEnabled b
forall a b c.
(a -> b -> c) -> PerasEnabled a -> PerasEnabled b -> PerasEnabled c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall a. a -> PerasEnabled a
pure :: forall a. a -> PerasEnabled a
$c<*> :: forall a b.
PerasEnabled (a -> b) -> PerasEnabled a -> PerasEnabled b
<*> :: forall a b.
PerasEnabled (a -> b) -> PerasEnabled a -> PerasEnabled b
$cliftA2 :: forall a b c.
(a -> b -> c) -> PerasEnabled a -> PerasEnabled b -> PerasEnabled c
liftA2 :: forall a b c.
(a -> b -> c) -> PerasEnabled a -> PerasEnabled b -> PerasEnabled c
$c*> :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
*> :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
$c<* :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled a
<* :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled a
Applicative, Applicative PerasEnabled
Applicative PerasEnabled =>
(forall a b.
 PerasEnabled a -> (a -> PerasEnabled b) -> PerasEnabled b)
-> (forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b)
-> (forall a. a -> PerasEnabled a)
-> Monad PerasEnabled
forall a. a -> PerasEnabled a
forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
forall a b.
PerasEnabled a -> (a -> PerasEnabled b) -> PerasEnabled b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall a b.
PerasEnabled a -> (a -> PerasEnabled b) -> PerasEnabled b
>>= :: forall a b.
PerasEnabled a -> (a -> PerasEnabled b) -> PerasEnabled b
$c>> :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
>> :: forall a b. PerasEnabled a -> PerasEnabled b -> PerasEnabled b
$creturn :: forall a. a -> PerasEnabled a
return :: forall a. a -> PerasEnabled a
Monad, Typeable (PerasEnabled a)
Typeable (PerasEnabled a) =>
(forall s. Decoder s (PerasEnabled a))
-> (Proxy (PerasEnabled a) -> Text) -> FromCBOR (PerasEnabled a)
Proxy (PerasEnabled a) -> Text
forall s. Decoder s (PerasEnabled a)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
forall a. FromCBOR a => Typeable (PerasEnabled a)
forall a. FromCBOR a => Proxy (PerasEnabled a) -> Text
forall a s. FromCBOR a => Decoder s (PerasEnabled a)
$cfromCBOR :: forall a s. FromCBOR a => Decoder s (PerasEnabled a)
fromCBOR :: forall s. Decoder s (PerasEnabled a)
$clabel :: forall a. FromCBOR a => Proxy (PerasEnabled a) -> Text
label :: Proxy (PerasEnabled a) -> Text
FromCBOR, Typeable (PerasEnabled a)
Typeable (PerasEnabled a) =>
(PerasEnabled a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy (PerasEnabled a) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PerasEnabled a] -> Size)
-> ToCBOR (PerasEnabled a)
PerasEnabled a -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasEnabled a] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (PerasEnabled a) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
forall a. ToCBOR a => Typeable (PerasEnabled a)
forall a. ToCBOR a => PerasEnabled a -> Encoding
forall a.
ToCBOR a =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasEnabled a] -> Size
forall a.
ToCBOR a =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (PerasEnabled a) -> Size
$ctoCBOR :: forall a. ToCBOR a => PerasEnabled a -> Encoding
toCBOR :: PerasEnabled a -> Encoding
$cencodedSizeExpr :: forall a.
ToCBOR a =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (PerasEnabled a) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (PerasEnabled a) -> Size
$cencodedListSizeExpr :: forall a.
ToCBOR a =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasEnabled a] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PerasEnabled a] -> Size
ToCBOR)

pattern PerasEnabled :: a -> PerasEnabled a
pattern $bPerasEnabled :: forall a. a -> PerasEnabled a
$mPerasEnabled :: forall {r} {a}. PerasEnabled a -> (a -> r) -> ((# #) -> r) -> r
PerasEnabled x <- MkPerasEnabled (Just !x)
 where
  PerasEnabled !a
x = Maybe a -> PerasEnabled a
forall a. Maybe a -> PerasEnabled a
MkPerasEnabled (a -> Maybe a
forall a. a -> Maybe a
Just a
x)

pattern NoPerasEnabled :: PerasEnabled a
pattern $bNoPerasEnabled :: forall a. PerasEnabled a
$mNoPerasEnabled :: forall {r} {a}. PerasEnabled a -> ((# #) -> r) -> ((# #) -> r) -> r
NoPerasEnabled = MkPerasEnabled Nothing

{-# COMPLETE PerasEnabled, NoPerasEnabled #-}

-- | A 'fromMaybe'-like eliminator for 'PerasEnabled'
fromPerasEnabled :: a -> PerasEnabled a -> a
fromPerasEnabled :: forall a. a -> PerasEnabled a -> a
fromPerasEnabled a
defaultValue = \case
  PerasEnabled a
NoPerasEnabled -> a
defaultValue
  PerasEnabled a
value -> a
value

-- | Return the underlying 'Maybe' of a 'PerasEnabled' value.
perasEnabledToMaybe :: PerasEnabled a -> Maybe a
perasEnabledToMaybe :: forall a. PerasEnabled a -> Maybe a
perasEnabledToMaybe = \case
  PerasEnabled a
NoPerasEnabled -> Maybe a
forall a. Maybe a
Nothing
  PerasEnabled a
value -> a -> Maybe a
forall a. a -> Maybe a
Just a
value

-- | A 'MaybeT'-like monad transformer.
--
--   Used solely for the Peras-related hard fork combinator queries,
--   see 'Ouroboros.Consensus.HardFork.History.Qry'.
newtype PerasEnabledT m a = PerasEnabledT
  { forall (m :: * -> *) a. PerasEnabledT m a -> m (PerasEnabled a)
runPerasEnabledT :: m (PerasEnabled a)
  }
  deriving stock (forall a b. (a -> b) -> PerasEnabledT m a -> PerasEnabledT m b)
-> (forall a b. a -> PerasEnabledT m b -> PerasEnabledT m a)
-> Functor (PerasEnabledT m)
forall a b. a -> PerasEnabledT m b -> PerasEnabledT m a
forall a b. (a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
forall (m :: * -> *) a b.
Functor m =>
a -> PerasEnabledT m b -> PerasEnabledT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
fmap :: forall a b. (a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> PerasEnabledT m b -> PerasEnabledT m a
<$ :: forall a b. a -> PerasEnabledT m b -> PerasEnabledT m a
Functor

instance (Functor m, Monad m) => Applicative (PerasEnabledT m) where
  pure :: forall a. a -> PerasEnabledT m a
pure = m (PerasEnabled a) -> PerasEnabledT m a
forall (m :: * -> *) a. m (PerasEnabled a) -> PerasEnabledT m a
PerasEnabledT (m (PerasEnabled a) -> PerasEnabledT m a)
-> (a -> m (PerasEnabled a)) -> a -> PerasEnabledT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PerasEnabled a -> m (PerasEnabled a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PerasEnabled a -> m (PerasEnabled a))
-> (a -> PerasEnabled a) -> a -> m (PerasEnabled a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> PerasEnabled a
forall a. a -> PerasEnabled a
PerasEnabled
  <*> :: forall a b.
PerasEnabledT m (a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
(<*>) = PerasEnabledT m (a -> b) -> PerasEnabledT m a -> PerasEnabledT m b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap

instance Monad m => Monad (PerasEnabledT m) where
  PerasEnabledT m a
x >>= :: forall a b.
PerasEnabledT m a -> (a -> PerasEnabledT m b) -> PerasEnabledT m b
>>= a -> PerasEnabledT m b
f = m (PerasEnabled b) -> PerasEnabledT m b
forall (m :: * -> *) a. m (PerasEnabled a) -> PerasEnabledT m a
PerasEnabledT (m (PerasEnabled b) -> PerasEnabledT m b)
-> m (PerasEnabled b) -> PerasEnabledT m b
forall a b. (a -> b) -> a -> b
$ do
    v <- PerasEnabledT m a -> m (PerasEnabled a)
forall (m :: * -> *) a. PerasEnabledT m a -> m (PerasEnabled a)
runPerasEnabledT PerasEnabledT m a
x
    case v of
      PerasEnabled a
NoPerasEnabled -> PerasEnabled b -> m (PerasEnabled b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PerasEnabled b
forall a. PerasEnabled a
NoPerasEnabled
      PerasEnabled a
y -> PerasEnabledT m b -> m (PerasEnabled b)
forall (m :: * -> *) a. PerasEnabledT m a -> m (PerasEnabled a)
runPerasEnabledT (a -> PerasEnabledT m b
f a
y)

instance MonadTrans PerasEnabledT where
  lift :: forall (m :: * -> *) a. Monad m => m a -> PerasEnabledT m a
lift = m (PerasEnabled a) -> PerasEnabledT m a
forall (m :: * -> *) a. m (PerasEnabled a) -> PerasEnabledT m a
PerasEnabledT (m (PerasEnabled a) -> PerasEnabledT m a)
-> (m a -> m (PerasEnabled a)) -> m a -> PerasEnabledT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> PerasEnabled a) -> m a -> m (PerasEnabled a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> PerasEnabled a
forall a. a -> PerasEnabled a
PerasEnabled