libp2p / libp2p/py-libp2p

Add Gossipsub 2.0 Support in py-libp2p

Open
#920 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
624
Forks
256
Avg merge
1d 34m
Merged PRs (30d)
47

Description

Description

We need to add Gossipsub 2.0 support to py-libp2p in order to bring the Python implementation up to parity with other libp2p language implementations.

Gossipsub 2.0 provides several improvements over Gossipsub 1.1, mainly focusing on security, robustness under adversarial conditions, and adaptive message propagation. Adding support in py-libp2p will make it possible for Python-based projects to participate in modern libp2p pubsub networks without being limited by outdated protocol versions.

Why This Is Important

Security: Peer scoring and behavioral penalties mitigate spam, Sybil, and Eclipse attacks.

Reliability: Adaptive gossip dissemination ensures better message propagation in dynamic networks.

Compatibility: Projects using Python can interoperate with other libp2p implementations already on Gossipsub 2.0.

Scope

This issue tracks the initial implementation and integration of Gossipsub 2.0 into py-libp2p. It includes:

Implementing peer scoring (delivery rates, behavior penalties, decay).

Adding message validation hooks to allow application-level validation.

Supporting adaptive gossip dissemination.

Ensuring interoperability with other libp2p implementations (Go, JS).

Maintaining fallback/compatibility with Gossipsub 1.1 for transition.

References

Gossipsub v2 Spec

Gossipsub v2 Research Paper

Existing implementations for reference:

go-libp2p-pubsub

js-libp2p-pubsub

Motivation

Currently, py-libp2p only supports Gossipsub 1.1, which is limited in its ability to handle adversarial network conditions such as spam, Sybil attacks, and poorly behaving peers.

With the growing adoption of Gossipsub 2.0 in Go and JS implementations, the Python ecosystem risks falling behind if it cannot interoperate with modern pubsub networks. Many decentralized applications, research projects, and data-sharing systems written in Python rely on py-libp2p for networking.

Without Gossipsub 2.0 support, they are exposed to:

Security risks from malicious peers (no peer scoring or penalties in 1.1).

Unreliable message propagation in high-churn networks.

Lack of interoperability with the latest libp2p implementations.

Adding Gossipsub 2.0 to py-libp2p will:

Bring feature parity with Go and JS implementations.

Strengthen the resilience and trustworthiness of Python-based libp2p networks.

Enable cross-language applications to seamlessly adopt modern pubsub protocols.

Provide a foundation for research and production systems that require robust pubsub behavior.

Requirements

For Gossipsub 2.0 support in py-libp2p, the following capabilities are required:

  1. Peer Scoring System

Implement scoring based on message delivery, behavior, and penalties.

Include score decay over time to prevent stale behavior from persisting.

Support application-defined scoring parameters.

  1. Message Validation Hooks

Allow applications to define topic-specific validation logic.

Messages must only be propagated once validated.

Provide async support for validation callbacks.

  1. Adaptive Gossip Dissemination

Implement opportunistic grafting to improve mesh resilience.

Dynamically adjust peer selection for gossip propagation.

Reduce redundant message delivery while ensuring reliability.

  1. Security Enhancements

Protect against spam, Sybil, and Eclipse attacks.

Penalize misbehaving peers and promote honest ones.

Add safeguards against equivocation and invalid messages.

  1. Interop and Compatibility

Ensure compatibility with Gossipsub 1.1 during transition.

Interoperate with existing Go and JS implementations of Gossipsub 2.0.

Include protocol negotiation logic for smooth upgrade.

  1. Testing & Benchmarking

Add unit and integration tests for peer scoring and validation.

Test interoperability against Go and JS libp2p test suites.

Benchmark performance under high churn and adversarial peers.

Open Questions

TBD (e.g., rollout strategy, parameter tuning).

Are you planning to do it yourself in a pull request?

Maybe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced Gossipsub v2 spec and compare the existing Go and JS implementations to define the implementation boundaries. Then inspect py-libp2p's current Gossipsub 1.1 integration, though no files or tests are named in the issue. Done requires an agreed rollout plan plus scoring, validation, adaptive gossip, compatibility, interoperability, tests, and benchmarks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, networking, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.