Skip to content

Add Bitswap client#501

Merged
dmitry-markin merged 5 commits intomasterfrom
dm-bitswap-client
Dec 18, 2025
Merged

Add Bitswap client#501
dmitry-markin merged 5 commits intomasterfrom
dm-bitswap-client

Conversation

@dmitry-markin
Copy link
Copy Markdown
Collaborator

@dmitry-markin dmitry-markin commented Dec 12, 2025

Implement Bitswap client. This is needed to benchmark data retrieval from transaction storage.

Additionally, outbound substreams are now reused for subsequent messages (there is a limit of one outbound substream per peer).

@dmitry-markin dmitry-markin requested a review from lexnv December 12, 2025 14:52
@dmitry-markin dmitry-markin self-assigned this Dec 12, 2025
@dmitry-markin dmitry-markin added the enhancement New feature or request label Dec 12, 2025
@dmitry-markin dmitry-markin marked this pull request as ready for review December 12, 2025 14:52
) {
let Some(entries) = self.pending_outbound.remove(&substream_id) else {
let Some(actions) = self.pending_outbound.remove(&peer) else {
tracing::warn!(target: LOG_TARGET, ?peer, ?substream_id, "pending outbound entry doesn't exist");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

dq: Should we check the pending_dials here? Thinking of cases where we might receive this before on_connection_established but looks unlikely

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TransportManager should deliver events in order, so this should not be possible.

}
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

dq: Unrelated to these changes, we have an self.inbound.remove(&peer) above. However, there's a high likelyhood that if the inbound is broken, the outboud is as well. Should cleanup the outbound and force a reconnection?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There may be legitimate cases where inbound fails (i.e., some implementations can close the outbound after sending just one request, like litep2p did before this PR), but outbound is fine.

The current code will fail fast if writing to the outbound fails and request a reconnection, so it shouldn't be a problem anyway.

Copy link
Copy Markdown
Collaborator

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

Code looks solid! Left some questions about the bitswap to understand our implementation a bit better 🙏

@dmitry-markin dmitry-markin merged commit 9954bf6 into master Dec 18, 2025
8 checks passed
@dmitry-markin dmitry-markin deleted the dm-bitswap-client branch December 18, 2025 13:20
@github-project-automation github-project-automation bot moved this to Blocked ⛔️ in Networking Dec 18, 2025
dmitry-markin added a commit that referenced this pull request Jan 21, 2026
## [0.13.0] - 2026-01-21

This release brings multiple fixes to both the transport and
application-level protocols.

Specifically, it enhances WebSocket stability by resolving AsyncWrite
errors and ensuring that partial writes during the negotiation phase no
longer trigger connection failures.

At the same time, Bitswap client functionality is introduced, which
makes this release semver breaking.

### Added

- Add Bitswap client
([#501](#501))

### Fixed

- notif/fix: Avoid CPU busy loops on litep2p full shutdown
([#521](#521))
- protocol: Ensure transport manager knows about closed connections
([#515](#515))
- substream: Decrement the bytes counter to avoid excessive flushing
([#511](#511))
- crypto/noise: Improve stability of websockets by fixing AsyncWrite
implementation ([#518](#518))
- bitswap: Split block responses into batches under 2 MiB
([#516](#516))
- crypto/noise: Fix connection negotiation logic on partial writes
([#519](#519))
- substream/fix: Fix partial reads for ProtocolCodec::Identity
([#512](#512))
- webrtc: Avoid panics returning error instead
([#509](#509))
- bitswap: e2e test & max payload fix
([#508](#508))
- tcp: Exit connections when events fail to propagate to protocols
([#506](#506))
- webrtc: Avoid future being dropped when channel is full
([#483](#483))

---------

Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Blocked ⛔️

Development

Successfully merging this pull request may close these issues.

2 participants