[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+12 -12
View File
@@ -24,16 +24,16 @@ rustc-hex = "2.0.1"
rand = "0.7.2"
libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] }
fork-tree = { path = "../../utils/fork-tree" }
consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" }
client = { package = "sc-client", path = "../" }
client-api = { package = "sc-client-api", path = "../api" }
sp-consensus = { path = "../../primitives/consensus/common" }
sc-client = { path = "../" }
sc-client-api = { path = "../api" }
sp-blockchain = { path = "../../primitives/blockchain" }
sp-runtime = { path = "../../primitives/runtime" }
sp-arithmetic = { path = "../../primitives/arithmetic" }
primitives = { package = "sp-core", path = "../../primitives/core" }
block-builder = { package = "sc-block-builder", path = "../block-builder" }
sp-core = { path = "../../primitives/core" }
sc-block-builder = { path = "../block-builder" }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
peerset = { package = "sc-peerset", path = "../peerset" }
sc-peerset = { path = "../peerset" }
serde = { version = "1.0.101", features = ["derive"] }
serde_json = "1.0.41"
slog = { version = "2.5.2", features = ["nested-values"] }
@@ -42,18 +42,18 @@ smallvec = "0.6.10"
tokio-io = "0.1.12"
tokio = { version = "0.1.22", optional = true }
unsigned-varint = { version = "0.2.2", features = ["codec"] }
keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true }
test_client = { package = "substrate-test-client", path = "../../test-utils/client", optional = true }
test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client", optional = true }
sp-keyring = { path = "../../primitives/keyring", optional = true }
substrate-test-client = { path = "../../test-utils/client", optional = true }
substrate-test-runtime-client = { path = "../../test-utils/runtime/client", optional = true }
erased-serde = "0.3.9"
void = "1.0.2"
zeroize = "1.0.0"
babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" }
sp-consensus-babe = { path = "../../primitives/consensus/babe" }
[dev-dependencies]
sp-test-primitives = { path = "../../primitives/test-primitives" }
env_logger = "0.7.0"
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
sp-keyring = { path = "../../primitives/keyring" }
quickcheck = "0.9.0"
rand = "0.7.2"
tempfile = "3.1.0"
@@ -61,4 +61,4 @@ tokio = "0.1.22"
[features]
default = []
test-helpers = ["keyring", "test-client", "tokio"]
test-helpers = ["sp-keyring", "substrate-test-runtime-client", "tokio"]
+1 -1
View File
@@ -20,7 +20,6 @@ use crate::{
};
use crate::{ExHashT, specialization::NetworkSpecialization};
use crate::protocol::{CustomMessageOutcome, Protocol};
use consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
use futures::prelude::*;
use libp2p::NetworkBehaviour;
use libp2p::core::{Multiaddr, PeerId, PublicKey};
@@ -28,6 +27,7 @@ use libp2p::kad::record;
use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess};
use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
use log::{debug, warn};
use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
use sp_runtime::{traits::{Block as BlockT, NumberFor}, Justification};
use std::iter;
use void;
+6 -6
View File
@@ -16,15 +16,15 @@
//! Blockchain access trait
use client::Client as SubstrateClient;
use sc_client::Client as SubstrateClient;
use sp_blockchain::Error;
use client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor};
use consensus::{BlockImport, BlockStatus, Error as ConsensusError};
use sc_client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor};
use sp_consensus::{BlockImport, BlockStatus, Error as ConsensusError};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sp_runtime::generic::{BlockId};
use sp_runtime::Justification;
use primitives::{H256, Blake2Hasher};
use primitives::storage::{StorageKey, ChildInfo};
use sp_core::{H256, Blake2Hasher};
use sp_core::storage::{StorageKey, ChildInfo};
/// Local client abstraction for the network.
pub trait Client<Block: BlockT>: Send + Sync {
@@ -93,7 +93,7 @@ impl<Block: BlockT> FinalityProofProvider<Block> for () {
}
impl<B, E, Block, RA> Client<Block> for SubstrateClient<B, E, Block, RA> where
B: client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
B: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
Self: BlockImport<Block, Error=ConsensusError>,
Block: BlockT<Hash=H256>,
+1 -1
View File
@@ -26,7 +26,7 @@ use crate::chain::{Client, FinalityProofProvider};
use crate::on_demand_layer::OnDemand;
use crate::service::{ExHashT, TransactionPool};
use bitflags::bitflags;
use consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue};
use sp_consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue};
use sp_runtime::traits::{Block as BlockT};
use libp2p::identity::{Keypair, ed25519};
use libp2p::wasm_ext;
+1 -1
View File
@@ -63,7 +63,7 @@ use libp2p::multiaddr::Protocol;
use log::{debug, info, trace, warn};
use std::{cmp, collections::VecDeque, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use primitives::hexdisplay::HexDisplay;
use sp_core::hexdisplay::HexDisplay;
/// Implementation of `NetworkBehaviour` that discovers the nodes on the network.
pub struct DiscoveryBehaviour<TSubstream> {
+1 -1
View File
@@ -195,7 +195,7 @@ pub use libp2p::multiaddr;
pub use message::{generic as generic_message, RequestId, Status as StatusMessage};
pub use on_demand_layer::{OnDemand, RemoteResponse};
pub use peerset::ReputationChange;
pub use sc_peerset::ReputationChange;
// Used by the `construct_simple_protocol!` macro.
#[doc(hidden)]
@@ -23,7 +23,7 @@ use futures::{prelude::*, sync::mpsc, sync::oneshot};
use futures03::compat::{Compat01As03, Future01CompatExt as _};
use parking_lot::Mutex;
use sp_blockchain::Error as ClientError;
use client_api::{Fetcher, FetchChecker, RemoteHeaderRequest,
use sc_client_api::{Fetcher, FetchChecker, RemoteHeaderRequest,
RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest,
RemoteReadChildRequest, RemoteBodyRequest};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
+15 -15
View File
@@ -24,8 +24,8 @@ use libp2p::{Multiaddr, PeerId};
use libp2p::core::{ConnectedPoint, nodes::Substream, muxing::StreamMuxerBox};
use libp2p::swarm::{ProtocolsHandler, IntoProtocolsHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use primitives::storage::{StorageKey, ChildInfo};
use consensus::{
use sp_core::storage::{StorageKey, ChildInfo};
use sp_consensus::{
BlockOrigin,
block_validation::BlockAnnounceValidator,
import_queue::{BlockImportResult, BlockImportError, IncomingBlock, Origin}
@@ -50,7 +50,7 @@ use std::fmt::Write;
use std::{cmp, num::NonZeroUsize, time};
use log::{log, Level, trace, debug, warn, error};
use crate::chain::{Client, FinalityProofProvider};
use client_api::{FetchChecker, ChangesProof, StorageProof};
use sc_client_api::{FetchChecker, ChangesProof, StorageProof};
use crate::error;
use util::LruHashSet;
@@ -89,7 +89,7 @@ const MAX_CONSENSUS_MESSAGES: usize = 256;
const LIGHT_MAXIMAL_BLOCKS_DIFFERENCE: u64 = 8192;
mod rep {
use peerset::ReputationChange as Rep;
use sc_peerset::ReputationChange as Rep;
/// Reputation change when a peer is "clogged", meaning that it's not fast enough to process our
/// messages.
pub const CLOGGED_PEER: Rep = Rep::new(-(1 << 12), "Clogged message queue");
@@ -140,7 +140,7 @@ pub struct Protocol<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> {
// Connected peers pending Status message.
handshaking_peers: HashMap<PeerId, HandshakingPeer>,
/// Used to report reputation changes.
peerset_handle: peerset::PeersetHandle,
peerset_handle: sc_peerset::PeersetHandle,
transaction_pool: Arc<dyn TransactionPool<H, B>>,
/// When asked for a proof of finality, we use this struct to build one.
finality_proof_provider: Option<Arc<dyn FinalityProofProvider<B>>>,
@@ -195,11 +195,11 @@ pub struct PeerInfo<B: BlockT> {
struct LightDispatchIn<'a> {
behaviour: &'a mut LegacyProto<Substream<StreamMuxerBox>>,
peerset: peerset::PeersetHandle,
peerset: sc_peerset::PeersetHandle,
}
impl<'a, B: BlockT> LightDispatchNetwork<B> for LightDispatchIn<'a> {
fn report_peer(&mut self, who: &PeerId, reputation: peerset::ReputationChange) {
fn report_peer(&mut self, who: &PeerId, reputation: sc_peerset::ReputationChange) {
self.peerset.report_peer(who.clone(), reputation)
}
@@ -323,7 +323,7 @@ impl<'a, B: BlockT> LightDispatchNetwork<B> for LightDispatchIn<'a> {
pub trait Context<B: BlockT> {
/// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or
/// irresponsible or appeared lazy.
fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange);
fn report_peer(&mut self, who: PeerId, reputation: sc_peerset::ReputationChange);
/// Force disconnecting from a peer. Use this when a peer misbehaved.
fn disconnect_peer(&mut self, who: PeerId);
@@ -339,21 +339,21 @@ pub trait Context<B: BlockT> {
struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
behaviour: &'a mut LegacyProto<Substream<StreamMuxerBox>>,
context_data: &'a mut ContextData<B, H>,
peerset_handle: &'a peerset::PeersetHandle,
peerset_handle: &'a sc_peerset::PeersetHandle,
}
impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> {
fn new(
context_data: &'a mut ContextData<B, H>,
behaviour: &'a mut LegacyProto<Substream<StreamMuxerBox>>,
peerset_handle: &'a peerset::PeersetHandle,
peerset_handle: &'a sc_peerset::PeersetHandle,
) -> Self {
ProtocolContext { context_data, peerset_handle, behaviour }
}
}
impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context<B> for ProtocolContext<'a, B, H> {
fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange) {
fn report_peer(&mut self, who: PeerId, reputation: sc_peerset::ReputationChange) {
self.peerset_handle.report_peer(who, reputation)
}
@@ -437,9 +437,9 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
finality_proof_provider: Option<Arc<dyn FinalityProofProvider<B>>>,
finality_proof_request_builder: Option<BoxFinalityProofRequestBuilder<B>>,
protocol_id: ProtocolId,
peerset_config: peerset::PeersetConfig,
peerset_config: sc_peerset::PeersetConfig,
block_announce_validator: Box<dyn BlockAnnounceValidator<B> + Send>
) -> error::Result<(Protocol<B, S, H>, peerset::PeersetHandle)> {
) -> error::Result<(Protocol<B, S, H>, sc_peerset::PeersetHandle)> {
let info = chain.info();
let sync = ChainSync::new(
config.roles,
@@ -459,7 +459,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
imp_p
};
let (peerset, peerset_handle) = peerset::Peerset::from_config(peerset_config);
let (peerset, peerset_handle) = sc_peerset::Peerset::from_config(peerset_config);
let versions = &((MIN_VERSION as u8)..=(CURRENT_VERSION as u8)).collect::<Vec<u8>>();
let behaviour = LegacyProto::new(protocol_id, versions, peerset);
@@ -853,7 +853,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
}
/// Adjusts the reputation of a node.
pub fn report_peer(&self, who: PeerId, reputation: peerset::ReputationChange) {
pub fn report_peer(&self, who: PeerId, reputation: sc_peerset::ReputationChange) {
self.peerset_handle.report_peer(who, reputation)
}
@@ -65,7 +65,7 @@ pub struct LegacyProto< TSubstream> {
protocol: RegisteredProtocol,
/// Receiver for instructions about who to connect to or disconnect from.
peerset: peerset::Peerset,
peerset: sc_peerset::Peerset,
/// List of peers in our state.
peers: FnvHashMap<PeerId, PeerState>,
@@ -76,7 +76,7 @@ pub struct LegacyProto< TSubstream> {
/// We generate indices to identify incoming connections. This is the next value for the index
/// to use when a connection is incoming.
next_incoming_index: peerset::IncomingIndex,
next_incoming_index: sc_peerset::IncomingIndex,
/// Events to produce from `poll()`.
events: SmallVec<[NetworkBehaviourAction<CustomProtoHandlerIn, LegacyProtoOut>; 4]>,
@@ -183,7 +183,7 @@ struct IncomingPeer {
/// connection corresponding to it has been closed or replaced already.
alive: bool,
/// Id that the we sent to the peerset.
incoming_id: peerset::IncomingIndex,
incoming_id: sc_peerset::IncomingIndex,
}
/// Event that can be emitted by the `LegacyProto`.
@@ -230,7 +230,7 @@ impl<TSubstream> LegacyProto<TSubstream> {
pub fn new(
protocol: impl Into<ProtocolId>,
versions: &[u8],
peerset: peerset::Peerset,
peerset: sc_peerset::Peerset,
) -> Self {
let protocol = RegisteredProtocol::new(protocol, versions);
@@ -239,7 +239,7 @@ impl<TSubstream> LegacyProto<TSubstream> {
peerset,
peers: FnvHashMap::default(),
incoming: SmallVec::new(),
next_incoming_index: peerset::IncomingIndex(0),
next_incoming_index: sc_peerset::IncomingIndex(0),
events: SmallVec::new(),
marker: PhantomData,
}
@@ -520,7 +520,7 @@ impl<TSubstream> LegacyProto<TSubstream> {
}
/// Function that is called when the peerset wants us to accept an incoming node.
fn peerset_report_accept(&mut self, index: peerset::IncomingIndex) {
fn peerset_report_accept(&mut self, index: sc_peerset::IncomingIndex) {
let incoming = if let Some(pos) = self.incoming.iter().position(|i| i.incoming_id == index) {
self.incoming.remove(pos)
} else {
@@ -564,7 +564,7 @@ impl<TSubstream> LegacyProto<TSubstream> {
}
/// Function that is called when the peerset wants us to reject an incoming node.
fn peerset_report_reject(&mut self, index: peerset::IncomingIndex) {
fn peerset_report_reject(&mut self, index: sc_peerset::IncomingIndex) {
let incoming = if let Some(pos) = self.incoming.iter().position(|i| i.incoming_id == index) {
self.incoming.remove(pos)
} else {
@@ -942,7 +942,7 @@ where
// again in the short term.
self.peerset.report_peer(
source.clone(),
peerset::ReputationChange::new(i32::min_value(), "Protocol error")
sc_peerset::ReputationChange::new(i32::min_value(), "Protocol error")
);
self.disconnect_peer_inner(&source, Some(Duration::from_secs(5)));
}
@@ -965,16 +965,16 @@ where
futures03::Stream::poll_next(Pin::new(&mut self.peerset), cx)
).map(|v| Ok::<_, ()>(v)).compat();
match peerset01.poll() {
Ok(Async::Ready(Some(peerset::Message::Accept(index)))) => {
Ok(Async::Ready(Some(sc_peerset::Message::Accept(index)))) => {
self.peerset_report_accept(index);
}
Ok(Async::Ready(Some(peerset::Message::Reject(index)))) => {
Ok(Async::Ready(Some(sc_peerset::Message::Reject(index)))) => {
self.peerset_report_reject(index);
}
Ok(Async::Ready(Some(peerset::Message::Connect(id)))) => {
Ok(Async::Ready(Some(sc_peerset::Message::Connect(id)))) => {
self.peerset_report_connect(id);
}
Ok(Async::Ready(Some(peerset::Message::Drop(id)))) => {
Ok(Async::Ready(Some(sc_peerset::Message::Drop(id)))) => {
self.peerset_report_disconnect(id);
}
Ok(Async::Ready(None)) => {
@@ -68,7 +68,7 @@ fn build_nodes()
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
.boxed();
let (peerset, _) = peerset::Peerset::from_config(peerset::PeersetConfig {
let (peerset, _) = sc_peerset::Peerset::from_config(sc_peerset::PeersetConfig {
in_peers: 25,
out_peers: 25,
bootnodes: if index == 0 {
@@ -26,14 +26,14 @@ use log::{trace, info};
use futures::sync::oneshot::{Sender as OneShotSender};
use linked_hash_map::{Entry, LinkedHashMap};
use sp_blockchain::Error as ClientError;
use client_api::{FetchChecker, RemoteHeaderRequest,
use sc_client_api::{FetchChecker, RemoteHeaderRequest,
RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof,
RemoteReadChildRequest, RemoteBodyRequest, StorageProof};
use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId};
use libp2p::PeerId;
use crate::config::Roles;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use peerset::ReputationChange;
use sc_peerset::ReputationChange;
/// Remote request timeout.
const REQUEST_TIMEOUT: Duration = Duration::from_secs(15);
@@ -681,10 +681,10 @@ pub mod tests {
use std::sync::Arc;
use std::time::Instant;
use futures::{Future, sync::oneshot};
use primitives::storage::ChildInfo;
use sp_core::storage::ChildInfo;
use sp_runtime::traits::{Block as BlockT, NumberFor, Header as HeaderT};
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use client_api::{FetchChecker, RemoteHeaderRequest,
use sc_client_api::{FetchChecker, RemoteHeaderRequest,
ChangesProof, RemoteCallRequest, RemoteReadRequest,
RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest};
use crate::config::Roles;
@@ -1233,7 +1233,7 @@ pub mod tests {
assert_eq!(light_dispatch.active_peers.len(), 1);
let block = message::BlockData::<Block> {
hash: primitives::H256::random(),
hash: sp_core::H256::random(),
header: None,
body: Some(Vec::new()),
message_queue: None,
@@ -1271,7 +1271,7 @@ pub mod tests {
let response = {
let blocks: Vec<_> = (0..3).map(|_| message::BlockData::<Block> {
hash: primitives::H256::random(),
hash: sp_core::H256::random(),
header: None,
body: Some(Vec::new()),
message_queue: None,
@@ -26,7 +26,7 @@ pub use self::generic::{
FinalityProofRequest, FinalityProofResponse,
FromBlock, RemoteReadChildRequest,
};
use client_api::StorageProof;
use sc_client_api::StorageProof;
/// A unique ID of a request.
pub type RequestId = u64;
@@ -28,9 +28,9 @@
//!
use blocks::BlockCollection;
use client_api::ClientInfo;
use sc_client_api::ClientInfo;
use sp_blockchain::Error as ClientError;
use consensus::{BlockOrigin, BlockStatus,
use sp_consensus::{BlockOrigin, BlockStatus,
block_validation::{BlockAnnounceValidator, Validation},
import_queue::{IncomingBlock, BlockImportResult, BlockImportError}
};
@@ -73,7 +73,7 @@ const MAJOR_SYNC_BLOCKS: u8 = 5;
const ANNOUNCE_HISTORY_SIZE: usize = 64;
mod rep {
use peerset::ReputationChange as Rep;
use sc_peerset::ReputationChange as Rep;
/// Reputation change when a peer sent us a message that led to a
/// database read error.
pub const BLOCKCHAIN_READ_ERROR: Rep = Rep::new(-(1 << 16), "DB Error");
@@ -230,7 +230,7 @@ pub struct Status<B: BlockT> {
/// A peer did not behave as expected and should be reported.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BadPeer(pub PeerId, pub peerset::ReputationChange);
pub struct BadPeer(pub PeerId, pub sc_peerset::ReputationChange);
impl fmt::Display for BadPeer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -216,7 +216,7 @@ mod test {
use super::{BlockCollection, BlockData, BlockRangeState};
use crate::{message, PeerId};
use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper};
use primitives::H256;
use sp_core::H256;
type Block = RawBlock<ExtrinsicWrapper<u64>>;
+6 -6
View File
@@ -28,8 +28,8 @@
use std::{collections::{HashMap, HashSet}, fs, marker::PhantomData, io, path::Path};
use std::sync::{Arc, atomic::{AtomicBool, AtomicUsize, Ordering}};
use consensus::import_queue::{ImportQueue, Link};
use consensus::import_queue::{BlockImportResult, BlockImportError};
use sp_consensus::import_queue::{ImportQueue, Link};
use sp_consensus::import_queue::{BlockImportResult, BlockImportError};
use futures::{prelude::*, sync::mpsc};
use futures03::TryFutureExt as _;
use log::{warn, error, info};
@@ -37,7 +37,7 @@ use libp2p::{PeerId, Multiaddr, kad::record};
use libp2p::core::{transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::swarm::NetworkBehaviour;
use parking_lot::Mutex;
use peerset::PeersetHandle;
use sc_peerset::PeersetHandle;
use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId};
use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}};
@@ -176,7 +176,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
}
}
let peerset_config = peerset::PeersetConfig {
let peerset_config = sc_peerset::PeersetConfig {
in_peers: params.network_config.in_peers,
out_peers: params.network_config.out_peers,
bootnodes,
@@ -604,7 +604,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkServic
}
}
impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> consensus::SyncOracle
impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> sp_consensus::SyncOracle
for NetworkService<B, S, H>
{
fn is_major_syncing(&mut self) -> bool {
@@ -616,7 +616,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> consensus::Sy
}
}
impl<'a, B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> consensus::SyncOracle
impl<'a, B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> sp_consensus::SyncOracle
for &'a NetworkService<B, S, H>
{
fn is_major_syncing(&mut self) -> bool {
+8 -8
View File
@@ -15,16 +15,16 @@ futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
futures-timer = "0.4.0"
rand = "0.7.2"
libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] }
consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
client = { package = "sc-client", path = "../../" }
client-api = { package = "sc-client-api", path = "../../api" }
sp-consensus = { path = "../../../primitives/consensus/common" }
sc-client = { path = "../../" }
sc-client-api = { path = "../../api" }
sp-blockchain = { path = "../../../primitives/blockchain" }
sp-runtime = { path = "../../../primitives/runtime" }
primitives = { package = "sp-core", path = "../../../primitives/core" }
block-builder = { package = "sc-block-builder", path = "../../block-builder" }
babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" }
sp-core = { path = "../../../primitives/core" }
sc-block-builder = { path = "../../block-builder" }
sp-consensus-babe = { path = "../../../primitives/consensus/babe" }
env_logger = "0.7.0"
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
test_runtime = { package = "substrate-test-runtime", path = "../../../test-utils/runtime" }
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
substrate-test-runtime = { path = "../../../test-utils/runtime" }
tempfile = "3.1.0"
tokio = "0.1.22"
@@ -16,17 +16,17 @@
//! Testing block import logic.
use consensus::ImportedAux;
use consensus::import_queue::{
use sp_consensus::ImportedAux;
use sp_consensus::import_queue::{
import_single_block, BasicQueue, BlockImportError, BlockImportResult, IncomingBlock,
};
use test_client::{self, prelude::*};
use test_client::runtime::{Block, Hash};
use substrate_test_runtime_client::{self, prelude::*};
use substrate_test_runtime_client::runtime::{Block, Hash};
use sp_runtime::generic::BlockId;
use super::*;
fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock<Block>) {
let client = test_client::new();
let client = substrate_test_runtime_client::new();
let block = client.new_block(Default::default()).unwrap().bake().unwrap();
client.import(BlockOrigin::File, block).unwrap();
@@ -52,7 +52,7 @@ fn import_single_good_block_works() {
let mut expected_aux = ImportedAux::default();
expected_aux.is_new_best = true;
match import_single_block(&mut test_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) {
match import_single_block(&mut substrate_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) {
Ok(BlockImportResult::ImportedUnknown(ref num, ref aux, ref org))
if *num == number && *aux == expected_aux && *org == Some(peer_id) => {}
r @ _ => panic!("{:?}", r)
@@ -72,7 +72,7 @@ fn import_single_good_known_block_is_ignored() {
fn import_single_good_block_without_header_fails() {
let (_, _, _, peer_id, mut block) = prepare_good_block();
block.header = None;
match import_single_block(&mut test_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) {
match import_single_block(&mut substrate_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) {
Err(BlockImportError::IncompleteHeader(ref org)) if *org == Some(peer_id) => {}
_ => panic!()
}
@@ -83,7 +83,7 @@ fn async_import_queue_drops() {
// Perform this test multiple times since it exhibits non-deterministic behavior.
for _ in 0..100 {
let verifier = PassThroughVerifier(true);
let queue = BasicQueue::new(verifier, Box::new(test_client::new()), None, None);
let queue = BasicQueue::new(verifier, Box::new(substrate_test_runtime_client::new()), None, None);
drop(queue);
}
}
+22 -22
View File
@@ -30,42 +30,42 @@ use sc_network::FinalityProofProvider;
use sp_blockchain::{
Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId},
};
use client_api::{
use sc_client_api::{
ClientInfo, BlockchainEvents, BlockImportNotification,
FinalityNotifications, ImportNotifications,
FinalityNotification,
backend::{AuxStore, Backend, Finalizer}
};
use block_builder::BlockBuilder;
use client::LongestChain;
use sc_block_builder::BlockBuilder;
use sc_client::LongestChain;
use sc_network::config::Roles;
use consensus::block_validation::DefaultBlockAnnounceValidator;
use consensus::import_queue::BasicQueue;
use consensus::import_queue::{
use sp_consensus::block_validation::DefaultBlockAnnounceValidator;
use sp_consensus::import_queue::BasicQueue;
use sp_consensus::import_queue::{
BoxBlockImport, BoxJustificationImport, Verifier, BoxFinalityProofImport,
};
use consensus::block_import::{BlockImport, ImportResult};
use consensus::Error as ConsensusError;
use consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport};
use sp_consensus::block_import::{BlockImport, ImportResult};
use sp_consensus::Error as ConsensusError;
use sp_consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport};
use futures::prelude::*;
use futures03::{StreamExt as _, TryStreamExt as _};
use sc_network::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId};
use sc_network::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder};
use libp2p::PeerId;
use parking_lot::Mutex;
use primitives::H256;
use sp_core::H256;
use sc_network::{Context, ProtocolConfig};
use sp_runtime::generic::{BlockId, OpaqueDigestItemId};
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
use sp_runtime::Justification;
use sc_network::TransactionPool;
use sc_network::specialization::NetworkSpecialization;
use test_client::{self, AccountKeyring};
use substrate_test_runtime_client::{self, AccountKeyring};
pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer};
pub use test_client::{TestClient, TestClientBuilder, TestClientBuilderExt};
pub use substrate_test_runtime_client::runtime::{Block, Extrinsic, Hash, Transfer};
pub use substrate_test_runtime_client::{TestClient, TestClientBuilder, TestClientBuilderExt};
type AuthorityId = babe_primitives::AuthorityId;
type AuthorityId = sp_consensus_babe::AuthorityId;
/// A Verifier that accepts all blocks and passes them on with the configured
/// finality to be imported.
@@ -129,14 +129,14 @@ impl NetworkSpecialization<Block> for DummySpecialization {
}
pub type PeersFullClient =
client::Client<test_client::Backend, test_client::Executor, Block, test_client::runtime::RuntimeApi>;
sc_client::Client<substrate_test_runtime_client::Backend, substrate_test_runtime_client::Executor, Block, substrate_test_runtime_client::runtime::RuntimeApi>;
pub type PeersLightClient =
client::Client<test_client::LightBackend, test_client::LightExecutor, Block, test_client::runtime::RuntimeApi>;
sc_client::Client<substrate_test_runtime_client::LightBackend, substrate_test_runtime_client::LightExecutor, Block, substrate_test_runtime_client::runtime::RuntimeApi>;
#[derive(Clone)]
pub enum PeersClient {
Full(Arc<PeersFullClient>, Arc<test_client::Backend>),
Light(Arc<PeersLightClient>, Arc<test_client::LightBackend>),
Full(Arc<PeersFullClient>, Arc<substrate_test_runtime_client::Backend>),
Light(Arc<PeersLightClient>, Arc<substrate_test_runtime_client::LightBackend>),
}
impl PeersClient {
@@ -218,8 +218,8 @@ pub struct Peer<D, S: NetworkSpecialization<Block>> {
/// We keep a copy of the block_import so that we can invoke it for locally-generated blocks,
/// instead of going through the import queue.
block_import: Box<dyn BlockImport<Block, Error = ConsensusError>>,
select_chain: Option<LongestChain<test_client::Backend, Block>>,
backend: Option<Arc<test_client::Backend>>,
select_chain: Option<LongestChain<substrate_test_runtime_client::Backend, Block>>,
backend: Option<Arc<substrate_test_runtime_client::Backend>>,
network: NetworkWorker<Block, S, <Block as BlockT>::Hash>,
imported_blocks_stream: Box<dyn Stream<Item = BlockImportNotification<Block>, Error = ()> + Send>,
finality_notification_stream: Box<dyn Stream<Item = FinalityNotification<Block>, Error = ()> + Send>,
@@ -237,7 +237,7 @@ impl<D, S: NetworkSpecialization<Block>> Peer<D, S> {
}
// Returns a clone of the local SelectChain, only available on full nodes
pub fn select_chain(&self) -> Option<LongestChain<test_client::Backend, Block>> {
pub fn select_chain(&self) -> Option<LongestChain<substrate_test_runtime_client::Backend, Block>> {
self.select_chain.clone()
}
@@ -608,7 +608,7 @@ pub trait TestNetFactory: Sized {
let mut config = config.clone();
config.roles = Roles::LIGHT;
let (c, backend) = test_client::new_light();
let (c, backend) = substrate_test_runtime_client::new_light();
let client = Arc::new(c);
let (
block_import,
+1 -1
View File
@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use sc_network::config::Roles;
use consensus::BlockOrigin;
use sp_consensus::BlockOrigin;
use futures03::TryFutureExt as _;
use std::time::Duration;
use tokio::runtime::current_thread;