Skip to content

Commit 9bee54f

Browse files
Document fork number
1 parent aa2271e commit 9bee54f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Setup/GenChains.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ genHonestChainSchema = do
6868

6969
-- | Random generator for one alternative chain schema forking off a given
7070
-- honest chain schema. The alternative chain schema is returned as the pair of
71-
-- a slot number on the honest chain schema and a list of active slots.
71+
-- a block number on the honest chain schema and a list of active slots.
7272
--
7373
-- REVIEW: Use 'SlotNo' instead of 'Int'?
7474
genAlternativeChainSchema :: (H.HonestRecipe, H.ChainSchema base hon) -> QC.Gen (Int, [S])
@@ -153,6 +153,11 @@ genChainsWithExtraHonestPeers genNumExtraHonest genNumForks = do
153153
-- those values for individual tests?
154154
-- Also, we might want to generate these randomly.
155155
gtCSJParams = CSJParams $ fromIntegral scg,
156+
-- The generated alternative chains (branches added to the @goodChain@)
157+
-- can end up having the same @prefixCount@, meaning they fork at the same block. but are
158+
-- The assigned fork number has no relation with the order in which the
159+
-- branching happens, but is just a means to distinguish among then for
160+
-- pretty printing.
156161
gtBlockTree = List.foldl' (flip BT.addBranch') (BT.mkTrunk goodChain) $ zipWith (genAdversarialFragment goodBlocks) [1..] alternativeChainSchemas,
157162
gtExtraHonestPeers,
158163
gtSchedule = ()
@@ -170,6 +175,9 @@ genChainsWithExtraHonestPeers genNumExtraHonest genNumForks = do
170175
mkTestFragment =
171176
AF.fromNewestFirst AF.AnchorGenesis
172177

178+
-- Cons new blocks acoording to the given active block schema
179+
-- and mark the first with the corresponding fork number; the
180+
-- next blocks get a zero fork number.
173181
mkTestBlocks :: [blk] -> [S] -> Int -> [blk]
174182
mkTestBlocks pre active forkNo =
175183
fst (List.foldl' folder ([], 0) active)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ hashForkNo bt hash =
405405
(Any False, _) -> 0
406406

407407
blockForkNo :: AF.HasHeader blk => BlockTree blk -> ChainHash blk -> Word64
408-
blockForkNo pxy = \case
409-
BlockHash h -> hashForkNo pxy h
408+
blockForkNo bt = \case
409+
BlockHash h -> hashForkNo bt h
410410
_ -> 0
411411

412412
initBranch :: forall blk. (GetHeader blk, AF.HasHeader blk) => BlockTree blk -> Int -> Range -> AF.AnchoredFragment blk -> BranchSlots blk

0 commit comments

Comments
 (0)