Replies: 1 comment
-
|
After analyzing both repositories, I believe we should consider migrating from Current Dependency Analysis
These APIs are not present in Why This Migration is Critical
Feasibility AssessmentBoth libraries are relatively small:
The missing functionality (
Proposed Path Forward
This approach addresses both the immediate |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Verification: multiaddr vs py-libp2p multihash Conflict
Verification Date: 2025-11-08
Status: ✅ CONFIRMED - Issue is REAL
Executive Summary
The dependency conflict between
multiaddr 0.1.0andpy-libp2pregarding multihash packages is confirmed to be a real issue. Whenmultiaddr 0.1.0is installed, it pulls inpy-multihash 2.0.1, which conflicts withpymultihash 0.8.2thatpy-libp2prequires. Both packages provide amultihashmodule, causing namespace collision andAttributeErrorwhenpy-libp2ptries to use APIs that only exist inpymultihash.Dependency Conflict Schema
Scenario 1: Current Working State (multiaddr 0.0.12)
Scenario 2: Conflict State (multiaddr 0.1.0)
Dependency Tree Comparison
Namespace Collision Visualization
API Compatibility Matrix
Verification Results
✅ Confirmed Facts
multiaddr 0.1.0exists and requirespy-multihash 2.0.1pip install --dry-run multiaddr==0.1.0Would install multiaddr-0.1.0 py-multihash-2.0.1multiaddr 0.1.0is the latest version on PyPIpy-libp2prequirespymultihash>=0.8.2(NOTpy-multihash)pyproject.tomlline 33:"pymultihash>=0.8.2"py-libp2puses these APIs frompymultihash:multihash.Func.sha2_256(used inlibp2p/peer/id.py:87)multihash.digest()(used in multiple files)multihash.FuncReg(used inlibp2p/peer/id.py:35)multihash.decode()(used inlibp2p/records/pubkey.py:39)API Incompatibility Between Packages
pymultihash 0.8.2provides:multihash.Func(enum with hash function codes)multihash.digest(data, code)(creates multihash from data)multihash.FuncReg(registry for custom hash functions)multihash.decode()(decodes multihash bytes)py-multihash 2.0.1provides:multihash.encode(digest, code)(encodes digest as multihash)multihash.decode()(decodes multihash bytes)multihash.constants.HASH_CODES(dictionary of hash codes)multihash.Multihashclassmultihash.Func,multihash.digest(),multihash.FuncRegNamespace Collision
multihashsys.pathpy-multihashis imported first,py-libp2pwill fail with:Current State in py-libp2p
pyproject.tomlline 28:"multiaddr>=0.0.11"(allows0.1.0to be installed)multiaddr 0.0.12multiaddr 0.0.12does NOT requirepy-multihash(no conflict)multiaddr 0.1.0is installed📋 Files in py-libp2p Using multihash APIs
The following files use
pymultihash-specific APIs that would break withpy-multihash:libp2p/peer/id.pymultihash.FuncReg.register()- registers identity hash functionmultihash.Func.sha2_256- gets SHA-256 hash function codemultihash.digest(serialized_key, algo)- creates multihash from keylibp2p/kad_dht/routing_table.pymultihash.digest(peer_id.to_bytes(), "sha2-256").digest- converts peer ID to DHT keylibp2p/kad_dht/utils.pymultihash.digest(binary_data, "sha2-256").digest- creates DHT keymultihash.digest(peer_id.to_bytes(), "sha2-256").digest- creates peer hashlibp2p/security/secio/transport.pymultihash.digest(data, "sha2-256")- creates multihash for scorelibp2p/records/pubkey.pymultihash.decode(keyhash)- decodes multihash (this API exists in both packages)Why It Doesn't Manifest in Development
The conflict does exist but doesn't manifest in
py-libp2p's development environment because:multiaddr 0.0.12installed (NOT0.1.0)multiaddr 0.0.12does NOT depend onpy-multihashpymultihashis installed, no conflict occursThe conflict only appears when:
pipresolves tomultiaddr 0.1.0(the latest version)py-multihash 2.0.1as a dependencyTest Results
Current Environment (multiaddr 0.0.12)
What Would Happen with multiaddr 0.1.0
Verification of py-libp2p APIs
Impact Assessment
Severity: HIGH
py-libp2pwhenmultiaddr 0.1.0is resolvedAttributeErrorwhen importing or usingpy-libp2pcore functionalityID.from_pubkey()Affected Scenarios
multiaddr 0.1.0is installedRecommended Solutions
Option 1: Fix in
multiaddr(Recommended - Long-term)Problem:
multiaddr 0.1.0addedpy-multihashas a dependency, but this conflicts withpymultihashthatpy-libp2pneeds.Solution:
multiaddrshould either:pymultihashinstead ofpy-multihash(if multihash functionality is needed)py-libp2palready usespy-multihashdependency (if it doesn't actually need multihash functionality)multiaddractually uses multihash APIspy-multihashif actually neededAction Items:
multiaddrmaintainerspy-multihashwas added as a dependency in0.1.0multiaddractually needs multihash functionalitypymultihashto align withpy-libp2pRepository: https://github.com/multiformats/py-multiaddr
Option 2: Fix in
py-libp2p(Not Recommended)Problem:
py-libp2pusesmultihash.Funcandmultihash.digest()APIs that only exist inpymultihash, not inpy-multihash.Solution:
py-libp2pcould update its code to usepy-multihash's API instead:multihash.Func.sha2_256withmultihash.constants.HASH_CODES["sha2-256"]multihash.digest()with a function usingmultihash.encode()andhashlibTrade-offs:
multiaddr 0.1.0's dependencypy-libp2ppy-multihashmight not have all the featurespymultihashprovides (e.g.,FuncReg)py-libp2pusingpymultihashWhy Not Recommended:
pymultihashis already working well forpy-libp2pmultiaddradding a new dependency, not bypy-libp2ppymultihashprovidesFuncRegwhich is used for identity hash function registrationOption 3: Pin
multiaddrVersion inpy-libp2p(Temporary Workaround)Problem:
py-libp2pspecifiesmultiaddr>=0.0.11, which allows0.1.0to be installed.Solution: Pin
multiaddrto>=0.0.11,<0.1.0inpy-libp2p'spyproject.toml:Trade-offs:
multiaddrupdates (might miss bug fixes or features)Action: This is a temporary workaround, not a proper fix. Should be used only until
multiaddris fixed.Current Workaround (If Needed)
Until the upstream fix is implemented, Docker builds or CI/CD can use this workaround:
RUN pip install --no-cache-dir -e . && \ pip uninstall -y py-multihash && \ pip install --no-cache-dir --force-reinstall pymultihash>=0.8.2This ensures only
pymultihashis installed, avoiding the conflict.Verification Commands
To verify the fix works after
multiaddris fixed:Historical Context
Previous Attempts to Address multiaddr Issues
The repository has a history of dealing with
multiaddrdependency issues:PR Fix multiaddr dep to use specific commit hash to resolve install issue #928 (September 14, 2025) - "Fix multiaddr dep to use specific commit hash to resolve install issue"
52625e0fmultiaddrto a specific git commit hash (b186e2ccadc22545dec4069ff313787bf29265e0)PR Update multiaddr to version 0.0.11 #935 / Issue Update multiaddr to version 0.0.11 #934 (September 16, 2025) - "Update multiaddr to version 0.0.11"
35a4bf2dmultiaddr>=0.0.11multiaddr 0.1.0by using>=0.0.11(which allows 0.0.11, 0.0.12, etc., but not 0.1.0 if properly constrained)Earlier commits (July 2025):
multiaddrto specific git commits to avoid build issues746d0a46: "fix: update multiaddr dependency to fix py-cid build issue"21ee4177: "Pin py-multiaddr dependency to specific git commit"Why Previous Fixes Don't Address 0.1.0 Conflict
The previous fixes addressed:
py-cidHowever, they did NOT address the
multiaddr 0.1.0→py-multihashconflict because:multiaddr 0.1.0may not have existed yet, ormultiaddr 0.1.0multiaddr>=0.0.11technically allows0.1.0to be installedCurrent State
multiaddr>=0.0.11(allows0.1.0)multiaddr 0.0.12(safe, no conflict)multiaddr 0.1.0→ conflict occursImportant Clarification: Not an API Regression in multiaddr
Important: The issue is NOT that
multiaddr 0.1.0changed its API or has fewer functions. The problem is:multiaddr 0.0.12does NOT depend onpy-multihash✅multiaddr 0.1.0ADDEDpy-multihashas a new dependency ❌py-multihashis installed (via multiaddr 0.1.0), it conflicts withpymultihashthatpy-libp2pneedspymultihashvspy-multihash) have incompatible APIs and both provide a module namedmultihashWhat changed in multiaddr 0.1.0:
py-multihash 2.0.1as a dependency (this is the new/regressive change)The "fewer functions" issue:
py-multihash(installed by multiaddr 0.1.0) has a different API thanpymultihash(needed by py-libp2p)py-multihashdoesn't providemultihash.Func,multihash.digest(), ormultihash.FuncRegthatpy-libp2prequiresmultihash, it getspy-multihashinstead ofpymultihash, causingAttributeErrorTimeline
multiaddr>=0.0.11from PyPImultiaddrversion inpy-libp2pto<0.1.0if neededmultiaddrto remove or change the dependencyReferences
multiaddrrepository: https://github.com/multiformats/py-multiaddrpy-libp2prepository: https://github.com/libp2p/py-libp2ppymultihashrepository: https://github.com/ivilata/pymultihashpy-multihashrepository: https://github.com/multiformats/py-multihashmultiaddr- https://pypi.org/project/multiaddr/pymultihash- https://pypi.org/project/pymultihash/py-multihash- https://pypi.org/project/py-multihash/Summary
The conflict exists because
multiaddr 0.1.0addedpy-multihashas a dependency, which conflicts withpymultihashthatpy-libp2pneeds. The fix should be inmultiaddr:pymultihash(if multihash is needed)This is a real issue that manifests in fresh installs, even though it doesn't appear in existing development environments that have
multiaddr 0.0.12installed.Next Steps:
multiaddrmaintainersmultiaddr<0.1.0inpy-libp2pas a temporary workaroundmultiaddrrepository for fixesBeta Was this translation helpful? Give feedback.
All reactions