Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
795e110
Refactor bitswap client
skunert Jun 2, 2026
d3814a8
sc-storage-chain-sync: adapt to new bitswap BitswapHandle API
skunert Jun 8, 2026
105b3de
Improve readability
skunert Jun 9, 2026
6587bc9
Use sync events
skunert Jun 24, 2026
7f77a03
Move bitswap service to own crate
skunert Jul 3, 2026
27d8c46
Remove unwanted file, fix closed channel bug
skunert Jul 2, 2026
75fa92a
Clean up
skunert Jul 3, 2026
0e98773
Restore base-branch changes lost during rebase, drop unused rand dep
skunert Jul 3, 2026
c41d8ed
Remove unneeded limit
skunert Jul 3, 2026
e67dc17
Remove CID limit, move timeout to caller
skunert Jul 15, 2026
b424172
Treat HAVE as a positive signal
skunert Jul 15, 2026
215cba3
Retry unresolved CIDs in rounds
skunert Jul 15, 2026
3af6891
Drop unused deps, deduplicate test rig helpers
skunert Jul 15, 2026
7771bba
Improve response handling, reset tried_peers
skunert Jul 16, 2026
0d16cb8
Use rstest for testing
skunert Jul 16, 2026
82c50e6
Add proptest
skunert Jul 16, 2026
e5c8720
Clean up comments, add metrics
skunert Jul 16, 2026
27519d4
Add inbound queue for server
skunert Jul 17, 2026
46d004e
Fix permit handling
skunert Jul 17, 2026
384d983
Introduce phase enum
skunert Jul 17, 2026
4150275
Remove bitswap init struct.
skunert Jul 17, 2026
2f861f6
Make Cid conversion more elegant
skunert Jul 18, 2026
b0c7697
Simplify fetch timeout
skunert Jul 18, 2026
bebf8a5
Remove by_cid hashmap
skunert Jul 18, 2026
be483ce
Remove expects
skunert Jul 18, 2026
e21505f
Improve comments
skunert Jul 18, 2026
520d413
fmt
skunert Jul 18, 2026
dbddd15
Split tests out into separate file
skunert Jul 18, 2026
183166e
Remove wrong prdoc
skunert Jul 18, 2026
230fb0f
prdoc
skunert Jul 18, 2026
51763d3
Fix umbrella crate
skunert Jul 19, 2026
b39eedd
Fix prdoc
skunert Jul 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ members = [
"substrate/client/mixnet",
"substrate/client/network",
"substrate/client/network-gossip",
"substrate/client/network/bitswap",
"substrate/client/network/common",
"substrate/client/network/light",
"substrate/client/network/statement",
Expand Down Expand Up @@ -1268,6 +1269,7 @@ sc-informant = { path = "substrate/client/informant", default-features = false }
sc-keystore = { path = "substrate/client/keystore", default-features = false }
sc-mixnet = { path = "substrate/client/mixnet", default-features = false }
sc-network = { path = "substrate/client/network", default-features = false }
sc-network-bitswap = { path = "substrate/client/network/bitswap", default-features = false }
sc-network-common = { path = "substrate/client/network/common", default-features = false }
sc-network-gossip = { path = "substrate/client/network-gossip", default-features = false }
sc-network-light = { path = "substrate/client/network/light", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions cumulus/client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ prometheus = { workspace = true }
sc-client-api = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-network-bitswap = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
sc-network-transactions = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
Expand Down
1 change: 1 addition & 0 deletions cumulus/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ pub async fn build_network<'a, Block, Client, RCInterface, IQ, Network>(
TracingUnboundedSender<sc_rpc::system::Request<Block>>,
TransactionsHandlerController<Block::Hash>,
Arc<SyncingService<Block>>,
Option<sc_network_bitswap::BitswapHandle>,
)>
where
Block: BlockT,
Expand Down
25 changes: 9 additions & 16 deletions cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use sc_network::{
use sc_service::{Configuration, ImportQueue, PartialComponents, TaskManager};
use sc_statement_store::Store;
use sc_storage_chain_sync::{
IndexedTransactionFetcher, NetworkHandle, StorageChainBlockImport, SyncingHandle,
BitswapHandleSlot, IndexedTransactionFetcher, StorageChainBlockImport,
};
use sc_sysinfo::HwBench;
use sc_telemetry::{TelemetryHandle, TelemetryWorker};
Expand Down Expand Up @@ -298,13 +298,9 @@ pub(crate) trait BaseNodeSpec {
.build(),
);

let network_handle: NetworkHandle = Arc::new(OnceLock::new());
let syncing_handle: SyncingHandle = Arc::new(OnceLock::new());
let bitswap_slot: BitswapHandleSlot = Arc::new(OnceLock::new());

let fetcher = IndexedTransactionFetcher::new(
Arc::clone(&network_handle),
Arc::clone(&syncing_handle),
);
let fetcher = IndexedTransactionFetcher::new(Arc::clone(&bitswap_slot));

let storage_chain_block_import =
StorageChainBlockImport::new(client.clone(), client.clone(), fetcher);
Expand Down Expand Up @@ -335,8 +331,7 @@ pub(crate) trait BaseNodeSpec {
telemetry,
telemetry_worker_handle,
block_import_auxiliary_data,
network_handle,
syncing_handle,
bitswap_slot,
),
})
}
Expand Down Expand Up @@ -404,8 +399,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
mut telemetry,
telemetry_worker_handle,
block_import_auxiliary_data,
network_handle,
syncing_handle,
bitswap_slot,
) = params.other;
let client = params.client.clone();
let backend = params.backend.clone();
Expand Down Expand Up @@ -450,7 +444,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
(proto, config)
});

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
let (network, system_rpc_tx, tx_handler_controller, sync_service, bitswap_handle) =
build_network(BuildNetworkParams {
parachain_config: &parachain_config,
net_config,
Expand All @@ -466,10 +460,9 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
})
.await?;

let _ = network_handle
.set(network.clone() as Arc<dyn sc_network::NetworkRequest + Send + Sync>);
let _ = syncing_handle.set(sync_service.clone()
as Arc<dyn sc_storage_chain_sync::BitswapPeerSource + Send + Sync>);
if let Some(handle) = bitswap_handle {
let _ = bitswap_slot.set(Arc::new(handle));
}

let peer_id = relay_chain_network.local_peer_id();

Expand Down
3 changes: 1 addition & 2 deletions cumulus/polkadot-omni-node/lib/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub type ParachainService<Block, RuntimeApi, BI, BIExtraReturnValue> = PartialCo
Option<Telemetry>,
Option<TelemetryWorkerHandle>,
BIExtraReturnValue,
sc_storage_chain_sync::NetworkHandle,
sc_storage_chain_sync::SyncingHandle,
sc_storage_chain_sync::BitswapHandleSlot,
),
>;
4 changes: 2 additions & 2 deletions cumulus/polkadot-omni-node/lib/src/nodes/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ where
keystore_container,
select_chain: _,
transaction_pool,
other: (_, mut telemetry, _, _, _, _),
other: (_, mut telemetry, _, _, _),
} = Self::new_partial(&config)?;

// Since this is a dev node, prevent it from connecting to peers.
Expand All @@ -276,7 +276,7 @@ where
(proto, *ss_config)
});

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
let (network, system_rpc_tx, tx_handler_controller, sync_service, _bitswap_handle) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
Expand Down
2 changes: 1 addition & 1 deletion cumulus/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ where
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
tracing::info!("Parachain id: {:?}", para_id);

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
let (network, system_rpc_tx, tx_handler_controller, sync_service, _bitswap_handle) =
build_network(BuildNetworkParams {
parachain_config: &parachain_config,
net_config,
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/service/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ where
})
};

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
let (network, system_rpc_tx, tx_handler_controller, sync_service, _bitswap_handle) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
net_config,
Expand Down
31 changes: 31 additions & 0 deletions prdoc/pr_12686.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
title: Extract and refactor the Bitswap service
doc:
- audience: Node Dev
description: |-
Moves the Bitswap client and server from `sc-network` into the new
`sc-network-bitswap` crate. The new actor exposes a streaming `BitswapHandle` and
centralizes CID deduplication, peer selection, retries, response handling, and
backpressure. Storage-chain sync and node service wiring now use this handle.

The backend-specific Bitswap shims and local protobuf plumbing are removed. Bitswap
is now supported through Litep2p only; starting a node with `--ipfs-server` and a
different network backend returns an error.
crates:
- name: sc-network-bitswap
bump: patch
- name: sc-network
bump: major
- name: sc-service
bump: major
validate: false
- name: sc-storage-chain-sync
bump: major
- name: cumulus-client-service
bump: major
validate: false
- name: polkadot-service
bump: patch
- name: polkadot-omni-node-lib
bump: major
- name: polkadot-sdk
bump: minor
2 changes: 1 addition & 1 deletion substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
Vec::default(),
));

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
let (network, system_rpc_tx, tx_handler_controller, sync_service, _bitswap_handle) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
net_config,
Expand Down
6 changes: 0 additions & 6 deletions substrate/client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ parking_lot = { workspace = true, default-features = true }
partial_sort = { workspace = true }
pin-project = { workspace = true }
prometheus-endpoint = { workspace = true, default-features = true }
prost = { workspace = true }
rand = { workspace = true, default-features = true }
rustls = { workspace = true }
sc-client-api = { workspace = true, default-features = true }
Expand All @@ -60,7 +59,6 @@ smallvec = { workspace = true, default-features = true }
sp-arithmetic = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio = { features = ["macros", "sync"], workspace = true, default-features = true }
Expand All @@ -72,7 +70,6 @@ zeroize = { workspace = true, default-features = true }

[dev-dependencies]
assert_matches = { workspace = true }
multihash-codetable = { workspace = true }
multistream-select = { workspace = true }
sc-block-builder = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
Expand All @@ -85,8 +82,5 @@ tokio-util = { features = ["compat"], workspace = true }

criterion = { workspace = true, default-features = true, features = ["async_tokio"] }

[build-dependencies]
prost-build = { workspace = true }

[features]
default = []
46 changes: 46 additions & 0 deletions substrate/client/network/bitswap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[package]
description = "Substrate Bitswap client/server service"
name = "sc-network-bitswap"
version = "0.1.0"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true
documentation = "https://docs.rs/sc-network-bitswap"

[lints]
workspace = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = { workspace = true }
cid = { workspace = true }
futures = { workspace = true }
litep2p = { workspace = true }
log = { workspace = true, default-features = true }
prometheus-endpoint = { workspace = true, default-features = true }
rand = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
sc-network-common = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
slotmap = { workspace = true }
smallvec = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio = { features = ["macros", "rt", "sync", "time"], workspace = true, default-features = true }

[dev-dependencies]
proptest = { workspace = true }
rstest = { workspace = true }
sc-block-builder = { workspace = true, default-features = true }
sc-network-types = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true, default-features = true }
substrate-test-runtime = { workspace = true }
substrate-test-runtime-client = { workspace = true }
tokio = { features = ["macros", "rt-multi-thread", "test-util"], workspace = true, default-features = true }
tokio-stream = { workspace = true }
Loading
Loading