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

bitswap move providing responsabilities from the server to blockservice & reprovider #528

Closed
wants to merge 6 commits into from

Conversation

Jorropo
Copy link
Contributor

@Jorropo Jorropo commented Dec 28, 2023

merge with merge commit, I have an other branch based on this.
Thx

We always had a very weird relationship between bitswap and providing.
Bitswap took care of doing the initial provide and then reprovider did it later.
The Bitswap server had a complicated providing workflow where it slurped thing into memory.

Reprovide accepts provides and is able to queue them in a database, such as on disk, this is much better.

I'll add options to hook initial provide logic from the blockservice to the reprovider queue so consumers don't have to do this themselves.
@Jorropo Jorropo force-pushed the bitswap/request-response branch 2 times, most recently from cf417f4 to 3b17bf2 Compare December 28, 2023 22:12
Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 45 lines in your changes are missing coverage. Please review.

Comparison is base (483bc39) 65.62% compared to head (a04b38e) 65.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #528      +/-   ##
==========================================
- Coverage   65.62%   65.19%   -0.44%     
==========================================
  Files         207      206       -1     
  Lines       25549    25232     -317     
==========================================
- Hits        16766    16449     -317     
+ Misses       7317     7307      -10     
- Partials     1466     1476      +10     
Files Coverage Δ
bitswap/bitswap.go 69.51% <ø> (+2.07%) ⬆️
bitswap/client/client.go 86.86% <100.00%> (-3.56%) ⬇️
...tswap/client/internal/messagequeue/messagequeue.go 83.53% <ø> (-1.39%) ⬇️
bitswap/network/ipfs_impl.go 80.00% <100.00%> (+3.40%) ⬆️
bitswap/options.go 44.44% <100.00%> (ø)
bitswap/server/server.go 58.50% <100.00%> (-7.97%) ⬇️
bitswap/testnet/peernet.go 38.46% <100.00%> (-4.40%) ⬇️
blockservice/test/mock.go 100.00% <100.00%> (ø)
examples/unixfs-file-cid/main.go 41.21% <100.00%> (ø)
bitswap/testinstance/testinstance.go 88.23% <92.30%> (+2.02%) ⬆️
... and 3 more

... and 8 files with indirect coverage changes

…bilities to an option of the client

Given that the previous commit remove the content advertising from the server, it did not made sense to share these paths on the network.

The code has been reworked:
- addresses aren't magically added to the peerstore as a side-effect of calling `Network.FindProvidersAsync`. Instead they are passed as hints to ConnectTo which copies libp2p `host.ConnectTo` API.
- the providerquerymanager is completely shutdown when not using `WithContentSearch` option, this helps usecase where `routinghelpers.Null` is used for content routing and the consumer exclusively rely on broadcast, like networks where most peoples have all the content (Filecoin, Celestia, ...).
@Jorropo Jorropo changed the title bitswap improvements bitswap move providing responsabilities from the server to blockservice & reprovider Dec 29, 2023
@Jorropo Jorropo marked this pull request as ready for review December 29, 2023 01:09
@Jorropo Jorropo requested a review from a team as a code owner December 29, 2023 01:09
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Jorropo added a commit to Jorropo/lassie that referenced this pull request Dec 29, 2023
This allows to recreate the behavior of advertising added blocks the bitswap server used to do.
blockservice is explicitely tolerent to having a nil exchange.
The constructor even logs that as running an offline blockservice.

Everything is except close, which panics.

It is confusing for consumers to only have to call close based on if it's online or offline.
They could also instead call close directly on the exchange (then we could remove blockservice's Close method).

Anyway here is as a simple fix, add a nil check.
@Jorropo Jorropo mentioned this pull request Dec 29, 2023
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Closes: #172
See #172 (comment) too.

providerQueryManager took care of:
- Deduping multiple sessions doing find providers for the same CID.
- limiting global find providers.

None of which we care:
- This is rare, if this happens it's fine to run the same query twice.
  If we care then we should make a deduping content router so we can inject it anywhere a content router is needed.
- It's fine to allow one concurrent find peer per session. No need to limit this at 6 globally after that, it's a great way to stall nodes doing many queries.
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
Jorropo added a commit to ipfs/kubo that referenced this pull request Dec 29, 2023
@Jorropo Jorropo closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant