From fdb1dba2e1eded282ff2eaf745d55c378f777cc2 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 8 Apr 2024 15:30:32 +0200 Subject: [PATCH] Add best block indicator to informant message + print parent block on import message (#4021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes you need to debug some issues just by the logs and reconstruct what happened. In these scenarios it would be nice to know if a block was imported as best block, and what it parent was. So here I propose to change the output of the informant to this: ``` 2024-04-05 20:38:22.004 INFO ⋮substrate: [Parachain] ✨ Imported #18 (0xe7b3…4555 -> 0xbd6f…ced7) 2024-04-05 20:38:24.005 INFO ⋮substrate: [Parachain] ✨ Imported #19 (0xbd6f…ced7 -> 0x4dd0…d81f) 2024-04-05 20:38:24.011 INFO ⋮substrate: [jobless-children-5352] 🌟 Imported #42 (0xed2e…27fc -> 0x718f…f30e) 2024-04-05 20:38:26.005 INFO ⋮substrate: [Parachain] ✨ Imported #20 (0x4dd0…d81f -> 0x6e85…e2b8) 2024-04-05 20:38:28.004 INFO ⋮substrate: [Parachain] 🌟 Imported #21 (0x6e85…e2b8 -> 0xad53…2a97) 2024-04-05 20:38:30.004 INFO ⋮substrate: [Parachain] 🌟 Imported #22 (0xad53…2a97 -> 0xa874…890f) ``` --------- Co-authored-by: Bastian Köcher --- prdoc/pr_4021.prdoc | 13 +++++++++++++ substrate/client/informant/src/lib.rs | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 prdoc/pr_4021.prdoc diff --git a/prdoc/pr_4021.prdoc b/prdoc/pr_4021.prdoc new file mode 100644 index 000000000000..1f3a2748d133 --- /dev/null +++ b/prdoc/pr_4021.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Improve log output for block imports + +doc: + - audience: Node Operator + description: | + Nodes now print the parent hash on import notification log messages. In addition, the emoji + of the log message indicates whether the block was imported as best block or not. "🏆" is used for + best blocks, "🆕" for other imported blocks. + +crates: [ ] diff --git a/substrate/client/informant/src/lib.rs b/substrate/client/informant/src/lib.rs index 7db80bb2d972..af778529ffc5 100644 --- a/substrate/client/informant/src/lib.rs +++ b/substrate/client/informant/src/lib.rs @@ -187,10 +187,12 @@ where last_blocks.pop_front(); } + let best_indicator = if n.is_new_best { "🏆" } else { "🆕" }; info!( target: "substrate", - "✨ Imported #{} ({})", + "{best_indicator} Imported #{} ({} → {})", format.print_with_color(Colour::White.bold(), n.header.number()), + n.header.parent_hash(), n.hash, ); }