diff --git a/ouroboros-consensus/src/unstable-consensus-testlib/Test/Ouroboros/Consensus/ChainGenerator/Adversarial.hs b/ouroboros-consensus/src/unstable-consensus-testlib/Test/Ouroboros/Consensus/ChainGenerator/Adversarial.hs index 59ddba8b63..72c03cf331 100644 --- a/ouroboros-consensus/src/unstable-consensus-testlib/Test/Ouroboros/Consensus/ChainGenerator/Adversarial.hs +++ b/ouroboros-consensus/src/unstable-consensus-testlib/Test/Ouroboros/Consensus/ChainGenerator/Adversarial.hs @@ -170,11 +170,24 @@ checkAdversarialChain recipe adv = do -- the rest of the function won't force this since there are no -- adversarial active slots error "dead code" - kPlus1stYoungest = case BV.findIthEmptyInV S.inverted vH (C.toIndex arPrefix C.+ k) of - BV.JustFound kPlus1st -> C.fromWindow winH $ kPlus1st C.+ d - BV.NothingFound -> C.Count d + kPlus1stYoungestPlusDelta = case BV.findIthEmptyInV S.inverted vH (C.toIndex arPrefix C.+ k) of + BV.JustFound kPlus1st -> C.fromWindow winH kPlus1st C.+ d + BV.NothingFound -> + -- If the honest chain didn't reach @k+1@ before it ended, then + -- the adversary cannot acclerate before the honest chain ends. + -- + -- The following value is inaccurate, since it is definitely + -- less than @d@ after the @k+1@st block. However, it's great + -- enough to prevent the test from ending while the adversary + -- has @k@ or more active slots remaining. + -- + -- TODO if the honest chain has @x < k+1@ remaining blocks, + -- then @(k+1) - x + d@ is the exact answer, isn't it? By + -- appeal to the conservative assumption that slots after 'Len' + -- are active on the honest schema. + C.Count d -- C.windowLast winH in - max sYoungest kPlus1stYoungest + max sYoungest kPlus1stYoungestPlusDelta checkRaces = do let iterH =