Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix chainspec resolution #60

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ color-print.workspace = true
substrate-build-script-utils.workspace = true

[features]
default = []
default = ["paseo"]
paseo = [
"pop-runtime-common/paseo",
"pop-runtime-devnet/paseo",
"pop-runtime-testnet/paseo",
]
runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
Expand Down
10 changes: 9 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ pub type TestnetChainSpec =
/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
pub(crate) enum Relay {
#[cfg(not(feature = "paseo"))]
Rococo,
#[cfg(feature = "paseo")]
Paseo,
#[cfg(not(feature = "paseo"))]
RococoLocal,
#[cfg(feature = "paseo")]
PaseoLocal,
}

Expand Down Expand Up @@ -86,13 +90,15 @@ fn configure_for_relay(

match relay {
// Test relay chains
#[cfg(not(feature = "paseo"))]
Relay::Rococo => {
para_id = 4385;
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());

(Extensions { relay_chain: "rococo".into(), para_id }, para_id)
},
#[cfg(feature = "paseo")]
Relay::Paseo => {
para_id = 4001;
properties.insert("tokenSymbol".into(), "PAS".into());
Expand All @@ -101,13 +107,15 @@ fn configure_for_relay(
(Extensions { relay_chain: "paseo".into(), para_id }, para_id)
},
// Local relay chains
#[cfg(not(feature = "paseo"))]
Relay::RococoLocal => {
para_id = 4385;
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());

(Extensions { relay_chain: "rococo-local".into(), para_id }, para_id)
},
#[cfg(feature = "paseo")]
Relay::PaseoLocal => {
para_id = 4001;
properties.insert("tokenSymbol".into(), "PAS".into());
Expand All @@ -128,7 +136,7 @@ pub fn development_config(relay: Relay) -> DevnetChainSpec {
extensions,
)
.with_name("Pop Network Development")
.with_id("pop-dev")
.with_id("pop-devnet")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(devnet_genesis(
// initial collators.
Expand Down
11 changes: 9 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ trait RuntimeResolver {
/// Private helper that pattern matches on the input (which is expected to be a ChainSpec ID)
/// and returns the Runtime accordingly.
fn runtime(id: &str) -> Runtime {
if id.starts_with("dev") {
if id.starts_with("dev") || id.ends_with("devnet") {
Runtime::Devnet
} else if id.starts_with("test") {
} else if id.starts_with("test") || id.ends_with("testnet") {
Runtime::Testnet
} else {
log::warn!("No specific runtime was recognized for ChainSpec's Id: '{}', so Runtime::Devnet will be used", id);
Expand Down Expand Up @@ -64,10 +64,17 @@ impl RuntimeResolver for PathBuf {

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
#[cfg(not(feature = "paseo"))]
"dev-rococo" => Box::new(chain_spec::development_config(Relay::RococoLocal)),
#[cfg(feature = "paseo")]
"dev-paseo" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
#[cfg(not(feature = "paseo"))]
"pop-rococo" => Box::new(chain_spec::testnet_config(Relay::Rococo)),
#[cfg(feature = "paseo")]
"pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
#[cfg(feature = "paseo")]
"" | "local" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
#[cfg(not(feature = "paseo"))]
"" | "local" => Box::new(chain_spec::development_config(Relay::RococoLocal)),
path => {
let path: PathBuf = path.into();
Expand Down
Loading