From cefd8a7a3fb3776455d507c8e16e497321d75316 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 12 Jun 2024 01:46:17 +0100 Subject: [PATCH] fix previous merge --- p2p/cuprate-p2p/src/block_downloader.rs | 7 ++++++- p2p/cuprate-p2p/src/lib.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/p2p/cuprate-p2p/src/block_downloader.rs b/p2p/cuprate-p2p/src/block_downloader.rs index f610de7a..c6c66463 100644 --- a/p2p/cuprate-p2p/src/block_downloader.rs +++ b/p2p/cuprate-p2p/src/block_downloader.rs @@ -626,7 +626,7 @@ where // block downloader. self.inflight_requests.get(&start_height).inspect(|entry| { tracing::warn!( - "Received an invalid chain from peer: {}, exiting block downloader (it will be restarted).", + "Received an invalid chain from peer: {}, exiting block downloader (it should be restarted).", entry.peer_who_told_us ); entry.peer_who_told_us_handle.ban_peer(LONG_BAN) @@ -867,6 +867,11 @@ async fn request_batch_from_peer( .number() .is_some_and(|height| height == expected_height) { + tracing::warn!( + "Invalid chain, expected height: {expected_height}, got height: {:?}", + block.number() + ); + // This peer probably did nothing wrong, it was the peer who told us this blockID which // is misbehaving. return Err(BlockDownloadError::ChainInvalid); diff --git a/p2p/cuprate-p2p/src/lib.rs b/p2p/cuprate-p2p/src/lib.rs index 634a040e..f15574ef 100644 --- a/p2p/cuprate-p2p/src/lib.rs +++ b/p2p/cuprate-p2p/src/lib.rs @@ -30,9 +30,7 @@ mod constants; mod inbound_server; mod sync_states; -use crate::block_downloader::{ - BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse, -}; +use block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse}; pub use broadcast::{BroadcastRequest, BroadcastSvc}; use client_pool::ClientPoolDropGuard; pub use config::P2PConfig; @@ -41,11 +39,13 @@ use monero_p2p::services::PeerSyncRequest; /// Initializes the P2P [`NetworkInterface`] for a specific [`NetworkZone`]. /// -/// This function starts all the tasks to maintain connections/ accept connections/ make connections. +/// This function starts all the tasks to maintain/accept/make connections. /// -/// To use you must provide, a peer request handler, which is given to each connection and a core sync service -/// which keeps track of the sync state of our node. -#[instrument(level="debug", name="net", skip_all, fields(zone=N::NAME))] +/// # Usage +/// You must provide: +/// - A peer request handler, which is given to each connection +/// - A core sync service, which keeps track of the sync state of our node +#[instrument(level = "debug", name = "net", skip_all, fields(zone = N::NAME))] pub async fn initialize_network( peer_req_handler: R, core_sync_svc: CS,