Skip to content

Commit

Permalink
feat: fix chainspec resolution (#60)
Browse files Browse the repository at this point in the history
* fix: chainspec id resolution

* feat: use paseo as default

Also uses feature within node.

* fix: name dev spec devnet

---------

Co-authored-by: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com>
  • Loading branch information
evilrobot-01 and al3mart authored Mar 29, 2024
1 parent 0d89a49 commit c8425bf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
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

0 comments on commit c8425bf

Please sign in to comment.