diff --git a/CHANGELOG.md b/CHANGELOG.md index 263d11c1dd..aeabbb33dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Changelog for the runtimes governed by the Polkadot Fellowship. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [Unreleased] + +### Changed +- Genesis config presets: Make use of RuntimeGenesisConfig to construct genesis config values for all runtimes ([polkadot-fellows/runtimes#451](https://github.com/polkadot-fellows/runtimes/pull/451)). + + ## [1.3.3] 01.10.2024 ### Changed diff --git a/Cargo.lock b/Cargo.lock index 4f4d467771..d0e091b201 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14998,6 +14998,7 @@ dependencies = [ "polkadot-core-primitives", "polkadot-primitives", "polkadot-runtime-constants", + "serde_json", "smallvec", "sp-core 34.0.0", "sp-runtime 38.0.0", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/genesis_config_presets.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/genesis_config_presets.rs index f092687fe6..3d48fba89f 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/genesis_config_presets.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/genesis_config_presets.rs @@ -28,41 +28,50 @@ fn asset_hub_kusama_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, ASSET_HUB_KUSAMA_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + transaction_payment: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: ASSET_HUB_KUSAMA_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + assets: Default::default(), + foreign_assets: Default::default(), + parachain_system: Default::default(), + vesting: Default::default(), + pool_assets: Default::default(), + }; + + serde_json::to_value(config).expect("Could not build genesis config.") } pub fn asset_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/genesis_config_presets.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/genesis_config_presets.rs index 4d60c808d8..7c00f43ac2 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/genesis_config_presets.rs @@ -44,41 +44,50 @@ fn asset_hub_polkadot_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, ASSET_HUB_POLKADOT_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + transaction_payment: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: ASSET_HUB_POLKADOT_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + assets: Default::default(), + foreign_assets: Default::default(), + parachain_system: Default::default(), + vesting: Default::default(), + pool_assets: Default::default(), + }; + + serde_json::to_value(config).expect("Could not build genesis config.") } pub fn asset_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs index d9850b62a7..53c72864dc 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs @@ -28,41 +28,52 @@ fn bridge_hub_kusama_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, BRIDGE_HUB_KUSAMA_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: BRIDGE_HUB_KUSAMA_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + bridge_polkadot_grandpa: Default::default(), + bridge_polkadot_parachains: Default::default(), + parachain_system: Default::default(), + transaction_payment: Default::default(), + bridge_polkadot_messages: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn bridge_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/genesis_config_presets.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/genesis_config_presets.rs index e4ee542bea..def7ec31a0 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/genesis_config_presets.rs @@ -28,46 +28,57 @@ fn bridge_hub_polkadot_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, BRIDGE_HUB_POLKADOT_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: BRIDGE_HUB_POLKADOT_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id + acc.clone(), // account id + acc, // validator id SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), }, - "ethereumSystem": EthereumSystemConfig { + bridge_kusama_grandpa: Default::default(), + bridge_kusama_parachains: Default::default(), + bridge_kusama_messages: Default::default(), + ethereum_system: EthereumSystemConfig { para_id: id, asset_hub_para_id: polkadot_runtime_constants::system_parachain::ASSET_HUB_ID.into(), ..Default::default() }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + parachain_system: Default::default(), + transaction_payment: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn bridge_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/collectives/collectives-polkadot/src/genesis_config_presets.rs b/system-parachains/collectives/collectives-polkadot/src/genesis_config_presets.rs index 0fcbb37305..8baac3b588 100644 --- a/system-parachains/collectives/collectives-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/collectives/collectives-polkadot/src/genesis_config_presets.rs @@ -28,41 +28,53 @@ fn collectives_polkadot_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, COLLECTIVES_POLKADOT_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: COLLECTIVES_POLKADOT_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + alliance: Default::default(), + alliance_motion: Default::default(), + fellowship_treasury: Default::default(), + parachain_system: Default::default(), + transaction_payment: Default::default(), + ambassador_treasury: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn collectives_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/constants/Cargo.toml b/system-parachains/constants/Cargo.toml index 17582f7785..40de8e9141 100644 --- a/system-parachains/constants/Cargo.toml +++ b/system-parachains/constants/Cargo.toml @@ -20,6 +20,7 @@ sp-core = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } xcm = { workspace = true } +serde_json = { features = ["alloc"], workspace = true } [features] default = ["std"] diff --git a/system-parachains/constants/src/genesis_presets.rs b/system-parachains/constants/src/genesis_presets.rs index abb1f8b955..8ef68e6ec5 100644 --- a/system-parachains/constants/src/genesis_presets.rs +++ b/system-parachains/constants/src/genesis_presets.rs @@ -17,6 +17,7 @@ use parachains_common::AuraId; use polkadot_primitives::{AccountId, AccountPublic}; +use serde_json::Value; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::IdentifyAccount; #[cfg(not(feature = "std"))] @@ -66,3 +67,20 @@ where /// The default XCM version to set in genesis config. pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; + +pub fn remove_phantom_fields(value: &mut Value) { + match value { + Value::Object(map) => { + map.remove("phantom"); + + for (_, v) in map.iter_mut() { + remove_phantom_fields(v); + } + }, + Value::Array(arr) => + for v in arr.iter_mut() { + remove_phantom_fields(v); + }, + _ => {}, + } +} diff --git a/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs b/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs index dbefac5c74..9ef7d7d578 100644 --- a/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs +++ b/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs @@ -30,24 +30,22 @@ fn coretime_kusama_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, CORETIME_KUSAMA_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: CORETIME_KUSAMA_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { @@ -59,12 +57,23 @@ fn coretime_kusama_genesis( }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + parachain_system: Default::default(), + transaction_payment: Default::default(), + broker: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn coretime_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs b/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs index 38f3aceed7..0b03d824a1 100644 --- a/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs @@ -30,24 +30,22 @@ fn coretime_polkadot_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, CORETIME_POLKADOT_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: CORETIME_POLKADOT_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { @@ -59,12 +57,23 @@ fn coretime_polkadot_genesis( }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + parachain_system: Default::default(), + transaction_payment: Default::default(), + broker: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } fn coretime_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/encointer/src/genesis_config_presets.rs b/system-parachains/encointer/src/genesis_config_presets.rs index 79d0dedaf9..5cb44aa922 100644 --- a/system-parachains/encointer/src/genesis_config_presets.rs +++ b/system-parachains/encointer/src/genesis_config_presets.rs @@ -15,7 +15,6 @@ // along with Polkadot. If not, see . //! Genesis configs presets for the EncointerKusama runtime - use crate::*; use sp_genesis_builder::PresetId; use sp_std::vec::Vec; @@ -28,71 +27,86 @@ fn encointer_kusama_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + parachain_system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, ENCOINTER_KUSAMA_ED * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + transaction_payment: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: ENCOINTER_KUSAMA_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), + // no need to pass anything to aura, in fact it will panic if we do. Session will take care + // of this. `aura: Default::default()` + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), }, - "encointerScheduler": { - "currentPhase": CeremonyPhaseType::Registering, - "currentCeremonyIndex": 1, - "phaseDurations": vec![ - (CeremonyPhaseType::Registering, 604800000u64), // 7d + collective: Default::default(), + membership: Default::default(), + encointer_scheduler: EncointerSchedulerConfig { + current_phase: CeremonyPhaseType::Registering, + current_ceremony_index: 1, + phase_durations: vec![ + (CeremonyPhaseType::Registering, 604800000u64), //7d (CeremonyPhaseType::Assigning, 86400000u64), // 1d (CeremonyPhaseType::Attesting, 172800000u64), // 2d ], + _config: Default::default(), }, - "encointerCeremonies": { - "ceremonyReward": BalanceType::from_num(1), - "timeTolerance": 600_000u64, // +-10min - "locationTolerance": 1_000, // [m] - "endorsementTicketsPerBootstrapper": 10, - "endorsementTicketsPerReputable": 5, - "reputationLifetime": 5, - "inactivityTimeout": 5, // idle ceremonies before purging community - "meetupTimeOffset": 0, + encointer_ceremonies: EncointerCeremoniesConfig { + ceremony_reward: BalanceType::from_num(1), + time_tolerance: 600_000u64, // +-10min + location_tolerance: 1_000, // [m] + endorsement_tickets_per_bootstrapper: 10, + endorsement_tickets_per_reputable: 5, + reputation_lifetime: 5, + inactivity_timeout: 5, // idle ceremonies before purging community + meetup_time_offset: 0, + _config: Default::default(), }, - "encointerCommunities": { - "minSolarTripTimeS": 1, // [s] - "maxSpeedMps": 1, // [m/s] suggested would be 83m/s for security, + encointer_communities: EncointerCommunitiesConfig { + min_solar_trip_time_s: 1, // [s] + max_speed_mps: 1, // [m/s] suggested would be 83m/s for security, + _config: Default::default(), }, - "encointerBalances": { - // for relative adjustment. - "feeConversionFactor": 7_143u32, + encointer_balances: EncointerBalancesConfig { + fee_conversion_factor: 7_143u128, + _config: Default::default(), }, - "encointerFaucet": { - "reserveAmount": 10_000_000_000_000u128, + encointer_faucet: EncointerFaucetConfig { + reserve_amount: 10_000_000_000_000u128, + _config: Default::default(), }, - // no need to pass anything to aura, in fact it will panic if we do. Session will take care - // of this. `aura: Default::default()` - }) + encointer_democracy: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn encointer_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/gluttons/glutton-kusama/src/genesis_config_presets.rs b/system-parachains/gluttons/glutton-kusama/src/genesis_config_presets.rs index c951b4e538..108a9cb020 100644 --- a/system-parachains/gluttons/glutton-kusama/src/genesis_config_presets.rs +++ b/system-parachains/gluttons/glutton-kusama/src/genesis_config_presets.rs @@ -19,14 +19,21 @@ use crate::*; use cumulus_primitives_core::ParaId; use sp_genesis_builder::PresetId; +use system_parachains_constants::genesis_presets::remove_phantom_fields; fn glutton_kusama_genesis(id: ParaId) -> serde_json::Value { - serde_json::json!({ - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - }) + let config = RuntimeGenesisConfig { + system: Default::default(), + parachain_system: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + glutton: Default::default(), + sudo: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn glutton_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/people/people-kusama/src/genesis_config_presets.rs b/system-parachains/people/people-kusama/src/genesis_config_presets.rs index 1254ed4469..fb35867390 100644 --- a/system-parachains/people/people-kusama/src/genesis_config_presets.rs +++ b/system-parachains/people/people-kusama/src/genesis_config_presets.rs @@ -28,41 +28,49 @@ fn people_kusama_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, PEOPLE_KUSAMA_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: PEOPLE_KUSAMA_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + parachain_system: Default::default(), + transaction_payment: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn people_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { diff --git a/system-parachains/people/people-polkadot/src/genesis_config_presets.rs b/system-parachains/people/people-polkadot/src/genesis_config_presets.rs index f48e219922..d59f215f7b 100644 --- a/system-parachains/people/people-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/people/people-polkadot/src/genesis_config_presets.rs @@ -28,41 +28,49 @@ fn people_polkadot_genesis( endowed_accounts: Vec, id: ParaId, ) -> serde_json::Value { - serde_json::json!({ - "balances": BalancesConfig { + let config = RuntimeGenesisConfig { + system: Default::default(), + balances: BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, PEOPLE_POLKADOT_ED * 4096 * 4096)) .collect(), }, - "parachainInfo": ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - "collatorSelection": CollatorSelectionConfig { + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, + collator_selection: CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: PEOPLE_POLKADOT_ED * 16, ..Default::default() }, - "session": SessionConfig { + session: SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` - }) + aura: Default::default(), + aura_ext: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + _config: Default::default(), + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + parachain_system: Default::default(), + transaction_payment: Default::default(), + }; + + let mut config_values = serde_json::to_value(config).expect("Could not build genesis config."); + remove_phantom_fields(&mut config_values); + + config_values } pub fn people_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {