mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-12 02:14:10 +00:00
Remove all batches related to a peer on disconnect (#5969)
* Remove all batches related to a peer on disconnect * Cleanup map entries after disconnect * Allow lookups to continue in case of disconnections * Pretty response types * fmt * Fix lints * Remove lookup if it cannot progress * Fix tests * Remove poll_close on rpc behaviour * Remove redundant test * Fix issue raised by lion * Revert pretty response types * Cleanup * Fix test * Merge remote-tracking branch 'origin/release-v5.2.1' into rpc-error-on-disconnect-revert * Apply suggestions from joao Co-authored-by: João Oliveira <hello@jxs.pt> * Fix log * update request status on no peers found * Do not remove lookup after peer disconnection * Add comments about expected event api * Update single_block_lookup.rs * Update mod.rs * Merge branch 'rpc-error-on-disconnect-revert' into 5969-review * Merge pull request #10 from dapplion/5969-review Add comments about expected event api
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use lighthouse_network::PeerId;
|
||||
use ssz_types::VariableList;
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
use types::{BlobSidecar, EthSpec, SignedBeaconBlock};
|
||||
@@ -17,16 +18,19 @@ pub struct BlocksAndBlobsRequestInfo<E: EthSpec> {
|
||||
is_sidecars_stream_terminated: bool,
|
||||
/// Used to determine if this accumulator should wait for a sidecars stream termination
|
||||
request_type: ByRangeRequestType,
|
||||
/// The peer the request was made to.
|
||||
pub(crate) peer_id: PeerId,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> BlocksAndBlobsRequestInfo<E> {
|
||||
pub fn new(request_type: ByRangeRequestType) -> Self {
|
||||
pub fn new(request_type: ByRangeRequestType, peer_id: PeerId) -> Self {
|
||||
Self {
|
||||
accumulated_blocks: <_>::default(),
|
||||
accumulated_sidecars: <_>::default(),
|
||||
is_blocks_stream_terminated: <_>::default(),
|
||||
is_sidecars_stream_terminated: <_>::default(),
|
||||
request_type,
|
||||
peer_id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +113,14 @@ mod tests {
|
||||
use super::BlocksAndBlobsRequestInfo;
|
||||
use crate::sync::range_sync::ByRangeRequestType;
|
||||
use beacon_chain::test_utils::{generate_rand_block_and_blobs, NumBlobs};
|
||||
use lighthouse_network::PeerId;
|
||||
use rand::SeedableRng;
|
||||
use types::{test_utils::XorShiftRng, ForkName, MinimalEthSpec as E};
|
||||
|
||||
#[test]
|
||||
fn no_blobs_into_responses() {
|
||||
let mut info = BlocksAndBlobsRequestInfo::<E>::new(ByRangeRequestType::Blocks);
|
||||
let peer_id = PeerId::random();
|
||||
let mut info = BlocksAndBlobsRequestInfo::<E>::new(ByRangeRequestType::Blocks, peer_id);
|
||||
let mut rng = XorShiftRng::from_seed([42; 16]);
|
||||
let blocks = (0..4)
|
||||
.map(|_| generate_rand_block_and_blobs::<E>(ForkName::Base, NumBlobs::None, &mut rng).0)
|
||||
@@ -133,7 +139,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn empty_blobs_into_responses() {
|
||||
let mut info = BlocksAndBlobsRequestInfo::<E>::new(ByRangeRequestType::BlocksAndBlobs);
|
||||
let peer_id = PeerId::random();
|
||||
let mut info =
|
||||
BlocksAndBlobsRequestInfo::<E>::new(ByRangeRequestType::BlocksAndBlobs, peer_id);
|
||||
let mut rng = XorShiftRng::from_seed([42; 16]);
|
||||
let blocks = (0..4)
|
||||
.map(|_| {
|
||||
|
||||
Reference in New Issue
Block a user