Skip to content
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

fix support for dialing /p2p-circuit/p2p/<peer> #789

Closed
jacobheun opened this issue Oct 22, 2020 · 8 comments
Closed

fix support for dialing /p2p-circuit/p2p/<peer> #789

jacobheun opened this issue Oct 22, 2020 · 8 comments
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now status/blocked Unable to be worked further until needs are met

Comments

@jacobheun
Copy link
Contributor

  • Version: 0.29
  • Platform: *
  • Subsystem: Relay

Type: Bug

Severity: High

Description:

The following dial will throw an error Error: Invalid version, must be a number equal to 1 or 0.

const connection = await libp2p.dial('/p2p-circuit/p2p/<peer>')

This circuit dial behavior is currently broken. Providing this address should attempt to connect to the given peer over any connected relays.

@jacobheun jacobheun added kind/bug A bug in existing code (including security flaws) exp/expert Having worked on the specific codebase is important status/ready Ready to be worked P1 High: Likely tackled by core team if no one steps up labels Oct 22, 2020
@imestin
Copy link

imestin commented Oct 22, 2020

Sometimes this.version will be null in /cids/src/index.js line 255.
Also in /cids/src/cid-util.js other.version is null.

Can be reproduced with this code:


'use strict'

const Libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const { NOISE } = require('libp2p-noise')

const createNode = async () => {
  const node = await Libp2p.create({
    addresses: {
      listen: ['/ip4/0.0.0.0/tcp/0']
    },
    modules: {
      transport: [ TCP ],
      connEncryption: [ NOISE ]
    }
  })

  await node.start()
  return node
}

(async () => {
    const node = await createNode();
    const connection = await node.dial('/p2p-circuit/p2p/Qmahcv1WK5W4oiSN6aUNd9YqB4affJZXWNWbwUXrGKGfJc')
    console.log('listening on:')
    node.multiaddrs.forEach((ma) => console.log(`${ma.toString()}/p2p/${node.peerId.toB58String()}`))
})();

@imestin
Copy link

imestin commented Oct 22, 2020

In /cids/src/index.js at line 71, _CID.isCID(version) is giving false for Qmahcv1WK5W4oiSN6aUNd9YqB4affJZXWNWbwUXrGKGfJc

@jacobheun
Copy link
Contributor Author

In /cids/src/index.js at line 71, _CID.isCID(version) is giving false for Qmahcv1WK5W4oiSN6aUNd9YqB4affJZXWNWbwUXrGKGfJc

This is due to how the Circuit is currently handling the dialing address https://github.com/libp2p/js-libp2p/blob/v0.29.1/src/circuit/index.js#L104-L108. There's no relay peer so it's not passing a valid PeerId when trying to create it.

Since there's no relay address it's failing. It should detect there is no relay peer in the multiaddr and then start dialing via the relays its connected to. If that all fails, we should likely just attempt to dial with the PeerId, in case we already have a valid address for the target peer.

@imestin
Copy link

imestin commented Oct 30, 2020

I don't understand libp2p that much yet.

By PeerId, do you mean this.peerId (that is, the PeerID of the class) And how to access relays it's already connected to? I'm guessing something like this._connectionManager._libp2p.peerStore.addressBook but I can't really figure it out.

@mpetrunic
Copy link
Member

@jacobheun @lidel I'm thinking of taking this on but wanted to check first. So to do this, when there is no relay specified, I'm supposed to send a CAN_HOP request to every connection in the connection manager to try to discover relay?

Should we prioritize this or #1029 ?

@jacobheun
Copy link
Contributor Author

@mpetrunic I've been away from libp2p for a bit but I would say #1029 would be the priority. Circuit v2 will have more utility (although much more involved). The main reason this was a P1 when we created it was that it broke some existing behaviors folks were depending on with js-ipfs in browser being able to dial peers through a local go-ipfs node. This is handy if you have that local node, and it's configured to be an active relay (passive relays won't dial on your behalf, they only relay to already connected peers).

So to do this, when there is no relay specified, I'm supposed to send a CAN_HOP request to every connection in the connection manager to try to discover relay

I believe the old iteration just did the CAN_HOP check on each connect, and then kept track of the known relays so this didn't need to be done at time of dial.

Overall I would likely just prioritize Circuit V2. Then you can actually set up reservations and it will help unblock other hole punching work.

@tinytb tinytb added status/blocked Unable to be worked further until needs are met and removed status/ready Ready to be worked labels Dec 2, 2022
@tinytb
Copy link
Contributor

tinytb commented Dec 2, 2022

It looks like #1029 is being worked on now; marking this as blocked for the time being.

@p-shahi p-shahi added P3 Low: Not priority right now and removed P1 High: Likely tackled by core team if no one steps up labels Dec 6, 2022
@achingbrain
Copy link
Member

Closing because the v2 implementation will be all that's supported in the future so traffic forwarding for remote hosts via the relay will not be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now status/blocked Unable to be worked further until needs are met
Projects
Archived in project
Development

No branches or pull requests

6 participants