Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Network sync refactoring (part 4) #11412

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ae1ceb9
Remove direct dependency of `sc-network` on `sc-network-light`
nazar-pc May 11, 2022
427d316
Move `WarpSyncProvider` trait and surrounding data structures into `s…
nazar-pc May 11, 2022
84ae282
Move `WarpSyncProvider` trait and surrounding data structures into `s…
nazar-pc May 11, 2022
5dd28b0
Create `sync` module in `sc-network-common`, create `ChainSync` trait…
nazar-pc May 11, 2022
922f1ae
Switch from concrete implementation to `ChainSync` trait from `sc-net…
nazar-pc May 12, 2022
d6d0a46
Introduce `OpaqueStateRequest`/`OpaqueStateResponse` to remove generi…
nazar-pc May 12, 2022
a91cd02
Introduce `OpaqueBlockRequest`/`OpaqueBlockResponse`, make `scheme` m…
nazar-pc May 12, 2022
dc4a721
Surface `sc-network-sync` into `sc-service` and make `sc-network` not…
nazar-pc May 12, 2022
38abfd0
Remove now unnecessary dependency from `sc-network`
nazar-pc May 12, 2022
0583c14
Replace crate links with just text since dependencies are gone now
nazar-pc May 14, 2022
95a9ab4
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 6, 2022
835b8fa
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 7, 2022
43bfb5c
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 17, 2022
1032789
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 20, 2022
26b8ab2
Remove `warp_sync` re-export from `sc-network-common`
nazar-pc Jun 20, 2022
4616d25
Update copyright in network-related files
nazar-pc Jun 20, 2022
2e2e6ee
Address review comments about documentation
nazar-pc Jun 20, 2022
93849a1
Apply review suggestion
nazar-pc Jun 20, 2022
6e1eae4
Rename `extra_requests` module to `metrics`
nazar-pc Jun 23, 2022
60be73c
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 28, 2022
6ca4645
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jul 11, 2022
ba9a85d
Merge remote-tracking branch 'origin/master' into network-sync-refact…
bkchr Jul 12, 2022
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
13 changes: 10 additions & 3 deletions Cargo.lock

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

14 changes: 2 additions & 12 deletions client/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use sc_chain_spec::{ChainSpec, GenericChainSpec};
use sc_client_api::HeaderBackend;
use sc_consensus::BoxJustificationImport;
use sc_keystore::LocalKeystore;
use sc_network::config::ProtocolConfig;
use sc_network_test::{
Block, BlockImportAdapter, FullPeerConfig, PassThroughVerifier, Peer, PeersClient,
TestNetFactory,
Expand Down Expand Up @@ -111,6 +110,7 @@ pub(crate) struct PeerData {
pub(crate) beefy_link_half: Mutex<Option<BeefyLinkHalf>>,
}

#[derive(Default)]
pub(crate) struct BeefyTestNet {
peers: Vec<BeefyPeer>,
}
Expand Down Expand Up @@ -166,17 +166,7 @@ impl TestNetFactory for BeefyTestNet {
type BlockImport = PeersClient;
type PeerData = PeerData;

/// Create new test network with peers and given config.
fn from_config(_config: &ProtocolConfig) -> Self {
BeefyTestNet { peers: Vec::new() }
}

fn make_verifier(
&self,
_client: PeersClient,
_cfg: &ProtocolConfig,
_: &PeerData,
) -> Self::Verifier {
fn make_verifier(&self, _client: PeersClient, _: &PeerData) -> Self::Verifier {
PassThroughVerifier::new(false) // use non-instant finality.
}

Expand Down
14 changes: 2 additions & 12 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ mod tests {
use sc_consensus::BoxJustificationImport;
use sc_consensus_slots::{BackoffAuthoringOnFinalizedHeadLagging, SimpleSlotWorker};
use sc_keystore::LocalKeystore;
use sc_network::config::ProtocolConfig;
use sc_network_test::{Block as TestBlock, *};
use sp_application_crypto::key_types::AURA;
use sp_consensus::{
Expand Down Expand Up @@ -645,6 +644,7 @@ mod tests {
>;
type AuraPeer = Peer<(), PeersClient>;

#[derive(Default)]
pub struct AuraTestNet {
peers: Vec<AuraPeer>,
}
Expand All @@ -654,17 +654,7 @@ mod tests {
type PeerData = ();
type BlockImport = PeersClient;

/// Create new test network with peers and given config.
fn from_config(_config: &ProtocolConfig) -> Self {
AuraTestNet { peers: Vec::new() }
}

fn make_verifier(
&self,
client: PeersClient,
_cfg: &ProtocolConfig,
_peer_data: &(),
) -> Self::Verifier {
fn make_verifier(&self, client: PeersClient, _peer_data: &()) -> Self::Verifier {
let client = client.as_client();
let slot_duration = slot_duration(&*client).expect("slot duration available");

Expand Down
18 changes: 2 additions & 16 deletions client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

//! BABE testsuite

// FIXME #2532: need to allow deprecated until refactor is done
// https://github.com/paritytech/substrate/issues/2532
#![allow(deprecated)]
use super::*;
use authorship::claim_slot;
use futures::executor::block_on;
Expand All @@ -32,7 +29,6 @@ use sc_client_api::{backend::TransactionFor, BlockchainEvents, Finalizer};
use sc_consensus::{BoxBlockImport, BoxJustificationImport};
use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging;
use sc_keystore::LocalKeystore;
use sc_network::config::ProtocolConfig;
use sc_network_test::{Block as TestBlock, *};
use sp_application_crypto::key_types::BABE;
use sp_consensus::{AlwaysCanAuthor, DisableProofRecording, NoNetwork as DummyOracle, Proposal};
Expand Down Expand Up @@ -223,6 +219,7 @@ where

type BabePeer = Peer<Option<PeerData>, BabeBlockImport>;

#[derive(Default)]
pub struct BabeTestNet {
peers: Vec<BabePeer>,
}
Expand Down Expand Up @@ -281,12 +278,6 @@ impl TestNetFactory for BabeTestNet {
type PeerData = Option<PeerData>;
type BlockImport = BabeBlockImport;

/// Create new test network with peers and given config.
fn from_config(_config: &ProtocolConfig) -> Self {
debug!(target: "babe", "Creating test network from config");
BabeTestNet { peers: Vec::new() }
}

fn make_block_import(
&self,
client: PeersClient,
Expand All @@ -312,12 +303,7 @@ impl TestNetFactory for BabeTestNet {
)
}

fn make_verifier(
&self,
client: PeersClient,
_cfg: &ProtocolConfig,
maybe_link: &Option<PeerData>,
) -> Self::Verifier {
fn make_verifier(&self, client: PeersClient, maybe_link: &Option<PeerData>) -> Self::Verifier {
use substrate_test_runtime_client::DefaultTestClientBuilderExt;

let client = client.as_client();
Expand Down
1 change: 1 addition & 0 deletions client/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
sc-network = { version = "0.10.0-dev", path = "../network" }
sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sc-telemetry = { version = "4.0.0-dev", path = "../telemetry" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
Expand Down
20 changes: 3 additions & 17 deletions client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sc_consensus::{
BlockImport, BlockImportParams, BoxJustificationImport, ForkChoiceStrategy, ImportResult,
ImportedAux,
};
use sc_network::config::{ProtocolConfig, Role};
use sc_network::config::Role;
use sc_network_test::{
Block, BlockImportAdapter, FullPeerConfig, Hash, PassThroughVerifier, Peer, PeersClient,
PeersFullClient, TestClient, TestNetFactory,
Expand Down Expand Up @@ -73,6 +73,7 @@ type GrandpaBlockImport = crate::GrandpaBlockImport<
LongestChain<substrate_test_runtime_client::Backend, Block>,
>;

#[derive(Default)]
struct GrandpaTestNet {
peers: Vec<GrandpaPeer>,
test_config: TestApi,
Expand Down Expand Up @@ -110,16 +111,6 @@ impl TestNetFactory for GrandpaTestNet {
type PeerData = PeerData;
type BlockImport = GrandpaBlockImport;

/// Create new test network with peers and given config.
fn from_config(_config: &ProtocolConfig) -> Self {
GrandpaTestNet { peers: Vec::new(), test_config: Default::default() }
}

fn default_config() -> ProtocolConfig {
// This is unused.
ProtocolConfig::default()
}

fn add_full_peer(&mut self) {
self.add_full_peer_with_config(FullPeerConfig {
notifications_protocols: vec![grandpa_protocol_name::NAME.into()],
Expand All @@ -128,12 +119,7 @@ impl TestNetFactory for GrandpaTestNet {
})
}

fn make_verifier(
&self,
_client: PeersClient,
_cfg: &ProtocolConfig,
_: &PeerData,
) -> Self::Verifier {
fn make_verifier(&self, _client: PeersClient, _: &PeerData) -> Self::Verifier {
PassThroughVerifier::new(false) // use non-instant finality.
}

Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/src/warp_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
BlockNumberOps, GrandpaJustification, SharedAuthoritySet,
};
use sc_client_api::Backend as ClientBackend;
use sc_network::warp_request_handler::{EncodedProof, VerificationResult, WarpSyncProvider};
use sc_network_common::warp_sync::{EncodedProof, VerificationResult, WarpSyncProvider};
use sp_blockchain::{Backend as BlockchainBackend, HeaderBackend};
use sp_finality_grandpa::{AuthorityList, SetId, GRANDPA_ENGINE_ID};
use sp_runtime::{
Expand Down
5 changes: 2 additions & 3 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ 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" }
sp-arithmetic = { version = "5.0.0", path = "../../primitives/arithmetic" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sp-core = { version = "6.0.0", path = "../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }

[dev-dependencies]
Expand All @@ -68,6 +65,8 @@ async-std = "1.11.0"
quickcheck = "1.0.3"
rand = "0.7.2"
tempfile = "3.1.0"
sc-network-light = { version = "0.10.0-dev", path = "./light" }
sc-network-sync = { version = "0.10.0-dev", path = "./sync" }
sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" }
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" }
Expand Down
5 changes: 5 additions & 0 deletions client/network/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ targets = ["x86_64-unknown-linux-gnu"]
prost-build = "0.9"

[dependencies]
bitflags = "1.3.2"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
futures = "0.3.21"
libp2p = "0.44.0"
smallvec = "1.8.0"
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" }
4 changes: 4 additions & 0 deletions client/network/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
pub mod config;
pub mod message;
pub mod request_responses;
pub mod sync;

// TODO: Remove re-export
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
pub use sync::warp as warp_sync;
Loading