From 5470574bf208b36696b44a4ecd591cfb3cc98496 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Tue, 20 Aug 2024 07:20:55 -0700 Subject: [PATCH] feat(node): remove freelist from status log (#10395) --- Cargo.lock | 1 - bin/reth/src/commands/debug_cmd/execution.rs | 1 - crates/cli/commands/src/import.rs | 7 +--- crates/node/builder/src/launch/engine.rs | 1 - crates/node/builder/src/launch/mod.rs | 1 - crates/node/events/Cargo.toml | 1 - crates/node/events/src/node.rs | 38 ++++---------------- crates/optimism/cli/src/commands/import.rs | 7 +--- 8 files changed, 9 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30acc74a04e8..b7e25aa4afff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7817,7 +7817,6 @@ dependencies = [ "humantime", "pin-project", "reth-beacon-consensus", - "reth-db-api", "reth-network", "reth-network-api", "reth-primitives", diff --git a/bin/reth/src/commands/debug_cmd/execution.rs b/bin/reth/src/commands/debug_cmd/execution.rs index 3d451ad6e86e..bfa5c24a311f 100644 --- a/bin/reth/src/commands/debug_cmd/execution.rs +++ b/bin/reth/src/commands/debug_cmd/execution.rs @@ -209,7 +209,6 @@ impl Command { Some(Box::new(network)), latest_block_number, events, - provider_factory.db_ref().clone(), ), ); diff --git a/crates/cli/commands/src/import.rs b/crates/cli/commands/src/import.rs index b7695379b0cb..fb3c1815d2c2 100644 --- a/crates/cli/commands/src/import.rs +++ b/crates/cli/commands/src/import.rs @@ -114,12 +114,7 @@ impl ImportCommand { let latest_block_number = provider.get_stage_checkpoint(StageId::Finish)?.map(|ch| ch.block_number); - tokio::spawn(reth_node_events::node::handle_events( - None, - latest_block_number, - events, - provider_factory.db_ref().clone(), - )); + tokio::spawn(reth_node_events::node::handle_events(None, latest_block_number, events)); // Run pipeline info!(target: "reth::cli", "Starting sync pipeline"); diff --git a/crates/node/builder/src/launch/engine.rs b/crates/node/builder/src/launch/engine.rs index b6f4a2bf998b..4d2ed714c2b5 100644 --- a/crates/node/builder/src/launch/engine.rs +++ b/crates/node/builder/src/launch/engine.rs @@ -240,7 +240,6 @@ where Some(Box::new(ctx.components().network().clone())), Some(ctx.head().number), events, - database.clone(), ), ); diff --git a/crates/node/builder/src/launch/mod.rs b/crates/node/builder/src/launch/mod.rs index a61c1def10b5..60b7dc6d795b 100644 --- a/crates/node/builder/src/launch/mod.rs +++ b/crates/node/builder/src/launch/mod.rs @@ -326,7 +326,6 @@ where Some(Box::new(ctx.components().network().clone())), Some(ctx.head().number), events, - database.clone(), ), ); diff --git a/crates/node/events/Cargo.toml b/crates/node/events/Cargo.toml index d592d25f3902..a4970677ac3a 100644 --- a/crates/node/events/Cargo.toml +++ b/crates/node/events/Cargo.toml @@ -18,7 +18,6 @@ reth-network-api.workspace = true reth-stages.workspace = true reth-prune.workspace = true reth-static-file.workspace = true -reth-db-api.workspace = true reth-primitives.workspace = true reth-primitives-traits.workspace = true diff --git a/crates/node/events/src/node.rs b/crates/node/events/src/node.rs index 3fe989ab0b54..1583c619e790 100644 --- a/crates/node/events/src/node.rs +++ b/crates/node/events/src/node.rs @@ -6,7 +6,6 @@ use futures::Stream; use reth_beacon_consensus::{ BeaconConsensusEngineEvent, ConsensusEngineLiveSyncProgress, ForkchoiceStatus, }; -use reth_db_api::{database::Database, database_metrics::DatabaseMetadata}; use reth_network::NetworkEvent; use reth_network_api::PeersInfo; use reth_primitives::{constants, BlockNumber, B256}; @@ -31,11 +30,7 @@ const INFO_MESSAGE_INTERVAL: Duration = Duration::from_secs(25); /// connections, current processing stage, and the latest block information. It provides /// methods to handle different types of events that affect the node's state, such as pipeline /// events, network events, and consensus engine events. -struct NodeState { - /// Database environment. - /// Used for freelist calculation reported in the "Status" log message. - /// See [`EventHandler::poll`]. - db: DB, +struct NodeState { /// Information about connected peers. peers_info: Option>, /// The stage currently being executed. @@ -52,14 +47,12 @@ struct NodeState { finalized_block_hash: Option, } -impl NodeState { +impl NodeState { const fn new( - db: DB, peers_info: Option>, latest_block: Option, ) -> Self { Self { - db, peers_info, current_stage: None, latest_block, @@ -332,12 +325,6 @@ impl NodeState { } } -impl NodeState { - fn freelist(&self) -> Option { - self.db.metadata().freelist_size() - } -} - /// Helper type for formatting of optional fields: /// - If [Some(x)], then `x` is written /// - If [None], then `None` is written @@ -423,16 +410,14 @@ impl From for NodeEvent { /// Displays relevant information to the user from components of the node, and periodically /// displays the high-level status of the node. -pub async fn handle_events( +pub async fn handle_events( peers_info: Option>, latest_block_number: Option, events: E, - db: DB, ) where E: Stream + Unpin, - DB: DatabaseMetadata + Database + 'static, { - let state = NodeState::new(db, peers_info, latest_block_number); + let state = NodeState::new(peers_info, latest_block_number); let start = tokio::time::Instant::now() + Duration::from_secs(3); let mut info_interval = tokio::time::interval_at(start, INFO_MESSAGE_INTERVAL); @@ -444,18 +429,17 @@ pub async fn handle_events( /// Handles events emitted by the node and logs them accordingly. #[pin_project::pin_project] -struct EventHandler { - state: NodeState, +struct EventHandler { + state: NodeState, #[pin] events: E, #[pin] info_interval: Interval, } -impl Future for EventHandler +impl Future for EventHandler where E: Stream + Unpin, - DB: DatabaseMetadata + Database + 'static, { type Output = (); @@ -463,8 +447,6 @@ where let mut this = self.project(); while this.info_interval.poll_tick(cx).is_ready() { - let freelist = OptionalField(this.state.freelist()); - if let Some(CurrentStage { stage_id, eta, checkpoint, entities_checkpoint, target }) = &this.state.current_stage { @@ -477,7 +459,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, stage = %stage_id, checkpoint = checkpoint.block_number, target = %OptionalField(*target), @@ -490,7 +471,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, stage = %stage_id, checkpoint = checkpoint.block_number, target = %OptionalField(*target), @@ -502,7 +482,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, stage = %stage_id, checkpoint = checkpoint.block_number, target = %OptionalField(*target), @@ -514,7 +493,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, stage = %stage_id, checkpoint = checkpoint.block_number, target = %OptionalField(*target), @@ -531,7 +509,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, %latest_block, "Status" ); @@ -540,7 +517,6 @@ where info!( target: "reth::cli", connected_peers = this.state.num_connected_peers(), - %freelist, "Status" ); } diff --git a/crates/optimism/cli/src/commands/import.rs b/crates/optimism/cli/src/commands/import.rs index a1004f9c4e0d..d69c7fb455d2 100644 --- a/crates/optimism/cli/src/commands/import.rs +++ b/crates/optimism/cli/src/commands/import.rs @@ -103,12 +103,7 @@ impl ImportOpCommand { let latest_block_number = provider.get_stage_checkpoint(StageId::Finish)?.map(|ch| ch.block_number); - tokio::spawn(reth_node_events::node::handle_events( - None, - latest_block_number, - events, - provider_factory.db_ref().clone(), - )); + tokio::spawn(reth_node_events::node::handle_events(None, latest_block_number, events)); // Run pipeline info!(target: "reth::cli", "Starting sync pipeline");