mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
cumulus: add asset-hub-rococo runtime based on asset-hub-kusama and add asset-bridging support to it (#1215)
This commit adds Rococo Asset Hub dedicated runtime so we can test new features here, before merging them in Kusama Asset Hub. Also adds one such feature: asset transfer over bridge (Rococo AssetHub <> Wococo AssetHub) - clone `asset-hub-kusama-runtime` -> `asset-hub-rococo-runtime` - make it use Rococo primitives, names, assets, constants, etc - add asset-transfer-over-bridge support to Rococo AssetHub <> Wococo AssetHub Fixes #1128 --------- Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
This commit is contained in:
@@ -30,6 +30,9 @@ pub type AssetHubKusamaChainSpec =
|
||||
sc_service::GenericChainSpec<asset_hub_kusama_runtime::RuntimeGenesisConfig, Extensions>;
|
||||
pub type AssetHubWestendChainSpec =
|
||||
sc_service::GenericChainSpec<asset_hub_westend_runtime::RuntimeGenesisConfig, Extensions>;
|
||||
pub type AssetHubRococoChainSpec =
|
||||
sc_service::GenericChainSpec<asset_hub_rococo_runtime::RuntimeGenesisConfig, Extensions>;
|
||||
pub type AssetHubWococoChainSpec = AssetHubRococoChainSpec;
|
||||
|
||||
const ASSET_HUB_POLKADOT_ED: AssetHubBalance =
|
||||
parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;
|
||||
@@ -37,6 +40,8 @@ const ASSET_HUB_KUSAMA_ED: AssetHubBalance =
|
||||
parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT;
|
||||
const ASSET_HUB_WESTEND_ED: AssetHubBalance =
|
||||
parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;
|
||||
const ASSET_HUB_ROCOCO_ED: AssetHubBalance =
|
||||
parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
@@ -54,6 +59,13 @@ pub fn asset_hub_kusama_session_keys(keys: AuraId) -> asset_hub_kusama_runtime::
|
||||
asset_hub_kusama_runtime::SessionKeys { aura: keys }
|
||||
}
|
||||
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||
pub fn asset_hub_rococo_session_keys(keys: AuraId) -> asset_hub_rococo_runtime::SessionKeys {
|
||||
asset_hub_rococo_runtime::SessionKeys { aura: keys }
|
||||
}
|
||||
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||
@@ -643,3 +655,240 @@ fn asset_hub_westend_genesis(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn asset_hub_rococo_development_config() -> AssetHubRococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_development_config(
|
||||
properties,
|
||||
"Rococo Asset Hub Development",
|
||||
"asset-hub-rococo-dev",
|
||||
1000,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_wococo_development_config() -> AssetHubWococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WOC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_development_config(
|
||||
properties,
|
||||
"Wococo Asset Hub Development",
|
||||
"asset-hub-wococo-dev",
|
||||
1000,
|
||||
)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_like_development_config(
|
||||
properties: sc_chain_spec::Properties,
|
||||
name: &str,
|
||||
chain_id: &str,
|
||||
para_id: u32,
|
||||
) -> AssetHubRococoChainSpec {
|
||||
AssetHubRococoChainSpec::from_genesis(
|
||||
// Name
|
||||
name,
|
||||
// ID
|
||||
chain_id,
|
||||
ChainType::Local,
|
||||
move || {
|
||||
asset_hub_rococo_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
],
|
||||
para_id.into(),
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: "rococo-dev".into(), para_id },
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_rococo_local_config() -> AssetHubRococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_local_config(
|
||||
properties,
|
||||
"Rococo Asset Hub Local",
|
||||
"asset-hub-rococo-local",
|
||||
1000,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_wococo_local_config() -> AssetHubWococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WOC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_local_config(
|
||||
properties,
|
||||
"Wococo Asset Hub Local",
|
||||
"asset-hub-wococo-local",
|
||||
1000,
|
||||
)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_like_local_config(
|
||||
properties: sc_chain_spec::Properties,
|
||||
name: &str,
|
||||
chain_id: &str,
|
||||
para_id: u32,
|
||||
) -> AssetHubRococoChainSpec {
|
||||
AssetHubRococoChainSpec::from_genesis(
|
||||
// Name
|
||||
name,
|
||||
// ID
|
||||
chain_id,
|
||||
ChainType::Local,
|
||||
move || {
|
||||
asset_hub_rococo_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.into(),
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: "rococo-local".into(), para_id },
|
||||
)
|
||||
}
|
||||
|
||||
pub fn asset_hub_rococo_config() -> AssetHubRococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_local_config(properties, "Rococo Asset Hub", "asset-hub-rococo", 1000)
|
||||
}
|
||||
|
||||
pub fn asset_hub_wococo_config() -> AssetHubWococoChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WOC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
asset_hub_rococo_like_config(properties, "Wococo Asset Hub", "asset-hub-wococo", 1000)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_like_config(
|
||||
properties: sc_chain_spec::Properties,
|
||||
name: &str,
|
||||
chain_id: &str,
|
||||
para_id: u32,
|
||||
) -> AssetHubRococoChainSpec {
|
||||
AssetHubRococoChainSpec::from_genesis(
|
||||
// Name
|
||||
name,
|
||||
// ID
|
||||
chain_id,
|
||||
ChainType::Live,
|
||||
move || {
|
||||
asset_hub_rococo_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
// TODO: add invulnerables? from Rockmine?
|
||||
],
|
||||
Vec::new(),
|
||||
para_id.into(),
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: "rococo".into(), para_id },
|
||||
)
|
||||
}
|
||||
|
||||
fn asset_hub_rococo_genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
id: ParaId,
|
||||
) -> asset_hub_rococo_runtime::RuntimeGenesisConfig {
|
||||
asset_hub_rococo_runtime::RuntimeGenesisConfig {
|
||||
system: asset_hub_rococo_runtime::SystemConfig {
|
||||
code: asset_hub_rococo_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
..Default::default()
|
||||
},
|
||||
balances: asset_hub_rococo_runtime::BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, ASSET_HUB_ROCOCO_ED * 524_288))
|
||||
.collect(),
|
||||
},
|
||||
parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig {
|
||||
parachain_id: id,
|
||||
..Default::default()
|
||||
},
|
||||
collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig {
|
||||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
||||
candidacy_bond: ASSET_HUB_ROCOCO_ED * 16,
|
||||
..Default::default()
|
||||
},
|
||||
session: asset_hub_rococo_runtime::SessionConfig {
|
||||
keys: invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
asset_hub_rococo_session_keys(aura), // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user