From 658763d28043c332f334a71003e2ff16ba391552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sat, 9 Nov 2019 13:22:21 +0100 Subject: [PATCH] Additional logging for the transaction pool. (#4068) * Additional logging for the pool. * Long line. --- core/transaction-pool/graph/src/listener.rs | 10 ++++++++-- core/transaction-pool/graph/src/pool.rs | 6 ++++++ core/transaction-pool/graph/src/validated_pool.rs | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/transaction-pool/graph/src/listener.rs b/core/transaction-pool/graph/src/listener.rs index 335ff8a0537e9..a96c31544fc75 100644 --- a/core/transaction-pool/graph/src/listener.rs +++ b/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 { @@ -37,7 +38,7 @@ impl Default for Listener { } } -impl Listener { +impl Listener { fn fire(&mut self, hash: &H, fun: F) where F: FnOnce(&mut watcher::Sender) { let clean = if let Some(h) = self.watchers.get_mut(hash) { fun(h); @@ -61,11 +62,13 @@ impl Listener { /// Notify the listeners about extrinsic broadcast. pub fn broadcasted(&mut self, hash: &H, peers: Vec) { + 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 Listener { /// 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 Listener { /// 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/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 081397bea135c..c6e33223282ff 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -177,6 +177,12 @@ impl Pool { parent: &BlockId, extrinsics: &[ExtrinsicFor], ) -> impl Future> { + 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/core/transaction-pool/graph/src/validated_pool.rs b/core/transaction-pool/graph/src/validated_pool.rs index d528843e98d73..7317d41f42e97 100644 --- a/core/transaction-pool/graph/src/validated_pool.rs +++ b/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( imported: &base::Imported, ) 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 } => {