Skip to content

Commit

Permalink
make polkadot-parachain startup errors pretty (paritytech#5214)
Browse files Browse the repository at this point in the history
The errors on polkadot-parachain are not printed with their full display
context(what is marked with `#[error(`) because main returns plain
Result and the error will be shown in its Debug format, that's not
consistent with how the polkadot binary behave and is not user friendly
since it does not tell them why they got the error.

Fix it by using `color_eyre` as polkadot already does it. 

Fixes: paritytech#5211

## Output before
```
Error: NetworkKeyNotFound("/acala/data/Collator2/chains/mandala-tc9/network/secret_ed25519")
```

## Output after
```
Error: 
   0: Starting an authorithy without network key in /home/alexggh/.local/share/polkadot-parachain/chains/asset-hub-kusama/network/secret_ed25519.
      
       This is not a safe operation because other authorities in the network may depend on your node having a stable identity.
      
       Otherwise these other authorities may not being able to reach you.
      
       If it is the first time running your node you could use one of the following methods:
      
       1. [Preferred] Separately generate the key with: <NODE_BINARY> key generate-node-key --base-path <YOUR_BASE_PATH>
      
       2. [Preferred] Separately generate the key with: <NODE_BINARY> key generate-node-key --file <YOUR_PATH_TO_NODE_KEY>
      
       3. [Preferred] Separately generate the key with: <NODE_BINARY> key generate-node-key --default-base-path
      
       4. [Unsafe] Pass --unsafe-force-node-key-generation and make sure you remove it for subsequent node restarts

```

---------

Signed-off-by: Alexandru Gheorghe <[email protected]>
  • Loading branch information
alexggh authored Aug 5, 2024
1 parent f170af6 commit 0cc3e17
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ path = "src/main.rs"
async-trait = { workspace = true }
clap = { features = ["derive"], workspace = true }
codec = { workspace = true, default-features = true }
color-eyre = { workspace = true }
color-print = { workspace = true }
futures = { workspace = true }
hex-literal = { workspace = true, default-features = true }
Expand Down
5 changes: 3 additions & 2 deletions cumulus/polkadot-parachain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mod fake_runtime_api;
mod rpc;
mod service;

fn main() -> sc_cli::Result<()> {
command::run()
fn main() -> color_eyre::eyre::Result<()> {
color_eyre::install()?;
Ok(command::run()?)
}
11 changes: 11 additions & 0 deletions prdoc/pr_5214.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: make polkadot-parachain startup errors pretty

doc:
- audience: Node Operator
description: |
Changed the format of how polkadot-parachain prints the startup errors to include
the full displayable context.

crates:
- name: polkadot-parachain-bin
bump: minor

0 comments on commit 0cc3e17

Please sign in to comment.