Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions crates/static-file/static-file/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ workspace = true
# reth
reth-codecs.workspace = true
reth-db-api.workspace = true
reth-metrics.workspace = true
reth-primitives-traits.workspace = true
reth-provider.workspace = true
reth-storage-errors.workspace = true
reth-tokio-util.workspace = true
reth-prune-types.workspace = true
reth-primitives-traits.workspace = true
reth-static-file-types.workspace = true
reth-stages-types.workspace = true
reth-static-file-types.workspace = true
reth-storage-errors.workspace = true
reth-tokio-util.workspace = true

alloy-primitives.workspace = true

# misc
tracing.workspace = true
rayon.workspace = true
metrics.workspace = true
parking_lot = { workspace = true, features = ["send_guard", "arc_lock"] }
rayon.workspace = true
tracing.workspace = true

[dev-dependencies]
reth-stages = { workspace = true, features = ["test-utils"] }
Expand Down
1 change: 1 addition & 0 deletions crates/static-file/static-file/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

mod metrics;
pub mod segments;
mod static_file_producer;

Expand Down
14 changes: 14 additions & 0 deletions crates/static-file/static-file/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Static file producer metrics.

use metrics::Histogram;
use reth_metrics::Metrics;

/// Static file producer metrics.
#[derive(Metrics, Clone)]
#[metrics(scope = "static_file.producer")]
pub(crate) struct StaticFileProducerMetrics {
/// Histogram for the time taken to produce static files for a single segment (in seconds).
pub(crate) segment_production_duration: Histogram,
/// Histogram for the total time taken to produce all static files (in seconds).
pub(crate) total_production_duration: Histogram,
}
19 changes: 15 additions & 4 deletions crates/static-file/static-file/src/static_file_producer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Support for producing static files.

use crate::{segments, segments::Segment, StaticFileProducerEvent};
use crate::{
metrics::StaticFileProducerMetrics, segments, segments::Segment, StaticFileProducerEvent,
};
use alloy_primitives::BlockNumber;
use parking_lot::Mutex;
use rayon::prelude::*;
Expand Down Expand Up @@ -67,11 +69,18 @@ pub struct StaticFileProducerInner<Provider> {
/// files. See [`StaticFileProducerInner::get_static_file_targets`].
prune_modes: PruneModes,
event_sender: EventSender<StaticFileProducerEvent>,
/// Metrics for tracking static file production performance.
metrics: StaticFileProducerMetrics,
}

impl<Provider> StaticFileProducerInner<Provider> {
fn new(provider: Provider, prune_modes: PruneModes) -> Self {
Self { provider, prune_modes, event_sender: Default::default() }
Self {
provider,
prune_modes,
event_sender: Default::default(),
metrics: StaticFileProducerMetrics::default(),
}
}
}

Expand Down Expand Up @@ -145,7 +154,8 @@ where
let provider = self.provider.database_provider_ro()?.disable_long_read_transaction_safety();
segment.copy_to_static_files(provider, block_range.clone())?;

let elapsed = start.elapsed(); // TODO(alexey): track in metrics
let elapsed = start.elapsed();
self.metrics.segment_production_duration.record(elapsed);
debug!(target: "static_file", segment = %segment.segment(), ?block_range, ?elapsed, "Finished StaticFileProducer segment");

Ok(())
Expand All @@ -158,7 +168,8 @@ where
.update_index(segment.segment(), Some(*block_range.end()))?;
}

let elapsed = start.elapsed(); // TODO(alexey): track in metrics
let elapsed = start.elapsed();
self.metrics.total_production_duration.record(elapsed);
debug!(target: "static_file", ?targets, ?elapsed, "StaticFileProducer finished");

self.event_sender
Expand Down
8 changes: 4 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
[advisories]
yanked = "warn"
ignore = [
# https://rustsec.org/advisories/RUSTSEC-2024-0384 used by sse example
"RUSTSEC-2024-0384",
# https://rustsec.org/advisories/RUSTSEC-2024-0436 paste! is unmaintained
"RUSTSEC-2024-0436",
# https://rustsec.org/advisories/RUSTSEC-2025-0141 bincode is unmaintained, need to transition all deps to wincode first
"RUSTSEC-2025-0141",
# https://rustsec.org/advisories/RUSTSEC-2026-0002 lru unused directly: <https://github.com/alloy-rs/alloy/pull/3460>
"RUSTSEC-2026-0002",
# https://rustsec.org/advisories/RUSTSEC-2026-0007 bytes integer overflow, will be fixed in separate PR
"RUSTSEC-2026-0007",
# https://rustsec.org/advisories/RUSTSEC-2026-0009 time DoS vulnerability, will be fixed in separate PR
"RUSTSEC-2026-0009",
]

# This section is considered when running `cargo deny check bans`.
Expand Down
Loading