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
10 changes: 8 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,18 @@ 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]
// - deprecate it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe temporarily put a deprecation here, to see that the CI stays green and we got all cases?

Copy link
Contributor Author

@juangirini juangirini May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's what I did locally. Let's double check with the CI, I will remove it after being confirmed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggwpez all green now with the deprecation attribute in place, except for the Cumulus and Polkadot companions of course, as they are throwing the deprecation warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you can do them lean without companion (since that is annoying).

// - later, remove it
Copy link
Contributor

@liamaharon liamaharon May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think it would be cleaner to not put TODO or deprecation steps in the code comment itself, and just list them in the issue.

The code comment could say something like "GenesisConfig is in the process of being deprecated [issue link]"

#[cfg(any(feature = "std", test))]
impl #scrate::sp_runtime::BuildStorage for GenesisConfig {
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
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