diff --git a/substrate/core/transaction-pool/graph/src/listener.rs b/substrate/core/transaction-pool/graph/src/listener.rs index 335ff8a0537e9e500e2cef19d5b202818efeeebd..a96c31544fc75c107efa05059307227890436e1e 100644 --- a/substrate/core/transaction-pool/graph/src/listener.rs +++ b/substrate/core/transaction-pool/graph/src/listener.rs @@ -17,12 +17,13 @@ use std::{ collections::HashMap, + fmt, hash, }; use serde::Serialize; use crate::watcher; use sr_primitives::traits; -use log::warn; +use log::{debug, trace, warn}; /// Extrinsic pool default listener. pub struct Listener<H: hash::Hash + Eq, H2> { @@ -37,7 +38,7 @@ impl<H: hash::Hash + Eq, H2> Default for Listener<H, H2> { } } -impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> { +impl<H: hash::Hash + traits::Member + Serialize, H2: Clone + fmt::Debug> Listener<H, H2> { fn fire<F>(&mut self, hash: &H, fun: F) where F: FnOnce(&mut watcher::Sender<H, H2>) { let clean = if let Some(h) = self.watchers.get_mut(hash) { fun(h); @@ -61,11 +62,13 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> { /// Notify the listeners about extrinsic broadcast. pub fn broadcasted(&mut self, hash: &H, peers: Vec<String>) { + trace!(target: "txpool", "[{:?}] 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: {:?})", tx, old); self.fire(tx, |watcher| watcher.ready()); if let Some(old) = old { self.fire(old, |watcher| watcher.usurped(tx.clone())); @@ -74,11 +77,13 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> { /// New transaction was added to the future pool. pub fn future(&mut self, tx: &H) { + trace!(target: "txpool", "[{:?}] 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 by {:?})", tx, by); self.fire(tx, |watcher| match by { Some(t) => watcher.usurped(t.clone()), None => watcher.dropped(), @@ -93,6 +98,7 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> { /// Transaction was pruned from the pool. pub fn pruned(&mut self, header_hash: H2, tx: &H) { + debug!(target: "txpool", "[{:?}] Pruned at {:?}", tx, header_hash); self.fire(tx, |watcher| watcher.finalized(header_hash)) } } diff --git a/substrate/core/transaction-pool/graph/src/pool.rs b/substrate/core/transaction-pool/graph/src/pool.rs index 081397bea135cb0ec2e9d0598b1c34f97a76ec5d..c6e33223282ffb53970ef728d8d1b9a5ce6a2eff 100644 --- a/substrate/core/transaction-pool/graph/src/pool.rs +++ b/substrate/core/transaction-pool/graph/src/pool.rs @@ -177,6 +177,12 @@ impl<B: ChainApi> Pool<B> { parent: &BlockId<B::Block>, extrinsics: &[ExtrinsicFor<B>], ) -> impl Future<Output=Result<(), B::Error>> { + log::debug!( + target: "txpool", + "Starting pruning of block {:?} (extrinsics: {})", + at, + extrinsics.len() + ); // Get details of all extrinsics that are already in the pool let (in_pool_hashes, in_pool_tags) = self.validated_pool.extrinsics_tags(extrinsics); diff --git a/substrate/core/transaction-pool/graph/src/validated_pool.rs b/substrate/core/transaction-pool/graph/src/validated_pool.rs index d528843e98d73261cf11832d48c8f0f0a1f6022c..7317d41f42e974b3b7ca89faf3913c2d3c19f750 100644 --- a/substrate/core/transaction-pool/graph/src/validated_pool.rs +++ b/substrate/core/transaction-pool/graph/src/validated_pool.rs @@ -16,6 +16,7 @@ use std::{ collections::{HashSet, HashMap}, + fmt, hash, time, }; @@ -355,7 +356,7 @@ fn fire_events<H, H2, Ex>( imported: &base::Imported<H, Ex>, ) where H: hash::Hash + Eq + traits::Member + Serialize, - H2: Clone, + H2: Clone + fmt::Debug, { match *imported { base::Imported::Ready { ref promoted, ref failed, ref removed, ref hash } => {