mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
Use LOG_TARGET in consensus related crates (#12875)
* Use shared LOG_TARGET in consensus related crates * Rename target from "afg" to "grandpa"
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
use crate::{
|
||||
aura_err, authorities, find_pre_digest, slot_author, AuthorityId, CompatibilityMode, Error,
|
||||
LOG_TARGET,
|
||||
};
|
||||
use codec::{Codec, Decode, Encode};
|
||||
use log::{debug, info, trace};
|
||||
@@ -88,7 +89,7 @@ where
|
||||
.map_err(Error::Client)?
|
||||
{
|
||||
info!(
|
||||
target: "aura",
|
||||
target: LOG_TARGET,
|
||||
"Slot author is equivocating at slot {} with headers {:?} and {:?}",
|
||||
slot,
|
||||
equivocation_proof.first_header.hash(),
|
||||
@@ -256,7 +257,7 @@ where
|
||||
block.body = Some(inner_body);
|
||||
}
|
||||
|
||||
trace!(target: "aura", "Checked {:?}; importing.", pre_header);
|
||||
trace!(target: LOG_TARGET, "Checked {:?}; importing.", pre_header);
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_TRACE;
|
||||
@@ -272,7 +273,7 @@ where
|
||||
Ok((block, None))
|
||||
},
|
||||
CheckedHeader::Deferred(a, b) => {
|
||||
debug!(target: "aura", "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||
debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
|
||||
@@ -72,6 +72,8 @@ pub use sp_consensus_aura::{
|
||||
AuraApi, ConsensusLog, SlotDuration, AURA_ENGINE_ID,
|
||||
};
|
||||
|
||||
const LOG_TARGET: &str = "aura";
|
||||
|
||||
type AuthorityId<P> = <P as Pair>::Public;
|
||||
|
||||
/// Run `AURA` in a compatibility mode.
|
||||
@@ -530,7 +532,7 @@ where
|
||||
}
|
||||
|
||||
fn aura_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
||||
debug!(target: "aura", "{}", error);
|
||||
debug!(target: LOG_TARGET, "{}", error);
|
||||
error
|
||||
}
|
||||
|
||||
@@ -580,10 +582,10 @@ pub fn find_pre_digest<B: BlockT, Signature: Codec>(header: &B::Header) -> Resul
|
||||
|
||||
let mut pre_digest: Option<Slot> = None;
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "aura", "Checking log {:?}", log);
|
||||
trace!(target: LOG_TARGET, "Checking log {:?}", log);
|
||||
match (CompatibleDigestItem::<Signature>::as_aura_pre_digest(log), pre_digest.is_some()) {
|
||||
(Some(_), true) => return Err(aura_err(Error::MultipleHeaders)),
|
||||
(None, _) => trace!(target: "aura", "Ignoring digest not meant for us"),
|
||||
(None, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||
(s, false) => pre_digest = s,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use codec::{Decode, Encode};
|
||||
use log::info;
|
||||
|
||||
use crate::{migration::EpochV0, Epoch};
|
||||
use crate::{migration::EpochV0, Epoch, LOG_TARGET};
|
||||
use sc_client_api::backend::AuxStore;
|
||||
use sc_consensus_epochs::{
|
||||
migration::{EpochChangesV0For, EpochChangesV1For},
|
||||
@@ -82,7 +82,7 @@ pub fn load_epoch_changes<Block: BlockT, B: AuxStore>(
|
||||
let epoch_changes =
|
||||
SharedEpochChanges::<Block, Epoch>::new(maybe_epoch_changes.unwrap_or_else(|| {
|
||||
info!(
|
||||
target: "babe",
|
||||
target: LOG_TARGET,
|
||||
"👶 Creating empty BABE epoch changes on what appears to be first startup.",
|
||||
);
|
||||
EpochChangesFor::<Block, Epoch>::default()
|
||||
|
||||
@@ -149,6 +149,8 @@ pub mod aux_schema;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
const LOG_TARGET: &str = "babe";
|
||||
|
||||
/// BABE epoch information
|
||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
|
||||
pub struct Epoch {
|
||||
@@ -323,7 +325,7 @@ impl<B: BlockT> From<Error<B>> for String {
|
||||
}
|
||||
|
||||
fn babe_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
||||
debug!(target: "babe", "{}", error);
|
||||
debug!(target: LOG_TARGET, "{}", error);
|
||||
error
|
||||
}
|
||||
|
||||
@@ -345,7 +347,7 @@ where
|
||||
let block_id = if client.usage_info().chain.finalized_state.is_some() {
|
||||
BlockId::Hash(client.usage_info().chain.best_hash)
|
||||
} else {
|
||||
debug!(target: "babe", "No finalized state is available. Reading config from genesis");
|
||||
debug!(target: LOG_TARGET, "No finalized state is available. Reading config from genesis");
|
||||
BlockId::Hash(client.usage_info().chain.genesis_hash)
|
||||
};
|
||||
|
||||
@@ -486,7 +488,7 @@ where
|
||||
telemetry,
|
||||
};
|
||||
|
||||
info!(target: "babe", "👶 Starting BABE Authorship worker");
|
||||
info!(target: LOG_TARGET, "👶 Starting BABE Authorship worker");
|
||||
|
||||
let slot_worker = sc_consensus_slots::start_slot_worker(
|
||||
babe_link.config.slot_duration(),
|
||||
@@ -523,12 +525,8 @@ fn aux_storage_cleanup<C: HeaderMetadata<Block> + HeaderBackend<Block>, Block: B
|
||||
Ok(meta) => {
|
||||
hashes.insert(meta.parent);
|
||||
},
|
||||
Err(err) => warn!(
|
||||
target: "babe",
|
||||
"Failed to lookup metadata for block `{:?}`: {}",
|
||||
first,
|
||||
err,
|
||||
),
|
||||
Err(err) =>
|
||||
warn!(target: LOG_TARGET, "Failed to lookup metadata for block `{:?}`: {}", first, err,),
|
||||
}
|
||||
|
||||
// Cleans data for finalized block's ancestors
|
||||
@@ -716,7 +714,7 @@ where
|
||||
type AuxData = ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>;
|
||||
|
||||
fn logging_target(&self) -> &'static str {
|
||||
"babe"
|
||||
LOG_TARGET
|
||||
}
|
||||
|
||||
fn block_import(&mut self) -> &mut Self::BlockImport {
|
||||
@@ -749,7 +747,7 @@ where
|
||||
slot: Slot,
|
||||
epoch_descriptor: &ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>,
|
||||
) -> Option<Self::Claim> {
|
||||
debug!(target: "babe", "Attempting to claim slot {}", slot);
|
||||
debug!(target: LOG_TARGET, "Attempting to claim slot {}", slot);
|
||||
let s = authorship::claim_slot(
|
||||
slot,
|
||||
self.epoch_changes
|
||||
@@ -760,7 +758,7 @@ where
|
||||
);
|
||||
|
||||
if s.is_some() {
|
||||
debug!(target: "babe", "Claimed slot {}", slot);
|
||||
debug!(target: LOG_TARGET, "Claimed slot {}", slot);
|
||||
}
|
||||
|
||||
s
|
||||
@@ -777,7 +775,7 @@ where
|
||||
Ok(()) => true,
|
||||
Err(e) =>
|
||||
if e.is_full() {
|
||||
warn!(target: "babe", "Trying to notify a slot but the channel is full");
|
||||
warn!(target: LOG_TARGET, "Trying to notify a slot but the channel is full");
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@@ -904,10 +902,10 @@ pub fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<PreDigest, Error
|
||||
|
||||
let mut pre_digest: Option<_> = None;
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "babe", "Checking log {:?}, looking for pre runtime digest", log);
|
||||
trace!(target: LOG_TARGET, "Checking log {:?}, looking for pre runtime digest", log);
|
||||
match (log.as_babe_pre_digest(), pre_digest.is_some()) {
|
||||
(Some(_), true) => return Err(babe_err(Error::MultiplePreRuntimeDigests)),
|
||||
(None, _) => trace!(target: "babe", "Ignoring digest not meant for us"),
|
||||
(None, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||
(s, false) => pre_digest = s,
|
||||
}
|
||||
}
|
||||
@@ -920,13 +918,13 @@ fn find_next_epoch_digest<B: BlockT>(
|
||||
) -> Result<Option<NextEpochDescriptor>, Error<B>> {
|
||||
let mut epoch_digest: Option<_> = None;
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "babe", "Checking log {:?}, looking for epoch change digest.", log);
|
||||
trace!(target: LOG_TARGET, "Checking log {:?}, looking for epoch change digest.", log);
|
||||
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
||||
match (log, epoch_digest.is_some()) {
|
||||
(Some(ConsensusLog::NextEpochData(_)), true) =>
|
||||
return Err(babe_err(Error::MultipleEpochChangeDigests)),
|
||||
(Some(ConsensusLog::NextEpochData(epoch)), false) => epoch_digest = Some(epoch),
|
||||
_ => trace!(target: "babe", "Ignoring digest not meant for us"),
|
||||
_ => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,13 +937,13 @@ fn find_next_config_digest<B: BlockT>(
|
||||
) -> Result<Option<NextConfigDescriptor>, Error<B>> {
|
||||
let mut config_digest: Option<_> = None;
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "babe", "Checking log {:?}, looking for epoch change digest.", log);
|
||||
trace!(target: LOG_TARGET, "Checking log {:?}, looking for epoch change digest.", log);
|
||||
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
||||
match (log, config_digest.is_some()) {
|
||||
(Some(ConsensusLog::NextConfigData(_)), true) =>
|
||||
return Err(babe_err(Error::MultipleConfigChangeDigests)),
|
||||
(Some(ConsensusLog::NextConfigData(config)), false) => config_digest = Some(config),
|
||||
_ => trace!(target: "babe", "Ignoring digest not meant for us"),
|
||||
_ => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,7 +1073,10 @@ where
|
||||
None => match generate_key_owner_proof(&best_id)? {
|
||||
Some(proof) => proof,
|
||||
None => {
|
||||
debug!(target: "babe", "Equivocation offender is not part of the authority set.");
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Equivocation offender is not part of the authority set."
|
||||
);
|
||||
return Ok(())
|
||||
},
|
||||
},
|
||||
@@ -1091,7 +1092,7 @@ where
|
||||
)
|
||||
.map_err(Error::RuntimeApi)?;
|
||||
|
||||
info!(target: "babe", "Submitted equivocation report for author {:?}", author);
|
||||
info!(target: LOG_TARGET, "Submitted equivocation report for author {:?}", author);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1121,7 +1122,7 @@ where
|
||||
mut block: BlockImportParams<Block, ()>,
|
||||
) -> BlockVerificationResult<Block> {
|
||||
trace!(
|
||||
target: "babe",
|
||||
target: LOG_TARGET,
|
||||
"Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}",
|
||||
block.origin,
|
||||
block.header,
|
||||
@@ -1140,7 +1141,11 @@ where
|
||||
return Ok((block, Default::default()))
|
||||
}
|
||||
|
||||
debug!(target: "babe", "We have {:?} logs in this header", block.header.digest().logs().len());
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"We have {:?} logs in this header",
|
||||
block.header.digest().logs().len()
|
||||
);
|
||||
|
||||
let create_inherent_data_providers = self
|
||||
.create_inherent_data_providers
|
||||
@@ -1204,7 +1209,10 @@ where
|
||||
)
|
||||
.await
|
||||
{
|
||||
warn!(target: "babe", "Error checking/reporting BABE equivocation: {}", err);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Error checking/reporting BABE equivocation: {}", err
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(inner_body) = block.body {
|
||||
@@ -1233,7 +1241,7 @@ where
|
||||
block.body = Some(inner_body);
|
||||
}
|
||||
|
||||
trace!(target: "babe", "Checked {:?}; importing.", pre_header);
|
||||
trace!(target: LOG_TARGET, "Checked {:?}; importing.", pre_header);
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_TRACE;
|
||||
@@ -1252,7 +1260,7 @@ where
|
||||
Ok((block, Default::default()))
|
||||
},
|
||||
CheckedHeader::Deferred(a, b) => {
|
||||
debug!(target: "babe", "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||
debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
@@ -1520,21 +1528,23 @@ where
|
||||
log::Level::Info
|
||||
};
|
||||
|
||||
log!(target: "babe",
|
||||
log_level,
|
||||
"👶 New epoch {} launching at block {} (block slot {} >= start slot {}).",
|
||||
viable_epoch.as_ref().epoch_index,
|
||||
hash,
|
||||
slot,
|
||||
viable_epoch.as_ref().start_slot,
|
||||
log!(
|
||||
target: LOG_TARGET,
|
||||
log_level,
|
||||
"👶 New epoch {} launching at block {} (block slot {} >= start slot {}).",
|
||||
viable_epoch.as_ref().epoch_index,
|
||||
hash,
|
||||
slot,
|
||||
viable_epoch.as_ref().start_slot,
|
||||
);
|
||||
|
||||
let next_epoch = viable_epoch.increment((next_epoch_descriptor, epoch_config));
|
||||
|
||||
log!(target: "babe",
|
||||
log_level,
|
||||
"👶 Next epoch starts at slot {}",
|
||||
next_epoch.as_ref().start_slot,
|
||||
log!(
|
||||
target: LOG_TARGET,
|
||||
log_level,
|
||||
"👶 Next epoch starts at slot {}",
|
||||
next_epoch.as_ref().start_slot,
|
||||
);
|
||||
|
||||
// prune the tree of epochs not part of the finalized chain or
|
||||
@@ -1565,7 +1575,7 @@ where
|
||||
};
|
||||
|
||||
if let Err(e) = prune_and_import() {
|
||||
debug!(target: "babe", "Failed to launch next epoch: {}", e);
|
||||
debug!(target: LOG_TARGET, "Failed to launch next epoch: {}", e);
|
||||
*epoch_changes =
|
||||
old_epoch_changes.expect("set `Some` above and not taken; qed");
|
||||
return Err(e)
|
||||
|
||||
@@ -323,7 +323,7 @@ impl TestNetFactory for BabeTestNet {
|
||||
use substrate_test_runtime_client::DefaultTestClientBuilderExt;
|
||||
|
||||
let client = client.as_client();
|
||||
trace!(target: "babe", "Creating a verifier");
|
||||
trace!(target: LOG_TARGET, "Creating a verifier");
|
||||
|
||||
// ensure block import and verifier are linked correctly.
|
||||
let data = maybe_link
|
||||
@@ -352,12 +352,12 @@ impl TestNetFactory for BabeTestNet {
|
||||
}
|
||||
|
||||
fn peer(&mut self, i: usize) -> &mut BabePeer {
|
||||
trace!(target: "babe", "Retrieving a peer");
|
||||
trace!(target: LOG_TARGET, "Retrieving a peer");
|
||||
&mut self.peers[i]
|
||||
}
|
||||
|
||||
fn peers(&self) -> &Vec<BabePeer> {
|
||||
trace!(target: "babe", "Retrieving peers");
|
||||
trace!(target: LOG_TARGET, "Retrieving peers");
|
||||
&self.peers
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ fn can_author_block() {
|
||||
// with secondary slots enabled it should never be empty
|
||||
match claim_slot(i.into(), &epoch, &keystore) {
|
||||
None => i += 1,
|
||||
Some(s) => debug!(target: "babe", "Authored block {:?}", s.0),
|
||||
Some(s) => debug!(target: LOG_TARGET, "Authored block {:?}", s.0),
|
||||
}
|
||||
|
||||
// otherwise with only vrf-based primary slots we might need to try a couple
|
||||
@@ -593,7 +593,7 @@ fn can_author_block() {
|
||||
match claim_slot(i.into(), &epoch, &keystore) {
|
||||
None => i += 1,
|
||||
Some(s) => {
|
||||
debug!(target: "babe", "Authored block {:?}", s.0);
|
||||
debug!(target: LOG_TARGET, "Authored block {:?}", s.0);
|
||||
break
|
||||
},
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! Verification for BABE headers.
|
||||
use super::{
|
||||
use crate::{
|
||||
authorship::{calculate_primary_threshold, check_primary_threshold, secondary_slot_author},
|
||||
babe_err, find_pre_digest, BlockT, Epoch, Error,
|
||||
babe_err, find_pre_digest, BlockT, Epoch, Error, LOG_TARGET,
|
||||
};
|
||||
use log::{debug, trace};
|
||||
use sc_consensus_slots::CheckedHeader;
|
||||
@@ -67,7 +67,7 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
let authorities = &epoch.authorities;
|
||||
let pre_digest = pre_digest.map(Ok).unwrap_or_else(|| find_pre_digest::<B>(&header))?;
|
||||
|
||||
trace!(target: "babe", "Checking header");
|
||||
trace!(target: LOG_TARGET, "Checking header");
|
||||
let seal = header
|
||||
.digest_mut()
|
||||
.pop()
|
||||
@@ -93,7 +93,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
|
||||
match &pre_digest {
|
||||
PreDigest::Primary(primary) => {
|
||||
debug!(target: "babe",
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Verifying primary block #{} at slot: {}",
|
||||
header.number(),
|
||||
primary.slot,
|
||||
@@ -104,7 +105,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
PreDigest::SecondaryPlain(secondary)
|
||||
if epoch.config.allowed_slots.is_secondary_plain_slots_allowed() =>
|
||||
{
|
||||
debug!(target: "babe",
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Verifying secondary plain block #{} at slot: {}",
|
||||
header.number(),
|
||||
secondary.slot,
|
||||
@@ -115,7 +117,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
PreDigest::SecondaryVRF(secondary)
|
||||
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
|
||||
{
|
||||
debug!(target: "babe",
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Verifying secondary VRF block #{} at slot: {}",
|
||||
header.number(),
|
||||
secondary.slot,
|
||||
|
||||
@@ -45,6 +45,8 @@ use crate::{
|
||||
pub use basic_queue::BasicQueue;
|
||||
use sp_consensus::{error::Error as ConsensusError, BlockOrigin, CacheKeyId};
|
||||
|
||||
const LOG_TARGET: &str = "sync::import-queue";
|
||||
|
||||
/// A commonly-used Import Queue type.
|
||||
///
|
||||
/// This defines the transaction type of the `BasicQueue` to be the transaction type for a client.
|
||||
@@ -247,15 +249,15 @@ pub(crate) async fn import_single_block_metered<
|
||||
(Some(header), justifications) => (header, justifications),
|
||||
(None, _) => {
|
||||
if let Some(ref peer) = peer {
|
||||
debug!(target: "sync", "Header {} was not provided by {} ", block.hash, peer);
|
||||
debug!(target: LOG_TARGET, "Header {} was not provided by {} ", block.hash, peer);
|
||||
} else {
|
||||
debug!(target: "sync", "Header {} was not provided ", block.hash);
|
||||
debug!(target: LOG_TARGET, "Header {} was not provided ", block.hash);
|
||||
}
|
||||
return Err(BlockImportError::IncompleteHeader(peer))
|
||||
},
|
||||
};
|
||||
|
||||
trace!(target: "sync", "Header {} has {:?} logs", block.hash, header.digest().logs().len());
|
||||
trace!(target: LOG_TARGET, "Header {} has {:?} logs", block.hash, header.digest().logs().len());
|
||||
|
||||
let number = *header.number();
|
||||
let hash = block.hash;
|
||||
@@ -263,27 +265,31 @@ pub(crate) async fn import_single_block_metered<
|
||||
|
||||
let import_handler = |import| match import {
|
||||
Ok(ImportResult::AlreadyInChain) => {
|
||||
trace!(target: "sync", "Block already in chain {}: {:?}", number, hash);
|
||||
trace!(target: LOG_TARGET, "Block already in chain {}: {:?}", number, hash);
|
||||
Ok(BlockImportStatus::ImportedKnown(number, peer))
|
||||
},
|
||||
Ok(ImportResult::Imported(aux)) =>
|
||||
Ok(BlockImportStatus::ImportedUnknown(number, aux, peer)),
|
||||
Ok(ImportResult::MissingState) => {
|
||||
debug!(target: "sync", "Parent state is missing for {}: {:?}, parent: {:?}",
|
||||
number, hash, parent_hash);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Parent state is missing for {}: {:?}, parent: {:?}", number, hash, parent_hash
|
||||
);
|
||||
Err(BlockImportError::MissingState)
|
||||
},
|
||||
Ok(ImportResult::UnknownParent) => {
|
||||
debug!(target: "sync", "Block with unknown parent {}: {:?}, parent: {:?}",
|
||||
number, hash, parent_hash);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Block with unknown parent {}: {:?}, parent: {:?}", number, hash, parent_hash
|
||||
);
|
||||
Err(BlockImportError::UnknownParent)
|
||||
},
|
||||
Ok(ImportResult::KnownBad) => {
|
||||
debug!(target: "sync", "Peer gave us a bad block {}: {:?}", number, hash);
|
||||
debug!(target: LOG_TARGET, "Peer gave us a bad block {}: {:?}", number, hash);
|
||||
Err(BlockImportError::BadBlock(peer))
|
||||
},
|
||||
Err(e) => {
|
||||
debug!(target: "sync", "Error importing block {}: {:?}: {}", number, hash, e);
|
||||
debug!(target: LOG_TARGET, "Error importing block {}: {:?}: {}", number, hash, e);
|
||||
Err(BlockImportError::Other(e))
|
||||
},
|
||||
};
|
||||
@@ -324,9 +330,16 @@ pub(crate) async fn import_single_block_metered<
|
||||
|
||||
let (import_block, maybe_keys) = verifier.verify(import_block).await.map_err(|msg| {
|
||||
if let Some(ref peer) = peer {
|
||||
trace!(target: "sync", "Verifying {}({}) from {} failed: {}", number, hash, peer, msg);
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Verifying {}({}) from {} failed: {}",
|
||||
number,
|
||||
hash,
|
||||
peer,
|
||||
msg
|
||||
);
|
||||
} else {
|
||||
trace!(target: "sync", "Verifying {}({}) failed: {}", number, hash, msg);
|
||||
trace!(target: LOG_TARGET, "Verifying {}({}) failed: {}", number, hash, msg);
|
||||
}
|
||||
if let Some(metrics) = metrics.as_ref() {
|
||||
metrics.report_verification(false, started.elapsed());
|
||||
|
||||
@@ -35,7 +35,7 @@ use crate::{
|
||||
buffered_link::{self, BufferedLinkReceiver, BufferedLinkSender},
|
||||
import_single_block_metered, BlockImportError, BlockImportStatus, BoxBlockImport,
|
||||
BoxJustificationImport, ImportQueue, ImportQueueService, IncomingBlock, Link,
|
||||
RuntimeOrigin, Verifier,
|
||||
RuntimeOrigin, Verifier, LOG_TARGET,
|
||||
},
|
||||
metrics::Metrics,
|
||||
};
|
||||
@@ -129,14 +129,14 @@ impl<B: BlockT> ImportQueueService<B> for BasicQueueHandle<B> {
|
||||
return
|
||||
}
|
||||
|
||||
trace!(target: "sync", "Scheduling {} blocks for import", blocks.len());
|
||||
trace!(target: LOG_TARGET, "Scheduling {} blocks for import", blocks.len());
|
||||
let res = self
|
||||
.block_import_sender
|
||||
.unbounded_send(worker_messages::ImportBlocks(origin, blocks));
|
||||
|
||||
if res.is_err() {
|
||||
log::error!(
|
||||
target: "sync",
|
||||
target: LOG_TARGET,
|
||||
"import_blocks: Background import task is no longer alive"
|
||||
);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ impl<B: BlockT> ImportQueueService<B> for BasicQueueHandle<B> {
|
||||
|
||||
if res.is_err() {
|
||||
log::error!(
|
||||
target: "sync",
|
||||
target: LOG_TARGET,
|
||||
"import_justification: Background import task is no longer alive"
|
||||
);
|
||||
}
|
||||
@@ -179,7 +179,10 @@ impl<B: BlockT, Transaction: Send> ImportQueue<B> for BasicQueue<B, Transaction>
|
||||
/// Poll actions from network.
|
||||
fn poll_actions(&mut self, cx: &mut Context, link: &mut dyn Link<B>) {
|
||||
if self.result_port.poll_actions(cx, link).is_err() {
|
||||
log::error!(target: "sync", "poll_actions: Background import task is no longer alive");
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"poll_actions: Background import task is no longer alive"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +234,7 @@ async fn block_import_process<B: BlockT, Transaction: Send + 'static>(
|
||||
Some(blocks) => blocks,
|
||||
None => {
|
||||
log::debug!(
|
||||
target: "block-import",
|
||||
target: LOG_TARGET,
|
||||
"Stopping block import because the import channel was closed!",
|
||||
);
|
||||
return
|
||||
@@ -305,7 +308,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
||||
// down and we should end this future.
|
||||
if worker.result_sender.is_closed() {
|
||||
log::debug!(
|
||||
target: "block-import",
|
||||
target: LOG_TARGET,
|
||||
"Stopping block import because result channel was closed!",
|
||||
);
|
||||
return
|
||||
@@ -318,7 +321,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
||||
worker.import_justification(who, hash, number, justification).await,
|
||||
None => {
|
||||
log::debug!(
|
||||
target: "block-import",
|
||||
target: LOG_TARGET,
|
||||
"Stopping block import because justification channel was closed!",
|
||||
);
|
||||
return
|
||||
@@ -353,7 +356,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
debug!(
|
||||
target: "sync",
|
||||
target: LOG_TARGET,
|
||||
"Justification import failed for hash = {:?} with number = {:?} coming from node = {:?} with error: {}",
|
||||
hash,
|
||||
number,
|
||||
@@ -407,7 +410,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
trace!(target: "sync", "Starting import of {} blocks {}", count, blocks_range);
|
||||
trace!(target: LOG_TARGET, "Starting import of {} blocks {}", count, blocks_range);
|
||||
|
||||
let mut imported = 0;
|
||||
let mut results = vec![];
|
||||
@@ -447,7 +450,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
||||
|
||||
if import_result.is_ok() {
|
||||
trace!(
|
||||
target: "sync",
|
||||
target: LOG_TARGET,
|
||||
"Block imported successfully {:?} ({})",
|
||||
block_number,
|
||||
block_hash,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! that expect babe-specific digests.
|
||||
|
||||
use super::ConsensusDataProvider;
|
||||
use crate::Error;
|
||||
use crate::{Error, LOG_TARGET};
|
||||
use codec::Encode;
|
||||
use sc_client_api::{AuxStore, UsageProvider};
|
||||
use sc_consensus_babe::{
|
||||
@@ -179,7 +179,7 @@ where
|
||||
let epoch = epoch_changes
|
||||
.viable_epoch(&epoch_descriptor, |slot| Epoch::genesis(&self.config, slot))
|
||||
.ok_or_else(|| {
|
||||
log::info!(target: "babe", "create_digest: no viable_epoch :(");
|
||||
log::info!(target: LOG_TARGET, "create_digest: no viable_epoch :(");
|
||||
sp_consensus::Error::InvalidAuthoritiesSet
|
||||
})?;
|
||||
|
||||
@@ -290,7 +290,7 @@ where
|
||||
let has_authority = epoch.authorities.iter().any(|(id, _)| *id == *authority);
|
||||
|
||||
if !has_authority {
|
||||
log::info!(target: "manual-seal", "authority not found");
|
||||
log::info!(target: LOG_TARGET, "authority not found");
|
||||
let timestamp = inherents
|
||||
.timestamp_inherent_data()?
|
||||
.ok_or_else(|| Error::StringError("No timestamp inherent data".into()))?;
|
||||
|
||||
@@ -49,6 +49,8 @@ pub use self::{
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
use sp_api::{ProvideRuntimeApi, TransactionFor};
|
||||
|
||||
const LOG_TARGET: &str = "manual-seal";
|
||||
|
||||
/// The `ConsensusEngineId` of Manual Seal.
|
||||
pub const MANUAL_SEAL_ENGINE_ID: ConsensusEngineId = [b'm', b'a', b'n', b'l'];
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ use sp_runtime::{
|
||||
};
|
||||
use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc, time::Duration};
|
||||
|
||||
const LOG_TARGET: &str = "pow";
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error<B: BlockT> {
|
||||
#[error("Header uses the wrong engine {0:?}")]
|
||||
@@ -531,7 +533,7 @@ where
|
||||
}
|
||||
|
||||
if sync_oracle.is_major_syncing() {
|
||||
debug!(target: "pow", "Skipping proposal due to sync.");
|
||||
debug!(target: LOG_TARGET, "Skipping proposal due to sync.");
|
||||
worker.on_major_syncing();
|
||||
continue
|
||||
}
|
||||
@@ -540,7 +542,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to pull new block for authoring. \
|
||||
Select best chain error: {}",
|
||||
err
|
||||
@@ -561,7 +563,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to propose new block for authoring. \
|
||||
Fetch difficulty failed: {}",
|
||||
err,
|
||||
@@ -577,7 +579,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating inherent data providers failed: {}",
|
||||
err,
|
||||
@@ -590,7 +592,7 @@ where
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating inherent data failed: {}",
|
||||
e,
|
||||
@@ -610,7 +612,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating proposer failed: {:?}",
|
||||
err,
|
||||
@@ -624,7 +626,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
target: LOG_TARGET,
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating proposal failed: {}",
|
||||
err,
|
||||
@@ -654,14 +656,14 @@ where
|
||||
fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<Option<Vec<u8>>, Error<B>> {
|
||||
let mut pre_digest: Option<_> = None;
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "pow", "Checking log {:?}, looking for pre runtime digest", log);
|
||||
trace!(target: LOG_TARGET, "Checking log {:?}, looking for pre runtime digest", log);
|
||||
match (log, pre_digest.is_some()) {
|
||||
(DigestItem::PreRuntime(POW_ENGINE_ID, _), true) =>
|
||||
return Err(Error::MultiplePreRuntimeDigests),
|
||||
(DigestItem::PreRuntime(POW_ENGINE_ID, v), false) => {
|
||||
pre_digest = Some(v.clone());
|
||||
},
|
||||
(_, _) => trace!(target: "pow", "Ignoring digest not meant for us"),
|
||||
(_, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::{PowAlgorithm, PowIntermediate, Seal, INTERMEDIATE_KEY, POW_ENGINE_ID};
|
||||
use crate::{PowAlgorithm, PowIntermediate, Seal, INTERMEDIATE_KEY, LOG_TARGET, POW_ENGINE_ID};
|
||||
|
||||
/// Mining metadata. This is the information needed to start an actual mining loop.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
@@ -159,26 +159,16 @@ where
|
||||
) {
|
||||
Ok(true) => (),
|
||||
Ok(false) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to import mined block: seal is invalid",
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Unable to import mined block: seal is invalid",);
|
||||
return false
|
||||
},
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to import mined block: {}",
|
||||
err,
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Unable to import mined block: {}", err,);
|
||||
return false
|
||||
},
|
||||
}
|
||||
} else {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to import mined block: metadata does not exist",
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Unable to import mined block: metadata does not exist",);
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -192,10 +182,7 @@ where
|
||||
} {
|
||||
build
|
||||
} else {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to import mined block: build does not exist",
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Unable to import mined block: build does not exist",);
|
||||
return false
|
||||
};
|
||||
|
||||
@@ -225,18 +212,13 @@ where
|
||||
);
|
||||
|
||||
info!(
|
||||
target: "pow",
|
||||
"✅ Successfully mined block on top of: {}",
|
||||
build.metadata.best_hash
|
||||
target: LOG_TARGET,
|
||||
"✅ Successfully mined block on top of: {}", build.metadata.best_hash
|
||||
);
|
||||
true
|
||||
},
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to import mined block: {}",
|
||||
err,
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Unable to import mined block: {}", err,);
|
||||
false
|
||||
},
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
const LOG_TARGET: &str = "slots";
|
||||
|
||||
/// The changes that need to applied to the storage to create the state for a block.
|
||||
///
|
||||
/// See [`sp_state_machine::StorageChanges`] for more information.
|
||||
@@ -198,9 +200,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
> {
|
||||
let slot = slot_info.slot;
|
||||
let telemetry = self.telemetry();
|
||||
let logging_target = self.logging_target();
|
||||
let log_target = self.logging_target();
|
||||
|
||||
let inherent_data = Self::create_inherent_data(&slot_info, &logging_target).await?;
|
||||
let inherent_data = Self::create_inherent_data(&slot_info, &log_target).await?;
|
||||
|
||||
let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info);
|
||||
let logs = self.pre_digest_data(slot, claim);
|
||||
@@ -220,19 +222,19 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
let proposal = match futures::future::select(proposing, proposing_remaining).await {
|
||||
Either::Left((Ok(p), _)) => p,
|
||||
Either::Left((Err(err), _)) => {
|
||||
warn!(target: logging_target, "Proposing failed: {}", err);
|
||||
warn!(target: log_target, "Proposing failed: {}", err);
|
||||
|
||||
return None
|
||||
},
|
||||
Either::Right(_) => {
|
||||
info!(
|
||||
target: logging_target,
|
||||
target: log_target,
|
||||
"⌛️ Discarding proposal for slot {}; block production took too long", slot,
|
||||
);
|
||||
// If the node was compiled with debug, tell the user to use release optimizations.
|
||||
#[cfg(build_type = "debug")]
|
||||
info!(
|
||||
target: logging_target,
|
||||
target: log_target,
|
||||
"👉 Recompile your node in `--release` mode to mitigate this problem.",
|
||||
);
|
||||
telemetry!(
|
||||
@@ -525,13 +527,13 @@ pub async fn start_slot_worker<B, C, W, SO, CIDP, Proof>(
|
||||
let slot_info = match slots.next_slot().await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
warn!(target: "slots", "Error while polling for next slot: {}", e);
|
||||
warn!(target: LOG_TARGET, "Error while polling for next slot: {}", e);
|
||||
return
|
||||
},
|
||||
};
|
||||
|
||||
if sync_oracle.is_major_syncing() {
|
||||
debug!(target: "slots", "Skipping proposal slot due to sync.");
|
||||
debug!(target: LOG_TARGET, "Skipping proposal slot due to sync.");
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//!
|
||||
//! This is used instead of `futures_timer::Interval` because it was unreliable.
|
||||
|
||||
use super::{InherentDataProviderExt, Slot};
|
||||
use super::{InherentDataProviderExt, Slot, LOG_TARGET};
|
||||
use sp_consensus::{Error, SelectChain};
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
@@ -146,7 +146,7 @@ where
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
target: "slots",
|
||||
target: LOG_TARGET,
|
||||
"Unable to author block in slot. No best block header: {}",
|
||||
e,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user