Gossipsub Playground: Versioned Examples & Protocol Insights #1297
Replies: 1 comment
-
|
@Winter-Soren: This is an excellent and highly valuable contribution, thank you for putting this together so comprehensively. The progression across Gossipsub versions is presented with strong clarity, and the combination of executable examples + feature matrix + protocol evolution narrative makes this especially impactful for both new contributors and experienced maintainers. The way each version incrementally builds on the previous one (from basic mesh pubsub to adaptive gossip and security in 2.0) is easy to follow, and the inclusion of realistic node roles (spammer, validator, observer, etc.) significantly improves the learning and testing experience. Next Steps: Protocol Research on GossipsubBuilding on this, there are several high-impact directions we should prioritize: 1. Formalizing Network Health & Adaptive Gossip
2. Peer Scoring Calibration & Attack Resistance
3. Cross-Implementation Interop Testing
4. Large-Scale Simulation & Visualization
5. Message Validation & Application-Aware Gossip
6. Security Hardening (Toward Gossipsub 2.x+)
7. Documentation → Spec Feedback Loop
If we sequence this well, this work can evolve from examples into a full-fledged Gossipsub research and testing framework, which would be a major contribution not just to py-libp2p, but to the broader libp2p ecosystem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discussion page contains comprehensive examples showcasing the differences between Gossipsub protocol versions. Implemented at PR #1139
Overview
Py-libp2p has full protocol version support spanning:
/meshsub/1.0.0) - Basic mesh-based pubsub/meshsub/1.1.0) - Added peer scoring and behavioral penalties/meshsub/1.2.0) - Added IDONTWANT message filtering/meshsub/1.3.0) - Extensions Control Message and Topic Observation/meshsub/1.4.0) - Rate limiting, GRAFT flood protection, and adaptive gossip/meshsub/2.0.0) - Enhanced security, adaptive gossip, and advanced peer scoringVersion comparison
Each version builds on the previous one. The summary table lists protocol id, example script (same directory as this README), and what that release adds. The feature matrix shows which major capabilities appear in which version.
Summary
/meshsub/1.0.0gossipsub_v1.0.py/meshsub/1.1.0gossipsub_v1.1.py/meshsub/1.2.0gossipsub_v1.2.py/meshsub/1.3.0gossipsub_v1.3.py/meshsub/1.4.0gossipsub_v1.4.py/meshsub/2.0.0gossipsub_v2.0.pyRun scripts from the repository root as
python examples/pubsub/gossipsub/<script>.py(see Examples).Feature matrix
Capabilities accumulate down the column: a ✓ means that version includes the capability (and usually everything above it in earlier versions).
Examples
Run each command from the repository root of py-libp2p; paths are relative to that root.
1. Gossipsub 1.0 Demo (
examples/pubsub/gossipsub/gossipsub_v1.0.py)Basic mesh-based pubsub demo using Gossipsub 1.0 (
/meshsub/1.0.0).Features:
Usage:
2. Gossipsub 1.1 Demo (
examples/pubsub/gossipsub/gossipsub_v1.1.py)Demonstrates Gossipsub 1.1 (
/meshsub/1.1.0) with peer scoring and behavioral penalties.Features:
Usage:
3. Gossipsub 1.2 Demo (
examples/pubsub/gossipsub/gossipsub_v1.2.py)Demonstrates Gossipsub 1.2 (
/meshsub/1.2.0) with IDONTWANT message filtering.Features:
Usage:
4. Gossipsub 1.3 Demo (
examples/pubsub/gossipsub/gossipsub_v1.3.py)Demonstrates GossipSub 1.3 (
/meshsub/1.3.0) with the Extensions Control Messagemechanism and the Topic Observation extension.
Features:
full message payloads
/meshsub/1.3.0is negotiatedNode roles in the demo:
publishersubscriberobserverAt the halfway point one observer sends UNOBSERVE to stop receiving notifications,
demonstrating the full OBSERVE → IHAVE → UNOBSERVE lifecycle.
Usage:
5. Gossipsub 1.4 Demo (
examples/pubsub/gossipsub/gossipsub_v1.4.py)Demonstrates GossipSub 1.4 (
/meshsub/1.4.0) with enhanced rate limiting, GRAFT floodprotection, and adaptive gossip parameter tuning.
Features:
trigger a
penalize_iwant_spamscore deductionexcess triggers
penalize_ihave_spamis penalised via
penalize_graft_floodand immediately re-prunednetwork health score (connectivity, peer scores, delivery rate, mesh stability, churn)
is lowered so high-quality peers are grafted more aggressively
accelerated for faster mesh recovery
/meshsub/1.4.0Node roles in the demo:
honestvalidatorspammerobserverAt
t = duration/4the spammer fires a burst of 12 messages in rapid succession todemonstrate rate-limit enforcement. At
t = duration/2one observer sends UNOBSERVE.Usage:
6. Gossipsub 2.0 Demo (
examples/pubsub/gossipsub/gossipsub_v2.0.py)Demonstrates Gossipsub 2.0 (
/meshsub/2.0.0) with adaptive gossip and advanced security features.Features:
Peer Scoring Visualization
Adaptive Gossip Demonstration
Security Features
Usage:
Protocol Version Differences
Gossipsub 1.0 (
/meshsub/1.0.0)Gossipsub 1.1 (
/meshsub/1.1.0)Gossipsub 1.2 (
/meshsub/1.2.0)Gossipsub 1.3 (
/meshsub/1.3.0)scorer.penalize_behaviorstart_observing_topic/stop_observing_topicAPI; observersreceive IHAVE notifications immediately on publish without fetching full payloads
is
/meshsub/1.3.0or laterGossipsub 1.4 (
/meshsub/1.4.0)penalize_iwant_spamscore deductiontriggers
penalize_ihave_spamreceive
penalize_graft_floodand are immediately re-prunedgossip_factor) scales dynamicallybased on a composite network health score (mesh connectivity, peer scores, delivery
rate, mesh stability, and connection churn)
promotes more aggressive peer selection for mesh repair
for faster mesh recovery, expanding again once health improves
supports_protocol_feature(peer, "extended_scoring")returns
Trueonly for/meshsub/1.4.0Gossipsub 2.0 (
/meshsub/2.0.0)Peer Scoring Parameters (P1-P7)
Topic-Scoped Parameters (P1-P4)
Global Parameters (P5-P7)
Security Features in Gossipsub 2.0
Spam Protection
Eclipse Attack Protection
Equivocation Detection
Message Validation
Running the Examples
Basic Usage
# From the repository root of py-libp2p python examples/pubsub/gossipsub/gossipsub_v1.0.py --nodes 5 --duration 30 python examples/pubsub/gossipsub/gossipsub_v1.1.py --nodes 5 --duration 30 python examples/pubsub/gossipsub/gossipsub_v1.2.py --nodes 5 --duration 30 python examples/pubsub/gossipsub/gossipsub_v1.3.py --nodes 6 --duration 40 python examples/pubsub/gossipsub/gossipsub_v1.4.py --nodes 6 --duration 40 python examples/pubsub/gossipsub/gossipsub_v2.0.py --nodes 5 --duration 60Understanding the Output
The per-version demos print statistics summarising:
Network Topologies
All demos create realistic network topologies:
Customization
Adding Custom Scenarios
To add new test scenarios to the per-version demos:
Custom Scoring Functions
To implement custom application scoring:
Custom Validation
To add custom message validation:
Troubleshooting
Common Issues
Debug Mode
Enable verbose logging for detailed information:
References
Beta Was this translation helpful? Give feedback.
All reactions