Skip to content

Commit

Permalink
Deprecate consensus internal options on cli flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed May 27, 2024
1 parent 2770221 commit 305d328
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
6 changes: 6 additions & 0 deletions cardano-node/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
## Next version

- Use p2p network stack by default, warn when using the legacy network stack.
- Deprecate some CLI flags corresponding to low-level consensus options. They are
still accepted but a warning is emitted on startup on stderr suggesting to set
them in the configuration file instead:
- `--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`.

## 8.2.1 -- August 2023

Expand Down
21 changes: 19 additions & 2 deletions cardano-node/app/cardano-node.hs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE GADTs #-}

import qualified Cardano.Crypto.Init as Crypto
import Cardano.Git.Rev (gitRev)
import Cardano.Node.Configuration.POM (PartialNodeConfiguration)
import Cardano.Node.Configuration.POM (PartialNodeConfiguration(..))
import Cardano.Node.Handlers.TopLevel
import Cardano.Node.Parsers (nodeCLIParser, parserHelpHeader, parserHelpOptions,
renderHelpDoc)
import Cardano.Node.Run (runNode)
import Cardano.Node.Tracing.Documentation (TraceDocumentationCmd (..),
parseTraceDocumentationCmd, runTraceDocumentationCmd)

import Data.Monoid (Last (getLast))
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Version (showVersion)
import Options.Applicative
import qualified Options.Applicative as Opt
import Options.Applicative.Help ((<$$>))
import System.Info (arch, compilerName, compilerVersion, os)
import System.IO (hPutStrLn, stderr)

import Paths_cardano_node (version)

Expand All @@ -30,13 +33,27 @@ main = do
cmd <- Opt.customExecParser p opts

case cmd of
RunCmd args -> runNode args
RunCmd args -> do
warnIfSet args pncMaybeMempoolCapacityOverride "mempool-capacity-override" "MempoolCapacityBytesOverride"
warnIfSet args pncNumOfDiskSnapshots "num-of-disk-snapshots" "NumOfDiskSnapshots"
warnIfSet args pncSnapshotInterval "snapshot-interval" "SnapshotInterval"
runNode args
TraceDocumentation tdc -> runTraceDocumentationCmd tdc
VersionCmd -> runVersionCommand

where
p = Opt.prefs Opt.showHelpOnEmpty

warnIfSet :: PartialNodeConfiguration -> (PartialNodeConfiguration -> Last a) -> String -> String -> IO ()
warnIfSet args f name key =
maybe
(pure ())
(\_ -> hPutStrLn stderr $ "WARNING: Option --" ++ name ++ " was set via CLI flags.\
\ This CLI flag will be removed in upcoming node releases.\
\ Please, set this configuration option in the configuration file instead with key " ++ key ++ ".")
$ getLast
$ f args

opts :: Opt.ParserInfo Command
opts =
Opt.info (fmap RunCmd nodeCLIParser
Expand Down
20 changes: 10 additions & 10 deletions cardano-node/src/Cardano/Node/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ nodeRunParser = do
-- Filepaths
topFp <- lastOption parseTopologyFile
dbFp <- lastOption parseDbPath
validate <- lastOption parseValidateDB
socketFp <- lastOption $ parseSocketPath "Path to a cardano-node socket"
traceForwardSocket <- lastOption parseTracerSocketMode
nodeConfigFp <- lastOption parseConfigFile

-- Protocol files
byronCertFile <- optional parseByronDelegationCert
Expand All @@ -68,15 +70,13 @@ nodeRunParser = do
nIPv6Address <- lastOption parseHostIPv6Addr
nPortNumber <- lastOption parsePort

-- NodeConfiguration filepath
nodeConfigFp <- lastOption parseConfigFile
numOfDiskSnapshots <- lastOption parseNumOfDiskSnapshots
snapshotInterval <- lastOption parseSnapshotInterval

validate <- lastOption parseValidateDB
-- Shutdown
shutdownIPC <- lastOption parseShutdownIPC
shutdownOnLimit <- lastOption parseShutdownOn

-- Hidden options (to be removed eventually)
numOfDiskSnapshots <- lastOption parseNumOfDiskSnapshots
snapshotInterval <- lastOption parseSnapshotInterval
maybeMempoolCapacityOverride <- lastOption parseMempoolCapacityOverride

pure $ PartialNodeConfiguration
Expand Down Expand Up @@ -215,13 +215,13 @@ parseMempoolCapacityOverride = parseOverride <|> parseNoOverride
Opt.option (auto @Word32)
( long "mempool-capacity-override"
<> metavar "BYTES"
<> help "The number of bytes"
<> help "[DEPRECATED: Set it in config file with key MempoolCapacityBytesOverride] The number of bytes"
)
parseNoOverride :: Parser MempoolCapacityBytesOverride
parseNoOverride =
flag' NoMempoolCapacityBytesOverride
( long "no-mempool-capacity-override"
<> help "The port number"
<> help "[DEPRECATED: Set it in config file] Don't override mempool capacity"
)

parseDbPath :: Parser FilePath
Expand Down Expand Up @@ -336,7 +336,7 @@ parseNumOfDiskSnapshots = fmap RequestedNumOfDiskSnapshots parseNum
parseNum = Opt.option auto
( long "num-of-disk-snapshots"
<> metavar "NUMOFDISKSNAPSHOTS"
<> help "Number of ledger snapshots stored on disk."
<> help "[DEPRECATED: Set it in config file with key NumOfDiskSnapshots] Number of ledger snapshots stored on disk."
)

-- TODO revisit because it sucks
Expand All @@ -346,7 +346,7 @@ parseSnapshotInterval = fmap (RequestedSnapshotInterval . secondsToDiffTime) par
parseDifftime = Opt.option auto
( long "snapshot-interval"
<> metavar "SNAPSHOTINTERVAL"
<> help "Snapshot Interval (in seconds)"
<> help "[DEPRECATED: Set it in config file with key SnapshotInterval] Snapshot Interval (in seconds)"
)

-- | Produce just the brief help header for a given CLI option parser,
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ instance ( LogFormatting (Header blk)
"Added request to queue to reprocess blocks postponed by LoE."
forHuman ChainDB.PoppedReprocessLoEBlocksFromQueue =
"Poppped request from queue to reprocess blocks postponed by LoE."
forHuman ChainDB.ChainSelectionLoEDebug {} =
forHuman ChainDB.ChainSelectionLoEDebug{} =
"ChainDB LoE debug event"
forMachine dtal (ChainDB.IgnoreBlockOlderThanK pt) =
mconcat [ "kind" .= String "IgnoreBlockOlderThanK"
Expand Down

0 comments on commit 305d328

Please sign in to comment.