Conversation
|
As the associated issue is in it, I suggest keeping only one in the roadmap.) |
* fixes Debug issue * does not fix TypeInfo requirement issue
| for decl in pallet_decls { | ||
| if let Some(_) = decl.find_part("Task") { | ||
| // TODO: for some reason `find_part` above never finds `Task` even when it is | ||
| // clearly in the pallet |
There was a problem hiding this comment.
@KiChjang do you recall when you were setting up HoldReason whether you ever ran into this issue? I based this expand_outer_task method off of your expand_outer_hold_reason method almost exactly and tried to follow all the conventions your HoldReason follows as far as I can tell.
Your version is here:
What's happening here is for some reason decl.find_part("Task") is coming back empty, even when we are looking at a pallet like TasksExample which 100% does have a pub enum Task.
Is there anything additional I need to do to make this get picked up by find_part?
I'll be looking deeply into how pallet parts are parsed and constructed next to see why this might be going around, but wanted to double check there isn't something obvious I've missed first.
There was a problem hiding this comment.
Yes, you need to an an additional variant to one of the enums in the parse module of construct_runtime.
There was a problem hiding this comment.
This is the enum I'm talking about:
substrate/frame/support/procedural/src/construct_runtime/parse.rs
Lines 395 to 409 in 34f45c6
In addition to modifying the above, the runtime maintainer (i.e. whoever calls construct_runtime) needs to also import the pallet part in the construct_runtime macro, e.g.
construct_runtime! {
pub enum Runtime
where
// ...
{
System: frame_system,
MyPallet: path::to::my::pallet::{Pallet, Storage, Call, Event<T>, Task},
}
}Note the additional Task keyword used in MyPallet. You can also use the implicit pallet part import syntax so you have less hassle (i.e. simply MyPallet: path::to::my::pallet,).
There was a problem hiding this comment.
So I believe I am already doing both of these...
In PalletPartKeyword:
https://github.com/paritytech/substrate/pull/14329/files#diff-bc4d1d4294aa1ace0173ab00f6fac84463c64992cd3857099a000fb2266388cfR408
In construct_runtime!:
https://github.com/paritytech/substrate/pull/14329/files#diff-67684005af418e25ff88c2ae5b520f0c040371f1d817e03a3652e76b9485224aR1956
Perhaps I'm not in the right construct_runtime!?? @KiChjang
There was a problem hiding this comment.
ahhh OK I followed your syntax now by doing this in construct_runtime!:
TasksExample: tasks_example::{Pallet, Storage, Call, Event<T>, Task},and now I am just getting this error:
error[E0412]: cannot find type `Task` in crate `tasks_example`
--> /home/sam/workspace/substrate/bin/node/runtime/src/lib.rs:1883:1
|
652 | | #[compact]
| |_________^ not found in `tasks_example`
...
1883 | // construct_runtime!(
1884 | | pub struct Runtime
1885 | | {
1886 | | System: frame_system,
... |
1957 | | }
1958 | | );
| |__- in this macro invocation
|
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
25 + use crate::tasks_example::pallet::Task;
|
25 + use frame_support::pallet_prelude::Task;
|
25 + use tasks_example::pallet::Task;
|
For more information about this error, try `rustc --explain E0412`.
Strangely, tasks_example::Task is perfectly accessible according to the language server, and I can see in the file that there is indeed pub use pallet::*; so yeah investigating this one now
There was a problem hiding this comment.
So yeah this is super weird. I went ahead and pushed up the current code. Anyone have any idea how/why this error is happening when that type is clearly accessible from that context?
* still has inexplicable import error
| .then_some(quote::quote!(HoldReason,)); | ||
|
|
||
| let task_part = def | ||
| .composites |
There was a problem hiding this comment.
This looks wrong. Task is not declared using #[pallet::composite_enum], so it shouldn't be accessing composites here. Instead, a new field called task should exist on the Def.
There was a problem hiding this comment.
ahhh that's probably it.
| } | ||
|
|
||
| fn expand_variant(index: u8, path: &PalletPath, variant_name: &Ident) -> TokenStream { | ||
| // Todo: Replace `Runtime` with the actual runtime ident |
There was a problem hiding this comment.
@sam0x17 Pushed the fix here. We will need to replace it with the actual runtime ident.
|
The CI pipeline was cancelled due to failure one of the required jobs. |
|
The CI pipeline was cancelled due to failure one of the required jobs. |
Fixes paritytech/polkadot-sdk#206