Skip to content
This repository has been 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

Closed
EmiM opened this issue Mar 15, 2021 · 7 comments
Closed
Assignees
Labels
kind/architecture Core architecture of project kind/resolved-in-helia need/analysis Needs further analysis before proceeding P3 Low: Not priority right now topic/docs Documentation topic/libp2p Topic libp2p

Comments

@EmiM
Copy link

EmiM commented Mar 15, 2021

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

@EmiM EmiM added the need/triage Needs initial labeling and prioritization label Mar 15, 2021
@welcome
Copy link

welcome bot commented Mar 15, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@momack2
Copy link
Contributor

momack2 commented Mar 16, 2021

Thank you for the report!

@vasco-santos
Copy link
Member

vasco-santos commented Mar 16, 2021

@momack2 the configuration issue here is a conflict between a user configuring libp2p via js-ipfs + what js-ipfs does to configure libp2p itself:

  • js-libp2p creates factory receives a PeerId, as part of a configuration object, to create a libp2p node
  • js-ipfs allows a user to bring their own libp2p configuration
  • js-ipfs/go-ipfs repo includes nodes configuration, including its cryptographic primitives (peerId, privateKey, publicKey, ...)

So what happens in this case is that IPFS repo already has a PeerId defined, but IPFS allows libp2p to be configured with another PeerId, which will be overwritten by IPFS when setting the repo's PeerId.

With the above considerations, this is a js-ipfs issue and what we need to decide is:

  • what should happen when "competing" peerIds exist
  • properly document the expectations in js-ipfs

As a side note, there is a lot of room for configuration improvements on js-ipfs and js-libp2p. This has been one of the pain points of users

EDIT: We are only talking about the peerId here, but I suspect this problem might exist on other configuration properties like the swarm addresses configured in IPFS config file, which are forwarded to the libp2p config (and probably overwrite user provided configs within libp2p scope)

@BigLep BigLep added need/analysis Needs further analysis before proceeding and removed need/triage Needs initial labeling and prioritization labels Mar 21, 2021
@BigLep
Copy link
Contributor

BigLep commented Mar 21, 2021

@vasco-santos: who owns the next steps here?

@BigLep BigLep added the need/triage Needs initial labeling and prioritization label Mar 21, 2021
@vasco-santos
Copy link
Member

This needs an analysis of the scope of this issue first, as this is not only a peer-id, but all the configuration that overlaps with libp2p like addresses. With all the information we need to discuss the solution. @achingbrain should give input on the solution.

This can be included in protocol/web3-dev-team#82 or as a maintenance task (probably for the onboarding team?)

@momack2
Copy link
Contributor

momack2 commented Mar 27, 2021

Seems like a simple v0 is just to define what does and doesn't work in the docs, and the work around that EmiM suggested (aka if you're using IPFS, your libp2p configurations will be overwritten and need to be passed directly to the IPFS constructor). Seems like something that @johnnymatthews @johndmulhausen can document!

@lidel lidel added P2 Medium: Good to have, but can wait until someone steps up topic/docs Documentation topic/libp2p Topic libp2p kind/architecture Core architecture of project P3 Low: Not priority right now and removed need/triage Needs initial labeling and prioritization P2 Medium: Good to have, but can wait until someone steps up labels Jul 23, 2021
@SgtPooki SgtPooki moved this to 🥞 Todo in js-ipfs deprecation May 17, 2023
@whizzzkid whizzzkid moved this from 🥞 Todo to 🛑 Blocked in js-ipfs deprecation May 23, 2023
@whizzzkid
Copy link

whizzzkid commented May 31, 2023

js-ipfs is being deprecated in favor of Helia. You can follow the migration plan here #4336 and read the migration guide.

This issue has been resolved in Helia! if this does not address your concern please let us know by reopening this issue before 2023-06-05!

@github-project-automation github-project-automation bot moved this from 🛑 Blocked to ✅ Done in js-ipfs deprecation May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/architecture Core architecture of project kind/resolved-in-helia need/analysis Needs further analysis before proceeding P3 Low: Not priority right now topic/docs Documentation topic/libp2p Topic libp2p
Projects
No open projects
Status: Done
Development

No branches or pull requests

6 participants