Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Move Block, NodeBlock and UncheckedExtrinsic to frame_system, instead construct_runtime #14126

@kianenigma

Description

@kianenigma

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.

Metadata

Metadata

Assignees

Labels

J0-enhancementAn additional feature request.T1-runtimeThis PR/Issue is related to the topic “runtime”.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions