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

Add an HTTP retrieval protocol #193

Merged
merged 16 commits into from
May 12, 2023
Merged

Add an HTTP retrieval protocol #193

merged 16 commits into from
May 12, 2023

Conversation

willscott
Copy link
Contributor

@willscott willscott commented Apr 20, 2023

remaining work in my head:

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2023

Codecov Report

Merging #193 (3a6d025) into main (a10856b) will increase coverage by 0.30%.
The diff coverage is 79.32%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #193      +/-   ##
==========================================
+ Coverage   70.86%   71.16%   +0.30%     
==========================================
  Files          63       68       +5     
  Lines        5307     6063     +756     
==========================================
+ Hits         3761     4315     +554     
- Misses       1348     1505     +157     
- Partials      198      243      +45     
Impacted Files Coverage Δ
cmd/lassie/flags.go 0.00% <ø> (ø)
pkg/internal/itest/unixfs/generator.go 95.55% <ø> (ø)
pkg/internal/testutil/mockclient.go 52.17% <33.33%> (-1.24%) ⬇️
...kg/internal/testutil/collectingeventlsubscriber.go 52.88% <44.00%> (-5.07%) ⬇️
pkg/session/session.go 57.14% <45.45%> (-1.95%) ⬇️
pkg/internal/testutil/mockcandidatefinder.go 83.33% <50.00%> (ø)
pkg/retriever/directcandidatefinder.go 64.80% <50.00%> (-1.31%) ⬇️
pkg/internal/itest/testpeer/generator.go 63.09% <54.33%> (-7.74%) ⬇️
pkg/internal/testutil/gen.go 92.94% <62.50%> (-7.06%) ⬇️
pkg/internal/itest/testpeer/peerhttpserver.go 65.71% <65.71%> (ø)
... and 14 more

... and 4 files with indirect coverage changes

pkg/retriever/directcandidatefinder.go Show resolved Hide resolved
clock clock.Clock,
awaitReceivedCandidates chan<- struct{},
initialPause time.Duration,
customCompare func(a, b ComparableCandidate, mda, mdb metadata.Protocol) bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

are these worth being options? maybe a subsequent refactor

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, so this is NewHttpRetrieverWithDeps() which is intended for instantiating for testing. NewHttpRetriever() is the normal path with defaults. We've been using this pattern in a few places, including NewGraphsyncRetrieverWithConfig and NewBitswapRetrieverFromDeps.

The customCompare is particularly shameful because it's only a testing option so we get to control candidate order. #197 #92 should make this go away. Also if we move logic into Connect() then we have something to measure (and control) at least, like we do with Graphsync.

return a.Duration < b.Duration
}

func (ph *ProtocolHttp) Connect(ctx context.Context, retrieval *retrieval, candidate types.RetrievalCandidate) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

one option is to start the net.Dial or tls.Dial at this point, so that you then have that dialing time to use for comparing candidates

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if something like this was possible (hence my questions to you about using libp2p's http client). I might need some pointers on how to achieve the desired result. Having something to put in Connect() would help both warm things up but also give us some timing data to help with priorisation.

log.Warnf("Couldn't construct a http request %s: %v", candidate.MinerPeer.ID, err)
return nil, fmt.Errorf("%w for peer %s: %v", ErrBadPathForRequest, candidate.MinerPeer.ID, err)
}
req.Header.Add("Accept", request.Scope.AcceptHeader())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

are there user agent / other headers that should be here?

@rvagg rvagg force-pushed the feat/http branch 2 times, most recently from c94e0de to 6810ff2 Compare May 10, 2023 07:17
willscott and others added 14 commits May 12, 2023 11:50
based on bitswap unit test framework
* too-detailed http testing, will remove this in favour of graphsync
  style testing.
* feat(verifiedcar): initial verifiedcar package

* feat(verifiedcar): verify http retrievals

* chore(verifiedcar): tests for basic error cases

* fix(verifiedcar): coverage of more cases, handle known edges properly

* fix(verifiedcar): remove extraneous go-routine (#226)

Co-authored-by: Rod Vagg <rod@vagg.org>

* fix(verifiedcar): address feedback

* fix(verifiedcar): fix flaky tests

---------

Co-authored-by: Hannah Howard <hannah@hannahhoward.net>
kylehuntsman and others added 2 commits May 11, 2023 19:35
* test: add itests for http

* test: add peer http server, minor refactors and fixes
Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

#Approved

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

#Approved

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

#Approved

@hannahhoward hannahhoward merged commit 70641fe into main May 12, 2023
@kylehuntsman kylehuntsman deleted the feat/http branch May 24, 2023 21:02
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.

5 participants