Skip to content

Conversation

@asmit27rai
Copy link
Contributor

@asmit27rai asmit27rai commented Jan 31, 2026

Multibase Integration

Integration of py-multibase into py-libp2p as discussed here #1173.


Phase-wise Plan

Phase 1: Add Multibase Support (Completed)

  • Add py-multibase as a dependency.
  • Extend Peer ID class with multibase encode/decode methods (backward compatible).
  • Add multibase-aware utility functions for DHT keys.
  • Update pubsub message ID encoding to use multibase.
  • Preserve legacy base58/base64 support for compatibility.
  • Add and update tests for multibase, compatibility, and error handling.

Phase 2: Internal Migration (Completed)

  • Migrate internal code to use multibase by default.
  • Update peer ID parsing, DHT, and pubsub internals.
  • Update examples and documentation.

Phase 3: External API & Config (Completed)

  • Consider making multibase the default for external APIs.
  • Provide configuration for encoding preferences.

Testing

  • All new and existing tests pass for Phase 3.

@seetadev
Copy link
Contributor

seetadev commented Feb 7, 2026

@asmit27rai : Thanks for the detailed breakdown and the solid work on the multibase integration — the phased approach and backward compatibility are especially well thought out 👏

Inviting @lla-dane, @yashksaini-coder, @sumanjeet0012, @acul71 to review the changes, particularly around the internal migration, API defaults, and config surface.

Noting that a few CI/CD checks are currently failing (docs, lint across multiple Python versions, and Windows 3.13 core). Could you please take a pass at fixing these so we can get this into a mergeable state? Happy to help debug if needed.

Overall, this is a strong contribution and a meaningful step forward for py-libp2p. Looking forward to the reviews and CI being green ✅

@yashksaini-coder
Copy link
Contributor

yashksaini-coder commented Feb 11, 2026

Multibase Integration (PR #1179)

Issues that I Found

Critical Blockers

  • **Missing newsfragment file in newsfragments/.

Major Issues

  1. Inconsistent Return Type for multibase.decode(): In some versions, this returns bytes, in others (encoding, payload). Handling exists, but not explained.

  2. Potential Race in encoding_override: In the encoding_config.py, context manager, The global lock is released after context init, not held for whole override duration. Docstring/doc comment should clarify race condition possibility.

  3. Unclear Error in ID.from_string():

    • In the main id.py, method ID.from_string, When decoding fails, users cannot tell if it was invalid base58 or multibase without better error messages.

Security Risks & Risk Mitigations

  • Overall Security Risk: LOW
  • Input Validation: Uses py-multibase, validates encodings, and falls back to base58 for compatibility.
  • Thread Safety: Protected by a lock, but encoding_override() not thread-safe under concurrency.

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.

3 participants