Skip to content

Commit

Permalink
Merge pull request #110 from paseo-network/al3mart/feat-bridge-hub-specs
Browse files Browse the repository at this point in the history
Al3mart/feat bridge hub specs (release backport)
  • Loading branch information
al3mart authored Jul 31, 2024
2 parents 8efa92c + f24489b commit d660f0f
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 571 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ repository.workspace = true
license.workspace = true

[dependencies]
clap = { features = [ "derive" ] , workspace = true }
clap = { features = ["derive"], workspace = true }
serde_json = { workspace = true }
serde = { features = ["derive"] , workspace = true }
serde = { features = ["derive"], workspace = true }

# Local dependencies
paseo-runtime = { path = "../relay/paseo" }
paseo-runtime-constants = { path = "../relay/paseo/constants", default-features = true }
asset-hub-paseo-runtime = { path = "../system-parachains/asset-hub-paseo", default-features = true }
bridge-hub-paseo-runtime = { path = "../system-parachains/bridge-hub-paseo", default-features = true }
system-parachains-constants = { path = "../system-parachains/constants", default-features = true }

# External dependencies
sc-chain-spec = { workspace = true }
runtime-parachains = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
Expand All @@ -29,15 +34,13 @@ parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }

[features]
fast-runtime = [
"paseo-runtime/fast-runtime"
]
fast-runtime = ["paseo-runtime/fast-runtime"]
runtime-benchmarks = [
"paseo-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks"
"paseo-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
10 changes: 7 additions & 3 deletions chain-spec-generator/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::{
relay_chain_specs::PaseoChainSpec,
//system_parachains_specs::{AssetHubPaseoChainSpec},
system_parachains_specs::{AssetHubPaseoChainSpec, BridgeHubPaseoChainSpec},
ChainSpec,
};
use polkadot_primitives::{AccountId, AccountPublic};
Expand Down Expand Up @@ -71,8 +71,12 @@ pub fn from_json_file(filepath: &str, supported: String) -> Result<Box<dyn Chain
x if x.starts_with("paseo") | x.starts_with("dot") => {
Ok(Box::new(PaseoChainSpec::from_json_file(path)?))
},
/* x if x.starts_with("asset-hub-paseo") =>
Ok(Box::new(AssetHubPolkadotChainSpec::from_json_file(path)?)), */
x if x.starts_with("asset-hub-paseo") => {
Ok(Box::new(AssetHubPaseoChainSpec::from_json_file(path)?))
},
x if x.starts_with("bridge-hub-paseo") => {
Ok(Box::new(BridgeHubPaseoChainSpec::from_json_file(path)?))
},
_ => Err(format!("Unknown chain 'id' in json file. Only supported: {supported}'")),
}
}
19 changes: 14 additions & 5 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::collections::HashMap;

mod common;
mod relay_chain_specs;
//mod system_parachains_specs;
mod system_parachains_specs;

#[derive(Parser)]
struct Cli {
Expand All @@ -40,20 +40,29 @@ fn main() -> Result<(), String> {
HashMap::<_, Box<dyn Fn() -> Result<Box<dyn ChainSpec>, String>>>::from([
("paseo-dev", Box::new(|| relay_chain_specs::paseo_development_config()) as Box<_>),
("paseo-local", Box::new(|| relay_chain_specs::paseo_local_testnet_config()) as Box<_>),
/* (
(
"asset-hub-paseo-local",
Box::new(|| system_parachains_specs::asset_hub_paseo_local_testnet_config())
as Box<_>,
) */
),
(
"bridge-hub-paseo",
Box::new(|| system_parachains_specs::bridge_hub_paseo_config()) as Box<_>,
),
(
"bridge-hub-paseo-local",
Box::new(|| system_parachains_specs::bridge_hub_paseo_local_testnet_config())
as Box<_>,
),
]);

if let Some(function) = supported_chains.get(&*cli.chain) {
let chain_spec = (*function)()?.as_json(cli.raw)?;
print!("{chain_spec}");
Ok(())
} else {
let supported = supported_chains.keys().enumerate().fold(String::new(), |c, (n, k)| {
let extra = (n + 1 < supported_chains.len()).then(|| ", ").unwrap_or("");
let supported = supported_chains.keys().enumerate().fold(String::new(), |c, (n, k)| {
let extra = if n + 1 < supported_chains.len() { ", " } else { "" };
format!("{c}{k}{extra}")
});
if cli.chain.ends_with(".json") {
Expand Down
Loading

0 comments on commit d660f0f

Please sign in to comment.