@@ -35,7 +35,6 @@ import qualified Ouroboros.Network.Block as Block
35
35
import Ouroboros.Network.Protocol.ChainSync.Client
36
36
37
37
import Cardano.Api
38
- import Cardano.Api.Byron
39
38
import Cardano.Api.Shelley
40
39
41
40
-- | The chairman checks for consensus and progress.
@@ -51,17 +50,16 @@ import Cardano.Api.Shelley
51
50
-- The consensus condition is checked incrementally as well as at the end, so
52
51
-- that failures can be detected as early as possible. The progress condition
53
52
-- is only checked at the end.
54
- chairmanTest
55
- :: Tracer IO String
53
+ chairmanTest :: ()
54
+ => Tracer IO String
56
55
-> NetworkId
57
56
-> DiffTime
58
57
-> BlockNo
59
58
-> [SocketPath ]
60
- -> AnyConsensusModeParams
59
+ -> ConsensusModeParams CardanoMode
61
60
-> SecurityParam
62
61
-> IO ()
63
- chairmanTest tracer nw runningTime progressThreshold socketPaths
64
- (AnyConsensusModeParams cModeParams) secParam = do
62
+ chairmanTest tracer nw runningTime progressThreshold socketPaths cModeParams secParam = do
65
63
traceWith tracer (" Will observe nodes for " ++ show runningTime)
66
64
traceWith tracer (" Will require chain growth of " ++ show progressThreshold)
67
65
@@ -110,11 +108,11 @@ instance Exception ConsensusFailure where
110
108
-- | For this test we define consensus as follows: for all pairs of chains,
111
109
-- the intersection of each pair is within K blocks of each tip.
112
110
113
- consensusCondition
114
- :: ConsensusBlockForMode mode ~ blk
111
+ consensusCondition :: ()
112
+ => ConsensusBlockForMode CardanoMode ~ blk
115
113
=> HasHeader (Header blk )
116
114
=> ConvertRawHash blk
117
- => ConsensusMode mode
115
+ => ConsensusMode CardanoMode
118
116
-> Map PeerId (AnchoredFragment (Header blk ))
119
117
-> SecurityParam
120
118
-> Either ConsensusFailure ConsensusSuccess
@@ -246,9 +244,9 @@ progressCondition minBlockNo (ConsensusSuccess _ tips) = do
246
244
getBlockNo (ChainTip _ _ bNum) = bNum
247
245
getBlockNo ChainTipAtGenesis = 0
248
246
249
- runChairman
250
- :: forall mode blk . ConsensusBlockForMode mode ~ blk
251
- => GetHeader (ConsensusBlockForMode mode )
247
+ runChairman :: forall blk . ()
248
+ => ConsensusBlockForMode CardanoMode ~ blk
249
+ => GetHeader (ConsensusBlockForMode CardanoMode )
252
250
=> Tracer IO String
253
251
-> NetworkId
254
252
-- ^ Security parameter, if a fork is deeper than it 'runChairman'
@@ -257,7 +255,7 @@ runChairman
257
255
-- ^ Run for this much time.
258
256
-> [SocketPath ]
259
257
-- ^ Local socket directory
260
- -> ConsensusModeParams mode
258
+ -> ConsensusModeParams CardanoMode
261
259
-> SecurityParam
262
260
-> IO (Map SocketPath
263
261
(AF. AnchoredSeq
@@ -312,41 +310,41 @@ addBlock sockPath chainsVar blk =
312
310
313
311
-- | Rollback a single block. If the rollback point is not found, we simply
314
312
-- error. It should never happen if the security parameter is set up correctly.
315
- rollback
316
- :: forall mode blk . ConsensusBlockForMode mode ~ blk
313
+ rollback :: forall blk . ()
314
+ => ConsensusBlockForMode CardanoMode ~ blk
317
315
=> HasHeader (Header blk )
318
316
=> SocketPath
319
- -> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode mode ))))
320
- -> ConsensusMode mode
317
+ -> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode ))))
318
+ -> ConsensusMode CardanoMode
321
319
-> ChainPoint
322
320
-> STM IO ()
323
321
rollback sockPath chainsVar cMode p =
324
322
modifyTVar chainsVar (Map. adjust fn sockPath)
325
323
where
326
- p' :: Point (Header (ConsensusBlockForMode mode ))
324
+ p' :: Point (Header (ConsensusBlockForMode CardanoMode ))
327
325
p' = coerce $ toConsensusPointInMode cMode p
328
326
329
- fn :: AnchoredFragment (Header (ConsensusBlockForMode mode ))
330
- -> AnchoredFragment (Header (ConsensusBlockForMode mode ))
327
+ fn :: AnchoredFragment (Header (ConsensusBlockForMode CardanoMode ))
328
+ -> AnchoredFragment (Header (ConsensusBlockForMode CardanoMode ))
331
329
fn cf = case AF. rollback p' cf of
332
330
Nothing -> error " rollback error: rollback beyond chain fragment"
333
331
Just cf' -> cf'
334
332
335
333
-- Chain-Sync client
336
334
type ChairmanTrace' = ConsensusSuccess
337
335
338
- type ChainVar mode = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode mode ))))
336
+ type ChainVar = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode ))))
339
337
340
338
-- | 'chainSyncClient which build chain fragment; on every roll forward it will
341
339
-- check if there is consensus on immutable chain.
342
340
chainSyncClient
343
- :: forall mode . GetHeader (ConsensusBlockForMode mode )
341
+ :: GetHeader (ConsensusBlockForMode CardanoMode )
344
342
=> Tracer IO ChairmanTrace'
345
343
-> SocketPath
346
- -> ChainVar mode
347
- -> ConsensusModeParams mode
344
+ -> ChainVar
345
+ -> ConsensusModeParams CardanoMode
348
346
-> SecurityParam
349
- -> ChainSyncClient (BlockInMode mode ) ChainPoint ChainTip IO ()
347
+ -> ChainSyncClient (BlockInMode CardanoMode ) ChainPoint ChainTip IO ()
350
348
chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pure $
351
349
-- Notify the core node about the our latest points at which we are
352
350
-- synchronised. This client is not persistent and thus it just
@@ -359,10 +357,10 @@ chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pu
359
357
, recvMsgIntersectNotFound = \ _ -> ChainSyncClient $ pure clientStIdle
360
358
}
361
359
where
362
- clientStIdle :: ClientStIdle (BlockInMode mode ) ChainPoint ChainTip IO ()
360
+ clientStIdle :: ClientStIdle (BlockInMode CardanoMode ) ChainPoint ChainTip IO ()
363
361
clientStIdle = SendMsgRequestNext clientStNext (pure clientStNext)
364
362
365
- clientStNext :: ClientStNext (BlockInMode mode ) ChainPoint ChainTip IO ()
363
+ clientStNext :: ClientStNext (BlockInMode CardanoMode ) ChainPoint ChainTip IO ()
366
364
clientStNext = ClientStNext
367
365
{ recvMsgRollForward = \ blk _tip -> ChainSyncClient $ do
368
366
-- add block & check if there is consensus on immutable chain
@@ -384,33 +382,27 @@ chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pu
384
382
-- Helpers
385
383
386
384
obtainHasHeader
387
- :: ConsensusBlockForMode mode ~ blk
388
- => ConsensusMode mode
389
- -> ((HasHeader (Header blk ), ConvertRawHash (ConsensusBlockForMode mode )) => a )
385
+ :: ConsensusBlockForMode CardanoMode ~ blk
386
+ => ConsensusMode CardanoMode
387
+ -> ((HasHeader (Header blk ), ConvertRawHash (ConsensusBlockForMode CardanoMode )) => a )
390
388
-> a
391
- obtainHasHeader ByronMode f = f
392
- obtainHasHeader ShelleyMode f = f
393
389
obtainHasHeader CardanoMode f = f
394
390
395
391
obtainGetHeader
396
- :: ConsensusMode mode
397
- -> ( (GetHeader (ConsensusBlockForMode mode )
392
+ :: ConsensusMode CardanoMode
393
+ -> ( (GetHeader (ConsensusBlockForMode CardanoMode )
398
394
) => a )
399
395
-> a
400
- obtainGetHeader ByronMode f = f
401
- obtainGetHeader ShelleyMode f = f
402
396
obtainGetHeader CardanoMode f = f
403
397
404
398
-- | Check that all nodes agree with each other, within the security parameter.
405
399
checkConsensus
406
- :: HasHeader (Header (ConsensusBlockForMode mode ))
407
- => ConvertRawHash (ConsensusBlockForMode mode )
408
- => ConsensusMode mode
409
- -> ChainVar mode
400
+ :: HasHeader (Header (ConsensusBlockForMode CardanoMode ))
401
+ => ConvertRawHash (ConsensusBlockForMode CardanoMode )
402
+ => ConsensusMode CardanoMode
403
+ -> ChainVar
410
404
-> SecurityParam
411
405
-> STM IO ConsensusSuccess
412
406
checkConsensus cMode chainsVar secParam = do
413
407
chainsSnapshot <- readTVar chainsVar
414
408
either throwIO return $ consensusCondition cMode chainsSnapshot secParam
415
-
416
-
0 commit comments