Telemetry (Slog + WS) (#217)

* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* Dispatch returns result.

* session & staking tests updated

* Fix democracy tests.

* Fix council tests.

* Fix up polkadot parachains in runtime

* Fix borked merge

* More Slicable support

Support general `Option` and array types.

* Basic storage types.

* Existential deposit for contract creation

* Basic implemnetation along with removals

* Fix tests.

* externalities builder fix.

* Tests.

* Fix up the runtime.

* Fix tests.

* Add generic `Address` type.

* Initial function integration of Address into Extrinsic.

* Fix build

* All tests compile.

* Fix (some) tests.

* Fix signing.

* Push error.

* transfer can accept Address

* Make Address generic over AccountIndex

* Fix test

* Make Council use Address for dispatch.

* Fix build

* Bend over backwards to support braindead derive.

* Repot some files.

* Fix tests.

* Fix grumbles

* Remove Default bound

* Fix build for new nightly.

* Make `apply_extrinsic` never panic, return useful Result.

* More merge hell

* Doesn't build, but might do soon

* Serde woes

* get substrate-runtime-staking compiling

* Polkadot builds again!

* Fix all build.

* Fix tests & binaries.

* Reserve some extra initial byte values of address for future format changes

* Make semantic of `ReservedBalance` clear.

* Fix panic handler.

* Integrate other balance transformations into the new model

Fix up staking tests.

* Fix runtime tests.

* Fix panic build.

* Tests for demonstrating interaction between balance types.

* Repot some runtime code

* Fix checkedblock in non-std builds

* Get rid of `DoLookup` phantom.

* Attempt to make transaction_pool work with lookups.

* Remove vscode settings

* New attempt at making transaction pool work.

* It builds again!

* --all builds

* Fix tests.

* New build.

* Test account nonce reset.

* polkadot transaction pool tests/framework.

* Initial draft (working).

* Address grumbles.

* Revert bad `map_or`

* Rebuild binaries, workaround.

* Avoid checking in vscode

* reconnecting, shared, slog

* CLI options for name and telemetry url

* ensure telemetry url imples enabled

* Avoid casting to usize early.

* Provide on-connect event for session message

* Better port

* heartbeat and some renaming

* transaction pool stuff

* minor renaming.

* report telemetry

* cleanups.

* Fix for previous cleanup

* Initial draft (working).

* Avoid checking in vscode

* reconnecting, shared, slog

* CLI options for name and telemetry url

* ensure telemetry url imples enabled

* Provide on-connect event for session message

* Better port

* heartbeat and some renaming

* transaction pool stuff

* minor renaming.

* report telemetry

* cleanups.

* Fix for previous cleanup

* Address grumble

* Final grumble and repot telemetry to substrate

* Fix comment

* Please build, travis...
This commit is contained in:
Gav Wood
2018-06-20 18:49:01 +02:00
committed by GitHub
parent 711306e524
commit 8e2f0274e6
8 changed files with 137 additions and 21 deletions
+48 -1
View File
@@ -22,7 +22,7 @@ pub use network::NetworkConfiguration;
/// The chain specification (this should eventually be replaced by a more general JSON-based chain
/// specification).
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub enum ChainSpec {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
@@ -32,6 +32,47 @@ pub enum ChainSpec {
PoC2Testnet,
}
/// Synonym for Option<ChainSpec> because we cannot `impl From<..> for Option<ChainSpec>`
pub struct OptionChainSpec(Option<ChainSpec>);
impl OptionChainSpec {
/// Return the inner part.
pub fn inner(self) -> Option<ChainSpec> {
self.0
}
}
impl<'a> From<&'a str> for OptionChainSpec {
fn from(s: &'a str) -> Self {
OptionChainSpec(Some(match s {
"dev" => ChainSpec::Development,
"local" => ChainSpec::LocalTestnet,
"poc-2" => ChainSpec::PoC2Testnet,
_ => return OptionChainSpec(None),
}))
}
}
impl From<ChainSpec> for &'static str {
fn from(s: ChainSpec) -> &'static str {
match s {
ChainSpec::Development => "dev",
ChainSpec::LocalTestnet => "local",
ChainSpec::PoC2Testnet => "poc-2",
}
}
}
impl ::std::fmt::Display for ChainSpec {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "{}", match *self {
ChainSpec::Development => "Development",
ChainSpec::LocalTestnet => "Local Testnet",
ChainSpec::PoC2Testnet => "PoC-2 Testnet",
})
}
}
/// Service configuration.
#[derive(Clone)]
pub struct Configuration {
@@ -49,6 +90,10 @@ pub struct Configuration {
pub keys: Vec<String>,
/// Chain specification.
pub chain_spec: ChainSpec,
/// Telemetry server URL, optional - only `Some` if telemetry reporting is enabled
pub telemetry: Option<String>,
/// Node name.
pub name: String,
}
impl Default for Configuration {
@@ -61,6 +106,8 @@ impl Default for Configuration {
database_path: Default::default(),
keys: Default::default(),
chain_spec: ChainSpec::Development,
telemetry: Default::default(),
name: "Anonymous".into(),
}
}
}
+10 -4
View File
@@ -19,8 +19,8 @@
extern crate futures;
extern crate ed25519;
extern crate clap;
extern crate exit_future;
extern crate parking_lot;
extern crate tokio_timer;
extern crate polkadot_primitives;
extern crate polkadot_runtime;
@@ -40,9 +40,13 @@ extern crate tokio_core;
extern crate substrate_client as client;
extern crate substrate_client_db as client_db;
#[macro_use]
extern crate substrate_telemetry;
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate slog; // needed until we can reexport `slog_info` from `substrate_telemetry`
#[macro_use]
extern crate log;
#[macro_use]
extern crate hex_literal;
@@ -71,7 +75,7 @@ use network::ManageNetwork;
use exit_future::Signal;
pub use self::error::{ErrorKind, Error};
pub use config::{Configuration, Role, ChainSpec};
pub use config::{Configuration, Role, OptionChainSpec, ChainSpec};
type CodeExecutor = NativeExecutor<LocalDispatch>;
@@ -410,7 +414,8 @@ impl<B, E> Service<B, E>
let (client, on_demand) = client_creator(db_settings, executor, genesis_builder)?;
let api = api_creator(client.clone());
let best_header = client.best_block_header()?;
info!("Starting Polkadot. Best block is #{}", best_header.number);
info!("Best block is #{}", best_header.number);
telemetry!("node.start"; "height" => best_header.number, "best" => ?best_header.hash());
let transaction_pool = Arc::new(TransactionPool::new(config.transaction_pool));
let transaction_pool_adapter = Arc::new(TransactionPoolAdapter {
pool: transaction_pool.clone(),
@@ -430,6 +435,7 @@ impl<B, E> Service<B, E>
let barrier = ::std::sync::Arc::new(Barrier::new(2));
on_demand.map(|on_demand| on_demand.set_service_link(Arc::downgrade(&network)));
let thread = {
let client = client.clone();
let network = network.clone();
@@ -445,11 +451,11 @@ impl<B, E> Service<B, E>
// block notifications
let network1 = network.clone();
let txpool1 = txpool.clone();
let events = client.import_notification_stream()
.for_each(move |notification| {
network1.on_block_imported(notification.hash, &notification.header);
prune_imported(&*api, &*txpool1, notification.hash);
Ok(())
});
core.handle().spawn(events);