Skip to content

Commit e8c8282

Browse files
committed
Introduce O.C.Peras.Params
1 parent 85525a1 commit e8c8282

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

ouroboros-consensus/ouroboros-consensus.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ library
206206
Ouroboros.Consensus.Node.Run
207207
Ouroboros.Consensus.Node.Serialisation
208208
Ouroboros.Consensus.NodeId
209+
Ouroboros.Consensus.Peras.Params
209210
Ouroboros.Consensus.Peras.SelectView
210211
Ouroboros.Consensus.Peras.Weight
211212
Ouroboros.Consensus.Protocol.Abstract
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{-# LANGUAGE DeriveAnyClass #-}
2+
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingVia #-}
4+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
6+
-- | Peras protocol parameters
7+
module Ouroboros.Consensus.Peras.Params
8+
( PerasIgnoranceRounds (..)
9+
, PerasCooldownRounds (..)
10+
, PerasBlockMinSlots (..)
11+
, PerasCertArrivalThreshold (..)
12+
, PerasParams (..)
13+
)
14+
where
15+
16+
import Data.Word (Word64)
17+
import GHC.Generics (Generic)
18+
import Ouroboros.Consensus.Util.IOLike (NoThunks)
19+
import Quiet (Quiet (..))
20+
21+
{-------------------------------------------------------------------------------
22+
Protocol parameters
23+
-------------------------------------------------------------------------------}
24+
25+
-- | Number of rounds for which to ignore certificates after entering a
26+
-- cooldown period.
27+
newtype PerasIgnoranceRounds
28+
= PerasIgnoranceRounds {unPerasIgnoranceRounds :: Word64}
29+
deriving Show via Quiet PerasIgnoranceRounds
30+
deriving stock Generic
31+
deriving newtype (Enum, Eq, Ord, NoThunks)
32+
33+
-- | Minimum number of rounds to wait before voting again after a cooldown
34+
-- period starts.
35+
newtype PerasCooldownRounds
36+
= PerasCooldownRounds {unPerasCooldownRounds :: Word64}
37+
deriving Show via Quiet PerasCooldownRounds
38+
deriving stock Generic
39+
deriving newtype (Enum, Eq, Ord, NoThunks)
40+
41+
-- | Minimum age (in slots) of a block to be voted on at the beginning of a
42+
-- Peras round.
43+
newtype PerasBlockMinSlots
44+
= PerasBlockMinSlots {unPerasBlockMinSlots :: Word64}
45+
deriving Show via Quiet PerasBlockMinSlots
46+
deriving stock Generic
47+
deriving newtype (Enum, Eq, Ord, NoThunks)
48+
49+
-- | Maximum number of slots to after the start of a round to consider a
50+
-- certificate for voting.
51+
newtype PerasCertArrivalThreshold
52+
= PerasCertArrivalThreshold {unPerasCertArrivalThreshold :: Word64}
53+
deriving Show via Quiet PerasCertArrivalThreshold
54+
deriving stock Generic
55+
deriving newtype (Enum, Eq, Ord, NoThunks)
56+
57+
{-------------------------------------------------------------------------------
58+
Protocol parameters bundle
59+
-------------------------------------------------------------------------------}
60+
61+
data PerasParams = PerasParams
62+
{ perasIgnoranceRounds :: PerasIgnoranceRounds
63+
, perasCooldownRounds :: PerasCooldownRounds
64+
, perasBlockMinSlots :: PerasBlockMinSlots
65+
, perasCertArrivalThreshold :: PerasCertArrivalThreshold
66+
}
67+
deriving (Show, Generic, NoThunks)

0 commit comments

Comments
 (0)