Transaction pool: Ensure that we prune transactions properly (#8963)

* Transaction pool: Ensure that we prune transactions properly

There was a bug in the transaction pool that we didn't pruned
transactions properly because we called `prune_known`, instead of `prune`.

This bug was introduced by:
https://github.com/paritytech/substrate/pull/4629

This is required to have stale extrinsics being removed properly, so
that they don't fill up the tx pool.

* Fix compilation

* Fix benches

* ...
This commit is contained in:
Bastian Köcher
2021-06-03 16:04:29 +02:00
committed by GitHub
parent f585bf1c1e
commit 258c1a86f6
8 changed files with 170 additions and 68 deletions
@@ -95,6 +95,12 @@ pub trait ChainApi: Send + Sync {
/// Returns a block body given the block id.
fn block_body(&self, at: &BlockId<Self::Block>) -> Self::BodyFuture;
/// Returns a block header given the block id.
fn block_header(
&self,
at: &BlockId<Self::Block>,
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error>;
}
/// Pool configuration options.
@@ -237,7 +243,7 @@ impl<B: ChainApi> Pool<B> {
) -> Result<(), B::Error> {
// Get details of all extrinsics that are already in the pool
let in_pool_tags = self.validated_pool.extrinsics_tags(hashes)
.into_iter().filter_map(|x| x).flat_map(|x| x);
.into_iter().filter_map(|x| x).flatten();
// Prune all transactions that provide given tags
let prune_status = self.validated_pool.prune_tags(in_pool_tags)?;
@@ -579,6 +585,13 @@ mod tests {
fn block_body(&self, _id: &BlockId<Self::Block>) -> Self::BodyFuture {
futures::future::ready(Ok(None))
}
fn block_header(
&self,
_: &BlockId<Self::Block>,
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error> {
Ok(None)
}
}
fn uxt(transfer: Transfer) -> Extrinsic {