From 9e75ca92d02b614e1eeae324a67bafc4e40cefb7 Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 17 Jan 2025 20:35:04 +0600 Subject: [PATCH 01/12] Support `RuntimeEvent` associated type bound, use it in example pallets --- substrate/frame/examples/basic/src/lib.rs | 7 +- substrate/frame/examples/basic/src/tests.rs | 1 - .../frame/examples/default-config/src/lib.rs | 10 +- substrate/frame/examples/dev-mode/src/lib.rs | 6 +- .../frame/examples/dev-mode/src/tests.rs | 4 +- .../frame/examples/frame-crate/src/lib.rs | 8 +- .../frame/examples/kitchensink/src/lib.rs | 5 +- .../frame/examples/kitchensink/src/tests.rs | 1 - .../frame/examples/offchain-worker/src/lib.rs | 7 +- .../examples/offchain-worker/src/tests.rs | 1 - substrate/frame/examples/split/src/lib.rs | 4 +- substrate/frame/examples/split/src/mock.rs | 1 - substrate/frame/parameters/src/tests/mock.rs | 2 - .../parameters/src/tests/test_renamed.rs | 2 - .../procedural/src/pallet/expand/event.rs | 14 ++- .../procedural/src/pallet/parse/config.rs | 103 +++++++++++++++++- .../procedural/src/pallet/parse/mod.rs | 20 +++- 17 files changed, 140 insertions(+), 56 deletions(-) diff --git a/substrate/frame/examples/basic/src/lib.rs b/substrate/frame/examples/basic/src/lib.rs index efdf4332e3296..5288415ae5a9f 100644 --- a/substrate/frame/examples/basic/src/lib.rs +++ b/substrate/frame/examples/basic/src/lib.rs @@ -153,14 +153,13 @@ pub mod pallet { /// /// `frame_system::Config` should always be included. #[pallet::config] - pub trait Config: pallet_balances::Config + frame_system::Config { + pub trait Config: + pallet_balances::Config + frame_system::Config>> + { // Setting a constant config parameter from the runtime #[pallet::constant] type MagicNumber: Get; - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// Type representing the weight of this pallet type WeightInfo: WeightInfo; } diff --git a/substrate/frame/examples/basic/src/tests.rs b/substrate/frame/examples/basic/src/tests.rs index 5ec253ebecf42..8659dfbdba130 100644 --- a/substrate/frame/examples/basic/src/tests.rs +++ b/substrate/frame/examples/basic/src/tests.rs @@ -79,7 +79,6 @@ impl pallet_balances::Config for Test { impl Config for Test { type MagicNumber = ConstU64<1_000_000_000>; - type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/substrate/frame/examples/default-config/src/lib.rs b/substrate/frame/examples/default-config/src/lib.rs index f690bffe0998b..573c037ce090d 100644 --- a/substrate/frame/examples/default-config/src/lib.rs +++ b/substrate/frame/examples/default-config/src/lib.rs @@ -43,12 +43,7 @@ pub mod pallet { /// /// It will be an identical, but won't have anything that is `#[pallet::no_default]`. #[pallet::config(with_default)] - pub trait Config: frame_system::Config { - /// The overarching event type. This is coming from the runtime, and cannot have a default. - /// In general, `Runtime*`-oriented types cannot have a sensible default. - #[pallet::no_default] // optional. `RuntimeEvent` is automatically excluded as well. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - + pub trait Config: frame_system::Config>> { /// The overarching task type. #[pallet::no_default] type RuntimeTask: Task; @@ -196,8 +191,7 @@ pub mod tests { #[derive_impl(TestDefaultConfig as pallet::DefaultConfig)] impl pallet_default_config_example::Config for Runtime { - // These two both cannot have defaults. - type RuntimeEvent = RuntimeEvent; + // This cannot have default. type RuntimeTask = RuntimeTask; type HasNoDefault = frame_support::traits::ConstU32<1>; diff --git a/substrate/frame/examples/dev-mode/src/lib.rs b/substrate/frame/examples/dev-mode/src/lib.rs index eb94c024280c7..02c4e6460fc10 100644 --- a/substrate/frame/examples/dev-mode/src/lib.rs +++ b/substrate/frame/examples/dev-mode/src/lib.rs @@ -51,9 +51,9 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::config] - pub trait Config: pallet_balances::Config + frame_system::Config { - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + pub trait Config: + pallet_balances::Config + frame_system::Config>> + { } // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and diff --git a/substrate/frame/examples/dev-mode/src/tests.rs b/substrate/frame/examples/dev-mode/src/tests.rs index 637864b87bc43..9a5e0436867f0 100644 --- a/substrate/frame/examples/dev-mode/src/tests.rs +++ b/substrate/frame/examples/dev-mode/src/tests.rs @@ -70,9 +70,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; } -impl Config for Test { - type RuntimeEvent = RuntimeEvent; -} +impl Config for Test {} // This function basically just builds a genesis storage key/value store according to // our desired mockup. diff --git a/substrate/frame/examples/frame-crate/src/lib.rs b/substrate/frame/examples/frame-crate/src/lib.rs index 781cba5658d77..bbafb5497910b 100644 --- a/substrate/frame/examples/frame-crate/src/lib.rs +++ b/substrate/frame/examples/frame-crate/src/lib.rs @@ -22,9 +22,7 @@ pub mod pallet { use super::*; #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: IsType<::RuntimeEvent> + From>; - } + pub trait Config: frame_system::Config>> {} #[pallet::pallet] pub struct Pallet(_); @@ -60,7 +58,5 @@ mod tests { type Block = MockBlock; } - impl my_pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - } + impl my_pallet::Config for Runtime {} } diff --git a/substrate/frame/examples/kitchensink/src/lib.rs b/substrate/frame/examples/kitchensink/src/lib.rs index 442318565426e..70de254ffca08 100644 --- a/substrate/frame/examples/kitchensink/src/lib.rs +++ b/substrate/frame/examples/kitchensink/src/lib.rs @@ -68,10 +68,7 @@ pub mod pallet { /// * `#[pallet::disable_frame_system_supertrait_check]` would remove the need for /// `frame_system::Config` to exist, which you should almost never need. #[pallet::config] - pub trait Config: frame_system::Config { - /// The overarching runtime event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - + pub trait Config: frame_system::Config>> { /// Type representing the weight of this pallet type WeightInfo: WeightInfo; diff --git a/substrate/frame/examples/kitchensink/src/tests.rs b/substrate/frame/examples/kitchensink/src/tests.rs index 7cf95497bf064..d8f8146d9e944 100644 --- a/substrate/frame/examples/kitchensink/src/tests.rs +++ b/substrate/frame/examples/kitchensink/src/tests.rs @@ -58,7 +58,6 @@ parameter_types! { } impl Config for Test { - type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = Balances; diff --git a/substrate/frame/examples/offchain-worker/src/lib.rs b/substrate/frame/examples/offchain-worker/src/lib.rs index b3fdb6ea1897a..71533aba445ed 100644 --- a/substrate/frame/examples/offchain-worker/src/lib.rs +++ b/substrate/frame/examples/offchain-worker/src/lib.rs @@ -125,14 +125,13 @@ pub mod pallet { /// This pallet's configuration trait #[pallet::config] pub trait Config: - CreateSignedTransaction> + CreateInherent> + frame_system::Config + CreateSignedTransaction> + + CreateInherent> + + frame_system::Config>> { /// The identifier type for an offchain worker. type AuthorityId: AppCrypto; - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - // Configuration parameters /// A grace period after we send transaction. diff --git a/substrate/frame/examples/offchain-worker/src/tests.rs b/substrate/frame/examples/offchain-worker/src/tests.rs index df5cf02594f6f..0f6bfd83e712a 100644 --- a/substrate/frame/examples/offchain-worker/src/tests.rs +++ b/substrate/frame/examples/offchain-worker/src/tests.rs @@ -129,7 +129,6 @@ parameter_types! { } impl Config for Test { - type RuntimeEvent = RuntimeEvent; type AuthorityId = crypto::TestAuthId; type GracePeriod = ConstU64<5>; type UnsignedInterval = ConstU64<128>; diff --git a/substrate/frame/examples/split/src/lib.rs b/substrate/frame/examples/split/src/lib.rs index 5245d90e390cf..c1591de30fc74 100644 --- a/substrate/frame/examples/split/src/lib.rs +++ b/substrate/frame/examples/split/src/lib.rs @@ -57,9 +57,7 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] - pub trait Config: frame_system::Config { - /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + pub trait Config: frame_system::Config>> { /// Type representing the weight of this pallet type WeightInfo: WeightInfo; } diff --git a/substrate/frame/examples/split/src/mock.rs b/substrate/frame/examples/split/src/mock.rs index 5bf414ee24133..f890ae703bfec 100644 --- a/substrate/frame/examples/split/src/mock.rs +++ b/substrate/frame/examples/split/src/mock.rs @@ -37,7 +37,6 @@ impl frame_system::Config for Test { } impl pallet_template::Config for Test { - type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/substrate/frame/parameters/src/tests/mock.rs b/substrate/frame/parameters/src/tests/mock.rs index 53a3b3e394c4b..b319e7d102384 100644 --- a/substrate/frame/parameters/src/tests/mock.rs +++ b/substrate/frame/parameters/src/tests/mock.rs @@ -140,8 +140,6 @@ impl Config for Runtime { impl pallet_example_basic::Config for Runtime { // Use the dynamic key in the pallet config: type MagicNumber = dynamic_params::pallet1::Key1; - - type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/substrate/frame/parameters/src/tests/test_renamed.rs b/substrate/frame/parameters/src/tests/test_renamed.rs index 7c371c5e55f87..9cf0f457d7002 100644 --- a/substrate/frame/parameters/src/tests/test_renamed.rs +++ b/substrate/frame/parameters/src/tests/test_renamed.rs @@ -90,8 +90,6 @@ impl Config for Runtime { impl pallet_example_basic::Config for Runtime { // Use the dynamic key in the pallet config: type MagicNumber = dynamic_params::pallet1::Key1; - - type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/substrate/frame/support/procedural/src/pallet/expand/event.rs b/substrate/frame/support/procedural/src/pallet/expand/event.rs index 8519143179d65..3dbbfb24e3852 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/event.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/event.rs @@ -143,17 +143,25 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let PalletEventDepositAttr { fn_vis, fn_span, .. } = deposit_event; + // `RuntimeEvent` can be defined either as associated type in `Config` or as a type bound in + // system supertrait. + let runtime_event_path = if def.config.has_event_bound { + quote::quote! { ::RuntimeEvent } + } else { + quote::quote! { ::RuntimeEvent } + }; + quote::quote_spanned!(*fn_span => impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause { #fn_vis fn deposit_event(event: Event<#event_use_gen>) { let event = < - ::RuntimeEvent as + #runtime_event_path as From> >::from(event); let event = < - ::RuntimeEvent as - Into<::RuntimeEvent> + #runtime_event_path as + Into<#runtime_event_path> >::into(event); <#frame_system::Pallet>::deposit_event(event) diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 6b6dcc802e2e7..5664b59b1128c 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -63,6 +63,8 @@ pub struct ConfigDef { /// * `IsType::RuntimeEvent` /// * `From` or `From>` or `From>` pub has_event_type: bool, + /// Whether the supertrait `frame_system::Config` defines associated type `RuntimeEvent`. + pub has_event_bound: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, /// Whether a default sub-trait should be generated. @@ -366,6 +368,38 @@ fn contains_type_info_bound(ty: &TraitItemType) -> bool { }) } +/// Check that supertrait `Config` contains `RuntimeEvent` associated type bound with +/// `From>`. +/// +/// NOTE: Does not check if the supertrait path is valid system config path. +/// +/// ```rs +/// pub trait Config: frame_system::Config>> { +/// ``` +fn contains_runtime_event_associated_type_bound(supertrait: &syn::Path) -> bool { + if let Some(args) = supertrait.segments.iter().find(|s| s.ident == "Config") { + if let syn::PathArguments::AngleBracketed(args) = &args.arguments { + for arg in &args.args { + if let syn::GenericArgument::Constraint(c) = arg { + if c.ident != "RuntimeEvent" { + continue; + } + + // Check `From>` bound + let from_event_bound = c + .bounds + .iter() + .find_map(|s| syn::parse2::(s.to_token_stream()).ok()); + + return from_event_bound.is_some(); + } + } + } + } + + false +} + impl ConfigDef { pub fn try_from( frame_system: &syn::Path, @@ -406,10 +440,18 @@ impl ConfigDef { false }; - let has_frame_system_supertrait = item.supertraits.iter().any(|s| { - syn::parse2::(s.to_token_stream()) - .map_or(false, |b| has_expected_system_config(b, frame_system)) - }); + let (has_frame_system_supertrait, has_event_bound) = item + .supertraits + .iter() + .filter_map(|supertrait| syn::parse2::(supertrait.to_token_stream()).ok()) + .fold((false, false), |(mut has_system, mut has_event_bound), supertrait| { + has_system = + has_system || has_expected_system_config(supertrait.clone(), frame_system); + has_event_bound = + has_event_bound || contains_runtime_event_associated_type_bound(&supertrait); + + (has_system, has_event_bound) + }); let mut has_event_type = false; let mut consts_metadata = vec![]; @@ -589,6 +631,7 @@ impl ConfigDef { consts_metadata, associated_types_metadata, has_event_type, + has_event_bound, where_clause, default_sub_trait, }) @@ -712,4 +755,56 @@ mod tests { let path = syn::parse2::(quote::quote!(something::Config)).unwrap(); assert!(!has_expected_system_config(path, &frame_system)); } + + #[test] + fn contains_runtime_event_associated_type_bound_no_bound() { + let supertrait = syn::parse2::(quote::quote!(frame_system::Config)).unwrap(); + assert!(!contains_runtime_event_associated_type_bound(&supertrait)); + } + + #[test] + fn contains_runtime_event_associated_type_bound_works() { + let supertrait = syn::parse2::(quote::quote!( + Config>> + )); + assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); + } + #[test] + fn contains_runtime_event_associated_type_bound_works_interface() { + let supertrait = syn::parse2::(quote::quote!( + Config>> + )); + assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); + } + + #[test] + fn contains_runtime_event_associated_type_bound_works_full_path() { + let supertrait = syn::parse2::(quote::quote!( + frame_system::Config>> + )); + assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); + } + + #[test] + fn contains_runtime_event_associated_type_bound_invalid_supertrait() { + let supertrait = + syn::parse2::(quote::quote!(SystemConfig>>)) + .unwrap(); + assert!(!contains_runtime_event_associated_type_bound(&supertrait)); + } + + #[test] + fn contains_runtime_event_associated_type_bound_invalid_assoc_type_name() { + let supertrait = + syn::parse2::(quote::quote!(Config>>)) + .unwrap(); + assert!(!contains_runtime_event_associated_type_bound(&supertrait)); + } + #[test] + fn contains_runtime_event_associated_type_bound_invalid_trait_bound() { + let supertrait = + syn::parse2::(quote::quote!(Config>>)) + .unwrap(); + assert!(!contains_runtime_event_associated_type_bound(&supertrait)); + } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index c9a150effccbe..f70f9a3d2313e 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -352,19 +352,27 @@ impl Def { } /// Check that usage of trait `Event` is consistent with the definition, i.e. it is declared - /// and trait defines type RuntimeEvent, or not declared and no trait associated type. + /// and trait defines type or type bound `RuntimeEvent`, or not declared and no trait associated + /// type. fn check_event_usage(&self) -> syn::Result<()> { - match (self.config.has_event_type, self.event.is_some()) { - (true, false) => { + match (self.config.has_event_type, self.config.has_event_bound, self.event.is_some()) { + (true, false, false) => { let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent`, \ but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ Note that type `RuntimeEvent` in trait is reserved to work alongside pallet event."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, - (false, true) => { + (false, true, false) => { + let msg = "Invalid usage of `RuntimeEvent`, `frame_system::Config` contains associated type bound `RuntimeEvent`, \ + but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ + Note that type associated type bound `RuntimeEvent` in trait is reserved to work alongside pallet event."; + Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) + }, + (false, false, true) => { let msg = "Invalid usage of RuntimeEvent, `Config` contains no associated type \ - `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). \ - An RuntimeEvent associated type must be declare on trait `Config`."; + `RuntimeEvent` or associated type bound `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). \ + A `RuntimeEvent` associated type must be declare on trait `Config` or a `RuntimeEvent` associated type bound must be \ + defined in the system supertrait."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, _ => Ok(()), From 214fdce776e5d78852feaae52224b3c740ca2a00 Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 17 Jan 2025 21:47:46 +0600 Subject: [PATCH 02/12] Add prdoc --- prdoc/pr_7229.prdoc | 32 +++++++++++++++++++ .../procedural/src/pallet/parse/config.rs | 10 +++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 prdoc/pr_7229.prdoc diff --git a/prdoc/pr_7229.prdoc b/prdoc/pr_7229.prdoc new file mode 100644 index 0000000000000..ccb61e81d5b00 --- /dev/null +++ b/prdoc/pr_7229.prdoc @@ -0,0 +1,32 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "FRAME: `RuntimeEvent` as associated type bound`" +doc: + - audience: Runtime Dev + description: | + Using stabilized feature of associated type bounds, we can reduce redundant types defined in the pallet's `Config` traits. This PR adds + support for `RuntimeEvent` as an associated type bound. + + With this change, we can do this: + + ```rs + #[pallet::config] + pub trait Config: frame_system::Config>> { + } + ``` + instead of this: + + ```rs + #[pallet::config] + pub trait Config: frame_system::Config { + /// Overarching event type. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + ``` + +crates: + - name: frame-support + bump: minor + - name: pallet-examples + bump: minor diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 5664b59b1128c..27386e3698c81 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -445,10 +445,12 @@ impl ConfigDef { .iter() .filter_map(|supertrait| syn::parse2::(supertrait.to_token_stream()).ok()) .fold((false, false), |(mut has_system, mut has_event_bound), supertrait| { - has_system = - has_system || has_expected_system_config(supertrait.clone(), frame_system); - has_event_bound = - has_event_bound || contains_runtime_event_associated_type_bound(&supertrait); + if has_expected_system_config(supertrait.clone(), frame_system) { + has_system = true; + // only check for `RuntimeEvent` bound if `frame_system::Config` is found. + has_event_bound = has_event_bound || + contains_runtime_event_associated_type_bound(&supertrait); + } (has_system, has_event_bound) }); From 668adefd09980ebe9b649fca8b9b76bedac25628 Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 17 Jan 2025 21:55:47 +0600 Subject: [PATCH 03/12] Only one way of declaring `RuntimeEvent` --- substrate/frame/support/procedural/src/pallet/parse/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index f70f9a3d2313e..464672a66841a 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -375,6 +375,11 @@ impl Def { defined in the system supertrait."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, + (true, true, _) => { + let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent` and associated type bound `RuntimeEvent`. \ + Only one of them should be used."; + Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) + }, _ => Ok(()), } } From 12d85f0d815151e2aadd8ba66f84001567123f01 Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 24 Jan 2025 18:25:58 +0600 Subject: [PATCH 04/12] Automatically append event type bound and add deprecation note --- prdoc/pr_7229.prdoc | 16 ++++-- substrate/frame/examples/basic/src/lib.rs | 4 +- .../frame/examples/default-config/src/lib.rs | 2 +- substrate/frame/examples/dev-mode/src/lib.rs | 5 +- .../frame/examples/frame-crate/src/lib.rs | 2 +- .../frame/examples/kitchensink/src/lib.rs | 2 +- .../frame/examples/offchain-worker/src/lib.rs | 4 +- substrate/frame/examples/split/src/lib.rs | 2 +- .../procedural/src/pallet/expand/config.rs | 50 +++++++++++++++++-- .../procedural/src/pallet/expand/event.rs | 2 +- .../procedural/src/pallet/parse/config.rs | 21 +++++--- .../procedural/src/pallet/parse/mod.rs | 7 --- 12 files changed, 80 insertions(+), 37 deletions(-) diff --git a/prdoc/pr_7229.prdoc b/prdoc/pr_7229.prdoc index ccb61e81d5b00..b6e2b35f5d035 100644 --- a/prdoc/pr_7229.prdoc +++ b/prdoc/pr_7229.prdoc @@ -1,18 +1,18 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: "FRAME: `RuntimeEvent` as associated type bound`" +title: "FRAME: Remove `RuntimeEvent` associated type from `Config` trait" doc: - audience: Runtime Dev description: | - Using stabilized feature of associated type bounds, we can reduce redundant types defined in the pallet's `Config` traits. This PR adds - support for `RuntimeEvent` as an associated type bound. + This PR removes the need for defining `RuntimeEvent` in the `Config` trait of a pallet. It uses associated type bound feature under the hood + to make sure that `Event` of the pallet is convertible to the `frame_system::RuntimeEvent` type. With this change, we can do this: ```rs #[pallet::config] - pub trait Config: frame_system::Config>> { + pub trait Config: frame_system::Config { } ``` instead of this: @@ -25,6 +25,14 @@ doc: } ``` + Or if developers want to explicitly define the `RuntimeEvent` type bound, they can still do so. + + ```rs + #[pallet::config] + pub trait Config: frame_system::Config>> { + } + ``` + crates: - name: frame-support bump: minor diff --git a/substrate/frame/examples/basic/src/lib.rs b/substrate/frame/examples/basic/src/lib.rs index 5288415ae5a9f..859ae2d0580e1 100644 --- a/substrate/frame/examples/basic/src/lib.rs +++ b/substrate/frame/examples/basic/src/lib.rs @@ -153,9 +153,7 @@ pub mod pallet { /// /// `frame_system::Config` should always be included. #[pallet::config] - pub trait Config: - pallet_balances::Config + frame_system::Config>> - { + pub trait Config: pallet_balances::Config + frame_system::Config { // Setting a constant config parameter from the runtime #[pallet::constant] type MagicNumber: Get; diff --git a/substrate/frame/examples/default-config/src/lib.rs b/substrate/frame/examples/default-config/src/lib.rs index 573c037ce090d..90e460cfca02c 100644 --- a/substrate/frame/examples/default-config/src/lib.rs +++ b/substrate/frame/examples/default-config/src/lib.rs @@ -43,7 +43,7 @@ pub mod pallet { /// /// It will be an identical, but won't have anything that is `#[pallet::no_default]`. #[pallet::config(with_default)] - pub trait Config: frame_system::Config>> { + pub trait Config: frame_system::Config { /// The overarching task type. #[pallet::no_default] type RuntimeTask: Task; diff --git a/substrate/frame/examples/dev-mode/src/lib.rs b/substrate/frame/examples/dev-mode/src/lib.rs index 02c4e6460fc10..1a88a2dd9a082 100644 --- a/substrate/frame/examples/dev-mode/src/lib.rs +++ b/substrate/frame/examples/dev-mode/src/lib.rs @@ -51,10 +51,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::config] - pub trait Config: - pallet_balances::Config + frame_system::Config>> - { - } + pub trait Config: pallet_balances::Config + frame_system::Config {} // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and // method. diff --git a/substrate/frame/examples/frame-crate/src/lib.rs b/substrate/frame/examples/frame-crate/src/lib.rs index bbafb5497910b..fcb90308b38f5 100644 --- a/substrate/frame/examples/frame-crate/src/lib.rs +++ b/substrate/frame/examples/frame-crate/src/lib.rs @@ -22,7 +22,7 @@ pub mod pallet { use super::*; #[pallet::config] - pub trait Config: frame_system::Config>> {} + pub trait Config: frame_system::Config {} #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/examples/kitchensink/src/lib.rs b/substrate/frame/examples/kitchensink/src/lib.rs index 70de254ffca08..8050c1065f298 100644 --- a/substrate/frame/examples/kitchensink/src/lib.rs +++ b/substrate/frame/examples/kitchensink/src/lib.rs @@ -68,7 +68,7 @@ pub mod pallet { /// * `#[pallet::disable_frame_system_supertrait_check]` would remove the need for /// `frame_system::Config` to exist, which you should almost never need. #[pallet::config] - pub trait Config: frame_system::Config>> { + pub trait Config: frame_system::Config { /// Type representing the weight of this pallet type WeightInfo: WeightInfo; diff --git a/substrate/frame/examples/offchain-worker/src/lib.rs b/substrate/frame/examples/offchain-worker/src/lib.rs index 71533aba445ed..97f444468ff33 100644 --- a/substrate/frame/examples/offchain-worker/src/lib.rs +++ b/substrate/frame/examples/offchain-worker/src/lib.rs @@ -125,9 +125,7 @@ pub mod pallet { /// This pallet's configuration trait #[pallet::config] pub trait Config: - CreateSignedTransaction> - + CreateInherent> - + frame_system::Config>> + CreateSignedTransaction> + CreateInherent> + frame_system::Config { /// The identifier type for an offchain worker. type AuthorityId: AppCrypto; diff --git a/substrate/frame/examples/split/src/lib.rs b/substrate/frame/examples/split/src/lib.rs index c1591de30fc74..87ad580f06a86 100644 --- a/substrate/frame/examples/split/src/lib.rs +++ b/substrate/frame/examples/split/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] - pub trait Config: frame_system::Config>> { + pub trait Config: frame_system::Config { /// Type representing the weight of this pallet type WeightInfo: WeightInfo; } diff --git a/substrate/frame/support/procedural/src/pallet/expand/config.rs b/substrate/frame/support/procedural/src/pallet/expand/config.rs index d39f276723600..976830720f83b 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/config.rs @@ -15,10 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::pallet::Def; +use crate::pallet::{parse::config::has_expected_system_config, Def}; use proc_macro2::TokenStream; -use quote::quote; -use syn::{parse_quote, Item}; +use quote::{quote, ToTokens}; +use syn::{parse_quote, Item, PathArguments, TypeParamBound}; /// /// * Generate default rust doc @@ -48,6 +48,39 @@ Consequently, a runtime that wants to include this pallet must implement this tr ), ); + // insert `frame_system::Config` supertrait with `RuntimeEvent: From>` if neither + // associated type nor type bound is defined. + if def.event.is_some() && !config.has_event_type && !config.has_event_bound { + // find the `frame_system::Config` supertrait + let frame_system = crate::generate_access_from_frame_or_crate("frame-system") + .expect("should have access to frame-system"); + + if let Some(TypeParamBound::Trait(trait_bound)) = + config_item.supertraits.iter_mut().find(|s| { + syn::parse2::(s.to_token_stream()) + .map_or(false, |b| has_expected_system_config(b, &frame_system)) + }) { + let event_bound: syn::GenericArgument = parse_quote!(RuntimeEvent: From>); + + if let Some(segment) = + trait_bound.path.segments.iter_mut().find(|s| s.ident == "Config") + { + match &mut segment.arguments { + // when `Config { + args.args.push(event_bound); + }, + // when `Config` + syn::PathArguments::None => { + segment.arguments = + PathArguments::AngleBracketed(parse_quote!(<#event_bound>)); + }, + _ => unreachable!("Checked by has_expected_system_config"), + } + } + } + } + // we only emit `DefaultConfig` if there are trait items, so an empty `DefaultConfig` is // impossible consequently. match &config.default_sub_trait { @@ -143,3 +176,14 @@ pub fn expand_config_metadata(def: &Def) -> proc_macro2::TokenStream { } ) } + +#[test] +fn test_parse_quote() { + // pub trait Config: pallet_balances::Config + frame_system::Config>>{ + + // the `RuntimeEvent: From>` part + let event: syn::AngleBracketedGenericArguments = parse_quote!(RuntimeEvent: From>); + let event_bound = syn::parse2::(event.to_token_stream()).unwrap(); + println!("{:?}", event_bound); +} diff --git a/substrate/frame/support/procedural/src/pallet/expand/event.rs b/substrate/frame/support/procedural/src/pallet/expand/event.rs index 3dbbfb24e3852..7384c65348c67 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/event.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/event.rs @@ -145,7 +145,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { // `RuntimeEvent` can be defined either as associated type in `Config` or as a type bound in // system supertrait. - let runtime_event_path = if def.config.has_event_bound { + let runtime_event_path = if def.config.has_event_bound || !def.config.has_event_type { quote::quote! { ::RuntimeEvent } } else { quote::quote! { ::RuntimeEvent } diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 27386e3698c81..651c28ee9d39d 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -300,7 +300,7 @@ fn check_event_type( /// Check that the path to `frame_system::Config` is valid, this is that the path is just /// `frame_system::Config` or when using the `frame` crate it is /// `polkadot_sdk_frame::xyz::frame_system::Config`. -fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool { +pub(crate) fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool { // Check if `frame_system` is actually 'frame_system'. if path.segments.iter().all(|s| s.ident != "frame_system") { return false; @@ -374,7 +374,7 @@ fn contains_type_info_bound(ty: &TraitItemType) -> bool { /// NOTE: Does not check if the supertrait path is valid system config path. /// /// ```rs -/// pub trait Config: frame_system::Config>> { +/// pub trait Config: frame_system::Config { /// ``` fn contains_runtime_event_associated_type_bound(supertrait: &syn::Path) -> bool { if let Some(args) = supertrait.segments.iter().find(|s| s.ident == "Config") { @@ -475,6 +475,15 @@ impl ConfigDef { let mut already_no_default_bounds = false; let mut already_collected_associated_type = None; + // add deprecation notice for `RuntimeEvent`, iff pallet is not `frame_system` + if is_event && has_frame_system_supertrait { + if let syn::TraitItem::Type(type_event) = trait_item { + type_event + .attrs + .push(syn::parse_quote!(#[deprecated(note = "`RuntimeEvent` associated type is deprecated, there is no need to define it in the pallet config.")])); + } + } + while let Ok(Some(pallet_attr)) = helper::take_first_item_pallet_attr::(trait_item) { @@ -766,9 +775,7 @@ mod tests { #[test] fn contains_runtime_event_associated_type_bound_works() { - let supertrait = syn::parse2::(quote::quote!( - Config>> - )); + let supertrait = syn::parse2::(quote::quote!(Config)); assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); } #[test] @@ -781,9 +788,7 @@ mod tests { #[test] fn contains_runtime_event_associated_type_bound_works_full_path() { - let supertrait = syn::parse2::(quote::quote!( - frame_system::Config>> - )); + let supertrait = syn::parse2::(quote::quote!(frame_system::Config)); assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); } diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index 464672a66841a..c851828435efd 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -368,13 +368,6 @@ impl Def { Note that type associated type bound `RuntimeEvent` in trait is reserved to work alongside pallet event."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, - (false, false, true) => { - let msg = "Invalid usage of RuntimeEvent, `Config` contains no associated type \ - `RuntimeEvent` or associated type bound `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). \ - A `RuntimeEvent` associated type must be declare on trait `Config` or a `RuntimeEvent` associated type bound must be \ - defined in the system supertrait."; - Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) - }, (true, true, _) => { let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent` and associated type bound `RuntimeEvent`. \ Only one of them should be used."; From 5344a60a4361687b5f2825a0154eaddd54e81f34 Mon Sep 17 00:00:00 2001 From: dastansam Date: Sat, 25 Jan 2025 14:13:16 +0600 Subject: [PATCH 05/12] Make warning compile time --- .../frame/examples/default-config/src/lib.rs | 5 +++-- .../procedural/src/pallet/expand/config.rs | 10 +++++++++- .../procedural/src/pallet/parse/config.rs | 19 ++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/substrate/frame/examples/default-config/src/lib.rs b/substrate/frame/examples/default-config/src/lib.rs index 90e460cfca02c..61bd9fcd83189 100644 --- a/substrate/frame/examples/default-config/src/lib.rs +++ b/substrate/frame/examples/default-config/src/lib.rs @@ -44,8 +44,9 @@ pub mod pallet { /// It will be an identical, but won't have anything that is `#[pallet::no_default]`. #[pallet::config(with_default)] pub trait Config: frame_system::Config { - /// The overarching task type. - #[pallet::no_default] + /// The overarching task type. This is coming from the runtime, and cannot have a default. + /// In general, `Runtime*`-oriented types cannot have a sensible default. + #[pallet::no_default] // optional. `RuntimeEvent` is automatically excluded as well. type RuntimeTask: Task; /// An input parameter to this pallet. This value can have a default, because it is not diff --git a/substrate/frame/support/procedural/src/pallet/expand/config.rs b/substrate/frame/support/procedural/src/pallet/expand/config.rs index 976830720f83b..77769f0147fc7 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/config.rs @@ -24,6 +24,7 @@ use syn::{parse_quote, Item, PathArguments, TypeParamBound}; /// * Generate default rust doc pub fn expand_config(def: &mut Def) -> TokenStream { let config = &def.config; + let warnings = &config.warnings; let config_item = { let item = &mut def.item.content.as_mut().expect("Checked by def parser").1[config.index]; if let Item::Trait(item) = item { @@ -111,6 +112,9 @@ Consequently, a runtime that wants to include this pallet must implement this tr }; quote!( + #( + #warnings + )* /// Based on [`Config`]. Auto-generated by /// [`#[pallet::config(with_default)]`](`frame_support::pallet_macros::config`). /// Can be used in tandem with @@ -125,7 +129,11 @@ Consequently, a runtime that wants to include this pallet must implement this tr } ) }, - _ => Default::default(), + _ => quote!( + #( + #warnings + )* + ), } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 651c28ee9d39d..4e22bfe9013b6 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -17,6 +17,7 @@ use super::helper; use frame_support_procedural_tools::{get_cfg_attributes, get_doc_literals, is_using_frame_crate}; +use proc_macro_warning::Warning; use quote::ToTokens; use syn::{spanned::Spanned, token, Token, TraitItemType}; @@ -73,6 +74,8 @@ pub struct ConfigDef { /// Vec will be empty if `#[pallet::config(with_default)]` is not specified or if there are /// no trait items. pub default_sub_trait: Option, + /// Compile time warnings. Mainly for deprecated items. + pub warnings: Vec, } /// Input definition for an associated type in pallet config. @@ -458,6 +461,7 @@ impl ConfigDef { let mut has_event_type = false; let mut consts_metadata = vec![]; let mut associated_types_metadata = vec![]; + let mut warnings = vec![]; let mut default_sub_trait = if enable_default { Some(DefaultTrait { items: Default::default(), @@ -478,9 +482,17 @@ impl ConfigDef { // add deprecation notice for `RuntimeEvent`, iff pallet is not `frame_system` if is_event && has_frame_system_supertrait { if let syn::TraitItem::Type(type_event) = trait_item { - type_event - .attrs - .push(syn::parse_quote!(#[deprecated(note = "`RuntimeEvent` associated type is deprecated, there is no need to define it in the pallet config.")])); + type_event.attrs.push(syn::parse_quote!(#[allow(deprecated)])); + + let warning = Warning::new_deprecated("RuntimeEvent") + .old("have `RuntimeEvent` associated type in the pallet config") + .new("remove it or explicitly define it as an associated type bound in the system supertrait: \n + pub trait Config: frame_system::Config>> { } \n") + .help_link("https://github.com/paritytech/polkadot-sdk/pull/7229") + .span(type_event.span()) + .build_or_panic(); + + warnings.push(warning); } } @@ -645,6 +657,7 @@ impl ConfigDef { has_event_bound, where_clause, default_sub_trait, + warnings, }) } } From d71f8789a2c8d9d7eb3a3826700dc940acdbd5ac Mon Sep 17 00:00:00 2001 From: dastansam Date: Sat, 25 Jan 2025 15:04:16 +0600 Subject: [PATCH 06/12] Add is_frame_system pallet config attribute option --- .../procedural/examples/proc_main/main.rs | 2 +- .../procedural/src/pallet/parse/config.rs | 34 +++++++------------ .../procedural/src/pallet/parse/mod.rs | 27 +++++++++++++-- substrate/frame/support/src/tests/mod.rs | 2 +- substrate/frame/support/test/src/lib.rs | 2 +- substrate/frame/system/src/lib.rs | 2 +- 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/substrate/frame/support/procedural/examples/proc_main/main.rs b/substrate/frame/support/procedural/examples/proc_main/main.rs index 4bdfc76dd92f0..f12259edd4e42 100644 --- a/substrate/frame/support/procedural/examples/proc_main/main.rs +++ b/substrate/frame/support/procedural/examples/proc_main/main.rs @@ -65,7 +65,7 @@ pub mod frame_system { #[pallet::pallet] pub struct Pallet(_); - #[pallet::config(with_default)] + #[pallet::config(with_default, is_frame_system)] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { #[pallet::no_default] diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 4e22bfe9013b6..2e3d6e07793de 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -410,6 +410,7 @@ impl ConfigDef { item: &mut syn::Item, enable_default: bool, disable_associated_metadata: bool, + is_frame_system: bool, ) -> syn::Result { let syn::Item::Trait(item) = item else { let msg = "Invalid pallet::config, expected trait definition"; @@ -443,30 +444,21 @@ impl ConfigDef { false }; - let (has_frame_system_supertrait, has_event_bound) = item - .supertraits - .iter() - .filter_map(|supertrait| syn::parse2::(supertrait.to_token_stream()).ok()) - .fold((false, false), |(mut has_system, mut has_event_bound), supertrait| { - if has_expected_system_config(supertrait.clone(), frame_system) { - has_system = true; - // only check for `RuntimeEvent` bound if `frame_system::Config` is found. - has_event_bound = has_event_bound || - contains_runtime_event_associated_type_bound(&supertrait); - } - - (has_system, has_event_bound) - }); + let has_event_bound = if is_frame_system { + false + } else { + item.supertraits.iter().any(|supertrait| { + syn::parse2::(supertrait.to_token_stream()) + .map_or(false, |b| contains_runtime_event_associated_type_bound(&b)) + }) + }; let mut has_event_type = false; let mut consts_metadata = vec![]; let mut associated_types_metadata = vec![]; let mut warnings = vec![]; let mut default_sub_trait = if enable_default { - Some(DefaultTrait { - items: Default::default(), - has_system: has_frame_system_supertrait, - }) + Some(DefaultTrait { items: Default::default(), has_system: !is_frame_system }) } else { None }; @@ -480,14 +472,14 @@ impl ConfigDef { let mut already_collected_associated_type = None; // add deprecation notice for `RuntimeEvent`, iff pallet is not `frame_system` - if is_event && has_frame_system_supertrait { + if is_event && !is_frame_system { if let syn::TraitItem::Type(type_event) = trait_item { type_event.attrs.push(syn::parse_quote!(#[allow(deprecated)])); let warning = Warning::new_deprecated("RuntimeEvent") .old("have `RuntimeEvent` associated type in the pallet config") .new("remove it or explicitly define it as an associated type bound in the system supertrait: \n - pub trait Config: frame_system::Config>> { } \n") + pub trait Config: frame_system::Config>> { }") .help_link("https://github.com/paritytech/polkadot-sdk/pull/7229") .span(type_event.span()) .build_or_panic(); @@ -623,7 +615,7 @@ impl ConfigDef { helper::take_first_item_pallet_attr(&mut item.attrs)?; let disable_system_supertrait_check = attr.is_some(); - if !has_frame_system_supertrait && !disable_system_supertrait_check { + if is_frame_system && !disable_system_supertrait_check { let found = if item.supertraits.is_empty() { "none".to_string() } else { diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index c851828435efd..d247f660aa453 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -108,13 +108,14 @@ impl Def { let pallet_attr: Option = helper::take_first_item_pallet_attr(item)?; match pallet_attr { - Some(PalletAttr::Config{ with_default, without_automatic_metadata, ..}) if config.is_none() => + Some(PalletAttr::Config{ with_default, is_frame_system, without_automatic_metadata, ..}) if config.is_none() => config = Some(config::ConfigDef::try_from( &frame_system, index, item, with_default, without_automatic_metadata, + is_frame_system, )?), Some(PalletAttr::Pallet(span)) if pallet_struct.is_none() => { let p = pallet_struct::PalletStructDef::try_from(span, index, item)?; @@ -558,6 +559,7 @@ mod keyword { syn::custom_keyword!(config); syn::custom_keyword!(with_default); syn::custom_keyword!(without_automatic_metadata); + syn::custom_keyword!(is_frame_system); syn::custom_keyword!(hooks); syn::custom_keyword!(inherent); syn::custom_keyword!(error); @@ -578,6 +580,8 @@ enum ConfigValue { WithDefault(keyword::with_default), /// `#[pallet::config(without_automatic_metadata)]` WithoutAutomaticMetadata(keyword::without_automatic_metadata), + /// `#[pallet::config(is_frame_system)]` + IsFrameSystem(keyword::is_frame_system), } impl syn::parse::Parse for ConfigValue { @@ -588,6 +592,8 @@ impl syn::parse::Parse for ConfigValue { input.parse().map(ConfigValue::WithDefault) } else if lookahead.peek(keyword::without_automatic_metadata) { input.parse().map(ConfigValue::WithoutAutomaticMetadata) + } else if lookahead.peek(keyword::is_frame_system) { + input.parse().map(ConfigValue::IsFrameSystem) } else { Err(lookahead.error()) } @@ -601,6 +607,7 @@ enum PalletAttr { span: proc_macro2::Span, with_default: bool, without_automatic_metadata: bool, + is_frame_system: bool, }, Pallet(proc_macro2::Span), Hooks(proc_macro2::Span), @@ -710,6 +717,7 @@ impl syn::parse::Parse for PalletAttr { let mut with_default = false; let mut without_automatic_metadata = false; + let mut is_frame_system = false; for config in config_values { match config { ConfigValue::WithDefault(_) => { @@ -730,15 +738,30 @@ impl syn::parse::Parse for PalletAttr { } without_automatic_metadata = true; }, + ConfigValue::IsFrameSystem(_) => { + if is_frame_system { + return Err(syn::Error::new( + span, + "Invalid duplicated attribute for `#[pallet::config]`. Please remove duplicates: is_frame_system.", + )); + } + is_frame_system = true; + }, } } - Ok(PalletAttr::Config { span, with_default, without_automatic_metadata }) + Ok(PalletAttr::Config { + span, + with_default, + without_automatic_metadata, + is_frame_system, + }) } else { Ok(PalletAttr::Config { span, with_default: false, without_automatic_metadata: false, + is_frame_system: false, }) } } else if lookahead.peek(keyword::pallet) { diff --git a/substrate/frame/support/src/tests/mod.rs b/substrate/frame/support/src/tests/mod.rs index 7c90a12d4167e..84ecd019fc482 100644 --- a/substrate/frame/support/src/tests/mod.rs +++ b/substrate/frame/support/src/tests/mod.rs @@ -58,7 +58,7 @@ pub mod frame_system { #[pallet::pallet] pub struct Pallet(_); - #[pallet::config(with_default)] + #[pallet::config(with_default, is_frame_system)] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { #[pallet::no_default] diff --git a/substrate/frame/support/test/src/lib.rs b/substrate/frame/support/test/src/lib.rs index b080740b0a4b1..fccc101db0c45 100644 --- a/substrate/frame/support/test/src/lib.rs +++ b/substrate/frame/support/test/src/lib.rs @@ -36,7 +36,7 @@ pub mod pallet { pub struct Pallet(_); /// The configuration trait. - #[pallet::config] + #[pallet::config(is_frame_system)] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static + Eq + Clone { /// The block number type. diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 894e1898ed155..9b073a70fb433 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -465,7 +465,7 @@ pub mod pallet { } /// System configuration trait. Implemented by runtime. - #[pallet::config(with_default)] + #[pallet::config(with_default, is_frame_system)] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static + Eq + Clone { /// The aggregated event type of the runtime. From 992aedee032f08a487b713c3323fad15beadc54d Mon Sep 17 00:00:00 2001 From: dastansam Date: Sat, 15 Feb 2025 18:15:14 +0600 Subject: [PATCH 07/12] Deprecate `RuntimeEvent` --- .../pallets/ethereum-client/src/lib.rs | 1 + .../pallets/inbound-queue/src/lib.rs | 1 + .../pallets/outbound-queue/src/lib.rs | 1 + bridges/snowbridge/pallets/system/src/lib.rs | 1 + cumulus/pallets/collator-selection/src/lib.rs | 1 + cumulus/pallets/dmp-queue/src/lib.rs | 1 + cumulus/pallets/parachain-system/src/lib.rs | 1 + cumulus/pallets/xcm/src/lib.rs | 1 + cumulus/pallets/xcmp-queue/src/lib.rs | 1 + cumulus/parachains/pallets/ping/src/lib.rs | 1 + .../packages/guides/first-pallet/src/lib.rs | 1 + docs/sdk/src/guides/your_first_pallet/mod.rs | 1 + .../runtime/common/src/assigned_slots/mod.rs | 1 + polkadot/runtime/common/src/auctions/mod.rs | 1 + polkadot/runtime/common/src/claims/mod.rs | 1 + polkadot/runtime/common/src/crowdloan/mod.rs | 1 + .../runtime/common/src/identity_migrator.rs | 1 + .../runtime/common/src/paras_registrar/mod.rs | 1 + polkadot/runtime/common/src/purchase/mod.rs | 1 + polkadot/runtime/common/src/slots/mod.rs | 1 + .../runtime/parachains/src/coretime/mod.rs | 1 + polkadot/runtime/parachains/src/disputes.rs | 1 + polkadot/runtime/parachains/src/hrmp.rs | 1 + .../runtime/parachains/src/inclusion/mod.rs | 1 + .../runtime/parachains/src/on_demand/mod.rs | 1 + .../runtime/rococo/src/validator_manager.rs | 1 + polkadot/xcm/pallet-xcm/src/lib.rs | 1 + .../xcm/xcm-simulator/fuzzer/src/parachain.rs | 1 + .../xcm-simulator/src/mock_message_queue.rs | 1 + prdoc/pr_7229.prdoc | 4 +++- .../frame/asset-conversion/ops/src/lib.rs | 1 + substrate/frame/asset-conversion/src/lib.rs | 1 + substrate/frame/asset-rate/src/lib.rs | 1 + substrate/frame/atomic-swap/src/lib.rs | 1 + substrate/frame/balances/src/lib.rs | 1 + substrate/frame/benchmarking/pov/src/lib.rs | 1 + substrate/frame/broker/src/lib.rs | 1 + substrate/frame/child-bounties/src/lib.rs | 1 + substrate/frame/collective/src/tests.rs | 1 + .../mock-network/src/mocks/msg_queue.rs | 1 + substrate/frame/contracts/src/lib.rs | 1 + substrate/frame/delegated-staking/src/lib.rs | 1 + substrate/frame/democracy/src/lib.rs | 1 + .../election-provider-multi-phase/src/lib.rs | 1 + substrate/frame/elections-phragmen/src/lib.rs | 1 + substrate/frame/fast-unstake/src/lib.rs | 1 + substrate/frame/identity/src/lib.rs | 1 + substrate/frame/im-online/src/lib.rs | 1 + substrate/frame/indices/src/lib.rs | 1 + substrate/frame/lottery/src/lib.rs | 1 + substrate/frame/message-queue/src/lib.rs | 1 + substrate/frame/migrations/src/lib.rs | 1 + substrate/frame/multisig/src/lib.rs | 1 + .../frame/nft-fractionalization/src/lib.rs | 1 + substrate/frame/nis/src/lib.rs | 1 + substrate/frame/node-authorization/src/lib.rs | 1 + substrate/frame/nomination-pools/src/lib.rs | 1 + substrate/frame/parameters/src/lib.rs | 1 + substrate/frame/preimage/src/lib.rs | 1 + substrate/frame/proxy/src/lib.rs | 1 + substrate/frame/recovery/src/lib.rs | 1 + substrate/frame/remark/src/lib.rs | 1 + .../mock-network/src/mocks/msg_queue.rs | 1 + substrate/frame/revive/src/lib.rs | 1 + substrate/frame/root-offences/src/lib.rs | 1 + substrate/frame/root-testing/src/lib.rs | 1 + substrate/frame/safe-mode/src/lib.rs | 1 + substrate/frame/scheduler/src/lib.rs | 1 + substrate/frame/scheduler/src/mock.rs | 1 + substrate/frame/staking/src/pallet/mod.rs | 1 + .../frame/state-trie-migration/src/lib.rs | 1 + substrate/frame/statement/src/lib.rs | 1 + substrate/frame/sudo/src/lib.rs | 1 + substrate/frame/sudo/src/mock.rs | 1 + .../procedural/src/pallet/expand/config.rs | 11 ++-------- .../procedural/src/pallet/expand/mod.rs | 5 +++++ .../procedural/src/pallet/parse/config.rs | 13 ++++++----- substrate/frame/support/src/lib.rs | 22 +++++++++++-------- .../support/test/tests/enum_deprecation.rs | 1 + substrate/frame/support/test/tests/origin.rs | 2 ++ substrate/frame/support/test/tests/pallet.rs | 1 + .../tests/pallet_associated_types_metadata.rs | 5 +++++ .../pallet_ui/config_metadata_on_events.rs | 1 + substrate/frame/support/test/tests/runtime.rs | 3 +++ .../test/tests/runtime_legacy_ordering.rs | 4 ++++ .../test/tests/split_ui/pass/split_valid.rs | 4 ++-- .../pass/split_valid_disambiguation.rs | 6 ++--- .../asset-conversion-tx-payment/src/lib.rs | 1 + .../asset-tx-payment/src/lib.rs | 1 + .../skip-feeless-payment/src/lib.rs | 1 + .../frame/transaction-payment/src/lib.rs | 1 + .../frame/transaction-storage/src/lib.rs | 1 + substrate/frame/tx-pause/src/lib.rs | 1 + substrate/frame/utility/src/tests.rs | 1 + substrate/frame/vesting/src/lib.rs | 1 + substrate/frame/whitelist/src/lib.rs | 1 + .../parachain/pallets/template/src/lib.rs | 1 + .../solochain/pallets/template/src/lib.rs | 1 + 98 files changed, 137 insertions(+), 29 deletions(-) diff --git a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs index 311b54b97dee9..4e7c2c0b43b04 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs @@ -82,6 +82,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; #[pallet::constant] type ForkVersions: Get; diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 423b92b9fae04..17b4bbf6139a1 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -96,6 +96,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The verifier for inbound messages from Ethereum diff --git a/bridges/snowbridge/pallets/outbound-queue/src/lib.rs b/bridges/snowbridge/pallets/outbound-queue/src/lib.rs index 9b9dbe854a5ee..9a8890cd9389f 100644 --- a/bridges/snowbridge/pallets/outbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/outbound-queue/src/lib.rs @@ -140,6 +140,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type Hashing: Hash; diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index eb3da095fe855..e45c2b626151d 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -147,6 +147,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Send messages to Ethereum diff --git a/cumulus/pallets/collator-selection/src/lib.rs b/cumulus/pallets/collator-selection/src/lib.rs index 9d7e62af3c68f..a4d38cbd93f61 100644 --- a/cumulus/pallets/collator-selection/src/lib.rs +++ b/cumulus/pallets/collator-selection/src/lib.rs @@ -141,6 +141,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency mechanism. diff --git a/cumulus/pallets/dmp-queue/src/lib.rs b/cumulus/pallets/dmp-queue/src/lib.rs index cedca6f3fb97f..ca042e32dadb2 100644 --- a/cumulus/pallets/dmp-queue/src/lib.rs +++ b/cumulus/pallets/dmp-queue/src/lib.rs @@ -59,6 +59,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type of the runtime. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The sink for all DMP messages that the lazy migration will use. diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index 0fa759357f653..264eb21e160fe 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -247,6 +247,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config> { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Something which can be notified when the validation data is set. diff --git a/cumulus/pallets/xcm/src/lib.rs b/cumulus/pallets/xcm/src/lib.rs index e31df8471c266..082d0ddb57a85 100644 --- a/cumulus/pallets/xcm/src/lib.rs +++ b/cumulus/pallets/xcm/src/lib.rs @@ -39,6 +39,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type XcmExecutor: ExecuteXcm; diff --git a/cumulus/pallets/xcmp-queue/src/lib.rs b/cumulus/pallets/xcmp-queue/src/lib.rs index 91f71558b54a2..2c0d6ab7d4297 100644 --- a/cumulus/pallets/xcmp-queue/src/lib.rs +++ b/cumulus/pallets/xcmp-queue/src/lib.rs @@ -112,6 +112,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Information on the available XCMP channels. diff --git a/cumulus/parachains/pallets/ping/src/lib.rs b/cumulus/parachains/pallets/ping/src/lib.rs index b6423a81db3c9..13a98344bbe05 100644 --- a/cumulus/parachains/pallets/ping/src/lib.rs +++ b/cumulus/parachains/pallets/ping/src/lib.rs @@ -48,6 +48,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeOrigin: From<::RuntimeOrigin> diff --git a/docs/sdk/packages/guides/first-pallet/src/lib.rs b/docs/sdk/packages/guides/first-pallet/src/lib.rs index 168b7ca44aba2..8e4b45c09000c 100644 --- a/docs/sdk/packages/guides/first-pallet/src/lib.rs +++ b/docs/sdk/packages/guides/first-pallet/src/lib.rs @@ -365,6 +365,7 @@ pub mod pallet_v2 { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type of the runtime. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/docs/sdk/src/guides/your_first_pallet/mod.rs b/docs/sdk/src/guides/your_first_pallet/mod.rs index aef8981b4d4a3..bff2e4bfa56f2 100644 --- a/docs/sdk/src/guides/your_first_pallet/mod.rs +++ b/docs/sdk/src/guides/your_first_pallet/mod.rs @@ -673,6 +673,7 @@ pub mod pallet_v2 { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type of the runtime. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index 65942c127b1cc..a92d0f1c89e7e 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -118,6 +118,7 @@ pub mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: configuration::Config + paras::Config + slots::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Origin for assigning slots. diff --git a/polkadot/runtime/common/src/auctions/mod.rs b/polkadot/runtime/common/src/auctions/mod.rs index 84d8a3846d40e..9cf9ec2c06d0e 100644 --- a/polkadot/runtime/common/src/auctions/mod.rs +++ b/polkadot/runtime/common/src/auctions/mod.rs @@ -90,6 +90,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The type representing the leasing system. diff --git a/polkadot/runtime/common/src/claims/mod.rs b/polkadot/runtime/common/src/claims/mod.rs index f48e40ee18878..d2f0b439c39da 100644 --- a/polkadot/runtime/common/src/claims/mod.rs +++ b/polkadot/runtime/common/src/claims/mod.rs @@ -191,6 +191,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type VestingSchedule: VestingSchedule>; #[pallet::constant] diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 8cf288197e3dd..213ca0b8f3fb0 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -186,6 +186,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// `PalletId` for the crowdloan pallet. An appropriate value could be diff --git a/polkadot/runtime/common/src/identity_migrator.rs b/polkadot/runtime/common/src/identity_migrator.rs index e3835b692526e..5bd835b29897d 100644 --- a/polkadot/runtime/common/src/identity_migrator.rs +++ b/polkadot/runtime/common/src/identity_migrator.rs @@ -78,6 +78,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_identity::Config { /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The origin that can reap identities. Expected to be `EnsureSigned` on the diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index aed0729c9d517..124f8426f0793 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -121,6 +121,7 @@ pub mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: configuration::Config + paras::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin type must support the `parachains` origin. We require that we can diff --git a/polkadot/runtime/common/src/purchase/mod.rs b/polkadot/runtime/common/src/purchase/mod.rs index 71dc5b5796706..516ac307f86e8 100644 --- a/polkadot/runtime/common/src/purchase/mod.rs +++ b/polkadot/runtime/common/src/purchase/mod.rs @@ -98,6 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Balances Pallet diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index 333f14c6608ac..67193466d8fa7 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -74,6 +74,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency type used for bidding. diff --git a/polkadot/runtime/parachains/src/coretime/mod.rs b/polkadot/runtime/parachains/src/coretime/mod.rs index 5656e92b90be0..83bf2dae25106 100644 --- a/polkadot/runtime/parachains/src/coretime/mod.rs +++ b/polkadot/runtime/parachains/src/coretime/mod.rs @@ -119,6 +119,7 @@ pub mod pallet { pub trait Config: frame_system::Config + assigner_coretime::Config + on_demand::Config { type RuntimeOrigin: From<::RuntimeOrigin> + Into::RuntimeOrigin>>; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The runtime's definition of a Currency. type Currency: Currency; diff --git a/polkadot/runtime/parachains/src/disputes.rs b/polkadot/runtime/parachains/src/disputes.rs index d5a3f31e5943f..a067d518a4a26 100644 --- a/polkadot/runtime/parachains/src/disputes.rs +++ b/polkadot/runtime/parachains/src/disputes.rs @@ -372,6 +372,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + configuration::Config + session_info::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RewardValidators: RewardValidators; type SlashingHandler: SlashingHandler>; diff --git a/polkadot/runtime/parachains/src/hrmp.rs b/polkadot/runtime/parachains/src/hrmp.rs index 220543f00ec33..35992652b3509 100644 --- a/polkadot/runtime/parachains/src/hrmp.rs +++ b/polkadot/runtime/parachains/src/hrmp.rs @@ -259,6 +259,7 @@ pub mod pallet { frame_system::Config + configuration::Config + paras::Config + dmp::Config { /// The outer event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeOrigin: From diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 8ad9711a0f388..45f13e7f06aa5 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -266,6 +266,7 @@ pub mod pallet { + configuration::Config + scheduler::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type DisputesHandler: disputes::DisputesHandler>; type RewardValidators: RewardValidators; diff --git a/polkadot/runtime/parachains/src/on_demand/mod.rs b/polkadot/runtime/parachains/src/on_demand/mod.rs index 66400eb00fd9d..20291cd68f12e 100644 --- a/polkadot/runtime/parachains/src/on_demand/mod.rs +++ b/polkadot/runtime/parachains/src/on_demand/mod.rs @@ -103,6 +103,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + configuration::Config + paras::Config { /// The runtime's definition of an event. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The runtime's definition of a Currency. diff --git a/polkadot/runtime/rococo/src/validator_manager.rs b/polkadot/runtime/rococo/src/validator_manager.rs index ecfbff4fa0688..7a3a99078ff77 100644 --- a/polkadot/runtime/rococo/src/validator_manager.rs +++ b/polkadot/runtime/rococo/src/validator_manager.rs @@ -37,6 +37,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_session::Config { /// The overreaching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Privileged origin that can add or remove validators. diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6360298b21c36..50c8cb3ac773c 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -216,6 +216,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A lockable currency. diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs index fc650ae55a785..a01cba7d3a610 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -156,6 +156,7 @@ pub mod mock_msg_queue { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type XcmExecutor: ExecuteXcm; } diff --git a/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs b/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs index bf7b0e15967c0..09d8c56871055 100644 --- a/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs +++ b/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs @@ -35,6 +35,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type XcmExecutor: ExecuteXcm; } diff --git a/prdoc/pr_7229.prdoc b/prdoc/pr_7229.prdoc index b6e2b35f5d035..940c3e0644b46 100644 --- a/prdoc/pr_7229.prdoc +++ b/prdoc/pr_7229.prdoc @@ -21,7 +21,9 @@ doc: #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + #[allow(deprecated)] +#[allow(deprecated)] +type RuntimeEvent: From> + IsType<::RuntimeEvent>; } ``` diff --git a/substrate/frame/asset-conversion/ops/src/lib.rs b/substrate/frame/asset-conversion/ops/src/lib.rs index 58c15b47a3eb3..1a451f8283768 100644 --- a/substrate/frame/asset-conversion/ops/src/lib.rs +++ b/substrate/frame/asset-conversion/ops/src/lib.rs @@ -73,6 +73,7 @@ pub mod pallet { > + frame_system::Config { /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type previously used to derive the account ID for a pool. Indicates that the pool's diff --git a/substrate/frame/asset-conversion/src/lib.rs b/substrate/frame/asset-conversion/src/lib.rs index d6671a45be559..5e2879ccb7889 100644 --- a/substrate/frame/asset-conversion/src/lib.rs +++ b/substrate/frame/asset-conversion/src/lib.rs @@ -113,6 +113,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The type in which the assets for swapping are measured. diff --git a/substrate/frame/asset-rate/src/lib.rs b/substrate/frame/asset-rate/src/lib.rs index cfb013a73f5e8..e3344c015008b 100644 --- a/substrate/frame/asset-rate/src/lib.rs +++ b/substrate/frame/asset-rate/src/lib.rs @@ -106,6 +106,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The origin permissioned to create a conversion rate for an asset. diff --git a/substrate/frame/atomic-swap/src/lib.rs b/substrate/frame/atomic-swap/src/lib.rs index 9521f20fe0092..75f5141fd4c3a 100644 --- a/substrate/frame/atomic-swap/src/lib.rs +++ b/substrate/frame/atomic-swap/src/lib.rs @@ -161,6 +161,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Swap action. type SwapAction: SwapAction + Parameter + MaxEncodedLen; diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 9d74014521010..9d48fd7345153 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -242,6 +242,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/benchmarking/pov/src/lib.rs b/substrate/frame/benchmarking/pov/src/lib.rs index 4cdbaec2305c1..10e93bd65e548 100644 --- a/substrate/frame/benchmarking/pov/src/lib.rs +++ b/substrate/frame/benchmarking/pov/src/lib.rs @@ -38,6 +38,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/broker/src/lib.rs b/substrate/frame/broker/src/lib.rs index 01368fd6404da..2de3456ccdc17 100644 --- a/substrate/frame/broker/src/lib.rs +++ b/substrate/frame/broker/src/lib.rs @@ -75,6 +75,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for all calls of this pallet. diff --git a/substrate/frame/child-bounties/src/lib.rs b/substrate/frame/child-bounties/src/lib.rs index 9fca26510989a..6593c159d5902 100644 --- a/substrate/frame/child-bounties/src/lib.rs +++ b/substrate/frame/child-bounties/src/lib.rs @@ -162,6 +162,7 @@ pub mod pallet { type ChildBountyValueMinimum: Get>; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/collective/src/tests.rs b/substrate/frame/collective/src/tests.rs index c4ed17821ae89..b14f507bc2061 100644 --- a/substrate/frame/collective/src/tests.rs +++ b/substrate/frame/collective/src/tests.rs @@ -62,6 +62,7 @@ mod mock_democracy { #[pallet::config] pub trait Config: frame_system::Config + Sized { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type ExternalMajorityOrigin: EnsureOrigin; diff --git a/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs b/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs index 88ab8135ea129..063f0bfaed669 100644 --- a/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs +++ b/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs @@ -34,6 +34,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type XcmExecutor: ExecuteXcm; } diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 7bb5b46cf527f..d9bb6225d4fff 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -276,6 +276,7 @@ pub mod pallet { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/substrate/frame/delegated-staking/src/lib.rs b/substrate/frame/delegated-staking/src/lib.rs index 1d181eb29cab7..4c1f867a6d4e0 100644 --- a/substrate/frame/delegated-staking/src/lib.rs +++ b/substrate/frame/delegated-staking/src/lib.rs @@ -190,6 +190,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Injected identifier for the pallet. diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index 2c662fbad26a5..f70ec6fba100d 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -222,6 +222,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { type WeightInfo: WeightInfo; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Scheduler. diff --git a/substrate/frame/election-provider-multi-phase/src/lib.rs b/substrate/frame/election-provider-multi-phase/src/lib.rs index 06cb2963d762d..557412ffb538b 100644 --- a/substrate/frame/election-provider-multi-phase/src/lib.rs +++ b/substrate/frame/election-provider-multi-phase/src/lib.rs @@ -577,6 +577,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + CreateInherent> { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index fa1c48ee65eda..5a1d90165af31 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -201,6 +201,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the elections-phragmen pallet's lock diff --git a/substrate/frame/fast-unstake/src/lib.rs b/substrate/frame/fast-unstake/src/lib.rs index 41920907bd57b..78a44890e2663 100644 --- a/substrate/frame/fast-unstake/src/lib.rs +++ b/substrate/frame/fast-unstake/src/lib.rs @@ -174,6 +174,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 6a71e831cca11..d8b30fa1ce461 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -153,6 +153,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index 74d3bc6484dd4..01beec879c380 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -277,6 +277,7 @@ pub mod pallet { type MaxPeerInHeartbeats: Get; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type for retrieving the validators supposed to be online in a session. diff --git a/substrate/frame/indices/src/lib.rs b/substrate/frame/indices/src/lib.rs index 740d69365df3e..ed3e16f0f19ec 100644 --- a/substrate/frame/indices/src/lib.rs +++ b/substrate/frame/indices/src/lib.rs @@ -70,6 +70,7 @@ pub mod pallet { type Deposit: Get>; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/lottery/src/lib.rs b/substrate/frame/lottery/src/lib.rs index 6a15de55ebd76..e8eb7a815205b 100644 --- a/substrate/frame/lottery/src/lib.rs +++ b/substrate/frame/lottery/src/lib.rs @@ -147,6 +147,7 @@ pub mod pallet { type Randomness: Randomness>; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The manager origin. diff --git a/substrate/frame/message-queue/src/lib.rs b/substrate/frame/message-queue/src/lib.rs index 04620fa88d85b..aa454bc482c0a 100644 --- a/substrate/frame/message-queue/src/lib.rs +++ b/substrate/frame/message-queue/src/lib.rs @@ -473,6 +473,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/migrations/src/lib.rs b/substrate/frame/migrations/src/lib.rs index d9490e7dcfe99..65bd8d7dce2b6 100644 --- a/substrate/frame/migrations/src/lib.rs +++ b/substrate/frame/migrations/src/lib.rs @@ -305,6 +305,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type of the runtime. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// All the multi-block migrations to run. diff --git a/substrate/frame/multisig/src/lib.rs b/substrate/frame/multisig/src/lib.rs index 869b4adc2adce..f1d817dd8afc1 100644 --- a/substrate/frame/multisig/src/lib.rs +++ b/substrate/frame/multisig/src/lib.rs @@ -124,6 +124,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/substrate/frame/nft-fractionalization/src/lib.rs b/substrate/frame/nft-fractionalization/src/lib.rs index 5fa990ecebe66..b8dc2331c524f 100644 --- a/substrate/frame/nft-fractionalization/src/lib.rs +++ b/substrate/frame/nft-fractionalization/src/lib.rs @@ -91,6 +91,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency mechanism, used for paying for deposits. diff --git a/substrate/frame/nis/src/lib.rs b/substrate/frame/nis/src/lib.rs index 87e2276e768d0..6ca2ad0a0652c 100644 --- a/substrate/frame/nis/src/lib.rs +++ b/substrate/frame/nis/src/lib.rs @@ -214,6 +214,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The treasury's pallet id, used for deriving its sovereign account ID. diff --git a/substrate/frame/node-authorization/src/lib.rs b/substrate/frame/node-authorization/src/lib.rs index 3cec0d3bcb63d..3e0f5e5250f7b 100644 --- a/substrate/frame/node-authorization/src/lib.rs +++ b/substrate/frame/node-authorization/src/lib.rs @@ -68,6 +68,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The maximum number of well known nodes that are allowed to set diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index dc82bf3a37c6e..5df0a9b062a84 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -1578,6 +1578,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/parameters/src/lib.rs b/substrate/frame/parameters/src/lib.rs index 55a6f1ff91ded..aa91c57b90688 100644 --- a/substrate/frame/parameters/src/lib.rs +++ b/substrate/frame/parameters/src/lib.rs @@ -148,6 +148,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching KV type of the parameters. diff --git a/substrate/frame/preimage/src/lib.rs b/substrate/frame/preimage/src/lib.rs index 849ffddf4fb3c..8e29f512a5d38 100644 --- a/substrate/frame/preimage/src/lib.rs +++ b/substrate/frame/preimage/src/lib.rs @@ -110,6 +110,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Weight information for this pallet. diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index cc21db7469b20..59c8b87472cd1 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -99,6 +99,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 42fb641983f63..fb3dfdaee11af 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -229,6 +229,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/remark/src/lib.rs b/substrate/frame/remark/src/lib.rs index eae8e0b83f5d2..158f64b41028b 100644 --- a/substrate/frame/remark/src/lib.rs +++ b/substrate/frame/remark/src/lib.rs @@ -45,6 +45,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/substrate/frame/revive/mock-network/src/mocks/msg_queue.rs b/substrate/frame/revive/mock-network/src/mocks/msg_queue.rs index 88ab8135ea129..063f0bfaed669 100644 --- a/substrate/frame/revive/mock-network/src/mocks/msg_queue.rs +++ b/substrate/frame/revive/mock-network/src/mocks/msg_queue.rs @@ -34,6 +34,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type XcmExecutor: ExecuteXcm; } diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index b9a39e7ce4d37..ebf928f76a91f 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -144,6 +144,7 @@ pub mod pallet { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/substrate/frame/root-offences/src/lib.rs b/substrate/frame/root-offences/src/lib.rs index fd6ffc55e40c3..213365fe7b47c 100644 --- a/substrate/frame/root-offences/src/lib.rs +++ b/substrate/frame/root-offences/src/lib.rs @@ -56,6 +56,7 @@ pub mod pallet { FullIdentificationOf = ExposureOf, > { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/root-testing/src/lib.rs b/substrate/frame/root-testing/src/lib.rs index 98e1f5c5b668d..c7b5d71b4aa9d 100644 --- a/substrate/frame/root-testing/src/lib.rs +++ b/substrate/frame/root-testing/src/lib.rs @@ -37,6 +37,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/safe-mode/src/lib.rs b/substrate/frame/safe-mode/src/lib.rs index cfa9097b54121..d1192385082ea 100644 --- a/substrate/frame/safe-mode/src/lib.rs +++ b/substrate/frame/safe-mode/src/lib.rs @@ -109,6 +109,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type for this pallet, used for Deposits. diff --git a/substrate/frame/scheduler/src/lib.rs b/substrate/frame/scheduler/src/lib.rs index 468099010bf97..f7fa53f9ce676 100644 --- a/substrate/frame/scheduler/src/lib.rs +++ b/substrate/frame/scheduler/src/lib.rs @@ -243,6 +243,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. diff --git a/substrate/frame/scheduler/src/mock.rs b/substrate/frame/scheduler/src/mock.rs index 8d36ca1c42e3a..2d3c63dfeee8e 100644 --- a/substrate/frame/scheduler/src/mock.rs +++ b/substrate/frame/scheduler/src/mock.rs @@ -60,6 +60,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index b3f8c18f704cd..a3c5a5d23f460 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -173,6 +173,7 @@ pub mod pallet { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced reduction when slashing a staker. diff --git a/substrate/frame/state-trie-migration/src/lib.rs b/substrate/frame/state-trie-migration/src/lib.rs index 61323b70b33d2..8b6e5239863f2 100644 --- a/substrate/frame/state-trie-migration/src/lib.rs +++ b/substrate/frame/state-trie-migration/src/lib.rs @@ -486,6 +486,7 @@ pub mod pallet { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency provider type. diff --git a/substrate/frame/statement/src/lib.rs b/substrate/frame/statement/src/lib.rs index 6a7f577ab0869..f852646711ee6 100644 --- a/substrate/frame/statement/src/lib.rs +++ b/substrate/frame/statement/src/lib.rs @@ -68,6 +68,7 @@ pub mod pallet { ::AccountId: From, { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency which is used to calculate account limits. type Currency: Inspect; diff --git a/substrate/frame/sudo/src/lib.rs b/substrate/frame/sudo/src/lib.rs index 66616bf801ebf..6363b3cbab0f3 100644 --- a/substrate/frame/sudo/src/lib.rs +++ b/substrate/frame/sudo/src/lib.rs @@ -175,6 +175,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. diff --git a/substrate/frame/sudo/src/mock.rs b/substrate/frame/sudo/src/mock.rs index 67f896e1c021c..f1c076332febf 100644 --- a/substrate/frame/sudo/src/mock.rs +++ b/substrate/frame/sudo/src/mock.rs @@ -31,6 +31,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/procedural/src/pallet/expand/config.rs b/substrate/frame/support/procedural/src/pallet/expand/config.rs index 77769f0147fc7..e7ff31e3207ab 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/config.rs @@ -24,7 +24,6 @@ use syn::{parse_quote, Item, PathArguments, TypeParamBound}; /// * Generate default rust doc pub fn expand_config(def: &mut Def) -> TokenStream { let config = &def.config; - let warnings = &config.warnings; let config_item = { let item = &mut def.item.content.as_mut().expect("Checked by def parser").1[config.index]; if let Item::Trait(item) = item { @@ -112,9 +111,6 @@ Consequently, a runtime that wants to include this pallet must implement this tr }; quote!( - #( - #warnings - )* /// Based on [`Config`]. Auto-generated by /// [`#[pallet::config(with_default)]`](`frame_support::pallet_macros::config`). /// Can be used in tandem with @@ -129,11 +125,7 @@ Consequently, a runtime that wants to include this pallet must implement this tr } ) }, - _ => quote!( - #( - #warnings - )* - ), + _ => quote!(), } } @@ -173,6 +165,7 @@ pub fn expand_config_metadata(def: &Def) -> proc_macro2::TokenStream { }); quote::quote!( + #[allow(deprecated)] impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause { #[doc(hidden)] diff --git a/substrate/frame/support/procedural/src/pallet/expand/mod.rs b/substrate/frame/support/procedural/src/pallet/expand/mod.rs index 3f9b50f79c0cc..b0a374fc792cc 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/mod.rs @@ -78,6 +78,8 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream { let doc_only = doc_only::expand_doc_only(&mut def); let composites = composite::expand_composites(&mut def); + let warnings = def.config.warnings; + def.item.attrs.insert( 0, syn::parse_quote!( @@ -98,6 +100,9 @@ storage item. Otherwise, all storage items are listed among [*Type Definitions*] ); let new_items = quote::quote!( + #( + #warnings + )* #metadata_docs #constants #pallet_struct diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 2e3d6e07793de..5b4dafdc3b4ba 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -19,7 +19,7 @@ use super::helper; use frame_support_procedural_tools::{get_cfg_attributes, get_doc_literals, is_using_frame_crate}; use proc_macro_warning::Warning; use quote::ToTokens; -use syn::{spanned::Spanned, token, Token, TraitItemType}; +use syn::{parse_quote, spanned::Spanned, token, Token, TraitItemType}; /// List of additional token to be used for parsing. mod keyword { @@ -474,17 +474,20 @@ impl ConfigDef { // add deprecation notice for `RuntimeEvent`, iff pallet is not `frame_system` if is_event && !is_frame_system { if let syn::TraitItem::Type(type_event) = trait_item { - type_event.attrs.push(syn::parse_quote!(#[allow(deprecated)])); + let allow_dep: syn::Attribute = parse_quote!(#[allow(deprecated)]); - let warning = Warning::new_deprecated("RuntimeEvent") + // Check if the `#[allow(deprecated)]` attribute is present + if !type_event.attrs.iter().any(|attr| attr == &allow_dep) { + let warning = Warning::new_deprecated("RuntimeEvent") .old("have `RuntimeEvent` associated type in the pallet config") .new("remove it or explicitly define it as an associated type bound in the system supertrait: \n pub trait Config: frame_system::Config>> { }") .help_link("https://github.com/paritytech/polkadot-sdk/pull/7229") - .span(type_event.span()) + .span(type_event.ident.span()) .build_or_panic(); - warnings.push(warning); + warnings.push(warning); + } } } diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index a6969260e6a26..d609f759cdba6 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -1344,7 +1344,8 @@ pub mod pallet_macros { /// # /// # #[pallet::config] /// # pub trait Config: frame_system::Config { - /// # type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// # #[allow(deprecated)] + /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// # } /// } /// ``` @@ -1511,7 +1512,8 @@ pub mod pallet_macros { /// pub trait Config: frame_system::Config { /// /// The overarching event type. /// #[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeEvent - /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// #[allow(deprecated)] + /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// /// /// A more complex type. /// #[pallet::no_default] // Example of type where no default should be provided @@ -1581,7 +1583,6 @@ pub mod pallet_macros { /// Furthermore, the `without_automatic_metadata` argument can be used in combination with /// the [`#[pallet::include_metadata]`](`include_metadata`) attribute to selectively /// include only certain associated types in the metadata collection. - /// /// ``` /// #[frame_support::pallet] /// mod pallet { @@ -1595,18 +1596,20 @@ pub mod pallet_macros { /// #[pallet::pallet] /// pub struct Pallet(_); /// - /// #[pallet::config(with_default, without_automatic_metadata)] // <- with_default and without_automatic_metadata are optional - /// pub trait Config: frame_system::Config { + /// #[pallet::config(with_default, without_automatic_metadata)] // <- with_default and + /// without_automatic_metadata are optional pub trait Config: frame_system::Config { /// /// The overarching event type. /// #[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeEvent - /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// #[allow(deprecated)] + /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// /// /// A simple type. /// // Type that would have been included in metadata, but is now excluded. /// type SimpleType: From + TypeInfo; /// - /// // The `pallet::include_metadata` is used to selectively include this type in metadata. - /// #[pallet::include_metadata] + /// // The `pallet::include_metadata` is used to selectively include this type in + /// metadata. #[pallet::include_metadata] /// type SelectivelyInclude: From + TypeInfo; /// } /// @@ -1993,7 +1996,8 @@ pub mod pallet_macros { /// #[pallet::config] /// pub trait Config: frame_system::Config { /// /// The overarching runtime event type. - /// type RuntimeEvent: From> + /// #[allow(deprecated)] + /// type RuntimeEvent: From> /// + IsType<::RuntimeEvent>; /// } /// } diff --git a/substrate/frame/support/test/tests/enum_deprecation.rs b/substrate/frame/support/test/tests/enum_deprecation.rs index c1167dfe339ce..68629f82efd09 100644 --- a/substrate/frame/support/test/tests/enum_deprecation.rs +++ b/substrate/frame/support/test/tests/enum_deprecation.rs @@ -60,6 +60,7 @@ pub mod pallet { { type Balance: Parameter + Default + TypeInfo; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/origin.rs b/substrate/frame/support/test/tests/origin.rs index e6dd0cfc0e315..4ca65f307ef29 100644 --- a/substrate/frame/support/test/tests/origin.rs +++ b/substrate/frame/support/test/tests/origin.rs @@ -36,6 +36,7 @@ mod nested { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -85,6 +86,7 @@ pub mod module { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index 9df1f461bba25..eebafcff8fd9b 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -154,6 +154,7 @@ pub mod pallet { type Balance: Parameter + Default + TypeInfo; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs b/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs index a2b916f54c5ed..7ab9822d5b7cd 100644 --- a/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs +++ b/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs @@ -35,6 +35,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; // Constants are already propagated. @@ -59,6 +60,8 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. + #[allow(deprecated)] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; // Constants are already propagated. @@ -95,6 +98,8 @@ pub mod pallet3 { #[pallet::config(without_automatic_metadata)] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. + #[allow(deprecated)] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; // Constants are already propagated. diff --git a/substrate/frame/support/test/tests/pallet_ui/config_metadata_on_events.rs b/substrate/frame/support/test/tests/pallet_ui/config_metadata_on_events.rs index d91f86771bf6d..5746d21a91b29 100644 --- a/substrate/frame/support/test/tests/pallet_ui/config_metadata_on_events.rs +++ b/substrate/frame/support/test/tests/pallet_ui/config_metadata_on_events.rs @@ -24,6 +24,7 @@ mod pallet { pub trait Config: frame_system::Config { #[pallet::no_default_bounds] #[pallet::include_metadata] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; #[pallet::constant] diff --git a/substrate/frame/support/test/tests/runtime.rs b/substrate/frame/support/test/tests/runtime.rs index 5335e08837e4a..5cc44721f68bd 100644 --- a/substrate/frame/support/test/tests/runtime.rs +++ b/substrate/frame/support/test/tests/runtime.rs @@ -90,6 +90,7 @@ mod module2 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -136,6 +137,7 @@ mod nested { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -204,6 +206,7 @@ pub mod module3 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs index 7b92073a82b1a..c993f3c47b53d 100644 --- a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs +++ b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs @@ -90,6 +90,7 @@ mod module2 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -136,6 +137,7 @@ mod nested { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -204,6 +206,8 @@ pub mod module3 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/split_ui/pass/split_valid.rs b/substrate/frame/support/test/tests/split_ui/pass/split_valid.rs index a3ad7c2bf6f98..9775ab2d367a6 100644 --- a/substrate/frame/support/test/tests/split_ui/pass/split_valid.rs +++ b/substrate/frame/support/test/tests/split_ui/pass/split_valid.rs @@ -41,6 +41,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -53,5 +54,4 @@ pub mod pallet { } } -fn main() { -} +fn main() {} diff --git a/substrate/frame/support/test/tests/split_ui/pass/split_valid_disambiguation.rs b/substrate/frame/support/test/tests/split_ui/pass/split_valid_disambiguation.rs index dba0eb7333a01..28bcb8c4edf95 100644 --- a/substrate/frame/support/test/tests/split_ui/pass/split_valid_disambiguation.rs +++ b/substrate/frame/support/test/tests/split_ui/pass/split_valid_disambiguation.rs @@ -36,7 +36,7 @@ mod first { mod second { use super::*; - + #[pallet_section(section2)] mod section { #[pallet::error] @@ -58,6 +58,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -74,5 +75,4 @@ pub mod pallet { } } -fn main() { -} +fn main() {} diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs index d6721c46422bd..faa2245f51638 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs @@ -111,6 +111,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The asset ID type that can be used for transaction payments in addition to a /// native asset. diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs index dd752989c3662..5c55bc12bf3ff 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -121,6 +121,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. type Fungibles: Balanced; diff --git a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs index 5ba1d1297679e..e5107b950028e 100644 --- a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs @@ -66,6 +66,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 216697beac698..db9285f4d5b3b 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -347,6 +347,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for withdrawing, refunding and depositing the transaction fee. diff --git a/substrate/frame/transaction-storage/src/lib.rs b/substrate/frame/transaction-storage/src/lib.rs index 68f24526300d8..cc6d4a0e9ea4b 100644 --- a/substrate/frame/transaction-storage/src/lib.rs +++ b/substrate/frame/transaction-storage/src/lib.rs @@ -104,6 +104,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A dispatchable call. type RuntimeCall: Parameter diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 962bfd744a658..d06b837d67af9 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -111,6 +111,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 274a90d77cf06..4bc0fa79a6781 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -99,6 +99,7 @@ mod mock_democracy { #[pallet::config] pub trait Config: frame_system::Config + Sized { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type ExternalMajorityOrigin: EnsureOrigin; diff --git a/substrate/frame/vesting/src/lib.rs b/substrate/frame/vesting/src/lib.rs index 15f8d397f81c9..bc7e6dce6cf82 100644 --- a/substrate/frame/vesting/src/lib.rs +++ b/substrate/frame/vesting/src/lib.rs @@ -160,6 +160,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. diff --git a/substrate/frame/whitelist/src/lib.rs b/substrate/frame/whitelist/src/lib.rs index 28887e0ca4aca..a16d524a6fc69 100644 --- a/substrate/frame/whitelist/src/lib.rs +++ b/substrate/frame/whitelist/src/lib.rs @@ -64,6 +64,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. diff --git a/templates/parachain/pallets/template/src/lib.rs b/templates/parachain/pallets/template/src/lib.rs index 211bef51aa86e..0f61f7a29a361 100644 --- a/templates/parachain/pallets/template/src/lib.rs +++ b/templates/parachain/pallets/template/src/lib.rs @@ -73,6 +73,7 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type representing the weights required by the dispatchables of this pallet. diff --git a/templates/solochain/pallets/template/src/lib.rs b/templates/solochain/pallets/template/src/lib.rs index 90dfe37014585..db01d163dc2b2 100644 --- a/templates/solochain/pallets/template/src/lib.rs +++ b/templates/solochain/pallets/template/src/lib.rs @@ -81,6 +81,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type representing the weights required by the dispatchables of this pallet. type WeightInfo: WeightInfo; From f4e70bd3f9642d1b68c2c276cc145ccec8a183b4 Mon Sep 17 00:00:00 2001 From: dastansam Date: Sat, 15 Feb 2025 23:00:30 +0600 Subject: [PATCH 08/12] Deprecate `RuntimeEvent` completely --- bridges/modules/grandpa/src/lib.rs | 1 + bridges/modules/messages/src/lib.rs | 1 + bridges/modules/parachains/src/lib.rs | 1 + bridges/modules/relayers/src/lib.rs | 1 + bridges/modules/xcm-bridge-hub-router/src/lib.rs | 1 + bridges/modules/xcm-bridge-hub/src/lib.rs | 1 + cumulus/pallets/solo-to-para/src/lib.rs | 1 + cumulus/parachains/pallets/collective-content/src/lib.rs | 1 + docs/sdk/src/polkadot_sdk/frame_runtime.rs | 1 + polkadot/runtime/parachains/src/paras/mod.rs | 1 + polkadot/runtime/test-runtime/src/lib.rs | 1 + polkadot/xcm/pallet-xcm/src/mock.rs | 5 +++-- prdoc/pr_7229.prdoc | 3 +-- substrate/frame/alliance/src/lib.rs | 1 + substrate/frame/asset-rewards/src/lib.rs | 1 + substrate/frame/assets-freezer/src/lib.rs | 1 + substrate/frame/assets/src/lib.rs | 1 + substrate/frame/bags-list/src/lib.rs | 1 + substrate/frame/benchmarking/src/tests_instance.rs | 1 + substrate/frame/bounties/src/lib.rs | 1 + substrate/frame/collective/src/lib.rs | 1 + substrate/frame/conviction-voting/src/lib.rs | 1 + substrate/frame/core-fellowship/src/lib.rs | 1 + substrate/frame/election-provider-multi-block/src/lib.rs | 1 + .../frame/election-provider-multi-block/src/signed/mod.rs | 1 + .../election-provider-multi-block/src/verifier/impls.rs | 1 + substrate/frame/glutton/src/lib.rs | 1 + substrate/frame/grandpa/src/lib.rs | 1 + substrate/frame/membership/src/lib.rs | 1 + substrate/frame/nfts/src/lib.rs | 1 + substrate/frame/offences/src/lib.rs | 1 + substrate/frame/ranked-collective/src/lib.rs | 1 + substrate/frame/referenda/src/lib.rs | 1 + substrate/frame/salary/src/lib.rs | 1 + substrate/frame/scored-pool/src/lib.rs | 1 + substrate/frame/session/src/lib.rs | 1 + substrate/frame/society/src/lib.rs | 1 + substrate/frame/support/test/tests/common/outer_enums.rs | 3 +++ substrate/frame/support/test/tests/instance.rs | 2 ++ substrate/frame/support/test/tests/pallet.rs | 1 + .../support/test/tests/pallet_associated_types_metadata.rs | 2 -- substrate/frame/support/test/tests/pallet_instance.rs | 2 ++ .../support/test/tests/pallet_ui/event_field_not_member.rs | 1 + .../test/tests/pallet_ui/event_type_invalid_bound_2.rs | 4 ++-- .../pallet_ui/event_type_invalid_bound_no_frame_crate.rs | 3 ++- .../pass/event_type_bound_system_config_assoc_type.rs | 1 + substrate/frame/support/test/tests/runtime.rs | 1 + .../frame/support/test/tests/runtime_legacy_ordering.rs | 2 +- substrate/frame/system/benches/bench.rs | 1 + substrate/frame/system/src/lib.rs | 1 + substrate/frame/tips/src/lib.rs | 1 + substrate/frame/treasury/src/lib.rs | 1 + substrate/frame/uniques/src/lib.rs | 1 + substrate/frame/utility/src/lib.rs | 1 + 54 files changed, 61 insertions(+), 10 deletions(-) diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 22a15ec4062f7..ab267018ef55a 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -98,6 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 61763186cb021..02013ad01ec80 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -107,6 +107,7 @@ pub mod pallet { // General types /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Benchmarks results from runtime we're plugged into. diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index bbf6a6600d56f..656f79594803b 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -183,6 +183,7 @@ pub mod pallet { BoundedBridgeGrandpaConfig { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Benchmarks results from runtime we're plugged into. diff --git a/bridges/modules/relayers/src/lib.rs b/bridges/modules/relayers/src/lib.rs index d1c71b6d30510..7334f9b52f5b5 100644 --- a/bridges/modules/relayers/src/lib.rs +++ b/bridges/modules/relayers/src/lib.rs @@ -67,6 +67,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type of relayer reward. diff --git a/bridges/modules/xcm-bridge-hub-router/src/lib.rs b/bridges/modules/xcm-bridge-hub-router/src/lib.rs index 7361696faba71..44249b97080c5 100644 --- a/bridges/modules/xcm-bridge-hub-router/src/lib.rs +++ b/bridges/modules/xcm-bridge-hub-router/src/lib.rs @@ -79,6 +79,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Benchmarks results from runtime we're plugged into. diff --git a/bridges/modules/xcm-bridge-hub/src/lib.rs b/bridges/modules/xcm-bridge-hub/src/lib.rs index 1633e99d7f303..0262cc426e23a 100644 --- a/bridges/modules/xcm-bridge-hub/src/lib.rs +++ b/bridges/modules/xcm-bridge-hub/src/lib.rs @@ -194,6 +194,7 @@ pub mod pallet { BridgeMessagesConfig { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/cumulus/pallets/solo-to-para/src/lib.rs b/cumulus/pallets/solo-to-para/src/lib.rs index f8761e13a0544..ff68d1b63fe7f 100644 --- a/cumulus/pallets/solo-to-para/src/lib.rs +++ b/cumulus/pallets/solo-to-para/src/lib.rs @@ -33,6 +33,7 @@ pub mod pallet { pub trait Config: frame_system::Config + parachain_system::Config + pallet_sudo::Config { + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; } diff --git a/cumulus/parachains/pallets/collective-content/src/lib.rs b/cumulus/parachains/pallets/collective-content/src/lib.rs index 7ea3c2d79fa79..58c220c0c606f 100644 --- a/cumulus/parachains/pallets/collective-content/src/lib.rs +++ b/cumulus/parachains/pallets/collective-content/src/lib.rs @@ -69,6 +69,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/docs/sdk/src/polkadot_sdk/frame_runtime.rs b/docs/sdk/src/polkadot_sdk/frame_runtime.rs index 24595e445fdd6..38068fc9c925f 100644 --- a/docs/sdk/src/polkadot_sdk/frame_runtime.rs +++ b/docs/sdk/src/polkadot_sdk/frame_runtime.rs @@ -104,6 +104,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// A type that is not known now, but the runtime that will contain this pallet will /// know it later, therefore we define it here as an associated type. + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; /// A parameterize-able value that we receive later via the `Get<_>` trait. diff --git a/polkadot/runtime/parachains/src/paras/mod.rs b/polkadot/runtime/parachains/src/paras/mod.rs index e0f244dbd8631..8574f0481dfb1 100644 --- a/polkadot/runtime/parachains/src/paras/mod.rs +++ b/polkadot/runtime/parachains/src/paras/mod.rs @@ -617,6 +617,7 @@ pub mod pallet { + shared::Config + frame_system::offchain::CreateInherent> { + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; #[pallet::constant] diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index c098587353202..7475bce6037ee 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -697,6 +697,7 @@ pub mod pallet_test_notifier { #[pallet::config] pub trait Config: frame_system::Config + pallet_xcm::Config { + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 58b4226ccf191..93e56182a3199 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -64,6 +64,7 @@ pub mod pallet_test_notifier { #[pallet::config] pub trait Config: frame_system::Config + crate::Config { + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; @@ -222,10 +223,10 @@ impl SendXcm for TestPaidForPara3000SendXcm { ) -> SendResult<(Location, Xcm<()>)> { if let Some(dest) = dest.as_ref() { if !dest.eq(&Para3000Location::get()) { - return Err(SendError::NotApplicable) + return Err(SendError::NotApplicable); } } else { - return Err(SendError::NotApplicable) + return Err(SendError::NotApplicable); } let pair = (dest.take().unwrap(), msg.take().unwrap()); diff --git a/prdoc/pr_7229.prdoc b/prdoc/pr_7229.prdoc index 940c3e0644b46..4f0ebdaef3813 100644 --- a/prdoc/pr_7229.prdoc +++ b/prdoc/pr_7229.prdoc @@ -22,8 +22,7 @@ doc: pub trait Config: frame_system::Config { /// Overarching event type. #[allow(deprecated)] -#[allow(deprecated)] -type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } ``` diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index be65f49e6e4ea..293ae6ac799bf 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -226,6 +226,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/asset-rewards/src/lib.rs b/substrate/frame/asset-rewards/src/lib.rs index 4ce73e9febf96..994bf0b61f5ae 100644 --- a/substrate/frame/asset-rewards/src/lib.rs +++ b/substrate/frame/asset-rewards/src/lib.rs @@ -210,6 +210,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The pallet's unique identifier, used to derive the pool's account ID. diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 61a695a6f5b81..6376a473d066d 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -81,6 +81,7 @@ pub mod pallet { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index a9b0dc950a610..e31bf3e8277dc 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -308,6 +308,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/bags-list/src/lib.rs b/substrate/frame/bags-list/src/lib.rs index ae65cc0783c93..ed4f822549e86 100644 --- a/substrate/frame/bags-list/src/lib.rs +++ b/substrate/frame/bags-list/src/lib.rs @@ -178,6 +178,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/benchmarking/src/tests_instance.rs b/substrate/frame/benchmarking/src/tests_instance.rs index 428f29e2bc161..bea3b85dc04a2 100644 --- a/substrate/frame/benchmarking/src/tests_instance.rs +++ b/substrate/frame/benchmarking/src/tests_instance.rs @@ -40,6 +40,7 @@ mod pallet_test { #[pallet::config] pub trait Config: frame_system::Config + OtherConfig { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type LowerBound: Get; diff --git a/substrate/frame/bounties/src/lib.rs b/substrate/frame/bounties/src/lib.rs index 9b6e3c06e9141..f52ba15a8c0f6 100644 --- a/substrate/frame/bounties/src/lib.rs +++ b/substrate/frame/bounties/src/lib.rs @@ -249,6 +249,7 @@ pub mod pallet { type DataDepositPerByte: Get>; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index 8e533a7b29043..b0cf0181e4dff 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -338,6 +338,7 @@ pub mod pallet { + GetDispatchInfo; /// The runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/conviction-voting/src/lib.rs b/substrate/frame/conviction-voting/src/lib.rs index 3dd2ad24298d3..a9c357c714b76 100644 --- a/substrate/frame/conviction-voting/src/lib.rs +++ b/substrate/frame/conviction-voting/src/lib.rs @@ -106,6 +106,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { // System level stuff. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/core-fellowship/src/lib.rs b/substrate/frame/core-fellowship/src/lib.rs index 22ba63b26161d..d81a7a965731e 100644 --- a/substrate/frame/core-fellowship/src/lib.rs +++ b/substrate/frame/core-fellowship/src/lib.rs @@ -184,6 +184,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/election-provider-multi-block/src/lib.rs b/substrate/frame/election-provider-multi-block/src/lib.rs index 355f117bc4573..95d900891b10d 100644 --- a/substrate/frame/election-provider-multi-block/src/lib.rs +++ b/substrate/frame/election-provider-multi-block/src/lib.rs @@ -358,6 +358,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/substrate/frame/election-provider-multi-block/src/signed/mod.rs b/substrate/frame/election-provider-multi-block/src/signed/mod.rs index 1784a87b22433..ef047c89fc5dd 100644 --- a/substrate/frame/election-provider-multi-block/src/signed/mod.rs +++ b/substrate/frame/election-provider-multi-block/src/signed/mod.rs @@ -220,6 +220,7 @@ pub mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: crate::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/substrate/frame/election-provider-multi-block/src/verifier/impls.rs b/substrate/frame/election-provider-multi-block/src/verifier/impls.rs index 0f5f0fb911be8..6d6524e69b513 100644 --- a/substrate/frame/election-provider-multi-block/src/verifier/impls.rs +++ b/substrate/frame/election-provider-multi-block/src/verifier/impls.rs @@ -112,6 +112,7 @@ pub(crate) mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: crate::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto> diff --git a/substrate/frame/glutton/src/lib.rs b/substrate/frame/glutton/src/lib.rs index c8d2981ebfef1..85608ad25e727 100644 --- a/substrate/frame/glutton/src/lib.rs +++ b/substrate/frame/glutton/src/lib.rs @@ -61,6 +61,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The admin origin that can set computational limits and initialize the pallet. diff --git a/substrate/frame/grandpa/src/lib.rs b/substrate/frame/grandpa/src/lib.rs index 9017eec2ca8f8..67cf98413640c 100644 --- a/substrate/frame/grandpa/src/lib.rs +++ b/substrate/frame/grandpa/src/lib.rs @@ -85,6 +85,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The event type of this module. + #[allow(deprecated)] type RuntimeEvent: From + Into<::RuntimeEvent> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index bbd17c66be4d8..28cfe038329ea 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -67,6 +67,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/nfts/src/lib.rs b/substrate/frame/nfts/src/lib.rs index 346ad162c5035..7a2a0d7765235 100644 --- a/substrate/frame/nfts/src/lib.rs +++ b/substrate/frame/nfts/src/lib.rs @@ -128,6 +128,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/offences/src/lib.rs b/substrate/frame/offences/src/lib.rs index 18f37c759a6a2..fea6475f7dc28 100644 --- a/substrate/frame/offences/src/lib.rs +++ b/substrate/frame/offences/src/lib.rs @@ -64,6 +64,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; /// Full identification of the validator. type IdentificationTuple: Parameter; diff --git a/substrate/frame/ranked-collective/src/lib.rs b/substrate/frame/ranked-collective/src/lib.rs index e34cf3d8df711..2e27adc3eb203 100644 --- a/substrate/frame/ranked-collective/src/lib.rs +++ b/substrate/frame/ranked-collective/src/lib.rs @@ -392,6 +392,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/referenda/src/lib.rs b/substrate/frame/referenda/src/lib.rs index e6a895f9c5933..3b1836ab9b58e 100644 --- a/substrate/frame/referenda/src/lib.rs +++ b/substrate/frame/referenda/src/lib.rs @@ -164,6 +164,7 @@ pub mod pallet { + From> + IsType<::RuntimeCall> + From>; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 6a843625f4a7b..0dd42938f3aac 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -87,6 +87,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The runtime event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/scored-pool/src/lib.rs b/substrate/frame/scored-pool/src/lib.rs index c4464bbbfac04..b6ed42fb15831 100644 --- a/substrate/frame/scored-pool/src/lib.rs +++ b/substrate/frame/scored-pool/src/lib.rs @@ -161,6 +161,7 @@ pub mod pallet { + MaxEncodedLen; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index 98ce774e42815..e4c52d3711ae2 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -385,6 +385,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; /// A stable ID for a validator. diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index 39aa6bf3566b2..53580d4e391bc 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -486,6 +486,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/support/test/tests/common/outer_enums.rs b/substrate/frame/support/test/tests/common/outer_enums.rs index 92dc7ac522079..9659f08430d8d 100644 --- a/substrate/frame/support/test/tests/common/outer_enums.rs +++ b/substrate/frame/support/test/tests/common/outer_enums.rs @@ -27,6 +27,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -71,6 +72,7 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -115,6 +117,7 @@ pub mod pallet3 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/instance.rs b/substrate/frame/support/test/tests/instance.rs index 7f8423a0127e4..619c3f8d78c51 100644 --- a/substrate/frame/support/test/tests/instance.rs +++ b/substrate/frame/support/test/tests/instance.rs @@ -50,6 +50,7 @@ mod module1 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeOrigin: From>; @@ -158,6 +159,7 @@ mod module2 { #[pallet::config] pub trait Config: frame_system::Config { type Amount: Parameter + MaybeSerializeDeserialize + Default + MaxEncodedLen; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeOrigin: From>; diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index 099215b0b3ed4..7f53667c62902 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -594,6 +594,7 @@ pub mod pallet2 { where ::AccountId: From + SomeAssociation1, { + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs b/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs index 7ab9822d5b7cd..8ff230470693b 100644 --- a/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs +++ b/substrate/frame/support/test/tests/pallet_associated_types_metadata.rs @@ -61,7 +61,6 @@ pub mod pallet2 { pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. #[allow(deprecated)] - #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; // Constants are already propagated. @@ -99,7 +98,6 @@ pub mod pallet3 { pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. #[allow(deprecated)] - #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; // Constants are already propagated. diff --git a/substrate/frame/support/test/tests/pallet_instance.rs b/substrate/frame/support/test/tests/pallet_instance.rs index 2e4baae1db7cf..42757d916afcb 100644 --- a/substrate/frame/support/test/tests/pallet_instance.rs +++ b/substrate/frame/support/test/tests/pallet_instance.rs @@ -48,6 +48,7 @@ pub mod pallet { #[pallet::constant] type MyGetParam: Get; type Balance: Parameter + Default + scale_info::StaticTypeInfo; + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -266,6 +267,7 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs index 33603d6f559a8..ed84060a1aa81 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs +++ b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs @@ -24,6 +24,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; } diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs index 23d5a3b449ec8..b811cae0acabc 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs +++ b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs @@ -23,6 +23,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent>; } @@ -41,5 +42,4 @@ mod pallet { } } -fn main() { -} +fn main() {} diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs index b510beb54dda0..81bfa33105d94 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs +++ b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs @@ -17,12 +17,13 @@ #[frame_support::pallet] mod pallet { - use polkadot_sdk_frame::deps::frame_system::pallet_prelude::BlockNumberFor; use frame_support::pallet_prelude::{Hooks, IsType}; + use polkadot_sdk_frame::deps::frame_system::pallet_prelude::BlockNumberFor; #[pallet::config] pub trait Config: polkadot_sdk_frame::deps::frame_system::Config { type Bar: Clone + std::fmt::Debug + Eq; + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; } diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs index d84d320b0b24a..835b0fce5957a 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs @@ -24,6 +24,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar: Clone + std::fmt::Debug + Eq; + #[allow(deprecated)] type RuntimeEvent: IsType<::RuntimeEvent> + From>; } diff --git a/substrate/frame/support/test/tests/runtime.rs b/substrate/frame/support/test/tests/runtime.rs index 6fa9e76b47c72..e51986cf7ed07 100644 --- a/substrate/frame/support/test/tests/runtime.rs +++ b/substrate/frame/support/test/tests/runtime.rs @@ -52,6 +52,7 @@ mod module1 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs index 671f3328e40bf..dd6d8d3db5f54 100644 --- a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs +++ b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs @@ -52,6 +52,7 @@ mod module1 { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -206,7 +207,6 @@ pub mod module3 { #[pallet::config] pub trait Config: frame_system::Config { - #[allow(deprecated)] #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/system/benches/bench.rs b/substrate/frame/system/benches/bench.rs index 1b0f459c9792f..84ece9d8b3065 100644 --- a/substrate/frame/system/benches/bench.rs +++ b/substrate/frame/system/benches/bench.rs @@ -27,6 +27,7 @@ mod module { #[pallet::config] pub trait Config: frame_system::Config { + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; } diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 348611420da1d..8447a7b66096e 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -470,6 +470,7 @@ pub mod pallet { pub trait Config: 'static + Eq + Clone { /// The aggregated event type of the runtime. #[pallet::no_default_bounds] + #[allow(deprecated)] type RuntimeEvent: Parameter + Member + From> diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index 67bcdfa0685e5..53d1be1c2df32 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -135,6 +135,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_treasury::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 281012ffb4c95..4005f07b035a4 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -218,6 +218,7 @@ pub mod pallet { type RejectOrigin: EnsureOrigin; /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/uniques/src/lib.rs b/substrate/frame/uniques/src/lib.rs index 84f122c08bb7b..776fb4283af37 100644 --- a/substrate/frame/uniques/src/lib.rs +++ b/substrate/frame/uniques/src/lib.rs @@ -96,6 +96,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 26c38d1f0459d..98a49bd857f3f 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -84,6 +84,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. + #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The overarching call type. From cf1d71632ead203530dfa9c8e69379f6623a70f5 Mon Sep 17 00:00:00 2001 From: dastansam Date: Sun, 16 Feb 2025 13:09:46 +0600 Subject: [PATCH 09/12] Always use associated type bound --- prdoc/pr_7229.prdoc | 8 +- .../procedural/src/pallet/expand/config.rs | 64 ++++------ .../procedural/src/pallet/expand/event.rs | 15 +-- .../procedural/src/pallet/parse/config.rs | 111 ++---------------- .../procedural/src/pallet/parse/mod.rs | 36 ++---- substrate/frame/support/src/lib.rs | 47 +++----- substrate/frame/system/src/lib.rs | 1 - 7 files changed, 58 insertions(+), 224 deletions(-) diff --git a/prdoc/pr_7229.prdoc b/prdoc/pr_7229.prdoc index 4f0ebdaef3813..0717ac7f0be7e 100644 --- a/prdoc/pr_7229.prdoc +++ b/prdoc/pr_7229.prdoc @@ -1,7 +1,7 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: "FRAME: Remove `RuntimeEvent` associated type from `Config` trait" +title: "FRAME: Deprecate `RuntimeEvent` associated type from `Config` trait" doc: - audience: Runtime Dev description: | @@ -25,12 +25,12 @@ doc: type RuntimeEvent: From> + IsType<::RuntimeEvent>; } ``` - - Or if developers want to explicitly define the `RuntimeEvent` type bound, they can still do so. + The latter compiles but is redundant since the associated type bound is automatically appended + if pallet defines `Event` type, i.e it looks like this after macro expansion: ```rs #[pallet::config] - pub trait Config: frame_system::Config>> { + pub trait Config: frame_system::Config + frame_system::Config>> { } ``` diff --git a/substrate/frame/support/procedural/src/pallet/expand/config.rs b/substrate/frame/support/procedural/src/pallet/expand/config.rs index e7ff31e3207ab..ebe54e6aad2ac 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/config.rs @@ -15,10 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::pallet::{parse::config::has_expected_system_config, Def}; +use crate::pallet::{parse::GenericKind, Def}; use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; -use syn::{parse_quote, Item, PathArguments, TypeParamBound}; +use quote::quote; +use syn::{parse_quote, Item}; /// /// * Generate default rust doc @@ -50,34 +50,25 @@ Consequently, a runtime that wants to include this pallet must implement this tr // insert `frame_system::Config` supertrait with `RuntimeEvent: From>` if neither // associated type nor type bound is defined. - if def.event.is_some() && !config.has_event_type && !config.has_event_bound { - // find the `frame_system::Config` supertrait - let frame_system = crate::generate_access_from_frame_or_crate("frame-system") - .expect("should have access to frame-system"); - - if let Some(TypeParamBound::Trait(trait_bound)) = - config_item.supertraits.iter_mut().find(|s| { - syn::parse2::(s.to_token_stream()) - .map_or(false, |b| has_expected_system_config(b, &frame_system)) - }) { - let event_bound: syn::GenericArgument = parse_quote!(RuntimeEvent: From>); - - if let Some(segment) = - trait_bound.path.segments.iter_mut().find(|s| s.ident == "Config") - { - match &mut segment.arguments { - // when `Config { - args.args.push(event_bound); - }, - // when `Config` - syn::PathArguments::None => { - segment.arguments = - PathArguments::AngleBracketed(parse_quote!(<#event_bound>)); - }, - _ => unreachable!("Checked by has_expected_system_config"), - } - } + if let Some(event) = &def.event { + if !def.is_frame_system { + let frame_system = crate::generate_access_from_frame_or_crate("frame-system") + .expect("should have access to frame-system"); + + // can't use `type_use_gen()` since it returns `T`, not `Self` + let event_use_gen = match event.gen_kind { + GenericKind::None => quote!(), + GenericKind::Config => quote::quote_spanned! {event.attr_span => Self}, + GenericKind::ConfigAndInstance => + quote::quote_spanned! {event.attr_span => Self, I}, + }; + + let supertrait_with_event_bound = syn::parse2::( + quote! { #frame_system::Config>> }, + ) + .expect("should be possible to parse system supertrait"); + + config_item.supertraits.push(supertrait_with_event_bound.into()); } } @@ -177,14 +168,3 @@ pub fn expand_config_metadata(def: &Def) -> proc_macro2::TokenStream { } ) } - -#[test] -fn test_parse_quote() { - // pub trait Config: pallet_balances::Config + frame_system::Config>>{ - - // the `RuntimeEvent: From>` part - let event: syn::AngleBracketedGenericArguments = parse_quote!(RuntimeEvent: From>); - let event_bound = syn::parse2::(event.to_token_stream()).unwrap(); - println!("{:?}", event_bound); -} diff --git a/substrate/frame/support/procedural/src/pallet/expand/event.rs b/substrate/frame/support/procedural/src/pallet/expand/event.rs index 83251dafcb081..4dee4dca3174f 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/event.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/event.rs @@ -136,32 +136,23 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let deposit_event = if let Some(deposit_event) = &event.deposit_event { let event_use_gen = &event.gen_kind.type_use_gen(event.attr_span); - let trait_use_gen = &def.trait_use_generics(event.attr_span); let type_impl_gen = &def.type_impl_generics(event.attr_span); let type_use_gen = &def.type_use_generics(event.attr_span); let pallet_ident = &def.pallet_struct.pallet; let PalletEventDepositAttr { fn_vis, fn_span, .. } = deposit_event; - // `RuntimeEvent` can be defined either as associated type in `Config` or as a type bound in - // system supertrait. - let runtime_event_path = if def.config.has_event_bound || !def.config.has_event_type { - quote::quote! { ::RuntimeEvent } - } else { - quote::quote! { ::RuntimeEvent } - }; - quote::quote_spanned!(*fn_span => impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause { #fn_vis fn deposit_event(event: Event<#event_use_gen>) { let event = < - #runtime_event_path as + ::RuntimeEvent as From> >::from(event); let event = < - #runtime_event_path as - Into<#runtime_event_path> + ::RuntimeEvent as + Into<::RuntimeEvent> >::into(event); <#frame_system::Pallet>::deposit_event(event) diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index 5b4dafdc3b4ba..1871cfbf34a9b 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -59,13 +59,6 @@ pub struct ConfigDef { pub consts_metadata: Vec, /// Associated types metadata. pub associated_types_metadata: Vec, - /// Whether the trait has the associated type `Event`, note that those bounds are - /// checked: - /// * `IsType::RuntimeEvent` - /// * `From` or `From>` or `From>` - pub has_event_type: bool, - /// Whether the supertrait `frame_system::Config` defines associated type `RuntimeEvent`. - pub has_event_bound: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, /// Whether a default sub-trait should be generated. @@ -303,7 +296,7 @@ fn check_event_type( /// Check that the path to `frame_system::Config` is valid, this is that the path is just /// `frame_system::Config` or when using the `frame` crate it is /// `polkadot_sdk_frame::xyz::frame_system::Config`. -pub(crate) fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool { +fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool { // Check if `frame_system` is actually 'frame_system'. if path.segments.iter().all(|s| s.ident != "frame_system") { return false; @@ -371,38 +364,6 @@ fn contains_type_info_bound(ty: &TraitItemType) -> bool { }) } -/// Check that supertrait `Config` contains `RuntimeEvent` associated type bound with -/// `From>`. -/// -/// NOTE: Does not check if the supertrait path is valid system config path. -/// -/// ```rs -/// pub trait Config: frame_system::Config { -/// ``` -fn contains_runtime_event_associated_type_bound(supertrait: &syn::Path) -> bool { - if let Some(args) = supertrait.segments.iter().find(|s| s.ident == "Config") { - if let syn::PathArguments::AngleBracketed(args) = &args.arguments { - for arg in &args.args { - if let syn::GenericArgument::Constraint(c) = arg { - if c.ident != "RuntimeEvent" { - continue; - } - - // Check `From>` bound - let from_event_bound = c - .bounds - .iter() - .find_map(|s| syn::parse2::(s.to_token_stream()).ok()); - - return from_event_bound.is_some(); - } - } - } - } - - false -} - impl ConfigDef { pub fn try_from( frame_system: &syn::Path, @@ -444,16 +405,6 @@ impl ConfigDef { false }; - let has_event_bound = if is_frame_system { - false - } else { - item.supertraits.iter().any(|supertrait| { - syn::parse2::(supertrait.to_token_stream()) - .map_or(false, |b| contains_runtime_event_associated_type_bound(&b)) - }) - }; - - let mut has_event_type = false; let mut consts_metadata = vec![]; let mut associated_types_metadata = vec![]; let mut warnings = vec![]; @@ -464,7 +415,6 @@ impl ConfigDef { }; for trait_item in &mut item.items { let is_event = check_event_type(frame_system, trait_item, has_instance)?; - has_event_type = has_event_type || is_event; let mut already_no_default = false; let mut already_constant = false; @@ -480,7 +430,7 @@ impl ConfigDef { if !type_event.attrs.iter().any(|attr| attr == &allow_dep) { let warning = Warning::new_deprecated("RuntimeEvent") .old("have `RuntimeEvent` associated type in the pallet config") - .new("remove it or explicitly define it as an associated type bound in the system supertrait: \n + .new("remove it as it is redundant since associated bound gets appended automatically: \n pub trait Config: frame_system::Config>> { }") .help_link("https://github.com/paritytech/polkadot-sdk/pull/7229") .span(type_event.ident.span()) @@ -618,7 +568,12 @@ impl ConfigDef { helper::take_first_item_pallet_attr(&mut item.attrs)?; let disable_system_supertrait_check = attr.is_some(); - if is_frame_system && !disable_system_supertrait_check { + let has_frame_system_supertrait = item.supertraits.iter().any(|s| { + syn::parse2::(s.to_token_stream()) + .map_or(false, |b| has_expected_system_config(b, frame_system)) + }); + + if !has_frame_system_supertrait && !disable_system_supertrait_check { let found = if item.supertraits.is_empty() { "none".to_string() } else { @@ -648,8 +603,6 @@ impl ConfigDef { has_instance, consts_metadata, associated_types_metadata, - has_event_type, - has_event_bound, where_clause, default_sub_trait, warnings, @@ -774,52 +727,4 @@ mod tests { let path = syn::parse2::(quote::quote!(something::Config)).unwrap(); assert!(!has_expected_system_config(path, &frame_system)); } - - #[test] - fn contains_runtime_event_associated_type_bound_no_bound() { - let supertrait = syn::parse2::(quote::quote!(frame_system::Config)).unwrap(); - assert!(!contains_runtime_event_associated_type_bound(&supertrait)); - } - - #[test] - fn contains_runtime_event_associated_type_bound_works() { - let supertrait = syn::parse2::(quote::quote!(Config)); - assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); - } - #[test] - fn contains_runtime_event_associated_type_bound_works_interface() { - let supertrait = syn::parse2::(quote::quote!( - Config>> - )); - assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); - } - - #[test] - fn contains_runtime_event_associated_type_bound_works_full_path() { - let supertrait = syn::parse2::(quote::quote!(frame_system::Config)); - assert!(contains_runtime_event_associated_type_bound(&supertrait.unwrap())); - } - - #[test] - fn contains_runtime_event_associated_type_bound_invalid_supertrait() { - let supertrait = - syn::parse2::(quote::quote!(SystemConfig>>)) - .unwrap(); - assert!(!contains_runtime_event_associated_type_bound(&supertrait)); - } - - #[test] - fn contains_runtime_event_associated_type_bound_invalid_assoc_type_name() { - let supertrait = - syn::parse2::(quote::quote!(Config>>)) - .unwrap(); - assert!(!contains_runtime_event_associated_type_bound(&supertrait)); - } - #[test] - fn contains_runtime_event_associated_type_bound_invalid_trait_bound() { - let supertrait = - syn::parse2::(quote::quote!(Config>>)) - .unwrap(); - assert!(!contains_runtime_event_associated_type_bound(&supertrait)); - } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index c599149767c6f..eb7264007b416 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -72,6 +72,7 @@ pub struct Def { pub frame_support: syn::Path, pub dev_mode: bool, pub view_functions: Option, + pub is_frame_system: bool, } impl Def { @@ -106,12 +107,14 @@ impl Def { let mut type_values = vec![]; let mut composites: Vec = vec![]; let mut view_functions = None; + let mut is_frame_system = false; for (index, item) in items.iter_mut().enumerate() { let pallet_attr: Option = helper::take_first_item_pallet_attr(item)?; match pallet_attr { - Some(PalletAttr::Config{ with_default, is_frame_system, without_automatic_metadata, ..}) if config.is_none() => + Some(PalletAttr::Config{ with_default, is_frame_system: is_frame_system_val, without_automatic_metadata, ..}) if config.is_none() => { + is_frame_system = is_frame_system_val; config = Some(config::ConfigDef::try_from( &frame_system, index, @@ -119,7 +122,8 @@ impl Def { with_default, without_automatic_metadata, is_frame_system, - )?), + )?); + }, Some(PalletAttr::Pallet(span)) if pallet_struct.is_none() => { let p = pallet_struct::PalletStructDef::try_from(span, index, item)?; pallet_struct = Some(p); @@ -258,10 +262,10 @@ impl Def { frame_support, dev_mode, view_functions, + is_frame_system, }; def.check_instance_usage()?; - def.check_event_usage()?; Ok(def) } @@ -359,32 +363,6 @@ impl Def { Ok(()) } - /// Check that usage of trait `Event` is consistent with the definition, i.e. it is declared - /// and trait defines type or type bound `RuntimeEvent`, or not declared and no trait associated - /// type. - fn check_event_usage(&self) -> syn::Result<()> { - match (self.config.has_event_type, self.config.has_event_bound, self.event.is_some()) { - (true, false, false) => { - let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent`, \ - but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ - Note that type `RuntimeEvent` in trait is reserved to work alongside pallet event."; - Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) - }, - (false, true, false) => { - let msg = "Invalid usage of `RuntimeEvent`, `frame_system::Config` contains associated type bound `RuntimeEvent`, \ - but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ - Note that type associated type bound `RuntimeEvent` in trait is reserved to work alongside pallet event."; - Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) - }, - (true, true, _) => { - let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent` and associated type bound `RuntimeEvent`. \ - Only one of them should be used."; - Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) - }, - _ => Ok(()), - } - } - /// Check that usage of trait `Config` is consistent with the definition, i.e. it is used with /// instance iff it is defined with instance. fn check_instance_usage(&self) -> syn::Result<()> { diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index 8541d49464031..cc251b48e57ac 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -1345,9 +1345,7 @@ pub mod pallet_macros { /// pub struct Pallet(_); /// # /// # #[pallet::config] - /// # pub trait Config: frame_system::Config { - /// # #[allow(deprecated)] - /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// # pub trait Config: frame_system::Config>> { /// # } /// } /// ``` @@ -1484,12 +1482,6 @@ pub mod pallet_macros { /// optionally other supertraits and a where clause. (Specifying other supertraits here is /// known as [tight coupling](https://docs.substrate.io/reference/how-to-guides/pallet-design/use-tight-coupling/)) /// - /// The associated type `RuntimeEvent` is reserved. If defined, it must have the bounds - /// `From` and `IsType<::RuntimeEvent>`. - /// - /// [`#[pallet::event]`](`event`) must be present if `RuntimeEvent` - /// exists as a config item in your `#[pallet::config]`. - /// /// ## Optional: `with_default` /// /// An optional `with_default` argument may also be specified. Doing so will automatically @@ -1512,11 +1504,6 @@ pub mod pallet_macros { /// /// #[pallet::config(with_default)] // <- with_default is optional /// pub trait Config: frame_system::Config { - /// /// The overarching event type. - /// #[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeEvent - /// #[allow(deprecated)] - /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// /// /// A more complex type. /// #[pallet::no_default] // Example of type where no default should be provided /// type MoreComplexType: SomeMoreComplexBound; @@ -1598,20 +1585,17 @@ pub mod pallet_macros { /// #[pallet::pallet] /// pub struct Pallet(_); /// - /// #[pallet::config(with_default, without_automatic_metadata)] // <- with_default and - /// without_automatic_metadata are optional pub trait Config: frame_system::Config { - /// /// The overarching event type. - /// #[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeEvent - /// #[allow(deprecated)] - /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// + /// #[pallet::config(with_default, without_automatic_metadata)] // <- with_default and without_automatic_metadata are optional + /// pub trait Config: frame_system::Config { + /// /// The overarching freeze reason. + /// #[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeFreezeReason + /// type RuntimeFreezeReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount; /// /// A simple type. /// // Type that would have been included in metadata, but is now excluded. /// type SimpleType: From + TypeInfo; /// - /// // The `pallet::include_metadata` is used to selectively include this type in - /// metadata. #[pallet::include_metadata] + /// // The `pallet::include_metadata` is used to selectively include this type in metadata. + /// #[pallet::include_metadata] /// type SelectivelyInclude: From + TypeInfo; /// } /// @@ -2049,21 +2033,18 @@ pub mod pallet_macros { /// /// SomeEvent doc /// SomeEvent(u16, u32), // SomeEvent with two fields /// } - /// - /// #[pallet::config] - /// pub trait Config: frame_system::Config { - /// /// The overarching runtime event type. - /// #[allow(deprecated)] - /// type RuntimeEvent: From> - /// + IsType<::RuntimeEvent>; - /// } /// } /// ``` /// /// I.e. an enum (with named or unnamed fields variant), named `Event`, with generic: none /// or `T` or `T: Config`, and optional w here clause. /// - /// `RuntimeEvent` must be defined in the `Config`, as shown in the example. + /// Macro expansion automatically appends `From>` bound to + /// system supertrait's `RuntimeEvent `associated type, i.e: + /// + /// ```rs + /// pub trait Config: frame_system::Config>> {} + /// ``` /// /// Each field must implement [`Clone`], [`Eq`], [`PartialEq`], [`codec::Encode`], /// [`codec::Decode`], and [`Debug`] (on std only). For ease of use, bound by the trait diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 8447a7b66096e..348611420da1d 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -470,7 +470,6 @@ pub mod pallet { pub trait Config: 'static + Eq + Clone { /// The aggregated event type of the runtime. #[pallet::no_default_bounds] - #[allow(deprecated)] type RuntimeEvent: Parameter + Member + From> From 18ce0f379c29614300f166cc78ff57a4006286a0 Mon Sep 17 00:00:00 2001 From: dastansam Date: Sun, 16 Feb 2025 13:57:36 +0600 Subject: [PATCH 10/12] Fix doc tests --- substrate/frame/support/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index cc251b48e57ac..f153ede6a83a7 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -1578,7 +1578,7 @@ pub mod pallet_macros { /// # use frame_support::pallet_prelude::*; /// # use frame_system::pallet_prelude::*; /// # use core::fmt::Debug; - /// # use frame_support::traits::Contains; + /// # use frame_support::traits::{Contains, VariantCount}; /// # /// # pub trait SomeMoreComplexBound {} /// # @@ -2027,6 +2027,9 @@ pub mod pallet_macros { /// #[pallet::pallet] /// pub struct Pallet(_); /// + /// #[pallet::config] + /// pub trait Config: frame_system::Config {} + /// /// #[pallet::event] /// #[pallet::generate_deposit(fn deposit_event)] // Optional /// pub enum Event { @@ -2043,6 +2046,7 @@ pub mod pallet_macros { /// system supertrait's `RuntimeEvent `associated type, i.e: /// /// ```rs + /// #[pallet::config] /// pub trait Config: frame_system::Config>> {} /// ``` /// From 06c4b3daf3a7ce2e35b17ee3548350ad46818aae Mon Sep 17 00:00:00 2001 From: dastansam Date: Sun, 16 Feb 2025 15:47:04 +0600 Subject: [PATCH 11/12] Remove old frame ui tests, add new ones --- ...2.rs => event_deprecated_runtime_event.rs} | 5 +- .../event_deprecated_runtime_event.stderr | 24 ++++++++++ .../tests/pallet_ui/event_field_not_member.rs | 2 - .../pallet_ui/event_field_not_member.stderr | 12 ++--- .../tests/pallet_ui/event_not_in_trait.rs | 44 ------------------ .../tests/pallet_ui/event_not_in_trait.stderr | 7 --- .../pallet_ui/event_type_invalid_bound.rs | 44 ------------------ .../pallet_ui/event_type_invalid_bound.stderr | 5 -- .../event_type_invalid_bound_2.stderr | 5 -- ...event_type_invalid_bound_no_frame_crate.rs | 46 ------------------- ...t_type_invalid_bound_no_frame_crate.stderr | 5 -- ...ent_type_bound_system_config_assoc_type.rs | 6 +-- 12 files changed, 35 insertions(+), 170 deletions(-) rename substrate/frame/support/test/tests/pallet_ui/{event_type_invalid_bound_2.rs => event_deprecated_runtime_event.rs} (93%) create mode 100644 substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.stderr delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.rs delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs delete mode 100644 substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.stderr diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs b/substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.rs similarity index 93% rename from substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs rename to substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.rs index b811cae0acabc..7e597106ba41f 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs +++ b/substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.rs @@ -22,9 +22,8 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type Bar; - #[allow(deprecated)] - type RuntimeEvent: IsType<::RuntimeEvent>; + type Bar: Clone + PartialEq + std::fmt::Debug; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] diff --git a/substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.stderr b/substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.stderr new file mode 100644 index 0000000000000..7931d55a1a16f --- /dev/null +++ b/substrate/frame/support/test/tests/pallet_ui/event_deprecated_runtime_event.stderr @@ -0,0 +1,24 @@ +error: unused import: `event` + --> tests/pallet_ui/event_deprecated_runtime_event.rs:38:12 + | +38 | #[pallet::event] + | ^^^^^ + | + = note: `-D unused-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unused_imports)]` + +error: use of deprecated constant `pallet::RuntimeEvent::_w`: + It is deprecated to have `RuntimeEvent` associated type in the pallet config. + Please instead remove it as it is redundant since associated bound gets appended automatically: + + pub trait Config: frame_system::Config>> { }. + + For more info see: + + --> tests/pallet_ui/event_deprecated_runtime_event.rs:26:8 + | +26 | type RuntimeEvent: IsType<::RuntimeEvent> + From>; + | ^^^^^^^^^^^^ + | + = note: `-D deprecated` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(deprecated)]` diff --git a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs index ed84060a1aa81..8e46895ace15f 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs +++ b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.rs @@ -24,8 +24,6 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - #[allow(deprecated)] - type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] diff --git a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr index e9c2eae686baf..e1a3292bf55c7 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr @@ -1,19 +1,19 @@ error[E0277]: the trait bound `::Bar: Clone` is not satisfied - --> tests/pallet_ui/event_field_not_member.rs:41:7 + --> tests/pallet_ui/event_field_not_member.rs:40:7 | -41 | B { b: T::Bar }, +40 | B { b: T::Bar }, | ^ the trait `Clone` is not implemented for `::Bar` error[E0369]: binary operation `==` cannot be applied to type `&::Bar` - --> tests/pallet_ui/event_field_not_member.rs:41:7 + --> tests/pallet_ui/event_field_not_member.rs:40:7 | -41 | B { b: T::Bar }, +40 | B { b: T::Bar }, | ^ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` - --> tests/pallet_ui/event_field_not_member.rs:41:7 + --> tests/pallet_ui/event_field_not_member.rs:40:7 | -41 | B { b: T::Bar }, +40 | B { b: T::Bar }, | ^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `std::fmt::Debug` is not implemented for `::Bar`, which is required by `&::Bar: std::fmt::Debug` diff --git a/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.rs b/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.rs deleted file mode 100644 index 405faeb6de050..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.rs +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[frame_support::pallet] -mod pallet { - use frame_support::pallet_prelude::Hooks; - use frame_system::pallet_prelude::BlockNumberFor; - - #[pallet::config] - pub trait Config: frame_system::Config { - type Bar; - } - - #[pallet::pallet] - pub struct Pallet(core::marker::PhantomData); - - #[pallet::hooks] - impl Hooks> for Pallet {} - - #[pallet::call] - impl Pallet {} - - #[pallet::event] - pub enum Event { - B { b: T::Bar }, - } -} - -fn main() { -} diff --git a/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr b/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr deleted file mode 100644 index eef17ffab4fef..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`. - --> tests/pallet_ui/event_not_in_trait.rs:18:1 - | -18 | #[frame_support::pallet] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs deleted file mode 100644 index 34b563ffb6433..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[frame_support::pallet] -mod pallet { - use frame_support::pallet_prelude::Hooks; - use frame_system::pallet_prelude::BlockNumberFor; - - #[pallet::config] - pub trait Config: frame_system::Config { - type Bar; - type RuntimeEvent; - } - - #[pallet::pallet] - pub struct Pallet(core::marker::PhantomData); - - #[pallet::hooks] - impl Hooks> for Pallet {} - - #[pallet::call] - impl Pallet {} - - #[pallet::event] - pub enum Event { - B { b: T::Bar }, - } -} - -fn main() {} diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr deleted file mode 100644 index e9e4c1269f29d..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `IsType<::RuntimeEvent>` - --> tests/pallet_ui/event_type_invalid_bound.rs:26:3 - | -26 | type RuntimeEvent; - | ^^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr deleted file mode 100644 index 436a8651bb80d..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `From` or `From>` or `From>` - --> tests/pallet_ui/event_type_invalid_bound_2.rs:26:3 - | -26 | type RuntimeEvent: IsType<::RuntimeEvent>; - | ^^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs deleted file mode 100644 index 81bfa33105d94..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[frame_support::pallet] -mod pallet { - use frame_support::pallet_prelude::{Hooks, IsType}; - use polkadot_sdk_frame::deps::frame_system::pallet_prelude::BlockNumberFor; - - #[pallet::config] - pub trait Config: polkadot_sdk_frame::deps::frame_system::Config { - type Bar: Clone + std::fmt::Debug + Eq; - #[allow(deprecated)] - type RuntimeEvent: IsType<::RuntimeEvent> - + From>; - } - - #[pallet::pallet] - pub struct Pallet(core::marker::PhantomData); - - #[pallet::hooks] - impl Hooks> for Pallet {} - - #[pallet::call] - impl Pallet {} - - #[pallet::event] - pub enum Event { - B { b: T::Bar }, - } -} - -fn main() {} diff --git a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.stderr b/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.stderr deleted file mode 100644 index 384e44d97a617..0000000000000 --- a/substrate/frame/support/test/tests/pallet_ui/event_type_invalid_bound_no_frame_crate.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `IsType<::RuntimeEvent>` - --> tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs:26:3 - | -26 | type RuntimeEvent: IsType<::RuntimeEvent> - | ^^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs index 835b0fce5957a..a640830921443 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs @@ -22,10 +22,10 @@ mod pallet { use frame_system::pallet_prelude::BlockNumberFor; #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: + frame_system::Config>> + { type Bar: Clone + std::fmt::Debug + Eq; - #[allow(deprecated)] - type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] From 80c7c93315f9dd36993b8fc936b7d17ea9228445 Mon Sep 17 00:00:00 2001 From: dastansam Date: Mon, 17 Feb 2025 10:25:17 +0600 Subject: [PATCH 12/12] Some minor fixes --- .../frame/support/procedural/src/pallet/expand/config.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/substrate/frame/support/procedural/src/pallet/expand/config.rs b/substrate/frame/support/procedural/src/pallet/expand/config.rs index ebe54e6aad2ac..b70f7cebb0674 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/config.rs @@ -52,8 +52,7 @@ Consequently, a runtime that wants to include this pallet must implement this tr // associated type nor type bound is defined. if let Some(event) = &def.event { if !def.is_frame_system { - let frame_system = crate::generate_access_from_frame_or_crate("frame-system") - .expect("should have access to frame-system"); + let frame_system = &def.frame_system; // can't use `type_use_gen()` since it returns `T`, not `Self` let event_use_gen = match event.gen_kind { @@ -156,7 +155,6 @@ pub fn expand_config_metadata(def: &Def) -> proc_macro2::TokenStream { }); quote::quote!( - #[allow(deprecated)] impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause { #[doc(hidden)]