Conversation
bddd5f5 to
e04e07a
Compare
01ebfd7 to
d0970c4
Compare
d0970c4 to
80d0178
Compare
| self.outbound_ping_peers.insert(peer_id); | ||
| self.events.push(PeerManagerEvent::Ping(peer_id)); |
There was a problem hiding this comment.
@AgeManning do you know why we need this? I thought it was handled by libp2p's Ping.
There was a problem hiding this comment.
We don't use libp2p ping instead we made our own in our RPC.
For anchor we can remove this, i think.
| // Updates peer's scores and unban any peers if required. | ||
| //let actions = self.peers.write().update_scores(); | ||
| //for (peer_id, action) in actions { | ||
| // self.handle_score_action(&peer_id, action, None); | ||
| //} | ||
|
|
||
| // Update peer score metrics; | ||
| //self.update_peer_score_metrics(); | ||
|
|
||
| // Prune any excess peers back to our target in such a way that incentivises good scores and | ||
| // a uniform distribution of subnets. | ||
| //self.prune_excess_peers(); | ||
|
|
||
| // Unban any peers that have served their temporary ban timeout | ||
| //self.unban_temporary_banned_peers(); |
There was a problem hiding this comment.
What's the plan for the commented calls here?
There was a problem hiding this comment.
We'll need it eventually, but it's not important for now. The plan is to reuse the LH code anyway.
| /// The current syncing state of the peer. The state may be determined after it's initial | ||
| /// connection. | ||
| sync_status: SyncStatus, |
There was a problem hiding this comment.
SSV has no sync status communicated via network, right?
There was a problem hiding this comment.
I don't know, we need input here. But I'd say it's not important for now.
There was a problem hiding this comment.
Yeah, Anchor doesn't sync anything. So can prob remove
|
We connect at the libp2p level but never perform a handshake with the remote peer, so both sides promptly disconnect. I think we can merge this PR as it is and address this next. It's tracked here #116. @dknopik @jking-aus thoughts? |
e0979af to
26638bd
Compare
AgeManning
left a comment
There was a problem hiding this comment.
I didn't really review this. Looks like most of the stuff we have in Lighthouse.
I think its a good place to start so we can get it up and running then fine-tune, remove parts and maybe modularize lighthouse in the future to not require all the code.
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug, Serialize, PartialEq, AsRefStr, IntoStaticStr, EnumIter)] | ||
| pub enum ClientKind { |
There was a problem hiding this comment.
We probably should change this just to have Anchor and SSV.
I think they are using libp2p identify, so once we figure out their agent string, we can identify them here.
|
|
||
| // helper function to identify clients from their agent_version. Returns the client | ||
| // kind and it's associated version and the OS kind. | ||
| fn client_from_agent_version(agent_version: &str) -> (ClientKind, String, String) { |
| use PeerConnectionStatus::*; | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Serialize)] | ||
| pub struct MetaData { |
There was a problem hiding this comment.
I think this might be their NodeInfo thingy
|
|
||
| #[derive(Clone, Debug, Serialize)] | ||
| /// The current sync status of the peer. | ||
| pub enum SyncStatus { |
There was a problem hiding this comment.
Most of the stuff in this file we can remove, but fine to keep for now
|
Closing this, as #126 is now merged. Still, we should keep this one in mind for possible future extensions of the peer manager. |
Issue Addressed
Related to #18
Proposed Changes
Dependencies:
Updated Cargo.toml and anchor/network/Cargo.toml to include new dependencies such as smallvec, arbitrary, delay_map, and itertools.
Network Types:
Added peer_manager module to anchor/network/src/lib.rs.
Network Implementation:
Enhanced anchor/network/src/behaviour.rs and anchor/network/src/network.rs to integrate the PeerManager.
The PeerManager is responsible for managing peer connections, including dialing, connecting, and disconnecting peers.
It includes logic to maintain the target peer count, ensuring the network has the desired number of peers connected.
Peer Manager:
Added a new peer_manager directory with modules for managing peers.
Implemented functionality in PeerManager to handle peer connections, maintain the target peer count, and manage peer discovery.
Additional Info
For now, it's mostly a copy from LH with a few modifications. However, there are efforts to make the LH code more modular, generic, and thus easier to reuse. See sigp/lighthouse#6840 and sigp/lighthouse#6757