Replies: 3 comments
-
PeerID Requirement in libp2p SpecificationSummaryThe libp2p specification does not mandate that a PeerID must be known in advance to establish a connection. While PeerIDs are typically included in multiaddresses for identity verification, some implementations and spec discussions acknowledge valid use cases for connecting without one. Specification InsightsThe libp2p specifications acknowledge scenarios where dialing a peer without a known PeerID is valid. For example, libp2p/specs#458 discusses use cases such as:
This illustrates that the libp2p spec allows for flexibility depending on context and trust models. In addition, the libp2p HTTP Transport Gateway Specification notes:
This supports the idea that PeerID is not universally required across all libp2p transports. Implementation ExamplesSome implementations explicitly support this:
Discussion: libp2p.io forum thread ConclusionWhile using PeerIDs enhances security and identity verification, libp2p does not strictly require a PeerID for establishing a connection. Both the specification and multiple implementations recognize and support scenarios where only a This behavior is useful for:
|
Beta Was this translation helpful? Give feedback.
-
@seetadev @pacrob @dhuseby |
Beta Was this translation helpful? Give feedback.
-
Sounds good to me! I don't see any reason not to update to allow resolving PeerID after connection as you suggest. |
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.
-
Issue: Python libp2p Connect Method Requires PeerID While Other Implementations Don't
Problem Description
The Python implementation of libp2p's
connect
method requires aPeerInfo
object that includes aPeerID
, which is not compliant with the libp2p specification. Other implementations like js-libp2p and rust-libp2p allow connections using just the network address (e.g.,/ip4/127.0.0.1/tcp/8000
).Current Behavior
In the Python implementation, attempting to connect using just a network address results in an error because the
connect
method requires aPeerInfo
object that must include aPeerID
. This is evident from the implementation inlibp2p/abc.py
:From
peerinfo.py
:Expected Behavior
In both Rust and JavaScript libp2p implementations, users can dial a peer using just a
Multiaddr
, without requiring a knownPeerID
. This allows greater flexibility, especially in discovery or NAT traversal scenarios.Swarm::dial
accept plainMultiaddr
values.libp2p.dial(multiaddr)
works without embedding a/p2p/PeerID
component.The libp2p specification supports this approach, and issue #458 explicitly discusses the need to document and standardize dialing without a PeerID.
Impact
This strict requirement in Python:
Example
Current Python implementation requires:
listener.py
dialer.py
Proposed Solution
To align with other implementations and the intent of the libp2p spec:
PeerID
optional: RefactorPeerInfo
to allow omission ofpeer_id
.Multiaddr
-only connections: Allow users to initiate connections from just aMultiaddr
.PeerID
after connection: As done in rust/js, resolve the remote peer’s ID after connection handshake.PeerInfo
for advanced/manual connections.References
Beta Was this translation helpful? Give feedback.
All reactions