-
Notifications
You must be signed in to change notification settings - Fork 190
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 peer_ip not in current_ips: | ||
| # This peer would add IP diversity | ||
| selected.append(peer_id) | ||
| current_ips.add(peer_ip) |
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.
peer_ip is not guaranteed to exist here. Maybe you meant to have it indented?
| 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?
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