Skip to content

Commit a98dd8d

Browse files
facundominguezneilmayhew
authored andcommitted
Disable blockfetch timeouts in uniform tests
1 parent d88a0e2 commit a98dd8d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Tests/Uniform.hs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ prop_leashingAttackTimeLimited =
285285
pure $ PointSchedule
286286
{ psSchedule = Peers honests advs
287287
, psStartOrder = []
288-
, psMinEndTime = timeLimit
288+
, psMinEndTime = addGracePeriodDelay (length advs) timeLimit
289289
}
290290

291291
takePointsUntil limit = takeWhile ((<= limit) . fst)
@@ -361,7 +361,8 @@ prop_loeStalling =
361361

362362
defaultSchedulerConfig {
363363
scEnableLoE = True,
364-
scEnableCSJ = True
364+
scEnableCSJ = True,
365+
scEnableBlockFetchTimeouts = False
365366
}
366367

367368
shrinkPeerSchedules
@@ -402,6 +403,7 @@ prop_downtime = forAllGenesisTest
402403
, scEnableLoP = True
403404
, scDowntime = Just 11
404405
, scEnableCSJ = True
406+
, scEnableBlockFetchTimeouts = False
405407
}
406408

407409
shrinkPeerSchedules
@@ -433,7 +435,8 @@ prop_blockFetchLeashingAttack =
433435
defaultSchedulerConfig
434436
{ scEnableLoE = True,
435437
scEnableLoP = True,
436-
scEnableCSJ = True
438+
scEnableCSJ = True,
439+
scEnableBlockFetchTimeouts = False
437440
}
438441
shrinkPeerSchedules
439442
theProperty
@@ -455,7 +458,7 @@ prop_blockFetchLeashingAttack =
455458
-- Important to shuffle the order in which the peers start, otherwise the
456459
-- honest peer starts first and systematically becomes dynamo.
457460
psStartOrder <- shuffle $ getPeerIds psSchedule'
458-
let maxTime = maximum $
461+
let maxTime = addGracePeriodDelay (length adversaries') $ maximum $
459462
Time 0 : [ pt | s <- honest : adversaries', (pt, _) <- take 1 (reverse s) ]
460463
pure $ PointSchedule {
461464
psSchedule = psSchedule',
@@ -470,6 +473,12 @@ prop_blockFetchLeashingAttack =
470473
isBlockPoint (ScheduleBlockPoint _) = True
471474
isBlockPoint _ = False
472475

476+
-- | Add a delay at the end of tests to account for retention of blocks
477+
-- by adversarial peers in blockfetch. This delay is 10 seconds per
478+
-- adversarial peer.
479+
addGracePeriodDelay :: Int -> Time -> Time
480+
addGracePeriodDelay adversaryCount = addTime (fromIntegral adversaryCount * 10)
481+
473482
disableBoringTimeouts :: GenesisTest blk schedule -> GenesisTest blk schedule
474483
disableBoringTimeouts gt =
475484
gt

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/PointSchedule.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import Control.Monad.ST (ST)
5555
import Data.Bifunctor (first)
5656
import Data.Functor (($>))
5757
import Data.List (mapAccumL, partition, scanl')
58+
import qualified Data.Map.Strict as Map
5859
import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
5960
import Data.Time (DiffTime)
6061
import Data.Word (Word64)
@@ -599,10 +600,12 @@ ensureScheduleDuration gt PointSchedule{psSchedule, psStartOrder, psMinEndTime}
599600
endingDelay =
600601
let cst = gtChainSyncTimeouts gt
601602
bft = gtBlockFetchTimeouts gt
602-
in 1 + fromIntegral peerCount * maximum (0 : catMaybes
603+
bfGracePeriodDelay = fromIntegral adversaryCount * 10
604+
in 1 + bfGracePeriodDelay + fromIntegral peerCount * maximum (0 : catMaybes
603605
[ canAwaitTimeout cst
604606
, intersectTimeout cst
605607
, busyTimeout bft
606608
, streamingTimeout bft
607609
])
608610
peerCount = length (peersList psSchedule)
611+
adversaryCount = Map.size (adversarialPeers psSchedule)

0 commit comments

Comments
 (0)