{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Protocol.Praos.Common
( MaxMajorProtVer (..)
, HasMaxMajorProtVer (..)
, PraosCanBeLeader (..)
, PraosTiebreakerView (..)
, VRFTiebreakerFlavor (..)
, PraosNonces (..)
, PraosProtocolSupportsNode (..)
) where
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.BaseTypes (Nonce)
import qualified Cardano.Ledger.BaseTypes as SL
import Cardano.Ledger.Binary (FromCBOR, ToCBOR)
import Cardano.Ledger.Keys (KeyHash, KeyRole (BlockIssuer))
import qualified Cardano.Ledger.Shelley.API as SL
import Cardano.Protocol.Crypto (Crypto, VRF)
import qualified Cardano.Protocol.TPraos.OCert as OCert
import Cardano.Slotting.Slot (SlotNo)
import Data.Function (on)
import Data.Map.Strict (Map)
import Data.Ord (Down (Down))
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Protocol.Abstract
newtype MaxMajorProtVer = MaxMajorProtVer
{ MaxMajorProtVer -> Version
getMaxMajorProtVer :: SL.Version
}
deriving (MaxMajorProtVer -> MaxMajorProtVer -> Bool
(MaxMajorProtVer -> MaxMajorProtVer -> Bool)
-> (MaxMajorProtVer -> MaxMajorProtVer -> Bool)
-> Eq MaxMajorProtVer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MaxMajorProtVer -> MaxMajorProtVer -> Bool
== :: MaxMajorProtVer -> MaxMajorProtVer -> Bool
$c/= :: MaxMajorProtVer -> MaxMajorProtVer -> Bool
/= :: MaxMajorProtVer -> MaxMajorProtVer -> Bool
Eq, Int -> MaxMajorProtVer -> ShowS
[MaxMajorProtVer] -> ShowS
MaxMajorProtVer -> String
(Int -> MaxMajorProtVer -> ShowS)
-> (MaxMajorProtVer -> String)
-> ([MaxMajorProtVer] -> ShowS)
-> Show MaxMajorProtVer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MaxMajorProtVer -> ShowS
showsPrec :: Int -> MaxMajorProtVer -> ShowS
$cshow :: MaxMajorProtVer -> String
show :: MaxMajorProtVer -> String
$cshowList :: [MaxMajorProtVer] -> ShowS
showList :: [MaxMajorProtVer] -> ShowS
Show, (forall x. MaxMajorProtVer -> Rep MaxMajorProtVer x)
-> (forall x. Rep MaxMajorProtVer x -> MaxMajorProtVer)
-> Generic MaxMajorProtVer
forall x. Rep MaxMajorProtVer x -> MaxMajorProtVer
forall x. MaxMajorProtVer -> Rep MaxMajorProtVer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MaxMajorProtVer -> Rep MaxMajorProtVer x
from :: forall x. MaxMajorProtVer -> Rep MaxMajorProtVer x
$cto :: forall x. Rep MaxMajorProtVer x -> MaxMajorProtVer
to :: forall x. Rep MaxMajorProtVer x -> MaxMajorProtVer
Generic)
deriving newtype (Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo)
Proxy MaxMajorProtVer -> String
(Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo))
-> (Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo))
-> (Proxy MaxMajorProtVer -> String)
-> NoThunks MaxMajorProtVer
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo)
noThunks :: Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> MaxMajorProtVer -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy MaxMajorProtVer -> String
showTypeOf :: Proxy MaxMajorProtVer -> String
NoThunks, Typeable MaxMajorProtVer
Typeable MaxMajorProtVer =>
(MaxMajorProtVer -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy MaxMajorProtVer -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [MaxMajorProtVer] -> Size)
-> ToCBOR MaxMajorProtVer
MaxMajorProtVer -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [MaxMajorProtVer] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy MaxMajorProtVer -> 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 :: MaxMajorProtVer -> Encoding
toCBOR :: MaxMajorProtVer -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy MaxMajorProtVer -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy MaxMajorProtVer -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [MaxMajorProtVer] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [MaxMajorProtVer] -> Size
ToCBOR, Typeable MaxMajorProtVer
Typeable MaxMajorProtVer =>
(forall s. Decoder s MaxMajorProtVer)
-> (Proxy MaxMajorProtVer -> Text) -> FromCBOR MaxMajorProtVer
Proxy MaxMajorProtVer -> Text
forall s. Decoder s MaxMajorProtVer
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s MaxMajorProtVer
fromCBOR :: forall s. Decoder s MaxMajorProtVer
$clabel :: Proxy MaxMajorProtVer -> Text
label :: Proxy MaxMajorProtVer -> Text
FromCBOR)
class HasMaxMajorProtVer proto where
protoMaxMajorPV :: ConsensusConfig proto -> MaxMajorProtVer
data PraosTiebreakerView c = PraosTiebreakerView
{ forall c. PraosTiebreakerView c -> SlotNo
ptvSlotNo :: SlotNo
, forall c. PraosTiebreakerView c -> VKey 'BlockIssuer
ptvIssuer :: SL.VKey 'SL.BlockIssuer
, forall c. PraosTiebreakerView c -> Word64
ptvIssueNo :: Word64
, forall c. PraosTiebreakerView c -> OutputVRF (VRF c)
ptvTieBreakVRF :: VRF.OutputVRF (VRF c)
}
deriving (Int -> PraosTiebreakerView c -> ShowS
[PraosTiebreakerView c] -> ShowS
PraosTiebreakerView c -> String
(Int -> PraosTiebreakerView c -> ShowS)
-> (PraosTiebreakerView c -> String)
-> ([PraosTiebreakerView c] -> ShowS)
-> Show (PraosTiebreakerView c)
forall c. Int -> PraosTiebreakerView c -> ShowS
forall c. [PraosTiebreakerView c] -> ShowS
forall c. PraosTiebreakerView c -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall c. Int -> PraosTiebreakerView c -> ShowS
showsPrec :: Int -> PraosTiebreakerView c -> ShowS
$cshow :: forall c. PraosTiebreakerView c -> String
show :: PraosTiebreakerView c -> String
$cshowList :: forall c. [PraosTiebreakerView c] -> ShowS
showList :: [PraosTiebreakerView c] -> ShowS
Show, PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
(PraosTiebreakerView c -> PraosTiebreakerView c -> Bool)
-> (PraosTiebreakerView c -> PraosTiebreakerView c -> Bool)
-> Eq (PraosTiebreakerView c)
forall c. PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall c. PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
== :: PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
$c/= :: forall c. PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
/= :: PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
Eq, (forall x. PraosTiebreakerView c -> Rep (PraosTiebreakerView c) x)
-> (forall x.
Rep (PraosTiebreakerView c) x -> PraosTiebreakerView c)
-> Generic (PraosTiebreakerView c)
forall x. Rep (PraosTiebreakerView c) x -> PraosTiebreakerView c
forall x. PraosTiebreakerView c -> Rep (PraosTiebreakerView c) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x. Rep (PraosTiebreakerView c) x -> PraosTiebreakerView c
forall c x. PraosTiebreakerView c -> Rep (PraosTiebreakerView c) x
$cfrom :: forall c x. PraosTiebreakerView c -> Rep (PraosTiebreakerView c) x
from :: forall x. PraosTiebreakerView c -> Rep (PraosTiebreakerView c) x
$cto :: forall c x. Rep (PraosTiebreakerView c) x -> PraosTiebreakerView c
to :: forall x. Rep (PraosTiebreakerView c) x -> PraosTiebreakerView c
Generic, Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
Proxy (PraosTiebreakerView c) -> String
(Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo))
-> (Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo))
-> (Proxy (PraosTiebreakerView c) -> String)
-> NoThunks (PraosTiebreakerView c)
forall c. Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
forall c. Proxy (PraosTiebreakerView c) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall c. Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
noThunks :: Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall c. Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PraosTiebreakerView c -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall c. Proxy (PraosTiebreakerView c) -> String
showTypeOf :: Proxy (PraosTiebreakerView c) -> String
NoThunks)
data VRFTiebreakerFlavor
=
UnrestrictedVRFTiebreaker
|
RestrictedVRFTiebreaker SlotNo
deriving stock (Int -> VRFTiebreakerFlavor -> ShowS
[VRFTiebreakerFlavor] -> ShowS
VRFTiebreakerFlavor -> String
(Int -> VRFTiebreakerFlavor -> ShowS)
-> (VRFTiebreakerFlavor -> String)
-> ([VRFTiebreakerFlavor] -> ShowS)
-> Show VRFTiebreakerFlavor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VRFTiebreakerFlavor -> ShowS
showsPrec :: Int -> VRFTiebreakerFlavor -> ShowS
$cshow :: VRFTiebreakerFlavor -> String
show :: VRFTiebreakerFlavor -> String
$cshowList :: [VRFTiebreakerFlavor] -> ShowS
showList :: [VRFTiebreakerFlavor] -> ShowS
Show, VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool
(VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool)
-> (VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool)
-> Eq VRFTiebreakerFlavor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool
== :: VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool
$c/= :: VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool
/= :: VRFTiebreakerFlavor -> VRFTiebreakerFlavor -> Bool
Eq, (forall x. VRFTiebreakerFlavor -> Rep VRFTiebreakerFlavor x)
-> (forall x. Rep VRFTiebreakerFlavor x -> VRFTiebreakerFlavor)
-> Generic VRFTiebreakerFlavor
forall x. Rep VRFTiebreakerFlavor x -> VRFTiebreakerFlavor
forall x. VRFTiebreakerFlavor -> Rep VRFTiebreakerFlavor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. VRFTiebreakerFlavor -> Rep VRFTiebreakerFlavor x
from :: forall x. VRFTiebreakerFlavor -> Rep VRFTiebreakerFlavor x
$cto :: forall x. Rep VRFTiebreakerFlavor x -> VRFTiebreakerFlavor
to :: forall x. Rep VRFTiebreakerFlavor x -> VRFTiebreakerFlavor
Generic)
deriving anyclass Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo)
Proxy VRFTiebreakerFlavor -> String
(Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo))
-> (Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo))
-> (Proxy VRFTiebreakerFlavor -> String)
-> NoThunks VRFTiebreakerFlavor
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo)
noThunks :: Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> VRFTiebreakerFlavor -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy VRFTiebreakerFlavor -> String
showTypeOf :: Proxy VRFTiebreakerFlavor -> String
NoThunks
comparePraos ::
VRFTiebreakerFlavor ->
PraosTiebreakerView c ->
PraosTiebreakerView c ->
Ordering
comparePraos :: forall c.
VRFTiebreakerFlavor
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
comparePraos VRFTiebreakerFlavor
tiebreakerFlavor =
(PraosTiebreakerView c -> PraosTiebreakerView c -> Bool)
-> (PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering)
-> PraosTiebreakerView c
-> PraosTiebreakerView c
-> Ordering
forall a.
(a -> a -> Bool) -> (a -> a -> Ordering) -> a -> a -> Ordering
when' PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
forall {c} {c}.
PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
issueNoArmed (Word64 -> Word64 -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Word64 -> Word64 -> Ordering)
-> (PraosTiebreakerView c -> Word64)
-> PraosTiebreakerView c
-> PraosTiebreakerView c
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` PraosTiebreakerView c -> Word64
forall c. PraosTiebreakerView c -> Word64
ptvIssueNo)
(PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering)
-> (PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering)
-> PraosTiebreakerView c
-> PraosTiebreakerView c
-> Ordering
forall a. Semigroup a => a -> a -> a
<> (PraosTiebreakerView c -> PraosTiebreakerView c -> Bool)
-> (PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering)
-> PraosTiebreakerView c
-> PraosTiebreakerView c
-> Ordering
forall a.
(a -> a -> Bool) -> (a -> a -> Ordering) -> a -> a -> Ordering
when' PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
vrfArmed (Down (OutputVRF (VRF c)) -> Down (OutputVRF (VRF c)) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Down (OutputVRF (VRF c)) -> Down (OutputVRF (VRF c)) -> Ordering)
-> (PraosTiebreakerView c -> Down (OutputVRF (VRF c)))
-> PraosTiebreakerView c
-> PraosTiebreakerView c
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` OutputVRF (VRF c) -> Down (OutputVRF (VRF c))
forall a. a -> Down a
Down (OutputVRF (VRF c) -> Down (OutputVRF (VRF c)))
-> (PraosTiebreakerView c -> OutputVRF (VRF c))
-> PraosTiebreakerView c
-> Down (OutputVRF (VRF c))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PraosTiebreakerView c -> OutputVRF (VRF c)
forall c. PraosTiebreakerView c -> OutputVRF (VRF c)
ptvTieBreakVRF)
where
when' ::
(a -> a -> Bool) ->
(a -> a -> Ordering) ->
(a -> a -> Ordering)
when' :: forall a.
(a -> a -> Bool) -> (a -> a -> Ordering) -> a -> a -> Ordering
when' a -> a -> Bool
p a -> a -> Ordering
comp a
a1 a
a2 =
if a -> a -> Bool
p a
a1 a
a2 then a -> a -> Ordering
comp a
a1 a
a2 else Ordering
EQ
issueNoArmed :: PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
issueNoArmed PraosTiebreakerView c
v1 PraosTiebreakerView c
v2 =
PraosTiebreakerView c -> SlotNo
forall c. PraosTiebreakerView c -> SlotNo
ptvSlotNo PraosTiebreakerView c
v1 SlotNo -> SlotNo -> Bool
forall a. Eq a => a -> a -> Bool
== PraosTiebreakerView c -> SlotNo
forall c. PraosTiebreakerView c -> SlotNo
ptvSlotNo PraosTiebreakerView c
v2
Bool -> Bool -> Bool
&& PraosTiebreakerView c -> VKey 'BlockIssuer
forall c. PraosTiebreakerView c -> VKey 'BlockIssuer
ptvIssuer PraosTiebreakerView c
v1 VKey 'BlockIssuer -> VKey 'BlockIssuer -> Bool
forall a. Eq a => a -> a -> Bool
== PraosTiebreakerView c -> VKey 'BlockIssuer
forall c. PraosTiebreakerView c -> VKey 'BlockIssuer
ptvIssuer PraosTiebreakerView c
v2
vrfArmed :: PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
vrfArmed PraosTiebreakerView c
v1 PraosTiebreakerView c
v2 = case VRFTiebreakerFlavor
tiebreakerFlavor of
VRFTiebreakerFlavor
UnrestrictedVRFTiebreaker -> Bool
True
RestrictedVRFTiebreaker SlotNo
maxDist ->
SlotNo -> SlotNo -> SlotNo
slotDist (PraosTiebreakerView c -> SlotNo
forall c. PraosTiebreakerView c -> SlotNo
ptvSlotNo PraosTiebreakerView c
v1) (PraosTiebreakerView c -> SlotNo
forall c. PraosTiebreakerView c -> SlotNo
ptvSlotNo PraosTiebreakerView c
v2) SlotNo -> SlotNo -> Bool
forall a. Ord a => a -> a -> Bool
<= SlotNo
maxDist
slotDist :: SlotNo -> SlotNo -> SlotNo
slotDist :: SlotNo -> SlotNo -> SlotNo
slotDist SlotNo
s SlotNo
t
| SlotNo
s SlotNo -> SlotNo -> Bool
forall a. Ord a => a -> a -> Bool
>= SlotNo
t = SlotNo
s SlotNo -> SlotNo -> SlotNo
forall a. Num a => a -> a -> a
- SlotNo
t
| Bool
otherwise = SlotNo
t SlotNo -> SlotNo -> SlotNo
forall a. Num a => a -> a -> a
- SlotNo
s
instance Crypto c => Ord (PraosTiebreakerView c) where
compare :: PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
compare = VRFTiebreakerFlavor
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
forall c.
VRFTiebreakerFlavor
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
comparePraos VRFTiebreakerFlavor
UnrestrictedVRFTiebreaker
instance Crypto c => ChainOrder (PraosTiebreakerView c) where
type ChainOrderConfig (PraosTiebreakerView c) = VRFTiebreakerFlavor
preferCandidate :: ChainOrderConfig (PraosTiebreakerView c)
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Bool
preferCandidate ChainOrderConfig (PraosTiebreakerView c)
cfg PraosTiebreakerView c
ours PraosTiebreakerView c
cand = VRFTiebreakerFlavor
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
forall c.
VRFTiebreakerFlavor
-> PraosTiebreakerView c -> PraosTiebreakerView c -> Ordering
comparePraos ChainOrderConfig (PraosTiebreakerView c)
VRFTiebreakerFlavor
cfg PraosTiebreakerView c
ours PraosTiebreakerView c
cand Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
LT
data PraosCanBeLeader c = PraosCanBeLeader
{ forall c. PraosCanBeLeader c -> OCert c
praosCanBeLeaderOpCert :: !(OCert.OCert c)
, forall c. PraosCanBeLeader c -> VKey 'BlockIssuer
praosCanBeLeaderColdVerKey :: !(SL.VKey 'SL.BlockIssuer)
, forall c. PraosCanBeLeader c -> SignKeyVRF (VRF c)
praosCanBeLeaderSignKeyVRF :: !(VRF.SignKeyVRF (VRF c))
}
deriving (forall x. PraosCanBeLeader c -> Rep (PraosCanBeLeader c) x)
-> (forall x. Rep (PraosCanBeLeader c) x -> PraosCanBeLeader c)
-> Generic (PraosCanBeLeader c)
forall x. Rep (PraosCanBeLeader c) x -> PraosCanBeLeader c
forall x. PraosCanBeLeader c -> Rep (PraosCanBeLeader c) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x. Rep (PraosCanBeLeader c) x -> PraosCanBeLeader c
forall c x. PraosCanBeLeader c -> Rep (PraosCanBeLeader c) x
$cfrom :: forall c x. PraosCanBeLeader c -> Rep (PraosCanBeLeader c) x
from :: forall x. PraosCanBeLeader c -> Rep (PraosCanBeLeader c) x
$cto :: forall c x. Rep (PraosCanBeLeader c) x -> PraosCanBeLeader c
to :: forall x. Rep (PraosCanBeLeader c) x -> PraosCanBeLeader c
Generic
instance Crypto c => NoThunks (PraosCanBeLeader c)
data PraosNonces = PraosNonces
{ PraosNonces -> Nonce
candidateNonce :: !Nonce
, PraosNonces -> Nonce
epochNonce :: !Nonce
, PraosNonces -> Nonce
evolvingNonce :: !Nonce
, PraosNonces -> Nonce
labNonce :: !Nonce
, PraosNonces -> Nonce
previousLabNonce :: !Nonce
}
class ConsensusProtocol p => PraosProtocolSupportsNode p where
type PraosProtocolSupportsNodeCrypto p
getPraosNonces :: proxy p -> ChainDepState p -> PraosNonces
getOpCertCounters :: proxy p -> ChainDepState p -> Map (KeyHash 'BlockIssuer) Word64