From 58a4f3baeb6eb514537a930bbac4cb5f36ec5cf5 Mon Sep 17 00:00:00 2001 From: Armando Santos Date: Tue, 20 Feb 2024 15:53:55 +0000 Subject: [PATCH 1/3] Forget about non established bootstrap peers --- .../Test/Ouroboros/Network/PeerSelection.hs | 17 ++++-- .../Network/PeerSelection/Governor/Monitor.hs | 52 +++++++++++++++++-- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/PeerSelection.hs b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/PeerSelection.hs index 2549758f5f5..d0f83f13995 100644 --- a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/PeerSelection.hs +++ b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/PeerSelection.hs @@ -1780,6 +1780,11 @@ prop_governor_target_known_5_no_shrink_below (MaxTime maxTime) env = selectGovState (PublicRootPeers.getBigLedgerPeers . Governor.publicRootPeers) events + bootstrapPeersSig :: Signal (Set PeerAddr) + bootstrapPeersSig = + selectGovState (PublicRootPeers.getBootstrapPeers . Governor.publicRootPeers) + events + knownPeersShrinksSig :: Signal (Set PeerAddr) knownPeersShrinksSig = Signal.nub @@ -1787,14 +1792,16 @@ prop_governor_target_known_5_no_shrink_below (MaxTime maxTime) env = . Signal.difference -- We subtract all big ledger peers. This is because we might -- first satisfy the target of known peers, and then learn that - -- one of them was a big ledger peers. This would be a fake - -- shrink of known non big ledger peers. + -- one of them was a big ledger peers. We also subtract + -- bootstrap peers. This would be a fake shrink of known non + -- big ledger peers. -- -- By subtracting a sum of `y` and `y'` we also do not account -- forgetting big ledger peers. - (\(x,y) (x',y') -> x Set.\\ x' Set.\\ y Set.\\ y') - $ (,) <$> govKnownPeersSig - <*> bigLedgerPeersSig + (\(x,y,z) (x',y',z') -> x Set.\\ x' Set.\\ y Set.\\ y' Set.\\ z Set.\\ z') + $ (,,) <$> govKnownPeersSig + <*> bigLedgerPeersSig + <*> bootstrapPeersSig unexpectedShrink :: Signal Bool unexpectedShrink = diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs index 16c8b7d4825..2c509c5b193 100644 --- a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs +++ b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs @@ -554,15 +554,29 @@ localRoots actions@PeerSelectionActions{ readLocalRootPeers -- peer connect to non-trusted peers, so just updating the boostrap peers -- flag will enable the previously disabled monitoring actions. -- -monitorBootstrapPeersFlag :: MonadSTM m +monitorBootstrapPeersFlag :: ( MonadSTM m + , Ord peeraddr + ) => PeerSelectionActions peeraddr peerconn m -> PeerSelectionState peeraddr peerconn -> Guarded (STM m) (TimedDecision m peeraddr peerconn) monitorBootstrapPeersFlag PeerSelectionActions { readUseBootstrapPeers } - st@PeerSelectionState { bootstrapPeersFlag } = + st@PeerSelectionState { bootstrapPeersFlag + , knownPeers + , establishedPeers + , publicRootPeers + , inProgressPromoteCold + , inProgressPromoteWarm + } = Guarded Nothing $ do ubp <- readUseBootstrapPeers check (ubp /= bootstrapPeersFlag) + let nonEstablishedBootstrapPeers = + PublicRootPeers.getBootstrapPeers publicRootPeers + `Set.difference` + EstablishedPeers.toSet establishedPeers + `Set.difference` + (inProgressPromoteCold <> inProgressPromoteWarm) return $ \_now -> Decision { decisionTrace = [TraceUseBootstrapPeersChanged ubp], @@ -572,6 +586,14 @@ monitorBootstrapPeersFlag PeerSelectionActions { readUseBootstrapPeers } , ledgerStateJudgement = YoungEnough , hasOnlyBootstrapPeers = False , bootstrapPeersTimeout = Nothing + , knownPeers = + KnownPeers.delete + nonEstablishedBootstrapPeers + knownPeers + , publicRootPeers = + PublicRootPeers.difference + publicRootPeers + nonEstablishedBootstrapPeers } } @@ -589,13 +611,21 @@ monitorBootstrapPeersFlag PeerSelectionActions { readUseBootstrapPeers } -- It should also be noted that churning is ignored until the node converges -- to a clean state. I.e., it will disconnect from the targets source of truth. -- -monitorLedgerStateJudgement :: MonadSTM m +monitorLedgerStateJudgement :: ( MonadSTM m + , Ord peeraddr + ) => PeerSelectionActions peeraddr peerconn m -> PeerSelectionState peeraddr peerconn -> Guarded (STM m) (TimedDecision m peeraddr peerconn) monitorLedgerStateJudgement PeerSelectionActions{ readLedgerStateJudgement } st@PeerSelectionState{ bootstrapPeersFlag, - ledgerStateJudgement } + publicRootPeers, + knownPeers, + establishedPeers, + inProgressPromoteCold, + inProgressPromoteWarm, + ledgerStateJudgement + } | isBootstrapPeersEnabled bootstrapPeersFlag = Guarded Nothing $ do lsj <- readLedgerStateJudgement @@ -622,10 +652,24 @@ monitorLedgerStateJudgement PeerSelectionActions{ readLedgerStateJudgement } , bootstrapPeersTimeout = Just (addTime governor_BOOTSTRAP_PEERS_TIMEOUT now) }) YoungEnough -> do + let nonEstablishedBootstrapPeers = + PublicRootPeers.getBootstrapPeers publicRootPeers + `Set.difference` + EstablishedPeers.toSet establishedPeers + `Set.difference` + (inProgressPromoteCold <> inProgressPromoteWarm) return (\_ -> st { ledgerStateJudgement = lsj , hasOnlyBootstrapPeers = False , bootstrapPeersTimeout = Nothing + , knownPeers = + KnownPeers.delete + nonEstablishedBootstrapPeers + knownPeers + , publicRootPeers = + PublicRootPeers.difference + publicRootPeers + nonEstablishedBootstrapPeers }) return $ \now -> Decision { From 05ab38bf1f2a8d9d4721f4b0c850784dd37b2ebe Mon Sep 17 00:00:00 2001 From: Armando Santos Date: Mon, 19 Feb 2024 15:38:02 +0000 Subject: [PATCH 2/3] Churn BootstrapPeers --- ouroboros-network/CHANGELOG.md | 5 + .../src/Ouroboros/Network/Diffusion/P2P.hs | 1 + .../Ouroboros/Network/PeerSelection/Churn.hs | 94 ++++++++++++------- .../Network/PeerSelection/Governor/Monitor.hs | 14 +-- 4 files changed, 75 insertions(+), 39 deletions(-) diff --git a/ouroboros-network/CHANGELOG.md b/ouroboros-network/CHANGELOG.md index e8542960a96..63e71346f7f 100644 --- a/ouroboros-network/CHANGELOG.md +++ b/ouroboros-network/CHANGELOG.md @@ -58,6 +58,11 @@ * Fix `targetPeers` monitoring action to use the correct set of local peers when in sensitive mode. +* Forget non-established bootstrap peers when transitioning from + `TooOld` state to `YoungEnough` + +* Implemented Churn for bootstrap peers + ## 0.11.0.0 -- 2023-01-22 ### Breaking changes diff --git a/ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs b/ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs index 661be62e6d8..d92c7fef30d 100644 --- a/ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs +++ b/ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs @@ -1023,6 +1023,7 @@ runM Interfaces daBlockFetchMode daPeerSelectionTargets peerSelectionTargetsVar + daReadUseBootstrapPeers -- -- Two functions only used in InitiatorAndResponder mode diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs index d57829cd4da..42c8fbab65c 100644 --- a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs +++ b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs @@ -16,6 +16,7 @@ import System.Random import Ouroboros.Network.BlockFetch (FetchMode (..)) import Ouroboros.Network.Diffusion.Policies (closeConnectionTimeout) +import Ouroboros.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Ouroboros.Network.PeerSelection.Governor.Types hiding (targets) import Ouroboros.Network.PeerSelection.PeerMetric @@ -45,9 +46,11 @@ peerChurnGovernor :: forall m peeraddr. -> STM m FetchMode -> PeerSelectionTargets -> StrictTVar m PeerSelectionTargets + -> STM m UseBootstrapPeers -> m Void peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeout - _metrics churnModeVar inRng getFetchMode base peerSelectionVar = do + _metrics churnModeVar inRng getFetchMode base peerSelectionVar + getUseBootstrapPeers = do -- Wait a while so that not only the closest peers have had the time -- to become warm. startTs0 <- getMonotonicTime @@ -55,8 +58,11 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou -- The intention is to give local root peers give head start and avoid -- giving advantage to hostile and quick root peers. threadDelay 3 - mode <- atomically updateChurnMode - atomically $ increaseActivePeers mode + (mode, ubp) <- atomically ((,) <$> updateChurnMode + <*> getUseBootstrapPeers) + atomically $ do + increaseActivePeers mode + increaseEstablishedPeers mode ubp endTs0 <- getMonotonicTime fuzzyDelay inRng (endTs0 `diffTime` startTs0) >>= go @@ -73,7 +79,7 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou -- TODO: #3396 revisit the policy for genesis increaseActivePeers :: ChurnMode -> STM m () - increaseActivePeers mode = do + increaseActivePeers mode = modifyTVar peerSelectionVar (\targets -> targets { targetNumberOfActivePeers = case mode of @@ -84,7 +90,7 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou }) decreaseActivePeers :: ChurnMode -> STM m () - decreaseActivePeers mode = do + decreaseActivePeers mode = modifyTVar peerSelectionVar (\targets -> targets { targetNumberOfActivePeers = case mode of @@ -94,8 +100,30 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou min 1 (targetNumberOfActivePeers base - 1) }) + increaseEstablishedPeers :: ChurnMode -> UseBootstrapPeers -> STM m () + increaseEstablishedPeers mode ubp = + modifyTVar peerSelectionVar (\targets -> targets { + targetNumberOfEstablishedPeers = + case (mode, ubp) of + (ChurnModeBulkSync, UseBootstrapPeers _) -> + min (targetNumberOfActivePeers targets + 1) + (targetNumberOfEstablishedPeers base) + _ -> targetNumberOfEstablishedPeers base + }) + + decreaseEstablished :: ChurnMode -> UseBootstrapPeers -> STM m () + decreaseEstablished mode ubp = + modifyTVar peerSelectionVar (\targets -> targets { + targetNumberOfEstablishedPeers = + case (mode, ubp) of + (ChurnModeBulkSync, UseBootstrapPeers _) -> + min (targetNumberOfActivePeers targets) (targetNumberOfEstablishedPeers base - 1) + _ -> decrease (targetNumberOfEstablishedPeers base - targetNumberOfActivePeers base) + + targetNumberOfActivePeers base + }) + increaseActiveBigLedgerPeers :: ChurnMode -> STM m () - increaseActiveBigLedgerPeers mode = do + increaseActiveBigLedgerPeers mode = modifyTVar peerSelectionVar (\targets -> targets { -- TODO: when chain-skipping will be implemented and chain-sync client -- will take into account big ledger peers, we don't need pattern @@ -110,7 +138,7 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou }) decreaseActiveBigLedgerPeers :: ChurnMode -> STM m () - decreaseActiveBigLedgerPeers mode = do + decreaseActiveBigLedgerPeers mode = modifyTVar peerSelectionVar (\targets -> targets { targetNumberOfActiveBigLedgerPeers = case mode of @@ -125,11 +153,13 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou go !rng = do startTs <- getMonotonicTime - churnMode <- atomically updateChurnMode + (churnMode, ubp) <- atomically ((,) <$> updateChurnMode + <*> getUseBootstrapPeers) traceWith tracer $ TraceChurnMode churnMode - -- Purge the worst active peer(s). - atomically $ decreaseActivePeers churnMode + atomically $ do + -- Purge the worst active peer(s). + decreaseActivePeers churnMode -- Short delay, we may have no active peers right now threadDelay 1 @@ -151,25 +181,24 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou threadDelay 1 -- Forget the worst performing non-active peers. - atomically $ modifyTVar peerSelectionVar (\targets -> targets { - targetNumberOfRootPeers = - decrease (targetNumberOfRootPeers base - targetNumberOfEstablishedPeers base) - + targetNumberOfEstablishedPeers base - , targetNumberOfKnownPeers = - decrease (targetNumberOfKnownPeers base - targetNumberOfEstablishedPeers base) - + targetNumberOfEstablishedPeers base - , targetNumberOfEstablishedPeers = - decrease (targetNumberOfEstablishedPeers base - targetNumberOfActivePeers base) - + targetNumberOfActivePeers base - , targetNumberOfKnownBigLedgerPeers = - decrease (targetNumberOfKnownBigLedgerPeers base - - targetNumberOfEstablishedBigLedgerPeers base) - + targetNumberOfEstablishedBigLedgerPeers base - , targetNumberOfEstablishedBigLedgerPeers = - decrease (targetNumberOfEstablishedBigLedgerPeers base - - targetNumberOfActiveBigLedgerPeers base) - + targetNumberOfActiveBigLedgerPeers base - }) + atomically $ do + decreaseEstablished churnMode ubp + modifyTVar peerSelectionVar (\targets -> targets { + targetNumberOfRootPeers = + decrease (targetNumberOfRootPeers base - targetNumberOfEstablishedPeers base) + + targetNumberOfEstablishedPeers base + , targetNumberOfKnownPeers = + decrease (targetNumberOfKnownPeers base - targetNumberOfEstablishedPeers base) + + targetNumberOfEstablishedPeers base + , targetNumberOfKnownBigLedgerPeers = + decrease (targetNumberOfKnownBigLedgerPeers base - + targetNumberOfEstablishedBigLedgerPeers base) + + targetNumberOfEstablishedBigLedgerPeers base + , targetNumberOfEstablishedBigLedgerPeers = + decrease (targetNumberOfEstablishedBigLedgerPeers base - + targetNumberOfActiveBigLedgerPeers base) + + targetNumberOfActiveBigLedgerPeers base + }) -- Give the governor time to properly demote them. threadDelay $ 1 + closeConnectionTimeout @@ -185,9 +214,10 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval psOverallTimeou threadDelay $ 1 + psOverallTimeout -- Pick new non-active peers - atomically $ modifyTVar peerSelectionVar (\targets -> targets { - targetNumberOfEstablishedPeers = targetNumberOfEstablishedPeers base - , targetNumberOfEstablishedBigLedgerPeers = targetNumberOfEstablishedBigLedgerPeers base + atomically $ do + increaseEstablishedPeers churnMode ubp + modifyTVar peerSelectionVar (\targets -> targets { + targetNumberOfEstablishedBigLedgerPeers = targetNumberOfEstablishedBigLedgerPeers base }) endTs <- getMonotonicTime diff --git a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs index 2c509c5b193..80d6f95fe39 100644 --- a/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs +++ b/ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Monitor.hs @@ -557,9 +557,9 @@ localRoots actions@PeerSelectionActions{ readLocalRootPeers monitorBootstrapPeersFlag :: ( MonadSTM m , Ord peeraddr ) - => PeerSelectionActions peeraddr peerconn m - -> PeerSelectionState peeraddr peerconn - -> Guarded (STM m) (TimedDecision m peeraddr peerconn) + => PeerSelectionActions peeraddr peerconn m + -> PeerSelectionState peeraddr peerconn + -> Guarded (STM m) (TimedDecision m peeraddr peerconn) monitorBootstrapPeersFlag PeerSelectionActions { readUseBootstrapPeers } st@PeerSelectionState { bootstrapPeersFlag , knownPeers @@ -573,9 +573,9 @@ monitorBootstrapPeersFlag PeerSelectionActions { readUseBootstrapPeers } check (ubp /= bootstrapPeersFlag) let nonEstablishedBootstrapPeers = PublicRootPeers.getBootstrapPeers publicRootPeers - `Set.difference` + Set.\\ EstablishedPeers.toSet establishedPeers - `Set.difference` + Set.\\ (inProgressPromoteCold <> inProgressPromoteWarm) return $ \_now -> Decision { @@ -654,9 +654,9 @@ monitorLedgerStateJudgement PeerSelectionActions{ readLedgerStateJudgement } YoungEnough -> do let nonEstablishedBootstrapPeers = PublicRootPeers.getBootstrapPeers publicRootPeers - `Set.difference` + Set.\\ EstablishedPeers.toSet establishedPeers - `Set.difference` + Set.\\ (inProgressPromoteCold <> inProgressPromoteWarm) return (\_ -> st { ledgerStateJudgement = lsj From 7d49003134b2cc9f4d43c230e1abce819ca570f1 Mon Sep 17 00:00:00 2001 From: Armando Santos Date: Wed, 21 Feb 2024 10:32:52 +0000 Subject: [PATCH 3/3] Added FetchMode script to Testnet tests --- .../sim-tests-lib/Test/Ouroboros/Network/Testnet.hs | 12 ++++++++++-- .../Ouroboros/Network/Testnet/Simulation/Node.hs | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs index ff901080b3c..99ca72ca220 100644 --- a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs +++ b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs @@ -68,7 +68,7 @@ import Test.Tasty import Test.Tasty.QuickCheck (testProperty) import Control.Exception (AssertionFailed (..), catch, evaluate) -import Ouroboros.Network.BlockFetch (TraceFetchClientState (..)) +import Ouroboros.Network.BlockFetch (FetchMode (..), TraceFetchClientState (..)) import Ouroboros.Network.ConnectionManager.Test.Timeouts (AllProperty (..), TestProperty (..), classifyActivityType, classifyEffectiveDataFlow, classifyNegotiatedDataFlow, classifyPrunings, classifyTermination, @@ -690,6 +690,7 @@ unit_4177 = prop_inbound_governor_transitions_coverage absNoAttenuation script (Script (DNSLookupDelay {getDNSLookupDelay = 0.067} :| [DNSLookupDelay {getDNSLookupDelay = 0.097},DNSLookupDelay {getDNSLookupDelay = 0.101},DNSLookupDelay {getDNSLookupDelay = 0.096},DNSLookupDelay {getDNSLookupDelay = 0.051}])) Nothing False + (Script (FetchModeDeadline :| [])) , [JoinNetwork 1.742857142857 ,Reconfigure 6.33333333333 [(1,1,Map.fromList [(RelayAccessDomain "test2" 65535,(DoAdvertisePeer, IsNotTrustable))]), (1,1,Map.fromList [(RelayAccessAddress "0:6:0:3:0:6:0:5" 65530,(DoAdvertisePeer, IsNotTrustable)) @@ -721,6 +722,7 @@ unit_4177 = prop_inbound_governor_transitions_coverage absNoAttenuation script ])) Nothing False + (Script (FetchModeDeadline :| [])) , [JoinNetwork 0.183783783783 ,Reconfigure 4.533333333333 [(1,1,Map.fromList [])] ] @@ -1328,6 +1330,7 @@ unit_4191 = prop_diffusion_dns_can_recover absInfo script ])) Nothing False + (Script (FetchModeDeadline :| [])) , [ JoinNetwork 6.710144927536 , Kill 7.454545454545 , JoinNetwork 10.763157894736 @@ -2338,7 +2341,8 @@ async_demotion_network_script = = Nothing, naChainSyncEarlyExit = False, - naPeerSharing = PeerSharingDisabled + naPeerSharing = PeerSharingDisabled, + naFetchModeScript = singletonScript FetchModeDeadline } @@ -2823,6 +2827,7 @@ prop_unit_4258 = (Script (DNSLookupDelay {getDNSLookupDelay = 0.065} :| [])) Nothing False + (Script (FetchModeDeadline :| [])) , [ JoinNetwork 4.166666666666, Kill 0.3, JoinNetwork 1.517857142857, @@ -2862,6 +2867,7 @@ prop_unit_4258 = ])) Nothing False + (Script (FetchModeDeadline :| [])) , [ JoinNetwork 3.384615384615, Reconfigure 3.583333333333 [(1,1,Map.fromList [(RelayAccessAddress "0.0.0.4" 9,(DoNotAdvertisePeer, IsNotTrustable))])], Kill 15.55555555555, @@ -2923,6 +2929,7 @@ prop_unit_reconnect = (Script (DNSLookupDelay {getDNSLookupDelay = 0} :| [])) Nothing False + (Script (FetchModeDeadline :| [])) , [ JoinNetwork 0 ]) , (NodeArgs @@ -2949,6 +2956,7 @@ prop_unit_reconnect = (Script (DNSLookupDelay {getDNSLookupDelay = 0} :| [])) Nothing False + (Script (FetchModeDeadline :| [])) , [ JoinNetwork 10 ]) ] diff --git a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet/Simulation/Node.hs b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet/Simulation/Node.hs index 2f7b363d4ba..37ecd8d6efb 100644 --- a/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet/Simulation/Node.hs +++ b/ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet/Simulation/Node.hs @@ -114,9 +114,11 @@ import Test.Ouroboros.Network.PeerSelection.RootPeersDNS (DNSLookupDelay (..), import Test.Ouroboros.Network.PeerSelection.RootPeersDNS qualified as PeerSelection hiding (tests) +import Data.Bool (bool) import Data.Function (on) import Data.Typeable (Typeable) -import Ouroboros.Network.BlockFetch (TraceFetchClientState, TraceLabelPeer (..)) +import Ouroboros.Network.BlockFetch (FetchMode (..), TraceFetchClientState, + TraceLabelPeer (..)) import Ouroboros.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise (..)) import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing) @@ -209,13 +211,14 @@ data NodeArgs = -- ^ 'Arguments' 'aDNSLookupDelayScript' value , naChainSyncExitOnBlockNo :: Maybe BlockNo , naChainSyncEarlyExit :: Bool + , naFetchModeScript :: Script FetchMode } instance Show NodeArgs where show NodeArgs { naSeed, naDiffusionMode, naMbTime, naBootstrapPeers, naPublicRoots, naAddr, naPeerSharing, naLocalRootPeers, naLocalSelectionTargets, naDNSTimeoutScript, naDNSLookupDelayScript, naChainSyncExitOnBlockNo, - naChainSyncEarlyExit } = + naChainSyncEarlyExit, naFetchModeScript } = unwords [ "NodeArgs" , "(" ++ show naSeed ++ ")" , show naDiffusionMode @@ -230,6 +233,7 @@ instance Show NodeArgs where , "(" ++ show naDNSLookupDelayScript ++ ")" , "(" ++ show naChainSyncExitOnBlockNo ++ ")" , show naChainSyncEarlyExit + , show naFetchModeScript ] data Command = JoinNetwork DiffTime @@ -414,6 +418,8 @@ genNodeArgs relays minConnected localRootPeers relay = flip suchThat hasUpstream firstLedgerPool <- arbitrary let ledgerPeerPoolsScript = Script (firstLedgerPool :| ledgerPeerPools) + fetchModeScript <- fmap (bool FetchModeBulkSync FetchModeDeadline) <$> arbitrary + firstBootstrapPeer <- maybe DontUseBootstrapPeers UseBootstrapPeers <$> arbitrary bootstrapPeers <- listOf (maybe DontUseBootstrapPeers UseBootstrapPeers @@ -438,6 +444,7 @@ genNodeArgs relays minConnected localRootPeers relay = flip suchThat hasUpstream , naChainSyncExitOnBlockNo = chainSyncExitOnBlockNo , naChainSyncEarlyExit = chainSyncEarlyExit , naPeerSharing = peerSharing + , naFetchModeScript = fetchModeScript } where hasActive :: SmallPeerSelectionTargets -> Bool