-
Notifications
You must be signed in to change notification settings - Fork 688
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
Macros to use path instead of ident #1474
Conversation
@@ -762,7 +767,7 @@ fn expand_benchmark( | |||
Expr::Cast(t) => { | |||
let ty = t.ty.clone(); | |||
quote! { | |||
<<T as frame_system::Config>::RuntimeOrigin as From<#ty>>::from(#origin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of this seem to have been hardcoded 🙈 well, not like anything broke because of it, but indeed not a good practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless if was intentional? but I can't see a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see a reason either, and we need this unhardcoded moving forward to work with the frame umbrella crate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Def. on the right path, just need more tests.
@@ -762,7 +767,7 @@ fn expand_benchmark( | |||
Expr::Cast(t) => { | |||
let ty = t.ty.clone(); | |||
quote! { | |||
<<T as frame_system::Config>::RuntimeOrigin as From<#ty>>::from(#origin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless if was intentional? but I can't see a reason.
@@ -783,7 +783,7 @@ fn decl_static_assertions( | |||
quote! { | |||
#scrate::__private::tt_call! { | |||
macro = [{ #path::tt_error_token }] | |||
frame_support = [{ #scrate }] | |||
your_tt_return = [{ #scrate::__private::tt_return }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall this was one of the BIG BIG fixes in this PR when I was working on it.
Try this for yourself: if you are familiar with the tt_call pattern a bit, instead of passing in the your_tt_return
, pass frame_support
as it was in the past to the caller. Then have the caller call #frame_support::__private::tt_return
instead of plain your_tt_return
. These two seem equivalent, but the former never worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, hearing what I just said, in the scope of this PR, it is pretty unclear why we are doing this. I recall my working example was minimal-runtime
. Would be good if you also bring back some sort of example here to demonstrate that this change is actually needed. Ideally, this example will just a test in frame-support and not the frame
crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two seem equivalent, but the former never worked.
Yes, that's what looks at a glance... did you find out what's the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good if you also bring back some sort of example here to demonstrate that this change is actually needed
@kianenigma Probably the best example is by using the frame-crate itself, which makes me reconsider if bringing this change here was a good idea and instead bring it in the 'main' frame umbrella PR. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I highly suspect that it didn't work before because the "receiver" didn't expect to see any "arguments" named your_tt_return
and have been coded to only recognize frame_support
as an "argument". If you take a look at tt_default_parts.rs
, you'll see what I mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my memory is good, the former didn't work because there was another error when giving a path instead of a single ident:
Like code was something like this:
frame_support = [{ $($frame_support:ident)::* }]
} => {
$($frame_support::)*__private::tt_return! {
but it should have been like this for path to work
frame_support = [{ $($frame_support:ident)::* }]
} => {
// see the semicolon is after the parentheses here
$($frame_support)::*__private::tt_return! {
but when you implemented with your_tt_return
you fixed this kind of error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macro_magic
might make this easier to reason about perhaps 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the specific workaround for passing paths to these btw is to do an interpolation of idents segmented by ::
and with an optional leading ::
. For some reason that just works positionally where path
doesn't,
see: https://github.com/sam0x17/macro_magic/blob/main/core/src/lib.rs#L511
bot fmt |
@juangirini https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3709127 was started for your command Comment |
@juangirini Command |
* master: (54 commits) Publish `xcm-emulator` crate (#1881) Adding migrations to clean Rococo Gov 1 storage & reserved funds (#1849) Arkworks Elliptic Curve utils overhaul (#1870) Fix typos (#1878) fix: GoAhead signal only set when runtime upgrade is enacted from parachain side (#1176) Refactor staking ledger (#1484) Paired-key Crypto Scheme (#1705) Include polkadot version in artifact path (#1828) add link to rfc-0001 in broker README (#1862) Discard `Executor` (#1855) Macros to use path instead of ident (#1474) Remove clippy clone-double-ref lint noise (#1860) Refactor alliance benchmarks to v2 (#1868) Check executor params coherence (#1774) frame: use derive-impl for beefy and mmr pallets (#1867) sc-consensus-beefy: improve gossip logic (#1852) Adds instance support for composite enums (#1857) Fix links to implementers' guide (#1865) Disabled validators runtime API (#1257) Adding `try_state` hook for `Treasury` pallet (#1820) ...
…ribution * tsv-disabling-backing: (54 commits) Publish `xcm-emulator` crate (#1881) Adding migrations to clean Rococo Gov 1 storage & reserved funds (#1849) Arkworks Elliptic Curve utils overhaul (#1870) Fix typos (#1878) fix: GoAhead signal only set when runtime upgrade is enacted from parachain side (#1176) Refactor staking ledger (#1484) Paired-key Crypto Scheme (#1705) Include polkadot version in artifact path (#1828) add link to rfc-0001 in broker README (#1862) Discard `Executor` (#1855) Macros to use path instead of ident (#1474) Remove clippy clone-double-ref lint noise (#1860) Refactor alliance benchmarks to v2 (#1868) Check executor params coherence (#1774) frame: use derive-impl for beefy and mmr pallets (#1867) sc-consensus-beefy: improve gossip logic (#1852) Adds instance support for composite enums (#1857) Fix links to implementers' guide (#1865) Disabled validators runtime API (#1257) Adding `try_state` hook for `Treasury` pallet (#1820) ...
Relates to #173
As part of the efforts towards making the FRAME umbrella crate in #1337, we need macros to work without
frame-support
,frame-system
andcodec
, andtype-info
being in scope.This PR leaves
generate_crate_access_2018
ready to check for theframe
crate once this one is ready and use its reexports instead of the local dependencies.