`fatxpool`: do not use individual transaction listeners (#7316)
#### Description During 2s block investigation it turned out that [ForkAwareTxPool::register_listeners](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1036) call takes significant amount of time. ``` register_listeners: at HashAndNumber { number: 12, hash: 0xe9a1...0b1d2 } took 200.041933ms register_listeners: at HashAndNumber { number: 13, hash: 0x5eb8...a87c6 } took 264.487414ms register_listeners: at HashAndNumber { number: 14, hash: 0x30cb...2e6ec } took 340.525566ms register_listeners: at HashAndNumber { number: 15, hash: 0x0450...4f05c } took 405.686659ms register_listeners: at HashAndNumber { number: 16, hash: 0xfa6f...16c20 } took 477.977836ms register_listeners: at HashAndNumber { number: 17, hash: 0x5474...5d0c1 } took 483.046029ms register_listeners: at HashAndNumber { number: 18, hash: 0x3ca5...37b78 } took 482.715468ms register_listeners: at HashAndNumber { number: 19, hash: 0xbfcc...df254 } took 484.206999ms register_listeners: at HashAndNumber { number: 20, hash: 0xd748...7f027 } took 414.635236ms register_listeners: at HashAndNumber { number: 21, hash: 0x2baa...f66b5 } took 418.015897ms register_listeners: at HashAndNumber { number: 22, hash: 0x5f1d...282b5 } took 423.342397ms register_listeners: at HashAndNumber { number: 23, hash: 0x7a18...f2d03 } took 472.742939ms register_listeners: at HashAndNumber { number: 24, hash: 0xc381...3fd07 } took 489.625557ms ``` This PR implements the idea outlined in #7071. Instead of having a separate listener for every transaction in each view, we now use a single stream of aggregated events per view, with each stream providing events for all transactions in that view. Each event is represented as a tuple: (transaction-hash, transaction-status). This significantly reduce the time required for `maintain`. #### Review Notes - single aggregated stream, provided by the individual view delivers events in form of `(transaction-hash, transaction-status)`, - `MultiViewListener` now has a task. This task is responsible for: - polling the stream map (which consists of individual view's aggregated streams) and the `controller_receiver` which provides side-channel [commands](https://github.com/paritytech/polkadot-sdk/blob/2b18e080 /substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs#L68-L95) (like `AddView` or `FinalizeTransaction`) sent from the _transaction pool_. - dispatching individual transaction statuses and control commands into the external (created via API, e.g. over RPC) listeners of individual transactions, - external listener is responsible for status handling _logic_ (e.g. deduplication of events, or ignoring some of them) and triggering statuses to external world (_this was not changed_). - level of debug messages was adjusted (per-tx messages shall be _trace_), Closes #7071 --------- Co-authored-by:Sebastian Kunert <skunert49@gmail.com>
parent
37446fcb
Showing
- substrate/client/service/src/lib.rs 2 additions, 2 deletionssubstrate/client/service/src/lib.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/dropped_watcher.rs 1 addition, 1 deletion...transaction-pool/src/fork_aware_txpool/dropped_watcher.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs 30 additions, 84 deletions...ansaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/mod.rs 47 additions, 26 deletions...rate/client/transaction-pool/src/fork_aware_txpool/mod.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs 524 additions, 305 deletions...saction-pool/src/fork_aware_txpool/multi_view_listener.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs 8 additions, 33 deletions...ent/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/view.rs 19 additions, 30 deletions...ate/client/transaction-pool/src/fork_aware_txpool/view.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs 16 additions, 76 deletions...ient/transaction-pool/src/fork_aware_txpool/view_store.rs
- substrate/client/transaction-pool/src/graph/listener.rs 78 additions, 38 deletionssubstrate/client/transaction-pool/src/graph/listener.rs
- substrate/client/transaction-pool/src/graph/mod.rs 3 additions, 1 deletionsubstrate/client/transaction-pool/src/graph/mod.rs
- substrate/client/transaction-pool/src/graph/tracked_map.rs 0 additions, 5 deletionssubstrate/client/transaction-pool/src/graph/tracked_map.rs
- substrate/client/transaction-pool/src/graph/validated_pool.rs 9 additions, 1 deletion...trate/client/transaction-pool/src/graph/validated_pool.rs
- substrate/client/transaction-pool/tests/fatp_common/mod.rs 2 additions, 2 deletionssubstrate/client/transaction-pool/tests/fatp_common/mod.rs
- substrate/client/transaction-pool/tests/fatp_limits.rs 1 addition, 2 deletionssubstrate/client/transaction-pool/tests/fatp_limits.rs
Please register or sign in to comment