mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
improve peer scoring during certain failures in parent lookups
This commit is contained in:
@@ -1292,7 +1292,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let response = parent_lookup.request_parent_block(cx);
|
||||
self.handle_response(parent_lookup, cx, response);
|
||||
self.handle_response(parent_lookup, cx, response, ResponseType::Block);
|
||||
}
|
||||
|
||||
fn request_parent_blob(
|
||||
@@ -1301,7 +1301,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let response = parent_lookup.request_parent_blobs(cx);
|
||||
self.handle_response(parent_lookup, cx, response);
|
||||
self.handle_response(parent_lookup, cx, response, ResponseType::Blob);
|
||||
}
|
||||
|
||||
fn request_parent_block_and_blobs(
|
||||
@@ -1309,18 +1309,24 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
mut parent_lookup: ParentLookup<T>,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let response = parent_lookup
|
||||
.request_parent_block(cx)
|
||||
.and_then(|_| parent_lookup.request_parent_blobs(cx));
|
||||
self.handle_response(parent_lookup, cx, response);
|
||||
let block_res = parent_lookup.request_parent_block(cx);
|
||||
match block_res {
|
||||
Ok(()) => {
|
||||
let blob_res = parent_lookup.request_parent_blobs(cx);
|
||||
self.handle_response(parent_lookup, cx, blob_res, ResponseType::Blob)
|
||||
}
|
||||
Err(e) => {
|
||||
self.handle_response(parent_lookup, cx, Err(e), ResponseType::Block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(sean) how should peer scoring work with failures in this method?
|
||||
fn handle_response(
|
||||
&mut self,
|
||||
mut parent_lookup: ParentLookup<T>,
|
||||
parent_lookup: ParentLookup<T>,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
result: Result<(), parent_lookup::RequestError>,
|
||||
response_type: ResponseType,
|
||||
) {
|
||||
match result {
|
||||
Err(e) => {
|
||||
@@ -1332,7 +1338,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
parent_lookup::RequestError::ChainTooLong => {
|
||||
self.failed_chains.insert(parent_lookup.chain_hash());
|
||||
// This indicates faulty peers.
|
||||
for &peer_id in parent_lookup.used_block_peers() {
|
||||
for &peer_id in parent_lookup.used_peers(response_type) {
|
||||
cx.report_peer(peer_id, PeerAction::LowToleranceError, e.as_static())
|
||||
}
|
||||
}
|
||||
@@ -1345,7 +1351,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
self.failed_chains.insert(parent_lookup.chain_hash());
|
||||
}
|
||||
// This indicates faulty peers.
|
||||
for &peer_id in parent_lookup.used_block_peers() {
|
||||
for &peer_id in parent_lookup.used_peers(response_type) {
|
||||
cx.report_peer(peer_id, PeerAction::LowToleranceError, e.as_static())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::single_block_lookup::{LookupRequestError, LookupVerifyError, SingleBlockLookup};
|
||||
use super::{DownloadedBlocks, PeerShouldHave};
|
||||
use super::{DownloadedBlocks, PeerShouldHave, ResponseType};
|
||||
use crate::sync::block_lookups::{single_block_lookup, RootBlockTuple};
|
||||
use crate::sync::{
|
||||
manager::{Id, SLOT_IMPORT_TOLERANCE},
|
||||
@@ -358,12 +358,19 @@ impl<T: BeaconChainTypes> ParentLookup<T> {
|
||||
.add_peer_if_useful(block_root, peer_id, peer_usefulness)
|
||||
}
|
||||
|
||||
//TODO(sean) fix this up
|
||||
pub fn used_block_peers(&self) -> impl Iterator<Item = &PeerId> + '_ {
|
||||
self.current_parent_request
|
||||
.block_request_state
|
||||
.used_peers
|
||||
.iter()
|
||||
pub fn used_peers(&self, response_type: ResponseType) -> impl Iterator<Item = &PeerId> + '_ {
|
||||
match response_type {
|
||||
ResponseType::Block => self
|
||||
.current_parent_request
|
||||
.block_request_state
|
||||
.used_peers
|
||||
.iter(),
|
||||
ResponseType::Blob => self
|
||||
.current_parent_request
|
||||
.blob_request_state
|
||||
.used_peers
|
||||
.iter(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user