| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Tools.Config
Description
How the tools in this package handle the node configuration.
Parsing it and loading the genesis files it names is cardano-config's job.
Left for here is what building a Cardano ProtocolInfo still needs derived
from the result: the hard-fork triggers, the initial nonce, the protocol
version and the ledger transition configuration. Both db-analyser and
db-synthesizer go through this module, so the two read a configuration file
the same way.
Synopsis
- resolveNodeConfiguration ∷ FilePath → IO (NodeConfiguration, [ConfigWarning])
- resolveNodeConfigurationWith ∷ CliArgs → IO (NodeConfiguration, [ConfigWarning])
- reportConfigWarnings ∷ [ConfigWarning] → IO ()
- mkHardForkTriggers ∷ TestingConfiguration Identity → Either String CardanoHardForkTriggers
- mkDijkstraGenesis ∷ NodeConfiguration → DijkstraGenesis
- mkInitialNonce ∷ NodeConfiguration → Nonce
- mkProtocolVersion ∷ NodeConfiguration → ProtVer
- mkTransitionConfig ∷ NodeConfiguration → TransitionConfig LatestKnownEra
- newtype ConfigError = ConfigError String
- throwConfigError ∷ String → IO a
- withConfigErrorHandling ∷ IO a → IO a
Reading the node configuration
resolveNodeConfiguration ∷ FilePath → IO (NodeConfiguration, [ConfigWarning]) Source #
Parse and resolve the node configuration with the shared 'cardano-config' package, with no command-line overrides: every value comes from the configuration file (and cardano-config's own defaults layer).
The warnings emitted while resolving are returned rather than reported here, so that the caller decides where they are printed.
resolveNodeConfigurationWith ∷ CliArgs → IO (NodeConfiguration, [ConfigWarning]) Source #
As resolveNodeConfiguration, but resolving the configuration file named
by the given command-line arguments against them, so that a tool that has
command-line options of its own (db-synthesizer and its credentials) can
override what the file says. defaultCliArgs is the starting point for
building those arguments.
reportConfigWarnings ∷ [ConfigWarning] → IO () Source #
Report the warnings raised while resolving a node configuration on stderr.
A tool carries on afterwards, but they say that some of what the file asks for was not honoured, which is worth seeing before its own output starts.
Interpreting the node configuration
mkHardForkTriggers ∷ TestingConfiguration Identity → Either String CardanoHardForkTriggers Source #
Build the CardanoHardForkTriggers from the Testing section of the
configuration: each era hard-forks at its configured epoch, or at the
default protocol version when no epoch is given.
If an era is configured to hard-fork at a specific epoch, then so must all earlier eras; otherwise the configuration is rejected.
mkDijkstraGenesis ∷ NodeConfiguration → DijkstraGenesis Source #
The Dijkstra genesis to build the transition configuration from.
A transition configuration needs one for every Shelley-based era, including
eras a chain never reaches, but a configuration need not name a
DijkstraGenesisFile. cardano-config reports what the file says without
inventing values, so the fallback is ours.
Whether the file applies at all is decided upstream: cardano-config gates it
on ExperimentalHardForksEnabled as cardano-node does, reporting SNothing
with the flag off without opening the file. Gating again here would put the
rule in two places.
mkInitialNonce ∷ NodeConfiguration → Nonce Source #
The initial nonce, ie the Blake2b-256 hash of the Shelley genesis file, which 'cardano-config' records alongside the file path.
mkProtocolVersion ∷ NodeConfiguration → ProtVer Source #
The greatest protocol version the tools forge in and validate.
As in cardano-node, ExperimentalHardForksEnabled decides it: the flag admits
the experimental era, so with it off the version stops at the era before.
The eras are named rather than written as the 12 and 11 they currently are, so that adding an era moves both.
mkTransitionConfig ∷ NodeConfiguration → TransitionConfig LatestKnownEra Source #
The ledger transition configuration, ie the genesis of every Shelley-based era, as parsed by 'cardano-config'.
Configuration errors
newtype ConfigError Source #
A tool was invoked with a configuration it cannot work with, be it in the node configuration file or on the command line.
Constructors
| ConfigError String |
Instances
| Exception ConfigError Source # | |
Defined in Cardano.Tools.Config | |
| Show ConfigError Source # | |
Defined in Cardano.Tools.Config Methods showsPrec ∷ Int → ConfigError → ShowS # show ∷ ConfigError → String # showList ∷ [ConfigError] → ShowS # | |
throwConfigError ∷ String → IO a Source #
Abort because of a ConfigError.
Every configuration problem these tools detect is reported this way, so that they all reach the user in the same shape.
withConfigErrorHandling ∷ IO a → IO a Source #
Report an escaping ConfigError as a plain <prog>: <message> on
stderr and exit with a failure.
Wrap a tool's main in this. GHC's default handler would otherwise bury the
message under the exception's qualified type name and a call-stack backtrace.