Skip to content

Commit e3deb7f

Browse files
committed
Various small improvements
* refactored `requireBootstrapPeers` * `unit_peer_sharing`: refactored to get debug output easier * labelled inbound governor state var
1 parent 2b6ffcc commit e3deb7f

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

cardano-diffusion/api/lib/Cardano/Network/PeerSelection/Bootstrap.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ isBootstrapPeersEnabled _ = True
3434
-- * When bootstrap peers are in use and the ledger is in 'TooOld' state,
3535
-- the system is considered to be in a sensitive state.
3636
requiresBootstrapPeers :: UseBootstrapPeers -> LedgerStateJudgement -> Bool
37-
requiresBootstrapPeers ubp lsj =
38-
isBootstrapPeersEnabled ubp && lsj == TooOld
37+
requiresBootstrapPeers _ubp YoungEnough = False
38+
requiresBootstrapPeers ubp TooOld = isBootstrapPeersEnabled ubp
39+
3940

4041
-- | A node is able to make progress either if it isn't in a sensitive state
4142
-- _or_ if it is in a sensitive state and has reached a clean state from which

cardano-diffusion/tests/lib/Test/Cardano/Network/Diffusion/Testnet.hs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4342,26 +4342,29 @@ unit_peer_sharing =
43424342
)
43434343
$ events'
43444344

4345+
events' :: [[WithName NtNAddr (WithTime DiffusionTestTrace)]]
43454346
events' = Trace.toList
43464347
. splitWithNameTrace
43474348
. fmap (\(WithTime t (WithName name b))
43484349
-> WithName name (WithTime t b))
43494350
. withTimeNameTraceEvents
43504351
@DiffusionTestTrace
43514352
@NtNAddr
4352-
-- We need roughly 1200 because:
4353-
-- * first peer sharing request will be issued after
4354-
-- `policyPeerSharAcitvationDelay = 300`
4355-
-- * this request will not bring any new peers, because none of
4356-
-- the peers are yet mature
4357-
-- * inbound connections become mature at 900s (15 mins)
4358-
-- * next peer share request happens after 900s, e.g. around 1200s.
4359-
. Trace.takeWhile (\se -> case se of
4360-
SimEvent {seTime} -> seTime < Time 1250
4361-
SimPOREvent {seTime} -> seTime < Time 1250
4362-
_ -> False
4363-
)
4364-
$ runSimTrace sim
4353+
$ trace
4354+
4355+
-- We need roughly 1200 because:
4356+
-- * first peer sharing request will be issued after
4357+
-- `policyPeerSharAcitvationDelay = 300`
4358+
-- * this request will not bring any new peers, because none of
4359+
-- the peers are yet mature
4360+
-- * inbound connections become mature at 900s (15 mins)
4361+
-- * next peer share request happens after 900s, e.g. around 1200s.
4362+
trace = Trace.takeWhile (\se -> case se of
4363+
SimEvent {seTime} -> seTime < Time 1_250
4364+
SimPOREvent {seTime} -> seTime < Time 1_250
4365+
_ -> False
4366+
)
4367+
$ runSimTrace sim
43654368

43664369
verify :: NtNAddr
43674370
-> [TracePeerSelection extraDebugState extraFlags
@@ -4386,7 +4389,8 @@ unit_peer_sharing =
43864389
verify _ _ = Every True
43874390

43884391
in
4389-
-- counterexample (ppEvents trace) $
4392+
-- counterexample (ppTrace_ trace) $
4393+
-- counterexample (foldr (\as out -> "===\n" ++ unlines (show <$> as) ++ out) "" events') $
43904394
counterexample (Map.foldrWithKey (\addr evs s -> concat [ "\n\n===== "
43914395
, show addr
43924396
, " =====\n\n"

ouroboros-network/framework/lib/Ouroboros/Network/InboundGovernor.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ with :: forall (muxMode :: Mux.Mode) socket peerAddr initiatorCtx responderCtx
155155
, MonadMask m
156156
, Ord peerAddr
157157
, HasResponder muxMode ~ True
158-
, MonadTraceSTM m
159158
, MonadFork m
160159
, MonadDelay m
161160
, Show peerAddr
@@ -181,6 +180,7 @@ with
181180
k
182181
= do
183182
stateVar <- newTVarIO emptyState
183+
labelTVarIO stateVar "inbound-governor-state-var"
184184
active <- newTVarIO True -- ^ inbound governor status: True = Active
185185
let connectionHandler =
186186
mkConnectionHandler $ inboundGovernorMuxTracer infoChannel

0 commit comments

Comments
 (0)