mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
Address review comments
This commit is contained in:
@@ -1225,10 +1225,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
// custody_by_range accumulates the results of multiple data_columns_by_range requests
|
// custody_by_range accumulates the results of multiple data_columns_by_range requests
|
||||||
// returning a bigger list of data columns across all the column indices this node has
|
// returning a bigger list of data columns across all the column indices this node has
|
||||||
// to custody
|
// to custody
|
||||||
if let Some(result) =
|
if let Some(result) = self.network.on_custody_by_range_response(id, peer_id, resp) {
|
||||||
self.network
|
|
||||||
.on_custody_by_range_response(id.parent_request_id, id, peer_id, resp)
|
|
||||||
{
|
|
||||||
self.on_custody_by_range_result(id.parent_request_id, result);
|
self.on_custody_by_range_result(id.parent_request_id, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1376,14 +1376,13 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn on_custody_by_range_response(
|
pub fn on_custody_by_range_response(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: CustodyByRangeRequestId,
|
|
||||||
req_id: DataColumnsByRangeRequestId,
|
req_id: DataColumnsByRangeRequestId,
|
||||||
peer_id: PeerId,
|
peer_id: PeerId,
|
||||||
resp: RpcResponseResult<DataColumnSidecarList<T::EthSpec>>,
|
resp: RpcResponseResult<DataColumnSidecarList<T::EthSpec>>,
|
||||||
) -> Option<CustodyRequestResult<T::EthSpec>> {
|
) -> Option<CustodyRequestResult<T::EthSpec>> {
|
||||||
// Note: need to remove the request to borrow self again below. Otherwise we can't
|
// Note: need to remove the request to borrow self again below. Otherwise we can't
|
||||||
// do nested requests
|
// do nested requests
|
||||||
let Some(mut request) = self.custody_by_range_requests.remove(&id) else {
|
let Some(mut request) = self.custody_by_range_requests.remove(&id.parent_request_id) else {
|
||||||
metrics::inc_counter_vec(
|
metrics::inc_counter_vec(
|
||||||
&metrics::SYNC_UNKNOWN_NETWORK_REQUESTS,
|
&metrics::SYNC_UNKNOWN_NETWORK_REQUESTS,
|
||||||
&["custody_by_range"],
|
&["custody_by_range"],
|
||||||
@@ -1396,7 +1395,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
.map_err(Into::<RpcResponseError>::into)
|
.map_err(Into::<RpcResponseError>::into)
|
||||||
.transpose();
|
.transpose();
|
||||||
|
|
||||||
self.handle_custody_by_range_result(id, request, result)
|
self.handle_custody_by_range_result(id.parent_request_id, request, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_custody_by_range_result(
|
fn handle_custody_by_range_result(
|
||||||
|
|||||||
@@ -368,16 +368,19 @@ impl TestRig {
|
|||||||
self.expect_empty_network();
|
self.expect_empty_network();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't make pub, use `add_connected_peer_testing_only`
|
// Note: prefer to use `add_connected_peer_testing_only`. This is currently extensively used in
|
||||||
|
// lookup tests. We should consolidate this "add peer" methods in a future refactor
|
||||||
fn new_connected_peer(&mut self) -> PeerId {
|
fn new_connected_peer(&mut self) -> PeerId {
|
||||||
self.add_connected_peer_testing_only(false)
|
self.add_connected_peer_testing_only(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't make pub, use `add_connected_peer_testing_only`
|
// Note: prefer to use `add_connected_peer_testing_only`. This is currently extensively used in
|
||||||
|
// lookup tests. We should consolidate this "add peer" methods in a future refactor
|
||||||
fn new_connected_supernode_peer(&mut self) -> PeerId {
|
fn new_connected_supernode_peer(&mut self) -> PeerId {
|
||||||
self.add_connected_peer_testing_only(true)
|
self.add_connected_peer_testing_only(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a random connected peer that is not known by the sync module
|
||||||
pub fn add_connected_peer_testing_only(&mut self, supernode: bool) -> PeerId {
|
pub fn add_connected_peer_testing_only(&mut self, supernode: bool) -> PeerId {
|
||||||
let key = self.determinstic_key();
|
let key = self.determinstic_key();
|
||||||
let peer_id = self
|
let peer_id = self
|
||||||
@@ -401,6 +404,7 @@ impl TestRig {
|
|||||||
peer_id
|
peer_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a random connected peer + add it to sync with a specific remote Status
|
||||||
pub fn add_sync_peer(&mut self, supernode: bool, remote_info: SyncInfo) -> PeerId {
|
pub fn add_sync_peer(&mut self, supernode: bool, remote_info: SyncInfo) -> PeerId {
|
||||||
let peer_id = self.add_connected_peer_testing_only(supernode);
|
let peer_id = self.add_connected_peer_testing_only(supernode);
|
||||||
self.send_sync_message(SyncMessage::AddPeer(peer_id, remote_info));
|
self.send_sync_message(SyncMessage::AddPeer(peer_id, remote_info));
|
||||||
@@ -887,7 +891,7 @@ impl TestRig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find, not pop
|
/// Similar to `pop_received_network_events` but finds matching events without removing them.
|
||||||
pub fn filter_received_network_events<T, F: Fn(&NetworkMessage<E>) -> Option<T>>(
|
pub fn filter_received_network_events<T, F: Fn(&NetworkMessage<E>) -> Option<T>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
predicate_transform: F,
|
predicate_transform: F,
|
||||||
@@ -1149,15 +1153,10 @@ impl TestRig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_no_penalty_for_anyone(&mut self) {
|
pub fn expect_no_penalty_for_anyone(&mut self) {
|
||||||
self.drain_network_rx();
|
let downscore_events = self.filter_received_network_events(|ev| match ev {
|
||||||
let downscore_events = self
|
NetworkMessage::ReportPeer { peer_id, msg, .. } => Some((peer_id, msg)),
|
||||||
.network_rx_queue
|
_ => None,
|
||||||
.iter()
|
});
|
||||||
.filter_map(|ev| match ev {
|
|
||||||
NetworkMessage::ReportPeer { peer_id, msg, .. } => Some((peer_id, msg)),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if !downscore_events.is_empty() {
|
if !downscore_events.is_empty() {
|
||||||
panic!("Expected no downscoring events but found: {downscore_events:?}");
|
panic!("Expected no downscoring events but found: {downscore_events:?}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ enum ByRangeDataRequestIds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ByRangeDataRequestIds {
|
impl ByRangeDataRequestIds {
|
||||||
|
/// If there's a single active request, returns its peer, else panics
|
||||||
fn peer(&self) -> PeerId {
|
fn peer(&self) -> PeerId {
|
||||||
match self {
|
match self {
|
||||||
Self::PreDeneb => panic!("no requests PreDeneb"),
|
Self::PreDeneb => panic!("no requests PreDeneb"),
|
||||||
|
|||||||
Reference in New Issue
Block a user