-
Notifications
You must be signed in to change notification settings - Fork 191
feat/920-add-gossipsub-2.0-support #1066
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
base: main
Are you sure you want to change the base?
feat/920-add-gossipsub-2.0-support #1066
Conversation
|
@Winter-Soren : Great efforts, Soham. Thank you for raising the PR. I will review all the Gossipsub 2.0 features that have been implemented. Appreciate the contribution. |
…vars, add None checks for scorer, fix test indentation and type narrowing
…e type checker treats it as non-None, allowing safe attribute access
| if score > scorer.params.graylist_threshold: | ||
| self.mesh[topic].add(peer) | ||
| # Note: In real implementation, we'd send GRAFT message | ||
| logger.debug( | ||
| "Grafted peer %s for IP diversity in topic %s", peer, topic | ||
| ) | ||
| grafted += 1 |
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.
Why this comment? And why not emitting a GRAFT message here?
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.
Thank you @pacrob for flagging this, the comment was misleading. I've fixed this by:
- Modified
_improve_mesh_diversity()to return peers that need grafting instead of just adding them locally - Updated the heartbeat flow to collect these diversity peers and include them in the
peers_to_graftdictionary - Now these peers properly receive GRAFT control messages through the existing
_emit_control_msgs()mechanism
added fix in the commit 0398d1d
pacrob
left a comment
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.
This PR needs a newsfragment, but is otherwise good to merge.
|
@Winter-Soren : This is excellent work — thank you for pushing this through. 🙌 Bringing full Gossipsub 2.0 support to py-libp2p is a major milestone and a big step toward parity with the Go and JS implementations. The scope and depth of this PR are very strong: peer scoring (including P6/P7), adaptive gossip, security hardening against spam/Sybil/Eclipse attacks, validation caching with timeouts, and careful backward compatibility with v1.1/v1.2 are all well thought out and clearly implemented. This meaningfully improves security, interoperability, and production readiness for Python-based libp2p applications. @pacrob: Thank you for the thoughtful review, clear feedback, and for approving the PR. Appreciate your great support. @Winter-Soren : Two small requests to help maximize the impact of this work along with adding the newsfragment for this PR:
Overall, this is a substantial contribution and sets a strong foundation for future pubsub and gossipsub work in py-libp2p. Fantastic work. 👏 |
@seetadev Thank you so much for the positive feedback and recognition! I'm thrilled that the Gossipsub 2.0 implementation meets the project's standards and contributes meaningfully to py-libp2p's capabilities. I'd be happy to work on both requests to maximize the impact: 1. Discussion Page / Design Document:
2. Gossipsub Demo/Example:
|
What was wrong?
Issue #920
py-libp2p only supported Gossipsub 1.1, which limited its ability to handle adversarial network conditions and interoperate with modern libp2p implementations. The Python ecosystem was falling behind Go and JS implementations that already supported Gossipsub 2.0, exposing Python-based applications to:
How was it fixed?
This PR implements comprehensive Gossipsub 2.0 support by adding advanced peer scoring, adaptive gossip dissemination, enhanced security features, and improved message validation while maintaining full backward compatibility.
Summary of approach:
🔐 Enhanced Peer Scoring System
🌐 Adaptive Gossip Dissemination
🛡️ Security Enhancements
⚡ Enhanced Message Validation
🔄 Protocol Evolution
/meshsub/2.0.0protocol ID with full backward compatibilityKey Files Modified:
libp2p/pubsub/gossipsub.py: Core Gossipsub 2.0 implementationlibp2p/pubsub/score.py: Enhanced peer scoring with P6/P7 parameterslibp2p/pubsub/pubsub.py: Validation caching and timeout mechanismstests/core/pubsub/test_gossipsub_v2_0.py: Comprehensive v2.0 test suitetests/core/pubsub/test_validation_enhancements.py: Validation feature testsTo-Do
Benefits:
This implementation brings py-libp2p to feature parity with other libp2p language implementations and provides a robust foundation for production systems requiring reliable pubsub behavior.
Cute Animal Picture