-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(network): implement Bitswap protocol support for libp2p network backend #9916
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
base: master
Are you sure you want to change the base?
Conversation
…erver is enabled; docs: mention libp2p support
|
User @yashranaway, please sign the CLA here. |
|
cc: @dmitry-markin |
|
Hi @yashranaway and thanks for looking into this! Unfortunately, Bitswap is not a request-response protocol how it is implemented in the libp2p network backend. It as an asynchronous protocol with requests coming over one substream and responses sent over another, with no limit on the number of messages sent over a substream. libp2p request-response protocol uses the same substream for a pair of request-response messages and closes the substream after the exchange. It can't be used to implement Bitswap, the implementation in libp2p network backend is invalid. In order to implement Bitswap for libp2p network backend you would need to implement a dedicated |
|
@dmitry-markin hey,I've implemented Bitswap as a proper NetworkBehaviour with a custom connection handler that manages persistent bidirectional substreams, as per the Bitswap spec. please let me if any updates are needed |
|
Hey, given the PR looks like AI-generated, can you please:
|
Description
This PR implements Bitswap protocol (
/ipfs/bitswap/1.2.0) support for the libp2p network backend, allowing the--ipfs-serveroption to work with both litep2p and libp2p backends.Closes: #9837
Previously, the
--ipfs-serveroption was only functional with the litep2p network backend. This change ensures compatibility across both network backends by registering the Bitswap request-response protocol in the libp2p backend when transaction storage with IPFS serving is enabled.Integration
This change is backward compatible and requires no action from downstream projects:
--ipfs-servercontinue to work unchanged--ipfs-serverto serve transaction data via Bitswapbitswap_configis present in the network parametersExample usage:
# Now works with libp2p backend (previously only worked with litep2p) ./substrate-node --ipfs-server --network-backend libp2pReview Notes
Implementation approach:
Files modified:
substrate/client/network/src/service.rs: Added Bitswap protocol registration in libp2pNetworkWorker::new()substrate/frame/transaction-storage/README.md: Updated documentation to mention libp2p supportKey changes:
Technical details:
BitswapRequestHandlerimplementation (substrate/client/network/src/bitswap/mod.rs)/ipfs/bitswap/1.2.0protocol in libp2p's request-response protocols listNetworkBackendtrait already providesbitswap_server()method for libp2p backendTesting:
cargo check -p sc-network--ipfs-serverusing libp2p and verify IPFS client can fetch transaction CIDsChecklist
Trequired)AI Disclosure