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:
Pawan Dhananjay
2024-06-26 16:53:53 -07:00
committed by GitHub
parent 758b58c9e9
commit bf4cbd3b0a
12 changed files with 270 additions and 182 deletions

View File

@@ -1,5 +1,8 @@
use beacon_chain::get_block_root;
use lighthouse_network::rpc::{methods::BlobsByRootRequest, BlocksByRootRequest};
use lighthouse_network::{
rpc::{methods::BlobsByRootRequest, BlocksByRootRequest},
PeerId,
};
use std::sync::Arc;
use strum::IntoStaticStr;
use types::{
@@ -20,13 +23,15 @@ pub enum LookupVerifyError {
pub struct ActiveBlocksByRootRequest {
request: BlocksByRootSingleRequest,
resolved: bool,
pub(crate) peer_id: PeerId,
}
impl ActiveBlocksByRootRequest {
pub fn new(request: BlocksByRootSingleRequest) -> Self {
pub fn new(request: BlocksByRootSingleRequest, peer_id: PeerId) -> Self {
Self {
request,
resolved: false,
peer_id,
}
}
@@ -94,14 +99,16 @@ pub struct ActiveBlobsByRootRequest<E: EthSpec> {
request: BlobsByRootSingleBlockRequest,
blobs: Vec<Arc<BlobSidecar<E>>>,
resolved: bool,
pub(crate) peer_id: PeerId,
}
impl<E: EthSpec> ActiveBlobsByRootRequest<E> {
pub fn new(request: BlobsByRootSingleBlockRequest) -> Self {
pub fn new(request: BlobsByRootSingleBlockRequest, peer_id: PeerId) -> Self {
Self {
request,
blobs: vec![],
resolved: false,
peer_id,
}
}