mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
feat(bin): log forkchoice status on FCU (#3067)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use crate::node::cl_events::ConsensusLayerHealthEvent;
|
||||
use futures::Stream;
|
||||
use reth_beacon_consensus::BeaconConsensusEngineEvent;
|
||||
use reth_interfaces::consensus::ForkchoiceState;
|
||||
use reth_network::{NetworkEvent, NetworkHandle};
|
||||
use reth_network_api::PeersInfo;
|
||||
use reth_primitives::{
|
||||
@@ -112,8 +113,17 @@ impl NodeState {
|
||||
|
||||
fn handle_consensus_engine_event(&mut self, event: BeaconConsensusEngineEvent) {
|
||||
match event {
|
||||
BeaconConsensusEngineEvent::ForkchoiceUpdated(state) => {
|
||||
info!(target: "reth::cli", ?state, "Forkchoice updated");
|
||||
BeaconConsensusEngineEvent::ForkchoiceUpdated(state, status) => {
|
||||
let ForkchoiceState { head_block_hash, safe_block_hash, finalized_block_hash } =
|
||||
state;
|
||||
info!(
|
||||
target: "reth::cli",
|
||||
?head_block_hash,
|
||||
?safe_block_hash,
|
||||
?finalized_block_hash,
|
||||
?status,
|
||||
"Forkchoice updated"
|
||||
);
|
||||
}
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block) => {
|
||||
self.latest_canonical_engine_block = Some(block.number);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::engine::forkchoice::ForkchoiceStatus;
|
||||
use reth_interfaces::consensus::ForkchoiceState;
|
||||
use reth_primitives::SealedBlock;
|
||||
use std::sync::Arc;
|
||||
@@ -6,7 +7,7 @@ use std::sync::Arc;
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BeaconConsensusEngineEvent {
|
||||
/// The fork choice state was updated.
|
||||
ForkchoiceUpdated(ForkchoiceState),
|
||||
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
|
||||
/// A block was added to the canonical chain.
|
||||
CanonicalBlockAdded(Arc<SealedBlock>),
|
||||
/// A block was added to the fork chain.
|
||||
|
||||
@@ -81,7 +81,7 @@ pub(crate) struct ReceivedForkchoiceState {
|
||||
|
||||
/// A simplified representation of [PayloadStatusEnum] specifically for FCU.
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum ForkchoiceStatus {
|
||||
pub enum ForkchoiceStatus {
|
||||
/// The forkchoice state is valid.
|
||||
Valid,
|
||||
/// The forkchoice state is invalid.
|
||||
|
||||
@@ -475,14 +475,16 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
let status = on_updated.forkchoice_status();
|
||||
|
||||
// update the forkchoice state tracker
|
||||
self.forkchoice_state_tracker.set_latest(state, on_updated.forkchoice_status());
|
||||
self.forkchoice_state_tracker.set_latest(state, status);
|
||||
|
||||
let is_valid_response = on_updated.is_valid_update();
|
||||
let _ = tx.send(Ok(on_updated));
|
||||
|
||||
// notify listeners about new processed FCU
|
||||
self.listeners.notify(BeaconConsensusEngineEvent::ForkchoiceUpdated(state));
|
||||
self.listeners.notify(BeaconConsensusEngineEvent::ForkchoiceUpdated(state, status));
|
||||
|
||||
// Terminate the sync early if it's reached the maximum user
|
||||
// configured block.
|
||||
|
||||
Reference in New Issue
Block a user