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
@@ -23,7 +23,7 @@ use codec::Encode;
use parking_lot::RwLock;
use sp_runtime::{
generic::{self, BlockId},
traits::{BlakeTwo256, Hash as HashT, Block as _, Header as _},
traits::{BlakeTwo256, Hash as HashT, Block as BlockT, Header as _},
transaction_validity::{
TransactionValidity, ValidTransaction, TransactionValidityError, InvalidTransaction,
TransactionSource,
@@ -346,6 +346,24 @@ impl sc_transaction_graph::ChainApi for TestApi {
.map(|b| b.extrinsics().to_vec()),
}))
}
fn block_header(
&self,
at: &BlockId<Self::Block>,
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error> {
Ok(match at {
BlockId::Number(num) => self.chain
.read()
.block_by_number
.get(num)
.map(|b| b[0].0.header().clone()),
BlockId::Hash(hash) => self.chain
.read()
.block_by_hash
.get(hash)
.map(|b| b.header().clone()),
})
}
}
impl sp_blockchain::HeaderMetadata<Block> for TestApi {