Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Comments

Filter bitswap records for hydras#163

Merged
willscott merged 2 commits intomasterfrom
indexbitswap
Apr 6, 2022
Merged

Filter bitswap records for hydras#163
willscott merged 2 commits intomasterfrom
indexbitswap

Conversation

@willscott
Copy link
Contributor

Currently, all provider records coming back from storetheindex are being returned to clients.
We should filter that implicitly to only providers advertising bitswap while clients are implicitly expecting that behavior.

@willscott willscott requested a review from aschmahmann April 4, 2022 16:41
Copy link

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

Seems fine, I'm just not sure how we can be certain that bitswap records will only ever start with this varint.

result := make([]peer.AddrInfo, 0, len(parsedResponse.MultihashResults[0].ProviderResults))
for _, m := range parsedResponse.MultihashResults[0].ProviderResults {
result = append(result, m.Provider)
if bytes.HasPrefix(m.Metadata, bitswapPrefix) {

Choose a reason for hiding this comment

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

How do you know that the metadata will have this prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec we settled on says that supported protocols should be uvarints in sorted order. bitswap is the smallest defined transport, so if it's supported it'll be at the beginning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting so the protocols are not in user-specified order? Is this mostly because the current indexer advertisements are not for lists of transports but instead separate advertisements per transport? If so is the a short or longer lived expectation (not that this is relevant to merging this PR specifically, but trying to understand how it'll operate with other systems that allow suggested prioritization/ordering).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a constraint on extending from 1 protocol to an array of them in a backwards compatible way with the current wire protocol.

Once we switch to something compatible with the records being discussed in reframe we'll make a switch once in what we ask from providers and will remove this expectation.

return nil, fmt.Errorf("unexpected number of responses")
}
result := make([]peer.AddrInfo, len(parsedResponse.MultihashResults[0].ProviderResults))
result := make([]peer.AddrInfo, 0, len(parsedResponse.MultihashResults[0].ProviderResults))
Copy link
Contributor

Choose a reason for hiding this comment

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

@guseggert it feels like we should've been getting errors due to this previously no? Any idea why not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think nil results are dropped without error in the combiner

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah they are dropped. What kind of error would you have expected, @aschmahmann ?

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 what's best here and obviously nothing bad happened, but if one of the systems started returning nil provider records to us that'd be a bug we'd potentially want to investigate. Probably just logging would be sufficient though, and ofc not a big rush given we fixed the above issue.

@willscott willscott temporarily deployed to DockerBuilders April 5, 2022 01:36 Inactive
@willscott willscott requested a review from guseggert April 6, 2022 08:46
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