Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

More timely block import notifications #306

Merged
merged 5 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ substrate/pwasm-alloc/Cargo.lock
substrate/pwasm-libc/Cargo.lock
demo/runtime/wasm/target/
**/._*
.vscode
.vscode
polkadot.*
2 changes: 2 additions & 0 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 polkadot/cli/src/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
let client = service.client();
let display_block_import = client.import_notification_stream().for_each(|n| {
info!(target: "polkadot", "Imported #{} ({})", n.header.number, n.hash);
telemetry!("block.import"; "height" => n.header.number, "best" => ?n.hash);
Ok(())
});

Expand Down
2 changes: 2 additions & 0 deletions substrate/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ triehash = "0.1"
hex-literal = "0.1"
futures = "0.1.17"
ed25519 = { path = "../ed25519" }
slog = "^2"
substrate-bft = { path = "../bft" }
substrate-codec = { path = "../codec" }
substrate-executor = { path = "../executor" }
Expand All @@ -20,6 +21,7 @@ substrate-runtime-support = { path = "../runtime-support" }
substrate-runtime-primitives = { path = "../runtime/primitives" }
substrate-state-machine = { path = "../state-machine" }
substrate-keyring = { path = "../../substrate/keyring" }
substrate-telemetry = { path = "../telemetry" }

[dev-dependencies]
substrate-test-client = { path = "../test-client" }
3 changes: 2 additions & 1 deletion substrate/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use futures::sync::mpsc;
use parking_lot::{Mutex, RwLock};
use primitives::AuthorityId;
use runtime_primitives::{bft::Justification, generic::{BlockId, SignedBlock, Block as RuntimeBlock}};
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One};
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, As};
use runtime_primitives::BuildStorage;
use primitives::storage::{StorageKey, StorageData};
use codec::Slicable;
Expand Down Expand Up @@ -335,6 +335,7 @@ impl<B, E, Block> Client<B, E, Block> where

let is_new_best = header.number() == &(self.backend.blockchain().info()?.best_number + One::one());
trace!("Imported {}, (#{}), best={}, origin={:?}", hash, header.number(), is_new_best, origin);
telemetry!("block.import"; "height" => { let n: u64 = header.number().as_(); n }, "best" => ?hash, "is_new_best" => is_new_best, "origin" => ?origin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we please wrap this 158char line ;) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called after import_lock is released in import_block.

let unchecked: bft::UncheckedJustification<_> = justification.uncheck().into();
transaction.set_block_data(header.clone(), body, Some(unchecked.into()), is_new_best)?;
if let Some(storage_update) = storage_update {
Expand Down
2 changes: 2 additions & 0 deletions substrate/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern crate substrate_runtime_primitives as runtime_primitives;
extern crate substrate_state_machine as state_machine;
#[cfg(test)] extern crate substrate_keyring as keyring;
#[cfg(test)] extern crate substrate_test_client as test_client;
#[macro_use] extern crate substrate_telemetry;
#[macro_use] extern crate slog; // needed until we can reexport `slog_info` from `substrate_telemetry`

extern crate ed25519;
extern crate futures;
Expand Down
2 changes: 1 addition & 1 deletion substrate/telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard
first_time: true, // ensures that on_connect will be called.
}
).fuse()
).build().fuse(), o!()
).chan_size(262144).overflow_strategy(slog_async::OverflowStrategy::DropAndReport).build().fuse(), o!()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this number mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

256kb of buffer length to store info in before dropping entries, I suppose, @pepyakin ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sure. Can we leave a comment? Just a lil bit wary about magic numbers.

);
slog_scope::set_global_logger(log)
}
Expand Down