-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Change construct_runtime! macro to use pallet names instead of pallet paths for enum variant identifiers #8862
Comments
What does this solve? What will this break? |
(edited: I wrongly answered for another issue)
this would make names of field and variants more consistent and better IMO, path can lead to weird names, not unique names, and currently we concatenate the instance in order to be unique which is not very good.
the names fields in genesis config, the name of variant in event, the name of variant in origin |
Currently, we use the module path as the enum variant names for a couple of the enums that we generate during macro expansion of This is undesirable fort the reasons Gui mentioned, and to further expand on why this naming scheme is not unique: suppose I have two pallets that are both named construct_runtime! {
pub enum Runtime where
// where clause goes here
{
Pallet1: foo::{Pallet, Event},
Pallet2: crate::foo::{Pallet, Event},
}
} We then use their respective paths to construct enum variant names, but with a caveat: we drop the We could solve this easily by including If the objective here is to use a relatively unique name to name the variants, it would make much more sense to just use an identifier that is already unique -- the pallet name. Not only is it unique, it's also pretty self-documenting: using pallet-collective as an example, I don't need to wonder what In terms of breakage, when FRAME devs upgrade their runtime, if their code makes references to the |
Currently, during macro expansion of
construct_runtime!
, the enums that we generate uses the pallet path rather than the pallet name as a component for the enum variants:Ideally, we would use the pallet name as specified in the
construct_runtime!
macro so that we generate the following instead:In other words, audit calls to
PalletPath::mod_name
, and see if they can be replaced by the pallet name.mod_name
should ideally not exist.Files:
frame/support/procedural/src/construct_runtime/mod.rs
,frame/support/procedural/src/construct_runtime/expand/event.rs
,frame/support/procedural/src/construct_runtime/expand/event.rs
,frame/support/procedural/src/construct_runtime/expand/origin.rs
The text was updated successfully, but these errors were encountered: