lighthouse/beacon_node
João Oliveira 0dc95a1d37 PeerManager: move the check for banned peers from connection_established (#4569)
## Issue Addressed
https://github.com/sigp/lighthouse/issues/4543
## Proposed Changes
- Removes `NotBanned` from `BanResult`, implements `Display` and `std::error::Error` for `BanResult` and changes `ban_result` return type to `Option<BanResult>` which helps returning `BanResult` on `handle_established_inbound_connection`  
- moves the check from for banned peers from `on_connection_established` to `handle_established_inbound_connection` to start addressing #4543.
- Removes `allow_block_list` as it's now redundant? Not sure about this one but if `PeerManager` keeps track of the banned peers, no need to send a `Swarm` event for `alow_block_list` to also keep that list right? 
 
## Questions

-  #4543 refers:
>  More specifically, implement the connection limit behaviour inside the peer manager.

@AgeManning do you mean copying `libp2p::connection_limits::Behaviour`'s code into `PeerManager`/ having it as an inner `NetworkBehaviour` of `PeerManager`/other? If it's the first two, I think it probably makes more sense to have it as it is as it's less code to maintain.

> Also implement the banning of peers inside the behaviour, rather than passing messages back up to the swarm.

I tried to achieve this, but we still need to pass the `PeerManagerEvent::Banned` swarm event as `DiscV5` handles it's node and ip management internally and I did not find a method to query if a peer is banned. Is there anything else we can do from here?

3397612160/beacon_node/lighthouse_network/src/discovery/mod.rs (L931-L940)

Same as the question above, I did not find a way to check if `DiscV5` has the peer banned, so that we could check here and avoid sending `Swarm` events

3397612160/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs (L168-L178)

Is there a chance we try to dial a peer that has been banned previously? 

Thanks!
2023-10-03 23:59:32 +00:00
..
beacon_chain Use only lighthouse types in the mock builder (#4793) 2023-10-03 17:59:28 +00:00
beacon_processor Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
builder_client Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
client Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
eth1 Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
execution_layer Use only lighthouse types in the mock builder (#4793) 2023-10-03 17:59:28 +00:00
genesis Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
http_api Use only lighthouse types in the mock builder (#4793) 2023-10-03 17:59:28 +00:00
http_metrics Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
lighthouse_network PeerManager: move the check for banned peers from connection_established (#4569) 2023-10-03 23:59:32 +00:00
network Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
operation_pool Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
src Fix cli options (#4772) 2023-09-22 12:00:51 +00:00
store Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
tests Appease Clippy 1.68 and refactor http_api (#4068) 2023-03-13 01:40:03 +00:00
timer Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
Cargo.toml Release v4.5.0 (#4768) 2023-09-25 05:14:01 +00:00