Skip to content

Commit 39b9818

Browse files
authored
Add peer sharing tracer (#1378)
# Description Added peer sharing tracer
2 parents d700f76 + ae21244 commit 39b9818

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Patch
9+
10+
- A bullet item for the Patch category.
11+
12+
-->
13+
<!--
14+
### Non-Breaking
15+
16+
- A bullet item for the Non-Breaking category.
17+
18+
-->
19+
20+
### Breaking
21+
22+
- Added peer sharing tracer to NTN tracers

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Network/NodeToNode.hs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,60 +369,64 @@ identityCodecs = Codecs {
369369
-------------------------------------------------------------------------------}
370370

371371
-- | A record of 'Tracer's for the different protocols.
372-
type Tracers m peer blk e =
373-
Tracers' peer blk e (Tracer m)
372+
type Tracers m ntnAddr blk e =
373+
Tracers' (ConnectionId ntnAddr) ntnAddr blk e (Tracer m)
374374

375-
data Tracers' peer blk e f = Tracers {
375+
data Tracers' peer ntnAddr blk e f = Tracers {
376376
tChainSyncTracer :: f (TraceLabelPeer peer (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk))))
377377
, tChainSyncSerialisedTracer :: f (TraceLabelPeer peer (TraceSendRecv (ChainSync (SerialisedHeader blk) (Point blk) (Tip blk))))
378378
, tBlockFetchTracer :: f (TraceLabelPeer peer (TraceSendRecv (BlockFetch blk (Point blk))))
379379
, tBlockFetchSerialisedTracer :: f (TraceLabelPeer peer (TraceSendRecv (BlockFetch (Serialised blk) (Point blk))))
380380
, tTxSubmission2Tracer :: f (TraceLabelPeer peer (TraceSendRecv (TxSubmission2 (GenTxId blk) (GenTx blk))))
381381
, tKeepAliveTracer :: f (TraceLabelPeer peer (TraceSendRecv KeepAlive))
382+
, tPeerSharingTracer :: f (TraceLabelPeer peer (TraceSendRecv (PeerSharing ntnAddr)))
382383
}
383384

384-
instance (forall a. Semigroup (f a)) => Semigroup (Tracers' peer blk e f) where
385+
instance (forall a. Semigroup (f a)) => Semigroup (Tracers' peer ntnAddr blk e f) where
385386
l <> r = Tracers {
386387
tChainSyncTracer = f tChainSyncTracer
387388
, tChainSyncSerialisedTracer = f tChainSyncSerialisedTracer
388389
, tBlockFetchTracer = f tBlockFetchTracer
389390
, tBlockFetchSerialisedTracer = f tBlockFetchSerialisedTracer
390391
, tTxSubmission2Tracer = f tTxSubmission2Tracer
391392
, tKeepAliveTracer = f tKeepAliveTracer
393+
, tPeerSharingTracer = f tPeerSharingTracer
392394
}
393395
where
394396
f :: forall a. Semigroup a
395-
=> (Tracers' peer blk e f -> a)
397+
=> (Tracers' peer ntnAddr blk e f -> a)
396398
-> a
397399
f prj = prj l <> prj r
398400

399401
-- | Use a 'nullTracer' for each protocol.
400-
nullTracers :: Monad m => Tracers m peer blk e
402+
nullTracers :: Monad m => Tracers m ntnAddr blk e
401403
nullTracers = Tracers {
402404
tChainSyncTracer = nullTracer
403405
, tChainSyncSerialisedTracer = nullTracer
404406
, tBlockFetchTracer = nullTracer
405407
, tBlockFetchSerialisedTracer = nullTracer
406408
, tTxSubmission2Tracer = nullTracer
407409
, tKeepAliveTracer = nullTracer
410+
, tPeerSharingTracer = nullTracer
408411
}
409412

410413
showTracers :: ( Show blk
411-
, Show peer
414+
, Show ntnAddr
412415
, Show (Header blk)
413416
, Show (GenTx blk)
414417
, Show (GenTxId blk)
415418
, HasHeader blk
416419
, HasNestedContent Header blk
417420
)
418-
=> Tracer m String -> Tracers m peer blk e
421+
=> Tracer m String -> Tracers m ntnAddr blk e
419422
showTracers tr = Tracers {
420423
tChainSyncTracer = showTracing tr
421424
, tChainSyncSerialisedTracer = showTracing tr
422425
, tBlockFetchTracer = showTracing tr
423426
, tBlockFetchSerialisedTracer = showTracing tr
424427
, tTxSubmission2Tracer = showTracing tr
425428
, tKeepAliveTracer = showTracing tr
429+
, tPeerSharingTracer = showTracing tr
426430
}
427431

428432
{-------------------------------------------------------------------------------
@@ -543,7 +547,7 @@ mkApps ::
543547
, ShowProxy (GenTx blk)
544548
)
545549
=> NodeKernel m addrNTN addrNTC blk -- ^ Needed for bracketing only
546-
-> Tracers m (ConnectionId addrNTN) blk e
550+
-> Tracers m addrNTN blk e
547551
-> (NodeToNodeVersion -> Codecs blk addrNTN e m bCS bCS bBF bBF bTX bKA bPS)
548552
-> ByteLimits bCS bBF bTX bKA
549553
-> m ChainSyncTimeout
@@ -770,8 +774,7 @@ mkApps kernel Tracers {..} mkCodecs ByteLimits {..} genChainSyncTimeout lopBucke
770774
$ \controller -> do
771775
psClient <- hPeerSharingClient version controlMessageSTM them controller
772776
((), trailing) <- runPeerWithLimits
773-
-- TODO: add tracer
774-
nullTracer
777+
(TraceLabelPeer them `contramap` tPeerSharingTracer)
775778
(cPeerSharingCodec (mkCodecs version))
776779
(byteLimitsPeerSharing (const 0))
777780
timeLimitsPeerSharing
@@ -787,8 +790,7 @@ mkApps kernel Tracers {..} mkCodecs ByteLimits {..} genChainSyncTimeout lopBucke
787790
aPeerSharingServer version ResponderContext { rcConnectionId = them } channel = do
788791
labelThisThread "PeerSharingServer"
789792
runPeerWithLimits
790-
-- TODO: add tracer
791-
nullTracer
793+
(TraceLabelPeer them `contramap` tPeerSharingTracer)
792794
(cPeerSharingCodec (mkCodecs version))
793795
(byteLimitsPeerSharing (const 0))
794796
timeLimitsPeerSharing

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ data RunNodeArgs m addrNTN addrNTC blk (p2p :: Diffusion.P2P) = RunNodeArgs {
177177
rnTraceConsensus :: Tracers m (ConnectionId addrNTN) (ConnectionId addrNTC) blk
178178

179179
-- | Protocol tracers for node-to-node communication
180-
, rnTraceNTN :: NTN.Tracers m (ConnectionId addrNTN) blk DeserialiseFailure
180+
, rnTraceNTN :: NTN.Tracers m addrNTN blk DeserialiseFailure
181181

182182
-- | Protocol tracers for node-to-client communication
183183
, rnTraceNTC :: NTC.Tracers m (ConnectionId addrNTC) blk DeserialiseFailure

0 commit comments

Comments
 (0)