Skip to content

[stable2506] Backport #8596#8970

Merged
michalkucharczyk merged 6 commits intostable2506from
backport-8596-to-stable2506
Jun 25, 2025
Merged

[stable2506] Backport #8596#8970
michalkucharczyk merged 6 commits intostable2506from
backport-8596-to-stable2506

Conversation

@paritytech-release-backport-bot

Backport #8596 into stable2506 from michalkucharczyk.

See the documentation on how to use this bot.

This PR adds some optimization and fixes in handling limits in
fork-aware transaction pool.

#### Notes for reviewers

Changes made (random order):
- debug levels adjusted in numerous places places ( `debug -> trace` for
tx, `trace -> debug` for general flow) for better readablity,
- internal TxMemPool
[storage](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs#L268-L272)
is now
[sorted](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool/tx_mem_pool_map.rs#L123-L132).
A new helper exposes methods to reduce number of transaction clones
(e.g.
[here](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1404-L1410),
see [previous
verions](https://github.com/paritytech/polkadot-sdk/blob/2863b7a9a879935ff16987d0e95065d088dad9f8/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1352-L1359)).
This new structure eliminates the necessity of sorting transactions on
the fly which was a not efficient, naive,
[first](https://github.com/paritytech/polkadot-sdk/blob/e44b89fb7ca3385f314803c733ad97b26cd14e9f/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs#L384-L400)
implementation.
- some _mutexes_ were migrated to `tokio::sync::Mutex` to avoid tokio
threads locking,
- `sync` to `async`
_[message](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs#L743)
based_ bridge was implemented. It's purpose is mainly to support
`LocalTransactionPool / OffchainTransactionPool` infrastucture. `sync`
methods can be called from both non-tokio and tokio context. This
requires one additional
[blocking](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L398-L402)
task for transaction pool.
- `ViewStore::most_recent_view` is now a
[reference](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs#L171)
to `View`.
- `TXMEMPOOL_TRANSACTION_LIMIT_MULTIPLIER` removed, there is no point
for buffering more. Initially intended to work as buffer accommodating
transactions from two different full views (which could have different
set of transactions), turned out to be a bottleneck in maintain function
(it still is but aligning sizes reduced the impact),
-
[bug](https://github.com/paritytech/polkadot-sdk/blob/74dafaee5c600fd2c8a59a280f647f94ccf0a755/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs#L769)
:see_no_evil: fixed in pre-insert actions removal
-
[`ValidateTransactionPriority`](https://github.com/paritytech/polkadot-sdk/blob/045bc6d342620a02ee9b28d8de51f72ae680f06f/substrate/client/transaction-pool/src/graph/pool.rs#L64-L71)
was added. The goal is to allow faster processing of validation requests
that were made from the `maintain` context. Otherwise all requests were
landing in the same queue and maintain requests could be delayed. Now
the processing power is evenly 50/50 split between _maintain_ and
_submit+revalidate_ context.

Related work:
- michalkucharczyk/tx-test-tool#42,
- #8152,

Todo:
- [x] some run should be done also for parachain,

---------

Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 6efe9f5)
@github-actions github-actions bot added the A3-backport Pull request is already reviewed well in another branch. label Jun 24, 2025
@michalkucharczyk michalkucharczyk requested a review from skunert June 24, 2025 19:33
@github-actions
Copy link
Contributor

This pull request is amending an existing release. Please proceed with extreme caution,
as to not impact downstream teams that rely on the stability of it. Some things to consider:

  • Backports are only for 'patch' or 'minor' changes. No 'major' or other breaking change.
  • Should be a legit fix for some bug, not adding tons of new features.
  • Must either be already audited or not need an audit.
Emergency Bypass

If you really need to bypass this check: add validate: false to each crate
in the Prdoc where a breaking change is introduced. This will release a new major
version of that crate and all its reverse dependencies and basically break the release.

@EgorPopelyaev EgorPopelyaev enabled auto-merge (squash) June 25, 2025 11:57
@michalkucharczyk michalkucharczyk enabled auto-merge (squash) June 25, 2025 14:52
@michalkucharczyk michalkucharczyk merged commit c2a088e into stable2506 Jun 25, 2025
280 of 306 checks passed
@michalkucharczyk michalkucharczyk deleted the backport-8596-to-stable2506 branch June 25, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A3-backport Pull request is already reviewed well in another branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants