chain-spec: getting ready for native-runtime-free world (#1256)

This PR prepares chains specs for _native-runtime-free_  world.

This PR has following changes:
- `substrate`:
  - adds support for:
- JSON based `GenesisConfig` to `ChainSpec` allowing interaction with
runtime `GenesisBuilder` API.
- interacting with arbitrary runtime wasm blob to[
`chain-spec-builder`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/bin/utils/chain-spec-builder/src/lib.rs#L46)
command line util,
- removes
[`code`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/frame/system/src/lib.rs#L660)
from `system_pallet`
  - adds `code` to the `ChainSpec`
- deprecates
[`ChainSpec::from_genesis`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/client/chain-spec/src/chain_spec.rs#L263),
but also changes the signature of this method extending it with `code`
argument.
[`ChainSpec::builder()`](https://github.com/paritytech/substrate/blob/20bee680ed098be7239cf7a6b804cd4de267983e/client/chain-spec/src/chain_spec.rs#L507)
should be used instead.
- `polkadot`:
- all references to `RuntimeGenesisConfig` in `node/service` are
removed,
- all
`(kusama|polkadot|versi|rococo|wococo)_(staging|dev)_genesis_config`
functions now return the JSON patch for default runtime `GenesisConfig`,
  - `ChainSpecBuilder` is used, `ChainSpec::from_genesis` is removed,

- `cumulus`:
  - `ChainSpecBuilder` is used, `ChainSpec::from_genesis` is removed,
- _JSON_ patch configuration used instead of `RuntimeGenesisConfig
struct` in all chain specs.
  
---------

Co-authored-by: command-bot <>
Co-authored-by: Javier Viola <javier@parity.io>
Co-authored-by: Davide Galassi <davxy@datawok.net>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Kevin Krone <kevin@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Michal Kucharczyk
2023-11-05 15:19:23 +01:00
committed by GitHub
parent c46a7dbb61
commit 8ba7a6aba8
90 changed files with 4833 additions and 3059 deletions
@@ -215,8 +215,7 @@ pub mod rococo {
parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec =
sc_service::GenericChainSpec<bridge_hub_rococo_runtime::RuntimeGenesisConfig, Extensions>;
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type RuntimeApi = bridge_hub_rococo_runtime::RuntimeApi;
@@ -235,52 +234,47 @@ pub mod rococo {
properties.insert("tokenDecimals".into(), 12.into());
modify_props(&mut properties);
BridgeHubChainSpec::from_genesis(
// Name
chain_name,
// ID
super::ensure_id(id).expect("invalid id"),
ChainType::Local,
move || {
genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
bridges_pallet_owner_seed
.as_ref()
.map(|seed| get_account_id_from_seed::<sr25519::Public>(seed)),
)
},
Vec::new(),
None,
None,
None,
Some(properties),
BridgeHubChainSpec::builder(
bridge_hub_rococo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(chain_name)
.with_id(super::ensure_id(id).expect("invalid id"))
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
bridges_pallet_owner_seed
.as_ref()
.map(|seed| get_account_id_from_seed::<sr25519::Public>(seed)),
))
.with_properties(properties)
.build()
}
fn genesis(
@@ -288,28 +282,20 @@ pub mod rococo {
endowed_accounts: Vec<AccountId>,
id: ParaId,
bridges_pallet_owner: Option<AccountId>,
) -> bridge_hub_rococo_runtime::RuntimeGenesisConfig {
bridge_hub_rococo_runtime::RuntimeGenesisConfig {
system: bridge_hub_rococo_runtime::SystemConfig {
code: bridge_hub_rococo_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
) -> serde_json::Value {
serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
balances: bridge_hub_rococo_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
"parachainInfo": {
"parachainId": id,
},
parachain_info: bridge_hub_rococo_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
"collatorSelection": {
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
"candidacyBond": BRIDGE_HUB_ROCOCO_ED * 16,
},
collator_selection: bridge_hub_rococo_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_ROCOCO_ED * 16,
..Default::default()
},
session: bridge_hub_rococo_runtime::SessionConfig {
keys: invulnerables
"session": {
"keys": invulnerables
.into_iter()
.map(|(acc, aura)| {
(
@@ -318,40 +304,31 @@ pub mod rococo {
bridge_hub_rococo_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
.collect::<Vec<_>>(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: bridge_hub_rococo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
bridge_wococo_grandpa: bridge_hub_rococo_runtime::BridgeWococoGrandpaConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeWococoGrandpa": {
"owner": bridges_pallet_owner.clone(),
},
bridge_westend_grandpa: bridge_hub_rococo_runtime::BridgeWestendGrandpaConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeWestendGrandpa": {
"owner": bridges_pallet_owner.clone(),
},
bridge_rococo_grandpa: bridge_hub_rococo_runtime::BridgeRococoGrandpaConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeRococoGrandpa": {
"owner": bridges_pallet_owner.clone(),
},
bridge_rococo_messages: bridge_hub_rococo_runtime::BridgeRococoMessagesConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeRococoMessages": {
"owner": bridges_pallet_owner.clone(),
},
bridge_wococo_messages: bridge_hub_rococo_runtime::BridgeWococoMessagesConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeWococoMessages": {
"owner": bridges_pallet_owner.clone(),
},
bridge_westend_messages: bridge_hub_rococo_runtime::BridgeWestendMessagesConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeWestendMessages": {
"owner": bridges_pallet_owner.clone(),
},
}
})
}
}
@@ -403,8 +380,7 @@ pub mod kusama {
parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec =
sc_service::GenericChainSpec<bridge_hub_kusama_runtime::RuntimeGenesisConfig, Extensions>;
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type RuntimeApi = bridge_hub_kusama_runtime::RuntimeApi;
pub fn local_config(
@@ -418,81 +394,68 @@ pub mod kusama {
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
BridgeHubChainSpec::from_genesis(
// Name
chain_name,
// ID
super::ensure_id(id).expect("invalid id"),
ChainType::Local,
move || {
genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
)
},
Vec::new(),
None,
None,
None,
Some(properties),
BridgeHubChainSpec::builder(
bridge_hub_kusama_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(chain_name)
.with_id(super::ensure_id(id).expect("invalid id"))
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
))
.with_properties(properties)
.build()
}
fn genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> bridge_hub_kusama_runtime::RuntimeGenesisConfig {
bridge_hub_kusama_runtime::RuntimeGenesisConfig {
system: bridge_hub_kusama_runtime::SystemConfig {
code: bridge_hub_kusama_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: bridge_hub_kusama_runtime::BalancesConfig {
balances: endowed_accounts
) -> serde_json::Value {
serde_json::json!({
"balances": {
"balances": endowed_accounts
.iter()
.cloned()
.map(|k| (k, BRIDGE_HUB_KUSAMA_ED * 524_288))
.collect(),
.collect::<Vec<_>>(),
},
parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
"parachainInfo": {
"parachainId": id,
},
collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_KUSAMA_ED * 16,
..Default::default()
"collatorSelection": {
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
"candidacyBond": BRIDGE_HUB_KUSAMA_ED * 16,
},
session: bridge_hub_kusama_runtime::SessionConfig {
keys: invulnerables
"session": {
"keys": invulnerables
.into_iter()
.map(|(acc, aura)| {
(
@@ -501,16 +464,12 @@ pub mod kusama {
bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
.collect::<Vec<_>>(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
}
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
}
})
}
}
@@ -545,52 +504,47 @@ pub mod westend {
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
BridgeHubChainSpec::from_genesis(
// Name
chain_name,
// ID
super::ensure_id(id).expect("invalid id"),
ChainType::Local,
move || {
genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
bridges_pallet_owner_seed
.as_ref()
.map(|seed| get_account_id_from_seed::<sr25519::Public>(seed)),
)
},
Vec::new(),
None,
None,
None,
Some(properties),
BridgeHubChainSpec::builder(
bridge_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(chain_name)
.with_id(super::ensure_id(id).expect("invalid id"))
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
bridges_pallet_owner_seed
.as_ref()
.map(|seed| get_account_id_from_seed::<sr25519::Public>(seed)),
))
.with_properties(properties)
.build()
}
fn genesis(
@@ -598,28 +552,20 @@ pub mod westend {
endowed_accounts: Vec<AccountId>,
id: ParaId,
bridges_pallet_owner: Option<AccountId>,
) -> bridge_hub_westend_runtime::RuntimeGenesisConfig {
bridge_hub_westend_runtime::RuntimeGenesisConfig {
system: bridge_hub_westend_runtime::SystemConfig {
code: bridge_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
) -> serde_json::Value {
serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
balances: bridge_hub_westend_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
"parachainInfo": {
"parachainId": id,
},
parachain_info: bridge_hub_westend_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
"collatorSelection": {
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
"candidacyBond": BRIDGE_HUB_WESTEND_ED * 16,
},
collator_selection: bridge_hub_westend_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_WESTEND_ED * 16,
..Default::default()
},
session: bridge_hub_westend_runtime::SessionConfig {
keys: invulnerables
"session": {
"keys": invulnerables
.into_iter()
.map(|(acc, aura)| {
(
@@ -628,24 +574,18 @@ pub mod westend {
bridge_hub_westend_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
.collect::<Vec<_>>(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: bridge_hub_westend_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
bridge_rococo_grandpa: bridge_hub_westend_runtime::BridgeRococoGrandpaConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
"bridgeRococoGrandpa": {
"owner": bridges_pallet_owner.clone(),
},
bridge_rococo_messages: bridge_hub_westend_runtime::BridgeRococoMessagesConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
},
}
"bridgeRococoMessages": {
"owner": bridges_pallet_owner.clone(),
}
})
}
}
@@ -666,8 +606,7 @@ pub mod polkadot {
parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec =
sc_service::GenericChainSpec<bridge_hub_polkadot_runtime::RuntimeGenesisConfig, Extensions>;
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type RuntimeApi = bridge_hub_polkadot_runtime::RuntimeApi;
pub fn local_config(
@@ -681,81 +620,68 @@ pub mod polkadot {
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
BridgeHubChainSpec::from_genesis(
// Name
chain_name,
// ID
super::ensure_id(id).expect("invalid id"),
ChainType::Local,
move || {
genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
)
},
Vec::new(),
None,
None,
None,
Some(properties),
BridgeHubChainSpec::builder(
bridge_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(chain_name)
.with_id(super::ensure_id(id).expect("invalid id"))
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed::<AuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed::<AuraId>("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
para_id,
))
.with_properties(properties)
.build()
}
fn genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> bridge_hub_polkadot_runtime::RuntimeGenesisConfig {
bridge_hub_polkadot_runtime::RuntimeGenesisConfig {
system: bridge_hub_polkadot_runtime::SystemConfig {
code: bridge_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: bridge_hub_polkadot_runtime::BalancesConfig {
balances: endowed_accounts
) -> serde_json::Value {
serde_json::json!({
"balances": {
"balances": endowed_accounts
.iter()
.cloned()
.map(|k| (k, BRIDGE_HUB_POLKADOT_ED * 4096))
.collect(),
.collect::<Vec<_>>(),
},
parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
"parachainInfo": {
"parachainId": id,
},
collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: BRIDGE_HUB_POLKADOT_ED * 16,
..Default::default()
"collatorSelection": {
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
"candidacyBond": BRIDGE_HUB_POLKADOT_ED * 16,
},
session: bridge_hub_polkadot_runtime::SessionConfig {
keys: invulnerables
"session": {
"keys": invulnerables
.into_iter()
.map(|(acc, aura)| {
(
@@ -764,15 +690,11 @@ pub mod polkadot {
bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
.collect::<Vec<_>>(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
}
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
}
})
}
}