From aa6dd5e4f92538d809b9c18cdc20b522b566fc09 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Tue, 2 Jun 2020 17:22:42 +0300 Subject: [PATCH 1/5] updates and logging --- client/basic-authorship/src/basic_authorship.rs | 3 ++- client/transaction-pool/src/lib.rs | 6 ++++++ client/transaction-pool/src/revalidation.rs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index cd241f38849a1..ea42ea910b20f 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -234,7 +234,8 @@ impl Proposer Either::Left((iterator, _)) => iterator, Either::Right(_) => { log::warn!( - "Timeout fired waiting for transaction pool to be ready. Proceeding to block production anyway.", + "Timeout fired waiting for transaction pool to be ready at block #{}. Proceeding to block production anyway.", + self.parent_number, ); self.transaction_pool.ready() } diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 05d7189a04a0d..444d96afad9de 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -325,6 +325,7 @@ impl TransactionPool for BasicPool fn ready_at(&self, at: NumberFor) -> PolledIterator { if self.ready_poll.lock().updated_at() >= at { + log::trace!(target: "txpool", "Transaction pool is already processed block #{}", at); let iterator: ReadyIteratorFor = Box::new(self.pool.validated_pool().ready()); return Box::pin(futures::future::ready(iterator)); } @@ -437,6 +438,9 @@ impl MaintainedTransactionPool for BasicPool fn maintain(&self, event: ChainEvent) -> Pin + Send>> { match event { ChainEvent::NewBlock { id, retracted, .. } => { + + log::trace!(target: "txpool", "Processing block #{} in the transaction pool. Retracted: {:?}", id, retracted); + let id = id.clone(); let pool = self.pool.clone(); let api = self.api.clone(); @@ -472,6 +476,8 @@ impl MaintainedTransactionPool for BasicPool .map(|tx| pool.hash_of(&tx)) .collect::>(); + log::trace!("Pruning transactions: {:?}", hashes); + if let Err(e) = pool.prune_known(&id, &hashes) { log::error!("Cannot prune known in the pool {:?}!", e); } diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs index 423ff92ba4db0..b609ea060f729 100644 --- a/client/transaction-pool/src/revalidation.rs +++ b/client/transaction-pool/src/revalidation.rs @@ -131,7 +131,7 @@ impl RevalidationWorker { fn prepare_batch(&mut self) -> Vec> { let mut queued_exts = Vec::new(); - let mut left = BACKGROUND_REVALIDATION_BATCH_SIZE; + let mut left = std::cmp::max(BACKGROUND_REVALIDATION_BATCH_SIZE, self.members.len() / 4); // Take maximum of count transaction by order // which they got into the pool From c13bf381852057716862d402637c15255f444b6d Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 4 Jun 2020 20:18:08 +0300 Subject: [PATCH 2/5] fix length --- client/basic-authorship/src/basic_authorship.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index ea42ea910b20f..c7788d743c70a 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -234,7 +234,7 @@ impl Proposer Either::Left((iterator, _)) => iterator, Either::Right(_) => { log::warn!( - "Timeout fired waiting for transaction pool to be ready at block #{}. Proceeding to block production anyway.", + "Timeout fired waiting for transaction pool at block #{}. Proceeding with production.", self.parent_number, ); self.transaction_pool.ready() From 1fca9b3ba75e4b886f0ce0422f110e42eaa6048a Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 4 Jun 2020 21:02:35 +0300 Subject: [PATCH 3/5] Update client/transaction-pool/src/lib.rs --- client/transaction-pool/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 444d96afad9de..5a70ebe29fad8 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -476,7 +476,7 @@ impl MaintainedTransactionPool for BasicPool .map(|tx| pool.hash_of(&tx)) .collect::>(); - log::trace!("Pruning transactions: {:?}", hashes); + log::trace!(target: "txpool", "Pruning transactions: {:?}", hashes); if let Err(e) = pool.prune_known(&id, &hashes) { log::error!("Cannot prune known in the pool {:?}!", e); From 51257829e462ecf5ed2c7dae31d8a933bace6bb8 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 4 Jun 2020 21:35:44 +0300 Subject: [PATCH 4/5] rename --- client/transaction-pool/src/revalidation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs index b609ea060f729..fe44603547f8f 100644 --- a/client/transaction-pool/src/revalidation.rs +++ b/client/transaction-pool/src/revalidation.rs @@ -34,7 +34,7 @@ const BACKGROUND_REVALIDATION_INTERVAL: Duration = Duration::from_millis(200); #[cfg(test)] pub const BACKGROUND_REVALIDATION_INTERVAL: Duration = Duration::from_millis(1); -const BACKGROUND_REVALIDATION_BATCH_SIZE: usize = 20; +const MIN_BACKGROUND_REVALIDATION_BATCH_SIZE: usize = 20; /// Payload from queue to worker. struct WorkerPayload { @@ -131,7 +131,7 @@ impl RevalidationWorker { fn prepare_batch(&mut self) -> Vec> { let mut queued_exts = Vec::new(); - let mut left = std::cmp::max(BACKGROUND_REVALIDATION_BATCH_SIZE, self.members.len() / 4); + let mut left = std::cmp::max(MIN_BACKGROUND_REVALIDATION_BATCH_SIZE, self.members.len() / 4); // Take maximum of count transaction by order // which they got into the pool From f78d21560830691ec56e5f8e1b9ba90c5e3214e6 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Mon, 8 Jun 2020 23:00:52 +0300 Subject: [PATCH 5/5] Update client/transaction-pool/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- client/transaction-pool/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 32fdeb9b2d260..19995a5ca1183 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -331,7 +331,7 @@ impl TransactionPool for BasicPool fn ready_at(&self, at: NumberFor) -> PolledIterator { if self.ready_poll.lock().updated_at() >= at { - log::trace!(target: "txpool", "Transaction pool is already processed block #{}", at); + log::trace!(target: "txpool", "Transaction pool already processed block #{}", at); let iterator: ReadyIteratorFor = Box::new(self.pool.validated_pool().ready()); return Box::pin(futures::future::ready(iterator)); }