diff --git a/Cargo.lock b/Cargo.lock
index e99d44d8e6db..f5de814ed7d1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -885,30 +885,6 @@ dependencies = [
"constant_time_eq",
]
-[[package]]
-name = "blake2s_simd"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae"
-dependencies = [
- "arrayref",
- "arrayvec 0.7.4",
- "constant_time_eq",
-]
-
-[[package]]
-name = "blake3"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87"
-dependencies = [
- "arrayref",
- "arrayvec 0.7.4",
- "cc",
- "cfg-if",
- "constant_time_eq",
-]
-
[[package]]
name = "block-buffer"
version = "0.7.3"
@@ -1231,19 +1207,6 @@ dependencies = [
"half",
]
-[[package]]
-name = "cid"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9b68e3193982cd54187d71afdb2a271ad4cf8af157858e9cb911b91321de143"
-dependencies = [
- "core2",
- "multibase",
- "multihash",
- "serde",
- "unsigned-varint",
-]
-
[[package]]
name = "cipher"
version = "0.2.5"
@@ -5070,14 +5033,10 @@ version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40"
dependencies = [
- "blake2b_simd",
- "blake2s_simd",
- "blake3",
"core2",
"digest 0.10.7",
"multihash-derive",
"sha2 0.10.8",
- "sha3",
"unsigned-varint",
]
@@ -8416,32 +8375,6 @@ dependencies = [
"zeroize",
]
-[[package]]
-name = "sc-network-bitswap"
-version = "0.10.0-dev"
-dependencies = [
- "async-channel",
- "cid",
- "futures",
- "libp2p-identity",
- "log",
- "prost",
- "prost-build",
- "sc-block-builder",
- "sc-client-api",
- "sc-consensus",
- "sc-network",
- "sp-blockchain",
- "sp-consensus",
- "sp-core",
- "sp-runtime",
- "substrate-test-runtime",
- "substrate-test-runtime-client",
- "thiserror",
- "tokio",
- "unsigned-varint",
-]
-
[[package]]
name = "sc-network-common"
version = "0.10.0-dev"
@@ -8776,7 +8709,6 @@ dependencies = [
"sc-informant",
"sc-keystore",
"sc-network",
- "sc-network-bitswap",
"sc-network-common",
"sc-network-light",
"sc-network-sync",
@@ -9195,18 +9127,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.192"
+version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
+checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.192"
+version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
+checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [
"proc-macro2",
"quote",
diff --git a/Cargo.toml b/Cargo.toml
index de0015912b64..ce2e062765d3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,7 +48,6 @@ members = [
"substrate/client/mixnet",
"substrate/client/network-gossip",
"substrate/client/network",
- "substrate/client/network/bitswap",
"substrate/client/network/common",
"substrate/client/network/light",
"substrate/client/network/sync",
diff --git a/removed_folders.txt b/removed_folders.txt
index 2a4fca5ce9a4..11eb0a1722e4 100644
--- a/removed_folders.txt
+++ b/removed_folders.txt
@@ -13,6 +13,7 @@
./substrate/client/consensus/merkle-mountain-range
./substrate/client/consensus/pow
./substrate/client/merkle-mountain-range
+./substrate/client/network/bitswap
./substrate/client/network/statement
./substrate/client/rpc/src/statement
./substrate/client/rpc-api/src/statement
diff --git a/substrate/client/cli/src/params/network_params.rs b/substrate/client/cli/src/params/network_params.rs
index c59f8a1ea4e2..9d830561eff6 100644
--- a/substrate/client/cli/src/params/network_params.rs
+++ b/substrate/client/cli/src/params/network_params.rs
@@ -129,10 +129,6 @@ pub struct NetworkParams {
#[arg(long, default_value = "20")]
pub kademlia_replication_factor: NonZeroUsize,
- /// Join the IPFS network and serve transactions over bitswap protocol.
- #[arg(long)]
- pub ipfs_server: bool,
-
/// Blockchain syncing mode.
#[arg(
long,
@@ -243,7 +239,6 @@ impl NetworkParams {
kademlia_disjoint_query_paths: self.kademlia_disjoint_query_paths,
kademlia_replication_factor: self.kademlia_replication_factor,
yamux_window_size: None,
- ipfs_server: self.ipfs_server,
sync_mode: self.sync.into(),
}
}
diff --git a/substrate/client/network/bitswap/Cargo.toml b/substrate/client/network/bitswap/Cargo.toml
deleted file mode 100644
index 9d06831019a5..000000000000
--- a/substrate/client/network/bitswap/Cargo.toml
+++ /dev/null
@@ -1,39 +0,0 @@
-[package]
-description = "Substrate bitswap protocol"
-name = "sc-network-bitswap"
-version = "0.10.0-dev"
-license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
-authors.workspace = true
-edition.workspace = true
-homepage = "https://substrate.io"
-repository.workspace = true
-documentation = "https://docs.rs/sc-network-bitswap"
-
-[package.metadata.docs.rs]
-targets = ["x86_64-unknown-linux-gnu"]
-
-[build-dependencies]
-prost-build = "0.12"
-
-[dependencies]
-async-channel = "1.8.0"
-cid = "0.9.0"
-futures = "0.3.21"
-libp2p-identity = { version = "0.1.3", features = ["peerid"] }
-log = "0.4.17"
-prost = "0.12"
-thiserror = "1.0"
-unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] }
-sc-client-api = { path = "../../api" }
-sc-network = { path = ".." }
-sp-blockchain = { path = "../../../primitives/blockchain" }
-sp-runtime = { path = "../../../primitives/runtime" }
-
-[dev-dependencies]
-tokio = { version = "1.22.0", features = ["full"] }
-sc-block-builder = { path = "../../block-builder" }
-sc-consensus = { path = "../../consensus/common" }
-sp-core = { path = "../../../primitives/core" }
-sp-consensus = { path = "../../../primitives/consensus/common" }
-substrate-test-runtime = { path = "../../../test-utils/runtime" }
-substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
diff --git a/substrate/client/network/bitswap/build.rs b/substrate/client/network/bitswap/build.rs
deleted file mode 100644
index d297b4530b54..000000000000
--- a/substrate/client/network/bitswap/build.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// This file is part of a fork of Substrate which has had various changes.
-
-// Copyright (C) Parity Technologies (UK) Ltd.
-// Copyright (C) 2022-2023 Luke Parker
-// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-const PROTOS: &[&str] = &["src/schema/bitswap.v1.2.0.proto"];
-
-fn main() {
- prost_build::compile_protos(PROTOS, &["src/schema"]).unwrap();
-}
diff --git a/substrate/client/network/bitswap/src/lib.rs b/substrate/client/network/bitswap/src/lib.rs
deleted file mode 100644
index 02314bce75fd..000000000000
--- a/substrate/client/network/bitswap/src/lib.rs
+++ /dev/null
@@ -1,528 +0,0 @@
-// Copyright (C) Parity Technologies (UK) Ltd.
-// Copyright (C) 2022-2023 Luke Parker
-// This file is part of a fork of Substrate which has had various changes.
-
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
-
-//! Bitswap server for Substrate.
-//!
-//! Allows querying transactions by hash over standard bitswap protocol
-//! Only supports bitswap 1.2.0.
-//! CID is expected to reference 256-bit Blake2b transaction hash.
-
-use cid::{self, Version};
-use futures::StreamExt;
-use libp2p_identity::PeerId;
-use log::{debug, error, trace};
-use prost::Message;
-use sc_client_api::BlockBackend;
-use sc_network::{
- request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig},
- types::ProtocolName,
-};
-use schema::bitswap::{
- message::{wantlist::WantType, Block as MessageBlock, BlockPresence, BlockPresenceType},
- Message as BitswapMessage,
-};
-use sp_runtime::traits::Block as BlockT;
-use std::{io, sync::Arc, time::Duration};
-use unsigned_varint::encode as varint_encode;
-
-mod schema;
-
-const LOG_TARGET: &str = "bitswap";
-
-// Undocumented, but according to JS the bitswap messages have a max size of 512*1024 bytes
-// https://github.com/ipfs/js-ipfs-bitswap/blob/
-// d8f80408aadab94c962f6b88f343eb9f39fa0fcc/src/decision-engine/index.js#L16
-// We set it to the same value as max substrate protocol message
-const MAX_PACKET_SIZE: u64 = 16 * 1024 * 1024;
-
-/// Max number of queued responses before denying requests.
-const MAX_REQUEST_QUEUE: usize = 20;
-
-/// Max number of blocks per wantlist
-const MAX_WANTED_BLOCKS: usize = 16;
-
-/// Bitswap protocol name
-const PROTOCOL_NAME: &'static str = "/ipfs/bitswap/1.2.0";
-
-/// Prefix represents all metadata of a CID, without the actual content.
-#[derive(PartialEq, Eq, Clone, Debug)]
-struct Prefix {
- /// The version of CID.
- pub version: Version,
- /// The codec of CID.
- pub codec: u64,
- /// The multihash type of CID.
- pub mh_type: u64,
- /// The multihash length of CID.
- pub mh_len: u8,
-}
-
-impl Prefix {
- /// Convert the prefix to encoded bytes.
- pub fn to_bytes(&self) -> Vec {
- let mut res = Vec::with_capacity(4);
- let mut buf = varint_encode::u64_buffer();
- let version = varint_encode::u64(self.version.into(), &mut buf);
- res.extend_from_slice(version);
- let mut buf = varint_encode::u64_buffer();
- let codec = varint_encode::u64(self.codec, &mut buf);
- res.extend_from_slice(codec);
- let mut buf = varint_encode::u64_buffer();
- let mh_type = varint_encode::u64(self.mh_type, &mut buf);
- res.extend_from_slice(mh_type);
- let mut buf = varint_encode::u64_buffer();
- let mh_len = varint_encode::u64(self.mh_len as u64, &mut buf);
- res.extend_from_slice(mh_len);
- res
- }
-}
-
-/// Bitswap request handler
-pub struct BitswapRequestHandler {
- client: Arc + Send + Sync>,
- request_receiver: async_channel::Receiver,
-}
-
-impl BitswapRequestHandler {
- /// Create a new [`BitswapRequestHandler`].
- pub fn new(client: Arc + Send + Sync>) -> (Self, ProtocolConfig) {
- let (tx, request_receiver) = async_channel::bounded(MAX_REQUEST_QUEUE);
-
- let config = ProtocolConfig {
- name: ProtocolName::from(PROTOCOL_NAME),
- fallback_names: vec![],
- max_request_size: MAX_PACKET_SIZE,
- max_response_size: MAX_PACKET_SIZE,
- request_timeout: Duration::from_secs(15),
- inbound_queue: Some(tx),
- };
-
- (Self { client, request_receiver }, config)
- }
-
- /// Run [`BitswapRequestHandler`].
- pub async fn run(mut self) {
- while let Some(request) = self.request_receiver.next().await {
- let IncomingRequest { peer, payload, pending_response } = request;
-
- match self.handle_message(&peer, &payload) {
- Ok(response) => {
- let response = OutgoingResponse {
- result: Ok(response),
- reputation_changes: Vec::new(),
- sent_feedback: None,
- };
-
- match pending_response.send(response) {
- Ok(()) => {
- trace!(target: LOG_TARGET, "Handled bitswap request from {peer}.",)
- },
- Err(_) => debug!(
- target: LOG_TARGET,
- "Failed to handle light client request from {peer}: {}",
- BitswapError::SendResponse,
- ),
- }
- },
- Err(err) => {
- error!(target: LOG_TARGET, "Failed to process request from {peer}: {err}");
-
- // TODO: adjust reputation?
-
- let response = OutgoingResponse {
- result: Err(()),
- reputation_changes: vec![],
- sent_feedback: None,
- };
-
- if pending_response.send(response).is_err() {
- debug!(
- target: LOG_TARGET,
- "Failed to handle bitswap request from {peer}: {}",
- BitswapError::SendResponse,
- );
- }
- },
- }
- }
- }
-
- /// Handle received Bitswap request
- fn handle_message(
- &mut self,
- peer: &PeerId,
- payload: &Vec,
- ) -> Result, BitswapError> {
- let request = schema::bitswap::Message::decode(&payload[..])?;
-
- trace!(target: LOG_TARGET, "Received request: {:?} from {}", request, peer);
-
- let mut response = BitswapMessage::default();
-
- let wantlist = match request.wantlist {
- Some(wantlist) => wantlist,
- None => {
- debug!(target: LOG_TARGET, "Unexpected bitswap message from {}", peer);
- return Err(BitswapError::InvalidWantList)
- },
- };
-
- if wantlist.entries.len() > MAX_WANTED_BLOCKS {
- trace!(target: LOG_TARGET, "Ignored request: too many entries");
- return Err(BitswapError::TooManyEntries)
- }
-
- for entry in wantlist.entries {
- let cid = match cid::Cid::read_bytes(entry.block.as_slice()) {
- Ok(cid) => cid,
- Err(e) => {
- trace!(target: LOG_TARGET, "Bad CID {:?}: {:?}", entry.block, e);
- continue
- },
- };
-
- if cid.version() != cid::Version::V1 ||
- cid.hash().code() != u64::from(cid::multihash::Code::Blake2b256) ||
- cid.hash().size() != 32
- {
- debug!(target: LOG_TARGET, "Ignoring unsupported CID {}: {}", peer, cid);
- continue
- }
-
- let mut hash = B::Hash::default();
- hash.as_mut().copy_from_slice(&cid.hash().digest()[0..32]);
- let transaction = match self.client.indexed_transaction(hash) {
- Ok(ex) => ex,
- Err(e) => {
- error!(target: LOG_TARGET, "Error retrieving transaction {}: {}", hash, e);
- None
- },
- };
-
- match transaction {
- Some(transaction) => {
- trace!(target: LOG_TARGET, "Found CID {:?}, hash {:?}", cid, hash);
-
- if entry.want_type == WantType::Block as i32 {
- let prefix = Prefix {
- version: cid.version(),
- codec: cid.codec(),
- mh_type: cid.hash().code(),
- mh_len: cid.hash().size(),
- };
- response
- .payload
- .push(MessageBlock { prefix: prefix.to_bytes(), data: transaction });
- } else {
- response.block_presences.push(BlockPresence {
- r#type: BlockPresenceType::Have as i32,
- cid: cid.to_bytes(),
- });
- }
- },
- None => {
- trace!(target: LOG_TARGET, "Missing CID {:?}, hash {:?}", cid, hash);
-
- if entry.send_dont_have {
- response.block_presences.push(BlockPresence {
- r#type: BlockPresenceType::DontHave as i32,
- cid: cid.to_bytes(),
- });
- }
- },
- }
- }
-
- Ok(response.encode_to_vec())
- }
-}
-
-/// Bitswap protocol error.
-#[derive(Debug, thiserror::Error)]
-pub enum BitswapError {
- /// Protobuf decoding error.
- #[error("Failed to decode request: {0}.")]
- DecodeProto(#[from] prost::DecodeError),
-
- /// Protobuf encoding error.
- #[error("Failed to encode response: {0}.")]
- EncodeProto(#[from] prost::EncodeError),
-
- /// Client backend error.
- #[error(transparent)]
- Client(#[from] sp_blockchain::Error),
-
- /// Error parsing CID
- #[error(transparent)]
- BadCid(#[from] cid::Error),
-
- /// Packet read error.
- #[error(transparent)]
- Read(#[from] io::Error),
-
- /// Error sending response.
- #[error("Failed to send response.")]
- SendResponse,
-
- /// Message doesn't have a WANT list.
- #[error("Invalid WANT list.")]
- InvalidWantList,
-
- /// Too many blocks requested.
- #[error("Too many block entries in the request.")]
- TooManyEntries,
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use futures::channel::oneshot;
- use sc_block_builder::BlockBuilderProvider;
- use schema::bitswap::{
- message::{wantlist::Entry, Wantlist},
- Message as BitswapMessage,
- };
- use sp_consensus::BlockOrigin;
- use sp_runtime::codec::Encode;
- use substrate_test_runtime::ExtrinsicBuilder;
- use substrate_test_runtime_client::{self, prelude::*, TestClientBuilder};
-
- #[tokio::test]
- async fn undecodeable_message() {
- let client = substrate_test_runtime_client::new();
- let (bitswap, config) = BitswapRequestHandler::new(Arc::new(client));
-
- tokio::spawn(async move { bitswap.run().await });
-
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: vec![0x13, 0x37, 0x13, 0x38],
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(result, Err(()));
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
- } else {
- panic!("invalid event received");
- }
- }
-
- #[tokio::test]
- async fn empty_want_list() {
- let client = substrate_test_runtime_client::new();
- let (bitswap, mut config) = BitswapRequestHandler::new(Arc::new(client));
-
- tokio::spawn(async move { bitswap.run().await });
-
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .as_mut()
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: BitswapMessage { wantlist: None, ..Default::default() }.encode_to_vec(),
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(result, Err(()));
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
- } else {
- panic!("invalid event received");
- }
-
- // Empty WANT list should not cause an error
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: BitswapMessage {
- wantlist: Some(Default::default()),
- ..Default::default()
- }
- .encode_to_vec(),
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(result, Ok(BitswapMessage::default().encode_to_vec()));
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
- } else {
- panic!("invalid event received");
- }
- }
-
- #[tokio::test]
- async fn too_long_want_list() {
- let client = substrate_test_runtime_client::new();
- let (bitswap, config) = BitswapRequestHandler::new(Arc::new(client));
-
- tokio::spawn(async move { bitswap.run().await });
-
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: BitswapMessage {
- wantlist: Some(Wantlist {
- entries: (0..MAX_WANTED_BLOCKS + 1)
- .map(|_| Entry::default())
- .collect::>(),
- full: false,
- }),
- ..Default::default()
- }
- .encode_to_vec(),
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(result, Err(()));
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
- } else {
- panic!("invalid event received");
- }
- }
-
- #[tokio::test]
- async fn transaction_not_found() {
- let client = TestClientBuilder::with_tx_storage(u32::MAX).build();
-
- let (bitswap, config) = BitswapRequestHandler::new(Arc::new(client));
- tokio::spawn(async move { bitswap.run().await });
-
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: BitswapMessage {
- wantlist: Some(Wantlist {
- entries: vec![Entry {
- block: cid::Cid::new_v1(
- 0x70,
- cid::multihash::Multihash::wrap(
- u64::from(cid::multihash::Code::Blake2b256),
- &[0u8; 32],
- )
- .unwrap(),
- )
- .to_bytes(),
- ..Default::default()
- }],
- full: false,
- }),
- ..Default::default()
- }
- .encode_to_vec(),
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(result, Ok(vec![]));
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
- } else {
- panic!("invalid event received");
- }
- }
-
- #[tokio::test]
- async fn transaction_found() {
- let mut client = TestClientBuilder::with_tx_storage(u32::MAX).build();
- let mut block_builder = client.new_block(Default::default()).unwrap();
-
- // encoded extrinsic: [161, .. , 2, 6, 16, 19, 55, 19, 56]
- let ext = ExtrinsicBuilder::new_indexed_call(vec![0x13, 0x37, 0x13, 0x38]).build();
- let pattern_index = ext.encoded_size() - 4;
-
- block_builder.push(ext.clone()).unwrap();
- let block = block_builder.build().unwrap().block;
-
- client.import(BlockOrigin::File, block).await.unwrap();
-
- let (bitswap, config) = BitswapRequestHandler::new(Arc::new(client));
-
- tokio::spawn(async move { bitswap.run().await });
-
- let (tx, rx) = oneshot::channel();
- config
- .inbound_queue
- .unwrap()
- .send(IncomingRequest {
- peer: PeerId::random(),
- payload: BitswapMessage {
- wantlist: Some(Wantlist {
- entries: vec![Entry {
- block: cid::Cid::new_v1(
- 0x70,
- cid::multihash::Multihash::wrap(
- u64::from(cid::multihash::Code::Blake2b256),
- &sp_core::hashing::blake2_256(&ext.encode()[pattern_index..]),
- )
- .unwrap(),
- )
- .to_bytes(),
- ..Default::default()
- }],
- full: false,
- }),
- ..Default::default()
- }
- .encode_to_vec(),
- pending_response: tx,
- })
- .await
- .unwrap();
-
- if let Ok(OutgoingResponse { result, reputation_changes, sent_feedback }) = rx.await {
- assert_eq!(reputation_changes, Vec::new());
- assert!(sent_feedback.is_none());
-
- let response =
- schema::bitswap::Message::decode(&result.expect("fetch to succeed")[..]).unwrap();
- assert_eq!(response.payload[0].data, vec![0x13, 0x37, 0x13, 0x38]);
- } else {
- panic!("invalid event received");
- }
- }
-}
diff --git a/substrate/client/network/bitswap/src/schema.rs b/substrate/client/network/bitswap/src/schema.rs
deleted file mode 100644
index b7ba52087952..000000000000
--- a/substrate/client/network/bitswap/src/schema.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// This file is part of a fork of Substrate which has had various changes.
-
-// Copyright (C) Parity Technologies (UK) Ltd.
-// Copyright (C) 2022-2023 Luke Parker
-// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-//! Include sources generated from protobuf definitions.
-
-pub(crate) mod bitswap {
- include!(concat!(env!("OUT_DIR"), "/bitswap.message.rs"));
-}
diff --git a/substrate/client/network/bitswap/src/schema/bitswap.v1.2.0.proto b/substrate/client/network/bitswap/src/schema/bitswap.v1.2.0.proto
deleted file mode 100644
index a4138b516d63..000000000000
--- a/substrate/client/network/bitswap/src/schema/bitswap.v1.2.0.proto
+++ /dev/null
@@ -1,43 +0,0 @@
-syntax = "proto3";
-
-package bitswap.message;
-
-message Message {
- message Wantlist {
- enum WantType {
- Block = 0;
- Have = 1;
- }
-
- message Entry {
- bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)
- int32 priority = 2; // the priority (normalized). default to 1
- bool cancel = 3; // whether this revokes an entry
- WantType wantType = 4; // Note: defaults to enum 0, ie Block
- bool sendDontHave = 5; // Note: defaults to false
- }
-
- repeated Entry entries = 1; // a list of wantlist entries
- bool full = 2; // whether this is the full wantlist. default to false
- }
-
- message Block {
- bytes prefix = 1; // CID prefix (cid version, multicodec and multihash prefix (type + length)
- bytes data = 2;
- }
-
- enum BlockPresenceType {
- Have = 0;
- DontHave = 1;
- }
- message BlockPresence {
- bytes cid = 1;
- BlockPresenceType type = 2;
- }
-
- Wantlist wantlist = 1;
- repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0
- repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0
- repeated BlockPresence blockPresences = 4;
- int32 pendingBytes = 5;
-}
diff --git a/substrate/client/network/src/config.rs b/substrate/client/network/src/config.rs
index f96152f0671c..17df8a907a3d 100644
--- a/substrate/client/network/src/config.rs
+++ b/substrate/client/network/src/config.rs
@@ -586,9 +586,6 @@ pub struct NetworkConfiguration {
/// `kademlia_replication_factor` peers to consider record successfully put.
pub kademlia_replication_factor: NonZeroUsize,
- /// Enable serving block data over IPFS bitswap.
- pub ipfs_server: bool,
-
/// Size of Yamux receive window of all substreams. `None` for the default (256kiB).
/// Any value less than 256kiB is invalid.
///
@@ -640,7 +637,6 @@ impl NetworkConfiguration {
kademlia_replication_factor: NonZeroUsize::new(DEFAULT_KADEMLIA_REPLICATION_FACTOR)
.expect("value is a constant; constant is non-zero; qed."),
yamux_window_size: None,
- ipfs_server: false,
}
}
diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml
index da3bf33beb7c..91e6408f1989 100644
--- a/substrate/client/service/Cargo.toml
+++ b/substrate/client/service/Cargo.toml
@@ -51,7 +51,6 @@ sp-consensus = { path = "../../primitives/consensus/common" }
sc-consensus = { path = "../consensus/common" }
sp-storage = { path = "../../primitives/storage" }
sc-network = { path = "../network" }
-sc-network-bitswap = { path = "../network/bitswap" }
sc-network-common = { path = "../network/common" }
sc-network-light = { path = "../network/light" }
sc-network-sync = { path = "../network/sync" }
diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs
index 2c2c2b4915a4..99acd14a4550 100644
--- a/substrate/client/service/src/builder.rs
+++ b/substrate/client/service/src/builder.rs
@@ -47,7 +47,6 @@ use sc_network::{
peer_store::PeerStore,
NetworkService, NetworkStateInfo, NetworkStatusProvider,
};
-use sc_network_bitswap::BitswapRequestHandler;
use sc_network_common::role::Roles;
use sc_network_light::light_client_requests::handler::LightClientRequestHandler;
use sc_network_sync::{
@@ -833,12 +832,6 @@ where
net_config.add_request_response_protocol(config);
}
- if config.network.ipfs_server {
- let (handler, protocol_config) = BitswapRequestHandler::new(client.clone());
- spawn_handle.spawn("bitswap-request-handler", Some("networking"), handler.run());
- net_config.add_request_response_protocol(protocol_config);
- }
-
// create transactions protocol and add it to the list of supported protocols of
// `network_params`
let transactions_handler_proto = sc_network_transactions::TransactionsHandlerPrototype::new(
diff --git a/substrate/scripts/ci/deny.toml b/substrate/scripts/ci/deny.toml
index c0a109905665..5dbb11805134 100644
--- a/substrate/scripts/ci/deny.toml
+++ b/substrate/scripts/ci/deny.toml
@@ -78,7 +78,6 @@ exceptions = [
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-keystore" },
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-mixnet" },
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-network" },
- { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-network-bitswap" },
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-network-common" },
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-network-gossip" },
{ allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-network-light" },