diff --git a/Cargo.lock b/Cargo.lock index 0dd90f3c01848..0b3258defb2a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2921,6 +2921,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "sp-runtime", ] [[package]] diff --git a/bin/node-template/node/src/chain_spec.rs b/bin/node-template/node/src/chain_spec.rs index b28e8140fabc6..2cd2d07293026 100644 --- a/bin/node-template/node/src/chain_spec.rs +++ b/bin/node-template/node/src/chain_spec.rs @@ -136,6 +136,7 @@ fn testnet_genesis( system: SystemConfig { // Add Wasm runtime to storage. code: wasm_binary.to_vec(), + ..Default::default() }, balances: BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. @@ -146,6 +147,7 @@ fn testnet_genesis( }, grandpa: GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), + ..Default::default() }, sudo: SudoConfig { // Assign network admin rights. diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index b4d6905378a5d..487e076feef95 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -4,6 +4,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -55,5 +56,5 @@ impl pallet_template::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index ebbda8baabd8b..a56c4e7b4016e 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -20,11 +20,10 @@ use grandpa_primitives::AuthorityId as GrandpaId; use kitchensink_runtime::{ - constants::currency::*, wasm_binary_unwrap, AuthorityDiscoveryConfig, BabeConfig, - BalancesConfig, Block, CouncilConfig, DemocracyConfig, ElectionsConfig, GluttonConfig, - GrandpaConfig, ImOnlineConfig, IndicesConfig, MaxNominations, NominationPoolsConfig, - SessionConfig, SessionKeys, SocietyConfig, StakerStatus, StakingConfig, SudoConfig, - SystemConfig, TechnicalCommitteeConfig, + constants::currency::*, wasm_binary_unwrap, BabeConfig, BalancesConfig, Block, CouncilConfig, + DemocracyConfig, ElectionsConfig, ImOnlineConfig, IndicesConfig, MaxNominations, + NominationPoolsConfig, SessionConfig, SessionKeys, SocietyConfig, StakerStatus, StakingConfig, + SudoConfig, SystemConfig, TechnicalCommitteeConfig, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use sc_chain_spec::ChainSpecExtension; @@ -295,7 +294,7 @@ pub fn testnet_genesis( const STASH: Balance = ENDOWMENT / 1000; RuntimeGenesisConfig { - system: SystemConfig { code: wasm_binary_unwrap().to_vec() }, + system: SystemConfig { code: wasm_binary_unwrap().to_vec(), ..Default::default() }, balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(), }, @@ -340,12 +339,12 @@ pub fn testnet_genesis( }, sudo: SudoConfig { key: Some(root_key) }, babe: BabeConfig { - authorities: vec![], epoch_config: Some(kitchensink_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() }, im_online: ImOnlineConfig { keys: vec![] }, - authority_discovery: AuthorityDiscoveryConfig { keys: vec![] }, - grandpa: GrandpaConfig { authorities: vec![] }, + authority_discovery: Default::default(), + grandpa: Default::default(), technical_membership: Default::default(), treasury: Default::default(), society: SocietyConfig { pot: 0 }, @@ -365,11 +364,7 @@ pub fn testnet_genesis( min_join_bond: 1 * DOLLARS, ..Default::default() }, - glutton: GluttonConfig { - compute: Default::default(), - storage: Default::default(), - trash_data_count: Default::default(), - }, + glutton: Default::default(), } } diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 8c4a1ed4bbda2..430a1ac2824b8 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -120,7 +120,7 @@ mod multiplier_tests { use sp_runtime::{ assert_eq_error_rate, traits::{Convert, One, Zero}, - FixedPointNumber, + BuildStorage, FixedPointNumber, }; use crate::{ @@ -197,8 +197,8 @@ mod multiplier_tests { where F: Fn() -> (), { - let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default() - .build_storage::() + let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::::default() + .build_storage() .unwrap() .into(); t.execute_with(|| { diff --git a/bin/node/testing/src/genesis.rs b/bin/node/testing/src/genesis.rs index 0514899dfbab8..8063b8ef45708 100644 --- a/bin/node/testing/src/genesis.rs +++ b/bin/node/testing/src/genesis.rs @@ -50,6 +50,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec) -> Run RuntimeGenesisConfig { system: SystemConfig { code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()), + ..Default::default() }, indices: IndicesConfig { indices: vec![] }, balances: BalancesConfig { balances: endowed }, @@ -76,8 +77,12 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec) -> Run invulnerables: vec![alice(), bob(), charlie()], ..Default::default() }, - babe: BabeConfig { authorities: vec![], epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG) }, - grandpa: GrandpaConfig { authorities: vec![] }, + babe: BabeConfig { + authorities: vec![], + epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + grandpa: GrandpaConfig { authorities: vec![], _config: Default::default() }, im_online: Default::default(), authority_discovery: Default::default(), democracy: Default::default(), @@ -100,6 +105,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec) -> Run compute: Default::default(), storage: Default::default(), trash_data_count: Default::default(), + ..Default::default() }, } } diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 6c034454cf7c0..6dec6543babd1 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -405,11 +405,12 @@ pub mod pallet { pub struct GenesisConfig, I: 'static = ()> { pub fellows: Vec, pub allies: Vec, + #[serde(skip)] pub phantom: PhantomData<(T, I)>, } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { for m in self.fellows.iter().chain(self.allies.iter()) { assert!(Pallet::::has_identity(m).is_ok(), "Member does not set identity!"); diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index e1da028f44576..ea6f4e58b1536 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -28,7 +28,7 @@ use sp_std::convert::{TryFrom, TryInto}; pub use frame_support::{ assert_noop, assert_ok, ord_parameter_types, parameter_types, - traits::{EitherOfDiverse, GenesisBuild, SortedMembers}, + traits::{EitherOfDiverse, SortedMembers}, BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -256,7 +256,7 @@ frame_support::construct_runtime!( ); pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![ @@ -274,14 +274,12 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage( - &pallet_alliance::GenesisConfig { - fellows: vec![], - allies: vec![], - phantom: Default::default(), - }, - &mut t, - ) + pallet_alliance::GenesisConfig:: { + fellows: vec![], + allies: vec![], + phantom: Default::default(), + } + .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 34d2eeb273ca8..35c10a22cf454 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -33,8 +33,8 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, + BuildStorage, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -183,7 +183,7 @@ impl Config for Test { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)], diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 2d90fcfecd79e..56d52d708d57f 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -23,6 +23,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -96,5 +97,5 @@ impl pallet_asset_rate::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 4b91f5184299d..363a99701b56a 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -380,7 +380,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { for (id, owner, is_sufficient, min_balance) in &self.assets { assert!(!Asset::::contains_key(id), "Asset id already in use"); diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 09d2bd2296088..7c93e5210015a 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -23,13 +23,14 @@ use crate as pallet_assets; use codec::Encode; use frame_support::{ construct_runtime, parameter_types, - traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, GenesisBuild}, + traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, }; use sp_core::H256; use sp_io::storage; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -41,7 +42,7 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Assets: pallet_assets::{Pallet, Call, Storage, Event}, } @@ -205,7 +206,7 @@ pub(crate) fn take_hooks() -> Vec { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let config: pallet_assets::GenesisConfig = pallet_assets::GenesisConfig { assets: vec![ diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 53ccd64bb2731..7e4d8e97319e7 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -8,6 +8,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -19,7 +20,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event}, } @@ -78,7 +79,7 @@ const A: u64 = 1; const B: u64 = 2; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let genesis = pallet_balances::GenesisConfig:: { balances: vec![(A, 100), (B, 200)] }; genesis.assimilate_storage(&mut t).unwrap(); t.into() diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index e02d24d7c237e..58c85166476f0 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -159,7 +159,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_authorities(&self.authorities); } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 5ae443b4f7685..3fa3bec669593 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -22,13 +22,14 @@ use crate as pallet_aura; use frame_support::{ parameter_types, - traits::{ConstU32, ConstU64, DisabledValidators, GenesisBuild}, + traits::{ConstU32, ConstU64, DisabledValidators}, }; use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::IdentityLookup, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -40,7 +41,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Aura: pallet_aura::{Pallet, Storage, Config}, } @@ -111,7 +112,7 @@ impl pallet_aura::Config for Test { } fn build_ext(authorities: Vec) -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_aura::GenesisConfig:: { authorities: authorities.into_iter().map(|a| UintAuthorityId(a).to_public_key()).collect(), } diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 6365c95359472..2b0c27740c3e6 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -59,14 +59,16 @@ pub mod pallet { pub(super) type NextKeys = StorageValue<_, WeakBoundedVec, ValueQuery>; - #[derive(Default)] + #[derive(frame_support::DefaultNoBound)] #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub keys: Vec, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_keys(&self.keys) } @@ -168,7 +170,7 @@ mod tests { use crate as pallet_authority_discovery; use frame_support::{ parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild}, + traits::{ConstU32, ConstU64}, }; use sp_application_crypto::Pair; use sp_authority_discovery::AuthorityPair; @@ -177,7 +179,7 @@ mod tests { use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, - KeyTypeId, Perbill, + BuildStorage, KeyTypeId, Perbill, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -189,9 +191,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config}, } ); @@ -308,13 +310,11 @@ mod tests { .collect::>(); // Build genesis. - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - GenesisBuild::::assimilate_storage( - &pallet_authority_discovery::GenesisConfig { keys: vec![] }, - &mut t, - ) - .unwrap(); + pallet_authority_discovery::GenesisConfig:: { keys: vec![], ..Default::default() } + .assimilate_storage(&mut t) + .unwrap(); // Create externalities. let mut externalities = TestExternalities::new(t); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 4bb8ba587ac8b..73c631c36f96e 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -106,6 +106,7 @@ mod tests { generic::DigestItem, testing::Header, traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -117,7 +118,7 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Authorship: pallet_authorship::{Pallet, Storage}, } ); @@ -188,7 +189,7 @@ mod tests { } fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); t.into() } diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 8001450b43583..de9fca3b75dd7 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -314,15 +314,17 @@ pub mod pallet { pub(super) type SkippedEpochs = StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>; - #[derive(Default)] + #[derive(frame_support::DefaultNoBound)] #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, pub epoch_config: Option, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { SegmentIndex::::put(0); Pallet::::initialize_genesis_authorities(&self.authorities); diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index ccc24050d53ba..96f9ce4ff8e8d 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -22,7 +22,7 @@ use codec::Encode; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ parameter_types, - traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize}, + traits::{ConstU128, ConstU32, ConstU64, KeyOwnerProofSystem, OnInitialize}, }; use pallet_session::historical as pallet_session_historical; use sp_consensus_babe::{AuthorityId, AuthorityPair, Randomness, Slot, VrfSignature}; @@ -36,7 +36,7 @@ use sp_runtime::{ impl_opaque_keys, testing::{Digest, DigestItem, Header, TestXt}, traits::{Header as _, IdentityLookup, OpaqueKeys}, - Perbill, + BuildStorage, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; @@ -345,7 +345,7 @@ pub fn new_test_ext_with_pairs( } pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index efbb2ed94c49f..f4f29ec35912d 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -21,6 +21,7 @@ use super::*; use crate::{self as bags_list}; use frame_election_provider_support::VoteWeight; use frame_support::parameter_types; +use sp_runtime::BuildStorage; use std::collections::HashMap; pub type AccountId = u32; @@ -94,7 +95,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Storage, Event, Config}, BagsList: bags_list::{Pallet, Call, Storage, Event}, } ); @@ -127,7 +128,7 @@ impl ExtBuilder { pub(crate) fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let ids_with_weight: Vec<_> = if self.skip_genesis_ids { self.ids.iter().collect() diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 4d24f5914f017..206ee371e0737 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -166,8 +166,6 @@ mod types; pub mod weights; use codec::{Codec, MaxEncodedLen}; -#[cfg(feature = "std")] -use frame_support::traits::GenesisBuild; use frame_support::{ ensure, pallet_prelude::DispatchResult, @@ -465,7 +463,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { let total = self.balances.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n); @@ -499,23 +497,6 @@ pub mod pallet { } } - #[cfg(feature = "std")] - impl, I: 'static> GenesisConfig { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build_storage(&self) -> Result { - >::build_storage(self) - } - - /// Direct implementation of `GenesisBuild::assimilate_storage`. - /// - /// Kept in order not to break dependency. - pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { - >::assimilate_storage(self, storage) - } - } - #[pallet::hooks] impl, I: 'static> Hooks for Pallet { #[cfg(not(feature = "insecure_zero_ed"))] diff --git a/frame/balances/src/tests/currency_tests.rs b/frame/balances/src/tests/currency_tests.rs index 0c6ab0dbbaad5..c9ad19f79e36d 100644 --- a/frame/balances/src/tests/currency_tests.rs +++ b/frame/balances/src/tests/currency_tests.rs @@ -666,7 +666,7 @@ fn burn_must_work() { #[should_panic = "the balance of any account should always be at least the existential deposit."] fn cannot_set_genesis_value_below_ed() { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = crate::GenesisConfig:: { balances: vec![(1, 10)] } .assimilate_storage(&mut t) .unwrap(); @@ -675,7 +675,7 @@ fn cannot_set_genesis_value_below_ed() { #[test] #[should_panic = "duplicate balances in genesis."] fn cannot_set_genesis_value_twice() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = crate::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (1, 15)] } .assimilate_storage(&mut t) .unwrap(); diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 6deb9885b79e5..6d9b9217ba0b0 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -40,7 +40,7 @@ use sp_io; use sp_runtime::{ testing::Header, traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, - ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError, + ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError, }; use std::collections::BTreeSet; @@ -78,7 +78,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, } @@ -176,7 +176,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: if self.monied { vec![ diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 31484aaa6be70..8cb20703c63e9 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -21,7 +21,7 @@ use codec::Encode; use frame_support::{ construct_runtime, parameter_types, sp_io::TestExternalities, - traits::{ConstU16, ConstU32, ConstU64, GenesisBuild}, + traits::{ConstU16, ConstU32, ConstU64}, BasicExternalities, }; use sp_consensus_beefy::mmr::MmrLeafVersion; @@ -31,6 +31,7 @@ use sp_runtime::{ impl_opaque_keys, testing::Header, traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, + BuildStorage, }; use crate as pallet_beefy_mmr; @@ -54,7 +55,7 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, Mmr: pallet_mmr::{Pallet, Storage}, Beefy: pallet_beefy::{Pallet, Config, Storage}, @@ -193,7 +194,7 @@ pub fn new_test_ext(ids: Vec) -> TestExternalities { } pub fn new_test_ext_raw_authorities(authorities: Vec<(u64, BeefyId)>) -> TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let session_keys: Vec<_> = authorities .iter() diff --git a/frame/beefy/src/lib.rs b/frame/beefy/src/lib.rs index d56d5b32f8f36..da469c5b9ca02 100644 --- a/frame/beefy/src/lib.rs +++ b/frame/beefy/src/lib.rs @@ -176,7 +176,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize(&self.authorities) // we panic here as runtime maintainers can simply reconfigure genesis and restart diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 270097e346c8f..5ec3bdb7e5593 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -21,9 +21,7 @@ use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ construct_runtime, parameter_types, sp_io::TestExternalities, - traits::{ - ConstU16, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize, - }, + traits::{ConstU16, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize}, BasicExternalities, }; use pallet_session::historical as pallet_session_historical; @@ -34,7 +32,7 @@ use sp_runtime::{ impl_opaque_keys, testing::{Header, TestXt}, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, - Perbill, + BuildStorage, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; @@ -260,7 +258,7 @@ pub fn new_test_ext(ids: Vec) -> TestExternalities { } pub fn new_test_ext_raw_authorities(authorities: Vec) -> TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 27191e37219fd..1112045d9cacc 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -339,7 +339,7 @@ frame_benchmarking::benchmarks! { #[cfg(test)] mod mock { - use sp_runtime::testing::H256; + use sp_runtime::{testing::H256, BuildStorage}; type AccountId = u64; type AccountIndex = u32; @@ -354,7 +354,7 @@ mod mock { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, } ); @@ -391,6 +391,6 @@ mod mock { } pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } } diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index b908925cccd8e..2136dc50b9e6f 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -173,7 +173,7 @@ mod mock { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 25336b6974d9f..a6a9fada9b2aa 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -111,7 +111,7 @@ benchmarks! { #[cfg(test)] pub mod mock { use super::*; - use sp_runtime::testing::H256; + use sp_runtime::{testing::H256, BuildStorage}; type AccountId = u64; type AccountIndex = u32; @@ -126,7 +126,7 @@ pub mod mock { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, } ); @@ -162,7 +162,7 @@ pub mod mock { pub fn new_test_ext() -> sp_io::TestExternalities { use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.register_extension(KeystoreExt::new(MemoryKeystore::new())); diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index c3f51aeb53d5a..0f22360a9431e 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -75,7 +75,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage}, } ); diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 7e02cbf834d08..1741142b17b63 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -85,7 +85,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 9fe34b16029cb..5d47b285f647b 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -23,9 +23,7 @@ use super::*; use crate as pallet_bounties; use frame_support::{ - assert_noop, assert_ok, - pallet_prelude::GenesisBuild, - parameter_types, + assert_noop, assert_ok, parameter_types, traits::{ConstU32, ConstU64, OnInitialize}, PalletId, }; @@ -48,12 +46,12 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Bounties: pallet_bounties::{Pallet, Call, Storage, Event}, Bounties1: pallet_bounties::::{Pallet, Call, Storage, Event}, - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, - Treasury1: pallet_treasury::::{Pallet, Call, Storage, Config, Event}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + Treasury1: pallet_treasury::::{Pallet, Call, Storage, Config, Event}, } ); @@ -412,7 +410,7 @@ fn treasury_account_doesnt_get_deleted() { // This is useful for chain that will just update runtime. #[test] fn inexistent_account_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)] } .assimilate_storage(&mut t) .unwrap(); @@ -1073,7 +1071,7 @@ fn test_migration_v4() { #[test] fn genesis_funding_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let initial_funding = 100; pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. @@ -1081,7 +1079,9 @@ fn genesis_funding_works() { } .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage(&pallet_treasury::GenesisConfig, &mut t).unwrap(); + pallet_treasury::GenesisConfig::::default() + .assimilate_storage(&mut t) + .unwrap(); let mut t: sp_io::TestExternalities = t.into(); t.execute_with(|| { diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index a8f0e16ea2136..2a430b30163de 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -23,9 +23,7 @@ use super::*; use crate as pallet_child_bounties; use frame_support::{ - assert_noop, assert_ok, - pallet_prelude::GenesisBuild, - parameter_types, + assert_noop, assert_ok, parameter_types, traits::{ConstU32, ConstU64, OnInitialize}, weights::Weight, PalletId, @@ -35,7 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - Perbill, Permill, TokenError, + BuildStorage, Perbill, Permill, TokenError, }; use super::Event as ChildBountiesEvent; @@ -50,10 +48,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Bounties: pallet_bounties::{Pallet, Call, Storage, Event}, - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event}, } ); @@ -162,14 +160,16 @@ impl pallet_child_bounties::Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], } .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage(&pallet_treasury::GenesisConfig, &mut t).unwrap(); + pallet_treasury::GenesisConfig::::default() + .assimilate_storage(&mut t) + .unwrap(); t.into() } diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index fc4ab0c4f1bbd..30c4ad09291ff 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -230,12 +230,13 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { + #[serde(skip)] pub phantom: PhantomData, pub members: Vec, } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { use sp_std::collections::btree_set::BTreeSet; let members_set: BTreeSet<_> = self.members.iter().collect(); diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 8d4e0a4a82cd7..a4ec55856e49c 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -21,7 +21,7 @@ use frame_support::{ assert_noop, assert_ok, dispatch::Pays, parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion}, + traits::{ConstU32, ConstU64, StorageVersion}, Hashable, }; use frame_system::{EnsureRoot, EventRecord, Phase}; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f67be602695d6..f11b26bc21689 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -52,7 +52,7 @@ use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, - AccountId32, TokenError, + AccountId32, BuildStorage, TokenError, }; use std::ops::Deref; @@ -65,7 +65,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Randomness: pallet_insecure_randomness_collective_flip::{Pallet, Storage}, @@ -486,7 +486,7 @@ impl ExtBuilder { let env = Env::new().default_filter_or("runtime=debug"); let _ = Builder::from_env(env).is_test(true).try_init(); self.set_associated_consts(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![] } .assimilate_storage(&mut t) .unwrap(); diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 1ea3a56adacb7..8f3451e28b87f 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -27,6 +27,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use super::*; @@ -41,7 +42,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Voting: pallet_conviction_voting::{Pallet, Call, Storage, Event}, } @@ -196,7 +197,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], } diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 87c0de112ac33..ded343d997bdf 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -30,7 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, - DispatchError, DispatchResult, + BuildStorage, DispatchError, DispatchResult, }; use sp_std::cell::RefCell; @@ -46,7 +46,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, CoreFellowship: pallet_core_fellowship::{Pallet, Call, Storage, Event}, } ); @@ -149,7 +149,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| { let params = ParamsType { diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 7ce3bb5611915..690224cc87217 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -441,11 +441,12 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { - _phantom: sp_std::marker::PhantomData, + #[serde(skip)] + _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { PublicPropCount::::put(0 as PropIndex); ReferendumCount::::put(0 as ReferendumIndex); diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index dd726004648ef..dedd13dd33227 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -22,8 +22,8 @@ use crate as pallet_democracy; use frame_support::{ assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::{ - ConstU32, ConstU64, Contains, EqualPrivilegeOnly, GenesisBuild, OnInitialize, - SortedMembers, StorePreimage, + ConstU32, ConstU64, Contains, EqualPrivilegeOnly, OnInitialize, SortedMembers, + StorePreimage, }, weights::Weight, }; @@ -33,7 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; mod cancellation; mod decoders; @@ -60,7 +60,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Preimage: pallet_preimage, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event}, @@ -203,7 +203,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], } diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index cf797aea845f4..6a02e26b27ab3 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -45,7 +45,7 @@ use sp_npos_elections::{ use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - PerU16, + BuildStorage, PerU16, }; use std::sync::Arc; @@ -59,7 +59,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Event, Config}, + System: frame_system::{Pallet, Call, Event, Config}, Balances: pallet_balances::{Pallet, Call, Event, Config}, MultiPhase: multi_phase::{Pallet, Call, Event}, } @@ -574,7 +574,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut storage = - frame_system::GenesisConfig::default().build_storage::().unwrap(); + frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_balances::GenesisConfig:: { balances: vec![ diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 8c641d6137c53..f41f8babd607c 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -18,18 +18,14 @@ #![allow(dead_code)] use _feps::ExtendedBalance; -use frame_support::{ - parameter_types, traits, - traits::{GenesisBuild, Hooks}, - weights::constants, -}; +use frame_support::{parameter_types, traits, traits::Hooks, weights::constants}; use frame_system::EnsureRoot; use sp_core::{ConstU32, Get, H256}; use sp_npos_elections::{ElectionScore, VoteWeight}; use sp_runtime::{ testing, traits::{IdentityLookup, Zero}, - transaction_validity, PerU16, Perbill, + transaction_validity, BuildStorage, PerU16, Perbill, }; use sp_staking::{ offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}, @@ -490,7 +486,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut storage = - frame_system::GenesisConfig::default().build_storage::().unwrap(); + frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_balances::GenesisConfig:: { balances: self.balances_builder.balances } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 7a4fb61970215..501e50c6a7acc 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -721,7 +721,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { assert!( self.members.len() as u32 <= T::DesiredMembers::get(), diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index af159c0f4bc98..adb8e99c6d6a8 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -627,7 +627,7 @@ pub mod pallet { // The build of genesis for the pallet. #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { >::put(&self.dummy); for (a, b) in &self.bar { diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 621d93b97cd01..ae985151e6665 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -44,7 +44,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Example: pallet_example_basic::{Pallet, Call, Storage, Config, Event}, } diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index 8a1ca6628b91c..95e02134eecc5 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -38,7 +38,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Example: pallet_dev_mode::{Pallet, Call, Storage, Event}, } diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index c60e126181a95..c42c7b2ec62e8 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -194,7 +194,7 @@ pub mod pallet { /// Allows you to define how `genesis_configuration is built. #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Foo::::put(self.foo); } diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index 9f1cdda9ea228..a1af5bc6c5f1a 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -33,7 +33,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Kitchensink: pallet_example_kitchensink::{Pallet, Call, Storage, Config, Event}, } diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 3df7f4a8d5439..c0ff46bafcdcc 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Example: example_offchain_worker::{Pallet, Call, Storage, Event, ValidateUnsigned}, } ); diff --git a/frame/examples/split/src/mock.rs b/frame/examples/split/src/mock.rs index e479e821f4262..2e117977c1418 100644 --- a/frame/examples/split/src/mock.rs +++ b/frame/examples/split/src/mock.rs @@ -16,7 +16,7 @@ // limitations under the License. use crate as pallet_template; -use frame_support::derive_impl; +use frame_support::{derive_impl, sp_runtime::BuildStorage}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -52,5 +52,5 @@ impl pallet_template::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 2aed177578a01..61daed626b040 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -689,7 +689,7 @@ mod tests { transaction_validity::{ InvalidTransaction, TransactionValidityError, UnknownTransaction, ValidTransaction, }, - DispatchError, + BuildStorage, DispatchError, }; use frame_support::{ @@ -833,7 +833,7 @@ mod tests { NodeBlock = TestBlock, UncheckedExtrinsic = TestUncheckedExtrinsic { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, Custom: custom::{Pallet, Call, ValidateUnsigned, Inherent}, @@ -972,7 +972,7 @@ mod tests { #[test] fn balance_transfer_dispatch_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 211)] } .assimilate_storage(&mut t) .unwrap(); @@ -1000,7 +1000,7 @@ mod tests { } fn new_test_ext(balance_factor: Balance) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 111 * balance_factor)] } .assimilate_storage(&mut t) .unwrap(); @@ -1008,7 +1008,7 @@ mod tests { } fn new_test_ext_v0(balance_factor: Balance) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 111 * balance_factor)] } .assimilate_storage(&mut t) .unwrap(); diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index ecdbad9ff7745..881f3f0645571 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -23,7 +23,10 @@ use frame_support::{ traits::{ConstU64, Currency}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; -use sp_runtime::traits::{Convert, IdentityLookup}; +use sp_runtime::{ + traits::{Convert, IdentityLookup}, + BuildStorage, +}; use pallet_staking::{Exposure, IndividualExposure, StakerStatus}; use sp_std::prelude::*; @@ -278,7 +281,7 @@ impl ExtBuilder { pub(crate) fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut storage = - frame_system::GenesisConfig::default().build_storage::().unwrap(); + frame_system::GenesisConfig::::default().build_storage().unwrap(); let validators_range = VALIDATOR_PREFIX..VALIDATOR_PREFIX + VALIDATORS_PER_ERA; let nominators_range = diff --git a/frame/glutton/src/lib.rs b/frame/glutton/src/lib.rs index c02a14810d0b2..ae3e4f87f0e80 100644 --- a/frame/glutton/src/lib.rs +++ b/frame/glutton/src/lib.rs @@ -130,14 +130,16 @@ pub mod pallet { #[pallet::genesis_config] #[derive(DefaultNoBound)] - pub struct GenesisConfig { + pub struct GenesisConfig { pub compute: FixedU64, pub storage: FixedU64, pub trash_data_count: u32, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { assert!( self.trash_data_count <= MAX_TRASH_DATA_ENTRIES, diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index f2ce53b206fa8..01fdc1e46a252 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -26,6 +26,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -37,7 +38,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Glutton: pallet_glutton::{Pallet, Event}, } ); @@ -76,7 +77,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 8311131e97347..3348fcce2ca80 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -333,14 +333,16 @@ pub mod pallet { #[pallet::getter(fn session_for_set)] pub(super) type SetIdSession = StorageMap<_, Twox64Concat, SetId, SessionIndex>; - #[derive(Default)] + #[derive(frame_support::DefaultNoBound)] #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub authorities: AuthorityList, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { CurrentSetId::::put(SetId::default()); Pallet::::initialize(&self.authorities) diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 3a13385d35320..d5a54a9fcfd51 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -25,9 +25,7 @@ use codec::Encode; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ parameter_types, - traits::{ - ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize, - }, + traits::{ConstU128, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize}, }; use pallet_session::historical as pallet_session_historical; use sp_consensus_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID}; @@ -38,7 +36,7 @@ use sp_runtime::{ impl_opaque_keys, testing::{Header, TestXt, UintAuthorityId}, traits::{IdentityLookup, OpaqueKeys}, - DigestItem, Perbill, + BuildStorage, DigestItem, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; @@ -257,7 +255,7 @@ pub fn new_test_ext(vec: Vec<(u64, u64)>) -> sp_io::TestExternalities { } pub fn new_test_ext_raw_authorities(authorities: AuthorityList) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 83035c402a7dc..2c0352ac1cea5 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -31,6 +31,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -42,7 +43,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Identity: pallet_identity::{Pallet, Call, Storage, Event}, } @@ -118,7 +119,7 @@ impl pallet_identity::Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (10, 100), (20, 100), (30, 100)], } diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index e1adbc062424f..23785c7b540c6 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -374,7 +374,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_keys(&self.keys); } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 78a86edf54598..141df6569b2ec 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -29,7 +29,7 @@ use sp_core::H256; use sp_runtime::{ testing::{Header, TestXt, UintAuthorityId}, traits::{BlakeTwo256, ConvertInto, IdentityLookup}, - Permill, + BuildStorage, Permill, }; use sp_staking::{ offence::{OffenceError, ReportOffence}, @@ -48,7 +48,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, ImOnline: imonline::{Pallet, Call, Storage, Config, Event}, Historical: pallet_session_historical::{Pallet}, @@ -105,7 +105,7 @@ impl ReportOffence for OffenceHandler { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut result: sp_io::TestExternalities = t.into(); // Set the default keys, otherwise session will discard the validator. result.execute_with(|| { diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index bcc47c0089bb8..3c0b49304131f 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -269,7 +269,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { for (a, b) in &self.indices { >::insert(a, (b, >::zero(), false)) diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index f54e4dfa088dc..c7784092cae4a 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -22,7 +22,7 @@ use crate::{self as pallet_indices, Config}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; -use sp_runtime::testing::Header; +use sp_runtime::{testing::Header, BuildStorage}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -33,7 +33,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Indices: pallet_indices::{Pallet, Call, Storage, Config, Event}, } @@ -91,7 +91,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], } diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index ad39c4c4fd885..883c546f441c2 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -166,6 +166,7 @@ mod tests { use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Header as _, IdentityLookup}, + BuildStorage, }; use frame_support::{ @@ -183,7 +184,7 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, CollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage}, } ); @@ -223,7 +224,7 @@ mod tests { impl pallet_insecure_randomness_collective_flip::Config for Test {} fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); t.into() } diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index d89c9d6890ee2..b0a0d9b916512 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -30,7 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -42,7 +42,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Lottery: pallet_lottery::{Pallet, Call, Storage, Event}, } @@ -116,7 +116,7 @@ pub type SystemCall = frame_system::Call; pub type BalancesCall = pallet_balances::Call; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 74891186a4e22..fd1fe7424f974 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -108,11 +108,12 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub members: BoundedVec, + #[serde(skip)] pub phantom: PhantomData, } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { use sp_std::collections::btree_set::BTreeSet; let members_set: BTreeSet<_> = self.members.iter().collect(); @@ -526,11 +527,12 @@ mod tests { use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + BuildStorage, }; use frame_support::{ assert_noop, assert_ok, bounded_vec, ord_parameter_types, parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion}, + traits::{ConstU32, ConstU64, StorageVersion}, }; use frame_system::EnsureSignedBy; @@ -543,7 +545,7 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Membership: pallet_membership::{Pallet, Call, Storage, Config, Event}, } ); @@ -629,7 +631,7 @@ mod tests { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); // We use default for brevity, but you can configure as desired if needed. pallet_membership::GenesisConfig:: { members: bounded_vec![10, 20, 30], @@ -642,7 +644,7 @@ mod tests { #[cfg(feature = "runtime-benchmarks")] pub(crate) fn new_bench_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } #[cfg(feature = "runtime-benchmarks")] diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index cea426368c35c..2c7b422c62ee3 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -39,7 +39,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, MMR: pallet_mmr::{Pallet, Storage}, } ); diff --git a/frame/merkle-mountain-range/src/tests.rs b/frame/merkle-mountain-range/src/tests.rs index b628b51d2938b..2f02fc09150f6 100644 --- a/frame/merkle-mountain-range/src/tests.rs +++ b/frame/merkle-mountain-range/src/tests.rs @@ -23,9 +23,10 @@ use sp_core::{ H256, }; use sp_mmr_primitives::{mmr_lib::helper, utils, Compact, Proof}; +use sp_runtime::BuildStorage; pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } fn register_offchain_ext(ext: &mut sp_io::TestExternalities) { diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index 9371fa7c7c291..3716597731eca 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -52,7 +52,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index f03ab8130952b..f2a0ca1b494c3 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -31,6 +31,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use sp_std::collections::btree_map::BTreeMap; @@ -43,7 +44,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, } ); @@ -294,7 +295,7 @@ where WeightForCall::take(); QueueChanges::take(); NumMessagesErrored::take(); - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| frame_system::Pallet::::set_block_number(1.into())); ext diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index cc0fbc8098936..e024da22810fc 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -30,7 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - TokenError, + BuildStorage, TokenError, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -42,7 +42,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Multisig: pallet_multisig::{Pallet, Call, Storage, Event}, } @@ -115,7 +115,7 @@ impl Config for Test { use pallet_balances::Call as BalancesCall; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], } diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 62ff3df5b1a0f..c5142c8695b98 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -31,7 +31,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, - MultiSignature, + BuildStorage, MultiSignature, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -184,7 +184,7 @@ impl Config for Test { // Build genesis storage according to the mock runtime. pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 79f0b341e9fd3..8b8c7c6a0fd70 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -29,7 +29,7 @@ use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, - MultiSignature, + BuildStorage, MultiSignature, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -41,7 +41,7 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Nfts: pallet_nfts::{Pallet, Call, Storage, Event}, } @@ -131,7 +131,7 @@ impl Config for Test { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.register_extension(KeystoreExt::new(MemoryKeystore::new())); diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 7a7b33051b22e..9fa7595bdf3f3 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -241,6 +241,7 @@ mod tests { use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -315,7 +316,7 @@ mod tests { } fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10)] } .assimilate_storage(&mut t) .unwrap(); diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 60aa0f756e9c6..0146acabf9fde 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -33,6 +33,7 @@ use sp_core::{ConstU128, H256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -157,7 +158,7 @@ impl pallet_nis::Config for Test { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100)], } @@ -170,7 +171,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { // our desired mockup, but without any balances. #[cfg(feature = "runtime-benchmarks")] pub fn new_test_ext_empty() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } pub fn run_to_block(n: u64) { diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 6ccc142431e61..dec05d0c37058 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -115,7 +115,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Pallet::::initialize_nodes(&self.nodes); } diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index b7c5957e15dee..c0594f1d94424 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -22,13 +22,14 @@ use crate as pallet_node_authorization; use frame_support::{ ord_parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild}, + traits::{ConstU32, ConstU64}, }; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -40,7 +41,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, NodeAuthorization: pallet_node_authorization::{ Pallet, Call, Storage, Config, Event, }, @@ -97,7 +98,7 @@ pub fn test_node(id: u8) -> PeerId { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_node_authorization::GenesisConfig:: { nodes: vec![(test_node(10), 10), (test_node(20), 20), (test_node(30), 30)], } diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 62655690a2d63..5666e7b450acb 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -20,7 +20,7 @@ use frame_election_provider_support::VoteWeight; use frame_support::{pallet_prelude::*, parameter_types, traits::ConstU64, PalletId}; use sp_runtime::{ traits::{Convert, IdentityLookup}, - FixedU128, Perbill, + BuildStorage, FixedU128, Perbill, }; type AccountId = u128; @@ -192,7 +192,7 @@ frame_support::construct_runtime!( ); pub fn new_test_ext() -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_nomination_pools::GenesisConfig:: { min_join_bond: 2, min_create_bond: 2, diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index a356ba529aa44..587fe1b9e8d2a 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -1680,7 +1680,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { MinJoinBond::::put(self.min_join_bond); MinCreateBond::::put(self.min_create_bond); diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 0a404603496ec..ef1240b666101 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -2,7 +2,7 @@ use super::*; use crate::{self as pools}; use frame_support::{assert_ok, parameter_types, PalletId}; use frame_system::RawOrigin; -use sp_runtime::FixedU128; +use sp_runtime::{BuildStorage, FixedU128}; use sp_staking::Stake; pub type BlockNumber = u64; @@ -254,7 +254,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Storage, Event, Config}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Pools: pools::{Pallet, Call, Storage, Event}, } @@ -324,7 +324,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut storage = - frame_system::GenesisConfig::default().build_storage::().unwrap(); + frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = crate::GenesisConfig:: { min_join_bond: MinJoinBondConfig::get(), diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 6d73615c8055b..f7697d534fd57 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -25,7 +25,7 @@ use frame_support::{ }; use sp_runtime::{ traits::{Convert, IdentityLookup}, - FixedU128, Perbill, + BuildStorage, FixedU128, Perbill, }; type AccountId = u128; @@ -206,7 +206,7 @@ frame_support::construct_runtime!( pub fn new_test_ext() -> sp_io::TestExternalities { sp_tracing::try_init_simple(); - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_nomination_pools::GenesisConfig:: { min_join_bond: 2, min_create_bond: 2, diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index d6c1f95117c61..ec64ce13632e3 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -30,6 +30,7 @@ use pallet_session::historical as pallet_session_historical; use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::IdentityLookup, + BuildStorage, }; type AccountId = u64; @@ -235,6 +236,6 @@ frame_support::construct_runtime!( ); pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); sp_io::TestExternalities::new(t) } diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 17480be76c1d8..f719fe6cdd7d2 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -31,7 +31,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; use sp_staking::{ offence::{self, DisableStrategy, Kind, OffenceDetails}, @@ -75,7 +75,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Offences: offences::{Pallet, Storage, Event}, } ); @@ -114,7 +114,7 @@ impl Config for Runtime { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 7c645da2c51d8..d3d891c1d0dc9 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -30,6 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -104,7 +105,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], }; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 54b76413bcff4..ccfeed8cd5693 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -33,6 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -44,7 +45,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Proxy: proxy::{Pallet, Call, Storage, Event}, Utility: pallet_utility::{Pallet, Call, Event}, @@ -174,7 +175,7 @@ use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; type SystemError = frame_system::Error; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 3)], } diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 338dcaacedcf7..fb8dc00e76551 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -29,6 +29,7 @@ use sp_core::{Get, H256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup, ReduceBy}, + BuildStorage, }; use super::*; @@ -44,7 +45,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Club: pallet_ranked_collective::{Pallet, Call, Storage, Event}, } ); @@ -199,7 +200,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 523dd3aa3e8dc..75e5168f13aaa 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -28,6 +28,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -39,7 +40,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Recovery: recovery::{Pallet, Call, Storage, Event}, } @@ -115,7 +116,7 @@ pub type BalancesCall = pallet_balances::Call; pub type RecoveryCall = super::Call; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 1a43257cb94e1..b6b5905709d0d 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -33,7 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup}, - DispatchResult, Perbill, + BuildStorage, DispatchResult, Perbill, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -233,7 +233,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]; pallet_balances::GenesisConfig:: { balances } .assimilate_storage(&mut t) diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 569c383928189..13f20557c6ceb 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -36,7 +36,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Remark: pallet_remark::{ Pallet, Call, Event }, } ); diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 65fd788e05f25..d8a8e597da484 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -21,7 +21,7 @@ use crate as root_offences; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild, Hooks, OneSessionHandler}, + traits::{ConstU32, ConstU64, Hooks, OneSessionHandler}, }; use pallet_staking::StakerStatus; use sp_core::H256; @@ -29,6 +29,7 @@ use sp_runtime::{ curve::PiecewiseLinear, testing::{Header, UintAuthorityId}, traits::{BlakeTwo256, IdentityLookup, Zero}, + BuildStorage, }; use sp_staking::{EraIndex, SessionIndex}; use sp_std::collections::btree_map::BTreeMap; @@ -48,7 +49,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, @@ -244,7 +245,7 @@ impl Default for ExtBuilder { impl ExtBuilder { fn build(self) -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![ diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 7bad2cf77ace5..7ffa819724ba1 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -29,7 +29,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Identity, IdentityLookup}, - DispatchResult, + BuildStorage, DispatchResult, }; use sp_std::cell::RefCell; @@ -45,7 +45,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Salary: pallet_salary::{Pallet, Call, Storage, Event}, } ); @@ -187,7 +187,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 1b0fb8112469c..7a98d8e0db1c6 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -32,7 +32,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; // Logger module to track execution. @@ -102,7 +102,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Logger: logger::{Pallet, Call, Event}, Scheduler: scheduler::{Pallet, Call, Storage, Event}, Preimage: pallet_preimage::{Pallet, Call, Storage, Event}, @@ -225,7 +225,7 @@ impl Config for Test { pub type LoggerCall = logger::Call; pub fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = system::GenesisConfig::::default().build_storage().unwrap(); t.into() } diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index f8fc0fecd492a..6aa64ea64abf0 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -256,7 +256,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { let mut pool = self.pool.clone(); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 83bc939e8230d..e6cfea1bfb281 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -22,13 +22,14 @@ use crate as pallet_scored_pool; use frame_support::{ bounded_vec, construct_runtime, ord_parameter_types, parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild}, + traits::{ConstU32, ConstU64}, }; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -40,7 +41,7 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, ScoredPool: pallet_scored_pool::{Pallet, Call, Storage, Config, Event}, } @@ -140,7 +141,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut balances = vec![]; for i in 1..31 { balances.push((i, 500_000)); diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index d4866a46079af..67c1d95f4707d 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -24,7 +24,7 @@ use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, }; -use sp_runtime::traits::IdentityLookup; +use sp_runtime::{traits::IdentityLookup, BuildStorage}; type AccountId = u64; type AccountIndex = u32; @@ -40,7 +40,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -192,6 +192,6 @@ impl pallet_staking::Config for Test { impl crate::Config for Test {} pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); sp_io::TestExternalities::new(t) } diff --git a/frame/session/src/historical/mod.rs b/frame/session/src/historical/mod.rs index f00a1c95e763e..04129e4eba130 100644 --- a/frame/session/src/historical/mod.rs +++ b/frame/session/src/historical/mod.rs @@ -377,17 +377,17 @@ pub(crate) mod tests { force_new_session, set_next_validators, NextValidators, Session, System, Test, }; - use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId}; + use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId, BuildStorage}; use frame_support::{ - traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize}, + traits::{KeyOwnerProofSystem, OnInitialize}, BasicExternalities, }; type Historical = Pallet; pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let keys: Vec<_> = NextValidators::get() .iter() .cloned() diff --git a/frame/session/src/historical/offchain.rs b/frame/session/src/historical/offchain.rs index 4185788cbbed0..c44eea2f374c0 100644 --- a/frame/session/src/historical/offchain.rs +++ b/frame/session/src/historical/offchain.rs @@ -149,18 +149,18 @@ mod tests { crypto::key_types::DUMMY, offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt, StorageKind}, }; - use sp_runtime::testing::UintAuthorityId; + use sp_runtime::{testing::UintAuthorityId, BuildStorage}; use frame_support::{ - traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize}, + traits::{KeyOwnerProofSystem, OnInitialize}, BasicExternalities, }; type Historical = Pallet; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .expect("Failed to create test externalities."); let keys: Vec<_> = NextValidators::get() diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 1219aaaf12a10..d1d6296e65730 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -420,7 +420,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { if T::SessionHandler::KEY_TYPE_IDS.len() != T::Keys::key_ids().len() { panic!("Number of keys in session handler and session keys does not match"); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index d6b8d9e207e02..3d74c32dcdb25 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -29,12 +29,13 @@ use sp_runtime::{ impl_opaque_keys, testing::{Header, UintAuthorityId}, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use sp_staking::SessionIndex; use frame_support::{ parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild}, + traits::{ConstU32, ConstU64}, BasicExternalities, }; @@ -85,7 +86,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, Historical: pallet_session_historical::{Pallet}, } @@ -98,7 +99,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); @@ -215,7 +216,7 @@ pub fn reset_before_session_end_called() { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let keys: Vec<_> = NextValidators::get() .iter() .cloned() diff --git a/frame/society/src/benchmarking.rs b/frame/society/src/benchmarking.rs index f9cd378b97d3d..20af6e35ada52 100644 --- a/frame/society/src/benchmarking.rs +++ b/frame/society/src/benchmarking.rs @@ -370,7 +370,10 @@ benchmarks_instance_pallet! { impl_benchmark_test_suite!( Society, - sp_io::TestExternalities::from(frame_system::GenesisConfig::default().build_storage::().unwrap()), + sp_io::TestExternalities::from( + as sp_runtime::BuildStorage>::build_storage( + &frame_system::GenesisConfig::default()).unwrap() + ), crate::mock::Test ); } diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 6f42ae00f287d..63d90a0703c4d 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -798,7 +798,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { Pot::::put(self.pot); } diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index ed04aa181e161..1b215febac6c0 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -30,6 +30,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use RuntimeOrigin as Origin; @@ -43,7 +44,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Society: pallet_society::{Pallet, Call, Storage, Event, Config}, } @@ -150,7 +151,7 @@ impl EnvBuilder { } pub fn execute R>(mut self, f: F) -> R { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); self.balances.push((Society::account_id(), self.balance.max(self.pot))); pallet_balances::GenesisConfig:: { balances: self.balances } .assimilate_storage(&mut t) diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 19529ca08735d..2a5edd6e00e56 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -22,8 +22,8 @@ use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight}; use frame_support::{ assert_ok, ord_parameter_types, parameter_types, traits::{ - ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, GenesisBuild, Get, Hooks, - Imbalance, OnUnbalanced, OneSessionHandler, + ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, Get, Hooks, Imbalance, + OnUnbalanced, OneSessionHandler, }, weights::constants::RocksDbWeight, }; @@ -34,6 +34,7 @@ use sp_runtime::{ curve::PiecewiseLinear, testing::{Header, UintAuthorityId}, traits::{IdentityLookup, Zero}, + BuildStorage, }; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; @@ -429,7 +430,7 @@ impl ExtBuilder { } fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_balances::GenesisConfig:: { balances: vec![ diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 0163d6543f2ab..41b8d4b415e1a 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -598,7 +598,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { ValidatorCount::::put(self.validator_count); MinimumValidatorCount::::put(self.minimum_validator_count); diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 05ca21c1de752..c7d4924de1fb9 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1062,7 +1062,7 @@ mod mock { }; use sp_runtime::{ traits::{BlakeTwo256, Header as _, IdentityLookup}, - StorageChild, + BuildStorage, StorageChild, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -1075,7 +1075,7 @@ mod mock { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, StateTrieMigration: pallet_state_trie_migration::{Pallet, Call, Storage, Event}, } @@ -1241,8 +1241,8 @@ mod mock { }; if with_pallets { - frame_system::GenesisConfig::default() - .assimilate_storage::(&mut custom_storage) + frame_system::GenesisConfig::::default() + .assimilate_storage(&mut custom_storage) .unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 1000)] } .assimilate_storage(&mut custom_storage) diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 8b9e7a1a7d965..f2e81b7719021 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -29,7 +29,7 @@ use sp_core::{Pair, H256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - AccountId32, + AccountId32, BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -111,7 +111,7 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = pallet_balances::GenesisConfig:: { balances: vec![ (sp_core::sr25519::Pair::from_string("//Alice", None).unwrap().public().into(), 6000), diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index a41e479b6154d..f735469558c70 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -289,7 +289,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { if let Some(ref key) = self.key { Key::::put(key); diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 856cb35c8718c..4854b006e19d8 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -19,12 +19,13 @@ use super::*; use crate as sudo; -use frame_support::traits::{ConstU32, ConstU64, Contains, GenesisBuild}; +use frame_support::traits::{ConstU32, ConstU64, Contains}; use sp_core::H256; use sp_io; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; // Logger module to track execution. @@ -99,7 +100,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Sudo: sudo::{Pallet, Call, Config, Storage, Event}, Logger: logger::{Pallet, Call, Storage, Event}, } @@ -157,7 +158,7 @@ pub type LoggerCall = logger::Call; // Build test environment by setting the root `key` for the Genesis. pub fn new_test_ext(root_key: u64) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); sudo::GenesisConfig:: { key: Some(root_key) } .assimilate_storage(&mut t) .unwrap(); @@ -166,5 +167,5 @@ pub fn new_test_ext(root_key: u64) -> sp_io::TestExternalities { #[cfg(feature = "runtime-benchmarks")] pub fn new_bench_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/frame/support/procedural/src/construct_runtime/expand/config.rs b/frame/support/procedural/src/construct_runtime/expand/config.rs index 32b8a32a4fe6a..440e856221a36 100644 --- a/frame/support/procedural/src/construct_runtime/expand/config.rs +++ b/frame/support/procedural/src/construct_runtime/expand/config.rs @@ -29,7 +29,7 @@ pub fn expand_outer_config( ) -> TokenStream { let mut types = TokenStream::new(); let mut fields = TokenStream::new(); - let mut build_storage_calls = TokenStream::new(); + let mut genesis_build_calls = TokenStream::new(); let mut query_genesis_config_part_macros = Vec::new(); for decl in pallet_decls { @@ -52,8 +52,8 @@ pub fn expand_outer_config( types.extend(expand_config_types(attr, runtime, decl, &config, part_is_generic)); fields.extend(quote!(#attr pub #field_name: #config,)); - build_storage_calls - .extend(expand_config_build_storage_call(scrate, attr, runtime, decl, field_name)); + genesis_build_calls + .extend(expand_config_build_storage_call(scrate, &config, attr, field_name)); query_genesis_config_part_macros.push(quote! { #path::__substrate_genesis_config_check::is_genesis_config_defined!(#pallet_name); #[cfg(feature = "std")] @@ -67,9 +67,7 @@ pub fn expand_outer_config( #types - #[cfg(any(feature = "std", test))] use #scrate::serde as __genesis_config_serde_import__; - #[cfg(any(feature = "std", test))] #[derive(#scrate::serde::Serialize, #scrate::serde::Deserialize, Default)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] @@ -88,13 +86,17 @@ pub fn expand_outer_config( &self, storage: &mut #scrate::sp_runtime::Storage, ) -> std::result::Result<(), String> { - #build_storage_calls - #scrate::BasicExternalities::execute_with_storage(storage, || { - ::on_genesis(); - }); + ::build(&self); + Ok(()) + }) + } + } - Ok(()) + impl #scrate::traits::BuildGenesisConfig for RuntimeGenesisConfig { + fn build(&self) { + #genesis_build_calls + ::on_genesis(); } } } @@ -112,17 +114,14 @@ fn expand_config_types( match (decl.instance.as_ref(), part_is_generic) { (Some(inst), true) => quote! { #attr - #[cfg(any(feature = "std", test))] pub type #config = #path::GenesisConfig<#runtime, #path::#inst>; }, (None, true) => quote! { #attr - #[cfg(any(feature = "std", test))] pub type #config = #path::GenesisConfig<#runtime>; }, (_, false) => quote! { #attr - #[cfg(any(feature = "std", test))] pub type #config = #path::GenesisConfig; }, } @@ -130,21 +129,12 @@ fn expand_config_types( fn expand_config_build_storage_call( scrate: &TokenStream, + pallet_genesis_config: &Ident, attr: &TokenStream, - runtime: &Ident, - decl: &Pallet, field_name: &Ident, ) -> TokenStream { - let path = &decl.path; - let instance = if let Some(inst) = decl.instance.as_ref() { - quote!(#path::#inst) - } else { - quote!(#path::__InherentHiddenInstance) - }; - quote! { #attr - #scrate::sp_runtime::BuildModuleGenesisStorage:: - <#runtime, #instance>::build_module_genesis_storage(&self.#field_name, storage)?; + <#pallet_genesis_config as #scrate::traits::BuildGenesisConfig>::build(&self.#field_name); } } diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 15b11a1c9698e..ca82a7971aca0 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -1651,8 +1651,7 @@ pub fn genesis_config(_: TokenStream, _: TokenStream) -> TokenStream { /// The macro will add the following attribute: /// * `#[cfg(feature = "std")]` /// -/// The macro will implement `sp_runtime::BuildModuleGenesisStorage` using `()` as a second -/// generic for non-instantiable pallets. +/// The macro will implement `sp_runtime::BuildStorage`. #[proc_macro_attribute] pub fn genesis_build(_: TokenStream, _: TokenStream) -> TokenStream { pallet_macro_stub() diff --git a/frame/support/procedural/src/pallet/expand/genesis_build.rs b/frame/support/procedural/src/pallet/expand/genesis_build.rs index 1c8fb40f1f96e..f54d308fce304 100644 --- a/frame/support/procedural/src/pallet/expand/genesis_build.rs +++ b/frame/support/procedural/src/pallet/expand/genesis_build.rs @@ -18,7 +18,7 @@ use crate::pallet::Def; /// -/// * implement the trait `sp_runtime::BuildModuleGenesisStorage` +/// * implement the trait `sp_runtime::BuildStorage` pub fn expand_genesis_build(def: &mut Def) -> proc_macro2::TokenStream { let genesis_config = if let Some(genesis_config) = &def.genesis_config { genesis_config @@ -28,34 +28,22 @@ pub fn expand_genesis_build(def: &mut Def) -> proc_macro2::TokenStream { let genesis_build = def.genesis_build.as_ref().expect("Checked by def parser"); let frame_support = &def.frame_support; - let type_impl_gen = &def.type_impl_generics(genesis_build.attr_span); - let type_use_gen = &def.type_use_generics(genesis_build.attr_span); - let trait_use_gen = if def.config.has_instance { - quote::quote_spanned!(genesis_build.attr_span => T, I) - } else { - // `__InherentHiddenInstance` used by construct_runtime here is alias for `()` - quote::quote_spanned!(genesis_build.attr_span => T, ()) - }; + let type_impl_gen = &genesis_config.gen_kind.type_impl_gen(genesis_build.attr_span); let gen_cfg_ident = &genesis_config.genesis_config; - - let gen_cfg_use_gen = genesis_config.gen_kind.type_use_gen(genesis_build.attr_span); + let gen_cfg_use_gen = &genesis_config.gen_kind.type_use_gen(genesis_build.attr_span); let where_clause = &genesis_build.where_clause; quote::quote_spanned!(genesis_build.attr_span => #[cfg(feature = "std")] - impl<#type_impl_gen> #frame_support::sp_runtime::BuildModuleGenesisStorage<#trait_use_gen> - for #gen_cfg_ident<#gen_cfg_use_gen> #where_clause - { - fn build_module_genesis_storage( - &self, - storage: &mut #frame_support::sp_runtime::Storage, - ) -> std::result::Result<(), std::string::String> { - #frame_support::BasicExternalities::execute_with_storage(storage, || { - >::build(self); - Ok(()) - }) + impl<#type_impl_gen> #frame_support::sp_runtime::BuildStorage for #gen_cfg_ident<#gen_cfg_use_gen> #where_clause + { + fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> std::result::Result<(), std::string::String> { + #frame_support::BasicExternalities::execute_with_storage(storage, || { + self.build(); + Ok(()) + }) + } } - } ) } diff --git a/frame/support/procedural/src/pallet/parse/genesis_build.rs b/frame/support/procedural/src/pallet/parse/genesis_build.rs index 6d356b2ee3844..d0e1d9ec998ec 100644 --- a/frame/support/procedural/src/pallet/parse/genesis_build.rs +++ b/frame/support/procedural/src/pallet/parse/genesis_build.rs @@ -23,7 +23,7 @@ pub struct GenesisBuildDef { /// The index of item in pallet module. pub index: usize, /// A set of usage of instance, must be check for consistency with trait. - pub instances: Vec, + pub instances: Option>, /// The where_clause used. pub where_clause: Option, /// The span of the pallet::genesis_build attribute. @@ -53,7 +53,8 @@ impl GenesisBuildDef { })? .1; - let instances = vec![helper::check_genesis_builder_usage(item_trait)?]; + let instances = + helper::check_genesis_builder_usage(item_trait)?.map(|instances| vec![instances]); Ok(Self { attr_span, index, instances, where_clause: item.generics.where_clause.clone() }) } diff --git a/frame/support/procedural/src/pallet/parse/helper.rs b/frame/support/procedural/src/pallet/parse/helper.rs index 9319248771642..1e6e83d7eeba7 100644 --- a/frame/support/procedural/src/pallet/parse/helper.rs +++ b/frame/support/procedural/src/pallet/parse/helper.rs @@ -23,6 +23,7 @@ mod keyword { syn::custom_keyword!(I); syn::custom_keyword!(compact); syn::custom_keyword!(GenesisBuild); + syn::custom_keyword!(BuildGenesisConfig); syn::custom_keyword!(Config); syn::custom_keyword!(T); syn::custom_keyword!(Pallet); @@ -488,26 +489,32 @@ pub fn check_type_def_gen( /// Check the syntax: /// * either `GenesisBuild` /// * or `GenesisBuild` +/// * or `BuildGenesisConfig` /// -/// return the instance if found. -pub fn check_genesis_builder_usage(type_: &syn::Path) -> syn::Result { +/// return the instance if found for `GenesisBuild` +/// return None for BuildGenesisConfig +pub fn check_genesis_builder_usage(type_: &syn::Path) -> syn::Result> { let expected = "expected `GenesisBuild` or `GenesisBuild`"; - pub struct Checker(InstanceUsage); + pub struct Checker(Option); impl syn::parse::Parse for Checker { fn parse(input: syn::parse::ParseStream) -> syn::Result { let mut instance_usage = InstanceUsage { span: input.span(), has_instance: false }; - input.parse::()?; - input.parse::()?; - input.parse::()?; - if input.peek(syn::Token![,]) { - instance_usage.has_instance = true; - input.parse::()?; - input.parse::()?; + if input.peek(keyword::GenesisBuild) { + input.parse::()?; + input.parse::()?; + input.parse::()?; + if input.peek(syn::Token![,]) { + instance_usage.has_instance = true; + input.parse::()?; + input.parse::()?; + } + input.parse::]>()?; + return Ok(Self(Some(instance_usage))) + } else { + input.parse::()?; + return Ok(Self(None)) } - input.parse::]>()?; - - Ok(Self(instance_usage)) } } diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 4a4602964a996..0f5e5f1136610 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -268,7 +268,7 @@ impl Def { instances.extend_from_slice(&genesis_config.instances[..]); } if let Some(genesis_build) = &self.genesis_build { - instances.extend_from_slice(&genesis_build.instances[..]); + genesis_build.instances.as_ref().map(|i| instances.extend_from_slice(&i)); } if let Some(extra_constants) = &self.extra_constants { instances.extend_from_slice(&extra_constants.instances[..]); diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 2a183b00ee14a..250f15bb36461 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -925,19 +925,25 @@ pub mod tests { >; #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub data: Vec<(u32, u64)>, pub test_config: Vec<(u32, u32, u64)>, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } - impl Default for GenesisConfig { + impl Default for GenesisConfig { fn default() -> Self { - Self { data: vec![(15u32, 42u64)], test_config: vec![(15u32, 16u32, 42u64)] } + Self { + _config: Default::default(), + data: vec![(15u32, 42u64)], + test_config: vec![(15u32, 16u32, 42u64)], + } } } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { for (k, v) in &self.data { >::insert(k, v); @@ -1556,7 +1562,7 @@ pub mod pallet_prelude { }, }, traits::{ - ConstU32, EnsureOrigin, GenesisBuild, Get, GetDefault, GetStorageVersion, Hooks, + BuildGenesisConfig, ConstU32, EnsureOrigin, Get, GetDefault, GetStorageVersion, Hooks, IsType, PalletInfoAccess, StorageInfoTrait, StorageVersion, TypedGet, }, Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity, @@ -2231,7 +2237,7 @@ pub mod pallet_prelude { /// for the pallet. /// /// Item is defined as either an enum or a struct. It needs to be public and implement the -/// trait [`GenesisBuild`](`traits::GenesisBuild`) with +/// trait [`BuildGenesisConfig`](`traits::BuildGenesisConfig`) with /// [`#[pallet::genesis_build]`](#genesis-build-palletgenesis_build-optional). The type /// generics are constrained to be either none, or `T` or `T: Config`. /// @@ -2513,14 +2519,15 @@ pub mod pallet_prelude { /// // /// // Type must implement the `Default` trait. /// #[pallet::genesis_config] -/// #[derive(Default)] -/// pub struct GenesisConfig { +/// #[derive(frame_support::DefaultNoBound)] +/// pub struct GenesisConfig { +/// _config: sp_std::marker::PhantomData, /// _myfield: u32, /// } /// /// // Declare genesis builder. (This is need only if GenesisConfig is declared) /// #[pallet::genesis_build] -/// impl GenesisBuild for GenesisConfig { +/// impl BuildGenesisConfig for GenesisConfig { /// fn build(&self) {} /// } /// @@ -2650,13 +2657,14 @@ pub mod pallet_prelude { /// StorageMap; /// /// #[pallet::genesis_config] -/// #[derive(Default)] -/// pub struct GenesisConfig { +/// #[derive(frame_support::DefaultNoBound)] +/// pub struct GenesisConfig, I: 'static = ()> { +/// _config: sp_std::marker::PhantomData<(T,I)>, /// _myfield: u32, /// } /// /// #[pallet::genesis_build] -/// impl, I: 'static> GenesisBuild for GenesisConfig { +/// impl, I: 'static> BuildGenesisConfig for GenesisConfig { /// fn build(&self) {} /// } /// diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index f34a0b5d87bcf..27396d93487bd 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -80,8 +80,10 @@ pub use metadata::{ }; mod hooks; +#[allow(deprecated)] +pub use hooks::GenesisBuild; pub use hooks::{ - GenesisBuild, Hooks, IntegrityTest, OnFinalize, OnGenesis, OnIdle, OnInitialize, + BuildGenesisConfig, Hooks, IntegrityTest, OnFinalize, OnGenesis, OnIdle, OnInitialize, OnRuntimeUpgrade, OnTimestampSet, }; diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index 7dda6624ffe65..58da1ad569929 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -359,8 +359,19 @@ pub trait Hooks { fn integrity_test() {} } +/// A trait to define the build function of a genesis config for both runtime and pallets. +/// +/// Replaces deprecated [`GenesisBuild`]. +pub trait BuildGenesisConfig: Default + sp_runtime::traits::MaybeSerializeDeserialize { + /// The build function puts initial `GenesisConfig` keys/values pairs into the storage. + fn build(&self); +} + /// A trait to define the build function of a genesis config, T and I are placeholder for pallet /// trait and pallet instance. +#[deprecated( + note = "GenesisBuild is planned to be removed in December 2023. Use BuildGenesisConfig instead of it." +)] pub trait GenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize { /// The build function is called within an externalities allowing storage APIs. /// Thus one can write to storage using regular pallet storages. diff --git a/frame/support/test/pallet/Cargo.toml b/frame/support/test/pallet/Cargo.toml index f2ff334a0438c..bc171c354e6ab 100644 --- a/frame/support/test/pallet/Cargo.toml +++ b/frame/support/test/pallet/Cargo.toml @@ -17,6 +17,7 @@ scale-info = { version = "2.0.0", default-features = false, features = ["derive" serde = { version = "1.0.163", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../system" } +sp-runtime = { version = "24.0.0", default-features = false, path = "../../../../primitives/runtime" } [features] default = ["std"] diff --git a/frame/support/test/pallet/src/lib.rs b/frame/support/test/pallet/src/lib.rs index f2d0fd7b80d8d..49450659285d7 100644 --- a/frame/support/test/pallet/src/lib.rs +++ b/frame/support/test/pallet/src/lib.rs @@ -37,11 +37,14 @@ pub mod pallet { pub type Value = StorageValue<_, u32>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + _config: core::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } diff --git a/frame/support/test/tests/common/outer_enums.rs b/frame/support/test/tests/common/outer_enums.rs index 98139b0f0d1a8..92dc7ac522079 100644 --- a/frame/support/test/tests/common/outer_enums.rs +++ b/frame/support/test/tests/common/outer_enums.rs @@ -52,7 +52,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) {} } @@ -96,7 +96,7 @@ pub mod pallet2 { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) {} } @@ -140,7 +140,7 @@ pub mod pallet3 { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index f91ea6cdf4127..acdaef190b330 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -165,11 +165,14 @@ mod nested { } #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } @@ -234,11 +237,14 @@ pub mod module3 { } #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } @@ -262,8 +268,8 @@ frame_support::construct_runtime!( Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, Module2: module2::{Pallet, Call, Storage, Event, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, - NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, - Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, + NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, + Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, Module1_3: module1::::{Pallet, Storage, Event } = 6, Module1_4: module1::::{Pallet, Call, Event } = 3, Module1_5: module1::::{Pallet, Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs index 7ab4329110d8b..e566f7d458233 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs @@ -7,7 +7,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { #[cfg(test)] - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr index a86a839615aa0..31ae4c987bbe3 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr @@ -1,5 +1,5 @@ error: `System` pallet declaration is feature gated, please remove any `#[cfg]` attributes --> tests/construct_runtime_ui/feature_gated_system_pallet.rs:10:3 | -10 | System: frame_system::{Pallet, Call, Storage, Config, Event}, +10 | System: frame_system::{Pallet, Call, Storage, Config, Event}, | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs index 5dfc67c83836a..577dbf4091048 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet1: pallet::{Pallet}, Pallet2: pallet::{Pallet}, Pallet3: pallet::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 866c3f0de6c3c..3b5773f2c9386 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -77,7 +77,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 0010f5277bb40..a65acf43584c7 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Call}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 28622eb08e443..fdc8a44930666 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, + System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Event}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index f6365ceb1a9cd..c245f65119776 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, + System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Config}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 83179a51abc8f..966d2d119baab 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, + System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Inherent}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index b15a2d3349043..fb712dbf05acc 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, + System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Origin}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index b5573d816eff2..3fb42f9a1ee04 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -52,7 +52,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, ValidateUnsigned}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index 211df67b70056..c2205c5286084 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -23,7 +23,7 @@ error[E0599]: no variant or associated item named `Pallet` found for enum `Runti 51 | || Block = Block, 52 | || NodeBlock = Block, ... || -55 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +55 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, 56 | || Pallet: pallet::{Pallet, ValidateUnsigned}, | || -^^^^^^ variant or associated item not found in `RuntimeCall` | ||________| diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index f56a6c9fcaaa1..164da3ff444a5 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -90,7 +90,7 @@ mod no_instance { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { >::put(self.value); >::put(&self.test_generic_value); @@ -169,7 +169,7 @@ mod instance { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { >::put(self.value); >::put(&self.test_generic_value); diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 291b250c146b2..8ac7bc37e2e72 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -53,7 +53,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { for (k1, k2, v) in &self.t { >::insert(k1, k2, v); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 28611ddbf599c..8d5d49927721f 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -87,7 +87,7 @@ mod module1 { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig + impl, I: 'static> BuildGenesisConfig for GenesisConfig where T::BlockNumber: std::fmt::Display, { @@ -196,7 +196,7 @@ mod module2 { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig + impl, I: 'static> BuildGenesisConfig for GenesisConfig where T::BlockNumber: std::fmt::Display, { diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 3822fea030d15..e6230dfc71018 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -134,14 +134,16 @@ mod module { pub type RequestLifeTime = StorageValue<_, u64, ValueQuery, ConstU64<0>>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig { + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { pub enable_storage_role: bool, pub request_life_time: u64, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { if self.enable_storage_role { >::insert(Role::Storage, >::default()); @@ -187,7 +189,11 @@ frame_support::construct_runtime!( #[test] fn create_genesis_config() { let config = RuntimeGenesisConfig { - module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true }, + module: module::GenesisConfig { + request_life_time: 0, + enable_storage_role: true, + ..Default::default() + }, }; assert_eq!(config.module.request_life_time, 0); assert!(config.module.enable_storage_role); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 47451157b352c..0d9a13c1bd8bc 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -60,11 +60,14 @@ mod nested { } #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } @@ -128,11 +131,14 @@ pub mod module { } #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 5129346acea55..e382176431b21 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -402,13 +402,18 @@ pub mod pallet { pub type Unbounded = StorageValue>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig { + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig + where + T::AccountId: From + SomeAssociation1 + From, + { + #[serde(skip)] + _config: sp_std::marker::PhantomData, _myfield: u32, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig + impl BuildGenesisConfig for GenesisConfig where T::AccountId: From + SomeAssociation1 + From, { @@ -586,7 +591,7 @@ pub mod pallet2 { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig + impl BuildGenesisConfig for GenesisConfig where T::AccountId: From + SomeAssociation1, { diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 03dcc455096e9..ed9ba048cf63c 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -185,13 +185,15 @@ pub mod pallet { >; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig { + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig, I: 'static = ()> { + #[serde(skip)] + _config: sp_std::marker::PhantomData<(T, I)>, _myfield: u32, } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) {} } @@ -281,7 +283,7 @@ pub mod pallet2 { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } diff --git a/frame/support/test/tests/pallet_outer_enums_explicit.rs b/frame/support/test/tests/pallet_outer_enums_explicit.rs index dc98ec43fd933..8c03f7ecf27aa 100644 --- a/frame/support/test/tests/pallet_outer_enums_explicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_explicit.rs @@ -78,7 +78,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { // Exclude part `Storage` in order not to check its metadata in tests. - System: frame_system::{Pallet, Config, Call, Event }, + System: frame_system::{Pallet, Config, Call, Event }, // This pallet exposes the Error type explicitly. Example: common::outer_enums::pallet::{Pallet, Config, Event, Error}, diff --git a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.rs b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.rs index da5e8d0c4da52..a4a0eb832c9c0 100644 --- a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.rs +++ b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.rs @@ -1,6 +1,6 @@ #[frame_support::pallet] mod pallet { - use frame_support::pallet_prelude::{Hooks, GenesisBuild}; + use frame_support::pallet_prelude::{BuildGenesisConfig, Hooks}; use frame_system::pallet_prelude::BlockNumberFor; #[pallet::config] @@ -19,7 +19,7 @@ mod pallet { pub struct GenesisConfig; #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig {} + impl BuildGenesisConfig for GenesisConfig {} } fn main() { diff --git a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr index 04d5b99d0dea5..7245333c9842e 100644 --- a/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr +++ b/frame/support/test/tests/pallet_ui/genesis_default_not_satisfied.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `pallet::GenesisConfig: std::default::Default` is not satisfied - --> tests/pallet_ui/genesis_default_not_satisfied.rs:22:38 + --> tests/pallet_ui/genesis_default_not_satisfied.rs:22:30 | -22 | impl GenesisBuild for GenesisConfig {} - | ^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `pallet::GenesisConfig` +22 | impl BuildGenesisConfig for GenesisConfig {} + | ^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `pallet::GenesisConfig` | -note: required by a bound in `GenesisBuild` +note: required by a bound in `BuildGenesisConfig` --> $WORKSPACE/frame/support/src/traits/hooks.rs | - | pub trait GenesisBuild: Default + sp_runtime::traits::MaybeSerializeDeserialize { - | ^^^^^^^ required by this bound in `GenesisBuild` + | pub trait BuildGenesisConfig: Default + sp_runtime::traits::MaybeSerializeDeserialize { + | ^^^^^^^ required by this bound in `BuildGenesisConfig` help: consider annotating `pallet::GenesisConfig` with `#[derive(Default)]` | 19 + #[derive(Default)] diff --git a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs index 9c9c49c4b2740..7682caf6bf1ce 100644 --- a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs +++ b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs @@ -43,8 +43,8 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Pallet: test_pallet::{Pallet, Config}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Pallet: test_pallet::{Pallet, Config}, } } diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index f74521f3101da..338d0776974ad 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -27,6 +27,7 @@ use frame_support::{ weights::constants::RocksDbWeight, }; use frame_system::Config; +use sp_runtime::BuildStorage; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -48,11 +49,14 @@ mod dummy_pallet { pub type SomeStorage = StorageValue<_, u32, ValueQuery>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig {} + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { + #[serde(skip)] + _config: sp_std::marker::PhantomData, + } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) {} } } @@ -65,8 +69,8 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - DummyPallet: dummy_pallet::{Pallet, Config, Storage} = 1, + System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, + DummyPallet: dummy_pallet::{Pallet, Config, Storage} = 1, } ); @@ -81,7 +85,7 @@ impl frame_system::Config for Test { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext: sp_io::TestExternalities = sp_io::TestExternalities::from(storage); ext.execute_with(|| System::set_block_number(1)); ext diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index e2fed3e51855d..f344e041a0d49 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -21,9 +21,8 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; - #[frame_support::pallet] mod module { use frame_support::pallet_prelude::*; @@ -52,7 +51,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Module: module::{Pallet, Event}, } ); @@ -95,8 +94,8 @@ impl module::Config for Runtime { } fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default() - .build_storage::() + frame_system::GenesisConfig::::default() + .build_storage() .unwrap() .into() } diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 8b05c5a8ba82a..98f8ea6e07ebf 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -20,7 +20,7 @@ #![cfg(test)] use codec::Encode; -use sp_runtime::traits::IdentityLookup; +use sp_runtime::{traits::IdentityLookup, BuildStorage}; type AccountId = u64; type AccountIndex = u32; @@ -35,7 +35,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, } ); @@ -81,7 +81,7 @@ impl sp_core::traits::ReadRuntimeVersion for MockedReadRuntimeVersion { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let version = sp_version::RuntimeVersion { spec_name: "spec_name".into(), diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index cbda3d55cc68c..9fcd7c12fec4e 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -84,6 +84,8 @@ use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; use sp_version::RuntimeVersion; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +#[cfg(feature = "std")] +use frame_support::traits::BuildGenesisConfig; use frame_support::{ dispatch::{ extract_actual_pays_fee, extract_actual_weight, DispatchClass, DispatchInfo, @@ -101,8 +103,6 @@ use scale_info::TypeInfo; use sp_core::storage::well_known_keys; use sp_weights::{RuntimeDbWeight, Weight}; -#[cfg(feature = "std")] -use frame_support::traits::GenesisBuild; #[cfg(any(feature = "std", test))] use sp_io::TestExternalities; @@ -670,15 +670,17 @@ pub mod pallet { #[pallet::whitelist_storage] pub(super) type ExecutionPhase = StorageValue<_, Phase>; - #[derive(Default)] + #[derive(frame_support::DefaultNoBound)] #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { #[serde(with = "sp_core::bytes")] pub code: Vec, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { >::insert::<_, T::Hash>(T::BlockNumber::zero(), hash69()); >::put::(hash69()); @@ -692,26 +694,6 @@ pub mod pallet { } } -#[cfg(feature = "std")] -impl GenesisConfig { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build_storage(&self) -> Result { - >::build_storage(self) - } - - /// Direct implementation of `GenesisBuild::assimilate_storage`. - /// - /// Kept in order not to break dependency. - pub fn assimilate_storage( - &self, - storage: &mut sp_runtime::Storage, - ) -> Result<(), String> { - >::assimilate_storage(self, storage) - } -} - pub type Key = Vec; pub type KeyValue = (Vec, Vec); diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index b484c22ad4fe4..0325c970b8616 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -36,7 +36,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, } ); diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 6f681788236c3..2144322e62128 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -29,6 +29,7 @@ use sp_io::TestExternalities; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -41,7 +42,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, } ); @@ -100,7 +101,7 @@ pub(crate) fn get_captured_moment() -> Option { } pub(crate) fn new_test_ext() -> TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); clear_captured_moment(); TestExternalities::new(t) } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 25043b413db07..4026e54863a32 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -28,9 +28,7 @@ use sp_runtime::{ use sp_storage::Storage; use frame_support::{ - assert_noop, assert_ok, - pallet_prelude::GenesisBuild, - parameter_types, + assert_noop, assert_ok, parameter_types, storage::StoragePrefixedMap, traits::{ConstU32, ConstU64, SortedMembers, StorageVersion}, PalletId, @@ -48,10 +46,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, - Treasury1: pallet_treasury::::{Pallet, Call, Storage, Config, Event}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + Treasury1: pallet_treasury::::{Pallet, Call, Storage, Config, Event}, Tips: pallet_tips::{Pallet, Call, Storage, Event}, Tips1: pallet_tips::::{Pallet, Call, Storage, Event}, } @@ -570,7 +568,7 @@ fn test_migration_v4() { #[test] fn genesis_funding_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let initial_funding = 100; pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. @@ -578,7 +576,9 @@ fn genesis_funding_works() { } .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage(&pallet_treasury::GenesisConfig, &mut t).unwrap(); + pallet_treasury::GenesisConfig::::default() + .assimilate_storage(&mut t) + .unwrap(); let mut t: sp_io::TestExternalities = t.into(); t.execute_with(|| { diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs index 7cd22e305831b..9e9b74a0ddb2e 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs @@ -26,7 +26,7 @@ use frame_system as system; use mock::{ExtrinsicBaseWeight, *}; use pallet_asset_conversion::NativeOrAssetId; use pallet_balances::Call as BalancesCall; -use sp_runtime::traits::StaticLookup; +use sp_runtime::{traits::StaticLookup, BuildStorage}; const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); @@ -65,7 +65,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_constants(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: if self.balance_factor > 0 { vec![ diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 2fee9c849f4b4..8df98ceda9971 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -25,7 +25,7 @@ use frame_support::{ use frame_system as system; use mock::{ExtrinsicBaseWeight, *}; use pallet_balances::Call as BalancesCall; -use sp_runtime::traits::StaticLookup; +use sp_runtime::{traits::StaticLookup, BuildStorage}; const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); @@ -64,7 +64,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_constants(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: if self.balance_factor > 0 { vec![ diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 1ea2dc9f33ebb..bff32456cba4a 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -380,18 +380,20 @@ pub mod pallet { pub(super) type StorageVersion = StorageValue<_, Releases, ValueQuery>; #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub multiplier: Multiplier, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } - impl Default for GenesisConfig { + impl Default for GenesisConfig { fn default() -> Self { - Self { multiplier: MULTIPLIER_DEFAULT_VALUE } + Self { multiplier: MULTIPLIER_DEFAULT_VALUE, _config: Default::default() } } } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { StorageVersion::::put(Releases::V2); NextFeeMultiplier::::put(self.multiplier); diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 28d57065eca18..448079000cab8 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -42,7 +42,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: system::{Pallet, Call, Config, Storage, Event}, + System: system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, } diff --git a/frame/transaction-payment/src/tests.rs b/frame/transaction-payment/src/tests.rs index d5109609e2975..d3a1721ccb990 100644 --- a/frame/transaction-payment/src/tests.rs +++ b/frame/transaction-payment/src/tests.rs @@ -20,12 +20,14 @@ use crate as pallet_transaction_payment; use codec::Encode; -use sp_runtime::{testing::TestXt, traits::One, transaction_validity::InvalidTransaction}; +use sp_runtime::{ + testing::TestXt, traits::One, transaction_validity::InvalidTransaction, BuildStorage, +}; use frame_support::{ assert_noop, assert_ok, dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo}, - traits::{Currency, GenesisBuild}, + traits::Currency, weights::Weight, }; use frame_system as system; @@ -80,7 +82,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_constants(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: if self.balance_factor > 0 { vec![ @@ -99,8 +101,9 @@ impl ExtBuilder { .unwrap(); if let Some(multiplier) = self.initial_multiplier { - let genesis = pallet::GenesisConfig { multiplier }; - GenesisBuild::::assimilate_storage(&genesis, &mut t).unwrap(); + pallet::GenesisConfig:: { multiplier, ..Default::default() } + .assimilate_storage(&mut t) + .unwrap(); } t.into() diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index b99bc49fc5b6f..4004dbd0a435b 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -394,7 +394,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { >::put(&self.byte_fee); >::put(&self.entry_fee); diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 1f8a4e2d09ba8..efabcb97f081d 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -39,7 +39,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, TransactionStorage: pallet_transaction_storage::{ Pallet, Call, Storage, Config, Inherent, Event diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 509ab933430bb..01cda66edbb25 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -234,24 +234,14 @@ pub mod pallet { StorageValue<_, BoundedVec, ValueQuery>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig; - - #[cfg(feature = "std")] - impl GenesisConfig { - /// Direct implementation of `GenesisBuild::assimilate_storage`. - #[deprecated(note = "Will be removed after July 2023; use \ - ` as GenesisBuild>::assimilate_storage` instead")] - pub fn assimilate_storage, I: 'static>( - &self, - storage: &mut sp_runtime::Storage, - ) -> Result<(), String> { - >::assimilate_storage(self, storage) - } + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig, I: 'static = ()> { + #[serde(skip)] + _config: sp_std::marker::PhantomData<(T, I)>, } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { // Create Treasury account let account_id = >::account_id(); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 0659c2f5941b1..e1cbffc2f2a31 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -23,12 +23,11 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}, + BuildStorage, }; use frame_support::{ - assert_err_ignore_postinfo, assert_noop, assert_ok, - pallet_prelude::GenesisBuild, - parameter_types, + assert_err_ignore_postinfo, assert_noop, assert_ok, parameter_types, traits::{ConstU32, ConstU64, OnInitialize}, PalletId, }; @@ -47,9 +46,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Treasury: treasury::{Pallet, Call, Storage, Config, Event}, + Treasury: treasury::{Pallet, Call, Storage, Config, Event}, Utility: pallet_utility, } ); @@ -147,14 +146,14 @@ impl Config for Test { } pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], } .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage(&crate::GenesisConfig, &mut t).unwrap(); + crate::GenesisConfig::::default().assimilate_storage(&mut t).unwrap(); t.into() } @@ -399,7 +398,7 @@ fn treasury_account_doesnt_get_deleted() { // This is useful for chain that will just update runtime. #[test] fn inexistent_account_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)] } .assimilate_storage(&mut t) .unwrap(); @@ -431,7 +430,7 @@ fn inexistent_account_works() { #[test] fn genesis_funding_works() { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let initial_funding = 100; pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. @@ -439,7 +438,7 @@ fn genesis_funding_works() { } .assimilate_storage(&mut t) .unwrap(); - GenesisBuild::::assimilate_storage(&crate::GenesisConfig, &mut t).unwrap(); + crate::GenesisConfig::::default().assimilate_storage(&mut t).unwrap(); let mut t: sp_io::TestExternalities = t.into(); t.execute_with(|| { diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index e783f0b7cf4d9..b975f6bac6a55 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -28,6 +28,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -39,7 +40,7 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Uniques: pallet_uniques::{Pallet, Call, Storage, Event}, } @@ -110,7 +111,7 @@ impl Config for Test { } pub(crate) fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index ced50f828d564..e39820ae251dd 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -27,7 +27,7 @@ use frame_support::{ dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable, Pays}, error::BadOrigin, parameter_types, storage, - traits::{ConstU32, ConstU64, Contains, GenesisBuild}, + traits::{ConstU32, ConstU64, Contains}, weights::Weight, }; use pallet_collective::{EnsureProportionAtLeast, Instance1}; @@ -35,7 +35,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup}, - TokenError, + BuildStorage, TokenError, }; type BlockNumber = u64; @@ -134,7 +134,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Call, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, RootTesting: pallet_root_testing::{Pallet, Call, Storage}, @@ -265,7 +265,7 @@ use pallet_root_testing::Call as RootTestingCall; use pallet_timestamp::Call as TimestampCall; pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], } diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 8f98295dd385a..f19e38d311914 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -220,7 +220,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { use sp_runtime::traits::Saturating; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 31f35bbdab604..d0c25221cd5e9 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -17,12 +17,13 @@ use frame_support::{ parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild, WithdrawReasons}, + traits::{ConstU32, ConstU64, WithdrawReasons}, }; use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, Identity, IdentityLookup}, + BuildStorage, }; use super::*; @@ -37,7 +38,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config}, } @@ -125,7 +126,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![ (1, 10 * self.existential_deposit), diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index d29938d0a8610..e2f890a46b3db 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -199,6 +199,9 @@ pub trait BuildStorage { /// Something that can build the genesis storage of a module. #[cfg(feature = "std")] +#[deprecated( + note = "`BuildModuleGenesisStorage` is planned to be removed in December 2023. Use `BuildStorage` instead of it." +)] pub trait BuildModuleGenesisStorage: Sized { /// Create the module genesis storage into the given `storage` and `child_storage`. fn build_module_genesis_storage( diff --git a/test-utils/runtime/src/genesismap.rs b/test-utils/runtime/src/genesismap.rs index ed27bce0b35b3..97504c232aef5 100644 --- a/test-utils/runtime/src/genesismap.rs +++ b/test-utils/runtime/src/genesismap.rs @@ -119,6 +119,7 @@ impl GenesisStorageBuilder { let genesis_config = RuntimeGenesisConfig { system: frame_system::GenesisConfig { code: self.wasm_code.clone().unwrap_or(wasm_binary_unwrap().to_vec()), + ..Default::default() }, babe: pallet_babe::GenesisConfig { authorities: authorities_sr25519 @@ -127,9 +128,11 @@ impl GenesisStorageBuilder { .map(|x| (x.into(), 1)) .collect(), epoch_config: Some(crate::TEST_RUNTIME_BABE_EPOCH_CONFIGURATION), + ..Default::default() }, substrate_test: substrate_test_pallet::GenesisConfig { authorities: authorities_sr25519.clone(), + ..Default::default() }, balances: pallet_balances::GenesisConfig { balances: self.balances.clone() }, }; diff --git a/test-utils/runtime/src/substrate_test_pallet.rs b/test-utils/runtime/src/substrate_test_pallet.rs index d080caa0898dd..ed1ad990472ba 100644 --- a/test-utils/runtime/src/substrate_test_pallet.rs +++ b/test-utils/runtime/src/substrate_test_pallet.rs @@ -55,13 +55,15 @@ pub mod pallet { pub type Authorities = StorageValue<_, Vec, ValueQuery>; #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig { + #[derive(frame_support::DefaultNoBound)] + pub struct GenesisConfig { pub authorities: Vec, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { >::put(self.authorities.clone()); } diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 431bcdab03288..424d16bd14c68 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -45,7 +45,7 @@ use sp_storage::{StorageData, StorageKey}; /// # NodeBlock = frame_system::mocking::MockBlock, /// # UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic, /// # { -/// # System: frame_system::{Pallet, Call, Config, Storage, Event}, +/// # System: frame_system::{Pallet, Call, Config, Storage, Event}, /// # Test: pallet_test::{Pallet, Storage}, /// # } /// # );