Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,27 @@ The flag names, metavars and help text match those historically accepted by
`cardano-node`, so existing operator scripts keep working. You can inspect the
parsed options with `cabal run cardano-config -- resolve --help`.

## Tracing options are **not** parsed by this library

Tracing is **not** parsed: it is owned by the node's tracing system (hermod /
`trace-dispatcher`) and given under a single top-level `HermodTracing` key whose
value is a path to a separate file. The key is recognised and captured opaquely
(it appears in the schema), but its contents are not interpreted here. The
authoritative schema lives in
[`hermod-tracing`](https://github.com/IntersectMBO/hermod-tracing).
## Tracing options are owned by `trace-dispatcher`

Tracing is owned by the node's tracing system (hermod / `trace-dispatcher`),
given under a single top-level `HermodTracing` key whose value is **either** a
path to a separate file holding the tracing configuration **or** that
configuration object inline. This library does not define or validate the shape
of that object — the authoritative schema lives in
[`hermod-tracing`](https://github.com/IntersectMBO/hermod-tracing), so the
configuration schema describes `HermodTracing` only as "a path or a JSON
object".

Instead, the parser hands the `HermodTracing` value to `trace-dispatcher`'s own
parser (`readConfiguration`), which resolves it into a `TraceConfig`: a file
reference is read via `FromFile` (after resolving the path to its canonical
location), an inline object via `FromJSONObject`.

The resolved `TraceConfig` is carried through to the final `NodeConfiguration`
(as `tracingConfiguration :: Maybe TraceConfig`), so a consumer of the library
gets the tracing configuration already parsed, and `cardano-config resolve`
emits it back under the `HermodTracing` key (as an inline object). It is
`Nothing`/absent when the configuration has no `HermodTracing` key.

## Mandatory keys

Expand Down
66 changes: 39 additions & 27 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,6 @@ index-state:
packages:
.

-- cardano-ledger at current master (provides the genesis types we decode here).
-- Kept to the minimum set of subdirs we actually depend on; add more only if the
-- solver requires them.
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: 29c7e3040621f323f3af27fd4e89a223ba429021
--sha256: sha256-XPXfHvYjuzN0ASL/z4HwWJwDPQn7vJbTPlEa5zV3w9k=
subdir:
eras/byron/ledger/impl
eras/byron/crypto
eras/byron/ledger/executable-spec
eras/byron/chain/executable-spec
eras/shelley/impl
eras/allegra/impl
eras/mary/impl
eras/alonzo/impl
eras/babbage/impl
eras/conway/impl
eras/dijkstra/impl
libs/cardano-ledger-core
libs/cardano-ledger-binary
libs/cardano-data
libs/vector-map
libs/non-integral
libs/small-steps

-- Ensures colourized output from test runners
test-show-details: direct
tests: true
Expand Down Expand Up @@ -73,6 +46,7 @@ if impl(ghc >=9.14)
, canonical-json:containers
, cborg:base
, cborg:containers
, cborg-json:base
, constrained-generators:QuickCheck
, dependent-map:containers
, dictionary-sharing:containers
Expand All @@ -91,3 +65,41 @@ if impl(ghc >=9.14)
constraints:
-- Happy version 2.2.1 fails to compile haskell-src-exts
, happy < 2.2.1

-- cardano-ledger at current master (provides the genesis types we decode here).
-- Kept to the minimum set of subdirs we actually depend on; add more only if the
-- solver requires them.
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: 29c7e3040621f323f3af27fd4e89a223ba429021
--sha256: sha256-XPXfHvYjuzN0ASL/z4HwWJwDPQn7vJbTPlEa5zV3w9k=
subdir:
eras/byron/ledger/impl
eras/byron/crypto
eras/byron/ledger/executable-spec
eras/byron/chain/executable-spec
eras/shelley/impl
eras/allegra/impl
eras/mary/impl
eras/alonzo/impl
eras/babbage/impl
eras/conway/impl
eras/dijkstra/impl
libs/cardano-ledger-core
libs/cardano-ledger-binary
libs/cardano-data
libs/vector-map
libs/non-integral
libs/small-steps

-- trace-dispatcher (hermod tracing) — provides the tracing configuration parser
-- (ConfigSource/readConfiguration) used to resolve the HermodTracing key.
-- Pinned to the merge commit after hermod-tracing#18 (mkarg/config-source).
source-repository-package
type: git
location: https://github.com/IntersectMBO/hermod-tracing
tag: 3d7aeb85d9ef01df48a44c751e45609b4c6dea00
--sha256: sha256-r4bVm4x2akrCLcg5f0TG6aovCGqNnZkiiBckA3YCz7Q=
subdir:
trace-dispatcher
1 change: 1 addition & 0 deletions cardano-config.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ library internal
scientific,
text,
time,
trace-dispatcher,
transformers,
yaml,

Expand Down
79 changes: 79 additions & 0 deletions defaults/HermodTracing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"ApplicationName": null,
"Forwarder": null,
"MetricsPrefix": "cardano.node.metrics.",
"Options": {
"": {
"backends": [
"Stdout MachineFormat",
"EKGBackend"
],
"detail": "DNormal",
"severity": "Notice"
},
"BlockFetch.Client.CompletedBlockFetch": {
"maxFrequency": 2
},
"BlockFetch.Decision": {
"severity": "Silence"
},
"ChainDB": {
"severity": "Info"
},
"ChainDB.AddBlockEvent.AddBlockValidation": {
"severity": "Silence"
},
"ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate": {
"maxFrequency": 2
},
"ChainDB.AddBlockEvent.AddedBlockToQueue": {
"maxFrequency": 2
},
"ChainDB.AddBlockEvent.AddedBlockToVolatileDB": {
"maxFrequency": 2
},
"ChainDB.CopyToImmutableDBEvent.CopiedBlockToImmutableDB": {
"maxFrequency": 2
},
"ChainSync.Client": {
"severity": "Warning"
},
"Forge.Loop": {
"severity": "Info"
},
"Forge.StateInfo": {
"severity": "Info"
},
"LedgerMetrics": {
"severity": "Silence"
},
"Mempool": {
"severity": "Info"
},
"Net.ConnectionManager.Remote": {
"severity": "Info"
},
"Net.ErrorPolicy": {
"severity": "Info"
},
"Net.InboundGovernor": {
"severity": "Warning"
},
"Net.InboundGovernor.Remote": {
"severity": "Info"
},
"Net.Mux.Remote": {
"severity": "Info"
},
"Net.PeerSelection": {
"severity": "Silence"
},
"Resources": {
"severity": "Silence"
},
"Startup.DiffusionInit": {
"severity": "Info"
}
},
"PrometheusSimpleRun": null
}
18 changes: 14 additions & 4 deletions schemas/config.legacy-one-file.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,20 @@
"type": "string"
},
"HermodTracing": {
"description": "Tracing configuration as a path to a separate file holding it. Consumed by the node tracing system (trace-dispatcher), not parsed or validated by cardano-config.",
"format": "path",
"title": "HermodTracing",
"type": "string"
"anyOf": [
{
"format": "path",
"title": "String",
"type": "string"
},
{
"additionalProperties": {},
"title": "Object",
"type": "object"
}
],
"description": "Tracing configuration, given as a path to a separate file holding it or as that configuration object inline. Consumed by the node tracing system (trace-dispatcher), which owns its schema; not described further by cardano-config.",
"title": "HermodTracing"
},
"LedgerDB": {
"description": "The LedgerDB configuration\nLedgerDB",
Expand Down
18 changes: 14 additions & 4 deletions schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,20 @@
"title": "ConsensusConfig"
},
"HermodTracing": {
"description": "Tracing configuration as a path to a separate file holding it. Consumed by the node tracing system (trace-dispatcher), not parsed or validated by cardano-config.",
"format": "path",
"title": "HermodTracing",
"type": "string"
"anyOf": [
{
"format": "path",
"title": "String",
"type": "string"
},
{
"additionalProperties": {},
"title": "Object",
"type": "object"
}
],
"description": "Tracing configuration, given as a path to a separate file holding it or as that configuration object inline. Consumed by the node tracing system (trace-dispatcher), which owns its schema; not described further by cardano-config.",
"title": "HermodTracing"
},
"LocalConnectionsConfig": {
"anyOf": [
Expand Down
9 changes: 9 additions & 0 deletions src/Cardano/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ module Cardano.Configuration
-- * Configuration file
, File.NodeConfigurationFromFile
, File.TracingConfiguration (..)
, File.TracingConfigSource (..)
, File.TraceConfig
, File.parseConfigurationFiles
, File.ConfigWarning (..)
, File.renderConfigWarning
Expand Down Expand Up @@ -123,6 +125,12 @@ data NodeConfiguration = NodeConfiguration
, localConnectionsConfig :: File.LocalConnectionsConfig Identity
, testingConfiguration :: File.TestingConfiguration Identity
, mempoolConfiguration :: File.MempoolConfiguration Identity
, tracingConfiguration :: File.TraceConfig
-- ^ The tracing configuration resolved from the top-level @HermodTracing@ key
-- by @trace-dispatcher@'s parser (see 'File.resolveTracingConfiguration'), or
-- 'File.defaultCardanoTracingConfig' when no @HermodTracing@ key is present.
-- Carried through unchanged from the file-parse result so consumers get the
-- parsed 'File.TraceConfig'.
, byronGenesisConfig :: ByronGenesisConfig
-- ^ The parsed Byron genesis.
, shelleyGenesisConfig :: ShelleyGenesis
Expand Down Expand Up @@ -302,6 +310,7 @@ resolveConfigurationWith checks cli file = do
, localConnectionsConfig = localConnections
, testingConfiguration = testing
, mempoolConfiguration = mempool
, tracingConfiguration = File.tracingConfiguration file
, byronGenesisConfig = File.byronGenesisConfig file
, shelleyGenesisConfig = File.shelleyGenesisConfig file
, alonzoGenesisConfig = File.alonzoGenesisConfig file
Expand Down
27 changes: 22 additions & 5 deletions src/Cardano/Configuration/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module Cardano.Configuration.File
, TestingConfiguration (..)
, MempoolConfiguration (..)
, TracingConfiguration (..)
, TracingConfigSource (..)
, TraceConfig
, defaultCardanoTracingConfig

-- * Resolving components
, finalizeNetwork
Expand Down Expand Up @@ -69,6 +72,11 @@ import Cardano.Configuration.File.Protocol
import Cardano.Configuration.File.Storage
import Cardano.Configuration.File.Testing
import Cardano.Configuration.File.Tracing
( TracingConfigSource (..)
, TracingConfiguration (..)
, defaultCardanoTracingConfig
, resolveTracingConfiguration
)
import Cardano.Configuration.Genesis
( GenesisReadError
, genesisErrorFile
Expand All @@ -83,6 +91,7 @@ import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe, strictMay
import Cardano.Ledger.Conway.Genesis (ConwayGenesis)
import Cardano.Ledger.Dijkstra.Genesis (DijkstraGenesis)
import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis)
import Cardano.Logging.Types (TraceConfig)
import Control.Exception (throwIO)
import Data.Aeson (FromJSON, Value)
import qualified Data.Aeson.Key as K
Expand Down Expand Up @@ -126,10 +135,14 @@ data NodeConfigurationFromFileF f
, localConnectionsConfig :: f (LocalConnectionsConfig StrictMaybe)
, testingConfiguration :: f (TestingConfiguration StrictMaybe)
, mempoolConfiguration :: f (MempoolConfiguration StrictMaybe)
, tracingConfiguration :: TracingConfiguration
-- ^ Tracing keys, captured opaquely; see 'TracingConfiguration'. Unlike the
-- other components this is never read from a sub-file: the node's tracing
-- system resolves its own @HermodTracing@ file indirection.
, tracingConfiguration :: TraceConfig
-- ^ The tracing configuration referenced by the top-level @HermodTracing@ key,
-- resolved by @trace-dispatcher@'s own parser ('resolveTracingConfiguration'):
-- a @HermodTracing@ file path is read from that file, an inline object is read
-- directly. When no @HermodTracing@ key is present it falls back to
-- 'defaultCardanoTracingConfig', so a tracing configuration is always present.
-- Its schema is owned by @trace-dispatcher@, not described here (see
-- 'TracingConfiguration').
, byronGenesisConfig :: ByronGenesisConfig
-- ^ The parsed Byron genesis (read from the @ByronGenesisFile@).
, shelleyGenesisConfig :: ShelleyGenesis
Expand Down Expand Up @@ -210,7 +223,11 @@ parseConfigurationVersion1 root minNodeVer configValue = do
localConnections <- parseSection root configValue "LocalConnectionsConfig"
testing <- parseSection root configValue "TestingConfig"
mempool <- parseSection root configValue "MempoolConfig"
-- The @HermodTracing@ value is captured (as a file path or an inline object)
-- and then handed to trace-dispatcher's own parser, which resolves it to a
-- 'TraceConfig' — reading the referenced file, or the inline object directly.
tracing <- runCodec Nothing "Tracing" configValue
traceConfig <- resolveTracingConfiguration root tracing
-- The genesis files referenced by the configuration are read and decoded
-- here, so that JSON resolution happens entirely within this library.
let byronCfg = byronGenesis protocol
Expand Down Expand Up @@ -238,7 +255,7 @@ parseConfigurationVersion1 root minNodeVer configValue = do
, localConnectionsConfig = Identity localConnections
, testingConfiguration = Identity testing
, mempoolConfiguration = Identity mempool
, tracingConfiguration = tracing
, tracingConfiguration = traceConfig
, byronGenesisConfig = byronGenesisData
, shelleyGenesisConfig = shelleyGenesisData
, alonzoGenesisConfig = alonzoGenesisData
Expand Down
Loading
Loading