From ac506ec4a803a7c0862edc5396daa48d39319a5b Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 13 May 2023 15:07:43 +0200 Subject: [PATCH 1/7] fully enable `RuntimeDebug` in `feature = try-runtime` --- .vscode/settings.json | 2 ++ frame/support/Cargo.toml | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000..2c63c0851048d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index f62609585818a..54d6f26910e8d 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -27,6 +27,7 @@ sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../pri sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } sp-weights = { version = "4.0.0", default-features = false, path = "../../primitives/weights" } +sp-debug-derive = { default-features = false, path = "../../primitives/debug-derive" } tt-call = "1.0.8" frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" } paste = "1.0" @@ -71,7 +72,9 @@ std = [ "environmental/std", ] runtime-benchmarks = [] -try-runtime = [] +try-runtime = [ + "sp-debug-derive/force-debug" +] # By default some types have documentation, `no-metadata-docs` allows to reduce the documentation # in the metadata. no-metadata-docs = ["frame-support-procedural/no-metadata-docs", "sp-api/no-metadata-docs"] From 735ace59fd1b9f1a4573199541852892948f27fb Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 13 May 2023 15:13:43 +0200 Subject: [PATCH 2/7] Delete settings.json --- .vscode/settings.json | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 2c63c0851048d..0000000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} From bcabcc6dc93c41e6cb408e6cc273a2c1ff58edf7 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 13 May 2023 15:14:25 +0200 Subject: [PATCH 3/7] fix --- frame/support/procedural/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 895b09a17e083..4352420444dda 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -652,7 +652,7 @@ pub fn derive_debug_no_bound(input: TokenStream) -> TokenStream { /// This behaviour is useful to prevent bloating the runtime WASM blob from unneeded code. #[proc_macro_derive(RuntimeDebugNoBound)] pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { - #[cfg(not(feature = "std"))] + #[cfg(not(any(feature = "std", feature = "try-runtime")))] { let input: syn::DeriveInput = match syn::parse(input) { Ok(input) => input, From 7fabf62b22ddefdec4dc3106c2b973a6c8b49ef1 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 13 May 2023 15:15:40 +0200 Subject: [PATCH 4/7] fix --- frame/support/procedural/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 4352420444dda..08d20593f9929 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -674,7 +674,7 @@ pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { .into() } - #[cfg(feature = "std")] + #[cfg(any(feature = "std", feature = "try-runtime"))] { debug_no_bound::derive_debug_no_bound(input) } From 16c91e10eec2323abfa53b8d88cc5f04f1017b8e Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 13 May 2023 15:59:21 +0200 Subject: [PATCH 5/7] fix --- frame/support/procedural/src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 08d20593f9929..a5ae4372c40b7 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -652,8 +652,9 @@ pub fn derive_debug_no_bound(input: TokenStream) -> TokenStream { /// This behaviour is useful to prevent bloating the runtime WASM blob from unneeded code. #[proc_macro_derive(RuntimeDebugNoBound)] pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { - #[cfg(not(any(feature = "std", feature = "try-runtime")))] - { + if cfg!(any(feature = "std", feature = "try-runtime")) { + debug_no_bound::derive_debug_no_bound(input) + } else { let input: syn::DeriveInput = match syn::parse(input) { Ok(input) => input, Err(e) => return e.to_compile_error().into(), @@ -666,18 +667,13 @@ pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { const _: () = { impl #impl_generics core::fmt::Debug for #name #ty_generics #where_clause { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { - fmt.write_str("") + fmt.write_str("") } } }; ) .into() } - - #[cfg(any(feature = "std", feature = "try-runtime"))] - { - debug_no_bound::derive_debug_no_bound(input) - } } /// Derive [`PartialEq`] but do not bound any generic. Docs are at From 71d5b707712fa67c651e325435e60593353a4f0e Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 15 May 2023 18:21:36 +0200 Subject: [PATCH 6/7] update lock file with sp-debug-derive dep --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index d9cb87af47edd..685171fd1df16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2700,6 +2700,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", + "sp-debug-derive", "sp-inherents", "sp-io", "sp-runtime", From bb520ffebf766a44c2c5a591caab36470d17959c Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 15 May 2023 18:22:04 +0200 Subject: [PATCH 7/7] update doc --- frame/support/procedural/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index a5ae4372c40b7..b8aa5674ddde5 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -648,7 +648,7 @@ pub fn derive_debug_no_bound(input: TokenStream) -> TokenStream { } /// Derive [`Debug`], if `std` is enabled it uses `frame_support::DebugNoBound`, if `std` is not -/// enabled it just returns `""`. +/// enabled it just returns `""`. /// This behaviour is useful to prevent bloating the runtime WASM blob from unneeded code. #[proc_macro_derive(RuntimeDebugNoBound)] pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream {