Skip to content

Commit

Permalink
cardano-testnet: allow to take config files as input
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jan 31, 2025
1 parent 53e05d9 commit b90ea7b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cardano-testnet/src/Parsers/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
11 changes: 11 additions & 0 deletions cardano-testnet/src/Testnet/Start/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
module Testnet.Start.Types
( CardanoTestnetCliOptions(..)
, CardanoTestnetOptions(..)
, InputConfigFiles(..)
, NumDReps(..)
, NumPools(..)
, NumRelays(..)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b90ea7b

Please sign in to comment.