Skip to content

Commit

Permalink
Merge pull request #52 from input-output-hk/smelc/adr-5-node-config
Browse files Browse the repository at this point in the history
Add ADR for checking node configuration files with cardano-cli
  • Loading branch information
smelc authored Dec 12, 2024
2 parents bbf170e + bd2ac25 commit 55fa90b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/ADR-5-cardano-testnet-node-configuration-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Status

πŸ“œ Proposed 2024-09-10

# Context

There is no way to check a node configuration file for basic sanity issues. This is a problem for people running testnets, because they will only discover _after having started their testnet_ that something is wrong (because the node will refuse to start). And starting a testnet is a costly operation, meaning the failures will only happen after tenth of seconds; causing the feedback loop to be slow.

# Decision

## Add a new command in the CLI

Introduce a new command in `cardano-cli` that takes a node configuration file as parameter and performs sanity checks:

1. The configuration file can be loaded.
2. Paths of genesis files are specified.
3. Hashes of genesis files are specified and are correct.

## Alternatives considered

### Provide a fixup option

We considered having a flag that would make `check-node-configuration`:

1. Fill the hashes of genesis files if missing
2. Fix the hashes of genesis files if present but wrong

However, in the end, we favored having a pure command (i.e. a command that doesn't modify things) so we ruled such a fixup flag.

### Have `create-testnet-data` create the node configuration file

We considered having `create-testnet-data` create a default node configuration file, and populating it with the paths and hashes of genesis files. This could have been nice to users, but it is complicated to implement, because most of the types for the node configuration file live in `cardano-node`, as for example the `NodeConfiguration` type which lives in [cardano-node/src/Cardano/Node/Configuration/POM.hs](https://github.com/IntersectMBO/cardano-node/blob/ef5f0a9ed52d969b3753c96955add25b9e08f02d/cardano-node/src/Cardano/Node/Configuration/POM.hs#L87). The `NodeConfig` type which we have in `cardano-api` (see [cardano-api/internal/Cardano/Api/LedgerState.hs](https://github.com/IntersectMBO/cardano-api/blob/4dde2e65c496f989f079354f407e7617563f4bc7/cardano-api/internal/Cardano/Api/LedgerState.hs#L1048)) for the node configuration file is not general enough to create a full-fledged node configuration file.

However, moving the `NodeConfiguration` type and its accompanying types to `cardano-api` is a large endeavor, which was not given priority yet. It is a large endeavor for two reasons: `NodeConfiguration` has many fields of different types and it is quite different from `NodeConfig`. `NodeConfig` contains the bare minimum needed for API specific operations: it is mostly concerned with genesis files and their hashes.

# Consequences

This will allow users of testnets to check their node configuration file before starting their testnet, and so they will catch errors earlier and faster.
2 changes: 2 additions & 0 deletions docs/Architecture-Decision-Records.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* βœ… [[ADR-1 Default eras for CLI commands]]
* βœ… [[ADR-2 Module structure for generators]]
* πŸ“œ [[ADR-3 Dependencies version constraints in cabal file]]
* πŸ“œ [[ADR-4 Support-only-for-mainnet-and-upcoming-eras]]
* πŸ“œ [[ADR-5 cardano-testnet-node-configuration-file]]
* πŸ“œ [[ADR-6 Using optparse-applicative main repository]]
* πŸ“œ [[ADR-7 CLI Output Presentation]]

Expand Down

0 comments on commit 55fa90b

Please sign in to comment.