chore(tree, engine, prune, stages, storage): improve logs (#4790)

This commit is contained in:
Alexey Shekhirin
2023-09-26 18:01:37 +01:00
committed by GitHub
parent d0ef5af580
commit 5e01a21ec4
13 changed files with 148 additions and 36 deletions

View File

@ -10,6 +10,7 @@ use reth_primitives::{
stage::{EntitiesCheckpoint, StageCheckpoint, StageId},
BlockNumber,
};
use reth_prune::PrunerEvent;
use reth_stages::{ExecOutput, PipelineEvent};
use std::{
future::Future,
@ -127,6 +128,9 @@ impl NodeState {
info!(number=block.number, hash=?block.hash, "Block added to canonical chain");
}
BeaconConsensusEngineEvent::CanonicalChainCommitted(head, elapsed) => {
info!(number=head.number, hash=?head.hash, ?elapsed, "Canonical chain committed");
}
BeaconConsensusEngineEvent::ForkBlockAdded(block) => {
info!(number=block.number, hash=?block.hash, "Block added to fork chain");
}
@ -149,6 +153,20 @@ impl NodeState {
}
}
}
fn handle_pruner_event(&self, event: PrunerEvent) {
match event {
PrunerEvent::Finished { tip_block_number, elapsed, done, parts_done } => {
info!(
tip_block_number = tip_block_number,
elapsed = ?elapsed,
done = done,
parts_done = ?parts_done,
"Pruner finished"
);
}
}
}
}
/// A node event.
@ -162,6 +180,8 @@ pub enum NodeEvent {
ConsensusEngine(BeaconConsensusEngineEvent),
/// A Consensus Layer health event.
ConsensusLayerHealth(ConsensusLayerHealthEvent),
/// A pruner event
Pruner(PrunerEvent),
}
impl From<NetworkEvent> for NodeEvent {
@ -188,6 +208,12 @@ impl From<ConsensusLayerHealthEvent> for NodeEvent {
}
}
impl From<PrunerEvent> for NodeEvent {
fn from(event: PrunerEvent) -> Self {
NodeEvent::Pruner(event)
}
}
/// 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<E>(
@ -260,6 +286,9 @@ where
NodeEvent::ConsensusLayerHealth(event) => {
this.state.handle_consensus_layer_health_event(event)
}
NodeEvent::Pruner(event) => {
this.state.handle_pruner_event(event);
}
}
}

View File

@ -452,17 +452,21 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
let mut hooks = EngineHooks::new();
if let Some(prune_config) = prune_config {
let pruner_events = if let Some(prune_config) = prune_config {
info!(target: "reth::cli", ?prune_config, "Pruner initialized");
let pruner = reth_prune::Pruner::new(
let mut pruner = reth_prune::Pruner::new(
db.clone(),
self.chain.clone(),
prune_config.block_interval,
prune_config.parts,
self.chain.prune_batch_sizes,
);
let events = pruner.events();
hooks.add(PruneHook::new(pruner, Box::new(ctx.task_executor.clone())));
}
Either::Left(events)
} else {
Either::Right(stream::empty())
};
// Configure the consensus engine
let (beacon_consensus_engine, beacon_engine_handle) = BeaconConsensusEngine::with_channel(
@ -493,7 +497,8 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
)
} else {
Either::Right(stream::empty())
}
},
pruner_events.map(Into::into)
);
ctx.task_executor.spawn_critical(
"events task",