Skip to content
Snippets Groups Projects
Unverified Commit f0128f50 authored by Serban Iorga's avatar Serban Iorga
Browse files

fixes

parent 00c3bfa0
Branches
No related merge requests found
Pipeline #516657 waiting for manual action with stages
in 1 hour, 16 minutes, and 28 seconds
......@@ -24128,6 +24128,7 @@ dependencies = [
name = "sc-tracing-proc-macro"
version = "11.0.0"
dependencies = [
"frame-support-procedural-tools 10.0.0",
"proc-macro-crate 3.1.0",
"proc-macro2 1.0.93",
"quote 1.0.38",
......
title: 'Fix sc-tracing to be derived from umbrella crate in parachain template'
title: 'Enable importing sc-tracing macros through polkadot-sdk'
doc:
- audience: Runtime Dev
- audience: Node Dev
description: |-
Resolving sc-tracing not being resolved when imported through the polkadot sdk
This PR makes it possible to use the sc-tracing macros when they are imported through the umbrella crate.
crates:
- name: parachain-template-node
......
......@@ -18,6 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true
[dependencies]
frame-support-procedural-tools = { workspace = true, default-features = true }
proc-macro-crate = { workspace = true }
proc-macro2 = { workspace = true }
quote = { features = ["proc-macro"], workspace = true }
......
......@@ -15,11 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support_procedural_tools::generate_access_from_frame_or_crate;
use proc_macro::TokenStream;
use proc_macro2::Span;
use proc_macro_crate::{crate_name, FoundCrate};
use quote::quote;
use syn::{Error, Expr, Ident, ItemFn};
use syn::{Error, Expr, ItemFn};
/// Add a log prefix to the function.
///
......@@ -109,7 +109,7 @@ pub fn prefix_logs_with(arg: TokenStream, item: TokenStream) -> TokenStream {
if arg.is_empty() {
return Error::new(
Span::call_site(),
"missing argument: name of the node. Example: #[prefix_logs_with(\"MyNode\")]",
"missing argument: prefix. Example: sc_cli::prefix_logs_with(<expr>)",
)
.to_compile_error()
.into();
......@@ -117,14 +117,9 @@ pub fn prefix_logs_with(arg: TokenStream, item: TokenStream) -> TokenStream {
let name = syn::parse_macro_input!(arg as Expr);
let crate_name = match crate_name("polkadot-sdk") {
Ok(FoundCrate::Name(sdk_name)) => Ident::new(sdk_name.as_str(), Span::call_site()),
_ => match crate_name("sc-tracing") {
Ok(FoundCrate::Itself) => Ident::new("sc_tracing", Span::call_site()),
Ok(FoundCrate::Name(tracing_name)) =>
Ident::new(tracing_name.as_str(), Span::call_site()),
Err(e) => return Error::new(Span::call_site(), e).to_compile_error().into(),
},
let crate_name = match generate_access_from_frame_or_crate("sc-tracing") {
Ok(ident) => ident,
Err(err) => return err.to_compile_error().into(),
};
let ItemFn { attrs, vis, sig, block } = item_fn;
......
......@@ -17,20 +17,25 @@ docify = { workspace = true }
futures = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
log = { workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["node"] }
serde = { features = ["derive"], workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["node"] }
parachain-template-runtime = { workspace = true }
# Substrate
prometheus-endpoint = { workspace = true, default-features = true }
[build-dependencies]
polkadot-sdk = { workspace = true, features = ["node", "substrate-build-script-utils"] }
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }
[features]
default = ["std"]
std = ["log/std", "parachain-template-runtime/std", "polkadot-sdk/std"]
std = [
"log/std",
"parachain-template-runtime/std",
"polkadot-sdk/std",
]
runtime-benchmarks = [
"parachain-template-runtime/runtime-benchmarks",
"polkadot-sdk/runtime-benchmarks",
......
......@@ -10,6 +10,7 @@ use parachain_template_runtime::{
};
use polkadot_sdk::*;
// Cumulus Imports
use cumulus_client_cli::CollatorOptions;
use cumulus_client_collator::service::CollatorService;
......@@ -31,7 +32,6 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use polkadot_sdk::sc_tracing::logging;
use prometheus_endpoint::Registry;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
......@@ -229,7 +229,7 @@ fn start_consensus(
}
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
#[logging::prefix_logs_with("Parachain")]
#[sc_tracing::logging::prefix_logs_with("Parachain")]
pub async fn start_parachain_node(
parachain_config: Configuration,
polkadot_config: Configuration,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment