Skip to content

[FRAME Core] tracking issue for full unleash of DefaultConfig for FRAME #171

@kianenigma

Description

@kianenigma

paritytech/substrate#13454 will bring in the basic functionality needed to start using this feature. See this example to learn more.

This will mark the first version of this work complete, but a lot has to be done in order for it to be fully complete.

Improve Error Handling, Bugs

  • Improve error handling. There seems to be an error in the parse/config.rs file that allows #[pallet::whatever] to be parsed and ignored in #[pallet::config]. This has to be fixed.
  • Properly hide __export_tokens_tt_test_default_config and similar from docs.
  • Handle pallet instancing.

Full usage in Substrate Pallets

Full Usage in node-template-runtime and parachain-template-runtime

  • We should provide runtime templates that utilize this, evangelising its usage. This requires us to carefully consider what is a reasonable default for a node template in order to use. We should provide possibly two new preludes:

Full usage in westend -> kusama -> polkadot runtimes.

  • Once we have are more and more confident in both the core functionality, and our skills to define sensible defaults, we can slowly start migrating perhaps some of the configs define in Polkadot to use this feature.

For security reasons we should be super caution here. Adding #[derive_impl] will open the door for upstream changes manipulating the configurations used in the Polkadot runtime. Perhaps we should only ever do this once we have more tooling that could notify us of unexpected upstream changes to config_preludes.

I would personally find it reasonable to never use this feature in production runtimes for this reason.

V2

At the moment, the system that is introduced is has some limitations. Most notably:

  • it cannot provide default for types that are reliant on types that are themselves reliant on frame_system::Config. For example, a type Admin: Get<Self::AccountId> cannot have a default. Is is mainly because trait DefaultConfig is not in itself trait DefaultConfig: frame_system::DefaultConfig. Moreover, sadly, because the definition of BalanceOf<T> (somewhat needlessly) also relies on frame_system::Config::AccountId, anything akin to Get<BalanceOf<Self>> can also not have a sensible default. add frame_system::DefaultConfig to individual pallet DefaultConfigs substrate#14453

I believe this is father easy to fix, by standardizing frame_system::DefaultConfig and making trait DefaultConfig: frame_system::DefaultConfig.

  • If the above is done, we are only left with types that cannot really have a default in any pallet. Such types are: PalletInfo, RuntimeEvent, RuntimeCall and such. Such types can also be mocked but they require more coordination with construct_runtime!. A new attribute can mark these types simply as #[derive_from_runtime] or similar, which would mean they are expected to be found in the existing scope with the same name. Adds ability to provide defaults for types provided by construct_runtime substrate#14682

Other approaches could be explored for the last step, as I am not quite sure what is the best way forward.

Improvements

Metadata

Metadata

Assignees

Labels

I6-metaA specific issue for grouping tasks or bugs of a specific category.T1-FRAMEThis PR/Issue is related to core FRAME, the framework.

Type

No type

Projects

Status

Draft

Status

To Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions