Skip to content

Commit

Permalink
Remove 'local' runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Mar 11, 2024
1 parent 2123283 commit 7feac80
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 1,269 deletions.
41 changes: 0 additions & 41 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,5 @@ parachain-info = { package = "staging-parachain-info", git = "https://github.com

# Local
regionx-primitives = { path = "./primitives", default-features = false }
local-runtime = { path = "./runtime/local" }
regionx-runtime = { path = "./runtime/regionx" }
pallet-parachain-template = { path = "./pallets/template", default-features = false }
20 changes: 4 additions & 16 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ name = "regionx-node"
version = "0.1.0"
description.workspace = true
build = "build.rs"
default-run = "regionx-node"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[[bin]]
name = "regionx-node"
path = "bin/main.rs"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
clap = { workspace = true, features = ["derive"]}
log = { workspace = true }
Expand All @@ -25,6 +17,10 @@ jsonrpsee = { workspace = true, features = ["server"] }
futures = { workspace = true }
serde_json = { wokrspace = true }

# Local
regionx-runtime = { workspace = true }
regionx-primitives = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true }
frame-benchmarking-cli = { workspace = true }
Expand All @@ -35,8 +31,6 @@ sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-offchain = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-aura = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-executor = { workspace = true }
sc-network = { workspace = true }
sc-network-sync = { workspace = true }
Expand All @@ -51,7 +45,6 @@ sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-consensus-grandpa = { workspace = true }
sp-core = { workspace = true }
sp-keystore = { workspace = true }
sp-io = { workspace = true }
Expand All @@ -78,11 +71,6 @@ cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
color-print = { workspace = true }

# Local
regionx-runtime = { workspace = true }
local-runtime = { workspace = true }
regionx-primitives = { workspace = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true }

Expand Down
3 changes: 0 additions & 3 deletions node/bin/main.rs

This file was deleted.

4 changes: 2 additions & 2 deletions node/src/parachain/chain_spec.rs → node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn template_session_keys(keys: AuraId) -> regionx_runtime::SessionKeys {
pub fn development_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "M4X".into());
properties.insert("tokenSymbol".into(), "REGX".into());
properties.insert("tokenDecimals".into(), 12.into());
// TODO: chose an ss58Format
properties.insert("ss58Format".into(), 42.into());
Expand Down Expand Up @@ -115,7 +115,7 @@ pub fn development_config() -> ChainSpec {
pub fn local_testnet_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "M4X".into());
properties.insert("tokenSymbol".into(), "REGX".into());
properties.insert("tokenDecimals".into(), 12.into());
// TODO: chose an ss58Format
properties.insert("ss58Format".into(), 42.into());
Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl RelayChainCli {
para_config: &sc_service::Configuration,
relay_chain_args: impl Iterator<Item = &'a String>,
) -> Self {
let extension = crate::parachain::chain_spec::Extensions::try_get(&*para_config.chain_spec);
let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.path().join("polkadot");
Self {
Expand Down
74 changes: 17 additions & 57 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,17 @@ use sc_service::config::{BasePath, PrometheusConfig};
use sp_runtime::traits::AccountIdConversion;

use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
local,
parachain::{self, chain_spec},
service::new_partial,
};

trait IdentifyChain {
fn is_dev(&self) -> bool;
fn is_regionx(&self) -> bool;
}

impl IdentifyChain for dyn sc_service::ChainSpec {
fn is_dev(&self) -> bool {
self.id().starts_with("dev")
}
fn is_regionx(&self) -> bool {
self.id().starts_with("regionx")
}
}

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(local::development_config()?),
"regionx-dev" => Box::new(chain_spec::development_config()),
"regionx-rococo" | "regionx-local" => Box::new(chain_spec::local_testnet_config()),
path => {
// TODO:
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
},
"dev" => Box::new(chain_spec::development_config()),
"regionx-rococo" => Box::new(chain_spec::local_testnet_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}

Expand Down Expand Up @@ -119,8 +102,7 @@ macro_rules! construct_async_run {
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
let runner = $cli.create_runner($cmd)?;
runner.async_run(|$config| {
// TODO: shouldn't assume `parachain`.
let $components = parachain::new_partial(&$config)?;
let $components = new_partial(&$config)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
Expand Down Expand Up @@ -183,13 +165,9 @@ pub fn run() -> Result<()> {
Some(Subcommand::ExportGenesisHead(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
if config.chain_spec.is_dev() {
let partials = local::new_partial(&config)?;
cmd.run(partials.client)
}else {
let partials = parachain::new_partial(&config)?;
cmd.run(partials.client)
}
let partials = new_partial(&config)?;

cmd.run(partials.client)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand All @@ -212,13 +190,8 @@ pub fn run() -> Result<()> {
.into())
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
if config.chain_spec.is_dev() {
let partials = local::new_partial(&config)?;
cmd.run(partials.client)
}else {
let partials = parachain::new_partial(&config)?;
cmd.run(partials.client)
}
let partials = new_partial(&config)?;
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) =>
Expand All @@ -230,19 +203,10 @@ pub fn run() -> Result<()> {
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
if config.chain_spec.is_dev() {
let partials = local::new_partial(&config)?;

let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
}else {
let partials = parachain::new_partial(&config)?;

let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
}
let partials = new_partial(&config)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
}),
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
Expand All @@ -265,10 +229,6 @@ pub fn run() -> Result<()> {
}))
.flatten();

if config.chain_spec.is_dev() {
return local::start_node(config).map_err(Into::into);
}

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or("Could not find parachain ID in chain-spec.")?;
Expand All @@ -293,7 +253,7 @@ pub fn run() -> Result<()> {
info!("Parachain Account: {parachain_account}");
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

parachain::service::start_regionx_node(
crate::service::start_parachain_node(
config,
polkadot_config,
collator_options,
Expand Down
9 changes: 0 additions & 9 deletions node/src/lib.rs

This file was deleted.

Loading

0 comments on commit 7feac80

Please sign in to comment.