-
Notifications
You must be signed in to change notification settings - Fork 479
fix: encapsulate /p2p-circuit multiaddrs when dialing a known peerid #1680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The logic for creating a dial target is intended to ensure multiaddrs are encapsulated with `/p2p/${peerId}` IF the dial target's peer id is known. It uses `addr.getPeerId()` to check if this is already the case. ``` > multiaddr("/ip4/127.0.0.1/tcp/4001/p2p/12D3...").getPeerId() '12D3...' ``` However, circuit relay addresses return the **relay server's** peer id if they don't end in `/p2p/${destinationPeerId}`. ``` > multiaddr("/ip4/127.0.0.1/tcp/4001/p2p/12D3.../p2p-circuit").getPeerId() '12D3...' ``` Since the dialer then thinks the multiaddr already has a peer id, it doesn't encapsulate with `/p2p/${destinationPeerId}`, which ultimately results in failed dials to circuit relay destinations with error `ERR_RELAYED_DIAL` (`Circuit relay dial failed as addresses did not have peer id`). If I understand things right, the desired behavior is for circuit relay addresses to get encapsulated with the destination peer id.
Just want to bump this since I'm now confident this is breaking all dials to circuit-relay addresses, at least on our network. @achingbrain if you could take a look at this, I'd be really grateful 💜 |
Thanks! This fix is available via the There's a short upgrade guide to follow but it should be relatively painless unless you are doing a lot of custom stuff with the connection manager. $ npm i libp2p@next |
That works! Thank you so much! |
This has been released in |
The logic for creating a dial target tries to ensure multiaddrs are encapsulated with
/p2p/${peerId}
IF the dial target's peer id is known. It usesaddr.getPeerId() != null
to check if this is already the case.However, circuit relay addresses return the relay server's peer id if they don't end in
/p2p/${destinationPeerId}
.Since the dialer then thinks the multiaddr already has a peer id, it doesn't encapsulate with
/p2p/${destinationPeerId}
, which ultimately results in failed dials to circuit relay destinations (Circuit relay dial failed as addresses did not have peer id
). If I understand things right, the desired behavior is for circuit relay addresses to get encapsulated with the destination peer id.