Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up for: Use the umbrella crate for the parachain template #5993 #7464

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
458f1d0
removing unused imports
seemantaggarwal Feb 5, 2025
a7eafd4
cargo lock commit
seemantaggarwal Feb 5, 2025
1b4dadf
removing sc-tracing from parachain node
seemantaggarwal Feb 5, 2025
31c7872
restoring dependencies
seemantaggarwal Feb 6, 2025
5a107ef
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 6, 2025
60a91c2
adding sc-tracing in umbrella
seemantaggarwal Feb 6, 2025
64a49ad
importing sc-tracing
seemantaggarwal Feb 6, 2025
397a818
using sc-tracing from polkadot sdk
seemantaggarwal Feb 6, 2025
a889bbc
adding sc-tracing-proc-macro
seemantaggarwal Feb 6, 2025
9ae57ca
updating cargo toml for umbrella
seemantaggarwal Feb 6, 2025
b2c016a
Update umbrella/Cargo.toml
seemantaggarwal Feb 6, 2025
e15c49d
removing breaking umbrella updates
seemantaggarwal Feb 6, 2025
ec70c2e
trial and error
seemantaggarwal Feb 7, 2025
8a09b44
creating a new feature for umbrella
seemantaggarwal Feb 10, 2025
38c3dcc
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 10, 2025
a62bced
cargo fmt
seemantaggarwal Feb 10, 2025
afcd41f
adding additional crate_name resolution for sc-tracing
seemantaggarwal Feb 13, 2025
db8ca90
fast forwarding Cargo.lock
seemantaggarwal Feb 13, 2025
e20a4f1
adding prdoc
seemantaggarwal Feb 13, 2025
718604e
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 13, 2025
ab2822e
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 14, 2025
8310ca2
taplo and fmt
seemantaggarwal Feb 14, 2025
3ef39b8
cargo.lock patch
seemantaggarwal Feb 14, 2025
0ae2a6c
cargo fmt
seemantaggarwal Feb 14, 2025
02d57d5
taplo format
seemantaggarwal Feb 14, 2025
1c69a34
simplifying crate_name code
seemantaggarwal Feb 14, 2025
f0f65c8
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 14, 2025
3f36de3
step towards replicating codec into sc-tracing
seemantaggarwal Feb 16, 2025
ad6e74a
effort for including sc-tracing in polkadot-sdk
seemantaggarwal Feb 17, 2025
4ad0f0a
changing logic from startswith to fix value for polkadot-sdk resolution
seemantaggarwal Feb 17, 2025
2f95de5
reverting last commit
seemantaggarwal Feb 17, 2025
c7a07b9
cargo fmt
seemantaggarwal Feb 17, 2025
ac9c846
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 17, 2025
5166954
making further changes
seemantaggarwal Feb 18, 2025
e2f570d
further effort, no success
seemantaggarwal Feb 18, 2025
52e0448
implementing suggested changes
seemantaggarwal Feb 23, 2025
13142f1
cargo and taplo
seemantaggarwal Feb 23, 2025
41f6258
resolving cargo.lock conflicts
seemantaggarwal Feb 23, 2025
7cf4e92
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Feb 23, 2025
41a860e
cargo fmt
seemantaggarwal Feb 23, 2025
60f3a6a
adding sc_tracing::loggin in sc-tracing feature
seemantaggarwal Feb 23, 2025
1ed9c36
removing unused imports
seemantaggarwal Feb 23, 2025
c93ad26
fixing umbrella crate changes
seemantaggarwal Feb 23, 2025
5391802
reverting changes from Cargo.toml
seemantaggarwal Feb 23, 2025
00c3bfa
explicit import for sc_tracing::logging
seemantaggarwal Feb 23, 2025
f0128f5
fixes
serban300 Feb 24, 2025
38d5c3c
messy attempt to re‑exports the logging module so that it’s availabl…
seemantaggarwal Mar 6, 2025
545d223
Update from seemantaggarwal running command 'fmt'
github-actions[bot] Mar 6, 2025
3cf488b
adding licenses
seemantaggarwal Mar 8, 2025
8f1997e
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Mar 8, 2025
10b5b92
conflict resolution on Cargo.lock
seemantaggarwal Mar 8, 2025
abf5bf5
fix errors
iulianbarbu Mar 11, 2025
51818d8
addressing comments
seemantaggarwal Mar 15, 2025
98a0fb2
Merge branch 'master' into seemant-parachain-umbrella-crate-mig
seemantaggarwal Mar 15, 2025
47e892d
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Mar 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions prdoc/pr_7464.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: 'Enable importing sc-tracing macros through polkadot-sdk'
doc:
- audience: Node Dev
description: |-
This PR makes it possible to use the sc-tracing macros when they are imported through the umbrella crate.

crates:
- name: parachain-template-node
bump: minor
1 change: 1 addition & 0 deletions substrate/client/tracing/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
15 changes: 7 additions & 8 deletions substrate/client/tracing/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can document this somewhere? what this is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a comment above the function definition:

/// Generate the crate access for the crate using 2018 syntax.
///
/// If `frame` is in scope, it will use `polkadot_sdk_frame::deps::<def_crate>`. Else, it will try
/// and find `<def_crate>` directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality seems to be shared between frame and substrate client. I would not pull in frame namespaced crates as dependencies for substrate/client crates (FYI, a quick fuzzy search for frame in substrate/client is not referencing any frame dependency). I wonder if we should add this (and maybe other related logic) to an existing shared place or a new one - e.g. substrate/utils (although, there isn't a crate for something like it, and we'd need to create one).

Also, the function docs miss to mention that it looks for polkadot-sdk as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, also thought of that, but I don't know. I didn't completely check, but I guess frame-support-procedural-tools should contain pretty generic methods. If it does, I think we could just use it. Maybe we should rename it or move it under primitives. I have to check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure.

@ggwpez @kianenigma what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't bring in frame_support_procedural_tools but rather create a helper function, somewhere accessible to the tracing proc macro, that similarly resolves dependencies.

it will check if polkadot-sdk is in scope, use that, else look for the crate name directly.

It should not care about polkadot-sdk-frame, because this is all client side code, which is why I am saying we should not use frame_support_procedural_tools (other than it being a weird dependency).

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.
///
Expand Down Expand Up @@ -109,18 +109,17 @@ 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: sc_cli::prefix_logs_with(<expr>)",
"missing argument: prefix. Example: sc_cli::prefix_logs_with(<expr>)",
)
.to_compile_error()
.into()
.into();
}

let name = syn::parse_macro_input!(arg as Expr);

let crate_name = match crate_name("sc-tracing") {
Ok(FoundCrate::Itself) => Ident::new("sc_tracing", Span::call_site()),
Ok(FoundCrate::Name(crate_name)) => Ident::new(&crate_name, 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;
Expand Down
3 changes: 0 additions & 3 deletions templates/parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ build = "build.rs"

[dependencies]
clap = { features = ["derive"], workspace = true }
codec = { workspace = true, default-features = true }
color-print = { workspace = true }
docify = { workspace = true }
futures = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
log = { workspace = true, default-features = true }
serde = { features = ["derive"], workspace = true, default-features = true }
serde_json = { workspace = true, default-features = true }

polkadot-sdk = { workspace = true, features = ["node"] }

parachain-template-runtime = { workspace = true }

# Substrate
prometheus-endpoint = { workspace = true, default-features = true }
sc-tracing = { workspace = true, default-features = true }

[build-dependencies]
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }
Expand Down
Loading