Skip to content

fix: error when loading chain spec for non-dev cfg_preset#187

Merged
gilescope merged 5 commits into
mainfrom
ozgb/fix-chain-spec-load-error
Oct 29, 2025
Merged

fix: error when loading chain spec for non-dev cfg_preset#187
gilescope merged 5 commits into
mainfrom
ozgb/fix-chain-spec-load-error

Conversation

@ozgb

@ozgb ozgb commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Overview

Bug reported by @rsporny

CFG_PRESET=node-dev-01 ./midnight-node wizards generate-keys
This 🧙 wizard will generate the following keys and save them to your node's keystore:
→ ecdsa Cross-chain key
→ sr25519 AURA key
→ ed25519 Grandpa key
→ ecdsa Cross-chain key
It will also generate a network key for your node if needed.


thread 'main' panicked at node/src/cli.rs:113:14:
chain spec generation must succeed when using default configuration: "ChainSpec Parse error: Error opening spec file `node-dev-01`: No such file or directory (os error 2)"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Introduced by: #79

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)
    • Tested manually and this now works

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

@ozgb ozgb requested a review from a team as a code owner October 29, 2025 11:57
@github-actions

github-actions Bot commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Logo
Checkmarx One – Scan Summary & Detailsc29422a4-84a3-4b7f-a235-af5b173a6dfa

Great job! No new security vulnerabilities introduced in this pull request

@rsporny

rsporny commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Thanks, works fine, after merge 🙏 please cherry pick to release branch

@gilescope gilescope enabled auto-merge (squash) October 29, 2025 15:50
@gilescope gilescope merged commit db84075 into main Oct 29, 2025
24 checks passed
@gilescope gilescope deleted the ozgb/fix-chain-spec-load-error branch October 29, 2025 16:36
rsporny pushed a commit that referenced this pull request Oct 30, 2025
* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Squirrel <giles.cope@shielded.io>
gilescope added a commit that referenced this pull request Oct 30, 2025
* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>
@justinfrevert justinfrevert mentioned this pull request Oct 31, 2025
13 tasks
gilescope added a commit that referenced this pull request Nov 4, 2025
* fix: error when loading chain spec for non-dev cfg_preset (#187) (#194)

* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>

* chore: PC 1.8 deployment fixes (#201)

* chore: node-dev-01 new chain spec with PC 1.8 registrations (#191)

* chore: PC 1.8 new registrations (#197)

* chore: PC 1.8 new registrations

* chore: add governance info

* chore: fix chain-spec to match PC 1.8 registration (#200)

* Cherry pick: bump to ledger ledger-6.1.0-alpha.5 (#203) (#204)

* bump to ledger ledger-6.1.0-alpha.5 (#203)

(cherry picked from commit b3fac93)

* Change GITHUB_TOKEN to GHP_TOKEN in workflow

---------

Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>

* Backport gov (#206)

* Fix: Federated Authority configurations (#180)

* fix federated authorities for qanet and node-dev-01

* chore: regenerate chain_specs

* fix: rebuild preview chainspec

---------

Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>

* docs: reset changes (node-0.18.0-rc.4)

* lockfile

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>
Co-authored-by: justinfrevert <81839854+justinfrevert@users.noreply.github.com>
Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>
gilescope added a commit that referenced this pull request Nov 7, 2025
* fix: error when loading chain spec for non-dev cfg_preset (#187) (#194)

* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>

* docs: reset changes (node-0.18.0-rc.2)

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
github-merge-queue Bot pushed a commit that referenced this pull request Nov 18, 2025
* fix: error when loading chain spec for non-dev cfg_preset (#187) (#194)

* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>

* chore: PC 1.8 deployment fixes (#201)

* chore: node-dev-01 new chain spec with PC 1.8 registrations (#191)

* chore: PC 1.8 new registrations (#197)

* chore: PC 1.8 new registrations

* chore: add governance info

* chore: fix chain-spec to match PC 1.8 registration (#200)

* Cherry pick: bump to ledger ledger-6.1.0-alpha.5 (#203) (#204)

* bump to ledger ledger-6.1.0-alpha.5 (#203)

(cherry picked from commit b3fac93)

* Change GITHUB_TOKEN to GHP_TOKEN in workflow

---------

Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>

* Backport gov (#206)

* Fix: Federated Authority configurations (#180)

* fix federated authorities for qanet and node-dev-01

* chore: regenerate chain_specs

* fix: rebuild preview chainspec

---------

Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>

* [0.18.0 cherry-pick] Add midnight_ prefix to chain ID to follow Polkadot convention (#216)

* Add `midnight_` prefix to chain ID to follow Polkadot convention (#188)

* feat: add 'midnight_' prefix to all chain ids

Network ID is created as a transformation of the chain id

* chore: rebuild chainspecs

* docs: add change file

* feat: add check on network_id spec conformity

* chore: rebuild chainspecs

* Backport #142 (#220)

* Feat: Federated Authority Observation - querying `db-sync` (#142)

* feat: query governance data

* test: e2e tests base for governance contracts

* feat: adding governance contracts to local-env

* aaarrrgggg deploy failing

* feat: Governance contracts deployed to local-env

* federate-authority-configs updated with expected contracts

* feat: new members properly read from the minted nft

* chore: clean up

* feat: add new calls to set addresses and policy_id + benchmarks

* nit

* chore: make clippy happy

* chore: add change file

* feat: replace vec by PolicyId and MainchainAddress

* chore: regenerate metadata

* chore: make clippy happy

* test: add test for contracts info setters

* chore: update federated configs with preview real data + test fix

* chore: regenerate metadata

* chore: rebuild metadata

* chore: rebuild chain_specs

* [cherry-pick 0.18.0] Deduplicate Mapping types (#166) (#221)

* Deduplicate Mapping types (#166)

* chore: replace Mapping with MappingEntry

Signed-off-by: yHSJ <josh@securitybot.info>

* chore: changefile

* chore: remove unnecessary conversions

* fix: regenerate metadata

* chore: update metadata

* Add change tag

* test: fix test compile errors

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>

* chore: rebuild metadata

* chore: rebuild chainspecs

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Joshua Marchand (JSHy) <79121297+yHSJ@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>

* Fix node entrypoint (#217)

* fix node entrypoint

* test

* last try

* fix: node entrypoint passing `--` as an arg

Found when running with SHOW_CONFIG=1:

```
NAME:          args
HELP:          The arguments passed to the node
TYPE:          Vec < String >
DEFAULT:
SOURCES:       cli
CURRENT_VALUE: "--, "
```

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>

* [cherry-pick 0.18.0] Update cNight Observation for new Datum structure (#189) (#225)

* Update cNight Observation for new Datum structure (#189)

* feat: update to follow new datum structure

* test: fix tests

* fix: DustPublicKey deserialized correctly (PM-19983); fix test

* fix: check for DustPublicKey length; Fix missing dereg event (PM-20229)

* refactor: rename types - more precise naming

* refactor: rename fields for precision

* feat: wrap cnight array types in new structs

* feat: use McBlockHash and TxBlockHash in more places

* fix: clippy warnings

* docs: add change file

* docs: add change file

* docs: add change file

* build: remove unused dep serde_arrays

* chore: update metadata

* feat: rename MappingEntry utxo_id -> utxo_tx_hash

* feat: update type of utxo_tx_hash

* feat: change type of cmst block hash

* feat: add check for mapping validator auth token

* chore: update sqlx cache

* test: fix tests for cnight config validation

* chore: update cnight config files

* test: use aiken cnight smart contracts

* fix: use new mapping validator address

* chore: update metadata

* test: fix tests after cnight pallet update

* test: fix more tests, 2 e2e tests still failing

* test: fix mint cnight tx budget

* test: remove old typescript local-env tests

* build: remove leftover target

* build: remove leftover target

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>

* chore: rebuild chainspecs

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>

* Update governance contracts (#226)

* fix: update node-dev-01 gov contracts

* fix: qanet and preview gov contracts

* chore: update chain-specs

* docs: reset changes (node-0.18.0-rc.5)

* fix: npm audit

* fix metadata

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Radosław Sporny <404@rspo.dev>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>
Co-authored-by: justinfrevert <81839854+justinfrevert@users.noreply.github.com>
Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Joshua Marchand (JSHy) <79121297+yHSJ@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
NachoPal added a commit that referenced this pull request Nov 21, 2025
* fix: error when loading chain spec for non-dev cfg_preset (#187) (#194)

* fix: error when loading chain spec for non-dev cfg_preset

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>

* chore: PC 1.8 deployment fixes (#201)

* chore: node-dev-01 new chain spec with PC 1.8 registrations (#191)

* chore: PC 1.8 new registrations (#197)

* chore: PC 1.8 new registrations

* chore: add governance info

* chore: fix chain-spec to match PC 1.8 registration (#200)

* Cherry pick: bump to ledger ledger-6.1.0-alpha.5 (#203) (#204)

* bump to ledger ledger-6.1.0-alpha.5 (#203)

(cherry picked from commit b3fac93)

* Change GITHUB_TOKEN to GHP_TOKEN in workflow

---------

Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>

* Backport gov (#206)

* Fix: Federated Authority configurations (#180)

* fix federated authorities for qanet and node-dev-01

* chore: regenerate chain_specs

* fix: rebuild preview chainspec

---------

Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>

* [0.18.0 cherry-pick] Add midnight_ prefix to chain ID to follow Polkadot convention (#216)

* Add `midnight_` prefix to chain ID to follow Polkadot convention (#188)

* feat: add 'midnight_' prefix to all chain ids

Network ID is created as a transformation of the chain id

* chore: rebuild chainspecs

* docs: add change file

* feat: add check on network_id spec conformity

* chore: rebuild chainspecs

* Backport #142 (#220)

* Feat: Federated Authority Observation - querying `db-sync` (#142)

* feat: query governance data

* test: e2e tests base for governance contracts

* feat: adding governance contracts to local-env

* aaarrrgggg deploy failing

* feat: Governance contracts deployed to local-env

* federate-authority-configs updated with expected contracts

* feat: new members properly read from the minted nft

* chore: clean up

* feat: add new calls to set addresses and policy_id + benchmarks

* nit

* chore: make clippy happy

* chore: add change file

* feat: replace vec by PolicyId and MainchainAddress

* chore: regenerate metadata

* chore: make clippy happy

* test: add test for contracts info setters

* chore: update federated configs with preview real data + test fix

* chore: regenerate metadata

* chore: rebuild metadata

* chore: rebuild chain_specs

* [cherry-pick 0.18.0] Deduplicate Mapping types (#166) (#221)

* Deduplicate Mapping types (#166)

* chore: replace Mapping with MappingEntry

Signed-off-by: yHSJ <josh@securitybot.info>

* chore: changefile

* chore: remove unnecessary conversions

* fix: regenerate metadata

* chore: update metadata

* Add change tag

* test: fix test compile errors

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>

* chore: rebuild metadata

* chore: rebuild chainspecs

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Joshua Marchand (JSHy) <79121297+yHSJ@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>

* Fix node entrypoint (#217)

* fix node entrypoint

* test

* last try

* fix: node entrypoint passing `--` as an arg

Found when running with SHOW_CONFIG=1:

```
NAME:          args
HELP:          The arguments passed to the node
TYPE:          Vec < String >
DEFAULT:
SOURCES:       cli
CURRENT_VALUE: "--, "
```

---------

Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>

* [cherry-pick 0.18.0] Update cNight Observation for new Datum structure (#189) (#225)

* Update cNight Observation for new Datum structure (#189)

* feat: update to follow new datum structure

* test: fix tests

* fix: DustPublicKey deserialized correctly (PM-19983); fix test

* fix: check for DustPublicKey length; Fix missing dereg event (PM-20229)

* refactor: rename types - more precise naming

* refactor: rename fields for precision

* feat: wrap cnight array types in new structs

* feat: use McBlockHash and TxBlockHash in more places

* fix: clippy warnings

* docs: add change file

* docs: add change file

* docs: add change file

* build: remove unused dep serde_arrays

* chore: update metadata

* feat: rename MappingEntry utxo_id -> utxo_tx_hash

* feat: update type of utxo_tx_hash

* feat: change type of cmst block hash

* feat: add check for mapping validator auth token

* chore: update sqlx cache

* test: fix tests for cnight config validation

* chore: update cnight config files

* test: use aiken cnight smart contracts

* fix: use new mapping validator address

* chore: update metadata

* test: fix tests after cnight pallet update

* test: fix more tests, 2 e2e tests still failing

* test: fix mint cnight tx budget

* test: remove old typescript local-env tests

* build: remove leftover target

* build: remove leftover target

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>

* chore: rebuild chainspecs

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>

* Update governance contracts (#226)

* fix: update node-dev-01 gov contracts

* fix: qanet and preview gov contracts

* chore: update chain-specs

* Add `preprod` network (#265)

* feat: add preprod network

* nit

* chore: change file

* chore: preprod validators

* chore: regenerate genesis

* fix: align with preview

* chore: update preprod pc-config

* Revert "chore: update preprod pc-config"

This reverts commit 5a43d4c.

* Revert "fix: align with preview"

This reverts commit 5c4d7e7.

* chore: preprod chain-spec

* fix: npm audit

* fix

* remove cache

* :/

* change to trixie

* Revert "remove cache"

This reverts commit e6fdbe2.

* recover no cache

* Revert "change to trixie"

This reverts commit d529e1d.

* Revert ":/"

This reverts commit 980d1a8.

* logs

* fix: update to trixie

* Revert "logs"

This reverts commit 6709891.

* undo no-cache

---------

Co-authored-by: Radosław Sporny <404@rspo.dev>

* docs: reset changes (node-0.18.0-rc.6)

* fix: fix main merge

* fix: fix main merge 2

* fix: fix main merge 3

* fix: add mainchain memebers for preprod

---------

Signed-off-by: yHSJ <josh@securitybot.info>
Co-authored-by: Radosław Sporny <404@rspo.dev>
Co-authored-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Co-authored-by: Squirrel <giles.cope@shielded.io>
Co-authored-by: justinfrevert <81839854+justinfrevert@users.noreply.github.com>
Co-authored-by: Fenton Haslam <50406962+Fentonhaslam@users.noreply.github.com>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Joshua Marchand (JSHy) <79121297+yHSJ@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Justin Frevert <justinfrevert@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
riusricardo added a commit to riusricardo/midnight-node that referenced this pull request Dec 11, 2025
Fixes regression introduced in PR midnightntwrk#187 where wizards generate-keys
command would panic when no custom chain specification was provided.

The original fix addressed the issue for explicit --chain-id usage
but introduced a new panic by calling load_spec("") when using
configuration presets (CFG_PRESET environment variable).

This change ensures the command respects the configuration system:
- Uses configured chain ID from SubstrateCfg
- Falls back to "dev" when no configuration is specified
- Maintains compatibility with all existing workflows:
  * CFG_PRESET=dev
  * CHAIN=local
  * CHAIN=path/to/custom/chainspec.json
  * Default behavior (no environment variables)
chrisferry pushed a commit that referenced this pull request Jan 9, 2026
…ommand (#365)

* fix: handle CFG_PRESET in wizards generate-keys command

Fixes regression introduced in PR #187 where wizards generate-keys
command would panic when no custom chain specification was provided.

The original fix addressed the issue for explicit --chain-id usage
but introduced a new panic by calling load_spec("") when using
configuration presets (CFG_PRESET environment variable).

This change ensures the command respects the configuration system:
- Uses configured chain ID from SubstrateCfg
- Falls back to "dev" when no configuration is specified
- Maintains compatibility with all existing workflows:
  * CFG_PRESET=dev
  * CHAIN=local
  * CHAIN=path/to/custom/chainspec.json
  * Default behavior (no environment variables)
* Add new change file
---------
Co-authored-by: justinfrevert <81839854+justinfrevert@users.noreply.github.com>
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants