From 0cc3e170d3c4ff7ba26054be0bc114fa287d9d69 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe <49718502+alexggh@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:32:46 +0300 Subject: [PATCH] make polkadot-parachain startup errors pretty (#5214) 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: https://github.com/paritytech/polkadot-sdk/issues/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: key generate-node-key --base-path 2. [Preferred] Separately generate the key with: key generate-node-key --file 3. [Preferred] Separately generate the key with: 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 --- Cargo.lock | 1 + cumulus/polkadot-parachain/Cargo.toml | 1 + cumulus/polkadot-parachain/src/main.rs | 5 +++-- prdoc/pr_5214.prdoc | 11 +++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 prdoc/pr_5214.prdoc diff --git a/Cargo.lock b/Cargo.lock index d37babb5bbc0..4f41f3ca1eb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13845,6 +13845,7 @@ dependencies = [ "bridge-hub-westend-runtime", "clap 4.5.11", "collectives-westend-runtime", + "color-eyre", "color-print", "contracts-rococo-runtime", "coretime-rococo-runtime", diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index b20d2a28fa7f..e1016cebb395 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -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 } diff --git a/cumulus/polkadot-parachain/src/main.rs b/cumulus/polkadot-parachain/src/main.rs index cbb76fa214cb..84e41fc347d9 100644 --- a/cumulus/polkadot-parachain/src/main.rs +++ b/cumulus/polkadot-parachain/src/main.rs @@ -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()?) } diff --git a/prdoc/pr_5214.prdoc b/prdoc/pr_5214.prdoc new file mode 100644 index 000000000000..4dc8b28c5948 --- /dev/null +++ b/prdoc/pr_5214.prdoc @@ -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