Skip to content

Commit

Permalink
fatxpool: handling limits and priorities improvements (paritytech#6405
Browse files Browse the repository at this point in the history
)

This PR provides a number of improvements around handling limits and
priorities in the fork-aware transaction pool.


#### Notes to reviewers.
#### Following are the notable changes:
1. #### [Better
support](paritytech@414ec3c)
for `Usurped` transactions

When any view reports an `Usurped` transaction (replaced by other with
higher priority) it is removed from all the views (also inactive).
Removal is implemented by simply submitting usurper transaction to all
the views. It is also ensured that usurped tx will not sneak into the
`view_store` in newly created view (this is why
`ViewStore::pending_txs_replacements` was added).

1. ####
[`TimedTransactionSource`](paritytech@f10590f)
introduced:

Every view now has an information when the transaction entered the pool.
Enforce limits (now only for future txs) uses this timestamp to find
worst transactions. Having common timestamp ensures coherent assessment
of the transaction's importance across different views. This also could
later be used to select which ready transaction shall be dropped.

1. #### `DroppedWatcher`: [improved
logic](paritytech@560db28)
for future transactions
For future transaction - if the last referencing view is removed, the
transaction will be dropped from the pool. This prevents future
unincluded and un-promoted transactions from staying in the pool for
long time.

#### And some minor changes:

1.
[simplified](paritytech@2d0bbf8)
the flow in `update_view_with_mempool` (code duplication + minor bug
fix).
2. `graph::BasePool`: [handling
priorities](paritytech@c9f2d39)
for future transaction improved (previously transaction with lower prio
was reported as failed),
3. `graph::listener`: dedicated `limit_enforced`/`usurped`/`dropped`
[calls
added](paritytech@7b58a68),
4. flaky test
[fixed](paritytech@e0a7bc6)
5. new tests added,

related to: paritytech#5809

---------

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Iulian Barbu <[email protected]>
  • Loading branch information
3 people authored and Krayt78 committed Dec 18, 2024
1 parent b780ceb commit d1f8255
Show file tree
Hide file tree
Showing 25 changed files with 1,420 additions and 379 deletions.
9 changes: 9 additions & 0 deletions prdoc/pr_6405.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: '`fatxpool`: handling limits and priorities improvements'
doc:
- audience: Node Dev
description: |-
This PR provides a number of improvements and fixes around handling limits and priorities in the fork-aware transaction pool.

crates:
- name: sc-transaction-pool
bump: major
4 changes: 2 additions & 2 deletions substrate/client/transaction-pool/benches/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn uxt(transfer: TransferData) -> Extrinsic {
}

fn bench_configured(pool: Pool<TestApi>, number: u64, api: Arc<TestApi>) {
let source = TransactionSource::External;
let source = TimedTransactionSource::new_external(false);
let mut futures = Vec::new();
let mut tags = Vec::new();
let at = HashAndNumber {
Expand All @@ -171,7 +171,7 @@ fn bench_configured(pool: Pool<TestApi>, number: u64, api: Arc<TestApi>) {

tags.push(to_tag(nonce, AccountId::from_h256(H256::from_low_u64_be(1))));

futures.push(pool.submit_one(&at, source, xt));
futures.push(pool.submit_one(&at, source.clone(), xt));
}

let res = block_on(futures::future::join_all(futures.into_iter()));
Expand Down
Loading

0 comments on commit d1f8255

Please sign in to comment.