Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove custom debugs #32

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
if lookup.elapsed_since_created() > Duration::from_secs(LOOKUP_MAX_DURATION_SECS) {
debug!(self.log, "Lookup maybe stuck";
// Fields id and block_root are also part of the summary. However, logging them
// here allows log parsers o index them and have better search
// here allows log parsers to index them and have better search
"id" => lookup.id,
"block_root" => ?lookup.block_root(),
"summary" => ?lookup,
Expand Down
52 changes: 8 additions & 44 deletions beacon_node/network/src/sync/block_lookups/single_block_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::sync::block_lookups::common::RequestState;
use crate::sync::block_lookups::Id;
use crate::sync::network_context::{LookupRequestResult, SyncNetworkContext};
use beacon_chain::BeaconChainTypes;
use derivative::Derivative;
use itertools::Itertools;
use rand::seq::IteratorRandom;
use std::collections::HashSet;
Expand Down Expand Up @@ -43,6 +44,8 @@ pub enum LookupRequestError {
UnknownLookup,
}

#[derive(Derivative)]
#[derivative(Debug(bound = "T: BeaconChainTypes"))]
pub struct SingleBlockLookup<T: BeaconChainTypes> {
pub id: Id,
pub block_request_state: BlockRequestState<T::EthSpec>,
Expand Down Expand Up @@ -270,15 +273,17 @@ impl<E: EthSpec> BlockRequestState<E> {
}
}

#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(PartialEq, Eq, Clone, Derivative)]
#[derivative(Debug)]
pub struct DownloadResult<T: Clone> {
#[derivative(Debug = "ignore")]
pub value: T,
pub block_root: Hash256,
pub seen_timestamp: Duration,
pub peer_id: PeerId,
}

#[derive(PartialEq, Eq, IntoStaticStr)]
#[derive(Debug, PartialEq, Eq, IntoStaticStr)]
pub enum State<T: Clone> {
AwaitingDownload,
Downloading,
Expand All @@ -292,7 +297,7 @@ pub enum State<T: Clone> {
}

/// Object representing the state of a single block or blob lookup request.
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Debug)]
pub struct SingleLookupRequestState<T: Clone> {
/// State of this request.
state: State<T>,
Expand Down Expand Up @@ -537,44 +542,3 @@ impl<T: Clone> std::fmt::Display for State<T> {
write!(f, "{}", Into::<&'static str>::into(self))
}
}

// Debug is used in the log_stuck_lookups print to include some more info. Implements custom Debug
// to not dump an entire block or blob to terminal which don't add valuable data.
impl<T: Clone> std::fmt::Debug for State<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::AwaitingDownload => write!(f, "AwaitingDownload"),
Self::Downloading => write!(f, "Downloading"),
Self::AwaitingProcess(d) => write!(f, "AwaitingProcess({:?})", d.peer_id),
Self::Processing(d) => write!(f, "Processing({:?})", d.peer_id),
Self::Processed(_) => write!(f, "Processed"),
}
}
}

// TODO: Manual implementation of Debug, otherwise T must be bounded by Debug
impl<T: BeaconChainTypes> std::fmt::Debug for SingleBlockLookup<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SingleBlockLookup")
.field("id", &self.id)
.field("block_root", &self.block_root)
.field("awaiting_parent", &self.awaiting_parent)
.field("created", &self.created)
.field("block_request_state", &self.block_request_state.state)
.field("blob_request_state", &self.blob_request_state.state)
// Log peers once for block and blob requests as are identical
.field("peers", &self.block_request_state.state.available_peers)
.finish()
}
}

impl<T: Clone> std::fmt::Debug for SingleLookupRequestState<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("State")
.field("state", &self.state)
.field("failed_downloading", &self.failed_downloading)
.field("failed_processing", &self.failed_processing)
// Do not log available peers here, do it once in SingleBlockLookup
.finish()
}
}
Loading