Simplify trait bounds in network to prepare for collator-rpc (#12082)

* Hack towards PoC

* Abstract away runtime requirement

* blockchainevents

* Remove bitswap

* Remove unused sync more

* Remove unused features in network

* Re-enable bitswap change

* Remove `Chain` trait bound

* Reimplement blockchain-rpc-events

* Move network to cumulus

* Make AuthorityDiscovery async

* Remove `ProofProvider` requirement from network behaviour

* Extract bitswap

* Adjustments after merge

* Remove HeaderMetadata trait from network

* Introduce NetworkHeaderBackend

* Add comments

* Improve comments

* Move NetworkHeaderBackend to new module

* Improve naming, remove redundand send + sync

* Clean up generics

* Fix CI

* Improve comment and readability

* Remove NetworkHeaderBackend

* Fix Cargo.lock

Co-authored-by: Sebastian Kunert <skunert@Sebastians-MacBook-Pro.fritz.box>
This commit is contained in:
Sebastian Kunert
2022-08-31 14:55:46 +02:00
committed by GitHub
parent 30951822ba
commit 800bc5cd8c
14 changed files with 165 additions and 155 deletions
+7 -2
View File
@@ -37,7 +37,7 @@ use sc_client_db::{Backend, DatabaseSettings};
use sc_consensus::import_queue::ImportQueue;
use sc_executor::RuntimeVersionOf;
use sc_keystore::LocalKeystore;
use sc_network::{config::SyncMode, NetworkService};
use sc_network::{bitswap::Bitswap, config::SyncMode, NetworkService};
use sc_network_common::{
service::{NetworkStateInfo, NetworkStatusProvider, NetworkTransaction},
sync::warp::WarpSyncProvider,
@@ -711,7 +711,6 @@ pub struct BuildNetworkParams<'a, TBl: BlockT, TExPool, TImpQu, TCl> {
/// An optional warp sync provider.
pub warp_sync: Option<Arc<dyn WarpSyncProvider<TBl>>>,
}
/// Build the network service, the network status sinks and an RPC sender.
pub fn build_network<TBl, TExPool, TImpQu, TCl>(
params: BuildNetworkParams<TBl, TExPool, TImpQu, TCl>,
@@ -857,6 +856,7 @@ where
fork_id: config.chain_spec.fork_id().map(ToOwned::to_owned),
import_queue: Box::new(import_queue),
chain_sync: Box::new(chain_sync),
bitswap: config.network.ipfs_server.then(|| Bitswap::from_client(client.clone())),
metrics_registry: config.prometheus_config.as_ref().map(|config| config.registry.clone()),
block_request_protocol_config,
state_request_protocol_config,
@@ -923,6 +923,11 @@ where
pub struct NetworkStarter(oneshot::Sender<()>);
impl NetworkStarter {
/// Create a new NetworkStarter
pub fn new(sender: oneshot::Sender<()>) -> Self {
NetworkStarter(sender)
}
/// Start the network. Call this after all sub-components have been initialized.
///
/// > **Note**: If you don't call this function, the networking will not work.