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

feat: attempt translate filecoin SP-like provider addresses with heyfil #441

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented Sep 29, 2023

One for you to review @willscott.

This ends up being a complete noop if none of the provided addresses look like they can be translated. So for current usage this is entirely transparent, but as soon as someone provides an f0\d+ or just a plain peer ID, it'll try and use heyfil to fill in the blank.

I don't have a good example handy of a specific bit of content and a working SP, but this one should work for some known content that the SP claims to be storing, using both forms:

Screenshot 2023-09-29 at 10 42 53 pm Screenshot 2023-09-29 at 10 41 57 pm

@rvagg rvagg requested a review from willscott September 29, 2023 12:43
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

Merging #441 (8ad02d4) into rvagg/--provider-http-shortcuts (b33092c) will decrease coverage by 0.49%.
The diff coverage is 51.51%.

Additional details and impacted files

Impacted file tree graph

@@                         Coverage Diff                         @@
##           rvagg/--provider-http-shortcuts     #441      +/-   ##
===================================================================
- Coverage                            76.40%   75.91%   -0.49%     
===================================================================
  Files                                   85       86       +1     
  Lines                                 6458     6586     +128     
===================================================================
+ Hits                                  4934     5000      +66     
- Misses                                1259     1305      +46     
- Partials                               265      281      +16     
Files Coverage Δ
cmd/lassie/flags.go 51.02% <40.00%> (-3.33%) ⬇️
pkg/server/http/ipfs.go 89.62% <62.50%> (-0.98%) ⬇️
cmd/lassie/fetch.go 33.62% <0.00%> (-0.61%) ⬇️
pkg/heyfil/heyfil.go 53.50% <53.50%> (ø)

... and 5 files with indirect coverage changes

Comment on lines 105 to 112
if isPeerId(s) {
res, err := h.translatePeerId(s)
if err != nil {
logger.Debugw("failed to translate peer id", "input", s, "err", err)
return "", err
}
return res, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if this is net good or net bad - it'd be better to have this part use the delegated peer routing more generally, since many peers may not be fil specific. cc @masih

Copy link
Member Author

Choose a reason for hiding this comment

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

Keep in mind that current behaviour would reject peer IDs entirely. They must be fully formed multiaddrs with a peer ID on the end. So this is strictly additive in that it'll now accept at least some subset of resolvable peer IDs, it's just that subset that heyfil can tell us.

We could just stick to f0 addresses for now to keep it simpler, I just figure that as long as there's an easy way to reject fewer types of input then we may as well try.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd stick to f0 for now

if len(addrs) == 0 {
return "", fmt.Errorf("expected addr_info.Addrs to be non-empty")
}
addr, ok := addrs[0].(string)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is probably flawed. It expects at least one Addr and uses the first. It could potentially use multiple addresses and just treat them as separate providers to try. I'm just not sure what's typically recorded here by SPs.

disabled in code, but can still be done in the heyfil package
@rvagg rvagg force-pushed the rvagg/--provider-heyfil branch from 14e022a to 8ad02d4 Compare October 2, 2023 06:30
@rvagg rvagg merged commit ab11c2b into rvagg/--provider-http-shortcuts Oct 2, 2023
@rvagg rvagg deleted the rvagg/--provider-heyfil branch October 2, 2023 06:54
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.

3 participants