-
Notifications
You must be signed in to change notification settings - Fork 23
feat(peer_manager): integrate peer blocking functionality into modular peer manager #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit fully integrates the peer blocking features from the block-peers branch into the new modular peer manager architecture. Key changes: Blocking Infrastructure: - Add BlockingManager wrapping libp2p-allow-block-list for connection denial - Integrate blocking checks into all connection handlers (pending/established) - Add automatic peer unblocking after RETAIN_SCORE_EPOCH_MULTIPLIER duration Score-Based Blocking: - Implement check_and_block_peers_by_score() to automatically block peers with gossipsub scores below GRAYLIST_THRESHOLD - Integrate peer score checking into heartbeat system for periodic execution - Automatically disconnect blocked peers immediately Connection Prevention: - Update should_dial_peer() to check blocked peers before dialing - Filter blocked peers in discovery and subnet peer selection - Ensure all connection paths respect the blocked peer list Event System Updates: - Replace ConnectActions events with PeerManagerHeartbeat events - Consolidate peer management actions and score checking into single heartbeat - Update Network to handle new event structure with integrated score checking API Cleanup: - Remove unused manual blocking API methods (block_peer, unblock_peer) - Keep essential methods for score-based blocking and status queries - Maintain clean separation between manual and automatic blocking The implementation ensures that peers with poor gossipsub scores are automatically blocked and prevented from connecting, while maintaining the modular architecture and ensuring no behavioral changes from the original peer manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates peer blocking functionality into the modular peer manager architecture, implementing automatic blocking of peers with poor gossipsub scores. The changes consolidate peer management actions and score checking into a unified heartbeat system while maintaining the modular design.
Key changes:
- Introduces
BlockingManager
for centralized peer blocking with automatic expiration - Replaces
ConnectActions
events with consolidatedPeerManagerHeartbeat
events that include both connection actions and score checking signals - Integrates blocking checks into all connection handlers and peer discovery logic
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
anchor/network/src/peer_manager/types.rs | Adds HeartbeatEvent struct and updates Event enum to use PeerManagerHeartbeat |
anchor/network/src/peer_manager/mod.rs | Integrates BlockingManager into PeerManager with blocking checks in connection handlers |
anchor/network/src/peer_manager/heartbeat.rs | Updates heartbeat logic to accept blocked_peers parameter |
anchor/network/src/peer_manager/discovery.rs | Adds blocked peer filtering to peer discovery and connection logic |
anchor/network/src/peer_manager/connection.rs | Prevents dialing of blocked peers in should_dial_peer method |
anchor/network/src/peer_manager/blocking.rs | New module implementing BlockingManager with libp2p integration |
anchor/network/src/network.rs | Updates event handling and adds score-based peer blocking functionality |
anchor/network/src/behaviour.rs | Passes epoch duration to PeerManager constructor |
- Remove redundant HeartbeatManager::heartbeat() wrapper function - Consolidate all heartbeat logic directly in PeerManager::heartbeat() - Simplify HeartbeatManager to only handle timing (poll_tick) - Clean up unused imports in heartbeat.rs - Improve code organization with clear separation of concerns: - HeartbeatManager: Timer management only - PeerManager: All heartbeat logic and orchestration - PeerDiscovery: Peer discovery/connection logic This eliminates an unnecessary layer of indirection and centralizes heartbeat functionality for better maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice, thanks!
This commit fully integrates the peer blocking features from the block-peers branch into the new modular peer manager architecture. Key changes:
Blocking Infrastructure:
Score-Based Blocking:
Connection Prevention:
Event System Updates:
The implementation ensures that peers with poor gossipsub scores are automatically blocked and prevented from connecting, while maintaining the modular architecture.