[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
@@ -17,7 +17,7 @@
//! Schema for slots in the aux-db.
use codec::{Encode, Decode};
use client_api::backend::AuxStore;
use sc_client_api::backend::AuxStore;
use sp_blockchain::{Result as ClientResult, Error as ClientError};
use sp_runtime::traits::Header;
@@ -151,10 +151,10 @@ pub fn check_equivocation<C, H, P>(
#[cfg(test)]
mod test {
use primitives::{sr25519, Pair};
use primitives::hash::H256;
use sp_core::{sr25519, Pair};
use sp_core::hash::H256;
use sp_runtime::testing::{Header as HeaderTest, Digest as DigestTest};
use test_client;
use substrate_test_runtime_client;
use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation};
@@ -175,7 +175,7 @@ mod test {
#[test]
fn check_equivocation_works() {
let client = test_client::new();
let client = substrate_test_runtime_client::new();
let (pair, _seed) = sr25519::Pair::generate();
let public = pair.public();
+12 -12
View File
@@ -31,23 +31,23 @@ use slots::Slots;
pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND};
use codec::{Decode, Encode};
use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData};
use sp_consensus::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData};
use futures::{prelude::*, future::{self, Either}};
use futures_timer::Delay;
use inherents::{InherentData, InherentDataProviders};
use sp_inherents::{InherentData, InherentDataProviders};
use log::{debug, error, info, warn};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi};
use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc, time::{Instant, Duration}};
use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO};
use parking_lot::Mutex;
use client_api;
use sc_client_api;
/// A worker that should be invoked at every new slot.
pub trait SlotWorker<B: BlockT> {
/// The type of the future that will be returned when a new slot is
/// triggered.
type OnSlot: Future<Output = Result<(), consensus_common::Error>>;
type OnSlot: Future<Output = Result<(), sp_consensus::Error>>;
/// Called when a new slot is triggered.
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot;
@@ -80,7 +80,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
/// Returns the epoch data necessary for authoring. For time-dependent epochs,
/// use the provided slot number as a canonical source of time.
fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result<Self::EpochData, consensus_common::Error>;
fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result<Self::EpochData, sp_consensus::Error>;
/// Returns the number of authorities given the epoch data.
fn authorities_len(&self, epoch_data: &Self::EpochData) -> usize;
@@ -102,7 +102,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
&B::Hash,
Vec<B::Extrinsic>,
Self::Claim,
) -> consensus_common::BlockImportParams<B> + Send>;
) -> sp_consensus::BlockImportParams<B> + Send>;
/// Whether to force authoring if offline.
fn force_authoring(&self) -> bool;
@@ -111,7 +111,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
fn sync_oracle(&mut self) -> &mut Self::SyncOracle;
/// Returns a `Proposer` to author on top of the given block.
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, consensus_common::Error>;
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, sp_consensus::Error>;
/// Remaining duration of the slot.
fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration {
@@ -134,7 +134,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
/// Implements the `on_slot` functionality from `SlotWorker`.
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo)
-> Pin<Box<dyn Future<Output = Result<(), consensus_common::Error>> + Send>> where
-> Pin<Box<dyn Future<Output = Result<(), sp_consensus::Error>> + Send>> where
Self: Send + Sync,
<Self::Proposer as Proposer<B>>::Create: Unpin + Send + 'static,
{
@@ -222,7 +222,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
logs,
},
slot_remaining_duration,
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)));
).map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e)));
let delay: Box<dyn Future<Output=()> + Unpin + Send> = match proposing_remaining_duration {
Some(r) => Box::new(Delay::new(r)),
None => Box::new(future::pending()),
@@ -239,7 +239,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
telemetry!(CONSENSUS_INFO; "slots.discarding_proposal_took_too_long";
"slot" => slot_number,
);
Err(consensus_common::Error::ClientImport("Timeout in the Slots proposer".into()))
Err(sp_consensus::Error::ClientImport("Timeout in the Slots proposer".into()))
},
}));
@@ -293,7 +293,7 @@ pub trait SlotCompatible {
fn extract_timestamp_and_slot(
&self,
inherent: &InherentData,
) -> Result<(u64, u64, std::time::Duration), consensus_common::Error>;
) -> Result<(u64, u64, std::time::Duration), sp_consensus::Error>;
/// Get the difference between chain time and local time. Defaults to
/// always returning zero.
@@ -417,7 +417,7 @@ impl<T: Clone> SlotDuration<T> {
/// `slot_key` is marked as `'static`, as it should really be a
/// compile-time constant.
pub fn get_or_compute<B: BlockT, C, CB>(client: &C, cb: CB) -> sp_blockchain::Result<Self> where
C: client_api::backend::AuxStore,
C: sc_client_api::backend::AuxStore,
C: ProvideRuntimeApi,
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> sp_blockchain::Result<T>,
T: SlotData + Encode + Decode + Debug,
@@ -19,9 +19,9 @@
//! This is used instead of `futures_timer::Interval` because it was unreliable.
use super::SlotCompatible;
use consensus_common::Error;
use sp_consensus::Error;
use futures::{prelude::*, task::Context, task::Poll};
use inherents::{InherentData, InherentDataProviders};
use sp_inherents::{InherentData, InherentDataProviders};
use std::{pin::Pin, time::{Duration, Instant}};
use futures_timer::Delay;
@@ -135,7 +135,7 @@ impl<SC: SlotCompatible + Unpin> Stream for Slots<SC> {
let inherent_data = match self.inherent_data_providers.create_inherent_data() {
Ok(id) => id,
Err(err) => return Poll::Ready(Some(Err(consensus_common::Error::InherentData(err)))),
Err(err) => return Poll::Ready(Some(Err(sp_consensus::Error::InherentData(err)))),
};
let result = self.timestamp_extractor.extract_timestamp_and_slot(&inherent_data);
let (timestamp, slot_num, offset) = match result {