Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit d3d9596

Browse files
jordy25519bkchrandresilvatomakakianenigma
authored
upstream patch fixes (#160)
* Fixes logging of target names with dashes (#7281) * Fixes logging of target names with dashes There was a bug in tracing-core which resulted in not supporting dashes in target names. This was fixed upstream. Besides that a test was added to ensure that we don't break this again. * Extend test * client: fix log filters (#7241) * client: fix multiple logger filters * client: add test for log filters setup * Fix logging from inside the WASM runtime (#7355) * Fix logging from inside the WASM runtime When using `RuntimeLogger` to log something from the runtime, we didn't set any logging level. So, we actually did not log anything from the runtime as logging is disabled by default. This pr fixes that by setting the logging level to `TRACE`. It also adds a test to ensure this does not break again ;) * Update frame/support/src/debug.rs * Print an error if an unregistered notifications protocol is used (#7457) * Print an error if an nregistered notifications protocol is used * Print an error if an nregistered notifications protocol is used * Update client/network/src/service.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix wrong outgoing calculation in election (#7384) * Fix wrong outgoing calculation in election * Add test. * Lil bit better naming. * grandpa: fix tests * *: Bump async-std to v1.6.5 (#7306) * *: Bump async-std to v1.6.5 Prevent users from using v1.6.4 which faces issues receiving incoming TCP connections. See async-rs/async-std#888 for details. * client/network/src/gossip: Use channel instead of condvar `async_std::sync::Condvar::wait_timeout` uses `gloo_timers::callback::Timeout` when compiled for `wasm32-unknown-unknown`. This timeout implementation does not fulfill the requirement of being `Send`. Instead of using a `Condvar` use a `futures::channel::mpsc` to signal progress from the `QueuedSender` to the background `Future`. * client/network/Cargo.toml: Remove async-std unstable feature * client/network/src/gossip: Forward all queued messages * client/network/gossip: Have QueuedSender methods take &mut self * client/network/gossip: Move queue_size_limit into QueuedSender The `queue_size_limit` field is only accessed by `QueuedSender`, thus there is no need to share it between the background future and the `QueuedSender`. * client/network/gossip: Rename background task to future To be a bit picky the background task is not a task in the sense of an asynchonous task, but rather a background future in the sense of `futures::future::Future`. * client/network: Remove option to disable yamux flow control (#7358) With the `OnRead` flow control option yamux "send[s] window updates only when data is read on the receiving end" and not as soon as "a Stream's receive window drops to 0". Yamux flow control has proven itself. This commit removes the feature flag. Yamux flow control is now always enabled. * Make `queryStorage` and `storagePairs` unsafe RPC functions (#7342) The RPC calls can be rather expensive and can easily bring a RPC node in some problems ;) * consensus: prioritize finality work over block import in queue (#7307) * consensus: prioritize finality work over block import in queue * consensus: add test for import queue task priority * sync: only restart peers not doing finality related requests (#7322) * sync: only restart peers not doing finality related requests * sync: add test for sync restart * sync: add better docs to restart method * Undo phragmen merge * grandpa: fix early enactment of forced changes (#7321) * grandpa: fix early enactment of forced authority set changes * grandpa: add test for early enactment of forced changes * grandpa: fix typo in log message * grandpa: only allow one pending forced change per fork * grandpa: fix tests Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: André Silva <andrerfosilva@gmail.com> Co-authored-by: Max Inden <mail@max-inden.de>
1 parent c0ee046 commit d3d9596

File tree

30 files changed

+1105
-358
lines changed

30 files changed

+1105
-358
lines changed

Cargo.lock

Lines changed: 130 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/cli/src/lib.rs

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use structopt::{
4343
clap::{self, AppSettings},
4444
StructOpt,
4545
};
46-
use tracing_subscriber::layer::SubscriberExt;
46+
use tracing_subscriber::{filter::Directive, layer::SubscriberExt};
4747

4848
/// Substrate client CLI
4949
///
@@ -234,6 +234,13 @@ pub fn init_logger(
234234
tracing_receiver: sc_tracing::TracingReceiver,
235235
tracing_targets: Option<String>,
236236
) -> std::result::Result<(), String> {
237+
fn parse_directives(dirs: impl AsRef<str>) -> Vec<Directive> {
238+
dirs.as_ref()
239+
.split(',')
240+
.filter_map(|s| s.parse().ok())
241+
.collect()
242+
}
243+
237244
if let Err(e) = tracing_log::LogTracer::init() {
238245
return Err(format!(
239246
"Registering Substrate logger failed: {:}!", e
@@ -257,7 +264,7 @@ pub fn init_logger(
257264
if lvl != "" {
258265
// We're not sure if log or tracing is available at this moment, so silently ignore the
259266
// parse error.
260-
if let Ok(directive) = lvl.parse() {
267+
for directive in parse_directives(lvl) {
261268
env_filter = env_filter.add_directive(directive);
262269
}
263270
}
@@ -266,7 +273,7 @@ pub fn init_logger(
266273
if pattern != "" {
267274
// We're not sure if log or tracing is available at this moment, so silently ignore the
268275
// parse error.
269-
if let Ok(directive) = pattern.parse() {
276+
for directive in parse_directives(pattern) {
270277
env_filter = env_filter.add_directive(directive);
271278
}
272279
}
@@ -299,3 +306,76 @@ pub fn init_logger(
299306
}
300307
Ok(())
301308
}
309+
mod tests {
310+
use super::*;
311+
use tracing::{metadata::Kind, subscriber::Interest, Callsite, Level, Metadata};
312+
use std::{process::Command, env};
313+
314+
#[test]
315+
fn test_logger_filters() {
316+
let test_pattern = "afg=debug,sync=trace,client=warn,telemetry,something-with-dash=error";
317+
init_logger(&test_pattern, Default::default(), Default::default()).unwrap();
318+
319+
tracing::dispatcher::get_default(|dispatcher| {
320+
let test_filter = |target, level| {
321+
struct DummyCallSite;
322+
impl Callsite for DummyCallSite {
323+
fn set_interest(&self, _: Interest) {}
324+
fn metadata(&self) -> &Metadata<'_> {
325+
unreachable!();
326+
}
327+
}
328+
329+
let metadata = tracing::metadata!(
330+
name: "",
331+
target: target,
332+
level: level,
333+
fields: &[],
334+
callsite: &DummyCallSite,
335+
kind: Kind::SPAN,
336+
);
337+
338+
dispatcher.enabled(&metadata)
339+
};
340+
341+
assert!(test_filter("afg", Level::INFO));
342+
assert!(test_filter("afg", Level::DEBUG));
343+
assert!(!test_filter("afg", Level::TRACE));
344+
345+
assert!(test_filter("sync", Level::TRACE));
346+
assert!(test_filter("client", Level::WARN));
347+
348+
assert!(test_filter("telemetry", Level::TRACE));
349+
assert!(test_filter("something-with-dash", Level::ERROR));
350+
});
351+
}
352+
353+
const EXPECTED_LOG_MESSAGE: &'static str = "yeah logging works as expected";
354+
355+
#[test]
356+
fn dash_in_target_name_works() {
357+
let executable = env::current_exe().unwrap();
358+
let output = Command::new(executable)
359+
.env("ENABLE_LOGGING", "1")
360+
.args(&["--nocapture", "log_something_with_dash_target_name"])
361+
.output()
362+
.unwrap();
363+
364+
let output = String::from_utf8(output.stderr).unwrap();
365+
assert!(output.contains(EXPECTED_LOG_MESSAGE));
366+
}
367+
368+
/// This is no actual test, it will be used by the `dash_in_target_name_works` test.
369+
/// The given test will call the test executable to only execute this test that
370+
/// will only print `EXPECTED_LOG_MESSAGE` through logging while using a target
371+
/// name that contains a dash. This ensures that targets names with dashes work.
372+
#[test]
373+
fn log_something_with_dash_target_name() {
374+
if env::var("ENABLE_LOGGING").is_ok() {
375+
let test_pattern = "test-target=info";
376+
init_logger(&test_pattern, Default::default(), Default::default()).unwrap();
377+
378+
log::info!(target: "test-target", "{}", EXPECTED_LOG_MESSAGE);
379+
}
380+
}
381+
}

client/cli/src/params/network_params.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ pub struct NetworkParams {
9292
#[structopt(flatten)]
9393
pub node_key_params: NodeKeyParams,
9494

95-
/// Disable the yamux flow control. This option will be removed in the future once there is
96-
/// enough confidence that this feature is properly working.
97-
#[structopt(long)]
98-
pub no_yamux_flow_control: bool,
99-
10095
/// Enable peer discovery on local networks.
10196
///
10297
/// By default this option is true for `--dev` and false otherwise.
@@ -158,7 +153,6 @@ impl NetworkParams {
158153
enable_mdns: !is_dev && !self.no_mdns,
159154
allow_private_ipv4: !self.no_private_ipv4,
160155
wasm_external_transport: None,
161-
use_yamux_flow_control: !self.no_yamux_flow_control,
162156
},
163157
max_parallel_downloads: self.max_parallel_downloads,
164158
allow_non_globals_in_dht: self.discover_local || is_dev,

0 commit comments

Comments
 (0)