[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
+1 -1
View File
@@ -40,7 +40,7 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result<Client, Box<dyn std
let wasm_ext = wasm_ext::ExtTransport::new(wasm_ext);
let chain_spec = ChainSpec::FlamingFir.load().map_err(|e| format!("{:?}", e))?;
let mut config = Configuration::<(), _, _>::default_with_spec_and_base_path(chain_spec, None);
config.network.transport = network::config::TransportConfig::Normal {
config.network.transport = sc_network::config::TransportConfig::Normal {
wasm_external_transport: Some(wasm_ext.clone()),
allow_private_ipv4: true,
enable_mdns: false,
+24 -24
View File
@@ -16,8 +16,8 @@
//! Substrate chain configurations.
use chain_spec::ChainSpecExtension;
use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
use sc_chain_spec::ChainSpecExtension;
use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
use serde::{Serialize, Deserialize};
use node_runtime::{
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig,
@@ -30,9 +30,9 @@ use sc_service;
use hex_literal::hex;
use sc_telemetry::TelemetryEndpoints;
use grandpa_primitives::{AuthorityId as GrandpaId};
use babe_primitives::{AuthorityId as BabeId};
use im_online::sr25519::{AuthorityId as ImOnlineId};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::{AuthorityId as BabeId};
use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}};
pub use node_primitives::{AccountId, Balance, Signature};
@@ -49,7 +49,7 @@ const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)]
pub struct Extensions {
/// Block numbers with known hashes.
pub fork_blocks: client::ForkBlocks<Block>,
pub fork_blocks: sc_client::ForkBlocks<Block>,
}
/// Specialized `ChainSpec`.
@@ -229,24 +229,24 @@ pub fn testnet_genesis(
code: WASM_BINARY.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(BalancesConfig {
pallet_balances: Some(BalancesConfig {
balances: endowed_accounts.iter().cloned()
.map(|k| (k, ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
vesting: vec![],
}),
indices: Some(IndicesConfig {
pallet_indices: Some(IndicesConfig {
ids: endowed_accounts.iter().cloned()
.chain(initial_authorities.iter().map(|x| x.0.clone()))
.collect::<Vec<_>>(),
}),
session: Some(SessionConfig {
pallet_session: Some(SessionConfig {
keys: initial_authorities.iter().map(|x| {
(x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()))
}).collect::<Vec<_>>(),
}),
staking: Some(StakingConfig {
pallet_staking: Some(StakingConfig {
current_era: 0,
validator_count: initial_authorities.len() as u32 * 2,
minimum_validator_count: initial_authorities.len() as u32,
@@ -257,41 +257,41 @@ pub fn testnet_genesis(
slash_reward_fraction: Perbill::from_percent(10),
.. Default::default()
}),
democracy: Some(DemocracyConfig::default()),
collective_Instance1: Some(CouncilConfig {
pallet_democracy: Some(DemocracyConfig::default()),
pallet_collective_Instance1: Some(CouncilConfig {
members: endowed_accounts.iter().cloned()
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
phantom: Default::default(),
}),
collective_Instance2: Some(TechnicalCommitteeConfig {
pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
members: endowed_accounts.iter().cloned()
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
phantom: Default::default(),
}),
contracts: Some(ContractsConfig {
current_schedule: contracts::Schedule {
pallet_contracts: Some(ContractsConfig {
current_schedule: pallet_contracts::Schedule {
enable_println, // this should only be enabled on development chains
..Default::default()
},
gas_price: 1 * MILLICENTS,
}),
sudo: Some(SudoConfig {
pallet_sudo: Some(SudoConfig {
key: root_key,
}),
babe: Some(BabeConfig {
pallet_babe: Some(BabeConfig {
authorities: vec![],
}),
im_online: Some(ImOnlineConfig {
pallet_im_online: Some(ImOnlineConfig {
keys: vec![],
}),
authority_discovery: Some(AuthorityDiscoveryConfig {
pallet_authority_discovery: Some(AuthorityDiscoveryConfig {
keys: vec![],
}),
grandpa: Some(GrandpaConfig {
pallet_grandpa: Some(GrandpaConfig {
authorities: vec![],
}),
membership_Instance1: Some(Default::default()),
treasury: Some(Default::default()),
pallet_membership_Instance1: Some(Default::default()),
pallet_treasury: Some(Default::default()),
}
}
@@ -351,7 +351,7 @@ pub(crate) mod tests {
use super::*;
use crate::service::new_full;
use sc_service::Roles;
use service_test;
use sc_service_test;
fn local_testnet_genesis_instant_single() -> GenesisConfig {
testnet_genesis(
@@ -395,7 +395,7 @@ pub(crate) mod tests {
#[test]
#[ignore]
fn test_connectivity() {
service_test::connectivity(
sc_service_test::connectivity(
integration_test_config_with_two_authorities(),
|config| new_full(config),
|mut config| {
+11 -11
View File
@@ -22,19 +22,19 @@ use rand::{Rng, SeedableRng};
use rand::rngs::StdRng;
use codec::{Encode, Decode};
use keyring::sr25519::Keyring;
use sp_keyring::sr25519::Keyring;
use node_runtime::{
Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall, ExistentialDeposit,
MinimumPeriod
};
use node_primitives::Signature;
use primitives::{sr25519, crypto::Pair};
use sp_core::{sr25519, crypto::Pair};
use sp_runtime::{
generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount}
};
use node_transaction_factory::RuntimeAdapter;
use node_transaction_factory::modes::Mode;
use inherents::InherentData;
use sp_inherents::InherentData;
use sp_timestamp;
use sp_finality_tracker;
@@ -56,12 +56,12 @@ type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
impl<Number> FactoryState<Number> {
fn build_extra(index: node_primitives::Index, phase: u64) -> node_runtime::SignedExtra {
(
system::CheckVersion::new(),
system::CheckGenesis::new(),
system::CheckEra::from(Era::mortal(256, phase)),
system::CheckNonce::from(index),
system::CheckWeight::new(),
transaction_payment::ChargeTransactionPayment::from(0),
frame_system::CheckVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(Era::mortal(256, phase)),
frame_system::CheckNonce::from(index),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(0),
Default::default(),
)
}
@@ -149,7 +149,7 @@ impl RuntimeAdapter for FactoryState<Number> {
signed: Some((sender.clone(), Self::build_extra(index, phase))),
function: Call::Balances(
BalancesCall::transfer(
indices::address::Address::Id(destination.clone().into()),
pallet_indices::address::Address::Id(destination.clone().into()),
(*amount).into()
)
)
@@ -253,7 +253,7 @@ fn sign<RA: RuntimeAdapter>(
}
}).into();
UncheckedExtrinsic {
signature: Some((indices::address::Address::Id(signed), signature, extra)),
signature: Some((pallet_indices::address::Address::Id(signed), signature, extra)),
function: payload.0,
}
}
+57 -57
View File
@@ -20,8 +20,8 @@
use std::sync::Arc;
use babe;
use client::{self, LongestChain};
use sc_consensus_babe;
use sc_client::{self, LongestChain};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use node_executor;
use node_primitives::Block;
@@ -29,17 +29,17 @@ use node_runtime::{GenesisConfig, RuntimeApi};
use sc_service::{
AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError},
};
use inherents::InherentDataProviders;
use network::construct_simple_protocol;
use sp_inherents::InherentDataProviders;
use sc_network::construct_simple_protocol;
use sc_service::{Service, NetworkStatus};
use client::{Client, LocalCallExecutor};
use client_db::Backend;
use sc_client::{Client, LocalCallExecutor};
use sc_client_db::Backend;
use sp_runtime::traits::Block as BlockT;
use node_executor::NativeExecutor;
use network::NetworkService;
use offchain::OffchainWorkers;
use primitives::Blake2Hasher;
use sc_network::NetworkService;
use sc_offchain::OffchainWorkers;
use sp_core::Blake2Hasher;
construct_simple_protocol! {
/// Demo protocol attachment for substrate.
@@ -54,19 +54,19 @@ macro_rules! new_full_start {
($config:expr) => {{
type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
let mut import_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new();
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
let builder = sc_service::ServiceBuilder::new_full::<
node_primitives::Block, node_runtime::RuntimeApi, node_executor::Executor
>($config)?
.with_select_chain(|_config, backend| {
Ok(client::LongestChain::new(backend.clone()))
Ok(sc_client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = txpool::FullChainApi::new(client.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
@@ -79,14 +79,14 @@ macro_rules! new_full_start {
)?;
let justification_import = grandpa_block_import.clone();
let (block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?,
let (block_import, babe_link) = sc_consensus_babe::block_import(
sc_consensus_babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
client.clone(),
)?;
let import_queue = babe::import_queue(
let import_queue = sc_consensus_babe::import_queue(
babe_link.clone(),
block_import.clone(),
Some(Box::new(justification_import)),
@@ -114,7 +114,7 @@ macro_rules! new_full_start {
macro_rules! new_full {
($config:expr, $with_startup_data: expr) => {{
use futures01::sync::mpsc;
use network::DhtEvent;
use sc_network::DhtEvent;
use futures::{
compat::Stream01CompatExt,
stream::StreamExt,
@@ -172,9 +172,9 @@ macro_rules! new_full {
.ok_or(sc_service::Error::SelectChainRequired)?;
let can_author_with =
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let babe_config = babe::BabeParams {
let babe_config = sc_consensus_babe::BabeParams {
keystore: service.keystore(),
client,
select_chain,
@@ -187,13 +187,13 @@ macro_rules! new_full {
can_author_with,
};
let babe = babe::start_babe(babe_config)?;
let babe = sc_consensus_babe::start_babe(babe_config)?;
service.spawn_essential_task(babe);
let future03_dht_event_rx = dht_event_rx.compat()
.map(|x| x.expect("<mpsc::channel::Receiver as Stream> never returns an error; qed"))
.boxed();
let authority_discovery = authority_discovery::AuthorityDiscovery::new(
let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new(
service.client(),
service.network(),
sentry_nodes,
@@ -280,14 +280,14 @@ type ConcreteClient =
#[allow(dead_code)]
type ConcreteBackend = Backend<ConcreteBlock>;
#[allow(dead_code)]
type ConcreteTransactionPool = txpool_api::MaintainableTransactionPool<
txpool::BasicPool<
txpool::FullChainApi<ConcreteClient, ConcreteBlock>,
type ConcreteTransactionPool = sp_transaction_pool::MaintainableTransactionPool<
sc_transaction_pool::BasicPool<
sc_transaction_pool::FullChainApi<ConcreteClient, ConcreteBlock>,
ConcreteBlock
>,
txpool::FullBasicPoolMaintainer<
sc_transaction_pool::FullBasicPoolMaintainer<
ConcreteClient,
txpool::FullChainApi<ConcreteClient, Block>
sc_transaction_pool::FullChainApi<ConcreteClient, Block>
>
>;
@@ -306,7 +306,7 @@ pub fn new_full<C: Send + Default + 'static>(config: NodeConfiguration<C>)
ConcreteTransactionPool,
OffchainWorkers<
ConcreteClient,
<ConcreteBackend as client_api::backend::Backend<Block, Blake2Hasher>>::OffchainStorage,
<ConcreteBackend as sc_client_api::backend::Backend<Block, Blake2Hasher>>::OffchainStorage,
ConcreteBlock,
>
>,
@@ -329,10 +329,10 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
.with_transaction_pool(|config, client, fetcher| {
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
@@ -350,14 +350,14 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();
let (babe_block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?,
let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
sc_consensus_babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
client.clone(),
)?;
let import_queue = babe::import_queue(
let import_queue = sc_consensus_babe::import_queue(
babe_link,
babe_block_import,
None,
@@ -390,15 +390,15 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
#[cfg(test)]
mod tests {
use std::sync::Arc;
use babe::CompatibleDigestItem;
use consensus_common::{
use sc_consensus_babe::CompatibleDigestItem;
use sp_consensus::{
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport,
};
use node_primitives::{Block, DigestItem, Signature};
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address};
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
use codec::{Encode, Decode};
use primitives::{crypto::Pair as CryptoPair, H256};
use sp_core::{crypto::Pair as CryptoPair, H256};
use sp_runtime::{
generic::{BlockId, Era, Digest, SignedPayload},
traits::Block as BlockT,
@@ -407,7 +407,7 @@ mod tests {
};
use sp_timestamp;
use sp_finality_tracker;
use keyring::AccountKeyring;
use sp_keyring::AccountKeyring;
use sc_service::{AbstractService, Roles};
use crate::service::new_full;
use sp_runtime::traits::IdentifyAccount;
@@ -416,10 +416,10 @@ mod tests {
#[cfg(feature = "rhd")]
fn test_sync() {
use primitives::ed25519::Pair;
use sp_core::ed25519::Pair;
use {service_test, Factory};
use client::{BlockImportParams, BlockOrigin};
use sc_client::{BlockImportParams, BlockOrigin};
let alice: Arc<ed25519::Pair> = Arc::new(Keyring::Alice.into());
let bob: Arc<ed25519::Pair> = Arc::new(Keyring::Bob.into());
@@ -467,8 +467,8 @@ mod tests {
let v: Vec<u8> = Decode::decode(&mut xt.as_slice()).unwrap();
OpaqueExtrinsic(v)
};
service_test::sync(
chain_spec::integration_test_config(),
sc_service_test::sync(
sc_chain_spec::integration_test_config(),
|config| new_full(config),
|mut config| {
// light nodes are unsupported
@@ -484,9 +484,9 @@ mod tests {
#[ignore]
fn test_sync() {
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = keystore::Store::open(keystore_path.path(), None)
let keystore = sc_keystore::Store::open(keystore_path.path(), None)
.expect("Creates keystore");
let alice = keystore.write().insert_ephemeral_from_seed::<babe::AuthorityPair>("//Alice")
let alice = keystore.write().insert_ephemeral_from_seed::<sc_consensus_babe::AuthorityPair>("//Alice")
.expect("Creates authority pair");
let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority();
@@ -499,13 +499,13 @@ mod tests {
let charlie = Arc::new(AccountKeyring::Charlie.pair());
let mut index = 0;
service_test::sync(
sc_service_test::sync(
chain_spec,
|config| {
let mut setup_handles = None;
new_full!(config, |
block_import: &babe::BabeBlockImport<_, _, Block, _, _, _>,
babe_link: &babe::BabeLink<Block>,
block_import: &sc_consensus_babe::BabeBlockImport<_, _, Block, _, _, _>,
babe_link: &sc_consensus_babe::BabeLink<Block>,
| {
setup_handles = Some((block_import.clone(), babe_link.clone()));
}).map(move |(node, x)| (node, (x, setup_handles.unwrap())))
@@ -534,7 +534,7 @@ mod tests {
// so we must keep trying the next slots until we can claim one.
let babe_pre_digest = loop {
inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot_num * SLOT_DURATION));
if let Some(babe_pre_digest) = babe::test_helpers::claim_slot(
if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot(
slot_num,
&parent_header,
&*service.client(),
@@ -594,12 +594,12 @@ mod tests {
let function = Call::Balances(BalancesCall::transfer(to.into(), amount));
let check_version = system::CheckVersion::new();
let check_genesis = system::CheckGenesis::new();
let check_era = system::CheckEra::from(Era::Immortal);
let check_nonce = system::CheckNonce::from(index);
let check_weight = system::CheckWeight::new();
let payment = transaction_payment::ChargeTransactionPayment::from(0);
let check_version = frame_system::CheckVersion::new();
let check_genesis = frame_system::CheckGenesis::new();
let check_era = frame_system::CheckEra::from(Era::Immortal);
let check_nonce = frame_system::CheckNonce::from(index);
let check_weight = frame_system::CheckWeight::new();
let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0);
let extra = (
check_version,
check_genesis,
@@ -635,7 +635,7 @@ mod tests {
#[test]
#[ignore]
fn test_consensus() {
service_test::consensus(
sc_service_test::consensus(
crate::chain_spec::tests::integration_test_config_with_two_authorities(),
|config| new_full(config),
|mut config| {