8000 Use go-fetcher, unixfsnode, and ipld-prime to resolve paths. by acruikshank · Pull Request #34 · ipfs/go-path · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Use go-fetcher, unixfsnode, and ipld-prime to resolve paths. #34

Merged
merged 8 commits into from
Apr 2, 2021

Conversation

acruikshank
Copy link
Contributor

Motivation

We are moving IPFS to use ipld-prime (via go-fetcher) for graph traversal. This PR replaces the path traversal algorithm in go-path's resolver with ipld-prime queries using a path selector.

This PR depends on linksystem changes to ipld-prime and must remain a draft until that PR lands.

What's in this PR

  • Create new prototype chooser that gives the new unixfsnode ADL prototype to unixfs protobuf nodes to permit path traversal.
  • Create path ipld-prime selectors.
  • Replace resolver logic with go-fetcher queries.
  • Modify tests to accept new unixfsnode output.

@welcome

This comment has been minimized.

@acruikshank acruikshank requested a review from willscott March 12, 2021 15:11
@acruikshank acruikshank changed the title first pass Use go-fetcher, unixfsnode, and ipld-prime to resolve paths. Mar 12, 2021
Copy link
@willscott willscott left a comment

Choose a reason for hiding this comment

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

super cool to see the more direct ability to path through ipldprime!

Comment on lines +58 to +59
func NewBasicResolver(bs blockservice.BlockService) *Resolver {
fc := fetcher.NewFetcherConfig(bs)

Choose a reason for hiding this comment

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

is it possible we'll want a single fetcher both for pathing and other things, and will want to pass in a fetchconfig here directly? (i guess we can make a Resolver struct if we need to do that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a little tricky. FetcherConfig owns the PrototypeChooser and go-path needs a custom PrototypeChooser to ensure it can path into dagpb nodes using the unixfsnode ADL. We probably don't want to push responsibility for constructing the correct chooser to the caller and we can't have go-path reconfigure a shared FetchConfig.

We could potentially pass the chooser into the GetSession call in go-fetcher (which would be called with a specific chooser in go-path/BasicResolver, but I'd want to get a better sense of the kinds of things that might need to be shared in a FetchConfig (other than blockservice) before making that kind of refactor.

default:
return nd.Cid(), p, nil
clnk, ok := lnk.(cidlink.Link)
if !ok {

Choose a reason for hiding this comment

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

eventually we may want to have a slow fallback of
cid.ParseString(lnk.String()) to support other concrete cid types.

cc @warpfork on thoughts on if needed / other ways to make our life remain extensible here.

Copy link
Member

Choose a reason for hiding this comment

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

nah, honestly I don't even know if the whole , ok and branch seems relevant to me.

It doesn't hurt anything to ask the cast rather than assert it, but I'd say that it's legitimately a compile-time bug if a program encounters an unexpected concrete type inside this interface, and so if this wanted to panic when that fails, that would make sense to me.

Co-authored-by: Eric Myhre <hash@exultant.us>
Comment on lines +54 to +56
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
Copy link
Member
@warpfork warpfork Mar 12, 2021

Choose a reason for hiding this comment

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

This isn't really constructive criticism for this PR, per se (because a lot of these existed before this PR too, and I'm just noticing them for the first time)... but... I want to make this comment somewhere, if for no other reason that being able to refer to it in other discussions in the future...

holy smokes. These dependencies. These are not things that I would expect.

github.com/envoyproxy/go-control-plane is a doozy. github.com/client9/misspell is also a doozy. github.com/btcsuite/btcd is a doozy. github.com/gopherjs/gopherjs is a superdoozy. And there's some CLI flag libraries. And a DNS library. And... I'm drowning in doozies.

It's not a job for this PR, but some kind of understanding about what the heck is going on with this module and its transitive dependencies needs to be reached in the future. Something's gone significantly off the rails, fallen into a wormhole, and appeared in the andromeda galaxy at some point.

@acruikshank acruikshank marked this pull request as ready for review March 18, 2021 15:39
Comment on lines 47 to 51
// Resolver provides path resolution to IPFS
// It has a pointer to a DAGService, which is uses to resolve nodes.
// It has a pointer to a FetcherConfig, which is uses to resolve nodes.
// TODO: now that this is more modular, try to unify this code with the
// the resolvers in namesys
type Resolver struct {
Copy link
Member

Choose a reason for hiding this comment

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

I could use more docs on this. I see there weren't a ton before, either, but if we're gonna lug this into the future, it would be good to have some comments on whether its shape is intentful or primarily legacy driven; any notes about what it doesn't do, etc.

Copy link
Member

Choose a reason for hiding this comment

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

I'm kinda wondering, throughout this whole file:

What's a Resolver for, vs using traverse.* on the nodes? (Is it just legacy API satisfying to try to reduce change splash size? Fine, but we should mark wherever that reasoning is used; that information failing to transfer to the next person working in this area would be devastating to that person's ability to plan changes.)

Is FetcherConfig adding any key data vs traversal.Config? Or did we accidentally create a similar abstraction twice, and we should try to simplify it back to one? If there is key data it adds that makes it suitable for Resolver -- what is it?

Copy link
Member

Choose a reason for hiding this comment

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

Should we be trying to push a lot harder on the ADL'ization of pathing over unixfsv1 stuff? If we do so, can we make this Resolver thing a much thinner facade over that?

@hannahhoward hannahhoward changed the base branch from master to feat/ipld-in-ipfs April 2, 2021 18:07
@hannahhoward hannahhoward merged commit 65ea051 into feat/ipld-in-ipfs Apr 2, 2021
hannahhoward added a commit that referenced this pull request Jul 22, 2021
* first pass

* Update resolver/resolver.go

Co-authored-by: Eric Myhre <hash@exultant.us>

* update dependencies to tagged versions

* correctly handles nested nodes within blocks

* return link from resolve path so we can fetch container block

* return expected NoSuchLink error

* more accurate errors

* feat(resolver): remove resolve once

remove ResolveOnce as it's no longer used and is just confusing

Co-authored-by: acruikshank <acruikshank@example.com>
Co-authored-by: Eric Myhre <hash@exultant.us>
Co-authored-by: hannahhoward <hannah@hannahhoward.net>
hannahhoward added a commit that referenced this pull request Aug 12, 2021
* Use go-fetcher, unixfsnode, and ipld-prime to resolve paths. (#34)

* first pass

* Update resolver/resolver.go

Co-authored-by: Eric Myhre <hash@exultant.us>

* update dependencies to tagged versions

* correctly handles nested nodes within blocks

* return link from resolve path so we can fetch container block

* return expected NoSuchLink error

* more accurate errors

* feat(resolver): remove resolve once

remove ResolveOnce as it's no longer used and is just confusing

Co-authored-by: acruikshank <acruikshank@example.com>
Co-authored-by: Eric Myhre <hash@exultant.us>
Co-authored-by: hannahhoward <hannah@hannahhoward.net>

* fix(update to tagged branches): update to tagged branches and use node reifier

* fix(deps): update go-unixfsnode

* fix(deps): update to latest go fetcher (#37)

* feat(resolver): take fetcher config as parameter (#38)

* fix(deps): switch to tagged go-fetcher

* fix(resolver): removed ipldcbor dependency

* fix(mod): remove unneeded deps

* fix(resolver): correct comments

* test(resolver): add test verifying ErrNoLink functionality

* fix(lint): fix lint errors

resolve go vet and staticcheck issues. note we had to ignore two lines that use deprecated
behavior, but which replacing could have unintended effects

* fix(resolver): LookupBySegment to handle list indexes as well as map fields (#42)

* fix(resolver): LookupBySegment to handle list indexes as well as map fields

* Add test for /mixed/path/segment/types/1/2/3

* feat(resolver): address more PR comments

* style(tests): add clarification

* style(lint): fix lint errors, redo test fix

* fix(deps): update deps to tagged version

Co-authored-by: Alex Cruikshank <169613+acruikshank@users.noreply.github.com>
Co-authored-by: acruikshank <acruikshank@example.com>
Co-authored-by: Eric Myhre <hash@exultant.us>
Co-authored-by: Rod Vagg <rod@vagg.org>
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.

4 participants
0