From b239fe0acc353acf3f71b779af15005c2d33ed8d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 11 Jul 2018 13:01:16 +0200 Subject: [PATCH] PoC-2 tweaks (#293) - Rename poc-2 to staging - Make telemetry default for global chains --- polkadot/cli/src/chain_spec.rs | 10 +++++----- polkadot/cli/src/cli.yml | 10 +++++++--- polkadot/cli/src/lib.rs | 24 ++++++++++++++++-------- polkadot/service/src/chain_spec.rs | 10 +++++----- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/polkadot/cli/src/chain_spec.rs b/polkadot/cli/src/chain_spec.rs index 84fad99da5..e5dc6f280b 100644 --- a/polkadot/cli/src/chain_spec.rs +++ b/polkadot/cli/src/chain_spec.rs @@ -29,8 +29,8 @@ pub enum ChainSpec { LocalTestnet, /// The PoC-1 testnet. PoC1Testnet, - /// The PoC-2 testnet. - PoC2Testnet, + /// Whatever the current runtime is with the "global testnet" defaults. + StagingTestnet, /// Custom Genesis file. Custom(String), } @@ -42,7 +42,7 @@ impl ChainSpec { ChainSpec::PoC1Testnet => service::ChainSpec::poc_1_testnet_config()?, ChainSpec::Development => service::ChainSpec::development_config(), ChainSpec::LocalTestnet => service::ChainSpec::local_testnet_config(), - ChainSpec::PoC2Testnet => service::ChainSpec::poc_2_testnet_config(), + ChainSpec::StagingTestnet => service::ChainSpec::staging_testnet_config(), ChainSpec::Custom(f) => service::ChainSpec::from_json_file(PathBuf::from(f))?, }) } @@ -54,7 +54,7 @@ impl<'a> From<&'a str> for ChainSpec { "dev" => ChainSpec::Development, "local" => ChainSpec::LocalTestnet, "poc-1" => ChainSpec::PoC1Testnet, - "poc-2" => ChainSpec::PoC2Testnet, + "staging" => ChainSpec::StagingTestnet, s => ChainSpec::Custom(s.into()), } } @@ -66,7 +66,7 @@ impl From for String { ChainSpec::Development => "dev".into(), ChainSpec::LocalTestnet => "local".into(), ChainSpec::PoC1Testnet => "poc-1".into(), - ChainSpec::PoC2Testnet => "poc-2".into(), + ChainSpec::StagingTestnet => "staging".into(), ChainSpec::Custom(f) => format!("custom ({})", f), } } diff --git a/polkadot/cli/src/cli.yml b/polkadot/cli/src/cli.yml index 9a50338311..bae81c5fd0 100644 --- a/polkadot/cli/src/cli.yml +++ b/polkadot/cli/src/cli.yml @@ -69,7 +69,7 @@ args: - chain: long: chain value_name: CHAIN_SPEC - help: Specify the chain specification (one of dev, local or poc-2) + help: Specify the chain specification (one of poc-1, dev, local or staging) takes_value: true - pruning: long: pruning @@ -84,7 +84,11 @@ args: - telemetry: short: t long: telemetry - help: Should connect to the Polkadot telemetry server (off by default) + help: Should connect to the Polkadot telemetry server (telemetry is off by default on local chains) + takes_value: false + - no-telemetry: + long: no-telemetry + help: Should not connect to the Polkadot telemetry server (telemetry is on by default on global chains) takes_value: false - telemetry-url: long: telemetry-url @@ -102,7 +106,7 @@ subcommands: - chain: long: chain value_name: CHAIN_SPEC - help: Specify the chain specification (one of dev, local or poc-2) + help: Specify the chain specification (one of poc-1, dev, local or staging) takes_value: true - export-blocks: about: Export blocks to a file diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 9d2846b8e5..6c0f44bd17 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -106,13 +106,17 @@ impl substrate_rpc::system::SystemApi for SystemConfiguration { } } -fn load_spec(matches: &clap::ArgMatches) -> Result { +fn load_spec(matches: &clap::ArgMatches) -> Result<(service::ChainSpec, bool), String> { let chain_spec = matches.value_of("chain") .map(ChainSpec::from) - .unwrap_or_else(|| if matches.is_present("dev") { ChainSpec::Development } else { ChainSpec::PoC2Testnet }); + .unwrap_or_else(|| if matches.is_present("dev") { ChainSpec::Development } else { ChainSpec::StagingTestnet }); + let is_global = match chain_spec { + ChainSpec::PoC1Testnet | ChainSpec::StagingTestnet => true, + _ => false, + }; let spec = chain_spec.load()?; info!("Chain specification: {}", spec.name()); - Ok(spec) + Ok((spec, is_global)) } fn base_path(matches: &clap::ArgMatches) -> PathBuf { @@ -186,7 +190,7 @@ pub fn run(args: I, worker: W) -> error::Result<()> where return import_blocks(matches, worker.exit_only()); } - let spec = load_spec(&matches)?; + let (spec, is_global) = load_spec(&matches)?; let mut config = service::Configuration::default_with_spec(spec); if let Some(name) = matches.value_of("name") { @@ -260,7 +264,11 @@ pub fn run(args: I, worker: W) -> error::Result<()> where let mut runtime = Runtime::new()?; let executor = runtime.executor(); - let _guard = if matches.is_present("telemetry") || matches.value_of("telemetry-url").is_some() { + let telemetry_enabled = + matches.is_present("telemetry") + || matches.value_of("telemetry-url").is_some() + || (is_global && !matches.is_present("no-telemetry")); + let _guard = if telemetry_enabled { let name = config.name.clone(); let chain_name = config.chain_spec.name().to_owned(); Some(init_telemetry(TelemetryConfig { @@ -290,7 +298,7 @@ pub fn run(args: I, worker: W) -> error::Result<()> where } fn build_spec(matches: &clap::ArgMatches) -> error::Result<()> { - let spec = load_spec(&matches)?; + let (spec, _) = load_spec(&matches)?; info!("Building chain spec"); let json = spec.to_json(matches.is_present("raw"))?; print!("{}", json); @@ -301,7 +309,7 @@ fn export_blocks(matches: &clap::ArgMatches, exit: E) -> error::Result<()> where E: Future + Send + 'static { let base_path = base_path(matches); - let spec = load_spec(&matches)?; + let (spec, _) = load_spec(&matches)?; let mut config = service::Configuration::default_with_spec(spec); config.database_path = db_path(&base_path).to_string_lossy().into(); info!("DB path: {}", config.database_path); @@ -365,7 +373,7 @@ fn export_blocks(matches: &clap::ArgMatches, exit: E) -> error::Result<()> fn import_blocks(matches: &clap::ArgMatches, exit: E) -> error::Result<()> where E: Future + Send + 'static { - let spec = load_spec(&matches)?; + let (spec, _) = load_spec(&matches)?; let base_path = base_path(matches); let mut config = service::Configuration::default_with_spec(spec); config.database_path = db_path(&base_path).to_string_lossy().into(); diff --git a/polkadot/service/src/chain_spec.rs b/polkadot/service/src/chain_spec.rs index 3c323f22f8..6249fca7e4 100644 --- a/polkadot/service/src/chain_spec.rs +++ b/polkadot/service/src/chain_spec.rs @@ -136,7 +136,7 @@ impl ChainSpec { Self::from_embedded(include_bytes!("../res/poc-1.json")) } - fn poc_2_testnet_config_genesis() -> Genesis { + fn staging_testnet_config_genesis() -> Genesis { let initial_authorities = vec![ hex!["82c39b31a2b79a90f8e66e7a77fdb85a4ed5517f2ae39f6a80565e8ecae85cf5"].into(), hex!["4de37a07567ebcbf8c64568428a835269a566723687058e017b6d69db00a77e7"].into(), @@ -200,16 +200,16 @@ impl ChainSpec { }), }) } - /// PoC-2 testnet config. - pub fn poc_2_testnet_config() -> Self { + /// Staging testnet config. + pub fn staging_testnet_config() -> Self { let boot_nodes = vec![ "enode://a93a29fa68d965452bf0ff8c1910f5992fe2273a72a1ee8d3a3482f68512a61974211ba32bb33f051ceb1530b8ba3527fc36224ba6b9910329025e6d9153cf50@104.211.54.233:30333".into(), "enode://051b18f63a316c4c5fef4631f8c550ae0adba179153588406fac3e5bbbbf534ebeda1bf475dceda27a531f6cdef3846ab6a010a269aa643a1fec7bff51af66bd@104.211.48.51:30333".into(), "enode://c831ec9011d2c02d2c4620fc88db6d897a40d2f88fd75f47b9e4cf3b243999acb6f01b7b7343474650b34eeb1363041a422a91f1fc3850e43482983ee15aa582@104.211.48.247:30333".into(), ]; ChainSpec { - spec: ChainSpecFile { name: "PoC-2 Testnet".to_owned(), boot_nodes }, - genesis: GenesisSource::Factory(Self::poc_2_testnet_config_genesis), + spec: ChainSpecFile { name: "Staging Testnet".to_owned(), boot_nodes }, + genesis: GenesisSource::Factory(Self::staging_testnet_config_genesis), } }