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

Soft deprecate GenesisConfig #14210

10 changes: 5 additions & 5 deletions bin/node-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use node_template_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,
SystemConfig, WASM_BINARY,
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, Signature,
SudoConfig, SystemConfig, WASM_BINARY,
};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
Expand All @@ -12,7 +12,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -131,8 +131,8 @@ fn testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
Expand Down
18 changes: 9 additions & 9 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sp_runtime::{
Perbill,
};

pub use kitchensink_runtime::GenesisConfig;
pub use kitchensink_runtime::RuntimeGenesisConfig;
pub use node_primitives::{AccountId, Balance, Signature};

type AccountPublic = <Signature as Verify>::Signer;
Expand All @@ -62,7 +62,7 @@ pub struct Extensions {
}

/// Specialized `ChainSpec`.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig, Extensions>;
/// Flaming Fir testnet generator
pub fn flaming_fir_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/flaming-fir.json")[..])
Expand All @@ -77,7 +77,7 @@ fn session_keys(
SessionKeys { grandpa, babe, im_online, authority_discovery }
}

fn staging_testnet_config_genesis() -> GenesisConfig {
fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
#[rustfmt::skip]
// stash, controller, session-key
// generated with secret:
Expand Down Expand Up @@ -229,7 +229,7 @@ pub fn authority_keys_from_seed(
)
}

/// Helper function to create GenesisConfig for testing
/// Helper function to create RuntimeGenesisConfig for testing
pub fn testnet_genesis(
initial_authorities: Vec<(
AccountId,
Expand All @@ -242,7 +242,7 @@ pub fn testnet_genesis(
initial_nominators: Vec<AccountId>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> GenesisConfig {
) -> RuntimeGenesisConfig {
let mut endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down Expand Up @@ -294,7 +294,7 @@ pub fn testnet_genesis(
const ENDOWMENT: Balance = 10_000_000 * DOLLARS;
const STASH: Balance = ENDOWMENT / 1000;

GenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig { code: wasm_binary_unwrap().to_vec() },
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
Expand Down Expand Up @@ -380,7 +380,7 @@ pub fn testnet_genesis(
}
}

fn development_config_genesis() -> GenesisConfig {
fn development_config_genesis() -> RuntimeGenesisConfig {
testnet_genesis(
vec![authority_keys_from_seed("Alice")],
vec![],
Expand All @@ -405,7 +405,7 @@ pub fn development_config() -> ChainSpec {
)
}

fn local_testnet_genesis() -> GenesisConfig {
fn local_testnet_genesis() -> RuntimeGenesisConfig {
testnet_genesis(
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
vec![],
Expand Down Expand Up @@ -437,7 +437,7 @@ pub(crate) mod tests {
use sc_service_test;
use sp_runtime::BuildStorage;

fn local_testnet_genesis_instant_single() -> GenesisConfig {
fn local_testnet_genesis_instant_single() -> RuntimeGenesisConfig {
testnet_genesis(
vec![authority_keys_from_seed("Alice")],
vec![],
Expand Down
2 changes: 1 addition & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl BenchKeyring {
}

/// Generate genesis with accounts from this keyring endowed with some balance.
pub fn generate_genesis(&self) -> kitchensink_runtime::GenesisConfig {
pub fn generate_genesis(&self) -> kitchensink_runtime::RuntimeGenesisConfig {
crate::genesis::config_endowed(
Some(kitchensink_runtime::wasm_binary_unwrap()),
self.collect_account_ids(),
Expand Down
11 changes: 6 additions & 5 deletions bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@
use crate::keyring::*;
use kitchensink_runtime::{
constants::currency::*, wasm_binary_unwrap, AccountId, AssetsConfig, BabeConfig,
BalancesConfig, GenesisConfig, GluttonConfig, GrandpaConfig, IndicesConfig, SessionConfig,
SocietyConfig, StakerStatus, StakingConfig, SystemConfig, BABE_GENESIS_EPOCH_CONFIG,
BalancesConfig, GluttonConfig, GrandpaConfig, IndicesConfig, RuntimeGenesisConfig,
SessionConfig, SocietyConfig, StakerStatus, StakingConfig, SystemConfig,
BABE_GENESIS_EPOCH_CONFIG,
};
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
use sp_runtime::Perbill;

/// Create genesis runtime configuration for tests.
pub fn config(code: Option<&[u8]>) -> GenesisConfig {
pub fn config(code: Option<&[u8]>) -> RuntimeGenesisConfig {
config_endowed(code, Default::default())
}

/// Create genesis runtime configuration for tests with some extra
/// endowed accounts.
pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> GenesisConfig {
pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> RuntimeGenesisConfig {
let mut endowed = vec![
(alice(), 111 * DOLLARS),
(bob(), 100 * DOLLARS),
Expand All @@ -46,7 +47,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen

endowed.extend(extra_endowed.into_iter().map(|endowed| (endowed, 100 * DOLLARS)));

GenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()),
},
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/chain-spec-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn genesis_constructor(
nominator_accounts: &[AccountId],
endowed_accounts: &[AccountId],
sudo_account: &AccountId,
) -> chain_spec::GenesisConfig {
) -> chain_spec::RuntimeGenesisConfig {
let authorities = authority_seeds
.iter()
.map(AsRef::as_ref)
Expand Down
2 changes: 1 addition & 1 deletion frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {

#[cfg(feature = "runtime-benchmarks")]
pub fn new_bench_ext() -> sp_io::TestExternalities {
GenesisConfig::default().build_storage().unwrap().into()
RuntimeGenesisConfig::default().build_storage().unwrap().into()
}

pub fn test_cid() -> Cid {
Expand Down
2 changes: 1 addition & 1 deletion frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl pallet_test::Config for Test {
}

fn new_test_ext() -> sp_io::TestExternalities {
GenesisConfig::default().build_storage().unwrap().into()
RuntimeGenesisConfig::default().build_storage().unwrap().into()
}

thread_local! {
Expand Down
2 changes: 1 addition & 1 deletion frame/benchmarking/src/tests_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl pallet_test::OtherConfig for Test {
}

fn new_test_ext() -> sp_io::TestExternalities {
GenesisConfig::default().build_storage().unwrap().into()
RuntimeGenesisConfig::default().build_storage().unwrap().into()
}

mod benchmarks {
Expand Down
2 changes: 1 addition & 1 deletion frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type TreasuryError = pallet_treasury::Error<Test>;
type TreasuryError1 = pallet_treasury::Error<Test, Instance1>;

pub fn new_test_ext() -> sp_io::TestExternalities {
let mut ext: sp_io::TestExternalities = GenesisConfig {
let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig {
system: frame_system::GenesisConfig::default(),
balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)] },
treasury: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion frame/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl ExtBuilder {
}

pub fn build(self) -> sp_io::TestExternalities {
let mut ext: sp_io::TestExternalities = GenesisConfig {
let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig {
collective: pallet_collective::GenesisConfig {
members: self.collective_members,
phantom: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ mod tests {
MEMBERS.with(|m| {
*m.borrow_mut() = self.genesis_members.iter().map(|(m, _)| *m).collect::<Vec<_>>()
});
let mut ext: sp_io::TestExternalities = GenesisConfig {
let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig {
balances: pallet_balances::GenesisConfig::<Test> {
balances: vec![
(1, 10 * self.balance_factor),
Expand Down
2 changes: 1 addition & 1 deletion frame/examples/basic/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl 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 t = GenesisConfig {
let t = RuntimeGenesisConfig {
// We use default for brevity, but you can configure as desired if needed.
system: Default::default(),
balances: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion frame/examples/dev-mode/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl 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 t = GenesisConfig {
let t = RuntimeGenesisConfig {
// We use default for brevity, but you can configure as desired if needed.
system: Default::default(),
balances: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion frame/remark/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ impl pallet_remark::Config for Test {
}

pub fn new_test_ext() -> sp_io::TestExternalities {
let t = GenesisConfig { system: Default::default() }.build_storage().unwrap();
let t = RuntimeGenesisConfig { system: Default::default() }.build_storage().unwrap();
t.into()
}
12 changes: 10 additions & 2 deletions frame/support/procedural/src/construct_runtime/expand/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,20 @@ pub fn expand_outer_config(
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
#[serde(crate = "__genesis_config_serde_import__")]
pub struct GenesisConfig {
pub struct RuntimeGenesisConfig {
#fields
}

// TODO [#14065]
// - remove the deprecation attribute before merging the PR
// - deprecate it (for real)
// - later, remove it
#[cfg(any(feature = "std", test))]
impl #scrate::sp_runtime::BuildStorage for GenesisConfig {
#[deprecated(note = "Use `RuntimeGenesisConfig` instead")] // just to make sure CI passes before merging the PR
pub type GenesisConfig = RuntimeGenesisConfig;

#[cfg(any(feature = "std", test))]
impl #scrate::sp_runtime::BuildStorage for RuntimeGenesisConfig {
fn assimilate_storage(
&self,
storage: &mut #scrate::sp_runtime::Storage,
Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ pub mod tests {
}

fn new_test_ext() -> TestExternalities {
GenesisConfig::default().build_storage().unwrap().into()
RuntimeGenesisConfig::default().build_storage().unwrap().into()
}

trait Sorted {
Expand Down
6 changes: 3 additions & 3 deletions frame/support/src/storage/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mod tests {

#[test]
fn value_translate_works() {
let t = GenesisConfig::default().build_storage().unwrap();
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
TestExternalities::new(t).execute_with(|| {
type Value = self::frame_system::Value<Runtime>;

Expand All @@ -170,7 +170,7 @@ mod tests {

#[test]
fn map_translate_works() {
let t = GenesisConfig::default().build_storage().unwrap();
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
TestExternalities::new(t).execute_with(|| {
type NumberMap = self::frame_system::NumberMap<Runtime>;

Expand Down Expand Up @@ -201,7 +201,7 @@ mod tests {

#[test]
fn try_mutate_works() {
let t = GenesisConfig::default().build_storage().unwrap();
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
TestExternalities::new(t).execute_with(|| {
type Value = self::frame_system::Value<Runtime>;
type NumberMap = self::frame_system::NumberMap<Runtime>;
Expand Down
2 changes: 1 addition & 1 deletion frame/support/test/tests/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ impl module3::Config for Runtime {
}

fn new_test_ext() -> sp_io::TestExternalities {
GenesisConfig {
RuntimeGenesisConfig {
module_1_1: module1::GenesisConfig { value: 3, test: 2 },
module_1_2: module1::GenesisConfig { value: 4, test: 5 },
module_2: module2::GenesisConfig {
Expand Down
2 changes: 1 addition & 1 deletion frame/support/test/tests/issue2219.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ frame_support::construct_runtime!(

#[test]
fn create_genesis_config() {
let config = GenesisConfig {
let config = RuntimeGenesisConfig {
module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true },
};
assert_eq!(config.module.request_life_time, 0);
Expand Down
2 changes: 1 addition & 1 deletion frame/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub const CALL: &<Test as Config>::RuntimeCall =
/// Create new externalities for `System` module tests.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut ext: sp_io::TestExternalities =
GenesisConfig::default().build_storage().unwrap().into();
RuntimeGenesisConfig::default().build_storage().unwrap().into();
// Add to each test the initial weight of a block
ext.execute_with(|| {
System::register_extra_weight_unchecked(
Expand Down
2 changes: 1 addition & 1 deletion frame/tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Config<Instance1> for Test {
}

pub fn new_test_ext() -> sp_io::TestExternalities {
let mut ext: sp_io::TestExternalities = GenesisConfig {
let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig {
system: frame_system::GenesisConfig::default(),
balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)] },
treasury: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion frame/transaction-storage/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl pallet_transaction_storage::Config for Test {
}

pub fn new_test_ext() -> sp_io::TestExternalities {
let t = GenesisConfig {
let t = RuntimeGenesisConfig {
system: Default::default(),
balances: pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 1000000000), (2, 100), (3, 100), (4, 100)],
Expand Down
2 changes: 1 addition & 1 deletion frame/whitelist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl pallet_whitelist::Config for Test {
}

pub fn new_test_ext() -> sp_io::TestExternalities {
let t = GenesisConfig::default().build_storage().unwrap();
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
Expand Down
4 changes: 2 additions & 2 deletions test-utils/runtime/src/genesismap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Tool for creating the genesis block.

use super::{
currency, substrate_test_pallet, wasm_binary_unwrap, AccountId, Balance, GenesisConfig,
currency, substrate_test_pallet, wasm_binary_unwrap, AccountId, Balance, RuntimeGenesisConfig,
};
use codec::Encode;
use sc_service::construct_genesis_block;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl GenesisStorageBuilder {
.map(|id| sr25519::Public::from(id))
.collect();

let genesis_config = GenesisConfig {
let genesis_config = RuntimeGenesisConfig {
system: frame_system::GenesisConfig {
code: self.wasm_code.clone().unwrap_or(wasm_binary_unwrap().to_vec()),
},
Expand Down