Skip to content

Rework bitswap client and server#12686

Open
skunert wants to merge 31 commits into
masterfrom
skunert/bitswap-API-stacked-new
Open

Rework bitswap client and server#12686
skunert wants to merge 31 commits into
masterfrom
skunert/bitswap-API-stacked-new

Conversation

@skunert

@skunert skunert commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

description TBD

skunert added 10 commits July 18, 2026 20:20
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
@skunert
skunert requested a review from a team as a code owner July 18, 2026 20:43
@skunert skunert added the T0-node This PR/Issue is related to the topic “node”. label Jul 18, 2026
skunert and others added 18 commits July 18, 2026 22:47
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
skunert force-pushed the skunert/bitswap-API-stacked-new branch from ca474c2 to 230fb0f Compare July 18, 2026 20:51
@paritytech paritytech deleted a comment from cla-bot-2021 Bot Jul 18, 2026
@paritytech-workflow-stopper

Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/29660506096
Failed job name: check-runtime-compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant