-
Notifications
You must be signed in to change notification settings - Fork 471
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
peerIdFromString
doesn't accept CID encoded PeerIDs
#2772
Comments
Ah, that's interesting. Where this function is used in the libp2p codebase, the string that's being decoded is a always a multibase encoded multihash, not a CID. Do you have a situation where the strings you have might be CIDs or might be multibase encoded multihashes? |
This is where this popped up: But it's also in the example: js-libp2p/packages/peer-id/src/index.ts Line 10 in c5bbb25
|
IPNS is a bit wonky like that, the spec for the value field is very loose. The question here is, do we want to push that complexity down to the libp2p level or can we contain it somewhere IPNS-related? One of the goals of #2660 was to reduce the complexity and guesswork in the
Yes, I think this is a symptom of the problem - when you're dealing with opaque strings, the compiler cannot help you. |
Probably not. But we should update the upgrade guide to account for this breaking change. |
Add breaking change in peerIdFromString to migration guide from 1 -> 2 Related #2772 --------- Co-authored-by: Daniel N <[email protected]> Co-authored-by: Alex Potsides <[email protected]>
Description
Since #2660, an undocumented breaking change was introduced, whereby the
peerIdFromString
function in@libp2p/peer-id
throws an error when a base36 encoded PeerID CID is passed.This can be attributed specifically to https://github.com/libp2p/js-libp2p/pull/2660/files#diff-03404c4c2b9d68fdd3cc5903cbdc0958a10b3a89c8070f1b498e60492fe6a20dL264.
There are to parts to this problem:
The older version would first try to decode the binary digest as a multihash and if that fails, attempt to decode it as a CID:
js-libp2p/packages/peer-id/src/index.ts
Lines 264 to 303 in e42da78
Proposed solutions & suggestions
The text was updated successfully, but these errors were encountered: