Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics to TxPool #2321

Merged
merged 85 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
eb5525c
Add `gas_per_block` metric
rafal-ch Oct 7, 2024
260b745
Add `transactions_per_block` metric
rafal-ch Oct 7, 2024
c84204b
Add `fee_per_block` metric
rafal-ch Oct 7, 2024
8c5a979
Correct bucket names
rafal-ch Oct 7, 2024
ddb424e
Producer metrics - gas price
acerone85 Oct 7, 2024
27fb0fd
Update bucket values for new metrics
rafal-ch Oct 7, 2024
09357db
chore: add libp2p bandwidth metrics
rymnc Oct 7, 2024
088b918
fix: use dns
rymnc Oct 7, 2024
76b1084
chore: more p2p metrics
rymnc Oct 7, 2024
090ada8
Rework histogram bucket initialization
rafal-ch Oct 8, 2024
bd8b64b
Bucket access function returns iterator
rafal-ch Oct 8, 2024
f205434
Extract the `buckets` module
rafal-ch Oct 8, 2024
de98ec5
Update changelog
rafal-ch Oct 8, 2024
58cf08b
Merge remote-tracking branch 'upstream/master' into 807_add_more_metrics
rafal-ch Oct 8, 2024
c897f8a
Fix `tokio` dependencies
rafal-ch Oct 8, 2024
f184a61
Add test for the presence of all required buckets
rafal-ch Oct 8, 2024
b86efce
Additional length assert in bucket tests
rafal-ch Oct 8, 2024
b8241a0
Remove the `GasPrice` metric
rafal-ch Oct 8, 2024
94f3d42
Fix `strum` dependency definition
rafal-ch Oct 8, 2024
4166809
Update the metric bucket values
rafal-ch Oct 8, 2024
3b128b5
Use explicit `_gwei` suffix for "fee_per_block" metric
rafal-ch Oct 8, 2024
8817d1a
Update changelog
rafal-ch Oct 8, 2024
9bc707c
Merge branch 'master' into 807_add_more_metrics
rafal-ch Oct 8, 2024
3badebd
Reformat `Buckets::Timing` for clarity
rafal-ch Oct 8, 2024
aadc59f
Merge remote-tracking branch 'upstream/807_add_more_metrics' into 807…
rafal-ch Oct 8, 2024
87eed6d
Calculate `total_gas_used` and `total_fee` in a single pass over tran…
rafal-ch Oct 8, 2024
fa60c9e
Move metrics to executor
rafal-ch Oct 8, 2024
10e3407
Add the `executor_size_per_block_bytes` metric
rafal-ch Oct 8, 2024
0978160
Remove no longer used metrics from the importer
rafal-ch Oct 8, 2024
3920e74
Remove the no longer needed `total_fee()` function
rafal-ch Oct 8, 2024
703a89d
Update executor metrics after processing all transactions from a block
rafal-ch Oct 8, 2024
b10178e
Fix comment
rafal-ch Oct 8, 2024
b41331b
Update bucket sized for 'Fee' metric
rafal-ch Oct 9, 2024
ef13002
Update bucket sized for 'TransactionsCount' metric
rafal-ch Oct 9, 2024
fecb95d
WIP: Add metrics to TxPoolV2
acerone85 Oct 8, 2024
f5f97e9
Number of transactions pending verification
acerone85 Oct 8, 2024
5387bc9
Update bucket sized for 'SizeUsed' metric
rafal-ch Oct 9, 2024
2b4482a
Fixup
acerone85 Oct 9, 2024
e25e1dc
Time spent in txpool
acerone85 Oct 9, 2024
4f9e452
Executable txs in txpool
acerone85 Oct 9, 2024
76532a9
Add code for metering tx size, rename some stuff, add comments
MitchTurner Oct 9, 2024
84d4595
Add select_transaction_time_nanoseconds TxPool metric
rafal-ch Oct 9, 2024
ad5d73f
Use nanoseconds in the `select_transaction_time_nanoseconds` metric
rafal-ch Oct 9, 2024
853100d
Move the execution metrics to importer
rafal-ch Oct 9, 2024
37d4cdc
Block importer respects the `--metrics` command line parameter
rafal-ch Oct 9, 2024
0fa3a39
Move metric bucket initialization to `buckets.rs`
rafal-ch Oct 9, 2024
fcab288
Merge remote-tracking branch 'upstream/807_add_more_metrics' into 193…
rafal-ch Oct 9, 2024
5c6c3f0
Add `TransactionSize` bucket for metrics
rafal-ch Oct 9, 2024
013ab50
Add a metric that keeps track of how long transaction insertion funct…
acerone85 Oct 10, 2024
fcb571f
Move measurements for transaction insertion task to a closure wrappin…
acerone85 Oct 10, 2024
ed18ad1
Add metrics flag to TxPool config and record metrics only when flag i…
acerone85 Oct 10, 2024
2297804
Merge remote-tracking branch 'upstream/master' into 807_add_more_metrics
rafal-ch Oct 11, 2024
11a6cfe
Merge remote-tracking branch 'upstream/master' into 807_add_more_metrics
rafal-ch Oct 14, 2024
c921a09
Add support for comma separated metric configuration
rafal-ch Oct 14, 2024
0785b2d
Update changelog
rafal-ch Oct 14, 2024
aa751cd
Detailed help message string for `disable-metrics`
rafal-ch Oct 14, 2024
0f85f04
Sort dependencies
rafal-ch Oct 14, 2024
21ebbc9
Make the `disable-metrics` cli arg optional
rafal-ch Oct 14, 2024
523932d
Simplify implementation of `HELP_STRING`
rafal-ch Oct 14, 2024
2b5da1d
Merge remote-tracking branch 'upstream/807_add_more_metrics' into 193…
rafal-ch Oct 14, 2024
1b5c428
Add additional tests for metrics config
rafal-ch Oct 14, 2024
2fba5d2
Figure out dependencies to be able to run tests locally
rafal-ch Oct 14, 2024
f23b469
Merge remote-tracking branch 'upstream/master' into 807_add_more_metrics
rafal-ch Oct 14, 2024
e67ae19
Fix compilation issues in `metrics` crate
rafal-ch Oct 14, 2024
c043ed7
Change some metrics from histogram to a gauge
rafal-ch Oct 14, 2024
7d17f99
Add `importer_gas_price_for_block` metric
rafal-ch Oct 14, 2024
e0124b6
Simplify metric config handling
rafal-ch Oct 14, 2024
f12185f
Make metric config tests more robust
rafal-ch Oct 14, 2024
be71c4b
Merge branch 'master' into 807_add_more_metrics
xgreenx Oct 14, 2024
9636887
Merge remote-tracking branch 'origin/807_add_more_metrics' into 1937_…
acerone85 Oct 14, 2024
a128622
Metric config creation may now return an error
rafal-ch Oct 14, 2024
395f491
Merge remote-tracking branch 'upstream/807_add_more_metrics' into 807…
rafal-ch Oct 14, 2024
eb3872f
Log metrics config at startup
rafal-ch Oct 14, 2024
bee9c6f
Allow creating metrics config from empty string, it's equal to `all`
rafal-ch Oct 14, 2024
8da222a
Merge remote-tracking branch 'upstream/master' into 807_add_more_metrics
rafal-ch Oct 14, 2024
5da05f0
Merge
acerone85 Oct 14, 2024
7b3e465
CHANGELOG
acerone85 Oct 14, 2024
d1f94b7
Merge branch 'master' into 1937_tx_pool_metrics
acerone85 Oct 15, 2024
e92c30f
Organize metrics recording functions
acerone85 Oct 15, 2024
365807b
Add coarse grained timing buckets for histograms in ms and ns
acerone85 Oct 15, 2024
dc197d3
Update changelog
acerone85 Oct 15, 2024
1e3810d
Rename op_without_metrics to op
acerone85 Oct 15, 2024
889b92d
Better naming for insert transaction internal operation
acerone85 Oct 15, 2024
e3f201d
Rename metrics into disable metrics in CLI extract configuration func…
acerone85 Oct 15, 2024
9cee869
Add documentation for TxPool metrics
acerone85 Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- [2321](https://github.com/FuelLabs/fuel-core/pull/2321): New metrics for the txpool: "The size of transactions in the txpool" (`txpool_tx_size`), "The time spent by a transaction in the txpool in seconds" (`txpool_tx_time_in_txpool_seconds`), The number of transactions in the txpool (`txpool_number_of_transactions`), "The number of transactions pending verification before entering the txpool" (`txpool_number_of_transactions_pending_verification`), "The number of executable transactions in the txpool" (`txpool_number_of_executable_transactions`), "The time it took to select transactions for inclusion in a block in nanoseconds" (`txpool_select_transaction_time_nanoseconds`), The time it took to insert a transaction in the txpool in milliseconds (`txpool_insert_transaction_time_milliseconds`).

## [Version 0.40.0]

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl Command {
p2p_args,
#[cfg(feature = "p2p")]
sync_args,
disabled_metrics: metrics,
disabled_metrics,
max_da_lag,
max_wait_time,
tx_pool,
Expand All @@ -309,7 +309,7 @@ impl Command {
profiling: _,
} = self;

let enabled_metrics = metrics.list_of_enabled();
let enabled_metrics = disabled_metrics.list_of_enabled();

if !enabled_metrics.is_empty() {
info!("`{:?}` metrics are enabled", enabled_metrics);
Expand All @@ -334,7 +334,7 @@ impl Command {
#[cfg(feature = "p2p")]
let p2p_cfg = p2p_args.into_config(
chain_config.chain_name.clone(),
metrics.is_enabled(Module::P2P),
disabled_metrics.is_enabled(Module::P2P),
)?;

let trigger: Trigger = poa_trigger.into();
Expand Down Expand Up @@ -444,7 +444,7 @@ impl Command {
};

let block_importer = fuel_core::service::config::fuel_core_importer::Config::new(
metrics.is_enabled(Module::Importer),
disabled_metrics.is_enabled(Module::Importer),
);

let da_compression = match da_compression {
Expand Down Expand Up @@ -562,10 +562,11 @@ impl Command {
pool_limits,
heavy_work: pool_heavy_work_config,
service_channel_limits,
metrics: disabled_metrics.is_enabled(Module::TxPool),
},
block_producer: ProducerConfig {
coinbase_recipient,
metrics: metrics.is_enabled(Module::Producer),
metrics: disabled_metrics.is_enabled(Module::Producer),
},
starting_gas_price,
gas_price_change_percent,
Expand Down
42 changes: 42 additions & 0 deletions crates/metrics/src/buckets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use strum_macros::EnumIter;
#[cfg_attr(test, derive(EnumIter))]
pub(crate) enum Buckets {
Timing,
TimingCoarseGrained,
TransactionSize,
}
static BUCKETS: OnceLock<HashMap<Buckets, Vec<f64>>> = OnceLock::new();
pub(crate) fn buckets(b: Buckets) -> impl Iterator<Item = f64> {
Expand All @@ -34,6 +36,46 @@ fn initialize_buckets() -> HashMap<Buckets, Vec<f64>> {
10.000,
],
),
(
Buckets::TimingCoarseGrained,
vec![
5.0,
10.0,
25.0,
50.0,
100.0,
250.0,
500.0,
1000.0,
2500.0,
5000.0,
10000.0,
],
),
(
// We consider blocks up to 256kb in size and single transaction can take any of this space.
Buckets::TransactionSize,
vec![
1.0 * 1024.0,
2.0 * 1024.0,
3.0 * 1024.0,
4.0 * 1024.0,
5.0 * 1024.0,
7.0 * 1024.0,
10.0 * 1024.0,
13.0 * 1024.0,
18.0 * 1024.0,
24.0 * 1024.0,
33.0 * 1024.0,
44.0 * 1024.0,
59.0 * 1024.0,
79.0 * 1024.0,
106.0 * 1024.0,
142.0 * 1024.0,
191.0 * 1024.0,
256.0 * 1024.0,
]
),
]
.into_iter()
.collect()
Expand Down
91 changes: 82 additions & 9 deletions crates/metrics/src/txpool_metrics.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,97 @@
use crate::global_registry;
use prometheus_client::metrics::histogram::Histogram;
use crate::{
buckets::{
buckets,
Buckets,
},
global_registry,
};
use prometheus_client::metrics::{
gauge::Gauge,
histogram::Histogram,
};
use std::sync::OnceLock;

pub struct TxPoolMetrics {
pub tx_size_histogram: Histogram,
/// Size of transactions in the txpool in bytes
pub tx_size: Histogram,
/// Number of transactions in the txpool
pub number_of_transactions: Gauge,
/// Number of transactions pending verification, before being inserted in the txpool
pub number_of_transactions_pending_verification: Gauge,
/// Number of transactions that can be included in the next block
pub number_of_executable_transactions: Gauge,
/// Time of transactions in the txpool in seconds
pub transaction_time_in_txpool_secs: Histogram,
/// Time actively spent by transaction insertion in the thread pool
pub transaction_insertion_time_in_thread_pool_milliseconds: Histogram,
/// How long it took for the selection algorithm to select transactions
pub select_transaction_time_nanoseconds: Histogram,
}
Comment on lines +24 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use the same units to track things. Like either nanoseconds, or milliseconds, or seconds. Not all 3=D

I think Nanoseconds are ok, we always can divide it=)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with having different units in the metric producer (I mean: units that fit the value being observed best), as long as the unit is clearly communicated in the metric name. The presentation layer could do all necessary shenanigans required to show proper data.

Otoh, there's also a merit in having a consistent time unit, but nanoseconds everywhere are too fine-grained in my opinion. For example, if transactions can live up to 10 minutes in the TxPool we're gonna be dealing with numbers such as 600_000_000_000.

I'll wait for more opinions before I start fiddling with the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on whether we decide to stick with nanoseconds for all metrics, as @rafal-ch said it has the merit of bringing uniformity across metrics. But even in that case we will need multiple timing buckets for different granularities.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the meeting:
transaction_insertion_time_in_thread_pool and select_transaction_time should be measured in microseconds.
10us - minimal value, 5s - max value (however, unlikely)

we don't aim for a single unit for all metrics at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in 49a79b2


impl Default for TxPoolMetrics {
fn default() -> Self {
let tx_sizes = Vec::new();
let tx_size = Histogram::new(buckets(Buckets::TransactionSize));
let transaction_time_in_txpool_secs = Histogram::new(buckets(Buckets::Timing));
let select_transaction_time_nanoseconds =
Histogram::new(buckets(Buckets::TimingCoarseGrained));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to rename it to be select_transactions_time_nanoseconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7c79307

let transaction_insertion_time_in_thread_pool_milliseconds =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I think these values are too small for selection of transaction and insertion into TxPool. The maximum values. I think we want to have:

50 microseconds
250 microseconds
1 milliseconds
10 milliseconds
100 milliseconds
300 milliseconds (because it is 1/3 of the block execution time)
1 second
5 second

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you use the same bucket table for nanoseconds and milliseconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buckets have been updated in 58bf187 and d46468c

Histogram::new(buckets(Buckets::TimingCoarseGrained));

let tx_size_histogram = Histogram::new(tx_sizes.into_iter());
let number_of_transactions = Gauge::default();
let number_of_transactions_pending_verification = Gauge::default();
let number_of_executable_transactions = Gauge::default();

let metrics = TxPoolMetrics { tx_size_histogram };
let metrics = TxPoolMetrics {
tx_size,
number_of_transactions,
number_of_transactions_pending_verification,
number_of_executable_transactions,
transaction_time_in_txpool_secs,
transaction_insertion_time_in_thread_pool_milliseconds,
select_transaction_time_nanoseconds,
};

let mut registry = global_registry().registry.lock();
registry.register(
"Tx_Size_Histogram",
"A Histogram keeping track of the size of txs",
metrics.tx_size_histogram.clone(),
"txpool_tx_size",
"The size of transactions in the txpool",
metrics.tx_size.clone(),
);

registry.register(
"txpool_tx_time_in_txpool_seconds",
"The time spent by a transaction in the txpool in seconds",
metrics.transaction_time_in_txpool_secs.clone(),
);

registry.register(
"txpool_number_of_transactions",
"The number of transactions in the txpool",
metrics.number_of_transactions.clone(),
);

registry.register(
"txpool_number_of_executable_transactions",
"The number of executable transactions in the txpool",
metrics.number_of_executable_transactions.clone(),
);

registry.register(
"txpool_number_of_transactions_pending_verification",
"The number of transactions pending verification before entering the txpool",
metrics.number_of_transactions_pending_verification.clone(),
);

registry.register(
"txpool_select_transaction_time_nanoseconds",
"The time it took to select transactions for inclusion in a block in nanoseconds",
metrics.select_transaction_time_nanoseconds.clone(),
);

registry.register(
"txpool_insert_transaction_time_milliseconds",
"The time it took to insert a transaction in the txpool in milliseconds",
metrics.select_transaction_time_nanoseconds.clone(),
);

metrics
Expand Down
1 change: 1 addition & 0 deletions crates/services/txpool_v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = "Transaction pool that manages transactions and their dependencies
anyhow = { workspace = true }
async-trait = { workspace = true }
derive_more = { workspace = true }
fuel-core-metrics = { workspace = true }
fuel-core-services = { workspace = true, features = ["sync-processor"] }
fuel-core-storage = { workspace = true, features = ["std"] }
fuel-core-types = { workspace = true, features = ["test-helpers"] }
Expand Down
3 changes: 3 additions & 0 deletions crates/services/txpool_v2/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ pub struct Config {
pub heavy_work: HeavyWorkConfig,
/// Blacklist. Transactions with blacklisted inputs will not be accepted.
pub black_list: BlackList,
/// Enable metrics when set to true
pub metrics: bool,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -199,6 +201,7 @@ impl Default for Config {
max_pending_write_pool_requests: 1000,
max_pending_read_pool_requests: 1000,
},
metrics: false,
}
}
}
39 changes: 36 additions & 3 deletions crates/services/txpool_v2/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ mod collisions;
use std::{
collections::HashMap,
iter,
time::SystemTime,
time::{
Instant,
SystemTime,
},
};

use collisions::CollisionsExt;
Expand Down Expand Up @@ -228,6 +231,22 @@ where
Ok(can_store_transaction)
}

fn record_transaction_time_in_txpool(tx: &StorageData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we need to remember to record these metrics only if config.metrics is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in ed18ad1, although the workflow could be improved. Maybe having MetricsRecorder struct that wraps TxPoolMetrics and exposes the functions to record the metrics could work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the current flow. You're talking about here?

        best_txs
            .into_iter()
            .inspect(|storage_data| {
                if metrics {
                    Self::record_transaction_time_in_txpool(storage_data)
                }
            })

It's pretty easy to read.

if let Ok(elapsed) = tx.creation_instant.elapsed() {
fuel_core_metrics::txpool_metrics::txpool_metrics()
.transaction_time_in_txpool_secs
.observe(elapsed.as_secs_f64());
Comment on lines +236 to +238
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sounds like a very bad bucket for TxPool. All transactions will live at least one second. But they can leave up to 10 minutes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bucket has been updated in d46468c

} else {
tracing::warn!("Failed to calculate transaction time in txpool");
}
}

fn record_select_transaction_time_in_nanoseconds(start: Instant) {
let elapsed = start.elapsed().as_nanos() as f64;
fuel_core_metrics::txpool_metrics::txpool_metrics()
.select_transaction_time_nanoseconds
.observe(elapsed);
}
// TODO: Use block space also (https://github.com/FuelLabs/fuel-core/issues/2133)
/// Extract transactions for a block.
/// Returns a list of transactions that were selected for the block
Expand All @@ -236,9 +255,23 @@ where
&mut self,
constraints: Constraints,
) -> Vec<ArcPoolTx> {
self.selection_algorithm
.gather_best_txs(constraints, &mut self.storage)
let start = std::time::Instant::now();
let metrics = self.config.metrics;
Comment on lines +258 to +259
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let start = if self.config.metrics {
    Some(std::time::Instant::now())
} else {
    None
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in da77cf9

let best_txs = self
.selection_algorithm
.gather_best_txs(constraints, &mut self.storage);

if metrics {
Self::record_select_transaction_time_in_nanoseconds(start)
};
Comment on lines +264 to +266
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if let Some(start) = start {
    Self::record_select_transaction_time_in_nanoseconds(start)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in da77cf9


best_txs
.into_iter()
.inspect(|storage_data| {
if metrics {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move this "If" before best_txs.into_iter() it will be more performant and compiler can do better optimizations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First approach: fec31bb

But I actually ended up with this, trading code clarity for the potential double iteration if metrics are enabled.

Self::record_transaction_time_in_txpool(storage_data)
}
})
.map(|storage_entry| {
self.update_components_and_caches_on_removal(iter::once(&storage_entry));

Expand Down
3 changes: 3 additions & 0 deletions crates/services/txpool_v2/src/selection_algorithms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub trait SelectionAlgorithm {
store_entry: &StorageData,
);

/// Returns the number of executable transactions
fn number_of_executable_transactions(&self) -> usize;

/// Get less worth transactions iterator
fn get_less_worth_txs(&self) -> impl Iterator<Item = &Self::StorageIndex>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,8 @@ where
let key = Self::key(storage_entry);
self.on_removed_transaction_inner(key)
}

fn number_of_executable_transactions(&self) -> usize {
self.executable_transactions_sorted_tip_gas_ratio.len()
}
}
Loading
Loading