-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Abstract away the executive #14742
base: master
Are you sure you want to change the base?
Abstract away the executive #14742
Conversation
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 generally like this direction. Such simplifications, especially when backwards compatible, can help reduce the hassle of setting up tests and simple runtimes a lot.
I would imagine a syntax like this, avoiding furthe "shady Rust":
// Valid, no migration, no need for executive.
construct_runtime_next {
struct Runtime { ... }
}
// Valid, some custom migration.
construct_runtime_next {
type Migration = ..
struct Runtime { ... }
}
// Valid, custom executive
construct_runtime_next {
type Executive = ..
struct Runtime { ... }
}
I am also suggesting that we somewhat make this be a new macro, as I can't find an easy way to make it fully backwards compatible. But this can be solved in different ways.
Regardless of my suggestion above, I think the struct Runtime<<Migration>
is a bit iffy, but there could be multiple different alternatives.
@kianenigma I have updated the syntax as per your suggestion. Now, we just need to provide a tuple Please let me know your thoughts. |
block: &TokenStream, | ||
executive_section: ExecutiveSection, | ||
) -> Result<TokenStream> { | ||
let executive = generate_crate_access_2018("frame-executive")?; |
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.
This will play nicely with the new frame
crate, it should re-export the frame-executive
.
pub type Executive = #executive::Executive< | ||
#runtime, | ||
#block, | ||
#system::ChainContext<#runtime>, |
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.
This is kinda cheating, if you want to be pedantic. There's now no good way to configure this. But I am not sure if this is all that useful.
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.
Yeah, I will add the support to provide a custom Executive as well, using the syntax you suggested above.
Why don't we start working on a new |
@@ -17,7 +17,8 @@ impl frame_system::Config for Runtime { | |||
struct Dummy; | |||
|
|||
construct_runtime! { | |||
pub struct Runtime<Dummy> | |||
type Migrations = (Dummy); |
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.
Does it work if you use (Dummy,)
?
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.
Yes, it parses correctly and throws the correct error.
I agree, the |
This PR adds the ability to auto-generate the
Executive
insideconstruct_runtime
. It also creates wrappers onRuntime
that internally call the Executive's APIs.In order to enable this, simply provide a
Migrations
tuple like so:Extension:
We should be able to generate a number of Runtime APIs internally.