Skip to content

Conversation

@Winter-Soren
Copy link
Contributor

@Winter-Soren Winter-Soren commented Oct 26, 2025

What was wrong?

Issue #992

  1. Protocol Version Gap: Only supported up to v1.2, missing v1.3 and v1.4 protocol versions

  2. Missing Core v1.4 Features:

    • Extended peer scoring parameters (P5-P7: application-specific, IP colocation, behavioral penalties)
    • IP colocation penalties for Sybil attack prevention
    • Adaptive gossip dissemination with dynamic parameter adjustment
    • Message ID customization support
    • Rate-limiting and score decay enhancements
    • Extensions control message handling (v1.3)
    • IDONTWANT message handling (v1.2)
  3. Interoperability Issues: Lack of protocol parity with go-libp2p, js-libp2p, and rust-libp2p implementations

How was it fixed?

Summary of approach:

Phase 1: Protocol Foundation (Completed)

  1. Protocol Version Support:

    • Added PROTOCOL_ID_V13 = TProtocol("/meshsub/1.3.0") and PROTOCOL_ID_V14 = TProtocol("/meshsub/1.4.0")
    • Updated add_peer() method to accept new protocol versions
    • Updated constants in libp2p/tools/constants.py
  2. Protocol Feature Detection:

    • Implemented supports_protocol_feature() method for capability negotiation
    • Added supports_scoring() helper method
    • Feature mapping by protocol version:
      • PX (Peer Exchange): v1.1+
      • IDONTWANT: v1.2+
      • Extensions: v1.3+
      • Adaptive gossip: v1.4
      • Scoring: v1.1+
      • Extended scoring (P5-P7): v1.4
  3. Message ID Customization Framework:

    • Created MessageIDGenerator abstract base class
    • Implemented PeerAndSeqnoMessageIDGenerator and ContentAddressedMessageIDGenerator
    • Added CustomMessageIDGenerator for user-defined functions
    • Updated Pubsub constructor to support both callables and generators
    • Maintained backward compatibility

Phase 2: Core v1.4 Features (In Progress)

  1. Extensions Control Message (v1.3):

    • Created protocol buffer definition for extensions (rpc_v13.proto)
    • Framework ready for extension registration and handling
  2. IDONTWANT Message Handling (v1.2):

    • Protocol support added, implementation pending

Phase 3: Advanced Features (Pending)

  1. Extended Peer Scoring System:

    • P5: Application-specific scoring
    • P6: IP colocation factor with subnet tracking
    • P7: Behavioral pattern penalties
    • Enhanced decay mechanisms
  2. IP-based Security:

    • IP colocation penalties
    • Sybil attack mitigation
    • IP whitelist functionality
  3. Adaptive Gossip Dissemination:

    • Dynamic parameter adjustment
    • Score-based peer selection
    • Opportunistic grafting enhancements
  4. Rate-limiting and Score Decay:

    • IWANT request tracking
    • IHAVE message limits
    • Graft flood threshold
    • Configurable decay intervals

Phase 4: Testing and Validation (Pending)

  1. Comprehensive Testing:

    • Unit tests for all components
  2. Documentation:

    • API documentation updates
    • Usage examples

Architecture Benefits:

  • Modular Design: Each feature can be implemented independently
  • Backward Compatibility: Existing v1.0/v1.1/v1.2 implementations continue to work
  • Protocol Negotiation: Automatic feature detection and capability matching
  • Extensibility: Framework supports future protocol versions and custom extensions

To-Do

  • Complete IDONTWANT message handling implementation
  • Implement extensions control message framework
  • Add extended peer scoring system (P5-P7)
  • Implement IP colocation penalties and Sybil mitigation
  • Add adaptive gossip dissemination
  • Implement rate-limiting mechanisms
  • Create comprehensive test suite
  • Add interoperability tests with other libp2p implementations
  • Clean up commit history
  • Add or update documentation related to these changes

Cute Animal Picture

pexels-eftodii-aurelia-90976-735423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants