{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module Ouroboros.Consensus.Block.SupportsPeras
  ( PerasRoundNo (..)
  , PerasWeight (..)
  , boostPerCert
  , BlockSupportsPeras (..)
  , PerasCert (..)
  , ValidatedPerasCert (..)
  , makePerasCfg
  , HasPerasCert (..)
  , getPerasCertRound
  , getPerasCertBoostedBlock
  , getPerasCertBoost

    -- * Ouroboros Peras round length
  , PerasRoundLength (..)
  , defaultPerasRoundLength
  ) where

import Codec.Serialise (Serialise (..))
import Codec.Serialise.Decoding (decodeListLenOf)
import Codec.Serialise.Encoding (encodeListLen)
import Data.Monoid (Sum (..))
import Data.Proxy (Proxy (..))
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class
import Ouroboros.Consensus.Block.Abstract
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.Condense
import Quiet (Quiet (..))

newtype PerasRoundNo = PerasRoundNo {PerasRoundNo -> Word64
unPerasRoundNo :: Word64}
  deriving Int -> PerasRoundNo -> ShowS
[PerasRoundNo] -> ShowS
PerasRoundNo -> String
(Int -> PerasRoundNo -> ShowS)
-> (PerasRoundNo -> String)
-> ([PerasRoundNo] -> ShowS)
-> Show PerasRoundNo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasRoundNo -> ShowS
showsPrec :: Int -> PerasRoundNo -> ShowS
$cshow :: PerasRoundNo -> String
show :: PerasRoundNo -> String
$cshowList :: [PerasRoundNo] -> ShowS
showList :: [PerasRoundNo] -> ShowS
Show via Quiet PerasRoundNo
  deriving stock (forall x. PerasRoundNo -> Rep PerasRoundNo x)
-> (forall x. Rep PerasRoundNo x -> PerasRoundNo)
-> Generic PerasRoundNo
forall x. Rep PerasRoundNo x -> PerasRoundNo
forall x. PerasRoundNo -> Rep PerasRoundNo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasRoundNo -> Rep PerasRoundNo x
from :: forall x. PerasRoundNo -> Rep PerasRoundNo x
$cto :: forall x. Rep PerasRoundNo x -> PerasRoundNo
to :: forall x. Rep PerasRoundNo x -> PerasRoundNo
Generic
  deriving newtype (Int -> PerasRoundNo
PerasRoundNo -> Int
PerasRoundNo -> [PerasRoundNo]
PerasRoundNo -> PerasRoundNo
PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
(PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo)
-> (Int -> PerasRoundNo)
-> (PerasRoundNo -> Int)
-> (PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> Enum PerasRoundNo
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 :: PerasRoundNo -> PerasRoundNo
succ :: PerasRoundNo -> PerasRoundNo
$cpred :: PerasRoundNo -> PerasRoundNo
pred :: PerasRoundNo -> PerasRoundNo
$ctoEnum :: Int -> PerasRoundNo
toEnum :: Int -> PerasRoundNo
$cfromEnum :: PerasRoundNo -> Int
fromEnum :: PerasRoundNo -> Int
$cenumFrom :: PerasRoundNo -> [PerasRoundNo]
enumFrom :: PerasRoundNo -> [PerasRoundNo]
$cenumFromThen :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromThen :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
$cenumFromTo :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromTo :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
$cenumFromThenTo :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromThenTo :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
Enum, PerasRoundNo -> PerasRoundNo -> Bool
(PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool) -> Eq PerasRoundNo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasRoundNo -> PerasRoundNo -> Bool
== :: PerasRoundNo -> PerasRoundNo -> Bool
$c/= :: PerasRoundNo -> PerasRoundNo -> Bool
/= :: PerasRoundNo -> PerasRoundNo -> Bool
Eq, Eq PerasRoundNo
Eq PerasRoundNo =>
(PerasRoundNo -> PerasRoundNo -> Ordering)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> Ord PerasRoundNo
PerasRoundNo -> PerasRoundNo -> Bool
PerasRoundNo -> PerasRoundNo -> Ordering
PerasRoundNo -> PerasRoundNo -> PerasRoundNo
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 :: PerasRoundNo -> PerasRoundNo -> Ordering
compare :: PerasRoundNo -> PerasRoundNo -> Ordering
$c< :: PerasRoundNo -> PerasRoundNo -> Bool
< :: PerasRoundNo -> PerasRoundNo -> Bool
$c<= :: PerasRoundNo -> PerasRoundNo -> Bool
<= :: PerasRoundNo -> PerasRoundNo -> Bool
$c> :: PerasRoundNo -> PerasRoundNo -> Bool
> :: PerasRoundNo -> PerasRoundNo -> Bool
$c>= :: PerasRoundNo -> PerasRoundNo -> Bool
>= :: PerasRoundNo -> PerasRoundNo -> Bool
$cmax :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
max :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
$cmin :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
min :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
Ord, Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
Proxy PerasRoundNo -> String
(Context -> PerasRoundNo -> IO (Maybe ThunkInfo))
-> (Context -> PerasRoundNo -> IO (Maybe ThunkInfo))
-> (Proxy PerasRoundNo -> String)
-> NoThunks PerasRoundNo
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasRoundNo -> String
showTypeOf :: Proxy PerasRoundNo -> String
NoThunks, [PerasRoundNo] -> Encoding
PerasRoundNo -> Encoding
(PerasRoundNo -> Encoding)
-> (forall s. Decoder s PerasRoundNo)
-> ([PerasRoundNo] -> Encoding)
-> (forall s. Decoder s [PerasRoundNo])
-> Serialise PerasRoundNo
forall s. Decoder s [PerasRoundNo]
forall s. Decoder s PerasRoundNo
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: PerasRoundNo -> Encoding
encode :: PerasRoundNo -> Encoding
$cdecode :: forall s. Decoder s PerasRoundNo
decode :: forall s. Decoder s PerasRoundNo
$cencodeList :: [PerasRoundNo] -> Encoding
encodeList :: [PerasRoundNo] -> Encoding
$cdecodeList :: forall s. Decoder s [PerasRoundNo]
decodeList :: forall s. Decoder s [PerasRoundNo]
Serialise)

instance Condense PerasRoundNo where
  condense :: PerasRoundNo -> String
condense = Word64 -> String
forall a. Show a => a -> String
show (Word64 -> String)
-> (PerasRoundNo -> Word64) -> PerasRoundNo -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PerasRoundNo -> Word64
unPerasRoundNo

instance ShowProxy PerasRoundNo where
  showProxy :: Proxy PerasRoundNo -> String
showProxy Proxy PerasRoundNo
_ = String
"PerasRoundNo"

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 (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)
  deriving (NonEmpty PerasWeight -> PerasWeight
PerasWeight -> PerasWeight -> PerasWeight
(PerasWeight -> PerasWeight -> PerasWeight)
-> (NonEmpty PerasWeight -> PerasWeight)
-> (forall b. Integral b => b -> PerasWeight -> PerasWeight)
-> Semigroup PerasWeight
forall b. Integral b => b -> PerasWeight -> PerasWeight
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: PerasWeight -> PerasWeight -> PerasWeight
<> :: PerasWeight -> PerasWeight -> PerasWeight
$csconcat :: NonEmpty PerasWeight -> PerasWeight
sconcat :: NonEmpty PerasWeight -> PerasWeight
$cstimes :: forall b. Integral b => b -> PerasWeight -> PerasWeight
stimes :: forall b. Integral b => b -> PerasWeight -> PerasWeight
Semigroup, Semigroup PerasWeight
PerasWeight
Semigroup PerasWeight =>
PerasWeight
-> (PerasWeight -> PerasWeight -> PerasWeight)
-> ([PerasWeight] -> PerasWeight)
-> Monoid PerasWeight
[PerasWeight] -> PerasWeight
PerasWeight -> PerasWeight -> PerasWeight
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: PerasWeight
mempty :: PerasWeight
$cmappend :: PerasWeight -> PerasWeight -> PerasWeight
mappend :: PerasWeight -> PerasWeight -> PerasWeight
$cmconcat :: [PerasWeight] -> PerasWeight
mconcat :: [PerasWeight] -> PerasWeight
Monoid) via Sum Word64

instance Condense PerasWeight where
  condense :: PerasWeight -> String
condense = Word64 -> String
forall a. Show a => a -> String
show (Word64 -> String)
-> (PerasWeight -> Word64) -> PerasWeight -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PerasWeight -> Word64
unPerasWeight

-- | TODO: this will become a Ledger protocol parameter
-- see https://github.com/tweag/cardano-peras/issues/119
boostPerCert :: PerasWeight
boostPerCert :: PerasWeight
boostPerCert = Word64 -> PerasWeight
PerasWeight Word64
15

-- TODO using 'Validated' for extra safety? Or some @.Unsafe@ module?
data ValidatedPerasCert blk = ValidatedPerasCert
  { forall blk. ValidatedPerasCert blk -> PerasCert blk
vpcCert :: !(PerasCert blk)
  , forall blk. ValidatedPerasCert blk -> PerasWeight
vpcCertBoost :: !PerasWeight
  }
  deriving stock (Int -> ValidatedPerasCert blk -> ShowS
[ValidatedPerasCert blk] -> ShowS
ValidatedPerasCert blk -> String
(Int -> ValidatedPerasCert blk -> ShowS)
-> (ValidatedPerasCert blk -> String)
-> ([ValidatedPerasCert blk] -> ShowS)
-> Show (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
Int -> ValidatedPerasCert blk -> ShowS
forall blk. StandardHash blk => [ValidatedPerasCert blk] -> ShowS
forall blk. StandardHash blk => ValidatedPerasCert blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk.
StandardHash blk =>
Int -> ValidatedPerasCert blk -> ShowS
showsPrec :: Int -> ValidatedPerasCert blk -> ShowS
$cshow :: forall blk. StandardHash blk => ValidatedPerasCert blk -> String
show :: ValidatedPerasCert blk -> String
$cshowList :: forall blk. StandardHash blk => [ValidatedPerasCert blk] -> ShowS
showList :: [ValidatedPerasCert blk] -> ShowS
Show, ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
(ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> Eq (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
== :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
/= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
Eq, Eq (ValidatedPerasCert blk)
Eq (ValidatedPerasCert blk) =>
(ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk
    -> ValidatedPerasCert blk -> ValidatedPerasCert blk)
-> (ValidatedPerasCert blk
    -> ValidatedPerasCert blk -> ValidatedPerasCert blk)
-> Ord (ValidatedPerasCert blk)
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
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 blk. StandardHash blk => Eq (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
$ccompare :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
compare :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
< :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
<= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c> :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
> :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
>= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
max :: ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
$cmin :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
min :: ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
Ord, (forall x.
 ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x)
-> (forall x.
    Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk)
-> Generic (ValidatedPerasCert blk)
forall x. Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
forall x. ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x.
Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
forall blk x.
ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
$cfrom :: forall blk x.
ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
from :: forall x. ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
$cto :: forall blk x.
Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
to :: forall x. Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
Generic)
  deriving anyclass Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
Proxy (ValidatedPerasCert blk) -> String
(Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo))
-> (Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo))
-> (Proxy (ValidatedPerasCert blk) -> String)
-> NoThunks (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
forall blk.
StandardHash blk =>
Proxy (ValidatedPerasCert blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk.
StandardHash blk =>
Proxy (ValidatedPerasCert blk) -> String
showTypeOf :: Proxy (ValidatedPerasCert blk) -> String
NoThunks

{-------------------------------------------------------------------------------
  Ouroboros Peras round length
-------------------------------------------------------------------------------}

newtype PerasRoundLength = PerasRoundLength {PerasRoundLength -> Word64
unPerasRoundLength :: Word64}
  deriving stock (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, 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)
  deriving newtype (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, Integer -> PerasRoundLength
PerasRoundLength -> PerasRoundLength
PerasRoundLength -> PerasRoundLength -> PerasRoundLength
(PerasRoundLength -> PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength)
-> (PerasRoundLength -> PerasRoundLength)
-> (Integer -> PerasRoundLength)
-> Num PerasRoundLength
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
+ :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
$c- :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
- :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
$c* :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
* :: PerasRoundLength -> PerasRoundLength -> PerasRoundLength
$cnegate :: PerasRoundLength -> PerasRoundLength
negate :: PerasRoundLength -> PerasRoundLength
$cabs :: PerasRoundLength -> PerasRoundLength
abs :: PerasRoundLength -> PerasRoundLength
$csignum :: PerasRoundLength -> PerasRoundLength
signum :: PerasRoundLength -> PerasRoundLength
$cfromInteger :: Integer -> PerasRoundLength
fromInteger :: Integer -> PerasRoundLength
Num)

-- | See the Protocol parameters section of the Peras design report:
--   https://tweag.github.io/cardano-peras/peras-design.pdf#section.2.1
-- TODO: this will become a Ledger protocol parameter
-- see https://github.com/tweag/cardano-peras/issues/119
defaultPerasRoundLength :: PerasRoundLength
defaultPerasRoundLength :: PerasRoundLength
defaultPerasRoundLength = PerasRoundLength
90

class
  ( Show (PerasCfg blk)
  , NoThunks (PerasCert blk)
  ) =>
  BlockSupportsPeras blk
  where
  data PerasCfg blk

  data PerasCert blk

  data PerasValidationErr blk

  validatePerasCert ::
    PerasCfg blk ->
    PerasCert blk ->
    Either (PerasValidationErr blk) (ValidatedPerasCert blk)

-- TODO: degenerate instance for all blks to get things to compile
-- see https://github.com/tweag/cardano-peras/issues/73
instance StandardHash blk => BlockSupportsPeras blk where
  newtype PerasCfg blk = PerasCfg
    { -- TODO: eventually, this will come from the
      -- protocol parameters from the ledger state
      -- see https://github.com/tweag/cardano-peras/issues/119
      forall blk. PerasCfg blk -> PerasWeight
perasCfgWeightBoost :: PerasWeight
    }
    deriving stock (Int -> PerasCfg blk -> ShowS
[PerasCfg blk] -> ShowS
PerasCfg blk -> String
(Int -> PerasCfg blk -> ShowS)
-> (PerasCfg blk -> String)
-> ([PerasCfg blk] -> ShowS)
-> Show (PerasCfg blk)
forall blk. Int -> PerasCfg blk -> ShowS
forall blk. [PerasCfg blk] -> ShowS
forall blk. PerasCfg blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasCfg blk -> ShowS
showsPrec :: Int -> PerasCfg blk -> ShowS
$cshow :: forall blk. PerasCfg blk -> String
show :: PerasCfg blk -> String
$cshowList :: forall blk. [PerasCfg blk] -> ShowS
showList :: [PerasCfg blk] -> ShowS
Show, PerasCfg blk -> PerasCfg blk -> Bool
(PerasCfg blk -> PerasCfg blk -> Bool)
-> (PerasCfg blk -> PerasCfg blk -> Bool) -> Eq (PerasCfg blk)
forall blk. PerasCfg blk -> PerasCfg blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. PerasCfg blk -> PerasCfg blk -> Bool
== :: PerasCfg blk -> PerasCfg blk -> Bool
$c/= :: forall blk. PerasCfg blk -> PerasCfg blk -> Bool
/= :: PerasCfg blk -> PerasCfg blk -> Bool
Eq)

  data PerasCert blk = PerasCert
    { forall blk. PerasCert blk -> PerasRoundNo
pcCertRound :: PerasRoundNo
    , forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock :: Point blk
    }
    deriving stock ((forall x. PerasCert blk -> Rep (PerasCert blk) x)
-> (forall x. Rep (PerasCert blk) x -> PerasCert blk)
-> Generic (PerasCert blk)
forall x. Rep (PerasCert blk) x -> PerasCert blk
forall x. PerasCert blk -> Rep (PerasCert blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasCert blk) x -> PerasCert blk
forall blk x. PerasCert blk -> Rep (PerasCert blk) x
$cfrom :: forall blk x. PerasCert blk -> Rep (PerasCert blk) x
from :: forall x. PerasCert blk -> Rep (PerasCert blk) x
$cto :: forall blk x. Rep (PerasCert blk) x -> PerasCert blk
to :: forall x. Rep (PerasCert blk) x -> PerasCert blk
Generic, PerasCert blk -> PerasCert blk -> Bool
(PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool) -> Eq (PerasCert blk)
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
== :: PerasCert blk -> PerasCert blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
/= :: PerasCert blk -> PerasCert blk -> Bool
Eq, Eq (PerasCert blk)
Eq (PerasCert blk) =>
(PerasCert blk -> PerasCert blk -> Ordering)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> PerasCert blk)
-> (PerasCert blk -> PerasCert blk -> PerasCert blk)
-> Ord (PerasCert blk)
PerasCert blk -> PerasCert blk -> Bool
PerasCert blk -> PerasCert blk -> Ordering
PerasCert blk -> PerasCert blk -> PerasCert blk
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 blk. StandardHash blk => Eq (PerasCert blk)
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Ordering
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
$ccompare :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Ordering
compare :: PerasCert blk -> PerasCert blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
< :: PerasCert blk -> PerasCert blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
<= :: PerasCert blk -> PerasCert blk -> Bool
$c> :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
> :: PerasCert blk -> PerasCert blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
>= :: PerasCert blk -> PerasCert blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
max :: PerasCert blk -> PerasCert blk -> PerasCert blk
$cmin :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
min :: PerasCert blk -> PerasCert blk -> PerasCert blk
Ord, Int -> PerasCert blk -> ShowS
[PerasCert blk] -> ShowS
PerasCert blk -> String
(Int -> PerasCert blk -> ShowS)
-> (PerasCert blk -> String)
-> ([PerasCert blk] -> ShowS)
-> Show (PerasCert blk)
forall blk. StandardHash blk => Int -> PerasCert blk -> ShowS
forall blk. StandardHash blk => [PerasCert blk] -> ShowS
forall blk. StandardHash blk => PerasCert blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> PerasCert blk -> ShowS
showsPrec :: Int -> PerasCert blk -> ShowS
$cshow :: forall blk. StandardHash blk => PerasCert blk -> String
show :: PerasCert blk -> String
$cshowList :: forall blk. StandardHash blk => [PerasCert blk] -> ShowS
showList :: [PerasCert blk] -> ShowS
Show)
    deriving anyclass Context -> PerasCert blk -> IO (Maybe ThunkInfo)
Proxy (PerasCert blk) -> String
(Context -> PerasCert blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasCert blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasCert blk) -> String)
-> NoThunks (PerasCert blk)
forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
forall blk. StandardHash blk => Proxy (PerasCert blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasCert blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasCert blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. StandardHash blk => Proxy (PerasCert blk) -> String
showTypeOf :: Proxy (PerasCert blk) -> String
NoThunks

  -- TODO: enrich with actual error types
  -- see https://github.com/tweag/cardano-peras/issues/120
  data PerasValidationErr blk
    = PerasValidationErr
    deriving stock (Int -> PerasValidationErr blk -> ShowS
[PerasValidationErr blk] -> ShowS
PerasValidationErr blk -> String
(Int -> PerasValidationErr blk -> ShowS)
-> (PerasValidationErr blk -> String)
-> ([PerasValidationErr blk] -> ShowS)
-> Show (PerasValidationErr blk)
forall blk. Int -> PerasValidationErr blk -> ShowS
forall blk. [PerasValidationErr blk] -> ShowS
forall blk. PerasValidationErr blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasValidationErr blk -> ShowS
showsPrec :: Int -> PerasValidationErr blk -> ShowS
$cshow :: forall blk. PerasValidationErr blk -> String
show :: PerasValidationErr blk -> String
$cshowList :: forall blk. [PerasValidationErr blk] -> ShowS
showList :: [PerasValidationErr blk] -> ShowS
Show, PerasValidationErr blk -> PerasValidationErr blk -> Bool
(PerasValidationErr blk -> PerasValidationErr blk -> Bool)
-> (PerasValidationErr blk -> PerasValidationErr blk -> Bool)
-> Eq (PerasValidationErr blk)
forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
== :: PerasValidationErr blk -> PerasValidationErr blk -> Bool
$c/= :: forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
/= :: PerasValidationErr blk -> PerasValidationErr blk -> Bool
Eq)

  -- TODO: perform actual validation against all
  -- possible 'PerasValidationErr' variants
  -- see https://github.com/tweag/cardano-peras/issues/120
  validatePerasCert :: PerasCfg blk
-> PerasCert blk
-> Either (PerasValidationErr blk) (ValidatedPerasCert blk)
validatePerasCert PerasCfg blk
cfg PerasCert blk
cert =
    ValidatedPerasCert blk
-> Either (PerasValidationErr blk) (ValidatedPerasCert blk)
forall a b. b -> Either a b
Right
      ValidatedPerasCert
        { vpcCert :: PerasCert blk
vpcCert = PerasCert blk
cert
        , vpcCertBoost :: PerasWeight
vpcCertBoost = PerasCfg blk -> PerasWeight
forall blk. PerasCfg blk -> PerasWeight
perasCfgWeightBoost PerasCfg blk
cfg
        }

instance ShowProxy blk => ShowProxy (PerasCert blk) where
  showProxy :: Proxy (PerasCert blk) -> String
showProxy Proxy (PerasCert blk)
_ = String
"PerasCert " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy blk -> String
forall {k} (p :: k). ShowProxy p => Proxy p -> String
showProxy (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @blk)

instance Serialise (HeaderHash blk) => Serialise (PerasCert blk) where
  encode :: PerasCert blk -> Encoding
encode PerasCert{PerasRoundNo
pcCertRound :: forall blk. PerasCert blk -> PerasRoundNo
pcCertRound :: PerasRoundNo
pcCertRound, Point blk
pcCertBoostedBlock :: forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock :: Point blk
pcCertBoostedBlock} =
    Word -> Encoding
encodeListLen Word
2
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasRoundNo -> Encoding
forall a. Serialise a => a -> Encoding
encode PerasRoundNo
pcCertRound
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Point blk -> Encoding
forall a. Serialise a => a -> Encoding
encode Point blk
pcCertBoostedBlock
  decode :: forall s. Decoder s (PerasCert blk)
decode = do
    Int -> Decoder s ()
forall s. Int -> Decoder s ()
decodeListLenOf Int
2
    pcCertRound <- Decoder s PerasRoundNo
forall s. Decoder s PerasRoundNo
forall a s. Serialise a => Decoder s a
decode
    pcCertBoostedBlock <- decode
    pure $ PerasCert{pcCertRound, pcCertBoostedBlock}

-- | Derive a 'PerasCfg' from a 'BlockConfig'
--
-- TODO: this currently doesn't depend on 'BlockConfig' at all, but likely will
-- depend on it in the future
-- see https://github.com/tweag/cardano-peras/issues/73
makePerasCfg :: Maybe (BlockConfig blk) -> PerasCfg blk
makePerasCfg :: forall blk. Maybe (BlockConfig blk) -> PerasCfg blk
makePerasCfg Maybe (BlockConfig blk)
_ =
  PerasCfg
    { perasCfgWeightBoost :: PerasWeight
perasCfgWeightBoost = PerasWeight
boostPerCert
    }

class StandardHash blk => HasPerasCert cert blk where
  getPerasCert :: cert blk -> PerasCert blk

instance StandardHash blk => HasPerasCert PerasCert blk where
  getPerasCert :: PerasCert blk -> PerasCert blk
getPerasCert = PerasCert blk -> PerasCert blk
forall a. a -> a
id

instance StandardHash blk => HasPerasCert ValidatedPerasCert blk where
  getPerasCert :: ValidatedPerasCert blk -> PerasCert blk
getPerasCert = ValidatedPerasCert blk -> PerasCert blk
forall blk. ValidatedPerasCert blk -> PerasCert blk
vpcCert

getPerasCertRound :: HasPerasCert cert blk => cert blk -> PerasRoundNo
getPerasCertRound :: forall (cert :: * -> *) blk.
HasPerasCert cert blk =>
cert blk -> PerasRoundNo
getPerasCertRound = PerasCert blk -> PerasRoundNo
forall blk. PerasCert blk -> PerasRoundNo
pcCertRound (PerasCert blk -> PerasRoundNo)
-> (cert blk -> PerasCert blk) -> cert blk -> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. cert blk -> PerasCert blk
forall (cert :: * -> *) blk.
HasPerasCert cert blk =>
cert blk -> PerasCert blk
getPerasCert

getPerasCertBoostedBlock :: HasPerasCert cert blk => cert blk -> Point blk
getPerasCertBoostedBlock :: forall (cert :: * -> *) blk.
HasPerasCert cert blk =>
cert blk -> Point blk
getPerasCertBoostedBlock = PerasCert blk -> Point blk
forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock (PerasCert blk -> Point blk)
-> (cert blk -> PerasCert blk) -> cert blk -> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. cert blk -> PerasCert blk
forall (cert :: * -> *) blk.
HasPerasCert cert blk =>
cert blk -> PerasCert blk
getPerasCert

getPerasCertBoost :: ValidatedPerasCert blk -> PerasWeight
getPerasCertBoost :: forall blk. ValidatedPerasCert blk -> PerasWeight
getPerasCertBoost = ValidatedPerasCert blk -> PerasWeight
forall blk. ValidatedPerasCert blk -> PerasWeight
vpcCertBoost