Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
GenesisBuild<T,I> deprecated. BuildGenesisConfig added (#7397)
Browse files Browse the repository at this point in the history
* GenesisBuild<T,I> deprecated. BuildGenesisConfig added

* fmt

* fixes

* more fixes

* more fixes

* fixes

* update lockfile for {"substrate"}

* fix

---------

Co-authored-by: parity-processbot <>
  • Loading branch information
michalkucharczyk authored and EgorPopelyaev committed Aug 2, 2023
1 parent a502cfb commit 36fc267
Show file tree
Hide file tree
Showing 31 changed files with 214 additions and 165 deletions.
72 changes: 54 additions & 18 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Runt
const STASH: u128 = 100 * DOT;

polkadot::RuntimeGenesisConfig {
system: polkadot::SystemConfig { code: wasm_binary.to_vec() },
system: polkadot::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: polkadot::BalancesConfig {
balances: endowed_accounts
.iter()
Expand Down Expand Up @@ -401,10 +401,14 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Runt
babe: polkadot::BabeConfig {
authorities: Default::default(),
epoch_config: Some(polkadot::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: polkadot::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: polkadot::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: polkadot::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: polkadot::VestingConfig { vesting: vec![] },
treasury: Default::default(),
Expand Down Expand Up @@ -541,7 +545,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Runtim
const STASH: u128 = 100 * WND;

westend::RuntimeGenesisConfig {
system: westend::SystemConfig { code: wasm_binary.to_vec() },
system: westend::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: westend::BalancesConfig {
balances: endowed_accounts
.iter()
Expand Down Expand Up @@ -584,10 +588,14 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Runtim
babe: westend::BabeConfig {
authorities: Default::default(),
epoch_config: Some(westend::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: westend::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: Some(endowed_accounts[0].clone()) },
hrmp: Default::default(),
Expand All @@ -597,6 +605,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Runtim
paras: Default::default(),
registrar: westend_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
Expand Down Expand Up @@ -731,7 +740,7 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeG
const STASH: u128 = 100 * KSM;

kusama::RuntimeGenesisConfig {
system: kusama::SystemConfig { code: wasm_binary.to_vec() },
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: kusama::BalancesConfig {
balances: endowed_accounts
.iter()
Expand Down Expand Up @@ -774,10 +783,14 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeG
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: kusama::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: kusama::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
Expand Down Expand Up @@ -1039,7 +1052,7 @@ fn rococo_staging_testnet_config_genesis(
const STASH: u128 = 100 * ROC;

rococo_runtime::RuntimeGenesisConfig {
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec() },
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: rococo_runtime::BalancesConfig {
balances: endowed_accounts
.iter()
Expand Down Expand Up @@ -1073,6 +1086,7 @@ fn rococo_staging_testnet_config_genesis(
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
Expand All @@ -1084,17 +1098,21 @@ fn rococo_staging_testnet_config_genesis(
},
technical_membership: Default::default(),
treasury: Default::default(),
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
paras: rococo_runtime::ParasConfig { paras: vec![] },
paras: rococo_runtime::ParasConfig { paras: vec![], ..Default::default() },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nis_counterpart_balances: Default::default(),
Expand Down Expand Up @@ -1347,7 +1365,7 @@ pub fn polkadot_testnet_genesis(
const STASH: u128 = 100 * DOT;

polkadot::RuntimeGenesisConfig {
system: polkadot::SystemConfig { code: wasm_binary.to_vec() },
system: polkadot::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: polkadot::IndicesConfig { indices: vec![] },
balances: polkadot::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
Expand Down Expand Up @@ -1394,10 +1412,14 @@ pub fn polkadot_testnet_genesis(
babe: polkadot::BabeConfig {
authorities: Default::default(),
epoch_config: Some(polkadot::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: polkadot::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: polkadot::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: polkadot::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: polkadot::VestingConfig { vesting: vec![] },
treasury: Default::default(),
Expand Down Expand Up @@ -1434,7 +1456,7 @@ pub fn kusama_testnet_genesis(
const STASH: u128 = 100 * KSM;

kusama::RuntimeGenesisConfig {
system: kusama::SystemConfig { code: wasm_binary.to_vec() },
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: kusama::IndicesConfig { indices: vec![] },
balances: kusama::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
Expand Down Expand Up @@ -1473,10 +1495,14 @@ pub fn kusama_testnet_genesis(
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: kusama::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: kusama::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
Expand Down Expand Up @@ -1514,7 +1540,7 @@ pub fn westend_testnet_genesis(
const STASH: u128 = 100 * WND;

westend::RuntimeGenesisConfig {
system: westend::SystemConfig { code: wasm_binary.to_vec() },
system: westend::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: westend::IndicesConfig { indices: vec![] },
balances: westend::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
Expand Down Expand Up @@ -1553,10 +1579,14 @@ pub fn westend_testnet_genesis(
babe: westend::BabeConfig {
authorities: Default::default(),
epoch_config: Some(westend::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: westend::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: Some(root_key) },
hrmp: Default::default(),
Expand All @@ -1566,6 +1596,7 @@ pub fn westend_testnet_genesis(
paras: Default::default(),
registrar: westend_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
Expand Down Expand Up @@ -1595,7 +1626,7 @@ pub fn rococo_testnet_genesis(
const ENDOWMENT: u128 = 1_000_000 * ROC;

rococo_runtime::RuntimeGenesisConfig {
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec() },
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
beefy: Default::default(),
indices: rococo_runtime::IndicesConfig { indices: vec![] },
balances: rococo_runtime::BalancesConfig {
Expand Down Expand Up @@ -1624,6 +1655,7 @@ pub fn rococo_testnet_genesis(
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
Expand All @@ -1638,7 +1670,10 @@ pub fn rococo_testnet_genesis(
treasury: Default::default(),
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
Expand All @@ -1647,9 +1682,10 @@ pub fn rococo_testnet_genesis(
..default_parachains_host_configuration()
},
},
paras: rococo_runtime::ParasConfig { paras: vec![] },
paras: rococo_runtime::ParasConfig { paras: vec![], ..Default::default() },
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nis_counterpart_balances: Default::default(),
Expand Down
6 changes: 5 additions & 1 deletion node/test/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ fn polkadot_testnet_genesis(
babe: runtime::BabeConfig {
authorities: vec![],
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
authority_discovery: runtime::AuthorityDiscoveryConfig { keys: vec![] },
authority_discovery: runtime::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: runtime::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: runtime::VestingConfig { vesting: vec![] },
sudo: runtime::SudoConfig { key: Some(root_key) },
Expand Down
7 changes: 4 additions & 3 deletions runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ mod tests {
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
transaction_validity::TransactionPriority,
BuildStorage,
DispatchError::BadOrigin,
};

Expand All @@ -569,11 +570,11 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
ParasShared: parachains_shared::{Pallet, Call, Storage},
Parachains: parachains_paras::{Pallet, Call, Storage, Config, Event},
Parachains: parachains_paras::{Pallet, Call, Storage, Config<T>, Event},
Slots: slots::{Pallet, Call, Storage, Event<T>},
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>},
}
Expand Down Expand Up @@ -693,7 +694,7 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
}
Expand Down
9 changes: 6 additions & 3 deletions runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,10 @@ mod tests {
use pallet_balances;
use primitives::{BlockNumber, Header, Id as ParaId};
use sp_core::H256;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use std::{cell::RefCell, collections::BTreeMap};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -697,7 +700,7 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Auctions: auctions::{Pallet, Call, Storage, Event<T>},
}
Expand Down Expand Up @@ -886,7 +889,7 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
}
Expand Down
10 changes: 5 additions & 5 deletions runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub mod pallet {
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
// build `Claims`
self.claims.iter().map(|(a, b, _, _)| (*a, *b)).for_each(|(a, b)| {
Expand Down Expand Up @@ -710,14 +710,14 @@ mod tests {
assert_err, assert_noop, assert_ok,
dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ConstU32, ExistenceRequirement, GenesisBuild, WithdrawReasons},
traits::{ConstU32, ExistenceRequirement, WithdrawReasons},
};
use pallet_balances;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Identity, IdentityLookup},
transaction_validity::TransactionLongevity,
TokenError,
BuildStorage, TokenError,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -729,7 +729,7 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Vesting: pallet_vesting::{Pallet, Call, Storage, Config<T>, Event<T>},
Claims: claims::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
Expand Down Expand Up @@ -836,7 +836,7 @@ mod tests {
// 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::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
Expand Down
6 changes: 3 additions & 3 deletions runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ mod tests {
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
DispatchResult,
BuildStorage, DispatchResult,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -892,7 +892,7 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>},
}
Expand Down Expand Up @@ -1110,7 +1110,7 @@ mod tests {
// 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::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)],
}
Expand Down
Loading

0 comments on commit 36fc267

Please sign in to comment.