-
Notifications
You must be signed in to change notification settings - Fork 1.2k
IPFS ignores PeerID passed by libp2p instance - too many ways of passing peer-id #3590
Description
-
Version:
"ipfs": "0.52" -
Platform:
-
Linux rf-Lenovo-ideapad-320-15IKB 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux -
nodejs
- Subsystem:
libp2p
Severity:
Low/Medium
Description:
IPFS ignores PeerID passed by libp2p instance.
This is the draft of my code:
peerID = PeerId.create() // let's assume that this peerID is static, e.g read from file
libp2p = Libp2p.create({peerId: peerID, (...)})
ipfs = await IPFS.create({
libp2p: () => libp2p,
preload: { enabled: false },
repo: targetPath,
EXPERIMENTAL: {
ipnsPubsub: true
},
})
The result of running the code above: Identity.PeerID saved in config file created by IPFS differs from peerID passed to libp2p. It causes further syncing problems with library that uses ipfs - orbitdb.
What I expect: IPFS uses peerID that I passed to libp2p.
What happened: IPFS completely ignores the peerID I passed and creates its own peerID. It uses privateKey from options or private key from Repo.
I managed to fix the problem by passing privateKey: peerID.toJSON().privKey to IPFS.create.
It's very confusing, especially that there are multiple ways of passing peer-id to IPFS and one of them that I would expect to work, doesn't work.
I've created a topic on your forum: https://discuss.ipfs.io/t/ipfs-ignores-peerid-passed-to-custom-libp2p-instance/10452, @vasco-santos suggested that IPFS could:
- throw an error if multiple peer-id are provided
or - add more docs on such configuration
Besides that, I think that IPFS should not ignore PeerID from libp2p.