Skip to content

renamed ForkPolicy configuration option as ResponderCoreAffinityPolicy #6192

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

Merged
merged 1 commit into from
May 29, 2025
Merged
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
37 changes: 21 additions & 16 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

module Cardano.Node.Configuration.POM
( NodeConfiguration (..)
, NCForkPolicy (..)
, ResponderCoreAffinityPolicy (..)
, NetworkP2PMode (..)
, SomeNetworkP2PMode (..)
, PartialNodeConfiguration(..)
Expand Down Expand Up @@ -51,7 +51,7 @@ import Ouroboros.Consensus.Storage.LedgerDB.Snapshots (NumOfDiskSnapsh
import Ouroboros.Consensus.Storage.LedgerDB.V1.Args (FlushFrequency (..))
import Ouroboros.Network.Diffusion.Configuration as Configuration
import qualified Ouroboros.Network.Diffusion.Configuration as Ouroboros
import Ouroboros.Network.Mux (ForkPolicy, noBindForkPolicy, responderForkPolicy)
import qualified Ouroboros.Network.Mux as Mux
import qualified Ouroboros.Network.PeerSelection.Governor as PeerSelection

import Control.Concurrent (getNumCapabilities)
Expand Down Expand Up @@ -199,20 +199,22 @@ data NodeConfiguration
-- Ouroboros Genesis
, ncGenesisConfig :: GenesisConfig

, ncForkPolicy :: NCForkPolicy
, ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy
} deriving (Eq, Show)

-- | We expose the `Ouroboros.Network.Mux.ForkPolicy` as a `NodeConfiguration` field.
-- * `NoBindForkPolicy` corresponds to `Ouroboros.Network.Mux.noBindForkPolicy`
-- * `ResponderForkPolicy` corresponds to `Ouroboros.Network.Mux.responderForkPolicy`
-- with a `randomIO` generated salt and `getNumCapabilities`
data NCForkPolicy = NoBindForkPolicy | ResponderForkPolicy deriving (Eq, Show, Generic, FromJSON)
--
-- * `NoResponderCoreAffinity` corresponds to `Ouroboros.Network.Mux.noBindForkPolicy`
-- * `ResponderCoreAffinity` corresponds to `Ouroboros.Network.Mux.responderForkPolicy`
-- with a `randomIO` generated salt and `getNumCapabilities`.
--
data ResponderCoreAffinityPolicy = NoResponderCoreAffinity | ResponderCoreAffinity deriving (Eq, Show, Generic, FromJSON)

-- | Convert `NCForkPolicy` to a `Ouroboros.Network.Mux.ForkPolicy`
getForkPolicy :: Hashable peerAddr => NCForkPolicy -> IO (ForkPolicy peerAddr)
getForkPolicy :: Hashable peerAddr => ResponderCoreAffinityPolicy -> IO (Mux.ForkPolicy peerAddr)
getForkPolicy = \case
NoBindForkPolicy -> pure noBindForkPolicy
ResponderForkPolicy -> responderForkPolicy <$> randomIO <*> getNumCapabilities
NoResponderCoreAffinity -> pure Mux.noBindForkPolicy
ResponderCoreAffinity -> Mux.responderForkPolicy <$> randomIO <*> getNumCapabilities

data PartialNodeConfiguration
= PartialNodeConfiguration
Expand Down Expand Up @@ -291,7 +293,7 @@ data PartialNodeConfiguration
-- Ouroboros Genesis
, pncGenesisConfigFlags :: !(Last GenesisConfigFlags)

, pncForkPolicy :: !(Last NCForkPolicy)
, pncResponderCoreAffinityPolicy :: !(Last ResponderCoreAffinityPolicy)
} deriving (Eq, Generic, Show)

instance AdjustFilePaths PartialNodeConfiguration where
Expand Down Expand Up @@ -402,7 +404,10 @@ instance FromJSON PartialNodeConfiguration where
-- pncConsensusMode determines whether Genesis is enabled in the first place.
pncGenesisConfigFlags <- Last <$> v .:? "LowLevelGenesisOptions"

pncForkPolicy <- Last <$> v .:? "ForkPolicy"
pncResponderCoreAffinityPolicy <-
(\a b -> Last a <> Last b)
<$> v .:? "ResponderCoreAffinityPolicy"
<*> v .:? "ForkPolicy" -- deprecated

pure PartialNodeConfiguration {
pncProtocolConfig
Expand Down Expand Up @@ -445,7 +450,7 @@ instance FromJSON PartialNodeConfiguration where
, pncEnableP2P
, pncPeerSharing
, pncGenesisConfigFlags
, pncForkPolicy
, pncResponderCoreAffinityPolicy
}
where
parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
Expand Down Expand Up @@ -682,7 +687,7 @@ defaultPartialNodeConfiguration =
, pncEnableP2P = Last (Just EnabledP2PMode)
, pncPeerSharing = Last (Just Ouroboros.defaultPeerSharing)
, pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
, pncForkPolicy = Last $ Just NoBindForkPolicy
, pncResponderCoreAffinityPolicy = Last $ Just NoResponderCoreAffinity
}
where
PeerSelectionTargets {
Expand Down Expand Up @@ -792,7 +797,7 @@ makeNodeConfiguration pnc = do
$ pncGenesisConfigFlags pnc
let ncGenesisConfig = mkGenesisConfig mGenesisConfigFlags

ncForkPolicy <- lastToEither "Missing ForkPolicy" $ pncForkPolicy pnc
ncResponderCoreAffinityPolicy <- lastToEither "Missing ResponderCoreAffinityPolicy" $ pncResponderCoreAffinityPolicy pnc

let deadlineTargets =
PeerSelectionTargets {
Expand Down Expand Up @@ -874,7 +879,7 @@ makeNodeConfiguration pnc = do
, ncPeerSharing
, ncConsensusMode
, ncGenesisConfig
, ncForkPolicy
, ncResponderCoreAffinityPolicy
}

ncProtocol :: NodeConfiguration -> Protocol
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 @@ -128,7 +128,7 @@ nodeRunParser = do
, pncEnableP2P = mempty
, pncPeerSharing = mempty
, pncGenesisConfigFlags = mempty
, pncForkPolicy = mempty
, pncResponderCoreAffinityPolicy = mempty
}

parseSocketPath :: Text -> Parser SocketPath
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 @@ -537,8 +537,8 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
)
Nothing
#endif
nForkPolicy <- getForkPolicy $ ncForkPolicy nc
cForkPolicy <- getForkPolicy $ ncForkPolicy nc
nForkPolicy <- getForkPolicy $ ncResponderCoreAffinityPolicy nc
cForkPolicy <- getForkPolicy $ ncResponderCoreAffinityPolicy nc
void $
let diffusionArgumentsExtra =
mkP2PArguments nForkPolicy cForkPolicy nc
Expand Down
6 changes: 3 additions & 3 deletions cardano-node/test/Test/Cardano/Node/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ testPartialYamlConfig =
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncConsensusMode = mempty
, pncGenesisConfigFlags = mempty
, pncForkPolicy = mempty
, pncResponderCoreAffinityPolicy = mempty
, pncLedgerDbConfig = mempty
, pncEgressPollInterval = mempty
}
Expand Down Expand Up @@ -212,7 +212,7 @@ testPartialCliConfig =
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncConsensusMode = Last (Just PraosMode)
, pncGenesisConfigFlags = mempty
, pncForkPolicy = mempty
, pncResponderCoreAffinityPolicy = mempty
, pncLedgerDbConfig = mempty
, pncEgressPollInterval = mempty
}
Expand Down Expand Up @@ -267,7 +267,7 @@ eExpectedConfig = do
, ncPeerSharing = PeerSharingDisabled
, ncConsensusMode = PraosMode
, ncGenesisConfig = disableGenesisConfig
, ncForkPolicy = NoBindForkPolicy
, ncResponderCoreAffinityPolicy = NoResponderCoreAffinity
, ncLedgerDbConfig = LedgerDbConfiguration DefaultNumOfDiskSnapshots DefaultSnapshotInterval DefaultQueryBatchSize V2InMemory noDeprecatedOptions
}

Expand Down
Loading