more resilient subsystems (#1908)

* backing: extract log target

* bitfield-signing: extract log target

* utils: fix a typo

* provisioner: extract log target

* candidate selection: remove unused error variant

* bitfield-distribution: change the return type of run

* pov-distribution: extract log target

* collator-protocol: simplify runtime request

* collation-generation: do not exit early on error

* collation-generation: do not exit on double init

* collator-protocol: do not exit on errors and rename LOG_TARGET

* collator-protocol: a workaround for ununused imports warning

* Update node/network/bitfield-distribution/src/lib.rs

* collation-generation: elevate warn! to error!

* collator-protocol: fix imports

* post merge fix

* fix compilation
This commit is contained in:
Andronik Ordian
2020-11-05 14:22:41 +01:00
committed by GitHub
parent c418758ebc
commit 2cde7732da
11 changed files with 122 additions and 105 deletions
+4 -2
View File
@@ -68,6 +68,8 @@ use statement_table::{
};
use thiserror::Error;
const LOG_TARGET: &str = "candidate_backing";
#[derive(Debug, Error)]
enum Error {
#[error("Candidate is not found")]
@@ -763,7 +765,7 @@ impl util::JobTrait for CandidateBackingJob {
Ok(x) => x,
Err(e) => {
log::warn!(
target: "candidate_backing",
target: LOG_TARGET,
"Failed to fetch runtime API data for job: {:?}",
e,
);
@@ -803,7 +805,7 @@ impl util::JobTrait for CandidateBackingJob {
Err(util::Error::NotAValidator) => { return Ok(()) },
Err(e) => {
log::warn!(
target: "candidate_backing",
target: LOG_TARGET,
"Cannot participate in candidate backing: {:?}",
e
);
@@ -40,6 +40,7 @@ use thiserror::Error;
/// Delay between starting a bitfield signing job and its attempting to create a bitfield.
const JOB_DELAY: Duration = Duration::from_millis(1500);
const LOG_TARGET: &str = "bitfield_signing";
/// Each `BitfieldSigningJob` prepares a signed bitfield for a single relay parent.
pub struct BitfieldSigningJob;
@@ -163,7 +164,7 @@ async fn get_core_availability(
Ok(None) => return Ok(false),
Err(e) => {
// Don't take down the node on runtime API errors.
log::warn!(target: "bitfield_signing", "Encountered a runtime API error: {:?}", e);
log::warn!(target: LOG_TARGET, "Encountered a runtime API error: {:?}", e);
return Ok(false);
}
};
@@ -288,7 +289,7 @@ impl JobTrait for BitfieldSigningJob {
{
Err(Error::Runtime(runtime_err)) => {
// Don't take down the node on runtime API errors.
log::warn!(target: "bitfield_signing", "Encountered a runtime API error: {:?}", runtime_err);
log::warn!(target: LOG_TARGET, "Encountered a runtime API error: {:?}", runtime_err);
return Ok(());
}
Err(err) => return Err(err),
@@ -24,8 +24,10 @@ use futures::{
prelude::*,
};
use polkadot_node_subsystem::{
errors::{ChainApiError, RuntimeApiError},
messages::{AllMessages, CandidateBackingMessage, CandidateSelectionMessage, CollatorProtocolMessage},
errors::ChainApiError,
messages::{
AllMessages, CandidateBackingMessage, CandidateSelectionMessage, CollatorProtocolMessage,
},
};
use polkadot_node_subsystem_util::{
self as util, delegated_subsystem, JobTrait, ToJobTrait,
@@ -118,8 +120,6 @@ enum Error {
OneshotRecv(#[from] oneshot::Canceled),
#[error(transparent)]
ChainApi(#[from] ChainApiError),
#[error(transparent)]
Runtime(#[from] RuntimeApiError),
}
impl JobTrait for CandidateSelectionJob {
+5 -2
View File
@@ -45,6 +45,8 @@ use std::{convert::TryFrom, pin::Pin};
use std::collections::BTreeMap;
use thiserror::Error;
const LOG_TARGET: &str = "provisioner";
struct ProvisioningJob {
relay_parent: Hash,
sender: mpsc::Sender<FromJob>,
@@ -203,7 +205,7 @@ impl ProvisioningJob {
)
.await
{
log::warn!(target: "provisioner", "failed to assemble or send inherent data: {:?}", err);
log::warn!(target: LOG_TARGET, "failed to assemble or send inherent data: {:?}", err);
self.metrics.on_inherent_data_request(Err(()));
} else {
self.metrics.on_inherent_data_request(Ok(()));
@@ -459,7 +461,8 @@ fn bitfields_indicate_availability(
// however, in practice, that would just push off an error-handling routine which would look a whole lot like this one.
// simpler to just handle the error internally here.
log::warn!(
target: "provisioner", "attempted to set a transverse bit at idx {} which is greater than bitfield size {}",
target: LOG_TARGET,
"attempted to set a transverse bit at idx {} which is greater than bitfield size {}",
validator_idx,
availability_len,
);