Skip to content
Snippets Groups Projects
Unverified Commit e5df3306 authored by Michal Kucharczyk's avatar Michal Kucharczyk Committed by GitHub
Browse files

`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: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
Co-authored-by: default avatarIulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
parent 645a6f40
Branches
Pipeline #515230 waiting for manual action with stages
in 39 minutes and 4 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment