`fatxpool`: transaction statuses metrics added (#7505)
#### Overview This PR introduces a new mechanism to capture and report metrics related to timings of transaction lifecycle events, which are currently not available. By exposing these timings, we aim to augment transaction-pool reliability dashboards and extend existing Grafana boards. A new `unknown_from_block_import_txs` metric is also introduced. It provides the number of transactions in imported block which are not known to the node's transaction pool. It allows to monitor alignment of transaction pools across the nodes in the network. #### Notes for reviewers - **[Per-event Metrics](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L84-L105) Collection**: implemented by[ `EventsMetricsCollector`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L353-L358) which allows to capture both submission timestamps and transaction status updates. An asynchronous [`EventsMetricsCollectorTask`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L503-L526) processes the metrics-related messages sent by the `EventsMetricsCollector` and reports the timings of transaction statuses updates to Prometheus. This task implements event[ de-duplication](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L458) using a `HashMap` of [`TransactionEventMetricsData`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L424-L435) entries which also holds transaction submission timestamps used to [compute timings](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L489-L495). Transaction-related items are removed when transaction's final status is [reported](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L496). - Transaction submission timestamp is reusing the timestamp of `TimedTransactionSource` kept in mempool. It is reported to `EventsMetricsCollector` in [`submit_at`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L735) and [`submit_and_watch`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L836) methods of `ForkAwareTxPool`. - Transaction updates are reported to `EventsMetricsCollector` from `MultiViewListener` [task](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs#L494). This allows to gather metrics for _watched_ and _non-watched_ transactions (what enables metrics on non-rpc-enabled collators). - New metric ([`unknown_from_block_import_txs`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L59-L60)) allowing checking alignment of pools across the network is [reported](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1288-L1292) using new `TxMemPool` [method](https://github.com/paritytech/polkadot-sdk/blob/8a53992e /substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs#L605-L611). fixes: #7355, #7448 --------- Co-authored-by:cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by:
Sebastian Kunert <skunert49@gmail.com> Co-authored-by:
Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
Showing
- prdoc/pr_7505.prdoc 14 additions, 0 deletionsprdoc/pr_7505.prdoc
- substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs 32 additions, 13 deletions...ansaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs 382 additions, 3 deletions.../client/transaction-pool/src/fork_aware_txpool/metrics.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs 44 additions, 6 deletions...saction-pool/src/fork_aware_txpool/multi_view_listener.rs
- substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs 11 additions, 1 deletion...ent/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs
Please register or sign in to comment