[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
@@ -20,8 +20,8 @@ use std::collections::BTreeMap;
use sp_io::hashing::{blake2_256, twox_128};
use super::{AuthorityId, AccountId, WASM_BINARY, system};
use codec::{Encode, KeyedVec, Joiner};
use primitives::{ChangesTrieConfiguration, map};
use primitives::storage::{well_known_keys, Storage};
use sp_core::{ChangesTrieConfiguration, map};
use sp_core::storage::{well_known_keys, Storage};
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
/// Configuration of a general Substrate test genesis block.
@@ -41,7 +41,7 @@ impl GenesisConfig {
endowed_accounts: Vec<AccountId>,
balance: u64,
heap_pages_override: Option<u64>,
extra_storage: Storage,
extra_storage: Storage,
) -> Self {
GenesisConfig {
changes_trie_config: match support_changes_trie {
@@ -87,7 +87,7 @@ impl GenesisConfig {
pub fn insert_genesis_block(
storage: &mut Storage,
) -> primitives::hash::H256 {
) -> sp_core::hash::H256 {
let child_roots = storage.children.iter().map(|(sk, child_content)| {
let state_root = <<<crate::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
child_content.data.clone().into_iter().collect(),
+32 -33
View File
@@ -25,9 +25,8 @@ pub mod system;
use sp_std::{prelude::*, marker::PhantomData};
use codec::{Encode, Decode, Input, Error};
use primitives::{Blake2Hasher, OpaqueMetadata, RuntimeDebug};
use app_crypto::{ed25519, sr25519, RuntimeAppPublic};
pub use app_crypto;
use sp_core::{Blake2Hasher, OpaqueMetadata, RuntimeDebug};
use sp_application_crypto::{ed25519, sr25519, RuntimeAppPublic};
use trie_db::{TrieMut, Trie};
use sp_trie::PrefixedMemoryDB;
use sp_trie::trie_types::{TrieDB, TrieDBMut};
@@ -43,18 +42,18 @@ use sp_runtime::{
GetNodeBlockType, GetRuntimeBlockType, Verify, IdentityLookup,
},
};
use runtime_version::RuntimeVersion;
pub use primitives::{hash::H256};
use sp_version::RuntimeVersion;
pub use sp_core::{hash::H256};
#[cfg(any(feature = "std", test))]
use runtime_version::NativeVersion;
use runtime_support::{impl_outer_origin, parameter_types, weights::Weight};
use inherents::{CheckInherentsResult, InherentData};
use sp_version::NativeVersion;
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use sp_inherents::{CheckInherentsResult, InherentData};
use cfg_if::cfg_if;
use primitives::storage::ChildType;
use sp_core::storage::ChildType;
// Ensure Babe and Aura use the same crypto to simplify things a bit.
pub use babe_primitives::AuthorityId;
pub type AuraId = aura_primitives::sr25519::AuthorityId;
pub use sp_consensus_babe::AuthorityId;
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
// Inlucde the WASM binary
#[cfg(feature = "std")]
@@ -96,7 +95,7 @@ impl Transfer {
/// Convert into a signed extrinsic.
#[cfg(feature = "std")]
pub fn into_signed_tx(self) -> Extrinsic {
let signature = keyring::AccountKeyring::from_public(&self.from)
let signature = sp_keyring::AccountKeyring::from_public(&self.from)
.expect("Creates keyring from public key.").sign(&self.encode()).into();
Extrinsic::Transfer(self, signature)
}
@@ -195,8 +194,8 @@ pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
}
/// Changes trie configuration (optionally) used in tests.
pub fn changes_trie_config() -> primitives::ChangesTrieConfiguration {
primitives::ChangesTrieConfiguration {
pub fn changes_trie_config() -> sp_core::ChangesTrieConfiguration {
sp_core::ChangesTrieConfiguration {
digest_interval: 4,
digest_levels: 2,
}
@@ -406,8 +405,8 @@ fn benchmark_add_one(i: u64) -> u64 {
/// The `benchmark_add_one` function as function pointer.
#[cfg(not(feature = "std"))]
static BENCHMARK_ADD_ONE: runtime_interface::wasm::ExchangeableFunction<fn(u64) -> u64> =
runtime_interface::wasm::ExchangeableFunction::new(benchmark_add_one);
static BENCHMARK_ADD_ONE: sp_runtime_interface::wasm::ExchangeableFunction<fn(u64) -> u64> =
sp_runtime_interface::wasm::ExchangeableFunction::new(benchmark_add_one);
fn code_using_trie() -> u64 {
let pairs = [
@@ -494,7 +493,7 @@ cfg_if! {
}
}
impl block_builder_api::BlockBuilder<Block> for Runtime {
impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
system::execute_transaction(extrinsic)
}
@@ -598,7 +597,7 @@ cfg_if! {
}
}
impl aura_primitives::AuraApi<Block, AuraId> for Runtime {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> u64 { 1000 }
fn authorities() -> Vec<AuraId> {
system::authorities().into_iter().map(|a| {
@@ -608,9 +607,9 @@ cfg_if! {
}
}
impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeConfiguration {
babe_primitives::BabeConfiguration {
impl sp_consensus_babe::BabeApi<Block> for Runtime {
fn configuration() -> sp_consensus_babe::BabeConfiguration {
sp_consensus_babe::BabeConfiguration {
slot_duration: 1000,
epoch_length: EpochDuration::get(),
c: (3, 10),
@@ -622,14 +621,14 @@ cfg_if! {
}
}
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(block: u64) {
let ex = Extrinsic::IncludeData(block.encode());
sp_io::offchain::submit_transaction(ex.encode()).unwrap();
}
}
impl session::SessionKeys<Block> for Runtime {
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(None)
}
@@ -679,7 +678,7 @@ cfg_if! {
}
}
impl block_builder_api::BlockBuilder<Block> for Runtime {
impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
system::execute_transaction(extrinsic)
}
@@ -814,7 +813,7 @@ cfg_if! {
}
}
impl aura_primitives::AuraApi<Block, AuraId> for Runtime {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> u64 { 1000 }
fn authorities() -> Vec<AuraId> {
system::authorities().into_iter().map(|a| {
@@ -824,9 +823,9 @@ cfg_if! {
}
}
impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeConfiguration {
babe_primitives::BabeConfiguration {
impl sp_consensus_babe::BabeApi<Block> for Runtime {
fn configuration() -> sp_consensus_babe::BabeConfiguration {
sp_consensus_babe::BabeConfiguration {
slot_duration: 1000,
epoch_length: EpochDuration::get(),
c: (3, 10),
@@ -838,14 +837,14 @@ cfg_if! {
}
}
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(block: u64) {
let ex = Extrinsic::IncludeData(block.encode());
sp_io::offchain::submit_transaction(ex.encode()).unwrap()
}
}
impl session::SessionKeys<Block> for Runtime {
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(None)
}
@@ -950,7 +949,7 @@ fn test_read_child_storage() {
mod tests {
use substrate_test_runtime_client::{
prelude::*,
consensus::BlockOrigin,
sp_consensus::BlockOrigin,
DefaultTestClientBuilderExt, TestClientBuilder,
runtime::TestAPI,
};
@@ -958,8 +957,8 @@ mod tests {
generic::BlockId,
traits::ProvideRuntimeApi,
};
use primitives::storage::well_known_keys::HEAP_PAGES;
use state_machine::ExecutionStrategy;
use sp_core::storage::well_known_keys::HEAP_PAGES;
use sp_state_machine::ExecutionStrategy;
use codec::Encode;
#[test]
+7 -7
View File
@@ -22,8 +22,8 @@ use sp_io::{
storage::root as storage_root, storage::changes_root as storage_changes_root,
hashing::blake2_256,
};
use runtime_support::storage;
use runtime_support::{decl_storage, decl_module};
use frame_support::storage;
use frame_support::{decl_storage, decl_module};
use sp_runtime::{
traits::{Hash as HashT, BlakeTwo256, Header as _}, generic, ApplyExtrinsicResult,
transaction_validity::{
@@ -35,7 +35,7 @@ use frame_system::Trait;
use crate::{
AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId
};
use primitives::storage::well_known_keys;
use sp_core::storage::well_known_keys;
const NONCE_OF: &[u8] = b"nonce:";
const BALANCE_OF: &[u8] = b"balance:";
@@ -169,7 +169,7 @@ fn execute_block_with_state_root_handler(
/// The block executor.
pub struct BlockExecutor;
impl executive::ExecuteBlock<Block> for BlockExecutor {
impl frame_executive::ExecuteBlock<Block> for BlockExecutor {
fn execute_block(block: Block) {
execute_block(block);
}
@@ -312,7 +312,7 @@ fn execute_storage_change(key: &[u8], value: Option<&[u8]>) -> ApplyExtrinsicRes
#[cfg(feature = "std")]
fn info_expect_equal_hash(given: &Hash, expected: &Hash) {
use primitives::hexdisplay::HexDisplay;
use sp_core::hexdisplay::HexDisplay;
if given != expected {
println!(
"Hash: given={}, expected={}",
@@ -338,7 +338,7 @@ mod tests {
use sp_io::TestExternalities;
use substrate_test_runtime_client::{AccountKeyring, Sr25519Keyring};
use crate::{Header, Transfer, WASM_BINARY};
use primitives::{NeverNativeValue, map, traits::CodeExecutor};
use sp_core::{NeverNativeValue, map, traits::CodeExecutor};
use sc_executor::{NativeExecutor, WasmExecutionMethod, native_executor_instance};
use sp_io::hashing::twox_128;
@@ -361,7 +361,7 @@ mod tests {
];
TestExternalities::new_with_code(
WASM_BINARY,
primitives::storage::Storage {
sp_core::storage::Storage {
top: map![
twox_128(b"latest").to_vec() => vec![69u8; 32],
twox_128(b"sys:auth").to_vec() => authorities.encode(),