Skip to content

Commit

Permalink
feat: update sync state based on chain event (#9695)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored and pull[bot] committed Oct 17, 2024
1 parent c731dbd commit 1985833
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions crates/ethereum/node/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use reth_beacon_consensus::{
use reth_ethereum_engine::service::{ChainEvent, EthService};
use reth_ethereum_engine_primitives::EthEngineTypes;
use reth_exex::ExExManagerHandle;
use reth_network::NetworkEvents;
use reth_network::{NetworkEvents, NetworkSyncUpdater, SyncState};
use reth_node_api::{FullNodeTypes, NodeAddOns};
use reth_node_builder::{
hooks::NodeHooks,
Expand Down Expand Up @@ -233,6 +233,7 @@ where
.await?;

// Run consensus engine to completion
let network_handle = ctx.components().network().clone();
let (tx, rx) = oneshot::channel();
info!(target: "reth::cli", "Starting consensus engine");
ctx.task_executor().spawn_critical_blocking("consensus engine", async move {
Expand All @@ -245,7 +246,12 @@ where
while let Some(event) = eth_service.next().await {
debug!(target: "reth::cli", "Event: {event:?}");
match event {
ChainEvent::BackfillSyncFinished | ChainEvent::BackfillSyncStarted => {}
ChainEvent::BackfillSyncFinished => {
network_handle.update_sync_state(SyncState::Idle);
}
ChainEvent::BackfillSyncStarted => {
network_handle.update_sync_state(SyncState::Syncing);
}
ChainEvent::FatalError => break,
ChainEvent::Handler(ev) => {
event_sender.notify(ev);
Expand Down
4 changes: 2 additions & 2 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ pub use session::{
SessionManager,
};

pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};

pub use flattened_response::FlattenedResponse;
pub use manager::DiscoveredEvent;
pub use metrics::TxTypesCounter;
pub use reth_eth_wire::{DisconnectReason, HelloMessageWithProtocols};
pub use reth_network_p2p::sync::{NetworkSyncUpdater, SyncState};
pub use reth_network_types::{PeersConfig, SessionsConfig};
pub use session::EthRlpxConnection;
pub use swarm::NetworkConnectionState;
pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};

0 comments on commit 1985833

Please sign in to comment.