Skip to content

Use cardano-config for cardano config parsing - #1379

Merged
palas merged 11 commits into
masterfrom
config-dedup
Oct 20, 2026
Merged

palas merged 11 commits into
masterfrom
config-dedup

Conversation

@palas

@palas palas commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Context

cardano-api has its own way of parsing the node configuration file. To avoid duplication, this PR removes it in favour of the functionality from cardano-config.

This has a couple of minor side effects:

The Byron settings PBftSignatureThreshold and LastKnownBlockVersion-Major/- Minor/-Alt are no longer read (cardano-config drops them without a warning), so ncPBftSignatureThreshold is always Nothing (the consensus default) and ncByronProtocolVersion is always 1.0.0, as in the node for a configuration in the cardano-config format. Neither affects reading or applying blocks.

And also, this PR, changes the implementation of NodeConfig to just be a newtype wrapper around cardano-config's NodeConfiguration. And to avoid storing computed values, fields just become accessor functions (same signature).

Another minor side-effect is that now it is necessary for the genesis files to be there when parsing, and for things to be valid, including the hashes. Nevertheless, a choice that this PR makes is not carrying out any of the consistency checks that resolveConfigurationWith does when it is used from the node.

CI-related

Last 3 commits are just patches to get the CI to pass in all platforms.

How to trust this PR

Except for the side effects this is pretty much a refactoring. And it relies on code that comes from cardano-config. The PR also includes a few new tests.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@palas palas self-assigned this Oct 16, 2026
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Public API and consensus-initialization changes warrant human validation, with configured Dijkstra genesis selection still lacking regression coverage.

1 open finding
What changed in this PR

Replaces duplicated node-configuration parsing with cardano-config in ledger-state initialization.

Changes:

  • Wraps NodeConfiguration and exposes accessor functions.
  • Reuses validated genesis data, including configured Dijkstra genesis.
  • Adds parsing tests and fixtures, updates dependencies, and documents breaking changes.
File Description
flake.lock Updates the package repository pin.
cardano-api/​test/​cardano-api-test/​Test/​Cardano/​Api/​NodeConfig.hs Tests configuration formats, triggers, and hash validation.
cardano-api/​test/​cardano-api-test/​files/​input/​node-config/​shelley-genesis.json Adds Shelley fixture.
cardano-api/​test/​cardano-api-test/​files/​input/​node-config/​conway-genesis.json Adds Conway fixture.
cardano-api/​test/​cardano-api-test/​files/​input/​node-config/​byron-genesis.json Adds Byron fixture.
cardano-api/​test/​cardano-api-test/​files/​input/​node-config/​alonzo-genesis.json Adds Alonzo fixture.
cardano-api/​src/​Cardano/​Api/​LedgerState.hs Delegates parsing and genesis loading to cardano-config.
cardano-api/​cardano-api.cabal Adds cardano-config; removes yaml.
cabal.project Updates the package index timestamp.
.changes/​20261015_022558_cardano-api_palas_read_node_config_cardano_config.yml Documents breaking API and behavior changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated

@carbolymer carbolymer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think exception handling really should be addressed.

Comment thread .github/workflows/haskell.yml
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/NodeConfig.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/NodeConfig.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/NodeConfig.hs Outdated
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs
@palas
palas added this pull request to the merge queue Oct 20, 2026
@Jimbo4350
Jimbo4350 removed this pull request from the merge queue due to a manual request Oct 20, 2026
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs Outdated
Comment thread cardano-api/src/Cardano/Api/LedgerState.hs
@Jimbo4350

Jimbo4350 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

LGTM but #1379 (comment) needs to be at least documented/addressed.

@Jimbo4350
Jimbo4350 self-requested a review October 20, 2026 19:53
@palas
palas enabled auto-merge October 20, 2026 21:21
@palas
palas added this pull request to the merge queue Oct 20, 2026
Merged via the queue into master with commit 0255a36 Oct 20, 2026
44 of 47 checks passed
@palas
palas deleted the config-dedup branch October 20, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants