Closed zthomas closed 1 year ago
The conversion of /p2p
to /ipfs
only applies to the string representation, the codecs are equivalent. Over the wire representation won't matter, as any other nodes on the network should know the codec.
We will be migrating over to /p2p
by default soon, https://github.com/libp2p/libp2p/issues/79, so the string representation will always be /p2p
as we migrate away from using /ipfs
.
In regards to the errors you're seeing, those lead me to believe that the node being dialed isn't correct. Pierre may be able to help more in terms of joining the substrate network as I am not familiar with doing that currently.
Error: dialed to the wrong peer, Ids do not match
This indicates that you were able to connect to the node, but SECIO failed because the node you actually connected to is not QmPiGU1jwL9UDw2FMyMQFr9FdpF9hURKxkfy6PWw6aLsur
.
Error: No available transports to dial peer
This means no transports are dialing, so TCP is likely failing since that's a TCP address. I turned on debugging for my local node to check the errors and TCP is getting an ECONNREFUSED
error. So the boot nodes may not be available.
Error: dialed to the wrong peer, Ids do not match
I faced similar issue when connecting Rust & JS via libp2p. The problem is that peer-id JS computes peer id from public key like this:
const computeDigest = (pubKey, cb) => {
if (pubKey.bytes.length <= 42) {
const digest = mh.encode(pubKey.bytes, 'identity') // This get's executed
cb(null, digest)
} else {
pubKey.hash((err, digest) => {
cb(err, digest)
})
}
}
Result is that in JS mh.encode(pubKey.bytes, 'identity')
results in addresses of format 12D3KooWSwNXzEeGjgwEocRJBzbdoDqxbz3LdrwgSuKmKeGvbM4G
, while in Rust PeerId for the same public key looks like QmTESkr2vWDCKqiHVsyvf4iRQCBgvNDqBJ6P3yTTDb6haw
.
Error then happens in libp2p-secio/src/handshake/crypto.js
in identify
function in JS:
if (state.id.remote.toB58String() !== remoteId.toB58String()) { // <-- remoteId here is computed from public key in 12D3 format, while state.id.remote is in Qm format
return callback(new Error('dialed to the wrong peer, Ids do not match'))
}
Currently, I don't have a solution for that except to patch either JS or Rust.
This issue is very stale - the modules referenced have been updated several times, some such as secio aren't used any more.
Please open a new issue if this is still a problem.
I'm trying to connect to the Polkadot Substrate network and it looks like the multiaddr library is converting all
p2p
protocol intoipfs
So while I'm able to ping bootnodes for IPFS network, when I try to ping bootnodes for Substrate, I get errors like
Error: dialed to the wrong peer, Ids do not match
orError: No available transports to dial peer
I feel like one of the reason is that when I run the command to ping an address like
/ip4/40.117.153.33/tcp/30363/p2p/QmPiGU1jwL9UDw2FMyMQFr9FdpF9hURKxkfy6PWw6aLsur
(one of the substrate bootnodes) it automatically converts it to an IPFS address/ip4/40.117.153.33/tcp/30363/ipfs/QmPiGU1jwL9UDw2FMyMQFr9FdpF9hURKxkfy6PWw6aLsur
This seems to be coded in the spec: https://github.com/multiformats/js-multiaddr/blob/master/test/index.spec.js#L223
This is an extension of the discussions from: https://discuss.libp2p.io/t/libp2p-on-the-polkadot-network/211/3