Skip to content

Commit 292d711

Browse files
authored
consensus: more carefully hide HeaderWithTime from traces (#1498)
This is a follow-up to #1288 that ensures - do not expose `HeaderWithTime` in `TraceGDDEvent` via `GDDDebugInfo` - do not store the chain fragment with `HeaderWithTime` in `DensityBounds` adding the "no changelog'' label, as the relevant changelog fragments are already included into "main" Draft PR to for integration with the node: IntersectMBO/cardano-node#6211
2 parents dfa1708 + 5e519ff commit 292d711

File tree

2 files changed

+15
-11
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Genesis
  • ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/PeerSimulator

2 files changed

+15
-11
lines changed

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/PeerSimulator/Trace.hs

+5-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import Ouroboros.Consensus.Block (GenesisWindow (..), Header, Point,
3030
WithOrigin (NotOrigin, Origin), succWithOrigin)
3131
import Ouroboros.Consensus.Genesis.Governor (DensityBounds (..),
3232
GDDDebugInfo (..), TraceGDDEvent (..))
33-
import Ouroboros.Consensus.HeaderValidation (HeaderWithTime (..))
3433
import Ouroboros.Consensus.MiniProtocol.ChainSync.Client
3534
(TraceChainSyncClientEvent (..))
3635
import Ouroboros.Consensus.MiniProtocol.ChainSync.Client.Jumping
@@ -60,9 +59,8 @@ import Ouroboros.Network.Protocol.ChainSync.Type (ChainSync,
6059
import Test.Consensus.PointSchedule.NodeState (NodeState)
6160
import Test.Consensus.PointSchedule.Peers (Peer (Peer), PeerId)
6261
import Test.Util.TersePrinting (terseAnchor, terseBlock,
63-
terseFragment, terseHFragment, terseHWTFragment,
64-
terseHeader, tersePoint, terseRealPoint, terseTip,
65-
terseWithOrigin)
62+
terseFragment, terseHFragment, terseHeader, tersePoint,
63+
terseRealPoint, terseTip, terseWithOrigin)
6664
import Test.Util.TestBlock (TestBlock)
6765
import Text.Printf (printf)
6866

@@ -557,7 +555,7 @@ prettyDensityBounds bounds =
557555
-- the density comparison should not be applied to two peers if they share any headers after the LoE fragment.
558556
lastPoint =
559557
"point: " ++
560-
tersePoint (castPoint @(HeaderWithTime TestBlock) @TestBlock (AF.lastPoint clippedFragment)) ++
558+
tersePoint (castPoint @(Header TestBlock) @TestBlock (AF.lastPoint clippedFragment)) ++
561559
", "
562560

563561
showLatestSlot = \case
@@ -584,14 +582,14 @@ terseGDDEvent = \case
584582
} ->
585583
unlines $ [
586584
"GDD | Window: " ++ window sgen loeHead,
587-
" Selection: " ++ terseHWTFragment curChain,
585+
" Selection: " ++ terseHFragment curChain,
588586
" Candidates:"
589587
] ++
590588
showPeers (second (tersePoint . castPoint . AF.headPoint) <$> candidates) ++
591589
[
592590
" Candidate suffixes (bounds):"
593591
] ++
594-
showPeers (second (terseHWTFragment . clippedFragment) <$> bounds) ++
592+
showPeers (second (terseHFragment . clippedFragment) <$> bounds) ++
595593
[" Density bounds:"] ++
596594
prettyDensityBounds bounds ++
597595
[" New candidate tips:"] ++

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Genesis/Governor.hs

+10-4
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ evaluateGDD cfg tracer stateView = do
234234

235235
traceWith tracer $ TraceGDDDebug $ GDDDebugInfo
236236
{ sgen
237-
, curChain
237+
, curChain = AF.mapAnchoredFragment hwtHeader curChain
238238
, bounds
239239
, candidates = dropTimes candidates
240240
, candidateSuffixes = dropTimes candidateSuffixes
@@ -306,7 +306,7 @@ sharedCandidatePrefix curChain candidates =
306306

307307
data DensityBounds blk =
308308
DensityBounds {
309-
clippedFragment :: AnchoredFragment (HeaderWithTime blk),
309+
clippedFragment :: AnchoredFragment (Header blk),
310310
offersMoreThanK :: Bool,
311311
lowerBound :: Word64,
312312
upperBound :: Word64,
@@ -395,7 +395,13 @@ densityDisconnect (GenesisWindow sgen) (SecurityParam k) states candidateSuffixe
395395
-- If not, it is not qualified to compete by density (yet).
396396
offersMoreThanK = totalBlockCount > unNonZero k
397397

398-
pure (peer, DensityBounds {clippedFragment, offersMoreThanK, lowerBound, upperBound, hasBlockAfter, latestSlot, idling})
398+
pure (peer, DensityBounds { clippedFragment = AF.mapAnchoredFragment hwtHeader clippedFragment
399+
, offersMoreThanK
400+
, lowerBound
401+
, upperBound
402+
, hasBlockAfter
403+
, latestSlot
404+
, idling})
399405

400406
losingPeers = nubOrd $ densityBounds >>= \
401407
(peer0 , DensityBounds { clippedFragment = frag0
@@ -473,7 +479,7 @@ densityDisconnect (GenesisWindow sgen) (SecurityParam k) states candidateSuffixe
473479
data GDDDebugInfo peer blk =
474480
GDDDebugInfo {
475481
bounds :: [(peer, DensityBounds blk)],
476-
curChain :: AnchoredFragment (HeaderWithTime blk),
482+
curChain :: AnchoredFragment (Header blk),
477483
candidates :: [(peer, AnchoredFragment (Header blk))],
478484
candidateSuffixes :: [(peer, AnchoredFragment (Header blk))],
479485
losingPeers :: [peer],

0 commit comments

Comments
 (0)