diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index 7c1c1588782..61f17699c29 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -87,6 +87,8 @@ data NodeConfiguration , ncValidateDB :: !Bool , ncShutdownConfig :: !ShutdownConfig + , ncStartAsNonProducingNode :: !Bool + -- Protocol-specific parameters: , ncProtocolConfig :: !NodeProtocolConfiguration @@ -159,6 +161,8 @@ data PartialNodeConfiguration , pncValidateDB :: !(Last Bool) , pncShutdownConfig :: !(Last ShutdownConfig) + , pncStartAsNonProducingNode :: !(Last Bool) + -- Protocol-specific parameters: , pncProtocolConfig :: !(Last NodeProtocolConfiguration) @@ -309,6 +313,7 @@ instance FromJSON PartialNodeConfiguration where , pncProtocolFiles = mempty , pncValidateDB = mempty , pncShutdownConfig = mempty + , pncStartAsNonProducingNode = Last $ Just False , pncMaybeMempoolCapacityOverride , pncProtocolIdleTimeout , pncTimeWaitTimeout @@ -466,6 +471,7 @@ defaultPartialNodeConfiguration = , pncProtocolFiles = mempty , pncValidateDB = Last $ Just False , pncShutdownConfig = Last . Just $ ShutdownConfig Nothing Nothing + , pncStartAsNonProducingNode = Last $ Just False , pncProtocolConfig = mempty , pncMaxConcurrencyBulkSync = mempty , pncMaxConcurrencyDeadline = mempty @@ -500,6 +506,7 @@ makeNodeConfiguration pnc = do topologyFile <- lastToEither "Missing TopologyFile" $ pncTopologyFile pnc databaseFile <- lastToEither "Missing DatabaseFile" $ pncDatabaseFile pnc validateDB <- lastToEither "Missing ValidateDB" $ pncValidateDB pnc + startAsNonProducingNode <- lastToEither "Missing StartAsNonProducingNode" $ pncStartAsNonProducingNode pnc protocolConfig <- lastToEither "Missing ProtocolConfig" $ pncProtocolConfig pnc loggingSwitch <- lastToEither "Missing LoggingSwitch" $ pncLoggingSwitch pnc logMetrics <- lastToEither "Missing LogMetrics" $ pncLogMetrics pnc @@ -555,6 +562,7 @@ makeNodeConfiguration pnc = do Nothing -> ProtocolFilepaths Nothing Nothing Nothing Nothing Nothing Nothing , ncValidateDB = validateDB , ncShutdownConfig = shutdownConfig + , ncStartAsNonProducingNode = startAsNonProducingNode , ncProtocolConfig = protocolConfig , ncSocketConfig = socketConfig , ncDiffusionMode = diffusionMode diff --git a/cardano-node/src/Cardano/Node/Parsers.hs b/cardano-node/src/Cardano/Node/Parsers.hs index 26e227f021a..2c0099ba89f 100644 --- a/cardano-node/src/Cardano/Node/Parsers.hs +++ b/cardano-node/src/Cardano/Node/Parsers.hs @@ -62,6 +62,7 @@ nodeRunParser = do shelleyVRFFile <- optional parseVrfKeyFilePath shelleyCertFile <- optional parseOperationalCertFilePath shelleyBulkCredsFile <- optional parseBulkCredsFilePath + startAsNonProducingNode <- lastOption parseStartAsNonProducingNode -- Node Address nIPv4Address <- lastOption parseHostIPv4Addr @@ -102,6 +103,7 @@ nodeRunParser = do , pncValidateDB = validate , pncShutdownConfig = Last . Just $ ShutdownConfig (getLast shutdownIPC) (getLast shutdownOnLimit) + , pncStartAsNonProducingNode = startAsNonProducingNode , pncProtocolConfig = mempty , pncMaxConcurrencyBulkSync = mempty , pncMaxConcurrencyDeadline = mempty @@ -313,6 +315,14 @@ parseVrfKeyFilePath = <> completer (bashCompleter "file") ) +parseStartAsNonProducingNode :: Parser Bool +parseStartAsNonProducingNode = + switch ( + long "start-as-non-producing-node" + <> help ("Start the node as a non block producing node even if " + ++ "credentials are specified.") + ) + -- TODO revisit because it sucks parseSnapshotInterval :: Parser SnapshotInterval parseSnapshotInterval = fmap (RequestedSnapshotInterval . secondsToDiffTime) parseDifftime diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index 3046aca1277..30220a2379a 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -411,7 +411,8 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do -- set the initial block forging blockForging <- snd (Api.protocolInfo runP) - setBlockForging nodeKernel blockForging + unless (ncStartAsNonProducingNode nc) $ + setBlockForging nodeKernel blockForging maybeSpawnOnSlotSyncedShutdownHandler (ncShutdownConfig nc) diff --git a/cardano-node/test/Test/Cardano/Node/POM.hs b/cardano-node/test/Test/Cardano/Node/POM.hs index b23b3c941fe..c54abaee3ba 100644 --- a/cardano-node/test/Test/Cardano/Node/POM.hs +++ b/cardano-node/test/Test/Cardano/Node/POM.hs @@ -52,9 +52,10 @@ testPartialYamlConfig = { pncProtocolConfig = Last . Just . NodeProtocolConfigurationShelley $ NodeShelleyProtocolConfiguration - (GenesisFile "dummmy-genesis-file") Nothing + (GenesisFile "dummmsy-genesis-file") Nothing , pncSocketConfig = Last . Just $ SocketConfig (Last Nothing) mempty mempty mempty , pncShutdownConfig = Last Nothing + , pncStartAsNonProducingNode = Last $ Just False , pncDiffusionMode = Last Nothing , pncSnapshotInterval = mempty , pncExperimentalProtocolsEnabled = Last Nothing @@ -88,6 +89,7 @@ testPartialCliConfig = PartialNodeConfiguration { pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty mempty , pncShutdownConfig = Last . Just $ ShutdownConfig Nothing (Just . ASlot $ SlotNo 42) + , pncStartAsNonProducingNode = Last $ Just $ False , pncConfigFile = mempty , pncTopologyFile = mempty , pncDatabaseFile = mempty @@ -123,6 +125,7 @@ eExpectedConfig = do return $ NodeConfiguration { ncSocketConfig = SocketConfig mempty mempty mempty mempty , ncShutdownConfig = ShutdownConfig Nothing (Just . ASlot $ SlotNo 42) + , ncStartAsNonProducingNode = False , ncConfigFile = ConfigYamlFilePath "configuration/cardano/mainnet-config.json" , ncTopologyFile = TopologyFile "configuration/cardano/mainnet-topology.json" , ncDatabaseFile = DbFile "mainnet/db/"