Skip to content
Merged
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
40 changes: 38 additions & 2 deletions crates/cli/commands/src/prune.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
//! Command that runs pruning without any limits.
use crate::common::{AccessRights, CliNodeTypes, EnvironmentArgs};
use clap::Parser;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks};
use reth_cli::chainspec::ChainSpecParser;
use reth_cli_runner::CliContext;
use reth_node_builder::common::metrics_hooks;
use reth_node_core::{args::MetricArgs, version::version_metadata};
use reth_node_metrics::{
chain::ChainSpecInfo,
server::{MetricServer, MetricServerConfig},
version::VersionInfo,
};
use reth_prune::PrunerBuilder;
use reth_static_file::StaticFileProducer;
use std::sync::Arc;
Expand All @@ -13,14 +21,42 @@ use tracing::info;
pub struct PruneCommand<C: ChainSpecParser> {
#[command(flatten)]
env: EnvironmentArgs<C>,

/// Prometheus metrics configuration.
#[command(flatten)]
metrics: MetricArgs,
}

impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> PruneCommand<C> {
/// Execute the `prune` command
pub async fn execute<N: CliNodeTypes<ChainSpec = C::ChainSpec>>(self) -> eyre::Result<()> {
pub async fn execute<N: CliNodeTypes<ChainSpec = C::ChainSpec>>(
self,
ctx: CliContext,
) -> eyre::Result<()> {
let env = self.env.init::<N>(AccessRights::RW)?;
let provider_factory = env.provider_factory;
let config = env.config.prune;
let data_dir = env.data_dir;

if let Some(listen_addr) = self.metrics.prometheus {
let config = MetricServerConfig::new(
listen_addr,
VersionInfo {
version: version_metadata().cargo_pkg_version.as_ref(),
build_timestamp: version_metadata().vergen_build_timestamp.as_ref(),
cargo_features: version_metadata().vergen_cargo_features.as_ref(),
git_sha: version_metadata().vergen_git_sha.as_ref(),
target_triple: version_metadata().vergen_cargo_target_triple.as_ref(),
build_profile: version_metadata().build_profile_name.as_ref(),
},
ChainSpecInfo { name: provider_factory.chain_spec().chain().to_string() },
ctx.task_executor,
metrics_hooks(&provider_factory),
data_dir.pprof_dumps(),
);

MetricServer::new(config).serve().await?;
}

// Copy data from database to static files
info!(target: "reth::cli", "Copying data from database to static files...");
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
}
Commands::P2P(command) => runner.run_until_ctrl_c(command.execute::<N>()),
Commands::Config(command) => runner.run_until_ctrl_c(command.execute()),
Commands::Prune(command) => runner.run_until_ctrl_c(command.execute::<N>()),
Commands::Prune(command) => runner.run_command_until_exit(|ctx| command.execute::<N>(ctx)),
#[cfg(feature = "dev")]
Commands::TestVectors(command) => runner.run_until_ctrl_c(command.execute()),
Commands::ReExecute(command) => runner.run_until_ctrl_c(command.execute::<N>(components)),
Expand Down
4 changes: 3 additions & 1 deletion crates/optimism/cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ where
}
Commands::P2P(command) => runner.run_until_ctrl_c(command.execute::<OpNode>()),
Commands::Config(command) => runner.run_until_ctrl_c(command.execute()),
Commands::Prune(command) => runner.run_until_ctrl_c(command.execute::<OpNode>()),
Commands::Prune(command) => {
runner.run_command_until_exit(|ctx| command.execute::<OpNode>(ctx))
}
#[cfg(feature = "dev")]
Commands::TestVectors(command) => runner.run_until_ctrl_c(command.execute()),
Commands::ReExecute(command) => {
Expand Down
18 changes: 18 additions & 0 deletions docs/vocs/docs/pages/cli/op-reth/prune.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ RocksDB:
[default: false]
[possible values: true, false]

Metrics:
--metrics <PROMETHEUS>
Enable Prometheus metrics.

The metrics will be served at the given interface and port.

--metrics.prometheus.push.url <PUSH_GATEWAY_URL>
URL for pushing Prometheus metrics to a push gateway.

If set, the node will periodically push metrics to the specified push gateway URL.

--metrics.prometheus.push.interval <SECONDS>
Interval in seconds for pushing metrics to push gateway.

Default: 5 seconds

[default: 5]

Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
18 changes: 18 additions & 0 deletions docs/vocs/docs/pages/cli/reth/prune.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ RocksDB:
[default: false]
[possible values: true, false]

Metrics:
--metrics <PROMETHEUS>
Enable Prometheus metrics.

The metrics will be served at the given interface and port.

--metrics.prometheus.push.url <PUSH_GATEWAY_URL>
URL for pushing Prometheus metrics to a push gateway.

If set, the node will periodically push metrics to the specified push gateway URL.

--metrics.prometheus.push.interval <SECONDS>
Interval in seconds for pushing metrics to push gateway.

Default: 5 seconds

[default: 5]

Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
Loading