I came across this in my effort to make the simplest FRAME runtime and pallet, for the new tutorials in https://github.com/paritytech/polkadot-sdk-docs/.
The observation is that construct_runtime, and the need to define type UncheckedExtrinsic and type Block is quite noisy. At best, in a tutorial, you should say: "shuuush... just ignore these for now", which sucks.
type Extrinsic = MockUncheckedExtrinsic<Runtime>;
type Block = MockBlock<Runtime>;
frame_support::construct_runtime!(
pub struct Runtime
where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = Extrinsic,
{
System: frame_system,
Currency: pallet,
}
);
Ideally, I want this to just be:
frame_support::construct_runtime!(
pub struct Runtime {
System: frame_system,
Currency: pallet_currency,
}
);
And I am inclined to think that it is possible.
The fact that construct_runtime needs to know these types is unavoidable. But, can't it get these from frame_system::Config? I think we already have a pretty hard requirement for the frame_system to exist, and exist with the exact crate name frame-system. So it should be possible for construct_runtime to get these types as <#frame_system::Pallet as #frame_system::Config>::Block.
Even further, I think with #13454 we can actually have these have their defaults be set to the things that are in frame_system::mocking:: and free the whole universe from needing to define them at all in 95% of tests.
Needs to be verified. Would love to hear @ggwpez and @bkchr's opinion.
If deemed feasible, suggest @gupnik to take it over.