Network sync refactoring (part 4) (#11412)

* Remove direct dependency of `sc-network` on `sc-network-light`

* Move `WarpSyncProvider` trait and surrounding data structures into `sc-network-common`

* Move `WarpSyncProvider` trait and surrounding data structures into `sc-network-common`

* Create `sync` module in `sc-network-common`, create `ChainSync` trait there (not used yet), move a bunch of associated data structures from `sc-network-sync`

* Switch from concrete implementation to `ChainSync` trait from `sc-network-common`

* Introduce `OpaqueStateRequest`/`OpaqueStateResponse` to remove generics from `StateSync` trait

* Introduce `OpaqueBlockRequest`/`OpaqueBlockResponse`, make `scheme` module of `sc-network-sync` private

* Surface `sc-network-sync` into `sc-service` and make `sc-network` not depend on it anymore

* Remove now unnecessary dependency from `sc-network`

* Replace crate links with just text since dependencies are gone now

* Remove `warp_sync` re-export from `sc-network-common`

* Update copyright in network-related files

* Address review comments about documentation

* Apply review suggestion

* Rename `extra_requests` module to `metrics`

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Nazar Mokrynskyi
2022-07-12 23:34:17 +03:00
committed by GitHub
parent 4b8d784210
commit 5896072b86
35 changed files with 1286 additions and 1041 deletions
+17 -16
View File
@@ -26,16 +26,11 @@ pub use sc_network_common::{
request_responses::{
IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig,
},
sync::warp::WarpSyncProvider,
};
pub use sc_network_sync::warp_request_handler::WarpSyncProvider;
pub use libp2p::{build_multiaddr, core::PublicKey, identity};
// Note: this re-export shouldn't be part of the public API of the crate and will be removed in
// the future.
#[doc(hidden)]
pub use crate::protocol::ProtocolConfig;
use crate::ExHashT;
use core::{fmt, iter};
@@ -46,7 +41,7 @@ use libp2p::{
};
use prometheus_endpoint::Registry;
use sc_consensus::ImportQueue;
use sp_consensus::block_validation::BlockAnnounceValidator;
use sc_network_common::sync::ChainSync;
use sp_runtime::traits::Block as BlockT;
use std::{
borrow::Cow,
@@ -101,8 +96,14 @@ where
/// valid.
pub import_queue: Box<dyn ImportQueue<B>>,
/// Type to check incoming block announcements.
pub block_announce_validator: Box<dyn BlockAnnounceValidator<B> + Send>,
/// Factory function that creates a new instance of chain sync.
pub create_chain_sync: Box<
dyn FnOnce(
sc_network_common::sync::SyncMode,
Arc<Client>,
Option<Arc<dyn WarpSyncProvider<B>>>,
) -> crate::error::Result<Box<dyn ChainSync<B>>>,
>,
/// Registry for recording prometheus metrics to.
pub metrics_registry: Option<Registry>,
@@ -114,26 +115,26 @@ where
/// block requests, if enabled.
///
/// Can be constructed either via
/// [`sc_network_sync::block_request_handler::generate_protocol_config`] allowing outgoing but
/// not incoming requests, or constructed via [`sc_network_sync::block_request_handler::
/// BlockRequestHandler::new`] allowing both outgoing and incoming requests.
/// `sc_network_sync::block_request_handler::generate_protocol_config` allowing outgoing but
/// not incoming requests, or constructed via `sc_network_sync::block_request_handler::
/// BlockRequestHandler::new` allowing both outgoing and incoming requests.
pub block_request_protocol_config: RequestResponseConfig,
/// Request response configuration for the light client request protocol.
///
/// Can be constructed either via
/// [`sc_network_light::light_client_requests::generate_protocol_config`] allowing outgoing but
/// `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`]
/// `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.
///
/// Can be constructed either via
/// [`sc_network_sync::block_request_handler::generate_protocol_config`] allowing outgoing but
/// `sc_network_sync::state_request_handler::generate_protocol_config` allowing outgoing but
/// not incoming requests, or constructed via
/// [`crate::state_request_handler::StateRequestHandler::new`] allowing
/// `sc_network_sync::state_request_handler::StateRequestHandler::new` allowing
/// both outgoing and incoming requests.
pub state_request_protocol_config: RequestResponseConfig,