@@ -56,8 +56,6 @@ import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry
5656import qualified Ouroboros.Consensus.Ledger.Basics as L
5757import Ouroboros.Consensus.Node.GsmState
5858import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB )
59- import Ouroboros.Consensus.Util.NormalForm.StrictTVar (StrictTVar )
60- import qualified Ouroboros.Consensus.Util.NormalForm.StrictTVar as StrictSTM
6159import System.FS.API
6260 ( HasFS
6361 , createDirectoryIfMissing
@@ -97,7 +95,7 @@ data CandidateVersusSelection
9795 WhetherCandidateIsBetter ! Bool
9896 deriving (Eq , Show )
9997
100- data GsmView m upstreamPeer selection chainSyncState = GsmView
98+ data GsmView m upstreamPeer selection peerState = GsmView
10199 { antiThunderingHerd :: Maybe StdGen
102100 -- ^ An initial seed used to randomly increase 'minCaughtUpDuration' by up
103101 -- to 15% every transition from Syncing to CaughtUp, in order to avoid a
@@ -108,13 +106,13 @@ data GsmView m upstreamPeer selection chainSyncState = GsmView
108106 STM
109107 m
110108 ( selection ->
111- chainSyncState ->
109+ peerState ->
112110 CandidateVersusSelection
113111 )
114112 -- ^ Whether the candidate from the @chainSyncState@ is preferable to the
115113 -- selection. This can depend on external state (Peras certificates boosting
116114 -- blocks).
117- , peerIsIdle :: chainSyncState -> Bool
115+ , peerIsIdle :: peerState -> Bool
118116 , durationUntilTooOld :: Maybe (selection -> m DurationFromNow )
119117 -- ^ How long from now until the selection will be so old that the node
120118 -- should exit the @CaughtUp@ state
@@ -123,10 +121,8 @@ data GsmView m upstreamPeer selection chainSyncState = GsmView
123121 , equivalent :: selection -> selection -> Bool
124122 -- ^ Whether the two selections are equivalent for the purpose of the
125123 -- Genesis State Machine
126- , getChainSyncStates ::
127- STM m (Map. Map upstreamPeer (StrictTVar m chainSyncState ))
128- -- ^ The current ChainSync state with the latest candidates from the
129- -- upstream peers
124+ , getPeerStates :: STM m (Map. Map upstreamPeer peerState )
125+ -- ^ The current peer state with the latest candidates from the upstream peers
130126 , getCurrentSelection :: STM m selection
131127 -- ^ The node's current selection
132128 , minCaughtUpDuration :: NominalDiffTime
@@ -244,7 +240,7 @@ realGsmEntryPoints tracerArgs gsmView =
244240 , peerIsIdle
245241 , durationUntilTooOld
246242 , equivalent
247- , getChainSyncStates
243+ , getPeerStates
248244 , getCurrentSelection
249245 , minCaughtUpDuration
250246 , setCaughtUpPersistentMark
@@ -370,12 +366,13 @@ realGsmEntryPoints tracerArgs gsmView =
370366
371367 blockUntilCaughtUp :: STM m (TraceGsmEvent tracedSelection )
372368 blockUntilCaughtUp = do
373- -- STAGE 1: all ChainSync clients report no subsequent headers
374- varsState <- getChainSyncStates
375- states <- traverse StrictSTM. readTVar varsState
369+ -- STAGE 1: all peers are idle, which means that
370+ -- * all ChainSync clients report no subsequent headers, and
371+ -- * all PerasCertDiffusion clients report no subsequent certificates
372+ peerStates <- getPeerStates
376373 check $
377- not (Map. null states )
378- && all peerIsIdle states
374+ not (Map. null peerStates )
375+ && all peerIsIdle peerStates
379376
380377 -- STAGE 2: no candidate is better than the node's current
381378 -- selection
@@ -388,16 +385,15 @@ realGsmEntryPoints tracerArgs gsmView =
388385 -- block; general Praos reasoning ensures that won't take particularly
389386 -- long.
390387 selection <- getCurrentSelection
391- candidates <- traverse StrictSTM. readTVar varsState
392388 candidateOverSelection <- getCandidateOverSelection
393389 let ok candidate =
394390 WhetherCandidateIsBetter False
395391 == candidateOverSelection selection candidate
396- check $ all ok candidates
392+ check $ all ok peerStates
397393
398394 pure $
399395 GsmEventEnterCaughtUp
400- (Map. size states )
396+ (Map. size peerStates )
401397 (cnvSelection selection)
402398
403399 -- STAGE 3: the previous stages weren't so slow that the idler
0 commit comments