Weber P2P Networking Interface¶
Notice: This document is a work-in-progress for researchers and implementers of the Weber protocol.
Table of contents¶
- Introduction
- Constants
- Network
- Gossip
- Resource Limits
- Transport
- ENR Structure
- Node Discovery
- Connection Handling
- The Gossip Domain: GossipSub
- Topics and Messages
- Attestation Subnets
- Sync Committee Subnets
- Weber Quick Finality Subnet
- Message Validation
- Attestation Aggregation
- The Req/Resp Domain
- Protocol Identification
- Encoding and Compression
- Request/Response Messages
- Weber-specific Network Optimizations
- Prioritized Message Propagation
- Dynamic Subnet Participation
- Intelligent Peer Selection
- Validator Performance Tracking
- Network Security
- Spam Protection
- Eclipse Attack Prevention
- P2P Credential Management
- Implementation Guidelines
- Common Patterns
- Testing Recommendations
- Performance Metrics
Introduction¶
This document specifies the peer-to-peer (P2P) networking layer for the Weber protocol. The P2P network enables nodes to discover each other, exchange blockchain data, propagate blocks and attestations, and maintain consensus across the network.
Weber builds upon libp2p as its foundational networking stack, with several protocol-specific enhancements designed to optimize for Weber's unique consensus mechanisms:
- Reputation-aware message propagation to prioritize data from reliable validators
- Quick finality subnets for accelerated block finalization
- Optimized attestation aggregation techniques
- Performance-based peer selection for improved network resilience
This specification defines the protocols, message formats, and behaviors that all Weber client implementations must follow to ensure interoperability.
Constants¶
Network¶
Name | Value | Description |
---|---|---|
TARGET_PEERS_COUNT |
60 |
Target number of peers to maintain |
MAX_PEERS_COUNT |
100 |
Maximum allowed number of peers |
MINIMUM_VIABLE_PEERS |
20 |
Minimum peers required for adequate network participation |
GOSSIP_MAX_SIZE |
1 MiB |
Maximum allowed size of uncompressed gossip messages |
MAX_REQUEST_BLOCKS |
1024 |
Maximum number of blocks in a single request |
SUBNET_COUNT |
64 |
Number of attestation subnets |
SYNC_COMMITTEE_SUBNET_COUNT |
4 |
Number of sync committee subnets |
WEBER_FINALITY_SUBNET_COUNT |
2 |
Number of Weber quick finality subnets |
ATTESTATION_SUBNET_EXTRA_BITS |
0 |
Amount of extra bits of randomness to add when determining a persistent attestation subnet |
GOSSIP_MAX_RETRIES |
3 |
Maximum number of gossip message retransmissions |
Gossip¶
Name | Value | Description |
---|---|---|
ATTESTATION_SUBNET_FRACTION |
4 |
1/N of all validators are in each subnet |
ATTESTATION_SUBNET_COUNT |
64 |
Number of attestation subnets |
FINALITY_SUBNET_FRACTION |
8 |
1/N of high-reputation validators are in the finality subnet |
GOSSIP_SCORING_THRESHOLD |
50 |
Score below which a peer is considered malicious |
GOSSIP_SCORING_MAX |
500 |
Maximum score a peer can achieve |
ATTESTATION_PROPAGATION_SLOT_RANGE |
32 |
Maximum number of slots during which an attestation can be propagated |
Resource Limits¶
Name | Value | Description |
---|---|---|
REQUEST_RESPONSE_TIMEOUT |
10s |
Timeout for response from a request |
RESP_TIMEOUT |
10s |
Timeout for full response |
MAX_CHUNK_SIZE |
1 MiB |
Maximum allowed size of uncompressed req/resp chunks |
TTFB_TIMEOUT |
5s |
Maximum time to wait for first byte of request response |
WEBER_PRIORITY_SLOTS |
4 |
Number of slots for which newly produced blocks receive network priority |
MAX_EPOCHS_BEHIND |
2 |
Maximum epochs a peer can be behind before being disconnected |
Transport¶
Weber's P2P network uses libp2p as its transport layer with several configurations and extensions specific to the protocol's needs.
ENR Structure¶
Weber nodes use Ethereum Node Records (ENR) for discovery with the following fields:
Name | ENR Value | SSZ Equivalent |
---|---|---|
eth2 |
ssz_snappy(ENRForkID) |
N/A |
attnets |
bitvector[64] |
Bitvector[ATTESTATION_SUBNET_COUNT] |
syncnets |
bitvector[4] |
Bitvector[SYNC_COMMITTEE_SUBNET_COUNT] |
webernets |
bitvector[2] |
Bitvector[WEBER_FINALITY_SUBNET_COUNT] |
Node Discovery¶
Weber uses discv5 for node discovery, enhanced with Weber-specific capabilities:
- Reputation Tracking: Discovery process considers node reputation from previous interactions
- Geographic Diversity: Prioritizes connections to nodes in different geographic regions
- Quick Finality Support: Tracks which nodes participate in quick finality subnets
The discovery implementation must support ENR updates to track changing subnet subscriptions.
Connection Handling¶
Weber nodes should maintain connections with the following prioritization:
- Peers participating in sync committee subnets
- Peers participating in attestation subnets assigned to the node
- Peers participating in Weber quick finality subnets
- Peers with high reputation scores
- Peers with diverse network locations
The Gossip Domain: GossipSub¶
Weber uses libp2p's GossipSub protocol for efficiently broadcasting messages across the network, with performance-critical enhancements:
- Message Scoring: Messages are scored based on validator reputation and timeliness
- Enhanced Mesh Formation: Mesh connections are prioritized based on peer reliability
- Opportunistic Grafting: Dynamic mesh adaptation based on network conditions
Topics and Messages¶
Topics in Weber are organized by fork digest to support versioning and by functionality for specific message types. The format follows:
/weber/{fork_digest}/{topic}/{encoding}
Global Topics¶
Name | Message Type | Message Contents |
---|---|---|
beacon_block |
SignedBeaconBlock |
A signed beacon block |
beacon_aggregate_and_proof |
SignedAggregateAndProof |
A signed attestation aggregate with selection proof |
voluntary_exit |
SignedVoluntaryExit |
A voluntary validator exit |
proposer_slashing |
ProposerSlashing |
A proposer slashing |
attester_slashing |
AttesterSlashing |
An attester slashing |
sync_committee_contribution_and_proof |
SignedContributionAndProof |
A sync committee contribution and BLS proof of possession |
validator_rotation |
SignedValidatorRotation |
A validator rotation request (Weber specific) |
quick_finality_vote |
SignedQuickFinalityVote |
A quick finality vote from high-reputation validators (Weber specific) |
Shard Topics¶
Name | Message Type | Message Contents |
---|---|---|
beacon_attestation_{subnet_id} |
Attestation |
An attestation with subnet selection |
sync_committee_{subnet_id} |
SyncCommitteeMessage |
A sync committee message for light clients |
Weber Enhanced Topics¶
Name | Message Type | Message Contents |
---|---|---|
weber_quick_finality_{subnet_id} |
QuickFinalityConsensusMessage |
Quick finality message for accelerated consensus |
validator_reputation_update |
SignedReputationUpdate |
A signed validator reputation update |
high_priority_attestation |
PrioritizedAttestation |
Critical attestation from high-reputation validators |
Attestation Subnets¶
Weber maintains the subnet-based attestation design to distribute network load, with 64 attestation subnets. Validators are assigned to specific subnets according to the following rules:
Sync Committee Subnets¶
Weber uses sync committee subnets to distribute sync committee messages which are used by light clients:
Weber Quick Finality Subnet¶
Weber introduces specialized subnets for quick finality messages:
Message Validation¶
Before propagating messages, Weber nodes must validate them according to specific rules for each message type:
For Weber's quick finality messages, additional validation is required:
Attestation Aggregation¶
Weber optimizes the attestation aggregation process with a reputation-aware strategy:
The Req/Resp Domain¶
Weber's request/response protocols handle direct communication between peers.
Protocol Identification¶
Weber req/resp protocols follow the format:
/weber/{protocol}/{version}/{encoding}
For example: /weber/beacon_blocks_by_range/1/ssz_snappy
Encoding and Compression¶
Weber supports SSZ with Snappy compression as the primary encoding format:
Name | Content Identifier | Description |
---|---|---|
ssz_snappy |
application/octet-stream |
SSZ encoded and snappy compressed |
Request/Response Messages¶
The following methods are defined in the req/resp domain:
Status¶
Protocol ID: /weber/status/1/ssz_snappy
Used to determine each peer's chain state during connection.
Goodbye¶
Protocol ID: /weber/goodbye/1/ssz_snappy
Used when disconnecting from a peer.
Code | Name | Description |
---|---|---|
0 |
CLIENT_SHUTDOWN |
Regular shutdown |
1 |
IRRELEVANT_NETWORK |
Wrong network |
2 |
FAULT_ERROR |
Generic fault |
3 |
UNABLE_TO_VERIFY_NETWORK |
Cannot verify network |
4 |
TOO_MANY_PEERS |
Exceeded peer limit |
5 |
REPUTATION_BELOW_THRESHOLD |
Peer reputation too low |
6 |
FORK_INCOMPATIBLE |
Fork version mismatch |
BeaconBlocks¶
Protocol ID: /weber/beacon_blocks_by_range/1/ssz_snappy
Request a range of beacon blocks.
Protocol ID: /weber/beacon_blocks_by_root/1/ssz_snappy
Request specific beacon blocks by their root.
Weber Enhanced Requests¶
Protocol ID: /weber/reputation_by_index/1/ssz_snappy
Request reputation scores for specific validators.
Protocol ID: /weber/quick_finality_checkpoints/1/ssz_snappy
Request recent quick finality checkpoints.
Weber-specific Network Optimizations¶
Prioritized Message Propagation¶
Weber implements a sophisticated prioritization system for message propagation:
Dynamic Subnet Participation¶
Weber implements dynamic subnet participation based on network conditions:
Intelligent Peer Selection¶
Weber optimizes peer connections based on multiple factors:
Validator Performance Tracking¶
Weber tracks validator network performance for reputation scoring:
Network Security¶
Spam Protection¶
Weber implements several spam protection mechanisms:
- Rate Limiting: Per-peer message rate limits with validator reputation adjustments
- Message Validation: Strict validation before propagation
- Reputation Scoring: Peers serving invalid or spammy content receive reduced scores
- IP Diversity: Connection limits per IP range to prevent Sybil attacks
Eclipse Attack Prevention¶
Weber mitigates eclipse attacks through:
- Peer Diversity: Maintaining connections to peers across different subnets and regions
- Bootstrap Nodes: Regular reconnection to trusted bootstrap nodes
- Network Monitoring: Detecting unusual connection patterns or sudden peer disconnections
- Regular Peer Rotation: Periodically replacing peers to prevent gradual isolation
P2P Credential Management¶
Implementation Guidelines¶
Common Patterns¶
Implementing Weber's P2P interface should follow these patterns:
- Progressive Enhancement: Start with basic libp2p functionality, then add Weber enhancements
- Modular Design: Separate network logic from consensus logic
- Metrics Collection: Instrument all network operations for monitoring
- Circuit Breakers: Implement fallback mechanisms when network conditions degrade
- Graceful Degradation: Maintain basic functionality even when advanced features fail
Testing Recommendations¶
Robust testing of the P2P implementation should include:
- Network Simulation: Testing with simulated latency, packet loss, and bandwidth constraints
- Adversarial Testing: Injecting malicious or malformed messages
- Scalability Testing: Verifying behavior with large peer counts
- NAT Traversal: Testing connectivity through various NAT configurations
- Fork Transition: Validating behavior during protocol upgrades
Performance Metrics¶
Key metrics to track in a Weber P2P implementation:
- Message Propagation Time: How quickly blocks and attestations spread through the network
- Peer Connectivity: Distribution and stability of peer connections
- Bandwidth Utilization: Network usage per peer and message type
- Subnet Coverage: Effectiveness of subnet subscription strategy
- Quick Finality Performance: Propagation time for quick finality votes
- CPU/Memory Overhead: Resources consumed by the networking stack
- Discovery Success Rate: Effectiveness of peer discovery
These metrics should be exposed via standard monitoring interfaces to enable network-wide health monitoring.