Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

txpool: don't validate block transactions if the pool is empty #12973

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions client/transaction-pool/src/graph/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,23 @@ impl<B: ChainApi> Pool<B> {
// if it's not found in the pool query the runtime at parent block
// to get validity info and tags that the extrinsic provides.
None => {
let validity = self
.validated_pool
.api()
.validate_transaction(parent, TransactionSource::InBlock, extrinsic.clone())
.await;

if let Ok(Ok(validity)) = validity {
future_tags.extend(validity.provides);
// Avoid validating block txs if the pool is empty
if !self.validated_pool.status().is_empty() {
let validity = self
.validated_pool
.api()
.validate_transaction(
parent,
TransactionSource::InBlock,
extrinsic.clone(),
)
.await;

if let Ok(Ok(validity)) = validity {
future_tags.extend(validity.provides);
}
} else {
log::trace!(target: "txpool", "txpool is empty, skipping validation for block {at:?}");
}
},
}
Expand Down