Skip to content

Commit

Permalink
Integrate o-network and o-consensus
Browse files Browse the repository at this point in the history
Missing updating Node Configuration parser to read genesis targets and
ledger snapshot.
  • Loading branch information
crocodile-dentist authored and neilmayhew committed Dec 19, 2024
1 parent 6a5331f commit 1dbbe6c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 51 deletions.
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 @@ -58,6 +58,7 @@ 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
30 changes: 19 additions & 11 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ data NodeConfiguration
-- 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 @@ -236,7 +240,9 @@ data PartialNodeConfiguration
, pncSyncTargetOfKnownBigLedgerPeers :: !(Last Int)
, pncSyncTargetOfEstablishedBigLedgerPeers :: !(Last Int)
, pncSyncTargetOfActiveBigLedgerPeers :: !(Last Int)
, pncSyncMinTrusted :: !(Last MinBigLedgerPeersForTrustedState)
-- 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)
Expand Down Expand Up @@ -334,7 +340,9 @@ instance FromJSON PartialNodeConfiguration where
pncSyncTargetOfKnownBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfKnownBigLedgerPeers"
pncSyncTargetOfEstablishedBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfEstablishedBigLedgerPeers"
pncSyncTargetOfActiveBigLedgerPeers <- Last <$> v .:? "SyncTargetNumberOfActiveBigLedgerPeers"
pncSyncMinTrusted <- Last <$> v .:? "SyncMinNumberOfBigLedgerPeersForTrustedState"
-- Minimum number of active big ledger peers we must be connected to
-- in Genesis mode
pncMinBigLedgerPeersForTrustedState <- Last <$> v .:? "MinBigLedgerPeersForTrustedState"

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

Expand All @@ -350,7 +358,7 @@ instance FromJSON PartialNodeConfiguration where

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

pure PartialNodeConfiguration {
pncProtocolConfig
Expand Down Expand Up @@ -390,7 +398,7 @@ instance FromJSON PartialNodeConfiguration where
, pncSyncTargetOfKnownBigLedgerPeers
, pncSyncTargetOfEstablishedBigLedgerPeers
, pncSyncTargetOfActiveBigLedgerPeers
, pncSyncMinTrusted
, pncMinBigLedgerPeersForTrustedState
, pncConsensusMode
, pncEnableP2P
, pncPeerSharing
Expand Down Expand Up @@ -573,10 +581,10 @@ defaultPartialNodeConfiguration =
, pncSyncTargetOfKnownBigLedgerPeers = Last (Just syncBigKnown)
, pncSyncTargetOfEstablishedBigLedgerPeers = Last (Just syncBigEst)
, pncSyncTargetOfActiveBigLedgerPeers = Last (Just syncBigAct)
, pncSyncMinTrusted = Last (Just defaultMinBigLedgerPeersForTrustedState)
, pncConsensusMode = mempty
, pncMinBigLedgerPeersForTrustedState = Last (Just defaultMinBigLedgerPeersForTrustedState)
, pncConsensusMode = Last (Just defaultConsensusMode)
, pncEnableP2P = Last (Just EnabledP2PMode)
, pncPeerSharing = Last (Just Configuration.PeerSharingDisabled)
, pncPeerSharing = Last (Just defaultPeerSharing)
}
where
Configuration.PeerSelectionTargets {
Expand Down Expand Up @@ -648,9 +656,9 @@ makeNodeConfiguration pnc = do
ncSyncTargetOfActiveBigLedgerPeers <-
lastToEither "Missing SyncTargetNumberOfActiveBigLedgerPeers"
$ pncSyncTargetOfActiveBigLedgerPeers pnc
ncSyncMinTrusted <-
lastToEither "Missing SyncMinNumberOfBigLedgerPeersForTrustedState"
$ pncSyncMinTrusted pnc
ncMinBigLedgerPeersForTrustedState <-
lastToEither "Missing MinBigLedgerPeersForTrustedState"
$ pncMinBigLedgerPeersForTrustedState pnc
ncConsensusMode <-
lastToEither "Missing ConsensusMode"
$ pncConsensusMode pnc
Expand Down Expand Up @@ -724,7 +732,7 @@ makeNodeConfiguration pnc = do
, ncSyncTargetOfKnownBigLedgerPeers
, ncSyncTargetOfEstablishedBigLedgerPeers
, ncSyncTargetOfActiveBigLedgerPeers
, ncSyncMinTrusted
, ncMinBigLedgerPeersForTrustedState
, ncEnableP2P = case enableP2P of
EnabledP2PMode -> SomeNetworkP2PMode Consensus.EnabledP2PMode
DisabledP2PMode -> SomeNetworkP2PMode Consensus.DisabledP2PMode
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ nodeRunParser = do
, pncSyncTargetOfKnownBigLedgerPeers = mempty
, pncSyncTargetOfEstablishedBigLedgerPeers = mempty
, pncSyncTargetOfActiveBigLedgerPeers = mempty
, pncSyncMinTrusted = mempty
, pncMinBigLedgerPeersForTrustedState = mempty
, pncConsensusMode = mempty
, pncEnableP2P = mempty
, pncPeerSharing = mempty
Expand Down
4 changes: 2 additions & 2 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ mkP2PArguments NodeConfiguration {
ncSyncTargetOfKnownBigLedgerPeers,
ncSyncTargetOfEstablishedBigLedgerPeers,
ncSyncTargetOfActiveBigLedgerPeers,
ncSyncMinTrusted,
ncMinBigLedgerPeersForTrustedState,
ncProtocolIdleTimeout,
ncTimeWaitTimeout,
ncPeerSharing,
Expand Down Expand Up @@ -930,7 +930,7 @@ mkP2PArguments NodeConfiguration {
, P2P.daBulkChurnInterval = Configuration.defaultBulkChurnInterval
, P2P.daOwnPeerSharing = ncPeerSharing
, P2P.daConsensusMode = ncConsensusMode
, P2P.daMinBigLedgerPeersForTrustedState = ncSyncMinTrusted
, P2P.daMinBigLedgerPeersForTrustedState = ncMinBigLedgerPeersForTrustedState
}
where
deadlineTargets = Configuration.defaultDeadlineTargets {
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ instance MetaTrace (TracePeerSelection SockAddr) where
documentFor (Namespace [] ["DebugState"]) = Just
"peer selection internal state"
documentFor (Namespace [] ["VerifyPeerSnapshot"]) = Just
"Big ledger peer snapshot file failed integrity check against the ledger"
"Verification outcome of big ledger peer snapshot"
documentFor _ = Nothing

metricsDocFor (Namespace [] ["ChurnAction"]) =
Expand Down
75 changes: 39 additions & 36 deletions cardano-node/test/Test/Cardano/Node/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,21 @@ testPartialYamlConfig =
, pncTimeWaitTimeout = mempty
, pncChainSyncIdleTimeout = mempty
, pncAcceptedConnectionsLimit = mempty
, pncTargetNumberOfRootPeers = mempty
, pncTargetNumberOfKnownPeers = mempty
, pncTargetNumberOfEstablishedPeers = mempty
, pncTargetNumberOfActivePeers = mempty
, pncTargetNumberOfKnownBigLedgerPeers = mempty
, pncTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncTargetNumberOfActiveBigLedgerPeers = mempty
, pncGenesisTargetNumberOfActivePeers = mempty
, pncGenesisTargetNumberOfKnownBigLedgerPeers = mempty
, pncGenesisTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncGenesisTargetNumberOfActiveBigLedgerPeers = mempty
, pncDeadlineTargetOfRootPeers = mempty
, pncDeadlineTargetOfKnownPeers = mempty
, pncDeadlineTargetOfEstablishedPeers = mempty
, pncDeadlineTargetOfActivePeers = mempty
, pncDeadlineTargetOfKnownBigLedgerPeers = mempty
, pncDeadlineTargetOfEstablishedBigLedgerPeers = mempty
, pncDeadlineTargetOfActiveBigLedgerPeers = mempty
, pncSyncTargetNumberOfActivePeers = mempty
, pncSyncTargetNumberOfKnownBigLedgerPeers = mempty
, pncSyncTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncSyncTargetNumberOfActiveBigLedgerPeers = mempty
, pncMinBigLedgerPeersForTrustedState = mempty
, pncEnableP2P = Last (Just DisabledP2PMode)
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncConsensusMode = Last (Just PraosMode)
, pncConsensusMode = mempty
}

-- | Example partial configuration theoretically created
Expand Down Expand Up @@ -182,20 +183,21 @@ testPartialCliConfig =
, pncTimeWaitTimeout = mempty
, pncChainSyncIdleTimeout = mempty
, pncAcceptedConnectionsLimit = mempty
, pncTargetNumberOfRootPeers = mempty
, pncTargetNumberOfKnownPeers = mempty
, pncTargetNumberOfEstablishedPeers = mempty
, pncTargetNumberOfActivePeers = mempty
, pncTargetNumberOfKnownBigLedgerPeers = mempty
, pncTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncTargetNumberOfActiveBigLedgerPeers = mempty
, pncGenesisTargetNumberOfActivePeers = mempty
, pncGenesisTargetNumberOfKnownBigLedgerPeers = mempty
, pncGenesisTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncGenesisTargetNumberOfActiveBigLedgerPeers = mempty
, pncDeadlineTargetNumberOfRootPeers = mempty
, pncDeadlineTargetNumberOfKnownPeers = mempty
, pncDeadlineTargetNumberOfEstablishedPeers = mempty
, pncDeadlineTargetNumberOfActivePeers = mempty
, pncDeadlineTargetNumberOfKnownBigLedgerPeers = mempty
, pncDeadlineTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncDeadlineTargetNumberOfActiveBigLedgerPeers = mempty
, pncSyncTargetNumberOfActivePeers = mempty
, pncSyncTargetNumberOfKnownBigLedgerPeers = mempty
, pncSyncTargetNumberOfEstablishedBigLedgerPeers = mempty
, pncSyncTargetNumberOfActiveBigLedgerPeers = mempty
, pncMinBigLedgerPeersForTrustedState = Last (Just defaultMinBigLedgerPeersForTrustedState)
, pncEnableP2P = Last (Just DisabledP2PMode)
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncConsensusMode = Last (Just GenesisMode)
, pncConsensusMode = Last (Just PraosMode)
}

-- | Expected final NodeConfiguration
Expand Down Expand Up @@ -234,20 +236,21 @@ eExpectedConfig = do
, acceptedConnectionsSoftLimit = 384
, acceptedConnectionsDelay = 5
}
, ncTargetNumberOfRootPeers = 60
, ncTargetNumberOfKnownPeers = 85
, ncTargetNumberOfEstablishedPeers = 40
, ncTargetNumberOfActivePeers = 15
, ncTargetNumberOfKnownBigLedgerPeers = 15
, ncTargetNumberOfEstablishedBigLedgerPeers = 10
, ncTargetNumberOfActiveBigLedgerPeers = 5
, ncGenesisTargetNumberOfActivePeers = 0
, ncGenesisTargetNumberOfKnownBigLedgerPeers = 100
, ncGenesisTargetNumberOfEstablishedBigLedgerPeers = 50
, ncGenesisTargetNumberOfActiveBigLedgerPeers = 30
, ncDeadlineTargetNumberOfRootPeers = 60
, ncDeadlineTargetNumberOfKnownPeers = 85
, ncDeadlineTargetNumberOfEstablishedPeers = 40
, ncDeadlineTargetNumberOfActivePeers = 15
, ncDeadlineTargetNumberOfKnownBigLedgerPeers = 15
, ncDeadlineTargetNumberOfEstablishedBigLedgerPeers = 10
, ncDeadlineTargetNumberOfActiveBigLedgerPeers = 5
, ncSyncTargetNumberOfActivePeers = 0
, ncSyncTargetNumberOfKnownBigLedgerPeers = 100
, ncSyncTargetNumberOfEstablishedBigLedgerPeers = 50
, ncSyncTargetNumberOfActiveBigLedgerPeers = 30
, ncMinBigLedgerPeersForTrustedState = defaultMinBigLedgerPeersForTrustedState
, ncEnableP2P = SomeNetworkP2PMode Consensus.DisabledP2PMode
, ncPeerSharing = PeerSharingDisabled
, ncConsensusMode = GenesisMode
, ncConsensusMode = PraosMode
}

-- -----------------------------------------------------------------------------
Expand Down

0 comments on commit 1dbbe6c

Please sign in to comment.