Understanding Peer Scoring
Peer scoring in Kona evaluates peers based on multiple factors:- Message Delivery: How reliably peers deliver messages
- Mesh Participation: Active participation in gossipsub mesh
- Invalid Messages: Penalties for invalid or malformed messages
- IP Colocation: Penalties for multiple peers from the same IP
- Behavior Patterns: General peer behavior and responsiveness
Peer scoring helps maintain network quality by identifying and removing peers that:
- Fail to deliver messages reliably
- Send invalid or spam messages
- Exhibit malicious behavior patterns
- Have poor network connectivity
Peer Score Levels
Kona supports two peer scoring levels:Score Calculation Parameters
The scoring system uses several key parameters:Basic Configuration
Using CLI Flags
Configure peer scoring via command-line flags:Programmatic Configuration
Configure peer scoring in code:Advanced Configuration
Topic Scoring Parameters
Configure topic-specific scoring based on block time:Gossipsub Mesh Parameters
Fine-tune gossipsub mesh parameters for optimal performance:Peer Score Thresholds
Configure thresholds that determine peer treatment:Complete Example
Here’s a comprehensive example configuring P2P with peer scoring:CLI Configuration Examples
Development Setup
Minimal scoring for local development:Production Setup
Full peer scoring with monitoring:High-Security Setup
Strict scoring with aggressive banning:Monitoring Peer Scores
Kona inspects peer scores every 15 seconds and can automatically ban poorly performing peers:Peer scores and banning events are recorded in metrics. Monitor these metrics
to understand your node’s peer health:
kona_gossip_peer_scores: Histogram of peer scoreskona_gossip_banned_peers: Counter of banned peerskona_gossip_peer_connection_duration_seconds: Connection durations
Best Practices
- Start with Light Scoring: Use
PeerScoreLevel::Lightfor most deployments - Monitor Before Banning: Run without banning initially to understand score distributions
- Adjust Thresholds Gradually: Start with default -100 threshold and adjust based on observations
- Consider Network Conditions: Increase ban duration in hostile environments
- Balance Security and Connectivity: Overly aggressive scoring can isolate your node
- Disable Topic Scoring: Unless specifically needed for compatibility
- Use Metrics: Monitor peer scores and ban events to tune configuration
Related Resources
- kona-peers - Peer management and scoring
- kona-gossip - Gossipsub implementation
- kona-node-service - Network service implementation
- libp2p gossipsub - Underlying gossipsub protocol
- OP Stack P2P Spec - Protocol specification