git.delta.rocks / unique-network / refs/commits / ec4bf05d3dc0

difftreelog

add: westend-local launch config

Igor Kozyrev2021-11-09parent: #dc1fefd.patch.diff
in: master

3 files changed

addedlaunch-config-westend.jsondiffbeforeafterboth
--- /dev/null
+++ b/launch-config-westend.json
@@ -0,0 +1,152 @@
+{
+    "relaychain": {
+        "bin": "../polkadot/target/release/polkadot",
+        "chain": "westend-local",
+        "nodes": [
+            {
+                "name": "alice",
+                "wsPort": 9844,
+                "rpcPort": 9843,
+                "port": 30444,
+                "flags": [
+                    "--rpc-port=9843",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            },
+            {
+                "name": "bob",
+                "wsPort": 9855,
+                "rpcPort": 9854,
+                "port": 30555,
+                "flags": [
+                    "--rpc-port=9854",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            },
+            {
+                "name": "charlie",
+                "wsPort": 9866,
+                "rpcPort": 9865,
+                "port": 30666,
+                "flags": [
+                    "--rpc-port=9865",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            },
+            {
+                "name": "dave",
+                "wsPort": 9877,
+                "rpcPort": 9876,
+                "port": 30777,
+                "flags": [
+                    "--rpc-port=9876",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            },
+            {
+                "name": "eve",
+                "wsPort": 9888,
+                "rpcPort": 9886,
+                "port": 30888,
+                "flags": [
+                    "--rpc-port=9886",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            },
+            {
+                "name": "ferdie",
+                "wsPort": 9897,
+                "rpcPort": 9896,
+                "port": 30999,
+                "flags": [
+                    "--rpc-port=9896",
+                    "-lparachain::candidate_validation=debug"
+                ]
+            }
+        ],
+        "genesis": {
+            "runtime": {
+                "runtime_genesis_config": {
+                    "parachainsConfiguration": {
+                        "config": {
+                            "validation_upgrade_frequency": 1,
+                            "validation_upgrade_delay": 1
+                        }
+                    }
+                }
+            }
+        }
+    },
+    "parachains": [
+        {
+            "bin": "../unique-chain/target/release/nft",
+            "chain": "westend-local",
+            "balance": "1000000000000000000000",
+            "nodes": [
+                {
+                    "port": 31200,
+                    "wsPort": 9944,
+                    "rpcPort": 9933,
+                    "name": "alice",
+                    "flags": [
+                        "--rpc-cors=all",
+                        "--rpc-port=9933",
+                        "--unsafe-rpc-external",
+                        "--unsafe-ws-external"
+                    ]
+                },
+                {
+                    "port": 31201,
+                    "wsPort": 9945,
+                    "rpcPort": 9934,
+                    "name": "bob",
+                    "flags": [
+                        "--rpc-cors=all",
+                        "--rpc-port=9934",
+                        "--unsafe-rpc-external",
+                        "--unsafe-ws-external"
+                    ]
+                },
+                {
+                    "port": 31202,
+                    "wsPort": 9946,
+                    "rpcPort": 9935,
+                    "name": "charlie",
+                    "flags": [
+                        "--rpc-cors=all",
+                        "--rpc-port=9935",
+                        "--unsafe-rpc-external",
+                        "--unsafe-ws-external"
+                    ]
+                },
+                {
+                    "port": 31203,
+                    "wsPort": 9947,
+                    "rpcPort": 9936,
+                    "name": "dave",
+                    "flags": [
+                        "--rpc-cors=all",
+                        "--rpc-port=9936",
+                        "--unsafe-rpc-external",
+                        "--unsafe-ws-external"
+                    ]
+                },
+                {
+                    "port": 31204,
+                    "wsPort": 9948,
+                    "rpcPort": 9937,
+                    "name": "eve",
+                    "flags": [
+                        "--rpc-cors=all",
+                        "--rpc-port=9937",
+                        "--unsafe-rpc-external",
+                        "--unsafe-ws-external"
+                    ]
+                }
+            ]
+        }
+    ],
+    "simpleParachains": [],
+    "hrmpChannels": [],
+    "finalization": false
+}
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
before · node/cli/src/chain_spec.rs
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56use cumulus_primitives_core::ParaId;7use nft_runtime::*;8use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};9use sc_service::ChainType;10use sp_core::{sr25519, Pair, Public};11use sp_runtime::traits::{IdentifyAccount, Verify};12use std::collections::BTreeMap;1314use serde::{Deserialize, Serialize};15use serde_json::map::Map;1617/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.18pub type ChainSpec = sc_service::GenericChainSpec<nft_runtime::GenesisConfig, Extensions>;1920/// Helper function to generate a crypto pair from seed21pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {22	TPublic::Pair::from_string(&format!("//{}", seed), None)23		.expect("static values are valid; qed")24		.public()25}2627/// The extensions for the [`ChainSpec`].28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]29#[serde(deny_unknown_fields)]30pub struct Extensions {31	/// The relay chain of the Parachain.32	pub relay_chain: String,33	/// The id of the Parachain.34	pub para_id: u32,35}3637impl Extensions {38	/// Try to get the extension from the given `ChainSpec`.39	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {40		sc_chain_spec::get_extension(chain_spec.extensions())41	}42}4344type AccountPublic = <Signature as Verify>::Signer;4546/// Helper function to generate an account ID from seed47pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId48where49	AccountPublic: From<<TPublic::Pair as Pair>::Public>,50{51	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()52}5354pub fn development_config(id: ParaId) -> ChainSpec {55	let mut properties = Map::new();56	properties.insert("tokenSymbol".into(), "testUNQ".into());57	properties.insert("tokenDecimals".into(), 15.into());58	properties.insert("ss58Format".into(), 42.into()); // Generic Substrate wildcard (SS58 checksum preimage)5960	ChainSpec::from_genesis(61		// Name62		"Development",63		// ID64		"dev",65		ChainType::Local,66		move || {67			testnet_genesis(68				// Sudo account69				get_account_id_from_seed::<sr25519::Public>("Alice"),70				vec![71					get_from_seed::<AuraId>("Alice"),72					get_from_seed::<AuraId>("Bob"),73				],74				// Pre-funded accounts75				vec![76					get_account_id_from_seed::<sr25519::Public>("Alice"),77					get_account_id_from_seed::<sr25519::Public>("Bob"),78				],79				id,80			)81		},82		// Bootnodes83		vec![],84		// Telemetry85		None,86		// Protocol ID87		None,88		// Properties89		Some(properties),90		// Extensions91		Extensions {92			relay_chain: "rococo-dev".into(),93			para_id: id.into(),94		},95	)96}9798pub fn local_testnet_config(id: ParaId) -> ChainSpec {99	ChainSpec::from_genesis(100		// Name101		"Local Testnet",102		// ID103		"local_testnet",104		ChainType::Local,105		move || {106			testnet_genesis(107				// Sudo account108				get_account_id_from_seed::<sr25519::Public>("Alice"),109				vec![110					get_from_seed::<AuraId>("Alice"),111					get_from_seed::<AuraId>("Bob"),112				],113				// Pre-funded accounts114				vec![115					get_account_id_from_seed::<sr25519::Public>("Alice"),116					get_account_id_from_seed::<sr25519::Public>("Bob"),117					get_account_id_from_seed::<sr25519::Public>("Charlie"),118					get_account_id_from_seed::<sr25519::Public>("Dave"),119					get_account_id_from_seed::<sr25519::Public>("Eve"),120					get_account_id_from_seed::<sr25519::Public>("Ferdie"),121					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),122					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),123					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),124					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),125					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),126					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),127				],128				id,129			)130		},131		// Bootnodes132		vec![],133		// Telemetry134		None,135		// Protocol ID136		None,137		// Properties138		None,139		// Extensions140		Extensions {141			relay_chain: "rococo-local".into(),142			para_id: id.into(),143		},144	)145}146147fn testnet_genesis(148	root_key: AccountId,149	initial_authorities: Vec<AuraId>,150	endowed_accounts: Vec<AccountId>,151	id: ParaId,152) -> GenesisConfig {153	GenesisConfig {154		system: nft_runtime::SystemConfig {155			code: nft_runtime::WASM_BINARY156				.expect("WASM binary was not build, please build it!")157				.to_vec(),158			changes_trie_config: Default::default(),159		},160		balances: BalancesConfig {161			balances: endowed_accounts162				.iter()163				.cloned()164				.map(|k| (k, 1 << 70))165				.collect(),166		},167		treasury: Default::default(),168		sudo: SudoConfig { key: root_key },169		vesting: VestingConfig { vesting: vec![] },170		parachain_info: nft_runtime::ParachainInfoConfig { parachain_id: id },171		aura: nft_runtime::AuraConfig {172			authorities: initial_authorities,173		},174		aura_ext: Default::default(),175		evm: EVMConfig {176			accounts: BTreeMap::new(),177		},178		ethereum: EthereumConfig {},179	}180}
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -42,8 +42,9 @@
 	para_id: ParaId,
 ) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
 	Ok(match id {
+		"westend-local" => Box::new(chain_spec::local_testnet_westend_config(para_id)),
 		"dev" => Box::new(chain_spec::development_config(para_id)),
-		"" | "local" => Box::new(chain_spec::local_testnet_config(para_id)),
+		"" | "local" => Box::new(chain_spec::local_testnet_rococo_config(para_id)),
 		path => Box::new(chain_spec::ChainSpec::from_json_file(
 			std::path::PathBuf::from(path),
 		)?),
@@ -84,7 +85,7 @@
 	}
 
 	fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
-		load_spec(id, self.run.parachain_id.unwrap_or(200).into())
+		load_spec(id, self.run.parachain_id.unwrap_or(2000).into())
 	}
 
 	fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
@@ -217,7 +218,7 @@
 
 			let block: Block = generate_genesis_block(&load_spec(
 				&params.chain.clone().unwrap_or_default(),
-				params.parachain_id.unwrap_or(200).into(),
+				params.parachain_id.unwrap_or(2000).into(),
 			)?)?;
 			let raw_header = block.header().encode();
 			let output_buf = if params.raw {
@@ -280,7 +281,7 @@
 						.chain(cli.relaychain_args.iter()),
 				);
 
-				let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(200));
+				let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(2000));
 
 				let parachain_account =
 					AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);