Make transaction pool prune transactions only of canonical blocks (#6123)

* Make tx pool aware of retracted fork blocks

* Make it compile

* Update client/transaction-pool/src/lib.rs

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>

* Fix doc test

* Simplify the implementation

* Send tree route as arc to prevent heavy clones

* Switch to use `ExtrinsicHash` to make it more clear

* Fix benchmark

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
Bastian Köcher
2020-06-05 23:12:00 +02:00
committed by GitHub
parent 8a8b4f99c3
commit d2846e2b9a
31 changed files with 808 additions and 359 deletions
+6 -4
View File
@@ -208,6 +208,8 @@ pub type AccountSignature = sr25519::Signature;
pub type AccountId = <AccountSignature as Verify>::Signer;
/// A simple hash type for all our hashing.
pub type Hash = H256;
/// The hashing algorithm used.
pub type Hashing = BlakeTwo256;
/// The block number type used in this runtime.
pub type BlockNumber = u64;
/// Index of a transaction.
@@ -219,7 +221,7 @@ pub type Digest = sp_runtime::generic::Digest<H256>;
/// A test block.
pub type Block = sp_runtime::generic::Block<Header, Extrinsic>;
/// A test block's header.
pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
pub type Header = sp_runtime::generic::Header<BlockNumber, Hashing>;
/// Run whatever tests we have.
pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
@@ -404,7 +406,7 @@ impl frame_system::Trait for Runtime {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type Hashing = Hashing;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
@@ -466,7 +468,7 @@ fn code_using_trie() -> u64 {
let mut root = sp_std::default::Default::default();
let _ = {
let v = &pairs;
let mut t = TrieDBMut::<BlakeTwo256>::new(&mut mdb, &mut root);
let mut t = TrieDBMut::<Hashing>::new(&mut mdb, &mut root);
for i in 0..v.len() {
let key: &[u8]= &v[i].0;
let val: &[u8] = &v[i].1;
@@ -477,7 +479,7 @@ fn code_using_trie() -> u64 {
t
};
if let Ok(trie) = TrieDB::<BlakeTwo256>::new(&mdb, &root) {
if let Ok(trie) = TrieDB::<Hashing>::new(&mdb, &root) {
if let Ok(iter) = trie.iter() {
let mut iter_pairs = Vec::new();
for pair in iter {