From 3246c704a3a8f6b3eeb54b8daedb377a370e5314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 20 Dec 2023 12:17:08 +0100 Subject: [PATCH 1/4] Colorize the output Adds some colors to the logs and also some empty space around the log lines from try-runtime-cli to make it more clear what belongs to what. Before I always had the problem that there was a wall of text and I didn't know when something started and something ended. This pr makes it a little bit better. The ashetics are discussable and clearly can be improved. --- Cargo.lock | 7 +++ core/Cargo.toml | 1 + core/src/commands/on_runtime_upgrade.rs | 58 ++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d43cea1dcc4..522af9ffddb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6923,6 +6923,12 @@ dependencies = [ "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=master)", ] +[[package]] +name = "paris" +version = "1.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fecab3723493c7851f292cb060f3ee1c42f19b8d749345d0d7eaf3fd19aa62d" + [[package]] name = "parity-db" version = "0.4.10" @@ -11727,6 +11733,7 @@ dependencies = [ "itertools 0.11.0", "log", "node-primitives", + "paris", "parity-scale-codec", "regex", "sc-cli", diff --git a/core/Cargo.toml b/core/Cargo.toml index 09cb7847d26..0562c028513 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -52,6 +52,7 @@ sp-version = { workspace = true } sp-weights = { workspace = true } substrate-rpc-client = { workspace = true } +paris = "1.5.15" [dev-dependencies] assert_cmd = { workspace = true } diff --git a/core/src/commands/on_runtime_upgrade.rs b/core/src/commands/on_runtime_upgrade.rs index 89d2e8f85d5..af16a356c34 100644 --- a/core/src/commands/on_runtime_upgrade.rs +++ b/core/src/commands/on_runtime_upgrade.rs @@ -19,6 +19,7 @@ use std::{fmt::Debug, str::FromStr}; use bytesize::ByteSize; use frame_try_runtime::UpgradeCheckSelect; +use paris::formatter::colorize_string; use parity_scale_codec::Encode; use sc_executor::sp_wasm_interface::HostFunctions; use sp_core::{hexdisplay::HexDisplay, Hasher}; @@ -101,8 +102,23 @@ where // Run `TryRuntime_on_runtime_upgrade` with the given checks. log::info!( - "🔬 Running TryRuntime_on_runtime_upgrade with checks: {:?}", - command.checks + "{}", + colorize_string( + "-------------------------------------------------------------------\n\n" + ) + ); + log::info!( + "{}", + colorize_string(format!( + "🔬 Running TryRuntime_on_runtime_upgrade with checks: {:?}\n\n", + command.checks + )) + ); + log::info!( + "{}", + colorize_string( + "-------------------------------------------------------------------" + ) ); // Save the overlayed changes from the first run, so we can use them later for idempotency // checks. @@ -126,7 +142,16 @@ where UpgradeCheckSelect::None => (proof, ref_time_results), _ => { log::info!( - "🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements." + "{}", + colorize_string("-------------------------------------------------------------------\n\n") + ); + log::info!( + "{}", + colorize_string("🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements.\n\n"), + ); + log::info!( + "{}", + colorize_string("-------------------------------------------------------------------") ); let (proof, encoded_result) = state_machine_call_with_proof::( &ext, @@ -150,8 +175,16 @@ where } false => { log::info!( - "🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: {:?}", - command.checks + "{}", + colorize_string("-------------------------------------------------------------------\n\n") + ); + log::info!( + "{}", + colorize_string(format!("🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: {:?}\n\n", command.checks)), + ); + log::info!( + "{}", + colorize_string("-------------------------------------------------------------------") ); let (oc_pre_root, _) = overlayed_changes.storage_root(&ext.backend, ext.state_version); match state_machine_call_with_proof::( @@ -212,8 +245,19 @@ where } }; - if !weight_ok || !idempotency_ok { - log::error!("❌ Issues detected, exiting non-zero. See logs."); + if !weight_ok || idempotency_ok { + log::error!( + "{}", + colorize_string("-------------------------------------------------------------------\n\n") + ); + log::error!( + "{}", + colorize_string("❌ Issues detected, exiting non-zero. See logs.\n\n"), + ); + log::error!( + "{}", + colorize_string("-------------------------------------------------------------------") + ); std::process::exit(1); } From f4d01a6d82a66c505d5107bffe473c7c9f6d9834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 20 Dec 2023 12:19:38 +0100 Subject: [PATCH 2/4] Revert testing --- core/src/commands/on_runtime_upgrade.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/commands/on_runtime_upgrade.rs b/core/src/commands/on_runtime_upgrade.rs index af16a356c34..b462bdaa9ce 100644 --- a/core/src/commands/on_runtime_upgrade.rs +++ b/core/src/commands/on_runtime_upgrade.rs @@ -245,7 +245,7 @@ where } }; - if !weight_ok || idempotency_ok { + if !weight_ok || !idempotency_ok { log::error!( "{}", colorize_string("-------------------------------------------------------------------\n\n") From b786c296de8ae2b6022fab7dc080e1895089c7fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 20 Dec 2023 12:21:38 +0100 Subject: [PATCH 3/4] FMT --- core/src/commands/on_runtime_upgrade.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/commands/on_runtime_upgrade.rs b/core/src/commands/on_runtime_upgrade.rs index b462bdaa9ce..7db7064f6d1 100644 --- a/core/src/commands/on_runtime_upgrade.rs +++ b/core/src/commands/on_runtime_upgrade.rs @@ -256,7 +256,9 @@ where ); log::error!( "{}", - colorize_string("-------------------------------------------------------------------") + colorize_string( + "-------------------------------------------------------------------" + ) ); std::process::exit(1); } From 41a9d4fbc58d0b7a47e945cf176a9f9474514f73 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 21 Dec 2023 11:29:26 +0400 Subject: [PATCH 4/4] bump version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 522af9ffddb..536d22a2666 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11666,7 +11666,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" -version = "0.5.1" +version = "0.5.2" dependencies = [ "clap", "env_logger", @@ -11721,7 +11721,7 @@ dependencies = [ [[package]] name = "try-runtime-core" -version = "0.5.1" +version = "0.5.2" dependencies = [ "assert_cmd", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 26edb908fe0..c2a1d6f9b00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ resolver = "2" members = ["cli", "core"] [workspace.package] -version = "0.5.1" +version = "0.5.2" authors = ["Parity Technologies "] description = "Substrate's programmatic testing framework." edition = "2021"