mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 20:01:08 +00:00
Network sync refactoring (part 3) (#11347)
* Move `light.v1.proto` schema into new crate `sc-network-light` * Move `sc_network::light_client_requests` and submodule to `sc_network_light::light_client_requests` * Fix apparently outdated reference in documentation and visibility modifier * Fix rustdoc check * Update lock file
This commit is contained in:
Generated
+20
@@ -8509,6 +8509,7 @@ dependencies = [
|
||||
"sc-client-api",
|
||||
"sc-consensus",
|
||||
"sc-network-common",
|
||||
"sc-network-light",
|
||||
"sc-network-sync",
|
||||
"sc-peerset",
|
||||
"sc-utils",
|
||||
@@ -8564,6 +8565,25 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-network-light"
|
||||
version = "0.10.0-dev"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"libp2p",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"sc-client-api",
|
||||
"sc-network-common",
|
||||
"sc-peerset",
|
||||
"sp-blockchain",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-network-sync"
|
||||
version = "0.10.0-dev"
|
||||
|
||||
@@ -42,8 +42,9 @@ members = [
|
||||
"client/informant",
|
||||
"client/keystore",
|
||||
"client/network",
|
||||
"client/network/common",
|
||||
"client/network-gossip",
|
||||
"client/network/common",
|
||||
"client/network/light",
|
||||
"client/network/sync",
|
||||
"client/network/test",
|
||||
"client/offchain",
|
||||
|
||||
@@ -51,6 +51,7 @@ sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
|
||||
sc-network-common = { version = "0.10.0-dev", path = "./common" }
|
||||
sc-network-light = { version = "0.10.0-dev", path = "./light" }
|
||||
sc-network-sync = { version = "0.10.0-dev", path = "./sync" }
|
||||
sc-peerset = { version = "4.0.0-dev", path = "../peerset" }
|
||||
sc-utils = { version = "4.0.0-dev", path = "../utils" }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const PROTOS: &[&str] = &["src/schema/light.v1.proto", "src/schema/bitswap.v1.2.0.proto"];
|
||||
const PROTOS: &[&str] = &["src/schema/bitswap.v1.2.0.proto"];
|
||||
|
||||
fn main() {
|
||||
prost_build::compile_protos(PROTOS, &["src/schema"]).unwrap();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
[package]
|
||||
description = "Substrate light network protocol"
|
||||
name = "sc-network-light"
|
||||
version = "0.10.0-dev"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
homepage = "https://substrate.io"
|
||||
repository = "https://github.com/paritytech/substrate/"
|
||||
documentation = "https://docs.rs/sc-network-light"
|
||||
readme = "README.md"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.9"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
|
||||
"derive",
|
||||
] }
|
||||
futures = "0.3.21"
|
||||
libp2p = "0.44.0"
|
||||
log = "0.4.16"
|
||||
prost = "0.9"
|
||||
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
|
||||
sc-network-common = { version = "0.10.0-dev", path = "../common" }
|
||||
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
|
||||
sp-core = { version = "6.0.0", path = "../../../primitives/core" }
|
||||
sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" }
|
||||
thiserror = "1.0"
|
||||
@@ -0,0 +1,5 @@
|
||||
const PROTOS: &[&str] = &["src/schema/light.v1.proto"];
|
||||
|
||||
fn main() {
|
||||
prost_build::compile_protos(PROTOS, &["src/schema"]).unwrap();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
|
||||
// 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! Light client data structures of the networking layer.
|
||||
|
||||
pub mod light_client_requests;
|
||||
mod schema;
|
||||
+3
-2
@@ -22,9 +22,10 @@
|
||||
//! `crate::request_responses::RequestResponsesBehaviour` with
|
||||
//! [`LightClientRequestHandler`](handler::LightClientRequestHandler).
|
||||
|
||||
use crate::{schema, PeerId};
|
||||
use crate::schema;
|
||||
use codec::{self, Decode, Encode};
|
||||
use futures::{channel::mpsc, prelude::*};
|
||||
use libp2p::PeerId;
|
||||
use log::{debug, trace};
|
||||
use prost::Message;
|
||||
use sc_client_api::{ProofProvider, StorageProof};
|
||||
@@ -55,7 +56,7 @@ where
|
||||
B: Block,
|
||||
Client: ProofProvider<B> + Send + Sync + 'static,
|
||||
{
|
||||
/// Create a new [`sc_network_sync::block_request_handler::BlockRequestHandler`].
|
||||
/// Create a new [`LightClientRequestHandler`].
|
||||
pub fn new(protocol_id: &ProtocolId, client: Arc<Client>) -> (Self, ProtocolConfig) {
|
||||
// For now due to lack of data on light client request handling in production systems, this
|
||||
// value is chosen to match the block request limit.
|
||||
@@ -0,0 +1,25 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
|
||||
// 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! Include sources generated from protobuf definitions.
|
||||
|
||||
pub(crate) mod v1 {
|
||||
pub(crate) mod light {
|
||||
include!(concat!(env!("OUT_DIR"), "/api.v1.light.rs"));
|
||||
}
|
||||
}
|
||||
@@ -122,10 +122,10 @@ where
|
||||
/// Request response configuration for the light client request protocol.
|
||||
///
|
||||
/// Can be constructed either via
|
||||
/// [`crate::light_client_requests::generate_protocol_config`] allowing outgoing but not
|
||||
/// incoming requests, or constructed via
|
||||
/// [`crate::light_client_requests::handler::LightClientRequestHandler::new`] allowing
|
||||
/// both outgoing and incoming requests.
|
||||
/// [`sc_network_light::light_client_requests::generate_protocol_config`] allowing outgoing but
|
||||
/// not incoming requests, or constructed via
|
||||
/// [`sc_network_light::light_client_requests::handler::LightClientRequestHandler::new`]
|
||||
/// allowing both outgoing and incoming requests.
|
||||
pub light_client_request_protocol_config: RequestResponseConfig,
|
||||
|
||||
/// Request response configuration for the state request protocol.
|
||||
|
||||
@@ -257,7 +257,6 @@ mod utils;
|
||||
pub mod bitswap;
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod light_client_requests;
|
||||
pub mod network_state;
|
||||
pub mod transactions;
|
||||
|
||||
@@ -267,6 +266,7 @@ pub use protocol::{
|
||||
event::{DhtEvent, Event, ObservedRole},
|
||||
PeerInfo,
|
||||
};
|
||||
pub use sc_network_light::light_client_requests;
|
||||
pub use sc_network_sync::{
|
||||
block_request_handler,
|
||||
state::StateDownloadProgress,
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
|
||||
//! Include sources generated from protobuf definitions.
|
||||
|
||||
pub mod v1 {
|
||||
pub mod light {
|
||||
include!(concat!(env!("OUT_DIR"), "/api.v1.light.rs"));
|
||||
}
|
||||
}
|
||||
|
||||
pub mod bitswap {
|
||||
include!(concat!(env!("OUT_DIR"), "/bitswap.message.rs"));
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
config, light_client_requests::handler::LightClientRequestHandler,
|
||||
state_request_handler::StateRequestHandler, Event, NetworkService, NetworkWorker,
|
||||
config, state_request_handler::StateRequestHandler, Event, NetworkService, NetworkWorker,
|
||||
};
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p::PeerId;
|
||||
use sc_network_common::config::ProtocolId;
|
||||
use sc_network_light::light_client_requests::handler::LightClientRequestHandler;
|
||||
use sc_network_sync::block_request_handler::BlockRequestHandler;
|
||||
use sp_runtime::traits::{Block as BlockT, Header as _};
|
||||
use std::{borrow::Cow, sync::Arc, time::Duration};
|
||||
|
||||
@@ -75,9 +75,7 @@ pub fn generate_protocol_config(protocol_id: &ProtocolId) -> ProtocolConfig {
|
||||
}
|
||||
|
||||
/// Generate the block protocol name from chain specific protocol identifier.
|
||||
// Visibility `pub(crate)` to allow `crate::light_client_requests::sender` to generate block request
|
||||
// protocol name and send block requests.
|
||||
pub(crate) fn generate_protocol_name(protocol_id: &ProtocolId) -> String {
|
||||
fn generate_protocol_name(protocol_id: &ProtocolId) -> String {
|
||||
format!("/{}/sync/2", protocol_id.as_ref())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user