Rework bitswap client and server#12686
Open
skunert wants to merge 31 commits into
Open
Conversation
The bitswap client refactor in the previous commit moved peer selection, per-peer timeouts, retries and hash verification into the bitswap service actor. This commit migrates the only in-tree consumer of the deleted `request_bitswap_blocks` helper. IndexedTransactionFetcher is now a thin adapter over BitswapHandle. It builds per-want CIDs, chunks by MAX_CIDS_PER_REQUEST, submits all chunks concurrently via request_stream, and drains the resulting per-chunk streams. Peer rotation and per-peer timeouts no longer live in this crate. Public surface changes on sc-storage-chain-sync: - removed: BitswapPeerSource, NetworkHandle, SyncingHandle - added: BitswapClient, BitswapHandleSlot The omni-node wiring in polkadot-omni-node-lib is updated accordingly: PartialComponents::other now carries a single BitswapHandleSlot instead of (NetworkHandle, SyncingHandle), and start_node populates it via NetworkService::bitswap_handle() (None when --ipfs-server is disabled or the libp2p backend is in use). The integration tests are rewritten to mock at the BitswapHandle boundary via a MockBitswap implementing BitswapClient. This removes the dependency on prost and the sc-network test-helpers feature for fabricating raw bitswap protobuf messages.
# Conflicts: # substrate/client/storage-chain-sync/src/fetcher.rs
A peer answering HAVE for a wanted CID was marked tried and permanently excluded, so the one peer that advertised having the block was never asked for it again. A first HAVE now keeps the peer eligible and preferred for an immediate WANT-BLOCK re-ask; a second HAVE without the block marks the peer tried (bounding a HAVE-looping peer to two requests per CID).
Once every connected peer was tried for a CID, the want stalled forever: tried_peers was insert-only, so a single timeout or DONT_HAVE from the only data-holding peer parked the CID until a brand-new peer connected, burning the caller's whole fetch budget. An exhausted CID now schedules a new round: after ROUND_RETRY_DELAY the sweep clears its per-round peer state (tried_peers, have_peers) and every connected peer becomes eligible again. Dispatching cancels a scheduled round, so a fresh peer connecting mid-park is used immediately without a duplicate re-ask later.
skunert
force-pushed
the
skunert/bitswap-API-stacked-new
branch
from
July 18, 2026 20:51
ca474c2 to
230fb0f
Compare
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
description TBD