Skip to content

cardano-testnet: Add backwards-compatibility with some old cli/node versions#6543

Open
palas wants to merge 6 commits intomasterfrom
make-testnet-backwards-compatible
Open

cardano-testnet: Add backwards-compatibility with some old cli/node versions#6543
palas wants to merge 6 commits intomasterfrom
make-testnet-backwards-compatible

Conversation

@palas
Copy link
Copy Markdown
Contributor

@palas palas commented Apr 20, 2026

Description

Makes cardano-testnet work seamlessly with older versions of cardano-cli and cardano-node (not all versions, just to some extent), without hard-coded version checks. The code probes the installed CLI's capabilities at runtime and adapts automatically — genesis files that the CLI doesn't produce are created via fallback, and the node configuration includes settings needed by older nodes.

Motivation: We aim to allow for cardano-testnet to run testnet with different versions of the cardano-node. This PR makes that easier, since we will only have to worry about running the correct node, and not about having the right configuration files generated.

What changed:

  • CLI capability detection (RunIO.hs): getCliHelpText probes cardano-cli <era> genesis create-testnet-data --help to discover which --spec-* flags are supported.
  • Conditional spec flags (Configuration.hs): specFlag takes a (String -> Bool) predicate and only passes flags the CLI advertises. Adding a future era is one extra ++ specFlag cliHas NewEra line.
  • Byron genesis fallback (Configuration.hs): When the CLI doesn't produce byron-genesis.json (older CLIs don't), it is created via the existing createByronGenesis from Byron.hs, with delegate keys copied into the expected pool-key directories.
  • Dijkstra genesis fallback (Configuration.hs): When dijkstra-genesis.json is missing, the default is written directly so that the node configuration and hash computation stay uniform.
  • Byron.hs constraint relaxation: createByronGenesis now requires only MonadIO (was MonadTest, MonadCatch, MonadIO) and uses Testnet.Process.RunIO.execCli_, so it can be called from both production code and tests.
  • EnableP2P in config (Defaults.hs): Older nodes (≤ 9.x) require EnableP2P: True explicitly to parse P2P topology files; newer nodes already default to P2P so the flag is harmless.

Tests with old versions of cardano-node and cardano-cli before this PR and after this PR:

Release node cli Before After
9.0.0 9.0.0 9.0.0.0 FAIL OK
9.1.0 9.1.0 9.2.1.0 FAIL OK
9.1.1 9.1.1 9.2.1.0 FAIL OK
9.2.0 9.2.0 9.4.1.0 FAIL OK
9.2.1 9.2.1 9.4.1.0 FAIL OK
10.1.1 10.1.1 10.1.0.0 FAIL OK
10.1.2 10.1.2 10.1.1.0 FAIL OK
10.1.3 10.1.3 10.1.1.0 FAIL OK
10.1.4 10.1.4 10.1.1.0 FAIL OK
10.2.1 10.2.1 10.4.0.0 FAIL OK
10.3.1 10.3.1 10.7.0.0 FAIL OK
10.4.1 10.4.1 10.8.0.0 FAIL OK
10.5.1 10.5.1 10.11.0.0 FAIL OK
10.5.2 10.5.2 10.11.0.0 FAIL OK
10.5.3 10.5.3 10.11.0.0 FAIL OK
10.5.4 10.5.4 10.11.0.0 FAIL OK
10.6.2 10.6.2 10.15.0.0 OK OK
10.6.3 10.6.3 10.15.0.0 OK OK
10.6.4 10.6.4 10.15.0.0 OK OK
10.7.1 10.7.1 10.16.0.0 OK OK

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Running tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

@palas palas requested a review from a team as a code owner April 20, 2026 18:46
@palas palas requested review from carbolymer and removed request for a team April 20, 2026 18:46
Comment thread cardano-testnet/src/Testnet/Components/Configuration.hs Outdated
Comment thread cardano-testnet/src/Testnet/Components/Configuration.hs Outdated
Comment thread cardano-testnet/src/Testnet/Process/RunIO.hs Outdated
@palas palas self-assigned this Apr 21, 2026
@palas palas requested a review from carbolymer April 22, 2026 21:37
Copy link
Copy Markdown
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

To clarify my earlier message. By "from this cardano-testnet onwards" I meant: make the current cardano-testnet work with the current cardano-cli release. That's the scope. I wasn't asking for a flag and backport mechanism or for us to collect past configurations. Since cardano-testnet has never been officially released there's no installed base to support, so we don't need a backwards compatibility path at all. We need forward compatibility with whatever cli is current.

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.

3 participants