diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index 86a64caaf8..6c034454cf 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -401,19 +401,13 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub fellows: Vec, pub allies: Vec, pub phantom: PhantomData<(T, I)>, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { fellows: Vec::new(), allies: Vec::new(), phantom: Default::default() } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 33aacd9323..e9259f4b67 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -369,6 +369,7 @@ pub mod pallet { >; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { /// Genesis assets: id, owner, is_sufficient, min_balance pub assets: Vec<(T::AssetId, T::AccountId, bool, T::Balance)>, @@ -378,17 +379,6 @@ pub mod pallet { pub accounts: Vec<(T::AssetId, T::AccountId, T::Balance)>, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { - assets: Default::default(), - metadata: Default::default(), - accounts: Default::default(), - } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/aura/src/lib.rs b/substrate/frame/aura/src/lib.rs index 108b9303b3..12b7ee3f5f 100644 --- a/substrate/frame/aura/src/lib.rs +++ b/substrate/frame/aura/src/lib.rs @@ -129,17 +129,11 @@ pub mod pallet { pub(super) type CurrentSlot = StorageValue<_, Slot, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub authorities: Vec, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { authorities: Vec::new() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/authority-discovery/src/lib.rs b/substrate/frame/authority-discovery/src/lib.rs index 341646b674..6365c95359 100644 --- a/substrate/frame/authority-discovery/src/lib.rs +++ b/substrate/frame/authority-discovery/src/lib.rs @@ -59,7 +59,7 @@ pub mod pallet { pub(super) type NextKeys = StorageValue<_, WeakBoundedVec, ValueQuery>; - #[cfg_attr(feature = "std", derive(Default))] + #[derive(Default)] #[pallet::genesis_config] pub struct GenesisConfig { pub keys: Vec, diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 15580457c9..8001450b43 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -314,7 +314,7 @@ pub mod pallet { pub(super) type SkippedEpochs = StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>; - #[cfg_attr(feature = "std", derive(Default))] + #[derive(Default)] #[pallet::genesis_config] pub struct GenesisConfig { pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index b3dc77a9b8..7ed725a77d 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -456,7 +456,6 @@ pub mod pallet { pub balances: Vec<(T::AccountId, T::Balance)>, } - #[cfg(feature = "std")] impl, I: 'static> Default for GenesisConfig { fn default() -> Self { Self { balances: Default::default() } @@ -483,7 +482,7 @@ pub mod pallet { .iter() .map(|(x, _)| x) .cloned() - .collect::>(); + .collect::>(); assert!( endowed_accounts.len() == self.balances.len(), diff --git a/substrate/frame/beefy/src/lib.rs b/substrate/frame/beefy/src/lib.rs index 945b32c12f..6a248da2bf 100644 --- a/substrate/frame/beefy/src/lib.rs +++ b/substrate/frame/beefy/src/lib.rs @@ -166,7 +166,6 @@ pub mod pallet { pub genesis_block: Option>, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { // BEEFY genesis will be first BEEFY-MANDATORY block, diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index fd89a998ad..12917f5bd6 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -224,18 +224,12 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub phantom: PhantomData, pub members: Vec, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { phantom: Default::default(), members: Default::default() } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index 69438eba91..370559b10a 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -439,17 +439,11 @@ pub mod pallet { pub type MetadataOf = StorageMap<_, Blake2_128Concat, MetadataOwner, PreimageHash>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { _phantom: sp_std::marker::PhantomData, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { _phantom: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index 9c40e542e1..1d7c79fe3c 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -711,17 +711,11 @@ pub mod pallet { StorageMap<_, Twox64Concat, T::AccountId, Voter>, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub members: Vec<(T::AccountId, BalanceOf)>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { members: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/examples/basic/src/lib.rs b/substrate/frame/examples/basic/src/lib.rs index bbeaac19f8..af159c0f4b 100644 --- a/substrate/frame/examples/basic/src/lib.rs +++ b/substrate/frame/examples/basic/src/lib.rs @@ -618,20 +618,13 @@ pub mod pallet { // The genesis config type. #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub dummy: T::Balance, pub bar: Vec<(T::AccountId, T::Balance)>, pub foo: T::Balance, } - // The default value for the genesis config type. - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { dummy: Default::default(), bar: Default::default(), foo: Default::default() } - } - } - // The build of genesis for the pallet. #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { diff --git a/substrate/frame/grandpa/src/lib.rs b/substrate/frame/grandpa/src/lib.rs index f01c25e49e..8311131e97 100644 --- a/substrate/frame/grandpa/src/lib.rs +++ b/substrate/frame/grandpa/src/lib.rs @@ -333,7 +333,7 @@ pub mod pallet { #[pallet::getter(fn session_for_set)] pub(super) type SetIdSession = StorageMap<_, Twox64Concat, SetId, SessionIndex>; - #[cfg_attr(feature = "std", derive(Default))] + #[derive(Default)] #[pallet::genesis_config] pub struct GenesisConfig { pub authorities: AuthorityList, diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index bc1e541cef..dd3809f8e9 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -442,17 +442,11 @@ pub mod pallet { >; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub keys: Vec, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { keys: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/indices/src/lib.rs b/substrate/frame/indices/src/lib.rs index 74f86abb51..56e177da31 100644 --- a/substrate/frame/indices/src/lib.rs +++ b/substrate/frame/indices/src/lib.rs @@ -263,17 +263,11 @@ pub mod pallet { StorageMap<_, Blake2_128Concat, T::AccountIndex, (T::AccountId, BalanceOf, bool)>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub indices: Vec<(T::AccountIndex, T::AccountId)>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { indices: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index e703b88f36..74891186a4 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -105,18 +105,12 @@ pub mod pallet { pub type Prime, I: 'static = ()> = StorageValue<_, T::AccountId, OptionQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub members: BoundedVec, pub phantom: PhantomData, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { members: Default::default(), phantom: Default::default() } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/node-authorization/src/lib.rs b/substrate/frame/node-authorization/src/lib.rs index eaeda3cade..6ccc142431 100644 --- a/substrate/frame/node-authorization/src/lib.rs +++ b/substrate/frame/node-authorization/src/lib.rs @@ -109,17 +109,11 @@ pub mod pallet { StorageMap<_, Blake2_128Concat, PeerId, BTreeSet, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub nodes: Vec<(PeerId, T::AccountId)>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { nodes: Vec::new() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 78f0c730ce..cc68f54bd5 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -1659,7 +1659,6 @@ pub mod pallet { pub global_max_commission: Option, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { diff --git a/substrate/frame/scored-pool/src/lib.rs b/substrate/frame/scored-pool/src/lib.rs index 8bd44e2ffa..f8fc0fecd4 100644 --- a/substrate/frame/scored-pool/src/lib.rs +++ b/substrate/frame/scored-pool/src/lib.rs @@ -249,18 +249,12 @@ pub mod pallet { pub(crate) type MemberCount = StorageValue<_, u32, ValueQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub pool: PoolT, pub member_count: u32, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { pool: Default::default(), member_count: Default::default() } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index a9f89412a7..1219aaaf12 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -414,17 +414,11 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub keys: Vec<(T::AccountId, T::ValidatorId, T::Keys)>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { keys: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index 899b6005af..d92bee48d6 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -643,23 +643,13 @@ pub mod pallet { } #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub pot: BalanceOf, pub members: Vec, pub max_members: u32, } - #[cfg(feature = "std")] - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - Self { - pot: Default::default(), - members: Default::default(), - max_members: Default::default(), - } - } - } - #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index c5c9c669d2..2b33573ac2 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -579,6 +579,7 @@ pub mod pallet { pub(crate) type ChillThreshold = StorageValue<_, Percent, OptionQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub validator_count: u32, pub minimum_validator_count: u32, @@ -594,25 +595,6 @@ pub mod pallet { pub max_nominator_count: Option, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { - validator_count: Default::default(), - minimum_validator_count: Default::default(), - invulnerables: Default::default(), - force_era: Default::default(), - slash_reward_fraction: Default::default(), - canceled_payout: Default::default(), - stakers: Default::default(), - min_nominator_bond: Default::default(), - min_validator_bond: Default::default(), - max_validator_count: None, - max_nominator_count: None, - } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/sudo/src/lib.rs b/substrate/frame/sudo/src/lib.rs index a35b870ed6..50eb83810d 100644 --- a/substrate/frame/sudo/src/lib.rs +++ b/substrate/frame/sudo/src/lib.rs @@ -282,18 +282,12 @@ pub mod pallet { pub(super) type Key = StorageValue<_, T::AccountId, OptionQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { /// The `AccountId` of the sudo key. pub key: Option, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { key: None } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { diff --git a/substrate/frame/support/procedural/src/pallet/expand/genesis_config.rs b/substrate/frame/support/procedural/src/pallet/expand/genesis_config.rs index 7c66ef7d35..de46afecf3 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/genesis_config.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/genesis_config.rs @@ -94,15 +94,24 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream { "] )); } - attrs.push(syn::parse_quote!( #[cfg(feature = "std")] )); attrs.push(syn::parse_quote!( - #[derive(#frame_support::Serialize, #frame_support::Deserialize)] + #[cfg_attr(feature = "std", derive(#frame_support::Serialize, #frame_support::Deserialize))] )); - attrs.push(syn::parse_quote!( #[serde(rename_all = "camelCase")] )); - attrs.push(syn::parse_quote!( #[serde(deny_unknown_fields)] )); - attrs.push(syn::parse_quote!( #[serde(bound(serialize = ""))] )); - attrs.push(syn::parse_quote!( #[serde(bound(deserialize = ""))] )); - attrs.push(syn::parse_quote!( #[serde(crate = #serde_crate)] )); + attrs.push( + syn::parse_quote!( #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] ), + ); + attrs.push( + syn::parse_quote!( #[cfg_attr(feature = "std", serde(deny_unknown_fields))] ), + ); + attrs.push( + syn::parse_quote!( #[cfg_attr(feature = "std", serde(bound(serialize = "")))] ), + ); + attrs.push( + syn::parse_quote!( #[cfg_attr(feature = "std", serde(bound(deserialize = "")))] ), + ); + attrs.push( + syn::parse_quote!( #[cfg_attr(feature = "std", serde(crate = #serde_crate))] ), + ); }, _ => unreachable!("Checked by genesis_config parser"), } @@ -126,7 +135,7 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream { stringify!($pallet_name), "` does not have the std feature enabled, this will cause the `", $pallet_path, - "::GenesisConfig` type to be undefined." + "::GenesisConfig` type to not implement serde traits." )); }; } diff --git a/substrate/frame/support/test/pallet/src/lib.rs b/substrate/frame/support/test/pallet/src/lib.rs index 2dfc94d831..f2d0fd7b80 100644 --- a/substrate/frame/support/test/pallet/src/lib.rs +++ b/substrate/frame/support/test/pallet/src/lib.rs @@ -37,7 +37,7 @@ pub mod pallet { pub type Value = StorageValue<_, u32>; #[pallet::genesis_config] - #[cfg_attr(feature = "std", derive(Default))] + #[derive(Default)] pub struct GenesisConfig {} #[pallet::genesis_build] diff --git a/substrate/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr b/substrate/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr index cfc8c9264e..afa210c1ae 100644 --- a/substrate/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr +++ b/substrate/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr @@ -1,4 +1,4 @@ -error: `Pallet` does not have the std feature enabled, this will cause the `test_pallet::GenesisConfig` type to be undefined. +error: `Pallet` does not have the std feature enabled, this will cause the `test_pallet::GenesisConfig` type to not implement serde traits. --> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1 | 40 | / construct_runtime! { @@ -12,7 +12,7 @@ error: `Pallet` does not have the std feature enabled, this will cause the `test | = note: this error originates in the macro `test_pallet::__substrate_genesis_config_check::is_std_enabled_for_genesis` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet` +error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Serialize` is not satisfied --> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1 | 40 | / construct_runtime! { @@ -22,10 +22,109 @@ error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet` ... | 48 | | } 49 | | } - | |_^ not found in `test_pallet` + | |_^ the trait `Serialize` is not implemented for `frame_support_test_pallet::GenesisConfig` | + = help: the following other types implement trait `Serialize`: + &'a T + &'a mut T + () + (T0, T1) + (T0, T1, T2) + (T0, T1, T2, T3) + (T0, T1, T2, T3, T4) + (T0, T1, T2, T3, T4, T5) + and $N others +note: required by a bound in `hidden_include::serde::ser::SerializeStruct::serialize_field` + --> $CARGO/serde-1.0.162/src/ser/mod.rs + | + | T: Serialize; + | ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this struct + +error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied + --> tests/construct_runtime_ui/no_std_genesis_config.rs:47:3 | -1 | use frame_system::GenesisConfig; +47 | Pallet: test_pallet::{Pallet, Config}, + | ^^^^^^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig` | + = help: the following other types implement trait `Deserialize<'de>`: + <&'a [u8] as Deserialize<'de>> + <&'a std::path::Path as Deserialize<'de>> + <&'a str as Deserialize<'de>> + <() as Deserialize<'de>> + <(T0, T1) as Deserialize<'de>> + <(T0, T1, T2) as Deserialize<'de>> + <(T0, T1, T2, T3) as Deserialize<'de>> + <(T0, T1, T2, T3, T4) as Deserialize<'de>> + and $N others +note: required by a bound in `next_element` + --> $CARGO/serde-1.0.162/src/de/mod.rs + | + | T: Deserialize<'de>, + | ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element` + +error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied + --> tests/construct_runtime_ui/no_std_genesis_config.rs:47:3 + | +47 | Pallet: test_pallet::{Pallet, Config}, + | ^^^^^^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig` + | + = help: the following other types implement trait `Deserialize<'de>`: + <&'a [u8] as Deserialize<'de>> + <&'a std::path::Path as Deserialize<'de>> + <&'a str as Deserialize<'de>> + <() as Deserialize<'de>> + <(T0, T1) as Deserialize<'de>> + <(T0, T1, T2) as Deserialize<'de>> + <(T0, T1, T2, T3) as Deserialize<'de>> + <(T0, T1, T2, T3, T4) as Deserialize<'de>> + and $N others +note: required by a bound in `next_value` + --> $CARGO/serde-1.0.162/src/de/mod.rs + | + | V: Deserialize<'de>, + | ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value` + +error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied + --> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1 + | +40 | / construct_runtime! { +41 | | pub struct Runtime where +42 | | Block = Block, +43 | | NodeBlock = Block, +... | +48 | | } +49 | | } + | |_^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig` + | + = help: the following other types implement trait `Deserialize<'de>`: + <&'a [u8] as Deserialize<'de>> + <&'a std::path::Path as Deserialize<'de>> + <&'a str as Deserialize<'de>> + <() as Deserialize<'de>> + <(T0, T1) as Deserialize<'de>> + <(T0, T1, T2) as Deserialize<'de>> + <(T0, T1, T2, T3) as Deserialize<'de>> + <(T0, T1, T2, T3, T4) as Deserialize<'de>> + and $N others +note: required by a bound in `hidden_include::serde::__private::de::missing_field` + --> $CARGO/serde-1.0.162/src/private/de.rs + | + | V: Deserialize<'de>, + | ^^^^^^^^^^^^^^^^ required by this bound in `missing_field` + = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: BuildModuleGenesisStorage` is not satisfied + --> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1 + | +40 | / construct_runtime! { +41 | | pub struct Runtime where +42 | | Block = Block, +43 | | NodeBlock = Block, +... | +48 | | } +49 | | } + | |_^ the trait `BuildModuleGenesisStorage` is not implemented for `frame_support_test_pallet::GenesisConfig` + | + = help: the trait `BuildModuleGenesisStorage` is implemented for `frame_system::GenesisConfig` + = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/substrate/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/substrate/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index f56780c0b0..a5f6b3a109 100644 --- a/substrate/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/substrate/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -28,7 +28,9 @@ error[E0412]: cannot find type `GenesisConfig` in module `pallet` | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this struct +help: consider importing one of these items | 1 | use frame_system::GenesisConfig; | +1 | use test_pallet::GenesisConfig; + | diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 7a97ace736..f3d75f719d 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -630,10 +630,10 @@ pub mod pallet { #[pallet::whitelist_storage] pub(super) type ExecutionPhase = StorageValue<_, Phase>; - #[cfg_attr(feature = "std", derive(Default))] + #[derive(Default)] #[pallet::genesis_config] pub struct GenesisConfig { - #[serde(with = "sp_core::bytes")] + #[cfg_attr(feature = "std", serde(with = "sp_core::bytes"))] pub code: Vec, } diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 83ff69428d..f7bdc23a0b 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -362,7 +362,6 @@ pub mod pallet { pub multiplier: Multiplier, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { multiplier: MULTIPLIER_DEFAULT_VALUE } diff --git a/substrate/frame/transaction-storage/src/lib.rs b/substrate/frame/transaction-storage/src/lib.rs index 59662ee860..b99bc49fc5 100644 --- a/substrate/frame/transaction-storage/src/lib.rs +++ b/substrate/frame/transaction-storage/src/lib.rs @@ -383,7 +383,6 @@ pub mod pallet { pub storage_period: T::BlockNumber, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 450aee51f2..847ff96a7a 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -234,15 +234,9 @@ pub mod pallet { StorageValue<_, BoundedVec, ValueQuery>; #[pallet::genesis_config] + #[derive(Default)] pub struct GenesisConfig; - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self - } - } - #[cfg(feature = "std")] impl GenesisConfig { /// Direct implementation of `GenesisBuild::assimilate_storage`. diff --git a/substrate/frame/vesting/src/lib.rs b/substrate/frame/vesting/src/lib.rs index af36549249..8f98295dd3 100644 --- a/substrate/frame/vesting/src/lib.rs +++ b/substrate/frame/vesting/src/lib.rs @@ -214,17 +214,11 @@ pub mod pallet { pub struct Pallet(_); #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub vesting: Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, BalanceOf)>, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { vesting: Default::default() } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) {