From b90ea7b3e34b7269c6c64364b4585f5aca0621d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 30 Jan 2025 17:52:00 +0100 Subject: [PATCH] cardano-testnet: allow to take config files as input --- cardano-testnet/src/Parsers/Cardano.hs | 10 ++++++++++ cardano-testnet/src/Testnet/Start/Types.hs | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index aa4767e89ba..e5795c969bd 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -57,10 +57,20 @@ pCardanoTestnetCliOptions envCli = CardanoTestnetOptions <> OA.help "Enable new epoch state logging to logs/ledger-epoch-state.log" <> OA.showDefault ) + <*> optional parseConfigFiles where pAnyShelleyBasedEra' :: Parser AnyShelleyBasedEra pAnyShelleyBasedEra' = pAnyShelleyBasedEra envCli <&> (\(EraInEon x) -> AnyShelleyBasedEra x) + parseConfigFiles :: Parser InputConfigFiles + parseConfigFiles = + InputConfigFiles + <$> make "node-config" "Path to the node's configuration file" + <*> make "shelley-genesis" "Path to the Shelley genesis file" + <*> make "alonzo-genesis" "Path to the Alonzo genesis file" + <*> make "conway-genesis" "Path to the Conway genesis file" + where + make flagName helpName = strOption ( long flagName <> metavar "FILEPATH" <> help helpName) pNumSpoNodes :: Parser [TestnetNodeOptions] pNumSpoNodes = diff --git a/cardano-testnet/src/Testnet/Start/Types.hs b/cardano-testnet/src/Testnet/Start/Types.hs index 53764c27b6b..19a6e66f43a 100644 --- a/cardano-testnet/src/Testnet/Start/Types.hs +++ b/cardano-testnet/src/Testnet/Start/Types.hs @@ -7,6 +7,7 @@ module Testnet.Start.Types ( CardanoTestnetCliOptions(..) , CardanoTestnetOptions(..) + , InputConfigFiles(..) , NumDReps(..) , NumPools(..) , NumRelays(..) @@ -74,8 +75,17 @@ data CardanoTestnetOptions = CardanoTestnetOptions , cardanoNodeLoggingFormat :: NodeLoggingFormat , cardanoNumDReps :: NumDReps -- ^ The number of DReps to generate at creation , cardanoEnableNewEpochStateLogging :: Bool -- ^ if epoch state logging is enabled + , cardanoInputConfigs :: Maybe InputConfigFiles -- ^ Paths to the (optional) configuration files } deriving (Eq, Show) +data InputConfigFiles = InputConfigFiles + { icfNodeConfigFile :: FilePath -- ^ Path to the configuration file of the node + , icfShelleyGenesisConfigFile :: FilePath -- ^ Path to the Shelley genesis file + , icfAlonzoGenesisConfigFile :: FilePath -- ^ Path to the Alonzo genesis file + , icfConwayGenesisConfigFile :: FilePath -- ^ Path to the Conway genesis file + } + deriving (Eq, Show) + cardanoNumPools :: CardanoTestnetOptions -> NumPools cardanoNumPools CardanoTestnetOptions{cardanoNodes} = NumPools . length $ filter isSpoNodeOptions cardanoNodes @@ -105,6 +115,7 @@ instance Default CardanoTestnetOptions where , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson , cardanoNumDReps = 3 , cardanoEnableNewEpochStateLogging = True + , cardanoInputConfigs = Nothing } -- | Options that are implemented by writing fields in the Shelley genesis file.