paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.76k stars 631 forks source link

[Frame Core] Construct Runtime V2 follow-ups #3688

Open gupnik opened 5 months ago

gupnik commented 5 months ago

https://github.com/paritytech/polkadot-sdk/pull/1378 introduced the new runtime macro. This issue tracks the follow-up items:

kianenigma commented 1 month ago

Abstract away the executive similar to https://github.com/paritytech/substrate/pull/14742

I am not sure about this. but it is a good candidate.

Alternatively, what I see missing rn is mostly that AllPallets is used in Type Executive but is never declared. Bringing it in scope might help.

I have also pointed out before that this macro seems to do some automatic use * that makes it not intuitive to use, and not in par with frame::pallet macro. Would be great if you can log this as well.

Here's my mentality:

You import polkadot-sdk-frame. This docs for this crate should be informative.

#[frame::pallet] 
pub mod pallet1 {
    use frame::pallet_prelude::*;
} 

#[frame::pallet] 
pub mod pallet2 {
    use frame::pallet_prelude::*;
}

#[cfg(test)]
pub mod tests {
    pub use frame::testing_prelude::*; 

    #[frame::runtime]
    pub mod runtime {
        use frame::runtime_prelude::*;
    }
}

So the experience and behavior you would get from all of these should be as similar as possible.

gupnik commented 1 month ago

I have also pointed out before that this macro seems to do some automatic use * that makes it not intuitive to use, and not in par with frame::pallet macro. Would be great if you can log this as well.

It actually maintains the same scope as with the previous CRV1. I can scope those under a mod and expose all of the generated types such as RuntimeEvent by default, but I am not sure if that adds a lot of value?

use frame::runtime_prelude::*;

What does this runtime_prelude provide?

kianenigma commented 1 month ago

What does this runtime_prelude provide?

Types that are needed for a typical runtime, the existing code should to some extent describe this

https://github.com/paritytech/polkadot-sdk/blob/fc07bdadde1dfa3345913130f5209b8267816972/substrate/frame/src/lib.rs#L165-L175