Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for big ledger peer snapshot in the topology file #5787

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bench/tx-generator/src/Cardano/Benchmarking/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@
import Data.List as List (unwords)
import Data.Time.Format as Time (defaultTimeLocale, formatTime)
import Data.Time.Clock.System as Time (getSystemTime, systemToUTCTime)
import Foreign.C (Errno(..))

Check warning on line 55 in bench/tx-generator/src/Cardano/Benchmarking/Command.hs

View workflow job for this annotation

GitHub Actions / build

Warning in module Cardano.Benchmarking.Command: Use fewer imports ▫︎ Found: "import Foreign.C ( Errno(..) )\nimport Foreign.C ( Errno(..) )\n" ▫︎ Perhaps: "import Foreign.C ( Errno(..), Errno(..) )\n"
import GHC.Weak as Weak (deRefWeak)

import System.Posix.Signals as Sig (Handler (CatchInfo),
SignalInfo (..), SignalSpecificInfo (..), installHandler,
sigINT, sigTERM)
import Foreign.C (Errno(..))
#if MIN_VERSION_base(4,18,0)
import Data.Maybe as Maybe (fromMaybe)
import GHC.Conc.Sync as Conc (threadLabel)
Expand Down
1 change: 1 addition & 0 deletions bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ library
, transformers-except
, unordered-containers
, yaml
, microlens

default-language: Haskell2010
default-extensions: OverloadedStrings
Expand Down
5 changes: 5 additions & 0 deletions cardano-node/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
- `--mempool-capacity-override` and `--no-mempool-capacity-override` can be set in the configuration file via the key `MempoolCapacityBytesOverride`.
- `--snapshot-interval` can be set in the configuration file via the key `SnapshotInterval`.
- `--num-of-disk-snapshots` can be set in the configuration file via the key `NumOfDiskSnapshots`.
- Ledger peer snapshot path entry added to topology JSON parser,
which a new decoder function `readPeerSnapshotFile` processes
at startup and SIGHUP. Data is available to the diffusion layer
via TVar.


- Use metric names of old-tracing in new-tracing as well, and fix some metrics in new tracing.

Expand Down
205 changes: 143 additions & 62 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ import Ouroboros.Consensus.Node (NodeDatabasePaths (..))
import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..),
SnapshotInterval (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.Diffusion.Configuration as Configuration

import Control.Monad (when)
import Data.Aeson
Expand Down Expand Up @@ -150,13 +149,26 @@ data NodeConfiguration
, ncAcceptedConnectionsLimit :: !AcceptedConnectionsLimit

-- P2P governor targets
, ncTargetNumberOfRootPeers :: Int
, ncTargetNumberOfKnownPeers :: Int
, ncTargetNumberOfEstablishedPeers :: Int
, ncTargetNumberOfActivePeers :: Int
, ncTargetNumberOfKnownBigLedgerPeers :: Int
, ncTargetNumberOfEstablishedBigLedgerPeers :: Int
, ncTargetNumberOfActiveBigLedgerPeers :: Int
, 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

-- Minimum number of active big ledger peers we must be connected to
-- in Genesis mode
, ncMinBigLedgerPeersForTrustedState :: MinBigLedgerPeersForTrustedState

-- Enable experimental P2P mode
, ncEnableP2P :: SomeNetworkP2PMode
Expand Down Expand Up @@ -185,7 +197,7 @@ data PartialNodeConfiguration
, pncProtocolConfig :: !(Last NodeProtocolConfiguration)

-- Node parameters, not protocol-specific:
, pncDiffusionMode :: !(Last DiffusionMode )
, pncDiffusionMode :: !(Last DiffusionMode)
, pncNumOfDiskSnapshots :: !(Last NumOfDiskSnapshots)
, pncSnapshotInterval :: !(Last SnapshotInterval)
, pncExperimentalProtocolsEnabled :: !(Last Bool)
Expand Down Expand Up @@ -213,13 +225,23 @@ 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)
, 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)
-- Minimum number of active big ledger peers we must be connected to
-- in Genesis mode
, pncMinBigLedgerPeersForTrustedState :: !(Last MinBigLedgerPeersForTrustedState)

-- Consensus mode for diffusion layer
, pncConsensusMode :: !(Last ConsensusMode)

-- Enable experimental P2P mode
, pncEnableP2P :: !(Last NetworkP2PMode)
Expand Down Expand Up @@ -301,13 +323,22 @@ 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"
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"
-- Minimum number of active big ledger peers we must be connected to
-- in Genesis mode
pncMinBigLedgerPeersForTrustedState <- Last <$> v .:? "MinBigLedgerPeersForTrustedState"

pncConsensusMode <- Last <$> v .:? "ConsensusMode"

pncChainSyncIdleTimeout <- Last <$> v .:? "ChainSyncIdleTimeout"

Expand All @@ -321,7 +352,7 @@ instance FromJSON PartialNodeConfiguration where

-- Peer Sharing
-- DISABLED BY DEFAULT
pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just PeerSharingDisabled
pncPeerSharing <- Last <$> v .:? "PeerSharing"

pure PartialNodeConfiguration {
pncProtocolConfig
Expand All @@ -348,13 +379,19 @@ instance FromJSON PartialNodeConfiguration where
, pncTimeWaitTimeout
, pncChainSyncIdleTimeout
, pncAcceptedConnectionsLimit
, pncTargetNumberOfRootPeers
, pncTargetNumberOfKnownPeers
, pncTargetNumberOfEstablishedPeers
, pncTargetNumberOfActivePeers
, pncTargetNumberOfKnownBigLedgerPeers
, pncTargetNumberOfEstablishedBigLedgerPeers
, pncTargetNumberOfActiveBigLedgerPeers
, pncDeadlineTargetOfRootPeers
, pncDeadlineTargetOfKnownPeers
, pncDeadlineTargetOfEstablishedPeers
, pncDeadlineTargetOfActivePeers
, pncDeadlineTargetOfKnownBigLedgerPeers
, pncDeadlineTargetOfEstablishedBigLedgerPeers
, pncDeadlineTargetOfActiveBigLedgerPeers
, pncSyncTargetOfActivePeers
, pncSyncTargetOfKnownBigLedgerPeers
, pncSyncTargetOfEstablishedBigLedgerPeers
, pncSyncTargetOfActiveBigLedgerPeers
, pncMinBigLedgerPeersForTrustedState
, pncConsensusMode
, pncEnableP2P
, pncPeerSharing
}
Expand Down Expand Up @@ -523,17 +560,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)
, 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)
, pncMinBigLedgerPeersForTrustedState = Last (Just defaultMinBigLedgerPeersForTrustedState)
, pncConsensusMode = Last (Just defaultConsensusMode)
, pncEnableP2P = Last (Just EnabledP2PMode)
, pncPeerSharing = Last (Just defaultPeerSharing)
}
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
Expand All @@ -555,27 +612,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
$ 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
ncMinBigLedgerPeersForTrustedState <-
lastToEither "Missing MinBigLedgerPeersForTrustedState"
$ pncMinBigLedgerPeersForTrustedState pnc
ncConsensusMode <-
lastToEither "Missing ConsensusMode"
$ pncConsensusMode pnc
ncProtocolIdleTimeout <-
lastToEither "Missing ProtocolIdleTimeout"
$ pncProtocolIdleTimeout pnc
Expand Down Expand Up @@ -634,17 +709,23 @@ makeNodeConfiguration pnc = do
, ncTimeWaitTimeout
, ncChainSyncIdleTimeout
, ncAcceptedConnectionsLimit
, ncTargetNumberOfRootPeers
, ncTargetNumberOfKnownPeers
, ncTargetNumberOfEstablishedPeers
, ncTargetNumberOfActivePeers
, ncTargetNumberOfKnownBigLedgerPeers
, ncTargetNumberOfEstablishedBigLedgerPeers
, ncTargetNumberOfActiveBigLedgerPeers
, ncDeadlineTargetOfRootPeers
, ncDeadlineTargetOfKnownPeers
, ncDeadlineTargetOfEstablishedPeers
, ncDeadlineTargetOfActivePeers
, ncDeadlineTargetOfKnownBigLedgerPeers
, ncDeadlineTargetOfEstablishedBigLedgerPeers
, ncDeadlineTargetOfActiveBigLedgerPeers
, ncSyncTargetOfActivePeers
, ncSyncTargetOfKnownBigLedgerPeers
, ncSyncTargetOfEstablishedBigLedgerPeers
, ncSyncTargetOfActiveBigLedgerPeers
, ncMinBigLedgerPeersForTrustedState
, ncEnableP2P = case enableP2P of
EnabledP2PMode -> SomeNetworkP2PMode Consensus.EnabledP2PMode
DisabledP2PMode -> SomeNetworkP2PMode Consensus.DisabledP2PMode
, ncPeerSharing
, ncConsensusMode
}

ncProtocol :: NodeConfiguration -> Protocol
Expand Down
Loading
Loading