Skip to content
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

fix(routing/http): support lookups with legacy peerid notation #585

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

lidel
Copy link
Member

@lidel lidel commented Mar 5, 2024

Summary

This PR adds support for legacy Base58-encoded PeerIDs on /routing/v1/peers/{peerid} endpoint.

Rationale

Robustness and consistency.

We already return base58 in responses, but we did not support base58 notation as input, hoping this would force initial implementers to do the right thing. But returning error here likely hurts routing in general, as someone may learn about peer using legacy ID, do a naive lookup, fail due to using old encoding, and then assume the peer is offline.

Another reason: libp2p specs here state implementations MUST support both,
it is also better for end users if we are liberal in inputs and support both notations:

Ref.

we already return base58, but we did not support them as input.
libp2p specs state implementations MUST support both, it is also better
for end users if we are liberal in inputs and support both notations:
https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#string-representation
@lidel lidel requested a review from hacdias March 5, 2024 17:28
@lidel lidel requested a review from a team as a code owner March 5, 2024 17:28
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 65.58%. Comparing base (8924807) to head (c165e4b).

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #585      +/-   ##
==========================================
- Coverage   65.59%   65.58%   -0.02%     
==========================================
  Files         207      207              
  Lines       25612    25617       +5     
==========================================
  Hits        16801    16801              
- Misses       7338     7340       +2     
- Partials     1473     1476       +3     
Files Coverage Δ
routing/http/server/server.go 67.63% <81.81%> (+0.18%) ⬆️

... and 13 files with indirect coverage changes

@hacdias hacdias merged commit 97e347e into main Mar 6, 2024
13 checks passed
@hacdias hacdias deleted the fix/http-routing-support-legacy-peerids branch March 6, 2024 09:20
@lidel
Copy link
Member Author

lidel commented Mar 13, 2024

For the record, anothr bug fixed by this PR is case when a legacy RSA key is used:

$ curl https://delegated-ipfs.dev/routing/v1/peers/QmQzqxhK82kAmKvARFZSkUVS6fo9sySaiogAnx5EnZ6ZmC
unable to parse peer ID: can't convert CID of type "dag-pb" to a peer ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants