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:
Adrian Catangiu
2023-10-18 09:47:45 +03:00
committed by GitHub
parent e73729b15f
commit 8b3905d2a5
95 changed files with 14143 additions and 767 deletions
+3
View File
@@ -27,6 +27,7 @@ glutton-runtime = { path = "../parachains/runtimes/glutton/glutton-kusama" }
seedling-runtime = { path = "../parachains/runtimes/starters/seedling" }
asset-hub-polkadot-runtime = { path = "../parachains/runtimes/assets/asset-hub-polkadot" }
asset-hub-kusama-runtime = { path = "../parachains/runtimes/assets/asset-hub-kusama" }
asset-hub-rococo-runtime = { path = "../parachains/runtimes/assets/asset-hub-rococo" }
asset-hub-westend-runtime = { path = "../parachains/runtimes/assets/asset-hub-westend" }
collectives-polkadot-runtime = { path = "../parachains/runtimes/collectives/collectives-polkadot" }
contracts-rococo-runtime = { path = "../parachains/runtimes/contracts/contracts-rococo" }
@@ -108,6 +109,7 @@ default = []
runtime-benchmarks = [
"asset-hub-kusama-runtime/runtime-benchmarks",
"asset-hub-polkadot-runtime/runtime-benchmarks",
"asset-hub-rococo-runtime/runtime-benchmarks",
"asset-hub-westend-runtime/runtime-benchmarks",
"bridge-hub-kusama-runtime/runtime-benchmarks",
"bridge-hub-polkadot-runtime/runtime-benchmarks",
@@ -129,6 +131,7 @@ runtime-benchmarks = [
try-runtime = [
"asset-hub-kusama-runtime/try-runtime",
"asset-hub-polkadot-runtime/try-runtime",
"asset-hub-rococo-runtime/try-runtime",
"asset-hub-westend-runtime/try-runtime",
"bridge-hub-kusama-runtime/try-runtime",
"bridge-hub-polkadot-runtime/try-runtime",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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()
},
}
}
+59
View File
@@ -42,6 +42,8 @@ enum Runtime {
Seedling,
AssetHubPolkadot,
AssetHubKusama,
AssetHubRococo,
AssetHubWococo,
AssetHubWestend,
Penpal(ParaId),
ContractsRococo,
@@ -90,6 +92,10 @@ fn runtime(id: &str) -> Runtime {
Runtime::AssetHubPolkadot
} else if id.starts_with("asset-hub-kusama") | id.starts_with("statemine") {
Runtime::AssetHubKusama
} else if id.starts_with("asset-hub-rococo") {
Runtime::AssetHubRococo
} else if id.starts_with("asset-hub-wococo") {
Runtime::AssetHubWococo
} else if id.starts_with("asset-hub-westend") | id.starts_with("westmint") {
Runtime::AssetHubWestend
} else if id.starts_with("penpal") {
@@ -164,6 +170,31 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
&include_bytes!("../chain-specs/asset-hub-kusama.json")[..],
)?),
// -- Asset Hub Rococo
"asset-hub-rococo-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_rococo_development_config()),
"asset-hub-rococo-local" =>
Box::new(chain_spec::asset_hubs::asset_hub_rococo_local_config()),
// the chain spec as used for generating the upgrade genesis values
"asset-hub-rococo-genesis" => Box::new(chain_spec::asset_hubs::asset_hub_rococo_config()),
// the shell-based chain spec as used for syncing
"asset-hub-rococo" =>
Box::new(chain_spec::asset_hubs::AssetHubRococoChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-rococo.json")[..],
)?),
// -- Asset Hub Wococo
"asset-hub-wococo-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_wococo_development_config()),
"asset-hub-wococo-local" =>
Box::new(chain_spec::asset_hubs::asset_hub_wococo_local_config()),
// the chain spec as used for generating the upgrade genesis values
"asset-hub-wococo-genesis" => Box::new(chain_spec::asset_hubs::asset_hub_wococo_config()),
"asset-hub-wococo" =>
Box::new(chain_spec::asset_hubs::AssetHubWococoChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-wococo.json")[..],
)?),
// -- Asset Hub Westend
"asset-hub-westend-dev" | "westmint-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_westend_development_config()),
@@ -249,6 +280,10 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
),
Runtime::AssetHubKusama =>
Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_file(path)?),
Runtime::AssetHubRococo =>
Box::new(chain_spec::asset_hubs::AssetHubRococoChainSpec::from_json_file(path)?),
Runtime::AssetHubWococo =>
Box::new(chain_spec::asset_hubs::AssetHubWococoChainSpec::from_json_file(path)?),
Runtime::AssetHubWestend => Box::new(
chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_file(path)?,
),
@@ -391,6 +426,13 @@ macro_rules! construct_partials {
)?;
$code
},
Runtime::AssetHubRococo | Runtime::AssetHubWococo => {
let $partials = new_partial::<asset_hub_rococo_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
$code
},
Runtime::AssetHubWestend => {
let $partials = new_partial::<asset_hub_westend_runtime::RuntimeApi, _>(
&$config,
@@ -509,6 +551,16 @@ macro_rules! construct_async_run {
{ $( $code )* }.map(|v| (v, task_manager))
})
},
Runtime::AssetHubRococo | Runtime::AssetHubWococo => {
runner.async_run(|$config| {
let $components = new_partial::<asset_hub_rococo_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
},
Runtime::AssetHubKusama => {
runner.async_run(|$config| {
let $components = new_partial::<asset_hub_kusama_runtime::RuntimeApi, _>(
@@ -850,6 +902,13 @@ pub fn run() -> Result<()> {
.await
.map(|r| r.0)
.map_err(Into::into),
Runtime::AssetHubRococo | Runtime::AssetHubWococo => crate::service::start_asset_hub_node::<
asset_hub_rococo_runtime::RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
Runtime::AssetHubWestend => crate::service::start_asset_hub_node::<
asset_hub_westend_runtime::RuntimeApi,
AuraId,