Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Get rid of ParaID parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Nov 11, 2021
1 parent 3694c76 commit 5139dfc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
18 changes: 9 additions & 9 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn canvas_session_keys(keys: AuraId) -> canvas_runtime::SessionKeys {
canvas_runtime::SessionKeys { aura: keys }
}

pub fn development_config(id: ParaId) -> ChainSpec {
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(), "ROC".into());
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn development_config(id: ParaId) -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
id,
1234.into(),
)
},
vec![],
Expand All @@ -123,12 +123,12 @@ pub fn development_config(id: ParaId) -> ChainSpec {
None,
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: id.into(),
para_id: 1234,
},
)
}

pub fn local_testnet_config(id: ParaId) -> 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(), "ROC".into());
Expand Down Expand Up @@ -168,7 +168,7 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
id,
1234.into(),
)
},
// Bootnodes
Expand All @@ -182,12 +182,12 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
// Extensions
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: id.into(),
para_id: 1234,
},
)
}

pub fn rococo_testnet_config(id: ParaId) -> ChainSpec {
pub fn rococo_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(), "ROC".into());
Expand Down Expand Up @@ -248,7 +248,7 @@ pub fn rococo_testnet_config(id: ParaId) -> ChainSpec {
// AccountId of an account which `ink-waterfall` uses for automated testing
hex!["0e47e2344d523c3cc5c34394b0d58b9a4200e813a038e6c5a6163cc07d70b069"].into(),
],
id,
1234.into(),
)
},
// Bootnodes
Expand All @@ -273,7 +273,7 @@ pub fn rococo_testnet_config(id: ParaId) -> ChainSpec {
// Properties
Some(properties),
// Extensions
Extensions { relay_chain: "rococo".into(), para_id: id.into() },
Extensions { relay_chain: "rococo".into(), para_id: 1234 },
)
}

Expand Down
15 changes: 7 additions & 8 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ use std::{io::Write, net::SocketAddr};

fn load_spec(
id: &str,
para_id: ParaId,
) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config(para_id)),
"canvas-rococo" => Box::new(chain_spec::rococo_testnet_config(para_id)),
"" | "local" => Box::new(chain_spec::local_testnet_config(para_id)),
"dev" => Box::new(chain_spec::development_config()),
"canvas-rococo" => Box::new(chain_spec::rococo_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 @@ -78,7 +77,7 @@ impl SubstrateCli for Cli {
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id, self.run.parachain_id.unwrap_or(1002).into())
load_spec(id)
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand Down Expand Up @@ -212,7 +211,6 @@ pub fn run() -> Result<()> {

let block: Block = generate_genesis_block(&load_spec(
&params.chain.clone().unwrap_or_default(),
params.parachain_id.unwrap_or(1002).into(),
)?)?;
let raw_header = block.header().encode();
let output_buf = if params.raw {
Expand Down Expand Up @@ -265,14 +263,15 @@ pub fn run() -> Result<()> {

runner.run_node_until_exit(|config| async move {
let para_id =
chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id);
chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain extension for chain-spec.")?;

let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()),
);

let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(1002));
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
Expand Down
25 changes: 20 additions & 5 deletions polkadot-launch/config.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
{
"relaychain": {
"bin": "../../polkadot/target/release/polkadot",
"bin": "../../polkadot-mbp/target/release/polkadot",
"chain": "rococo-local",
"nodes": [
{
"name": "alice",
"wsPort": 9944,
"port": 30444
"port": 30444,
"flags": [
"--rpc-cors=all",
"--unsafe-rpc-external",
"--unsafe-ws-external",
"--execution=wasm"
]
},
{
"name": "bob",
"wsPort": 9955,
"port": 30555
"port": 30555,
"flags": [
"--rpc-cors=all",
"--unsafe-rpc-external",
"--unsafe-ws-external",
"--execution=wasm"
]
}
]
},
"parachains": [
{
"bin": "../target/release/canvas",
"bin": "./target/release/canvas",
"id": "200",
"balance": "1000000000000000000000",
"nodes": [
Expand All @@ -27,7 +39,10 @@
"port": 31200,
"flags": [
"--",
"--execution=wasm"
"--rpc-cors=all",
"--unsafe-rpc-external",
"--unsafe-ws-external",
"--execution=wasm"
]
}
]
Expand Down

0 comments on commit 5139dfc

Please sign in to comment.