diff --git a/client/transaction-pool/api/src/lib.rs b/client/transaction-pool/api/src/lib.rs index c1e49ad07d7b1..870760962a520 100644 --- a/client/transaction-pool/api/src/lib.rs +++ b/client/transaction-pool/api/src/lib.rs @@ -30,6 +30,8 @@ use sp_runtime::{ }; use std::{collections::HashMap, hash::Hash, pin::Pin, sync::Arc}; +const LOG_TARGET: &str = "txpool::api"; + pub use sp_runtime::transaction_validity::{ TransactionLongevity, TransactionPriority, TransactionSource, TransactionTag, }; @@ -353,7 +355,7 @@ impl OffchainSubmitTransaction for TP extrinsic: ::Extrinsic, ) -> Result<(), ()> { log::debug!( - target: "txpool", + target: LOG_TARGET, "(offchain call) Submitting a transaction to the pool: {:?}", extrinsic ); @@ -362,7 +364,7 @@ impl OffchainSubmitTransaction for TP result.map(|_| ()).map_err(|e| { log::warn!( - target: "txpool", + target: LOG_TARGET, "(offchain call) Error submitting a transaction to the pool: {}", e ) diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index a2b317cfb3998..0166dfaced208 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -18,6 +18,7 @@ //! Chain api required for the transaction pool. +use crate::LOG_TARGET; use codec::Encode; use futures::{ channel::{mpsc, oneshot}, @@ -85,7 +86,7 @@ impl FullChainApi { let metrics = prometheus.map(ApiMetrics::register).and_then(|r| match r { Err(err) => { log::warn!( - target: "txpool", + target: LOG_TARGET, "Failed to register transaction pool api prometheus metrics: {:?}", err, ); diff --git a/client/transaction-pool/src/enactment_state.rs b/client/transaction-pool/src/enactment_state.rs index 382b2683156b6..7252c0dec7f2a 100644 --- a/client/transaction-pool/src/enactment_state.rs +++ b/client/transaction-pool/src/enactment_state.rs @@ -18,6 +18,7 @@ //! Substrate transaction pool implementation. +use crate::LOG_TARGET; use num_traits::CheckedSub; use sc_transaction_pool_api::ChainEvent; use sp_blockchain::TreeRoute; @@ -113,14 +114,14 @@ where }; if skip_maintenance { - log::debug!(target: "txpool", "skip maintain: tree_route would be too long"); + log::debug!(target: LOG_TARGET, "skip maintain: tree_route would be too long"); self.force_update(event); return Ok(EnactmentAction::Skip) } // block was already finalized if self.recent_finalized_block == new_hash { - log::debug!(target: "txpool", "handle_enactment: block already finalized"); + log::debug!(target: LOG_TARGET, "handle_enactment: block already finalized"); return Ok(EnactmentAction::Skip) } @@ -129,9 +130,13 @@ where let tree_route = tree_route(self.recent_best_block, new_hash)?; log::debug!( - target: "txpool", + target: LOG_TARGET, "resolve hash:{:?} finalized:{:?} tree_route:{:?} best_block:{:?} finalized_block:{:?}", - new_hash, finalized, tree_route, self.recent_best_block, self.recent_finalized_block + new_hash, + finalized, + tree_route, + self.recent_best_block, + self.recent_finalized_block ); // check if recently finalized block is on retracted path. this could be @@ -139,9 +144,10 @@ where // best event for some old stale best head. if tree_route.retracted().iter().any(|x| x.hash == self.recent_finalized_block) { log::debug!( - target: "txpool", + target: LOG_TARGET, "Recently finalized block {} would be retracted by ChainEvent {}, skipping", - self.recent_finalized_block, new_hash + self.recent_finalized_block, + new_hash ); return Ok(EnactmentAction::Skip) } @@ -155,7 +161,7 @@ where // remains valid. if tree_route.enacted().is_empty() { log::trace!( - target: "txpool", + target: LOG_TARGET, "handle_enactment: no newly enacted blocks since recent best block" ); return Ok(EnactmentAction::HandleFinalization) @@ -176,7 +182,12 @@ where ChainEvent::NewBestBlock { hash, .. } => self.recent_best_block = *hash, ChainEvent::Finalized { hash, .. } => self.recent_finalized_block = *hash, }; - log::debug!(target: "txpool", "forced update: {:?}, {:?}", self.recent_best_block, self.recent_finalized_block); + log::debug!( + target: LOG_TARGET, + "forced update: {:?}, {:?}", + self.recent_best_block, + self.recent_finalized_block, + ); } } diff --git a/client/transaction-pool/src/graph/base_pool.rs b/client/transaction-pool/src/graph/base_pool.rs index 67580d698b8c1..44371be62c621 100644 --- a/client/transaction-pool/src/graph/base_pool.rs +++ b/client/transaction-pool/src/graph/base_pool.rs @@ -22,6 +22,7 @@ use std::{cmp::Ordering, collections::HashSet, fmt, hash, sync::Arc}; +use crate::LOG_TARGET; use log::{debug, trace, warn}; use sc_transaction_pool_api::{error, InPoolTransaction, PoolStatus}; use serde::Serialize; @@ -272,9 +273,9 @@ impl BasePool BasePool if first { - debug!(target: "txpool", "[{:?}] Error importing: {:?}", current_hash, e); + debug!(target: LOG_TARGET, "[{:?}] Error importing: {:?}", current_hash, e); return Err(e) } else { failed.push(current_hash); @@ -347,7 +348,7 @@ impl BasePool BasePool promoted.push(res), Err(e) => { - warn!(target: "txpool", "[{:?}] Failed to promote during pruning: {:?}", hash, e); + warn!( + target: LOG_TARGET, + "[{:?}] Failed to promote during pruning: {:?}", hash, e, + ); failed.push(hash) }, } diff --git a/client/transaction-pool/src/graph/listener.rs b/client/transaction-pool/src/graph/listener.rs index 776749abf2d5d..c603a542c2767 100644 --- a/client/transaction-pool/src/graph/listener.rs +++ b/client/transaction-pool/src/graph/listener.rs @@ -18,6 +18,7 @@ use std::{collections::HashMap, fmt::Debug, hash}; +use crate::LOG_TARGET; use linked_hash_map::LinkedHashMap; use log::{debug, trace}; use serde::Serialize; @@ -67,13 +68,13 @@ impl Listener { /// Notify the listeners about extrinsic broadcast. pub fn broadcasted(&mut self, hash: &H, peers: Vec) { - trace!(target: "txpool", "[{:?}] Broadcasted", hash); + trace!(target: LOG_TARGET, "[{:?}] Broadcasted", hash); self.fire(hash, |watcher| watcher.broadcast(peers)); } /// New transaction was added to the ready pool or promoted from the future pool. pub fn ready(&mut self, tx: &H, old: Option<&H>) { - trace!(target: "txpool", "[{:?}] Ready (replaced with {:?})", tx, old); + trace!(target: LOG_TARGET, "[{:?}] Ready (replaced with {:?})", tx, old); self.fire(tx, |watcher| watcher.ready()); if let Some(old) = old { self.fire(old, |watcher| watcher.usurped(tx.clone())); @@ -82,13 +83,13 @@ impl Listener { /// New transaction was added to the future pool. pub fn future(&mut self, tx: &H) { - trace!(target: "txpool", "[{:?}] Future", tx); + trace!(target: LOG_TARGET, "[{:?}] Future", tx); self.fire(tx, |watcher| watcher.future()); } /// Transaction was dropped from the pool because of the limit. pub fn dropped(&mut self, tx: &H, by: Option<&H>) { - trace!(target: "txpool", "[{:?}] Dropped (replaced with {:?})", tx, by); + trace!(target: LOG_TARGET, "[{:?}] Dropped (replaced with {:?})", tx, by); self.fire(tx, |watcher| match by { Some(t) => watcher.usurped(t.clone()), None => watcher.dropped(), @@ -97,13 +98,13 @@ impl Listener { /// Transaction was removed as invalid. pub fn invalid(&mut self, tx: &H) { - debug!(target: "txpool", "[{:?}] Extrinsic invalid", tx); + debug!(target: LOG_TARGET, "[{:?}] Extrinsic invalid", tx); self.fire(tx, |watcher| watcher.invalid()); } /// Transaction was pruned from the pool. pub fn pruned(&mut self, block_hash: BlockHash, tx: &H) { - debug!(target: "txpool", "[{:?}] Pruned at {:?}", tx, block_hash); + debug!(target: LOG_TARGET, "[{:?}] Pruned at {:?}", tx, block_hash); // Get the transactions included in the given block hash. let txs = self.finality_watchers.entry(block_hash).or_insert(vec![]); txs.push(tx.clone()); @@ -134,7 +135,12 @@ impl Listener { pub fn finalized(&mut self, block_hash: BlockHash) { if let Some(hashes) = self.finality_watchers.remove(&block_hash) { for (tx_index, hash) in hashes.into_iter().enumerate() { - log::debug!(target: "txpool", "[{:?}] Sent finalization event (block {:?})", hash, block_hash); + log::debug!( + target: LOG_TARGET, + "[{:?}] Sent finalization event (block {:?})", + hash, + block_hash, + ); self.fire(&hash, |watcher| watcher.finalized(block_hash, tx_index)) } } diff --git a/client/transaction-pool/src/graph/pool.rs b/client/transaction-pool/src/graph/pool.rs index 8e3570d1dbd1f..14217d56aaa57 100644 --- a/client/transaction-pool/src/graph/pool.rs +++ b/client/transaction-pool/src/graph/pool.rs @@ -18,6 +18,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; +use crate::LOG_TARGET; use futures::{channel::mpsc::Receiver, Future}; use sc_transaction_pool_api::error; use sp_blockchain::TreeRoute; @@ -208,7 +209,8 @@ impl Pool { ) { let now = Instant::now(); self.validated_pool.resubmit(revalidated_transactions); - log::debug!(target: "txpool", + log::debug!( + target: LOG_TARGET, "Resubmitted. Took {} ms. Status: {:?}", now.elapsed().as_millis(), self.validated_pool.status() @@ -249,7 +251,7 @@ impl Pool { extrinsics: &[ExtrinsicFor], ) -> Result<(), B::Error> { log::debug!( - target: "txpool", + target: LOG_TARGET, "Starting pruning of block {:?} (extrinsics: {})", at, extrinsics.len() @@ -287,7 +289,10 @@ impl Pool { future_tags.extend(validity.provides); } } else { - log::trace!(target: "txpool", "txpool is empty, skipping validation for block {at:?}"); + log::trace!( + target: LOG_TARGET, + "txpool is empty, skipping validation for block {at:?}", + ); } }, } @@ -323,7 +328,7 @@ impl Pool { tags: impl IntoIterator, known_imported_hashes: impl IntoIterator> + Clone, ) -> Result<(), B::Error> { - log::debug!(target: "txpool", "Pruning at {:?}", at); + log::debug!(target: LOG_TARGET, "Pruning at {:?}", at); // Prune all transactions that provide given tags let prune_status = self.validated_pool.prune_tags(tags)?; @@ -342,7 +347,7 @@ impl Pool { let reverified_transactions = self.verify(at, pruned_transactions, CheckBannedBeforeVerify::Yes).await?; - log::trace!(target: "txpool", "Pruning at {:?}. Resubmitting transactions.", at); + log::trace!(target: LOG_TARGET, "Pruning at {:?}. Resubmitting transactions.", at); // And finally - submit reverified transactions back to the pool self.validated_pool.resubmit_pruned( diff --git a/client/transaction-pool/src/graph/ready.rs b/client/transaction-pool/src/graph/ready.rs index b52372a3c4d10..9040c81b3c434 100644 --- a/client/transaction-pool/src/graph/ready.rs +++ b/client/transaction-pool/src/graph/ready.rs @@ -23,6 +23,7 @@ use std::{ sync::Arc, }; +use crate::LOG_TARGET; use log::{debug, trace}; use sc_transaction_pool_api::error; use serde::Serialize; @@ -314,7 +315,7 @@ impl ReadyTransactions { } // add to removed - trace!(target: "txpool", "[{:?}] Removed as part of the subtree.", hash); + trace!(target: LOG_TARGET, "[{:?}] Removed as part of the subtree.", hash); removed.push(tx.transaction.transaction); } } @@ -521,7 +522,7 @@ impl BestIterator { pub fn report_invalid(&mut self, tx: &Arc>) { if let Some(to_report) = self.all.get(&tx.hash) { debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Reported as invalid. Will skip sub-chains while iterating.", to_report.transaction.transaction.hash ); @@ -544,9 +545,8 @@ impl Iterator for BestIterator { // Check if the transaction was marked invalid. if self.invalid.contains(hash) { debug!( - target: "txpool", - "[{:?}] Skipping invalid child transaction while iterating.", - hash + target: LOG_TARGET, + "[{:?}] Skipping invalid child transaction while iterating.", hash, ); continue } diff --git a/client/transaction-pool/src/graph/validated_pool.rs b/client/transaction-pool/src/graph/validated_pool.rs index ab99a090e5654..bf8a059af2ff1 100644 --- a/client/transaction-pool/src/graph/validated_pool.rs +++ b/client/transaction-pool/src/graph/validated_pool.rs @@ -22,6 +22,7 @@ use std::{ sync::Arc, }; +use crate::LOG_TARGET; use futures::channel::mpsc::{channel, Sender}; use parking_lot::{Mutex, RwLock}; use sc_transaction_pool_api::{error, PoolStatus, ReadyTransactions}; @@ -199,7 +200,7 @@ impl ValidatedPool { Err(e) => if e.is_full() { log::warn!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Trying to notify an import but the channel is full", hash, ); @@ -230,15 +231,17 @@ impl ValidatedPool { let ready_limit = &self.options.ready; let future_limit = &self.options.future; - log::debug!(target: "txpool", "Pool Status: {:?}", status); + log::debug!(target: LOG_TARGET, "Pool Status: {:?}", status); if ready_limit.is_exceeded(status.ready, status.ready_bytes) || future_limit.is_exceeded(status.future, status.future_bytes) { log::debug!( - target: "txpool", + target: LOG_TARGET, "Enforcing limits ({}/{}kB ready, {}/{}kB future", - ready_limit.count, ready_limit.total_bytes / 1024, - future_limit.count, future_limit.total_bytes / 1024, + ready_limit.count, + ready_limit.total_bytes / 1024, + future_limit.count, + future_limit.total_bytes / 1024, ); // clean up the pool @@ -254,7 +257,7 @@ impl ValidatedPool { removed }; if !removed.is_empty() { - log::debug!(target: "txpool", "Enforcing limits: {} dropped", removed.len()); + log::debug!(target: LOG_TARGET, "Enforcing limits: {} dropped", removed.len()); } // run notifications @@ -385,7 +388,7 @@ impl ValidatedPool { // unknown to caller => let's just notify listeners (and issue debug // message) log::warn!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Removing invalid transaction from update: {}", hash, err, @@ -595,14 +598,14 @@ impl ValidatedPool { return vec![] } - log::debug!(target: "txpool", "Removing invalid transactions: {:?}", hashes); + log::debug!(target: LOG_TARGET, "Removing invalid transactions: {:?}", hashes); // temporarily ban invalid transactions self.rotator.ban(&Instant::now(), hashes.iter().cloned()); let invalid = self.pool.write().remove_subtree(hashes); - log::debug!(target: "txpool", "Removed invalid transactions: {:?}", invalid); + log::debug!(target: LOG_TARGET, "Removed invalid transactions: {:?}", invalid); let mut listener = self.listener.write(); for tx in &invalid { @@ -629,7 +632,11 @@ impl ValidatedPool { /// Notify all watchers that transactions in the block with hash have been finalized pub async fn on_block_finalized(&self, block_hash: BlockHash) -> Result<(), B::Error> { - log::trace!(target: "txpool", "Attempting to notify watchers of finalization for {}", block_hash); + log::trace!( + target: LOG_TARGET, + "Attempting to notify watchers of finalization for {}", + block_hash, + ); self.listener.write().finalized(block_hash); Ok(()) } diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 1cd9bef77bc69..44bda82da38a1 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -67,6 +67,8 @@ use prometheus_endpoint::Registry as PrometheusRegistry; use sp_blockchain::{HashAndNumber, TreeRoute}; +pub(crate) const LOG_TARGET: &str = "txpool"; + type BoxedReadyIterator = Box>> + Send>; @@ -116,7 +118,7 @@ impl ReadyPoll { while idx < self.pollers.len() { if self.pollers[idx].0 <= number { let poller_sender = self.pollers.swap_remove(idx); - log::debug!(target: "txpool", "Sending ready signal at block {}", number); + log::debug!(target: LOG_TARGET, "Sending ready signal at block {}", number); let _ = poller_sender.1.send(iterator_factory()); } else { idx += 1; @@ -336,7 +338,7 @@ where } if self.ready_poll.lock().updated_at() >= at { - log::trace!(target: "txpool", "Transaction pool already processed block #{}", at); + log::trace!(target: LOG_TARGET, "Transaction pool already processed block #{}", at); let iterator: ReadyIteratorFor = Box::new(self.pool.validated_pool().ready()); return async move { iterator }.boxed() } @@ -554,16 +556,16 @@ async fn prune_known_txs_for_block>(); - log::trace!(target: "txpool", "Pruning transactions: {:?}", hashes); + log::trace!(target: LOG_TARGET, "Pruning transactions: {:?}", hashes); let header = match api.block_header(block_hash) { Ok(Some(h)) => h, Ok(None) => { - log::debug!(target: "txpool", "Could not find header for {:?}.", block_hash); + log::debug!(target: LOG_TARGET, "Could not find header for {:?}.", block_hash); return hashes }, Err(e) => { - log::debug!(target: "txpool", "Error retrieving header for {:?}: {}", block_hash, e); + log::debug!(target: LOG_TARGET, "Error retrieving header for {:?}: {}", block_hash, e); return hashes }, }; @@ -587,7 +589,7 @@ where /// (that have already been enacted) and resubmits transactions that were /// retracted. async fn handle_enactment(&self, tree_route: TreeRoute) { - log::trace!(target: "txpool", "handle_enactment tree_route: {tree_route:?}"); + log::trace!(target: LOG_TARGET, "handle_enactment tree_route: {tree_route:?}"); let pool = self.pool.clone(); let api = self.api.clone(); @@ -595,7 +597,7 @@ where Some(HashAndNumber { hash, number }) => (hash, number), None => { log::warn!( - target: "txpool", + target: LOG_TARGET, "Skipping ChainEvent - no last block in tree route {:?}", tree_route, ); @@ -666,7 +668,7 @@ where if !contains { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}]: Resubmitting from retracted block {:?}", tx_hash, hash, @@ -691,7 +693,7 @@ where .await { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Error re-submitting transactions: {}", hash, e, @@ -742,7 +744,7 @@ where match result { Err(msg) => { - log::debug!(target: "txpool", "{msg}"); + log::debug!(target: LOG_TARGET, "{msg}"); self.enactment_state.lock().force_update(&event); }, Ok(EnactmentAction::Skip) => return, @@ -754,7 +756,7 @@ where if let ChainEvent::Finalized { hash, tree_route } = event { log::trace!( - target: "txpool", + target: LOG_TARGET, "on-finalized enacted: {tree_route:?}, previously finalized: \ {prev_finalized_block:?}", ); @@ -762,7 +764,7 @@ where for hash in tree_route.iter().chain(std::iter::once(&hash)) { if let Err(e) = self.pool.validated_pool().on_block_finalized(*hash).await { log::warn!( - target: "txpool", + target: LOG_TARGET, "Error occurred while attempting to notify watchers about finalization {}: {}", hash, e ) diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs index d8c8bea625fb3..99602b50a2269 100644 --- a/client/transaction-pool/src/revalidation.rs +++ b/client/transaction-pool/src/revalidation.rs @@ -24,7 +24,10 @@ use std::{ sync::Arc, }; -use crate::graph::{ChainApi, ExtrinsicHash, NumberFor, Pool, ValidatedTransaction}; +use crate::{ + graph::{ChainApi, ExtrinsicHash, NumberFor, Pool, ValidatedTransaction}, + LOG_TARGET, +}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_runtime::{ generic::BlockId, @@ -82,13 +85,23 @@ async fn batch_revalidate( for (validation_result, ext_hash, ext) in validation_results { match validation_result { Ok(Err(TransactionValidityError::Invalid(err))) => { - log::debug!(target: "txpool", "[{:?}]: Revalidation: invalid {:?}", ext_hash, err); + log::debug!( + target: LOG_TARGET, + "[{:?}]: Revalidation: invalid {:?}", + ext_hash, + err, + ); invalid_hashes.push(ext_hash); }, Ok(Err(TransactionValidityError::Unknown(err))) => { // skipping unknown, they might be pushed by valid or invalid transaction // when latter resubmitted. - log::trace!(target: "txpool", "[{:?}]: Unknown during revalidation: {:?}", ext_hash, err); + log::trace!( + target: LOG_TARGET, + "[{:?}]: Unknown during revalidation: {:?}", + ext_hash, + err, + ); }, Ok(Ok(validity)) => { revalidated.insert( @@ -105,7 +118,7 @@ async fn batch_revalidate( }, Err(validation_err) => { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}]: Removing due to error during revalidation: {}", ext_hash, validation_err @@ -183,7 +196,7 @@ impl RevalidationWorker { // we don't add something that already scheduled for revalidation if self.members.contains_key(&ext_hash) { log::trace!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Skipped adding for revalidation: Already there.", ext_hash, ); @@ -231,7 +244,7 @@ impl RevalidationWorker { if batch_len > 0 || this.len() > 0 { log::debug!( - target: "txpool", + target: LOG_TARGET, "Revalidated {} transactions. Left in the queue for revalidation: {}.", batch_len, this.len(), @@ -248,7 +261,7 @@ impl RevalidationWorker { if this.members.len() > 0 { log::debug!( - target: "txpool", + target: LOG_TARGET, "Updated revalidation queue at {:?}. Transactions: {:?}", this.best_block, this.members, @@ -320,14 +333,15 @@ where ) { if transactions.len() > 0 { log::debug!( - target: "txpool", "Sent {} transactions to revalidation queue", + target: LOG_TARGET, + "Sent {} transactions to revalidation queue", transactions.len(), ); } if let Some(ref to_worker) = self.background { if let Err(e) = to_worker.unbounded_send(WorkerPayload { at, transactions }) { - log::warn!(target: "txpool", "Failed to update background worker: {:?}", e); + log::warn!(target: LOG_TARGET, "Failed to update background worker: {:?}", e); } } else { let pool = self.pool.clone(); diff --git a/client/transaction-pool/tests/pool.rs b/client/transaction-pool/tests/pool.rs index 27d62c3250abc..511f6d9e24b5f 100644 --- a/client/transaction-pool/tests/pool.rs +++ b/client/transaction-pool/tests/pool.rs @@ -45,6 +45,8 @@ use substrate_test_runtime_client::{ }; use substrate_test_runtime_transaction_pool::{uxt, TestApi}; +const LOG_TARGET: &str = "txpool"; + fn pool() -> Pool { Pool::new(Default::default(), true.into(), TestApi::with_alice_nonce(209).into()) } @@ -505,7 +507,7 @@ fn fork_aware_finalization() { canon_watchers.push((watcher, header.hash())); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; b1 = header.hash(); block_on(pool.maintain(event)); @@ -521,7 +523,7 @@ fn fork_aware_finalization() { block_on(pool.submit_and_watch(&BlockId::number(1), SOURCE, from_dave.clone())) .expect("1. Imported"); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> C2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C2: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; c2 = header.hash(); block_on(pool.maintain(event)); @@ -536,7 +538,7 @@ fn fork_aware_finalization() { assert_eq!(pool.status().ready, 1); let header = pool.api().push_block_with_parent(c2, vec![from_bob.clone()], true); - log::trace!(target:"txpool", ">> D2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D2: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; d2 = header.hash(); block_on(pool.maintain(event)); @@ -550,7 +552,7 @@ fn fork_aware_finalization() { .expect("1.Imported"); assert_eq!(pool.status().ready, 1); let header = pool.api().push_block_with_parent(b1, vec![from_charlie.clone()], true); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1 = header.hash(); canon_watchers.push((watcher, header.hash())); let event = block_event_with_retracted(header.clone(), d2, pool.api()); @@ -568,7 +570,7 @@ fn fork_aware_finalization() { .expect("1. Imported"); assert_eq!(pool.status().ready, 3); let header = pool.api().push_block_with_parent(c1, vec![xt.clone()], true); - log::trace!(target:"txpool", ">> D1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D1: {:?} {:?}", header.hash(), header); d1 = header.hash(); canon_watchers.push((w, header.hash())); @@ -584,7 +586,7 @@ fn fork_aware_finalization() { // block E1 { let header = pool.api().push_block_with_parent(d1, vec![from_dave, from_bob], true); - log::trace!(target:"txpool", ">> E1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> E1: {:?} {:?}", header.hash(), header); e1 = header.hash(); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; block_on(pool.maintain(event)); @@ -1115,7 +1117,7 @@ fn switching_fork_with_finalized_works() { pool.api() .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1131,7 +1133,7 @@ fn switching_fork_with_finalized_works() { ); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> B2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B2: {:?} {:?}", header.hash(), header); b2_header = header; } @@ -1193,7 +1195,7 @@ fn switching_fork_multiple_times_works() { pool.api() .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1209,7 +1211,7 @@ fn switching_fork_multiple_times_works() { ); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> B2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B2: {:?} {:?}", header.hash(), header); b2_header = header; } @@ -1306,7 +1308,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1320,7 +1322,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; } @@ -1334,7 +1336,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(c1_header.hash(), vec![from_charlie.clone()], true); assert_eq!(pool.status().ready, 3); - log::trace!(target:"txpool", ">> D1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D1: {:?} {:?}", header.hash(), header); d1_header = header; } @@ -1418,7 +1420,7 @@ fn delayed_finalization_does_not_retract() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1432,7 +1434,7 @@ fn delayed_finalization_does_not_retract() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; } @@ -1513,7 +1515,7 @@ fn best_block_after_finalization_does_not_retract() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1527,7 +1529,7 @@ fn best_block_after_finalization_does_not_retract() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; }