Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

IPFS ignores PeerID passed by libp2p instance - too many ways of passing peer-id #3590

@EmiM

Description

@EmiM
  • 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.

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions