mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
@@ -249,6 +249,9 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
self.da_checker.clone(),
|
||||
cx,
|
||||
);
|
||||
|
||||
debug!(self.log, "Created new parent lookup"; "block_root" => ?block_root, "parent_root" => ?parent_root);
|
||||
|
||||
self.request_parent(parent_lookup, cx);
|
||||
}
|
||||
|
||||
@@ -575,7 +578,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
| ParentVerifyError::ExtraBlobsReturned
|
||||
| ParentVerifyError::InvalidIndex(_) => {
|
||||
let e = e.into();
|
||||
warn!(self.log, "Peer sent invalid response to parent request.";
|
||||
warn!(self.log, "Peer sent invalid response to parent request";
|
||||
"peer_id" => %peer_id, "reason" => %e);
|
||||
|
||||
// We do not tolerate these kinds of errors. We will accept a few but these are signs
|
||||
@@ -661,7 +664,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
.position(|req| req.check_peer_disconnected(peer_id).is_err())
|
||||
{
|
||||
let parent_lookup = self.parent_lookups.remove(pos);
|
||||
trace!(self.log, "Parent lookup's peer disconnected"; &parent_lookup);
|
||||
debug!(self.log, "Dropping parent lookup after peer disconnected"; &parent_lookup);
|
||||
self.request_parent(parent_lookup, cx);
|
||||
}
|
||||
}
|
||||
@@ -745,14 +748,19 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let Some(mut lookup) = self.single_block_lookups.remove(&target_id) else {
|
||||
debug!(self.log, "Unknown single block lookup"; "target_id" => target_id);
|
||||
return;
|
||||
};
|
||||
|
||||
let root = lookup.block_root();
|
||||
let request_state = R::request_state_mut(&mut lookup);
|
||||
|
||||
let Ok(peer_id) = request_state.get_state().processing_peer() else {
|
||||
return;
|
||||
let peer_id = match request_state.get_state().processing_peer() {
|
||||
Ok(peer_id) => peer_id,
|
||||
Err(e) => {
|
||||
debug!(self.log, "Attempting to process single block lookup in bad state"; "id" => target_id, "response_type" => ?R::response_type(), "error" => e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
debug!(
|
||||
self.log,
|
||||
|
||||
@@ -127,14 +127,14 @@ impl<T: BeaconChainTypes> ParentLookup<T> {
|
||||
.update_requested_parent_block(next_parent)
|
||||
}
|
||||
|
||||
pub fn block_processing_peer(&self) -> Result<PeerId, ()> {
|
||||
pub fn block_processing_peer(&self) -> Result<PeerId, String> {
|
||||
self.current_parent_request
|
||||
.block_request_state
|
||||
.state
|
||||
.processing_peer()
|
||||
}
|
||||
|
||||
pub fn blob_processing_peer(&self) -> Result<PeerId, ()> {
|
||||
pub fn blob_processing_peer(&self) -> Result<PeerId, String> {
|
||||
self.current_parent_request
|
||||
.blob_request_state
|
||||
.state
|
||||
|
||||
@@ -465,11 +465,10 @@ impl SingleLookupRequestState {
|
||||
|
||||
/// Returns the id peer we downloaded from if we have downloaded a verified block, otherwise
|
||||
/// returns an error.
|
||||
pub fn processing_peer(&self) -> Result<PeerId, ()> {
|
||||
if let State::Processing { peer_id } = &self.state {
|
||||
Ok(*peer_id)
|
||||
} else {
|
||||
Err(())
|
||||
pub fn processing_peer(&self) -> Result<PeerId, String> {
|
||||
match &self.state {
|
||||
State::Processing { peer_id } => Ok(*peer_id),
|
||||
other => Err(format!("not in processing state: {}", other).to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -525,6 +524,16 @@ impl slog::Value for SingleLookupRequestState {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for State {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
State::AwaitingDownload => write!(f, "AwaitingDownload"),
|
||||
State::Downloading { .. } => write!(f, "Downloading"),
|
||||
State::Processing { .. } => write!(f, "Processing"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user