Skip to content

Commit 5f46f41

Browse files
committed
Format Ouroboros/Consensus/Shelley/Node/Praos.hs
1 parent efff828 commit 5f46f41

File tree

1 file changed

+118
-125
lines changed
  • ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node

1 file changed

+118
-125
lines changed

ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node/Praos.hs

+118-125
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ import Ouroboros.Consensus.Util.IOLike (IOLike)
6969

7070
-- | Create a 'BlockForging' record for a single era.
7171
praosBlockForging ::
72-
forall m era c.
73-
( ShelleyCompatible (Praos c) era,
74-
c ~ EraCrypto era,
75-
TxLimits (ShelleyBlock (Praos c) era),
76-
IOLike m
77-
) =>
78-
PraosParams ->
79-
TxLimits.Overrides (ShelleyBlock (Praos c) era) ->
80-
ShelleyLeaderCredentials (EraCrypto era) ->
81-
m (BlockForging m (ShelleyBlock (Praos c) era))
72+
forall m era c.
73+
( ShelleyCompatible (Praos c) era
74+
, c ~ EraCrypto era
75+
, TxLimits (ShelleyBlock (Praos c) era)
76+
, IOLike m
77+
)
78+
=> PraosParams
79+
-> TxLimits.Overrides (ShelleyBlock (Praos c) era)
80+
-> ShelleyLeaderCredentials (EraCrypto era)
81+
-> m (BlockForging m (ShelleyBlock (Praos c) era))
8282
praosBlockForging praosParams maxTxCapacityOverrides credentials = do
8383
hotKey <- HotKey.mkHotKey @m @c initSignKey startPeriod praosMaxKESEvo
8484
pure $ praosSharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
@@ -102,10 +102,10 @@ praosBlockForging praosParams maxTxCapacityOverrides credentials = do
102102
-- The name of the era (separated by a @_@) will be appended to each
103103
-- 'forgeLabel'.
104104
praosSharedBlockForging ::
105-
forall m c era.
106-
( ShelleyEraWithCrypto c (Praos c) era,
107-
IOLike m
108-
)
105+
forall m c era.
106+
( ShelleyEraWithCrypto c (Praos c) era
107+
, IOLike m
108+
)
109109
=> HotKey.HotKey c m
110110
-> (SlotNo -> Absolute.KESPeriod)
111111
-> ShelleyLeaderCredentials c
@@ -114,55 +114,55 @@ praosSharedBlockForging ::
114114
praosSharedBlockForging
115115
hotKey
116116
slotToPeriod
117-
ShelleyLeaderCredentials
118-
{ shelleyLeaderCredentialsCanBeLeader = canBeLeader,
119-
shelleyLeaderCredentialsLabel = label
117+
ShelleyLeaderCredentials {
118+
shelleyLeaderCredentialsCanBeLeader = canBeLeader
119+
, shelleyLeaderCredentialsLabel = label
120120
}
121121
maxTxCapacityOverrides = do
122-
BlockForging
123-
{ forgeLabel = label <> "_" <> shelleyBasedEraName (Proxy @era),
124-
canBeLeader = canBeLeader,
125-
updateForgeState = \_ curSlot _ ->
126-
forgeStateUpdateInfoFromUpdateInfo
127-
<$> HotKey.evolve hotKey (slotToPeriod curSlot),
128-
checkCanForge = \cfg curSlot _tickedChainDepState _isLeader ->
129-
praosCheckCanForge
130-
(configConsensus cfg)
131-
curSlot,
132-
forgeBlock = \cfg ->
133-
forgeShelleyBlock
134-
hotKey
135-
canBeLeader
136-
cfg
137-
maxTxCapacityOverrides
138-
}
122+
BlockForging
123+
{ forgeLabel = label <> "_" <> shelleyBasedEraName (Proxy @era),
124+
canBeLeader = canBeLeader,
125+
updateForgeState = \_ curSlot _ ->
126+
forgeStateUpdateInfoFromUpdateInfo
127+
<$> HotKey.evolve hotKey (slotToPeriod curSlot),
128+
checkCanForge = \cfg curSlot _tickedChainDepState _isLeader ->
129+
praosCheckCanForge
130+
(configConsensus cfg)
131+
curSlot,
132+
forgeBlock = \cfg ->
133+
forgeShelleyBlock
134+
hotKey
135+
canBeLeader
136+
cfg
137+
maxTxCapacityOverrides
138+
}
139139

140140
{-------------------------------------------------------------------------------
141141
ProtocolInfo
142142
-------------------------------------------------------------------------------}
143143

144144
-- | Parameters needed to run Babbage
145-
data ProtocolParamsBabbage c = ProtocolParamsBabbage
146-
{ babbageProtVer :: SL.ProtVer,
147-
babbageMaxTxCapacityOverrides :: TxLimits.Overrides (ShelleyBlock (Praos c) (BabbageEra c))
145+
data ProtocolParamsBabbage c = ProtocolParamsBabbage {
146+
babbageProtVer :: SL.ProtVer
147+
, babbageMaxTxCapacityOverrides :: TxLimits.Overrides (ShelleyBlock (Praos c) (BabbageEra c))
148148
}
149149

150150
protocolInfoPraosBabbage ::
151-
forall m c.
152-
( IOLike m,
153-
ShelleyCompatible (Praos c) (BabbageEra c),
154-
TxLimits (ShelleyBlock (Praos c) (BabbageEra c))
155-
) =>
156-
ProtocolParamsShelleyBased (BabbageEra c) ->
157-
AlonzoGenesis ->
158-
ProtocolParamsBabbage c ->
159-
ProtocolInfo m (ShelleyBlock (Praos c) (BabbageEra c))
151+
forall m c.
152+
( IOLike m,
153+
ShelleyCompatible (Praos c) (BabbageEra c),
154+
TxLimits (ShelleyBlock (Praos c) (BabbageEra c))
155+
)
156+
=> ProtocolParamsShelleyBased (BabbageEra c)
157+
-> AlonzoGenesis
158+
-> ProtocolParamsBabbage c
159+
-> ProtocolInfo m (ShelleyBlock (Praos c) (BabbageEra c))
160160
protocolInfoPraosBabbage
161161
protocolParamsShelleyBased
162162
genesisAlonzo
163-
ProtocolParamsBabbage
164-
{ babbageProtVer = protVer,
165-
babbageMaxTxCapacityOverrides = maxTxCapacityOverrides
163+
ProtocolParamsBabbage {
164+
babbageProtVer = protVer
165+
, babbageMaxTxCapacityOverrides = maxTxCapacityOverrides
166166
} =
167167
protocolInfoPraosShelleyBased
168168
protocolParamsShelleyBased
@@ -171,27 +171,27 @@ protocolInfoPraosBabbage
171171
maxTxCapacityOverrides
172172

173173
-- | Parameters needed to run Conway
174-
data ProtocolParamsConway c = ProtocolParamsConway
175-
{ conwayProtVer :: SL.ProtVer,
176-
conwayMaxTxCapacityOverrides :: TxLimits.Overrides (ShelleyBlock (Praos c) (ConwayEra c))
174+
data ProtocolParamsConway c = ProtocolParamsConway {
175+
conwayProtVer :: SL.ProtVer
176+
, conwayMaxTxCapacityOverrides :: TxLimits.Overrides (ShelleyBlock (Praos c) (ConwayEra c))
177177
}
178178

179179
protocolInfoPraosConway ::
180-
forall m c.
181-
( IOLike m,
182-
ShelleyCompatible (Praos c) (ConwayEra c),
183-
TxLimits (ShelleyBlock (Praos c) (ConwayEra c))
184-
) =>
185-
ProtocolParamsShelleyBased (ConwayEra c) ->
186-
(AlonzoGenesis, ConwayGenesis c) ->
187-
ProtocolParamsConway c ->
188-
ProtocolInfo m (ShelleyBlock (Praos c) (ConwayEra c))
180+
forall m c.
181+
( IOLike m,
182+
ShelleyCompatible (Praos c) (ConwayEra c),
183+
TxLimits (ShelleyBlock (Praos c) (ConwayEra c))
184+
)
185+
=> ProtocolParamsShelleyBased (ConwayEra c)
186+
-> (AlonzoGenesis, ConwayGenesis c)
187+
-> ProtocolParamsConway c
188+
-> ProtocolInfo m (ShelleyBlock (Praos c) (ConwayEra c))
189189
protocolInfoPraosConway
190190
protocolParamsShelleyBased
191191
(genesisAlonzo, genesisConway)
192-
ProtocolParamsConway
193-
{ conwayProtVer = protVer,
194-
conwayMaxTxCapacityOverrides = maxTxCapacityOverrides
192+
ProtocolParamsConway {
193+
conwayProtVer = protVer
194+
, conwayMaxTxCapacityOverrides = maxTxCapacityOverrides
195195
} =
196196
protocolInfoPraosShelleyBased
197197
protocolParamsShelleyBased
@@ -200,30 +200,30 @@ protocolInfoPraosConway
200200
maxTxCapacityOverrides
201201

202202
protocolInfoPraosShelleyBased ::
203-
forall m era c.
204-
( IOLike m,
205-
ShelleyCompatible (Praos c) era,
206-
TxLimits (ShelleyBlock (Praos c) era),
207-
c ~ EraCrypto era
208-
) =>
209-
ProtocolParamsShelleyBased era ->
210-
(SL.AdditionalGenesisConfig era, Core.TranslationContext era) ->
211-
SL.ProtVer ->
212-
TxLimits.Overrides (ShelleyBlock (Praos c) era) ->
213-
ProtocolInfo m (ShelleyBlock (Praos c) era)
203+
forall m era c.
204+
( IOLike m,
205+
ShelleyCompatible (Praos c) era,
206+
TxLimits (ShelleyBlock (Praos c) era),
207+
c ~ EraCrypto era
208+
)
209+
=> ProtocolParamsShelleyBased era
210+
-> (SL.AdditionalGenesisConfig era, Core.TranslationContext era)
211+
-> SL.ProtVer
212+
-> TxLimits.Overrides (ShelleyBlock (Praos c) era)
213+
-> ProtocolInfo m (ShelleyBlock (Praos c) era)
214214
protocolInfoPraosShelleyBased
215-
ProtocolParamsShelleyBased
216-
{ shelleyBasedGenesis = genesis,
217-
shelleyBasedInitialNonce = initialNonce,
218-
shelleyBasedLeaderCredentials = credentialss
215+
ProtocolParamsShelleyBased {
216+
shelleyBasedGenesis = genesis
217+
, shelleyBasedInitialNonce = initialNonce
218+
, shelleyBasedLeaderCredentials = credentialss
219219
}
220220
(additionalGenesisConfig, transCtxt)
221221
protVer
222222
maxTxCapacityOverrides =
223223
assertWithMsg (validateGenesis genesis) $
224224
ProtocolInfo
225-
{ pInfoConfig = topLevelConfig,
226-
pInfoInitLedger = initExtLedgerState,
225+
{ pInfoConfig = topLevelConfig,
226+
pInfoInitLedger = initExtLedgerState,
227227
pInfoBlockForging =
228228
traverse
229229
(praosBlockForging praosParams maxTxCapacityOverrides)
@@ -234,20 +234,18 @@ protocolInfoPraosShelleyBased
234234
maxMajorProtVer = MaxMajorProtVer $ SL.pvMajor protVer
235235

236236
topLevelConfig :: TopLevelConfig (ShelleyBlock (Praos c) era)
237-
topLevelConfig =
238-
TopLevelConfig
239-
{ topLevelConfigProtocol = consensusConfig,
240-
topLevelConfigLedger = ledgerConfig,
241-
topLevelConfigBlock = blockConfig,
242-
topLevelConfigCodec = ShelleyCodecConfig,
243-
topLevelConfigStorage = storageConfig
237+
topLevelConfig = TopLevelConfig {
238+
topLevelConfigProtocol = consensusConfig
239+
, topLevelConfigLedger = ledgerConfig
240+
, topLevelConfigBlock = blockConfig
241+
, topLevelConfigCodec = ShelleyCodecConfig
242+
, topLevelConfigStorage = storageConfig
244243
}
245244

246245
consensusConfig :: ConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) era))
247-
consensusConfig =
248-
PraosConfig
249-
{ praosParams,
250-
praosEpochInfo = epochInfo
246+
consensusConfig = PraosConfig {
247+
praosParams
248+
, praosEpochInfo = epochInfo
251249
}
252250

253251
ledgerConfig :: LedgerConfig (ShelleyBlock (Praos c) era)
@@ -260,17 +258,16 @@ protocolInfoPraosShelleyBased
260258
(mkSlotLength $ SL.sgSlotLength genesis)
261259

262260
praosParams :: PraosParams
263-
praosParams =
264-
PraosParams
265-
{ praosSlotsPerKESPeriod = SL.sgSlotsPerKESPeriod genesis,
266-
praosLeaderF = SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesis,
267-
praosSecurityParam = SecurityParam $ SL.sgSecurityParam genesis,
268-
praosMaxKESEvo = SL.sgMaxKESEvolutions genesis,
269-
praosQuorum = SL.sgUpdateQuorum genesis,
270-
praosMaxMajorPV = maxMajorProtVer,
271-
praosMaxLovelaceSupply = SL.sgMaxLovelaceSupply genesis,
272-
praosNetworkId = SL.sgNetworkId genesis,
273-
praosSystemStart = SystemStart $ SL.sgSystemStart genesis
261+
praosParams = PraosParams {
262+
praosSlotsPerKESPeriod = SL.sgSlotsPerKESPeriod genesis
263+
, praosLeaderF = SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesis
264+
, praosSecurityParam = SecurityParam $ SL.sgSecurityParam genesis
265+
, praosMaxKESEvo = SL.sgMaxKESEvolutions genesis
266+
, praosQuorum = SL.sgUpdateQuorum genesis
267+
, praosMaxMajorPV = maxMajorProtVer
268+
, praosMaxLovelaceSupply = SL.sgMaxLovelaceSupply genesis
269+
, praosNetworkId = SL.sgNetworkId genesis
270+
, praosSystemStart = SystemStart $ SL.sgSystemStart genesis
274271
}
275272

276273
blockConfig :: BlockConfig (ShelleyBlock (Praos c) era)
@@ -281,35 +278,31 @@ protocolInfoPraosShelleyBased
281278
(shelleyBlockIssuerVKey <$> credentialss)
282279

283280
storageConfig :: StorageConfig (ShelleyBlock (Praos c) era)
284-
storageConfig =
285-
ShelleyStorageConfig
286-
{ shelleyStorageConfigSlotsPerKESPeriod = praosSlotsPerKESPeriod praosParams,
287-
shelleyStorageConfigSecurityParam = praosSecurityParam praosParams
281+
storageConfig = ShelleyStorageConfig {
282+
shelleyStorageConfigSlotsPerKESPeriod = praosSlotsPerKESPeriod praosParams
283+
, shelleyStorageConfigSecurityParam = praosSecurityParam praosParams
288284
}
289285

290286
initLedgerState :: LedgerState (ShelleyBlock (Praos c) era)
291-
initLedgerState =
292-
ShelleyLedgerState
293-
{ shelleyLedgerTip = Origin,
294-
shelleyLedgerState = SL.initialState genesis additionalGenesisConfig,
295-
shelleyLedgerTransition = ShelleyTransitionInfo {shelleyAfterVoting = 0}
287+
initLedgerState = ShelleyLedgerState {
288+
shelleyLedgerTip = Origin
289+
, shelleyLedgerState = SL.initialState genesis additionalGenesisConfig
290+
, shelleyLedgerTransition = ShelleyTransitionInfo {shelleyAfterVoting = 0}
296291
}
297292

298293
initChainDepState :: PraosState c
299-
initChainDepState =
300-
PraosState
301-
{ praosStateLastSlot = Origin,
302-
praosStateOCertCounters = mempty,
303-
praosStateEvolvingNonce = initialNonce,
304-
praosStateCandidateNonce = initialNonce,
305-
praosStateEpochNonce = initialNonce,
306-
praosStateLabNonce = initialNonce,
307-
praosStateLastEpochBlockNonce = initialNonce
294+
initChainDepState = PraosState {
295+
praosStateLastSlot = Origin
296+
, praosStateOCertCounters = mempty
297+
, praosStateEvolvingNonce = initialNonce
298+
, praosStateCandidateNonce = initialNonce
299+
, praosStateEpochNonce = initialNonce
300+
, praosStateLabNonce = initialNonce
301+
, praosStateLastEpochBlockNonce = initialNonce
308302
}
309303

310304
initExtLedgerState :: ExtLedgerState (ShelleyBlock (Praos c) era)
311-
initExtLedgerState =
312-
ExtLedgerState
313-
{ ledgerState = initLedgerState,
314-
headerState = HeaderState Origin initChainDepState
305+
initExtLedgerState = ExtLedgerState {
306+
ledgerState = initLedgerState
307+
, headerState = HeaderState Origin initChainDepState
315308
}

0 commit comments

Comments
 (0)