-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
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.rsfile that allows#[pallet::whatever]to be parsed and ignored in#[pallet::config]. This has to be fixed. - Properly hide
__export_tokens_tt_test_default_configand similar from docs. - Handle pallet instancing.
Full usage in Substrate Pallets
-
migrate the docs for
derive_implto use real code. As all of this functionality can work on normal traits, and as per add new documentation guidelines substrate#14115, we should strive to make the docs ofderive_implbe real rust code. We might even want to remove./frame/example/default-configin favor this. -
Provide testing defaults for common pallets
- System: already provided
- Balances add
frame_system::DefaultConfigto individual palletDefaultConfigssubstrate#14453 - Assets Adds default config for assets pallet #3637
-
Then, we should start migrating existing pallets and their test setup to use the unified testing prelude of system, balances and so on. Here's the tracking issue: [FRAME Core] remove unnecessary overrides while using
derive_implforframe_system#3237
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, atype Admin: Get<Self::AccountId>cannot have a default. Is is mainly becausetrait DefaultConfigis not in itselftrait DefaultConfig: frame_system::DefaultConfig. Moreover, sadly, because the definition ofBalanceOf<T>(somewhat needlessly) also relies onframe_system::Config::AccountId, anything akin toGet<BalanceOf<Self>>can also not have a sensible default. addframe_system::DefaultConfigto individual palletDefaultConfigssubstrate#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,RuntimeCalland such. Such types can also be mocked but they require more coordination withconstruct_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 byconstruct_runtimesubstrate#14682
Other approaches could be explored for the last step, as I am not quite sure what is the best way forward.
Improvements
- Remove
as frame_system::DefaultConfigfrom the required syntax Removeas frame_system::DefaultConfigfrom the required syntax inderive_impl#3505
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status