Skip to content

Commit 75c0642

Browse files
facundominguezNiols
authored andcommitted
Documentation edits for CSJ
* Mention that the objector also gets demoted * Edit note on Interactions with the BlockFetch logic * Expand the comments motivating DynamoInitState and ObjectorInitState Co-authored-by: Nicolas “Niols” Jeannerod <[email protected]>
1 parent 31b1fa5 commit 75c0642

File tree

2 files changed

+22
-13
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client

2 files changed

+22
-13
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client/Jumping.hs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@
7777
-- Interactions with the BlockFetch logic
7878
-- --------------------------------------
7979
--
80-
-- When syncing, the BlockFetch logic will fetch blocks from the dynamo. If the
81-
-- dynamo is responding too slowly, the BlockFetch logic can ask to change the
82-
-- dynamo with a call to 'rotateDynamo'.
80+
-- When syncing, the BlockFetch logic might request to change the dynamo with
81+
-- a call to 'rotateDynamo'. This is because the choice of dynamo influences
82+
-- which peer is selected to download blocks. See the note "Interactions with
83+
-- ChainSync Jumping" in "Ouroboros.Network.BlockFetch.Decision.BulkSync".
8384
--
8485
-- Interactions with the Limit on Patience
8586
-- ---------------------------------------
@@ -155,8 +156,9 @@
155156
-- (j|k).
156157
--
157158
-- The BlockFetch logic can ask to change the dynamo if it is not serving blocks
158-
-- fast enough. If there are other non-disengaged peers the dynamo is demoted to
159-
-- a jumper (l) and a new dynamo is elected.
159+
-- fast enough. If there are other non-disengaged peers, the dynamo (and the
160+
-- objector if there is one) is demoted to a jumper (l+g) and a new dynamo is
161+
-- elected.
160162
--
161163
module Ouroboros.Consensus.MiniProtocol.ChainSync.Client.Jumping (
162164
Context
@@ -275,9 +277,9 @@ mkJumping peerContext = Jumping
275277
--
276278
-- Invariants:
277279
--
278-
-- - If 'handlesCol is not empty, then there is exactly one dynamo in it.
279-
-- - There is at most one objector in 'handlesCol.
280-
-- - If there exist 'FoundIntersection' jumpers in 'handlesCol, then there
280+
-- - If 'handlesCol' is not empty, then there is exactly one dynamo in it.
281+
-- - There is at most one objector in 'handlesCol'.
282+
-- - If there exist 'FoundIntersection' jumpers in 'handlesCol', then there
281283
-- is an objector and the intersection of the objector with the dynamo is
282284
-- at least as old as the oldest intersection of the `FoundIntersection` jumpers
283285
-- with the dynamo.
@@ -763,8 +765,9 @@ unregisterClient context = do
763765
Objector{} -> electNewObjector context'
764766
Dynamo{} -> void $ electNewDynamo context'
765767

766-
-- | Elects a new dynamo by demoting the given dynamo to a jumper, moving the
767-
-- peer to the end of the queue of chain sync handles and electing a new dynamo.
768+
-- | Elects a new dynamo by demoting the given dynamo (and the objector if there
769+
-- is one) to a jumper, moving the peer to the end of the queue of chain sync
770+
-- handles and electing a new dynamo.
768771
--
769772
-- It does nothing if there is no other engaged peer to elect or if the given
770773
-- peer is not the dynamo.

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client/State.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ newChainSyncClientHandleCollection = do
165165
}
166166

167167
data DynamoInitState blk
168-
= -- | The dynamo has not yet started jumping and we first need to jump to the
169-
-- given jump info to set the intersection of the ChainSync server.
168+
= -- | The dynamo still has to set the intersection of the ChainSync server
169+
-- before it can resume downloading headers. This is because
170+
-- the message pipeline might be drained to do jumps, and this causes
171+
-- the intersection on the ChainSync server to diverge from the tip of
172+
-- the candidate fragment.
170173
DynamoStarting !(JumpInfo blk)
171174
| DynamoStarted
172175
deriving (Generic)
@@ -179,7 +182,10 @@ deriving anyclass instance
179182

180183
data ObjectorInitState
181184
= -- | The objector still needs to set the intersection of the ChainSync
182-
-- server before resuming retrieval of headers.
185+
-- server before resuming retrieval of headers. This is mainly because
186+
-- the message pipeline might be drained to do jumps, and this causes
187+
-- the intersection on the ChainSync server to diverge from the tip of
188+
-- the candidate fragment.
183189
Starting
184190
| Started
185191
deriving (Generic, Show, NoThunks)

0 commit comments

Comments
 (0)