Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

fix: CIDv1 error with go-libp2p 0.19 #32

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

lidel
Copy link
Member

@lidel lidel commented Apr 26, 2022

This PR fixes regression detected by failure in t0160-resolve.sh sharness test in ipfs/kubo#8868 (where we test go-libp2p 0.19)

  • The error message changed in recent go-libp2p-core/peer (go-libp2p 0.19)
    • Due to string matching, namesys no longer returned a user-friendly error message
    • String matching is a bad practice so just removing it, as we validate CID and codec already.

The error message changed in libp2p and we no longer get this nice error
message. String matching is a bad practice so just removing it, as we
validate CID and codec already.
@lidel lidel requested a review from guseggert April 26, 2022 17:52
lidel added a commit to ipfs/kubo that referenced this pull request Apr 26, 2022
Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as long as things pass with the upstream tests as well.

@@ -202,12 +202,12 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.

// CIDs in IPNS are expected to have libp2p-key multicodec
// We ease the transition by returning a more meaningful error with a valid CID
if err != nil && err.Error() == "can't convert CID of type protobuf to a peer ID" {
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right.

Just playing this out though, if there is a DNSLink name that is a CIDv1 with a codec other than libp2p-key it previously would've worked as long as the codec wasn't dag-pb but now always fails. To be fair, the realm of TLD DNSLinks (i.e. foo not foo.bar or foo.bar.baz) has a bunch of sketchy areas anyway and is uncommon so I'm not too concerned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in some sense we had a bug before and this fixed it. Now, we always prioritize CIDs over DNSLink names, so if someone tries to squat Handshake TLD that looks like a valid CID, it won't work.

@guseggert guseggert merged commit 605965e into master Apr 27, 2022
@guseggert guseggert deleted the fix/cidv1-libp2p-key-error-go-libp2p-0.19 branch April 27, 2022 15:11
lidel added a commit to ipfs/kubo that referenced this pull request Apr 27, 2022
lidel added a commit to ipfs/kubo that referenced this pull request Apr 28, 2022
lidel added a commit to ipfs/kubo that referenced this pull request Apr 28, 2022
* update go-libp2p to v0.19.0
* chore: go-namesys v0.5.0
* refactor(config): cleanup relay handling
* docs(config): document updated defaults
* fix(tests): panic during sharness

* fix: t0160-resolve.sh
See ipfs/go-namesys#32

* fix: t0182-circuit-relay.sh
* test: transport encryption

Old tests were no longer working because go-libp2p 0.19 removed
the undocumented 'ls' pseudoprotocol.

This replaces these tests with handshake attempt (name is echoed back on
OK or 'na' is returned when protocol is not available) for tls and noise
variants + adds explicit test that safeguards us against enabling
plaintext by default by a mistake.

* fix: ./t0182-circuit-relay.sh

test is flaky, for now we just restart the testbed when we get
NO_RESERVATION error

* refactor: AutoRelayFeeder with exp. backoff

It starts at feeding peers ever 15s, then backs off each time
until it is done once an hour

Should be acceptable until we have smarter mechanism in go-lib2p 0.20

* feat(AutoRelay): prioritize Peering.Peers

This ensures we feed trusted Peering.Peers in addition to any peers
discovered over DHT.

* docs(CHANGELOG): document breaking changes

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Gus Eggert <gus@gus.dev>
hannahhoward pushed a commit to filecoin-project/kubo-api-client that referenced this pull request Jun 19, 2023
* update go-libp2p to v0.19.0
* chore: go-namesys v0.5.0
* refactor(config): cleanup relay handling
* docs(config): document updated defaults
* fix(tests): panic during sharness

* fix: t0160-resolve.sh
See ipfs/go-namesys#32

* fix: t0182-circuit-relay.sh
* test: transport encryption

Old tests were no longer working because go-libp2p 0.19 removed
the undocumented 'ls' pseudoprotocol.

This replaces these tests with handshake attempt (name is echoed back on
OK or 'na' is returned when protocol is not available) for tls and noise
variants + adds explicit test that safeguards us against enabling
plaintext by default by a mistake.

* fix: ./t0182-circuit-relay.sh

test is flaky, for now we just restart the testbed when we get
NO_RESERVATION error

* refactor: AutoRelayFeeder with exp. backoff

It starts at feeding peers ever 15s, then backs off each time
until it is done once an hour

Should be acceptable until we have smarter mechanism in go-lib2p 0.20

* feat(AutoRelay): prioritize Peering.Peers

This ensures we feed trusted Peering.Peers in addition to any peers
discovered over DHT.

* docs(CHANGELOG): document breaking changes

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Gus Eggert <gus@gus.dev>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants