{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Consensus.Mock.Ledger.Block.Praos (
SignedSimplePraos (..)
, SimplePraosBlock
, SimplePraosExt (..)
, SimplePraosHeader
, forgePraosExt
) where
import Cardano.Binary (FromCBOR (..), ToCBOR (..), serialize')
import Cardano.Crypto.KES
import Cardano.Crypto.Util
import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Encoding as CBOR
import Codec.Serialise (Serialise (..))
import Data.Typeable (Typeable)
import Data.Void (Void)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Forecast
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Mock.Ledger.Address
import Ouroboros.Consensus.Mock.Ledger.Block
import Ouroboros.Consensus.Mock.Ledger.Forge
import Ouroboros.Consensus.Mock.Node.Abstract
import Ouroboros.Consensus.Mock.Protocol.Praos
import Ouroboros.Consensus.Protocol.Signed
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Consensus.Util.Condense
type SimplePraosBlock c c' = SimpleBlock c (SimplePraosExt c c')
type c c' = SimpleHeader c (SimplePraosExt c c')
newtype SimplePraosExt c c' = SimplePraosExt {
forall c c'.
SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c')
simplePraosExt :: PraosFields c' (SignedSimplePraos c c')
}
deriving stock ((forall x. SimplePraosExt c c' -> Rep (SimplePraosExt c c') x)
-> (forall x. Rep (SimplePraosExt c c') x -> SimplePraosExt c c')
-> Generic (SimplePraosExt c c')
forall x. Rep (SimplePraosExt c c') x -> SimplePraosExt c c'
forall x. SimplePraosExt c c' -> Rep (SimplePraosExt c c') x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c c' x. Rep (SimplePraosExt c c') x -> SimplePraosExt c c'
forall c c' x. SimplePraosExt c c' -> Rep (SimplePraosExt c c') x
$cfrom :: forall c c' x. SimplePraosExt c c' -> Rep (SimplePraosExt c c') x
from :: forall x. SimplePraosExt c c' -> Rep (SimplePraosExt c c') x
$cto :: forall c c' x. Rep (SimplePraosExt c c') x -> SimplePraosExt c c'
to :: forall x. Rep (SimplePraosExt c c') x -> SimplePraosExt c c'
Generic, Int -> SimplePraosExt c c' -> ShowS
[SimplePraosExt c c'] -> ShowS
SimplePraosExt c c' -> String
(Int -> SimplePraosExt c c' -> ShowS)
-> (SimplePraosExt c c' -> String)
-> ([SimplePraosExt c c'] -> ShowS)
-> Show (SimplePraosExt c c')
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall c c'. PraosCrypto c' => Int -> SimplePraosExt c c' -> ShowS
forall c c'. PraosCrypto c' => [SimplePraosExt c c'] -> ShowS
forall c c'. PraosCrypto c' => SimplePraosExt c c' -> String
$cshowsPrec :: forall c c'. PraosCrypto c' => Int -> SimplePraosExt c c' -> ShowS
showsPrec :: Int -> SimplePraosExt c c' -> ShowS
$cshow :: forall c c'. PraosCrypto c' => SimplePraosExt c c' -> String
show :: SimplePraosExt c c' -> String
$cshowList :: forall c c'. PraosCrypto c' => [SimplePraosExt c c'] -> ShowS
showList :: [SimplePraosExt c c'] -> ShowS
Show, SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
(SimplePraosExt c c' -> SimplePraosExt c c' -> Bool)
-> (SimplePraosExt c c' -> SimplePraosExt c c' -> Bool)
-> Eq (SimplePraosExt c c')
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall c c'.
PraosCrypto c' =>
SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
$c== :: forall c c'.
PraosCrypto c' =>
SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
== :: SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
$c/= :: forall c c'.
PraosCrypto c' =>
SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
/= :: SimplePraosExt c c' -> SimplePraosExt c c' -> Bool
Eq)
deriving newtype (SimplePraosExt c c' -> String
(SimplePraosExt c c' -> String) -> Condense (SimplePraosExt c c')
forall a. (a -> String) -> Condense a
forall c c'. PraosCrypto c' => SimplePraosExt c c' -> String
$ccondense :: forall c c'. PraosCrypto c' => SimplePraosExt c c' -> String
condense :: SimplePraosExt c c' -> String
Condense)
deriving anyclass (Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
Proxy (SimplePraosExt c c') -> String
(Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo))
-> (Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo))
-> (Proxy (SimplePraosExt c c') -> String)
-> NoThunks (SimplePraosExt c c')
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
forall c c'.
(PraosCrypto c', Typeable c) =>
Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
forall c c'.
(PraosCrypto c', Typeable c) =>
Proxy (SimplePraosExt c c') -> String
$cnoThunks :: forall c c'.
(PraosCrypto c', Typeable c) =>
Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
noThunks :: Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall c c'.
(PraosCrypto c', Typeable c) =>
Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> SimplePraosExt c c' -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall c c'.
(PraosCrypto c', Typeable c) =>
Proxy (SimplePraosExt c c') -> String
showTypeOf :: Proxy (SimplePraosExt c c') -> String
NoThunks)
data SignedSimplePraos c c' = SignedSimplePraos {
forall c c'.
SignedSimplePraos c c' -> SimpleStdHeader c (SimplePraosExt c c')
signedSimplePraos :: SimpleStdHeader c (SimplePraosExt c c')
, forall c c'. SignedSimplePraos c c' -> PraosExtraFields c'
signedPraosFields :: PraosExtraFields c'
}
type instance BlockProtocol (SimplePraosBlock c c') = Praos c'
_simplePraosHeader :: SimplePraosBlock c c' -> SimplePraosHeader c c'
= SimpleBlock' c (SimplePraosExt c c') (SimplePraosExt c c')
-> Header
(SimpleBlock' c (SimplePraosExt c c') (SimplePraosExt c c'))
forall c ext ext'.
SimpleBlock' c ext ext' -> Header (SimpleBlock' c ext ext')
simpleHeader
instance (SimpleCrypto c, Typeable c')
=> MockProtocolSpecific c (SimplePraosExt c c') where
type MockLedgerConfig c (SimplePraosExt c c') = AddrDist
type instance Signed (SimplePraosHeader c c') = SignedSimplePraos c c'
instance PraosCrypto c' => SignedHeader (SimplePraosHeader c c') where
headerSigned :: SimplePraosHeader c c' -> Signed (SimplePraosHeader c c')
headerSigned SimpleHeader{HeaderHash
(SimpleBlock' c (SimplePraosExt c c') (SimplePraosExt c c'))
SimpleStdHeader c (SimplePraosExt c c')
SimplePraosExt c c'
simpleHeaderHash :: HeaderHash
(SimpleBlock' c (SimplePraosExt c c') (SimplePraosExt c c'))
simpleHeaderStd :: SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderExt :: SimplePraosExt c c'
simpleHeaderHash :: forall c ext ext'.
Header (SimpleBlock' c ext ext')
-> HeaderHash (SimpleBlock' c ext ext')
simpleHeaderStd :: forall c ext ext'.
Header (SimpleBlock' c ext ext') -> SimpleStdHeader c ext
simpleHeaderExt :: forall c ext ext'. Header (SimpleBlock' c ext ext') -> ext'
..} = SignedSimplePraos {
signedSimplePraos :: SimpleStdHeader c (SimplePraosExt c c')
signedSimplePraos = SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderStd
, signedPraosFields :: PraosExtraFields c'
signedPraosFields = PraosFields c' (SignedSimplePraos c c') -> PraosExtraFields c'
forall crypto typeBeingSigned.
PraosFields crypto typeBeingSigned -> PraosExtraFields crypto
praosExtraFields (SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c')
forall c c'.
SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c')
simplePraosExt SimplePraosExt c c'
simpleHeaderExt)
}
instance ( SimpleCrypto c
, PraosCrypto c'
) => RunMockBlock c (SimplePraosExt c c') where
mockNetworkMagic :: BlockConfig (SimpleBlock c (SimplePraosExt c c')) -> NetworkMagic
mockNetworkMagic = NetworkMagic
-> BlockConfig (SimpleBlock c (SimplePraosExt c c'))
-> NetworkMagic
forall a b. a -> b -> a
const NetworkMagic
HasCallStack => NetworkMagic
constructMockNetworkMagic
instance ( SimpleCrypto c
, PraosCrypto c'
, Signable (PraosKES c') (SignedSimplePraos c c')
) => BlockSupportsProtocol (SimpleBlock c (SimplePraosExt c c')) where
validateView :: BlockConfig (SimpleBlock c (SimplePraosExt c c'))
-> Header (SimpleBlock c (SimplePraosExt c c'))
-> ValidateView
(BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
validateView BlockConfig (SimpleBlock c (SimplePraosExt c c'))
_ = (Header (SimpleBlock c (SimplePraosExt c c'))
-> PraosFields
c' (Signed (Header (SimpleBlock c (SimplePraosExt c c')))))
-> Header (SimpleBlock c (SimplePraosExt c c'))
-> PraosValidateView c'
forall hdr c.
(SignedHeader hdr, Signable (PraosKES c) (Signed hdr)) =>
(hdr -> PraosFields c (Signed hdr)) -> hdr -> PraosValidateView c
praosValidateView (SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c')
forall c c'.
SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c')
simplePraosExt (SimplePraosExt c c' -> PraosFields c' (SignedSimplePraos c c'))
-> (Header (SimpleBlock c (SimplePraosExt c c'))
-> SimplePraosExt c c')
-> Header (SimpleBlock c (SimplePraosExt c c'))
-> PraosFields c' (SignedSimplePraos c c')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header (SimpleBlock c (SimplePraosExt c c')) -> SimplePraosExt c c'
forall c ext ext'. Header (SimpleBlock' c ext ext') -> ext'
simpleHeaderExt)
instance ( SimpleCrypto c
, PraosCrypto c'
, Signable (PraosKES c') (SignedSimplePraos c c')
) => LedgerSupportsProtocol (SimplePraosBlock c c') where
protocolLedgerView :: LedgerConfig (SimplePraosBlock c c')
-> Ticked (LedgerState (SimplePraosBlock c c'))
-> LedgerView (BlockProtocol (SimplePraosBlock c c'))
protocolLedgerView LedgerConfig (SimplePraosBlock c c')
_ Ticked (LedgerState (SimplePraosBlock c c'))
_ = ()
ledgerViewForecastAt :: HasCallStack =>
LedgerConfig (SimplePraosBlock c c')
-> LedgerState (SimplePraosBlock c c')
-> Forecast (LedgerView (BlockProtocol (SimplePraosBlock c c')))
ledgerViewForecastAt LedgerConfig (SimplePraosBlock c c')
_ LedgerState (SimplePraosBlock c c')
st = () -> WithOrigin SlotNo -> Forecast ()
forall a. a -> WithOrigin SlotNo -> Forecast a
constantForecastOf () (LedgerState (SimplePraosBlock c c') -> WithOrigin SlotNo
forall l. GetTip l => l -> WithOrigin SlotNo
getTipSlot LedgerState (SimplePraosBlock c c')
st)
type instance CannotForge (SimplePraosBlock c c') = Void
type instance ForgeStateInfo (SimplePraosBlock c c') = HotKey c'
type instance ForgeStateUpdateError (SimplePraosBlock c c') =
HotKeyEvolutionError
forgePraosExt :: forall c c'.
( SimpleCrypto c
, PraosCrypto c'
, Signable (PraosKES c') (SignedSimplePraos c c')
)
=> HotKey c'
-> ForgeExt c (SimplePraosExt c c')
forgePraosExt :: forall c c'.
(SimpleCrypto c, PraosCrypto c',
Signable (PraosKES c') (SignedSimplePraos c c')) =>
HotKey c' -> ForgeExt c (SimplePraosExt c c')
forgePraosExt HotKey c'
hotKey = (TopLevelConfig (SimpleBlock c (SimplePraosExt c c'))
-> IsLeader (BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
-> SimpleBlock' c (SimplePraosExt c c') ()
-> SimpleBlock c (SimplePraosExt c c'))
-> ForgeExt c (SimplePraosExt c c')
forall c ext.
(TopLevelConfig (SimpleBlock c ext)
-> IsLeader (BlockProtocol (SimpleBlock c ext))
-> SimpleBlock' c ext ()
-> SimpleBlock c ext)
-> ForgeExt c ext
ForgeExt ((TopLevelConfig (SimpleBlock c (SimplePraosExt c c'))
-> IsLeader (BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
-> SimpleBlock' c (SimplePraosExt c c') ()
-> SimpleBlock c (SimplePraosExt c c'))
-> ForgeExt c (SimplePraosExt c c'))
-> (TopLevelConfig (SimpleBlock c (SimplePraosExt c c'))
-> IsLeader (BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
-> SimpleBlock' c (SimplePraosExt c c') ()
-> SimpleBlock c (SimplePraosExt c c'))
-> ForgeExt c (SimplePraosExt c c')
forall a b. (a -> b) -> a -> b
$ \TopLevelConfig (SimpleBlock c (SimplePraosExt c c'))
_cfg IsLeader (BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
isLeader SimpleBlock{Header (SimpleBlock' c (SimplePraosExt c c') ())
SimpleBody
simpleHeader :: forall c ext ext'.
SimpleBlock' c ext ext' -> Header (SimpleBlock' c ext ext')
simpleHeader :: Header (SimpleBlock' c (SimplePraosExt c c') ())
simpleBody :: SimpleBody
simpleBody :: forall c ext ext'. SimpleBlock' c ext ext' -> SimpleBody
..} ->
let SimpleHeader{()
HeaderHash (SimpleBlock' c (SimplePraosExt c c') ())
SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderHash :: forall c ext ext'.
Header (SimpleBlock' c ext ext')
-> HeaderHash (SimpleBlock' c ext ext')
simpleHeaderStd :: forall c ext ext'.
Header (SimpleBlock' c ext ext') -> SimpleStdHeader c ext
simpleHeaderExt :: forall c ext ext'. Header (SimpleBlock' c ext ext') -> ext'
simpleHeaderHash :: HeaderHash (SimpleBlock' c (SimplePraosExt c c') ())
simpleHeaderStd :: SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderExt :: ()
..} = Header (SimpleBlock' c (SimplePraosExt c c') ())
simpleHeader
ext :: SimplePraosExt c c'
ext :: SimplePraosExt c c'
ext = PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c'
forall c c'.
PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c'
SimplePraosExt (PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c')
-> PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c'
forall a b. (a -> b) -> a -> b
$
PraosProof c'
-> HotKey c'
-> (PraosExtraFields c' -> SignedSimplePraos c c')
-> PraosFields c' (SignedSimplePraos c c')
forall c toSign.
(PraosCrypto c, Signable (PraosKES c) toSign, HasCallStack) =>
PraosProof c
-> HotKey c
-> (PraosExtraFields c -> toSign)
-> PraosFields c toSign
forgePraosFields IsLeader (BlockProtocol (SimpleBlock c (SimplePraosExt c c')))
PraosProof c'
isLeader HotKey c'
hotKey ((PraosExtraFields c' -> SignedSimplePraos c c')
-> PraosFields c' (SignedSimplePraos c c'))
-> (PraosExtraFields c' -> SignedSimplePraos c c')
-> PraosFields c' (SignedSimplePraos c c')
forall a b. (a -> b) -> a -> b
$ \PraosExtraFields c'
praosExtraFields ->
SignedSimplePraos {
signedSimplePraos :: SimpleStdHeader c (SimplePraosExt c c')
signedSimplePraos = SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderStd
, signedPraosFields :: PraosExtraFields c'
signedPraosFields = PraosExtraFields c'
praosExtraFields
}
in SimpleBlock {
simpleHeader :: Header (SimpleBlock c (SimplePraosExt c c'))
simpleHeader = (SimplePraosExt c c' -> Encoding)
-> SimpleStdHeader c (SimplePraosExt c c')
-> SimplePraosExt c c'
-> Header (SimpleBlock c (SimplePraosExt c c'))
forall c ext' ext.
SimpleCrypto c =>
(ext' -> Encoding)
-> SimpleStdHeader c ext
-> ext'
-> Header (SimpleBlock' c ext ext')
mkSimpleHeader SimplePraosExt c c' -> Encoding
forall a. Serialise a => a -> Encoding
encode SimpleStdHeader c (SimplePraosExt c c')
simpleHeaderStd SimplePraosExt c c'
ext
, simpleBody :: SimpleBody
simpleBody = SimpleBody
simpleBody
}
instance PraosCrypto c' => Serialise (SimplePraosExt c c') where
encode :: SimplePraosExt c c' -> Encoding
encode (SimplePraosExt PraosFields{SignedKES (PraosKES c') (SignedSimplePraos c c')
PraosExtraFields c'
praosExtraFields :: forall crypto typeBeingSigned.
PraosFields crypto typeBeingSigned -> PraosExtraFields crypto
praosSignature :: SignedKES (PraosKES c') (SignedSimplePraos c c')
praosExtraFields :: PraosExtraFields c'
praosSignature :: forall crypto typeBeingSigned.
PraosFields crypto typeBeingSigned
-> SignedKES (PraosKES crypto) typeBeingSigned
..}) = [Encoding] -> Encoding
forall a. Monoid a => [a] -> a
mconcat [
SignedKES (PraosKES c') (SignedSimplePraos c c') -> Encoding
forall v a. KESAlgorithm v => SignedKES v a -> Encoding
encodeSignedKES SignedKES (PraosKES c') (SignedSimplePraos c c')
praosSignature
, PraosExtraFields c' -> Encoding
forall c'. PraosCrypto c' => PraosExtraFields c' -> Encoding
encodePraosExtraFields PraosExtraFields c'
praosExtraFields
]
decode :: forall s. Decoder s (SimplePraosExt c c')
decode = do
SignedKES (PraosKES c') (SignedSimplePraos c c')
praosSignature <- Decoder s (SignedKES (PraosKES c') (SignedSimplePraos c c'))
forall v s a. KESAlgorithm v => Decoder s (SignedKES v a)
decodeSignedKES
PraosExtraFields c'
praosExtraFields <- Decoder s (PraosExtraFields c')
forall s c'. PraosCrypto c' => Decoder s (PraosExtraFields c')
decodePraosExtraFields
SimplePraosExt c c' -> Decoder s (SimplePraosExt c c')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return (SimplePraosExt c c' -> Decoder s (SimplePraosExt c c'))
-> SimplePraosExt c c' -> Decoder s (SimplePraosExt c c')
forall a b. (a -> b) -> a -> b
$ PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c'
forall c c'.
PraosFields c' (SignedSimplePraos c c') -> SimplePraosExt c c'
SimplePraosExt PraosFields{SignedKES (PraosKES c') (SignedSimplePraos c c')
PraosExtraFields c'
praosExtraFields :: PraosExtraFields c'
praosSignature :: SignedKES (PraosKES c') (SignedSimplePraos c c')
praosSignature :: SignedKES (PraosKES c') (SignedSimplePraos c c')
praosExtraFields :: PraosExtraFields c'
..}
instance (SimpleCrypto c, PraosCrypto c')
=> ToCBOR (SignedSimplePraos c c') where
toCBOR :: SignedSimplePraos c c' -> Encoding
toCBOR SignedSimplePraos{SimpleStdHeader c (SimplePraosExt c c')
PraosExtraFields c'
signedSimplePraos :: forall c c'.
SignedSimplePraos c c' -> SimpleStdHeader c (SimplePraosExt c c')
signedPraosFields :: forall c c'. SignedSimplePraos c c' -> PraosExtraFields c'
signedSimplePraos :: SimpleStdHeader c (SimplePraosExt c c')
signedPraosFields :: PraosExtraFields c'
..} = [Encoding] -> Encoding
forall a. Monoid a => [a] -> a
mconcat [
SimpleStdHeader c (SimplePraosExt c c') -> Encoding
forall a. Serialise a => a -> Encoding
encode SimpleStdHeader c (SimplePraosExt c c')
signedSimplePraos
, PraosExtraFields c' -> Encoding
forall c'. PraosCrypto c' => PraosExtraFields c' -> Encoding
encodePraosExtraFields PraosExtraFields c'
signedPraosFields
]
instance (SimpleCrypto c, PraosCrypto c')
=> SignableRepresentation (SignedSimplePraos c c') where
getSignableRepresentation :: SignedSimplePraos c c' -> ByteString
getSignableRepresentation = SignedSimplePraos c c' -> ByteString
forall a. ToCBOR a => a -> ByteString
serialize'
encodePraosExtraFields :: PraosCrypto c' => PraosExtraFields c' -> CBOR.Encoding
PraosExtraFields{CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
CoreNodeId
praosCreator :: CoreNodeId
praosRho :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosY :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosCreator :: forall c. PraosExtraFields c -> CoreNodeId
praosRho :: forall c.
PraosExtraFields c
-> CertifiedVRF (PraosVRF c) (Natural, SlotNo, VRFType)
praosY :: forall c.
PraosExtraFields c
-> CertifiedVRF (PraosVRF c) (Natural, SlotNo, VRFType)
..} = [Encoding] -> Encoding
forall a. Monoid a => [a] -> a
mconcat [
CoreNodeId -> Encoding
forall a. Serialise a => a -> Encoding
encode CoreNodeId
praosCreator
, CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosRho
, CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosY
]
decodePraosExtraFields :: forall s c'. PraosCrypto c'
=> CBOR.Decoder s (PraosExtraFields c')
= do
CoreNodeId
praosCreator <- Decoder s CoreNodeId
forall s. Decoder s CoreNodeId
forall a s. Serialise a => Decoder s a
decode
CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosRho <- Decoder s (CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType))
forall s.
Decoder s (CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType))
forall a s. FromCBOR a => Decoder s a
fromCBOR
CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosY <- Decoder s (CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType))
forall s.
Decoder s (CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType))
forall a s. FromCBOR a => Decoder s a
fromCBOR
PraosExtraFields c' -> Decoder s (PraosExtraFields c')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return PraosExtraFields{CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
CoreNodeId
praosCreator :: CoreNodeId
praosRho :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosY :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosCreator :: CoreNodeId
praosRho :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
praosY :: CertifiedVRF (PraosVRF c') (Natural, SlotNo, VRFType)
..}
instance PraosCrypto c' => EncodeDisk (SimplePraosBlock c c') (PraosChainDepState c')
instance PraosCrypto c' => DecodeDisk (SimplePraosBlock c c') (PraosChainDepState c')