mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 07:37:57 +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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user