[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
+9 -9
View File
@@ -21,16 +21,16 @@ use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::RwLock;
use primitives::storage::{ChildInfo, OwnedChildInfo};
use state_machine::{
use sp_core::storage::{ChildInfo, OwnedChildInfo};
use sp_core::offchain::storage::InMemOffchainStorage;
use sp_state_machine::{
Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction
};
use primitives::offchain::storage::InMemOffchainStorage;
use sp_runtime::{generic::BlockId, Justification, Storage};
use sp_runtime::traits::{Block as BlockT, NumberFor, Zero, Header};
use crate::in_mem::{self, check_genesis_storage};
use sp_blockchain::{ Error as ClientError, Result as ClientResult };
use client_api::{
use sc_client_api::{
backend::{
AuxStore, Backend as ClientBackend, BlockImportOperation, RemoteBackend, NewBlockState,
StorageCollection, ChildStorageCollection,
@@ -42,7 +42,7 @@ use client_api::{
};
use crate::light::blockchain::Blockchain;
use hash_db::Hasher;
use trie::MemoryDB;
use sp_trie::MemoryDB;
const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type and always succeeds; qed";
@@ -487,16 +487,16 @@ impl<H: Hasher> StateBackend<H> for GenesisOrUnavailableState<H>
#[cfg(test)]
mod tests {
use primitives::Blake2Hasher;
use test_client::{self, runtime::Block};
use client_api::backend::NewBlockState;
use sp_core::Blake2Hasher;
use substrate_test_runtime_client::{self, runtime::Block};
use sc_client_api::backend::NewBlockState;
use crate::light::blockchain::tests::{DummyBlockchain, DummyStorage};
use super::*;
#[test]
fn local_state_is_created_when_genesis_state_is_available() {
let def = Default::default();
let header0 = test_client::runtime::Header::new(0, def, def, def, Default::default());
let header0 = substrate_test_runtime_client::runtime::Header::new(0, def, def, def, Default::default());
let backend: Backend<_, Blake2Hasher> = Backend::new(Arc::new(DummyBlockchain::new(DummyStorage::new())));
let mut op = backend.begin_operation().unwrap();
+3 -3
View File
@@ -27,7 +27,7 @@ use sp_blockchain::{
HeaderMetadata, CachedHeaderMetadata,
Error as ClientError, Result as ClientResult,
};
pub use client_api::{
pub use sc_client_api::{
backend::{
AuxStore, NewBlockState
},
@@ -195,8 +195,8 @@ pub fn future_header<Block: BlockT, F: Fetcher<Block>>(
pub mod tests {
use std::collections::HashMap;
use parking_lot::Mutex;
use test_client::runtime::{Hash, Block, Header};
use client_api::blockchain::Info;
use substrate_test_runtime_client::runtime::{Hash, Block, Header};
use sc_client_api::blockchain::Info;
use super::*;
pub type DummyBlockchain = Blockchain<DummyStorage>;
+23 -23
View File
@@ -21,15 +21,15 @@ use std::{
};
use codec::{Encode, Decode};
use primitives::{
use sp_core::{
H256, Blake2Hasher, convert_hash, NativeOrEncoded,
traits::CodeExecutor,
};
use sp_runtime::{
generic::BlockId, traits::{One, Block as BlockT, Header as HeaderT, NumberFor},
};
use externalities::Extensions;
use state_machine::{
use sp_externalities::Extensions;
use sp_state_machine::{
self, Backend as StateBackend, OverlayedChanges, ExecutionStrategy, create_proof_check_backend,
execution_proof_check_on_trie_backend, ExecutionManager, ChangesTrieTransaction, StorageProof,
merge_storage_proofs,
@@ -40,12 +40,12 @@ use sp_api::{ProofRecorder, InitializeBlock};
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use client_api::{
use sc_client_api::{
backend::RemoteBackend,
light::RemoteCallRequest,
call_executor::CallExecutor
};
use executor::{RuntimeVersion, NativeVersion};
use sc_executor::{RuntimeVersion, NativeVersion};
/// Call executor that is able to execute calls only on genesis state.
///
@@ -176,9 +176,9 @@ impl<Block, B, Local> CallExecutor<Block, Blake2Hasher> for
Err(ClientError::NotAvailableOnLightClient)
}
fn prove_at_trie_state<S: state_machine::TrieBackendStorage<Blake2Hasher>>(
fn prove_at_trie_state<S: sp_state_machine::TrieBackendStorage<Blake2Hasher>>(
&self,
_state: &state_machine::TrieBackend<S, Blake2Hasher>,
_state: &sp_state_machine::TrieBackend<S, Blake2Hasher>,
_changes: &mut OverlayedChanges,
_method: &str,
_call_data: &[u8]
@@ -208,7 +208,7 @@ pub fn prove_execution<Block, S, E>(
E: CallExecutor<Block, Blake2Hasher>,
{
let trie_state = state.as_trie_backend()
.ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box<dyn state_machine::Error>)?;
.ok_or_else(|| Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) as Box<dyn sp_state_machine::Error>)?;
// prepare execution environment + record preparation proof
let mut changes = Default::default();
@@ -293,11 +293,11 @@ fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader: Fn(&Head
#[cfg(test)]
mod tests {
use super::*;
use consensus::BlockOrigin;
use test_client::{self, runtime::{Header, Digest, Block}, ClientExt, TestClient};
use executor::{NativeExecutor, WasmExecutionMethod};
use primitives::Blake2Hasher;
use client_api::backend::{Backend, NewBlockState};
use sp_consensus::BlockOrigin;
use substrate_test_runtime_client::{self, runtime::{Header, Digest, Block}, ClientExt, TestClient};
use sc_executor::{NativeExecutor, WasmExecutionMethod};
use sp_core::Blake2Hasher;
use sc_client_api::backend::{Backend, NewBlockState};
use crate::in_mem::Backend as InMemBackend;
struct DummyCallExecutor;
@@ -346,7 +346,7 @@ mod tests {
}
fn call_at_state<
S: state_machine::Backend<Blake2Hasher>,
S: sp_state_machine::Backend<Blake2Hasher>,
F: FnOnce(
Result<NativeOrEncoded<R>, Self::Error>,
Result<NativeOrEncoded<R>, Self::Error>
@@ -372,9 +372,9 @@ mod tests {
unreachable!()
}
fn prove_at_trie_state<S: state_machine::TrieBackendStorage<Blake2Hasher>>(
fn prove_at_trie_state<S: sp_state_machine::TrieBackendStorage<Blake2Hasher>>(
&self,
_trie_state: &state_machine::TrieBackend<S, Blake2Hasher>,
_trie_state: &sp_state_machine::TrieBackend<S, Blake2Hasher>,
_overlay: &mut OverlayedChanges,
_method: &str,
_call_data: &[u8]
@@ -387,7 +387,7 @@ mod tests {
}
}
fn local_executor() -> NativeExecutor<test_client::LocalExecutor> {
fn local_executor() -> NativeExecutor<substrate_test_runtime_client::LocalExecutor> {
NativeExecutor::new(WasmExecutionMethod::Interpreted, None)
}
@@ -408,7 +408,7 @@ mod tests {
let local_result = check_execution_proof::<_, _, Blake2Hasher>(
&local_executor(),
&RemoteCallRequest {
block: test_client::runtime::Hash::default(),
block: substrate_test_runtime_client::runtime::Hash::default(),
header: remote_header,
method: method.into(),
call_data: vec![],
@@ -435,7 +435,7 @@ mod tests {
let execution_result = check_execution_proof_with_make_header::<_, _, Blake2Hasher, _>(
&local_executor(),
&RemoteCallRequest {
block: test_client::runtime::Hash::default(),
block: substrate_test_runtime_client::runtime::Hash::default(),
header: remote_header,
method: method.into(),
call_data: vec![],
@@ -457,7 +457,7 @@ mod tests {
}
// prepare remote client
let remote_client = test_client::new();
let remote_client = substrate_test_runtime_client::new();
for i in 1u32..3u32 {
let mut digest = Digest::default();
digest.push(sp_runtime::generic::DigestItem::Other::<H256>(i.to_le_bytes().to_vec()));
@@ -488,7 +488,7 @@ mod tests {
execute_with_proof_failure(&remote_client, 2, "Core_version");
// check that proof check doesn't panic even if proof is incorrect AND panic handler is set
panic_handler::set("TEST", "1.2.3");
sp_panic_handler::set("TEST", "1.2.3");
execute_with_proof_failure(&remote_client, 2, "Core_version");
}
@@ -496,9 +496,9 @@ mod tests {
fn code_is_executed_at_genesis_only() {
let backend = Arc::new(InMemBackend::<Block, Blake2Hasher>::new());
let def = H256::default();
let header0 = test_client::runtime::Header::new(0, def, def, def, Default::default());
let header0 = substrate_test_runtime_client::runtime::Header::new(0, def, def, def, Default::default());
let hash0 = header0.hash();
let header1 = test_client::runtime::Header::new(1, def, def, hash0, Default::default());
let header1 = substrate_test_runtime_client::runtime::Header::new(1, def, def, hash0, Default::default());
let hash1 = header1.hash();
backend.blockchain().insert(hash0, header0, None, None, NewBlockState::Final).unwrap();
backend.blockchain().insert(hash1, header1, None, None, NewBlockState::Final).unwrap();
+20 -20
View File
@@ -22,21 +22,21 @@ use std::marker::PhantomData;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use codec::{Decode, Encode};
use primitives::{convert_hash, traits::CodeExecutor, H256};
use sp_core::{convert_hash, traits::CodeExecutor, H256};
use sp_runtime::traits::{
Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor,
SimpleArithmetic, CheckedConversion, Zero,
};
use state_machine::{
use sp_state_machine::{
ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, ChangesTrieConfigurationRange,
TrieBackend, read_proof_check, key_changes_proof_check, create_proof_check_backend_storage,
read_child_proof_check,
};
pub use state_machine::StorageProof;
pub use sp_state_machine::StorageProof;
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use crate::cht;
pub use client_api::{
pub use sc_client_api::{
light::{
RemoteCallRequest, RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest,
RemoteChangesRequest, ChangesProof, RemoteBodyRequest, Fetcher, FetchChecker,
@@ -294,7 +294,7 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage<H, Number> for RootsStorage<'a
fn build_anchor(
&self,
_hash: H::Out,
) -> Result<state_machine::ChangesTrieAnchorBlockId<H::Out, Number>, String> {
) -> Result<sp_state_machine::ChangesTrieAnchorBlockId<H::Out, Number>, String> {
Err("build_anchor is only called when building block".into())
}
@@ -326,40 +326,40 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage<H, Number> for RootsStorage<'a
pub mod tests {
use codec::Decode;
use crate::client::tests::prepare_client_with_key_changes;
use executor::{NativeExecutor, WasmExecutionMethod};
use sc_executor::{NativeExecutor, WasmExecutionMethod};
use sp_blockchain::Error as ClientError;
use client_api::backend::NewBlockState;
use test_client::{
use sc_client_api::backend::NewBlockState;
use substrate_test_runtime_client::{
self, ClientExt, blockchain::HeaderBackend, AccountKeyring,
runtime::{self, Hash, Block, Header, Extrinsic}
};
use consensus::BlockOrigin;
use sp_consensus::BlockOrigin;
use crate::in_mem::{Blockchain as InMemoryBlockchain};
use crate::light::fetcher::{FetchChecker, LightDataChecker, RemoteHeaderRequest};
use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain};
use primitives::{blake2_256, Blake2Hasher, H256};
use primitives::storage::{well_known_keys, StorageKey, ChildInfo};
use sp_core::{blake2_256, Blake2Hasher, H256};
use sp_core::storage::{well_known_keys, StorageKey, ChildInfo};
use sp_runtime::generic::BlockId;
use state_machine::Backend;
use sp_state_machine::Backend;
use super::*;
const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1");
type TestChecker = LightDataChecker<
NativeExecutor<test_client::LocalExecutor>,
NativeExecutor<substrate_test_runtime_client::LocalExecutor>,
Blake2Hasher,
Block,
DummyStorage,
>;
fn local_executor() -> NativeExecutor<test_client::LocalExecutor> {
fn local_executor() -> NativeExecutor<substrate_test_runtime_client::LocalExecutor> {
NativeExecutor::new(WasmExecutionMethod::Interpreted, None)
}
fn prepare_for_read_proof_check() -> (TestChecker, Header, StorageProof, u32) {
// prepare remote client
let remote_client = test_client::new();
let remote_client = substrate_test_runtime_client::new();
let remote_block_id = BlockId::Number(0);
let remote_block_hash = remote_client.block_hash(0).unwrap().unwrap();
let mut remote_block_header = remote_client.header(&remote_block_id).unwrap().unwrap();
@@ -392,10 +392,10 @@ pub mod tests {
}
fn prepare_for_read_child_proof_check() -> (TestChecker, Header, StorageProof, Vec<u8>) {
use test_client::DefaultTestClientBuilderExt;
use test_client::TestClientBuilderExt;
use substrate_test_runtime_client::DefaultTestClientBuilderExt;
use substrate_test_runtime_client::TestClientBuilderExt;
// prepare remote client
let remote_client = test_client::TestClientBuilder::new()
let remote_client = substrate_test_runtime_client::TestClientBuilder::new()
.add_extra_child_storage(
b":child_storage:default:child1".to_vec(),
CHILD_INFO_1,
@@ -441,7 +441,7 @@ pub mod tests {
fn prepare_for_header_proof_check(insert_cht: bool) -> (TestChecker, Hash, Header, StorageProof) {
// prepare remote client
let remote_client = test_client::new();
let remote_client = substrate_test_runtime_client::new();
let mut local_headers_hashes = Vec::new();
for i in 0..4 {
let builder = remote_client.new_block(Default::default()).unwrap();
@@ -468,7 +468,7 @@ pub mod tests {
}
fn header_with_computed_extrinsics_root(extrinsics: Vec<Extrinsic>) -> Header {
use trie::{TrieConfiguration, trie_types::Layout};
use sp_trie::{TrieConfiguration, trie_types::Layout};
let iter = extrinsics.iter().map(Encode::encode);
let extrinsics_root = Layout::<Blake2Hasher>::ordered_trie_root(iter);
+3 -3
View File
@@ -23,15 +23,15 @@ pub mod fetcher;
use std::sync::Arc;
use executor::RuntimeInfo;
use primitives::{H256, Blake2Hasher, traits::CodeExecutor};
use sc_executor::RuntimeInfo;
use sp_core::{H256, Blake2Hasher, traits::CodeExecutor};
use sp_runtime::BuildStorage;
use sp_runtime::traits::Block as BlockT;
use sp_blockchain::Result as ClientResult;
use crate::call_executor::LocalCallExecutor;
use crate::client::Client;
use client_api::{
use sc_client_api::{
light::Storage as BlockchainStorage,
};
use crate::light::backend::Backend;