diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index 8a907384bf3..db1978a7837 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -37,12 +37,9 @@ import Ouroboros.Consensus.Ledger.SupportsMempool import Ouroboros.Consensus.Mempool (MempoolCapacityBytesOverride (..)) import Ouroboros.Consensus.Node (NodeDatabasePaths (..)) import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..)) -import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (Flag (..), - NumOfDiskSnapshots (..), SnapshotInterval (..), pattern DoDiskSnapshotChecksum) -import Ouroboros.Network.Diffusion.Configuration (ConsensusMode, - MinBigLedgerPeersForTrustedState (..), defaultConsensusMode) -import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..)) -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) +import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..), + SnapshotInterval (..)) +import Ouroboros.Network.Diffusion.Configuration as Configuration import Control.Monad (when) import Data.Aeson @@ -107,7 +104,6 @@ data NodeConfiguration , ncProtocolConfig :: !NodeProtocolConfiguration -- Node parameters, not protocol-specific: - , ncConsensusMode :: !ConsensusMode , ncDiffusionMode :: !DiffusionMode , ncNumOfDiskSnapshots :: !NumOfDiskSnapshots , ncSnapshotInterval :: !SnapshotInterval @@ -156,14 +152,22 @@ data NodeConfiguration , ncAcceptedConnectionsLimit :: !AcceptedConnectionsLimit -- P2P governor targets - , ncTargetNumberOfRootPeers :: Int - , ncTargetNumberOfKnownPeers :: Int - , ncTargetNumberOfEstablishedPeers :: Int - , ncTargetNumberOfActivePeers :: Int - , ncTargetNumberOfKnownBigLedgerPeers :: Int - , ncTargetNumberOfEstablishedBigLedgerPeers :: Int - , ncTargetNumberOfActiveBigLedgerPeers :: Int - , ncMinBigLedgerPeersForTrustedState :: MinBigLedgerPeersForTrustedState + , ncDeadlineTargetOfRootPeers :: !Int + , ncDeadlineTargetOfKnownPeers :: !Int + , ncDeadlineTargetOfEstablishedPeers :: !Int + , ncDeadlineTargetOfActivePeers :: !Int + , ncDeadlineTargetOfKnownBigLedgerPeers :: !Int + , ncDeadlineTargetOfEstablishedBigLedgerPeers :: !Int + , ncDeadlineTargetOfActiveBigLedgerPeers :: !Int + , ncSyncTargetOfActivePeers :: !Int + , ncSyncTargetOfKnownBigLedgerPeers :: !Int + , ncSyncTargetOfEstablishedBigLedgerPeers :: !Int + , ncSyncTargetOfActiveBigLedgerPeers :: !Int + , ncSyncMinTrusted :: !MinBigLedgerPeersForTrustedState + + -- Used to determine which set of peer targets to use + -- by the diffusion layer when syncing + , ncConsensusMode :: !ConsensusMode -- Enable experimental P2P mode , ncEnableP2P :: SomeNetworkP2PMode @@ -192,8 +196,7 @@ data PartialNodeConfiguration , pncProtocolConfig :: !(Last NodeProtocolConfiguration) -- Node parameters, not protocol-specific: - , pncConsensusMode :: !(Last ConsensusMode) - , pncDiffusionMode :: !(Last DiffusionMode ) + , pncDiffusionMode :: !(Last DiffusionMode) , pncNumOfDiskSnapshots :: !(Last NumOfDiskSnapshots) , pncSnapshotInterval :: !(Last SnapshotInterval) , pncDoDiskSnapshotChecksum :: !(Last (Flag "DoDiskSnapshotChecksum")) @@ -222,14 +225,21 @@ data PartialNodeConfiguration , pncAcceptedConnectionsLimit :: !(Last AcceptedConnectionsLimit) -- P2P governor targets - , pncTargetNumberOfRootPeers :: !(Last Int) - , pncTargetNumberOfKnownPeers :: !(Last Int) - , pncTargetNumberOfEstablishedPeers :: !(Last Int) - , pncTargetNumberOfActivePeers :: !(Last Int) - , pncTargetNumberOfKnownBigLedgerPeers :: !(Last Int) - , pncTargetNumberOfEstablishedBigLedgerPeers :: !(Last Int) - , pncTargetNumberOfActiveBigLedgerPeers :: !(Last Int) - , pncMinBigLedgerPeersForTrustedState :: !(Last MinBigLedgerPeersForTrustedState) + , pncDeadlineTargetOfRootPeers :: !(Last Int) + , pncDeadlineTargetOfKnownPeers :: !(Last Int) + , pncDeadlineTargetOfEstablishedPeers :: !(Last Int) + , pncDeadlineTargetOfActivePeers :: !(Last Int) + , pncDeadlineTargetOfKnownBigLedgerPeers :: !(Last Int) + , pncDeadlineTargetOfEstablishedBigLedgerPeers :: !(Last Int) + , pncDeadlineTargetOfActiveBigLedgerPeers :: !(Last Int) + , pncSyncTargetOfActivePeers :: !(Last Int) + , pncSyncTargetOfKnownBigLedgerPeers :: !(Last Int) + , pncSyncTargetOfEstablishedBigLedgerPeers :: !(Last Int) + , pncSyncTargetOfActiveBigLedgerPeers :: !(Last Int) + , pncSyncMinTrusted :: !(Last MinBigLedgerPeersForTrustedState) + + -- Consensus mode for diffusion layer + , pncConsensusMode :: !(Last ConsensusMode) -- Enable experimental P2P mode , pncEnableP2P :: !(Last NetworkP2PMode) @@ -254,8 +264,6 @@ instance FromJSON PartialNodeConfiguration where -- Node parameters, not protocol-specific pncSocketPath <- Last <$> v .:? "SocketPath" pncDatabaseFile <- Last <$> v .:? "DatabasePath" - pncConsensusMode - <- Last . fmap getConsensusMode <$> v .:? "ConsensusMode" pncDiffusionMode <- Last . fmap getDiffusionMode <$> v .:? "DiffusionMode" pncNumOfDiskSnapshots @@ -315,14 +323,20 @@ instance FromJSON PartialNodeConfiguration where <- Last <$> v .:? "AcceptedConnectionsLimit" -- P2P Governor parameters, with conservative defaults. - pncTargetNumberOfRootPeers <- Last <$> v .:? "TargetNumberOfRootPeers" - pncTargetNumberOfKnownPeers <- Last <$> v .:? "TargetNumberOfKnownPeers" - pncTargetNumberOfEstablishedPeers <- Last <$> v .:? "TargetNumberOfEstablishedPeers" - pncTargetNumberOfActivePeers <- Last <$> v .:? "TargetNumberOfActivePeers" - pncTargetNumberOfKnownBigLedgerPeers <- Last <$> v .:? "TargetNumberOfKnownBigLedgerPeers" - pncTargetNumberOfEstablishedBigLedgerPeers <- Last <$> v .:? "TargetNumberOfEstablishedBigLedgerPeers" - pncTargetNumberOfActiveBigLedgerPeers <- Last <$> v .:? "TargetNumberOfActiveBigLedgerPeers" - pncMinBigLedgerPeersForTrustedState <- Last <$> v .:? "MinBigLedgerPeersForTrustedState" + pncDeadlineTargetOfRootPeers <- Last <$> v .:? "TargetNumberOfRootPeers" + pncDeadlineTargetOfKnownPeers <- Last <$> v .:? "TargetNumberOfKnownPeers" + pncDeadlineTargetOfEstablishedPeers <- Last <$> v .:? "TargetNumberOfEstablishedPeers" + pncDeadlineTargetOfActivePeers <- Last <$> v .:? "TargetNumberOfActivePeers" + pncDeadlineTargetOfKnownBigLedgerPeers <- Last <$> v .:? "TargetNumberOfKnownBigLedgerPeers" + pncDeadlineTargetOfEstablishedBigLedgerPeers <- Last <$> v .:? "TargetNumberOfEstablishedBigLedgerPeers" + pncDeadlineTargetOfActiveBigLedgerPeers <- Last <$> v .:? "TargetNumberOfActiveBigLedgerPeers" + pncSyncTargetOfActivePeers <- Last <$> v .:? "SyncTargetNumberOfActivePeers" + pncSyncTargetOfKnownBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfKnownBigLedgerPeers" + pncSyncTargetOfEstablishedBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfEstablishedBigLedgerPeers" + pncSyncTargetOfActiveBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfActiveBigLedgerPeers" + pncSyncMinTrusted <- Last <$> v .:? "SyncMinNumberOfBigLedgerPeersForTrustedState" + + pncConsensusMode <- Last <$> v .:? "ConsensusMode" pncChainSyncIdleTimeout <- Last <$> v .:? "ChainSyncIdleTimeout" @@ -336,7 +350,7 @@ instance FromJSON PartialNodeConfiguration where -- Peer Sharing -- DISABLED BY DEFAULT - pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just PeerSharingDisabled + pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just Configuration.PeerSharingDisabled pure PartialNodeConfiguration { pncProtocolConfig @@ -365,14 +379,19 @@ instance FromJSON PartialNodeConfiguration where , pncTimeWaitTimeout , pncChainSyncIdleTimeout , pncAcceptedConnectionsLimit - , pncTargetNumberOfRootPeers - , pncTargetNumberOfKnownPeers - , pncTargetNumberOfEstablishedPeers - , pncTargetNumberOfActivePeers - , pncTargetNumberOfKnownBigLedgerPeers - , pncTargetNumberOfEstablishedBigLedgerPeers - , pncTargetNumberOfActiveBigLedgerPeers - , pncMinBigLedgerPeersForTrustedState + , pncDeadlineTargetOfRootPeers + , pncDeadlineTargetOfKnownPeers + , pncDeadlineTargetOfEstablishedPeers + , pncDeadlineTargetOfActivePeers + , pncDeadlineTargetOfKnownBigLedgerPeers + , pncDeadlineTargetOfEstablishedBigLedgerPeers + , pncDeadlineTargetOfActiveBigLedgerPeers + , pncSyncTargetOfActivePeers + , pncSyncTargetOfKnownBigLedgerPeers + , pncSyncTargetOfEstablishedBigLedgerPeers + , pncSyncTargetOfActiveBigLedgerPeers + , pncSyncMinTrusted + , pncConsensusMode , pncEnableP2P , pncPeerSharing } @@ -515,7 +534,6 @@ defaultPartialNodeConfiguration = , pncDatabaseFile = Last . Just $ OnePathForAllDbs "mainnet/db/" , pncLoggingSwitch = Last $ Just True , pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty mempty - , pncConsensusMode = Last $ Just defaultConsensusMode , pncDiffusionMode = Last $ Just InitiatorAndResponderDiffusionMode , pncNumOfDiskSnapshots = Last $ Just DefaultNumOfDiskSnapshots , pncSnapshotInterval = Last $ Just DefaultSnapshotInterval @@ -543,18 +561,37 @@ defaultPartialNodeConfiguration = , acceptedConnectionsSoftLimit = 384 , acceptedConnectionsDelay = 5 } - , pncTargetNumberOfRootPeers = Last (Just 85) - , pncTargetNumberOfKnownPeers = Last (Just 85) - , pncTargetNumberOfEstablishedPeers = Last (Just 40) - , pncTargetNumberOfActivePeers = Last (Just 15) + , pncDeadlineTargetOfRootPeers = Last (Just deadlineRoots) + , pncDeadlineTargetOfKnownPeers = Last (Just deadlineKnown) + , pncDeadlineTargetOfEstablishedPeers = Last (Just deadlineEstablished) + , pncDeadlineTargetOfActivePeers = Last (Just deadlineActive) , pncChainSyncIdleTimeout = mempty - , pncTargetNumberOfKnownBigLedgerPeers = Last (Just 15) - , pncTargetNumberOfEstablishedBigLedgerPeers = Last (Just 10) - , pncTargetNumberOfActiveBigLedgerPeers = Last (Just 5) - , pncMinBigLedgerPeersForTrustedState = pure (MinBigLedgerPeersForTrustedState 3) -- TODO: Review - , pncEnableP2P = Last (Just EnabledP2PMode) - , pncPeerSharing = Last (Just PeerSharingDisabled) + , pncDeadlineTargetOfKnownBigLedgerPeers = Last (Just deadlineBigKnown) + , pncDeadlineTargetOfEstablishedBigLedgerPeers = Last (Just deadlineBigEst) + , pncDeadlineTargetOfActiveBigLedgerPeers = Last (Just deadlineBigAct) + , pncSyncTargetOfActivePeers = Last (Just syncActive) + , pncSyncTargetOfKnownBigLedgerPeers = Last (Just syncBigKnown) + , pncSyncTargetOfEstablishedBigLedgerPeers = Last (Just syncBigEst) + , pncSyncTargetOfActiveBigLedgerPeers = Last (Just syncBigAct) + , pncSyncMinTrusted = Last (Just defaultMinBigLedgerPeersForTrustedState) + , pncConsensusMode = mempty + , pncEnableP2P = Last (Just EnabledP2PMode) + , pncPeerSharing = Last (Just Configuration.PeerSharingDisabled) } + where + Configuration.PeerSelectionTargets { + targetNumberOfRootPeers = deadlineRoots, + targetNumberOfKnownPeers = deadlineKnown, + targetNumberOfEstablishedPeers = deadlineEstablished, + targetNumberOfActivePeers = deadlineActive, + targetNumberOfKnownBigLedgerPeers = deadlineBigKnown, + targetNumberOfEstablishedBigLedgerPeers = deadlineBigEst, + targetNumberOfActiveBigLedgerPeers = deadlineBigAct } = defaultDeadlineTargets + Configuration.PeerSelectionTargets { + targetNumberOfActivePeers = syncActive, + targetNumberOfKnownBigLedgerPeers = syncBigKnown, + targetNumberOfEstablishedBigLedgerPeers = syncBigEst, + targetNumberOfActiveBigLedgerPeers = syncBigAct } = defaultSyncTargets lastOption :: Parser a -> Parser (Last a) lastOption = fmap Last . optional @@ -578,30 +615,45 @@ makeNodeConfiguration pnc = do shutdownConfig <- lastToEither "Missing ShutdownConfig" $ pncShutdownConfig pnc socketConfig <- lastToEither "Missing SocketConfig" $ pncSocketConfig pnc - ncTargetNumberOfRootPeers <- + ncDeadlineTargetOfRootPeers <- lastToEither "Missing TargetNumberOfRootPeers" - $ pncTargetNumberOfRootPeers pnc - ncTargetNumberOfKnownPeers <- + $ pncDeadlineTargetOfRootPeers pnc + ncDeadlineTargetOfKnownPeers <- lastToEither "Missing TargetNumberOfKnownPeers" - $ pncTargetNumberOfKnownPeers pnc - ncTargetNumberOfEstablishedPeers <- + $ pncDeadlineTargetOfKnownPeers pnc + ncDeadlineTargetOfEstablishedPeers <- lastToEither "Missing TargetNumberOfEstablishedPeers" - $ pncTargetNumberOfEstablishedPeers pnc - ncTargetNumberOfActivePeers <- + $ pncDeadlineTargetOfEstablishedPeers pnc + ncDeadlineTargetOfActivePeers <- lastToEither "Missing TargetNumberOfActivePeers" - $ pncTargetNumberOfActivePeers pnc - ncTargetNumberOfKnownBigLedgerPeers <- + $ pncDeadlineTargetOfActivePeers pnc + ncDeadlineTargetOfKnownBigLedgerPeers <- lastToEither "Missing TargetNumberOfKnownBigLedgerPeers" - $ pncTargetNumberOfKnownBigLedgerPeers pnc - ncTargetNumberOfEstablishedBigLedgerPeers <- + $ pncDeadlineTargetOfKnownBigLedgerPeers pnc + ncDeadlineTargetOfEstablishedBigLedgerPeers <- lastToEither "Missing TargetNumberOfEstablishedBigLedgerPeers" - $ pncTargetNumberOfEstablishedBigLedgerPeers pnc - ncTargetNumberOfActiveBigLedgerPeers <- + $ pncDeadlineTargetOfEstablishedBigLedgerPeers pnc + ncDeadlineTargetOfActiveBigLedgerPeers <- lastToEither "Missing TargetNumberOfActiveBigLedgerPeers" - $ pncTargetNumberOfActiveBigLedgerPeers pnc - ncMinBigLedgerPeersForTrustedState <- - lastToEither "Missing MinBigLedgerPeersForTrustedState" - $ pncMinBigLedgerPeersForTrustedState pnc + $ pncDeadlineTargetOfActiveBigLedgerPeers pnc + ncSyncTargetOfActivePeers <- + lastToEither "Missing SyncTargetNumberOfActivePeers" + $ pncSyncTargetOfActivePeers pnc + ncSyncTargetOfKnownBigLedgerPeers <- + lastToEither "Missing SyncTargetNumberOfKnownBigLedgerPeers" + $ pncSyncTargetOfKnownBigLedgerPeers pnc + ncSyncTargetOfEstablishedBigLedgerPeers <- + lastToEither "Missing SyncTargetNumberOfEstablishedBigLedgerPeers" + $ pncSyncTargetOfEstablishedBigLedgerPeers pnc + ncSyncTargetOfActiveBigLedgerPeers <- + lastToEither "Missing SyncTargetNumberOfActiveBigLedgerPeers" + $ pncSyncTargetOfActiveBigLedgerPeers pnc + ncSyncMinTrusted <- + lastToEither "Missing SyncMinNumberOfBigLedgerPeersForTrustedState" + $ pncSyncMinTrusted pnc + ncConsensusMode <- + lastToEither "Missing ConsensusMode" + $ pncConsensusMode pnc ncProtocolIdleTimeout <- lastToEither "Missing ProtocolIdleTimeout" $ pncProtocolIdleTimeout pnc @@ -644,7 +696,6 @@ makeNodeConfiguration pnc = do , ncStartAsNonProducingNode = startAsNonProducingNode , ncProtocolConfig = protocolConfig , ncSocketConfig = socketConfig - , ncConsensusMode = consensusMode , ncDiffusionMode = diffusionMode , ncNumOfDiskSnapshots = numOfDiskSnapshots , ncSnapshotInterval = snapshotInterval @@ -662,18 +713,23 @@ makeNodeConfiguration pnc = do , ncTimeWaitTimeout , ncChainSyncIdleTimeout , ncAcceptedConnectionsLimit - , ncTargetNumberOfRootPeers - , ncTargetNumberOfKnownPeers - , ncTargetNumberOfEstablishedPeers - , ncTargetNumberOfActivePeers - , ncTargetNumberOfKnownBigLedgerPeers - , ncTargetNumberOfEstablishedBigLedgerPeers - , ncTargetNumberOfActiveBigLedgerPeers - , ncMinBigLedgerPeersForTrustedState + , ncDeadlineTargetOfRootPeers + , ncDeadlineTargetOfKnownPeers + , ncDeadlineTargetOfEstablishedPeers + , ncDeadlineTargetOfActivePeers + , ncDeadlineTargetOfKnownBigLedgerPeers + , ncDeadlineTargetOfEstablishedBigLedgerPeers + , ncDeadlineTargetOfActiveBigLedgerPeers + , ncSyncTargetOfActivePeers + , ncSyncTargetOfKnownBigLedgerPeers + , ncSyncTargetOfEstablishedBigLedgerPeers + , ncSyncTargetOfActiveBigLedgerPeers + , ncSyncMinTrusted , ncEnableP2P = case enableP2P of EnabledP2PMode -> SomeNetworkP2PMode Consensus.EnabledP2PMode DisabledP2PMode -> SomeNetworkP2PMode Consensus.DisabledP2PMode , ncPeerSharing + , ncConsensusMode } ncProtocol :: NodeConfiguration -> Protocol diff --git a/cardano-node/src/Cardano/Node/Parsers.hs b/cardano-node/src/Cardano/Node/Parsers.hs index 08ab701d89b..821d580b3bd 100644 --- a/cardano-node/src/Cardano/Node/Parsers.hs +++ b/cardano-node/src/Cardano/Node/Parsers.hs @@ -119,14 +119,19 @@ nodeRunParser = do , pncTimeWaitTimeout = mempty , pncChainSyncIdleTimeout = mempty , pncAcceptedConnectionsLimit = mempty - , pncTargetNumberOfRootPeers = mempty - , pncTargetNumberOfKnownPeers = mempty - , pncTargetNumberOfEstablishedPeers = mempty - , pncTargetNumberOfActivePeers = mempty - , pncTargetNumberOfKnownBigLedgerPeers = mempty - , pncTargetNumberOfEstablishedBigLedgerPeers = mempty - , pncTargetNumberOfActiveBigLedgerPeers = mempty - , pncMinBigLedgerPeersForTrustedState = mempty + , pncDeadlineTargetOfRootPeers = mempty + , pncDeadlineTargetOfKnownPeers = mempty + , pncDeadlineTargetOfEstablishedPeers = mempty + , pncDeadlineTargetOfActivePeers = mempty + , pncDeadlineTargetOfKnownBigLedgerPeers = mempty + , pncDeadlineTargetOfEstablishedBigLedgerPeers = mempty + , pncDeadlineTargetOfActiveBigLedgerPeers = mempty + , pncSyncTargetOfActivePeers = mempty + , pncSyncTargetOfKnownBigLedgerPeers = mempty + , pncSyncTargetOfEstablishedBigLedgerPeers = mempty + , pncSyncTargetOfActiveBigLedgerPeers = mempty + , pncSyncMinTrusted = mempty + , pncConsensusMode = mempty , pncEnableP2P = mempty , pncPeerSharing = mempty } diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index f26fa0b1d88..e89f5dc2eef 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -891,18 +891,22 @@ mkP2PArguments -> STM IO (Maybe LedgerPeerSnapshot) -> Diffusion.ExtraArguments 'Diffusion.P2P IO mkP2PArguments NodeConfiguration { - ncConsensusMode, - ncTargetNumberOfRootPeers, - ncTargetNumberOfKnownPeers, - ncTargetNumberOfEstablishedPeers, - ncTargetNumberOfActivePeers, - ncTargetNumberOfKnownBigLedgerPeers, - ncTargetNumberOfEstablishedBigLedgerPeers, - ncTargetNumberOfActiveBigLedgerPeers, - ncMinBigLedgerPeersForTrustedState, + ncDeadlineTargetOfRootPeers, + ncDeadlineTargetOfKnownPeers, + ncDeadlineTargetOfEstablishedPeers, + ncDeadlineTargetOfActivePeers, + ncDeadlineTargetOfKnownBigLedgerPeers, + ncDeadlineTargetOfEstablishedBigLedgerPeers, + ncDeadlineTargetOfActiveBigLedgerPeers, + ncSyncTargetOfActivePeers, + ncSyncTargetOfKnownBigLedgerPeers, + ncSyncTargetOfEstablishedBigLedgerPeers, + ncSyncTargetOfActiveBigLedgerPeers, + ncSyncMinTrusted, ncProtocolIdleTimeout, ncTimeWaitTimeout, - ncPeerSharing + ncPeerSharing, + ncConsensusMode } daReadLocalRootPeers daReadPublicRootPeers @@ -910,7 +914,9 @@ mkP2PArguments NodeConfiguration { daReadUseBootstrapPeers daReadLedgerPeerSnapshot = Diffusion.P2PArguments P2P.ArgumentsExtra - { P2P.daPeerTargets + { P2P.daPeerTargets = Configuration.ConsensusModePeerTargets { + Configuration.deadlineTargets, + Configuration.syncTargets } , P2P.daReadLocalRootPeers , P2P.daReadPublicRootPeers , P2P.daReadUseLedgerPeers @@ -920,24 +926,27 @@ mkP2PArguments NodeConfiguration { , P2P.daMinBigLedgerPeersForTrustedState = ncMinBigLedgerPeersForTrustedState , P2P.daProtocolIdleTimeout = ncProtocolIdleTimeout , P2P.daTimeWaitTimeout = ncTimeWaitTimeout - , P2P.daDeadlineChurnInterval = 3300 - , P2P.daBulkChurnInterval = 900 + , P2P.daDeadlineChurnInterval = Configuration.defaultDeadlineChurnInterval + , P2P.daBulkChurnInterval = Configuration.defaultBulkChurnInterval , P2P.daOwnPeerSharing = ncPeerSharing + , P2P.daConsensusMode = ncConsensusMode + , P2P.daMinBigLedgerPeersForTrustedState = ncSyncMinTrusted } where - daPeerTargets = Configuration.ConsensusModePeerTargets { - Configuration.deadlineTargets = peerSelectionTargets, - Configuration.syncTargets = peerSelectionTargets - } - peerSelectionTargets = PeerSelectionTargets { - targetNumberOfRootPeers = ncTargetNumberOfRootPeers, - targetNumberOfKnownPeers = ncTargetNumberOfKnownPeers, - targetNumberOfEstablishedPeers = ncTargetNumberOfEstablishedPeers, - targetNumberOfActivePeers = ncTargetNumberOfActivePeers, - targetNumberOfKnownBigLedgerPeers = ncTargetNumberOfKnownBigLedgerPeers, - targetNumberOfEstablishedBigLedgerPeers = ncTargetNumberOfEstablishedBigLedgerPeers, - targetNumberOfActiveBigLedgerPeers = ncTargetNumberOfActiveBigLedgerPeers + deadlineTargets = Configuration.defaultDeadlineTargets { + targetNumberOfRootPeers = ncDeadlineTargetOfRootPeers, + targetNumberOfKnownPeers = ncDeadlineTargetOfKnownPeers, + targetNumberOfEstablishedPeers = ncDeadlineTargetOfEstablishedPeers, + targetNumberOfActivePeers = ncDeadlineTargetOfActivePeers, + targetNumberOfKnownBigLedgerPeers = ncDeadlineTargetOfKnownBigLedgerPeers, + targetNumberOfEstablishedBigLedgerPeers = ncDeadlineTargetOfEstablishedBigLedgerPeers, + targetNumberOfActiveBigLedgerPeers = ncDeadlineTargetOfActiveBigLedgerPeers } + syncTargets = Configuration.defaultSyncTargets { + targetNumberOfActivePeers = ncSyncTargetOfActivePeers, + targetNumberOfKnownBigLedgerPeers = ncSyncTargetOfKnownBigLedgerPeers, + targetNumberOfEstablishedBigLedgerPeers = ncSyncTargetOfEstablishedBigLedgerPeers, + targetNumberOfActiveBigLedgerPeers = ncSyncTargetOfActiveBigLedgerPeers } mkNonP2PArguments :: IPSubscriptionTarget diff --git a/cardano-node/test/Test/Cardano/Node/POM.hs b/cardano-node/test/Test/Cardano/Node/POM.hs index 882c5cede40..b6b59c403d9 100644 --- a/cardano-node/test/Test/Cardano/Node/POM.hs +++ b/cardano-node/test/Test/Cardano/Node/POM.hs @@ -18,10 +18,7 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..)) import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..), SnapshotInterval (..), pattern DoDiskSnapshotChecksum) import Ouroboros.Network.Block (SlotNo (..)) -import Ouroboros.Network.Diffusion.Configuration (MinBigLedgerPeersForTrustedState (..), defaultConsensusMode) -import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), - DiffusionMode (InitiatorAndResponderDiffusionMode)) -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) +import Ouroboros.Network.Diffusion.Configuration import Data.Monoid (Last (..)) import Data.Text (Text) @@ -118,7 +115,6 @@ testPartialYamlConfig = , pncSocketConfig = Last . Just $ SocketConfig (Last Nothing) mempty mempty mempty , pncShutdownConfig = Last Nothing , pncStartAsNonProducingNode = Last $ Just False - , pncConsensusMode = mempty , pncDiffusionMode = Last Nothing , pncNumOfDiskSnapshots = Last Nothing , pncSnapshotInterval = mempty @@ -147,9 +143,13 @@ testPartialYamlConfig = , pncTargetNumberOfKnownBigLedgerPeers = mempty , pncTargetNumberOfEstablishedBigLedgerPeers = mempty , pncTargetNumberOfActiveBigLedgerPeers = mempty - , pncMinBigLedgerPeersForTrustedState = pure (MinBigLedgerPeersForTrustedState 3) -- TODO: Review + , pncGenesisTargetNumberOfActivePeers = mempty + , pncGenesisTargetNumberOfKnownBigLedgerPeers = mempty + , pncGenesisTargetNumberOfEstablishedBigLedgerPeers = mempty + , pncGenesisTargetNumberOfActiveBigLedgerPeers = mempty , pncEnableP2P = Last (Just DisabledP2PMode) , pncPeerSharing = Last (Just PeerSharingDisabled) + , pncConsensusMode = Last (Just PraosMode) } -- | Example partial configuration theoretically created @@ -163,7 +163,6 @@ testPartialCliConfig = , pncConfigFile = mempty , pncTopologyFile = mempty , pncDatabaseFile = mempty - , pncConsensusMode = mempty , pncDiffusionMode = mempty , pncNumOfDiskSnapshots = Last Nothing , pncSnapshotInterval = Last . Just . RequestedSnapshotInterval $ secondsToDiffTime 100 @@ -190,9 +189,13 @@ testPartialCliConfig = , pncTargetNumberOfKnownBigLedgerPeers = mempty , pncTargetNumberOfEstablishedBigLedgerPeers = mempty , pncTargetNumberOfActiveBigLedgerPeers = mempty - , pncMinBigLedgerPeersForTrustedState = pure (MinBigLedgerPeersForTrustedState 3) -- TODO: Review + , pncGenesisTargetNumberOfActivePeers = mempty + , pncGenesisTargetNumberOfKnownBigLedgerPeers = mempty + , pncGenesisTargetNumberOfEstablishedBigLedgerPeers = mempty + , pncGenesisTargetNumberOfActiveBigLedgerPeers = mempty , pncEnableP2P = Last (Just DisabledP2PMode) , pncPeerSharing = Last (Just PeerSharingDisabled) + , pncConsensusMode = Last (Just GenesisMode) } -- | Expected final NodeConfiguration @@ -210,7 +213,6 @@ eExpectedConfig = do , ncProtocolFiles = ProtocolFilepaths Nothing Nothing Nothing Nothing Nothing Nothing , ncValidateDB = True , ncProtocolConfig = testNodeProtocolConfiguration - , ncConsensusMode = defaultConsensusMode , ncDiffusionMode = InitiatorAndResponderDiffusionMode , ncNumOfDiskSnapshots = DefaultNumOfDiskSnapshots , ncSnapshotInterval = RequestedSnapshotInterval $ secondsToDiffTime 100 @@ -232,16 +234,20 @@ eExpectedConfig = do , acceptedConnectionsSoftLimit = 384 , acceptedConnectionsDelay = 5 } - , ncTargetNumberOfRootPeers = 85 + , ncTargetNumberOfRootPeers = 60 , ncTargetNumberOfKnownPeers = 85 , ncTargetNumberOfEstablishedPeers = 40 , ncTargetNumberOfActivePeers = 15 , ncTargetNumberOfKnownBigLedgerPeers = 15 , ncTargetNumberOfEstablishedBigLedgerPeers = 10 , ncTargetNumberOfActiveBigLedgerPeers = 5 - , ncMinBigLedgerPeersForTrustedState = MinBigLedgerPeersForTrustedState 3 -- TODO: Review + , ncGenesisTargetNumberOfActivePeers = 0 + , ncGenesisTargetNumberOfKnownBigLedgerPeers = 100 + , ncGenesisTargetNumberOfEstablishedBigLedgerPeers = 50 + , ncGenesisTargetNumberOfActiveBigLedgerPeers = 30 , ncEnableP2P = SomeNetworkP2PMode Consensus.DisabledP2PMode , ncPeerSharing = PeerSharingDisabled + , ncConsensusMode = GenesisMode } -- ----------------------------------------------------------------------------- diff --git a/configuration/cardano/mainnet-config.json b/configuration/cardano/mainnet-config.json index 75d872ae24e..4bf2b5e4e63 100644 --- a/configuration/cardano/mainnet-config.json +++ b/configuration/cardano/mainnet-config.json @@ -16,6 +16,7 @@ "RequiresNetworkMagic": "RequiresNoMagic", "ShelleyGenesisFile": "mainnet-shelley-genesis.json", "ShelleyGenesisHash": "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81", + "ConsensusMode": "PraosMode" "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, "TargetNumberOfKnownPeers": 150, diff --git a/configuration/cardano/mainnet-config.yaml b/configuration/cardano/mainnet-config.yaml index 3427468ed8f..f774a429ec7 100644 --- a/configuration/cardano/mainnet-config.yaml +++ b/configuration/cardano/mainnet-config.yaml @@ -34,6 +34,7 @@ MaxKnownMajorProtocolVersion: 2 ##### Network Configuration ##### +ConsensusMode: PraosMode PeerSharing: True TargetNumberOfActivePeers: 20 TargetNumberOfEstablishedPeers: 50 diff --git a/configuration/cardano/shelley_qa-config.json b/configuration/cardano/shelley_qa-config.json index 925aefa76aa..2151c1908dc 100644 --- a/configuration/cardano/shelley_qa-config.json +++ b/configuration/cardano/shelley_qa-config.json @@ -17,6 +17,7 @@ "RequiresNetworkMagic": "RequiresMagic", "ShelleyGenesisFile": "shelley_qa-shelley-genesis.json", "ShelleyGenesisHash": "73a9f6bdb0aa97f5e63190a6f14a702bd64a21f2bec831cbfc28f6037128b952", + "ConsensusMode": "PraosMode" "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, "TargetNumberOfKnownPeers": 150,