[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
+29 -29
View File
@@ -6,26 +6,26 @@ edition = "2018"
build = "build.rs"
[dependencies]
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura", default-features = false }
babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe", default-features = false }
block-builder-api = { package = "sp-block-builder", path = "../../primitives/block-builder", default-features = false }
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false }
sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false }
sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false }
sp-block-builder = { path = "../../primitives/block-builder", default-features = false }
cfg-if = "0.1.10"
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
executive = { package = "frame-executive", path = "../../frame/executive", default-features = false }
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true }
frame-executive = { path = "../../frame/executive", default-features = false }
sp-inherents = { path = "../../primitives/inherents", default-features = false }
sp-keyring = { path = "../../primitives/keyring", optional = true }
log = { version = "0.4.8", optional = true }
memory-db = { version = "0.15.2", default-features = false }
offchain-primitives = { package = "sp-offchain", path = "../../primitives/offchain", default-features = false}
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
sp-offchain = { path = "../../primitives/offchain", default-features = false}
sp-core = { path = "../../primitives/core", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface", default-features = false}
sp-runtime-interface = { path = "../../primitives/runtime-interface", default-features = false}
sp-io = { path = "../../primitives/io", default-features = false }
runtime_support = { package = "frame-support", path = "../../frame/support", default-features = false }
runtime_version = { package = "sp-version", path = "../../primitives/version", default-features = false }
frame-support = { path = "../../frame/support", default-features = false }
sp-version = { path = "../../primitives/version", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
session = { package = "sp-session", path = "../../primitives/session", default-features = false }
sp-session = { path = "../../primitives/session", default-features = false }
sp-api = { path = "../../primitives/api", default-features = false }
sp-runtime = { path = "../../primitives/runtime", default-features = false }
pallet-babe = { path = "../../frame/babe", default-features = false }
@@ -34,13 +34,13 @@ frame-system-rpc-runtime-api = { path = "../../frame/system/rpc/runtime-api", de
pallet-timestamp = { path = "../../frame/timestamp", default-features = false }
sc-client = { path = "../../client", optional = true }
sp-trie = { path = "../../primitives/trie", default-features = false }
sp-transaction-pool = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool", default-features = false }
sp-transaction-pool = { path = "../../primitives/transaction-pool", default-features = false }
trie-db = { version = "0.16.0", default-features = false }
[dev-dependencies]
sc-executor = { path = "../../client/executor" }
substrate-test-runtime-client = { path = "./client" }
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
sp-state-machine = { path = "../../primitives/state-machine" }
[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner", version = "1.0.4" }
@@ -50,26 +50,26 @@ default = [
"std",
]
std = [
"app-crypto/std",
"aura-primitives/std",
"babe-primitives/std",
"block-builder-api/std",
"sp-application-crypto/std",
"sp-consensus-aura/std",
"sp-consensus-babe/std",
"sp-block-builder/std",
"codec/std",
"executive/std",
"inherents/std",
"keyring",
"frame-executive/std",
"sp-inherents/std",
"sp-keyring",
"log",
"memory-db/std",
"offchain-primitives/std",
"primitives/std",
"primitives/std",
"sp-offchain/std",
"sp-core/std",
"sp-core/std",
"sp-std/std",
"runtime-interface/std",
"sp-runtime-interface/std",
"sp-io/std",
"runtime_support/std",
"runtime_version/std",
"frame-support/std",
"sp-version/std",
"serde",
"session/std",
"sp-session/std",
"sp-api/std",
"sp-runtime/std",
"pallet-babe/std",
@@ -5,13 +5,13 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
block-builder = { package = "sc-block-builder", path = "../../../client/block-builder" }
generic-test-client = { package = "substrate-test-client", path = "../../client" }
primitives = { package = "sp-core", path = "../../../primitives/core" }
runtime = { package = "substrate-test-runtime", path = "../../runtime" }
sc-block-builder = { path = "../../../client/block-builder" }
substrate-test-client = { path = "../../client" }
sp-core = { path = "../../../primitives/core" }
substrate-test-runtime = { path = "../../runtime" }
sp-runtime = { path = "../../../primitives/runtime" }
sp-blockchain = { path = "../../../primitives/blockchain" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
client-api = { package = "sc-client-api", path = "../../../client/api" }
client = { package = "sc-client", path = "../../../client/" }
sc-client-api = { path = "../../../client/api" }
sc-client = { path = "../../../client/" }
futures = "0.3.1"
@@ -16,15 +16,15 @@
//! Block Builder extensions for tests.
use runtime;
use substrate_test_runtime;
use sp_runtime::traits::ProvideRuntimeApi;
use block_builder::BlockBuilderApi;
use sc_block_builder::BlockBuilderApi;
/// Extension trait for test block builder.
pub trait BlockBuilderExt {
/// Add transfer extrinsic to the block.
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error>;
fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error>;
/// Add storage change extrinsic to the block.
fn push_storage_change(
&mut self,
@@ -33,11 +33,11 @@ pub trait BlockBuilderExt {
) -> Result<(), sp_blockchain::Error>;
}
impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where
impl<'a, A> BlockBuilderExt for sc_block_builder::BlockBuilder<'a, substrate_test_runtime::Block, A> where
A: ProvideRuntimeApi + 'a,
A::Api: BlockBuilderApi<runtime::Block, Error = sp_blockchain::Error>,
A::Api: BlockBuilderApi<substrate_test_runtime::Block, Error = sp_blockchain::Error>,
{
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error> {
fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error> {
self.push(transfer.into_signed_tx())
}
@@ -46,6 +46,6 @@ impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), sp_blockchain::Error> {
self.push(runtime::Extrinsic::StorageChange(key, value))
self.push(substrate_test_runtime::Extrinsic::StorageChange(key, value))
}
}
+50 -48
View File
@@ -24,15 +24,16 @@ mod block_builder_ext;
use std::sync::Arc;
use std::collections::HashMap;
pub use block_builder_ext::BlockBuilderExt;
pub use generic_test_client::*;
pub use runtime;
pub use substrate_test_client::*;
pub use substrate_test_runtime as runtime;
use primitives::sr25519;
use primitives::storage::{ChildInfo, Storage, StorageChild};
use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
pub use self::block_builder_ext::BlockBuilderExt;
use sp_core::sr25519;
use sp_core::storage::{ChildInfo, Storage, StorageChild};
use substrate_test_runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor};
use client::{
use sc_client::{
light::fetcher::{
Fetcher,
RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest,
@@ -56,37 +57,37 @@ pub mod prelude {
mod local_executor {
#![allow(missing_docs)]
use runtime;
use crate::executor::native_executor_instance;
use substrate_test_runtime;
use crate::sc_executor::native_executor_instance;
// FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead
native_executor_instance!(
pub LocalExecutor,
runtime::api::dispatch,
runtime::native_version
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version
);
}
/// Native executor used for tests.
pub use local_executor::LocalExecutor;
pub use self::local_executor::LocalExecutor;
/// Test client database backend.
pub type Backend = generic_test_client::Backend<runtime::Block>;
pub type Backend = substrate_test_client::Backend<substrate_test_runtime::Block>;
/// Test client executor.
pub type Executor = client::LocalCallExecutor<
pub type Executor = sc_client::LocalCallExecutor<
Backend,
NativeExecutor<LocalExecutor>,
>;
/// Test client light database backend.
pub type LightBackend = generic_test_client::LightBackend<runtime::Block>;
pub type LightBackend = substrate_test_client::LightBackend<substrate_test_runtime::Block>;
/// Test client light executor.
pub type LightExecutor = client::light::call_executor::GenesisCallExecutor<
pub type LightExecutor = sc_client::light::call_executor::GenesisCallExecutor<
LightBackend,
client::LocalCallExecutor<
client::light::backend::Backend<
client_db::light::LightStorage<runtime::Block>,
sc_client::LocalCallExecutor<
sc_client::light::backend::Backend<
sc_client_db::light::LightStorage<substrate_test_runtime::Block>,
Blake2Hasher,
>,
NativeExecutor<LocalExecutor>
@@ -122,9 +123,10 @@ impl GenesisParameters {
}
}
impl generic_test_client::GenesisInit for GenesisParameters {
impl substrate_test_client::GenesisInit for GenesisParameters {
fn genesis_storage(&self) -> Storage {
use codec::Encode;
let mut storage = self.genesis_config().genesis_map();
let child_roots = storage.children.iter().map(|(sk, child_content)| {
@@ -136,7 +138,7 @@ impl generic_test_client::GenesisInit for GenesisParameters {
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
storage.top.clone().into_iter().chain(child_roots).collect()
);
let block: runtime::Block = client::genesis::construct_genesis_block(state_root);
let block: runtime::Block = sc_client::genesis::construct_genesis_block(state_root);
storage.top.extend(additional_storage_with_genesis(&block));
storage
@@ -144,14 +146,14 @@ impl generic_test_client::GenesisInit for GenesisParameters {
}
/// A `TestClient` with `test-runtime` builder.
pub type TestClientBuilder<E, B> = generic_test_client::TestClientBuilder<E, B, GenesisParameters>;
pub type TestClientBuilder<E, B> = substrate_test_client::TestClientBuilder<E, B, GenesisParameters>;
/// Test client type with `LocalExecutor` and generic Backend.
pub type Client<B> = client::Client<
pub type Client<B> = sc_client::Client<
B,
client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>,
runtime::Block,
runtime::RuntimeApi,
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
substrate_test_runtime::Block,
substrate_test_runtime::RuntimeApi,
>;
/// A test client with default backend.
@@ -206,14 +208,14 @@ pub trait TestClientBuilderExt<B>: Sized {
}
/// Build the test client and longest chain selector.
fn build_with_longest_chain(self) -> (Client<B>, client::LongestChain<B, runtime::Block>);
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>);
}
impl<B> TestClientBuilderExt<B> for TestClientBuilder<
client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>,
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
B
> where
B: client_api::backend::Backend<runtime::Block, Blake2Hasher>,
B: sc_client_api::backend::Backend<substrate_test_runtime::Block, Blake2Hasher>,
{
fn set_heap_pages(mut self, heap_pages: u64) -> Self {
self.genesis_init_mut().heap_pages_override = Some(heap_pages);
@@ -253,7 +255,7 @@ impl<B> TestClientBuilderExt<B> for TestClientBuilder<
}
fn build_with_longest_chain(self) -> (Client<B>, client::LongestChain<B, runtime::Block>) {
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>) {
self.build_with_native_executor(None)
}
}
@@ -267,15 +269,15 @@ type FetcherFutureResult<Resp> = futures::future::Ready<Result<Resp, sp_blockcha
/// Implementation of light client fetcher used in tests.
#[derive(Default)]
pub struct LightFetcher {
call: MaybeFetcherCallback<RemoteCallRequest<runtime::Header>, Vec<u8>>,
body: MaybeFetcherCallback<RemoteBodyRequest<runtime::Header>, Vec<runtime::Extrinsic>>,
call: MaybeFetcherCallback<RemoteCallRequest<substrate_test_runtime::Header>, Vec<u8>>,
body: MaybeFetcherCallback<RemoteBodyRequest<substrate_test_runtime::Header>, Vec<substrate_test_runtime::Extrinsic>>,
}
impl LightFetcher {
/// Sets remote call callback.
pub fn with_remote_call(
self,
call: MaybeFetcherCallback<RemoteCallRequest<runtime::Header>, Vec<u8>>,
call: MaybeFetcherCallback<RemoteCallRequest<substrate_test_runtime::Header>, Vec<u8>>,
) -> Self {
LightFetcher {
call,
@@ -286,7 +288,7 @@ impl LightFetcher {
/// Sets remote body callback.
pub fn with_remote_body(
self,
body: MaybeFetcherCallback<RemoteBodyRequest<runtime::Header>, Vec<runtime::Extrinsic>>,
body: MaybeFetcherCallback<RemoteBodyRequest<substrate_test_runtime::Header>, Vec<substrate_test_runtime::Extrinsic>>,
) -> Self {
LightFetcher {
call: self.call,
@@ -295,37 +297,37 @@ impl LightFetcher {
}
}
impl Fetcher<runtime::Block> for LightFetcher {
type RemoteHeaderResult = FetcherFutureResult<runtime::Header>;
impl Fetcher<substrate_test_runtime::Block> for LightFetcher {
type RemoteHeaderResult = FetcherFutureResult<substrate_test_runtime::Header>;
type RemoteReadResult = FetcherFutureResult<HashMap<Vec<u8>, Option<Vec<u8>>>>;
type RemoteCallResult = FetcherFutureResult<Vec<u8>>;
type RemoteChangesResult = FetcherFutureResult<Vec<(NumberFor<runtime::Block>, u32)>>;
type RemoteBodyResult = FetcherFutureResult<Vec<runtime::Extrinsic>>;
type RemoteChangesResult = FetcherFutureResult<Vec<(NumberFor<substrate_test_runtime::Block>, u32)>>;
type RemoteBodyResult = FetcherFutureResult<Vec<substrate_test_runtime::Extrinsic>>;
fn remote_header(&self, _: RemoteHeaderRequest<runtime::Header>) -> Self::RemoteHeaderResult {
fn remote_header(&self, _: RemoteHeaderRequest<substrate_test_runtime::Header>) -> Self::RemoteHeaderResult {
unimplemented!()
}
fn remote_read(&self, _: RemoteReadRequest<runtime::Header>) -> Self::RemoteReadResult {
fn remote_read(&self, _: RemoteReadRequest<substrate_test_runtime::Header>) -> Self::RemoteReadResult {
unimplemented!()
}
fn remote_read_child(&self, _: RemoteReadChildRequest<runtime::Header>) -> Self::RemoteReadResult {
fn remote_read_child(&self, _: RemoteReadChildRequest<substrate_test_runtime::Header>) -> Self::RemoteReadResult {
unimplemented!()
}
fn remote_call(&self, req: RemoteCallRequest<runtime::Header>) -> Self::RemoteCallResult {
fn remote_call(&self, req: RemoteCallRequest<substrate_test_runtime::Header>) -> Self::RemoteCallResult {
match self.call {
Some(ref call) => futures::future::ready(call(req)),
None => unimplemented!(),
}
}
fn remote_changes(&self, _: RemoteChangesRequest<runtime::Header>) -> Self::RemoteChangesResult {
fn remote_changes(&self, _: RemoteChangesRequest<substrate_test_runtime::Header>) -> Self::RemoteChangesResult {
unimplemented!()
}
fn remote_body(&self, req: RemoteBodyRequest<runtime::Header>) -> Self::RemoteBodyResult {
fn remote_body(&self, req: RemoteBodyRequest<substrate_test_runtime::Header>) -> Self::RemoteBodyResult {
match self.body {
Some(ref body) => futures::future::ready(body(req)),
None => unimplemented!(),
@@ -340,15 +342,15 @@ pub fn new() -> Client<Backend> {
/// Creates new light client instance used for tests.
pub fn new_light() -> (
client::Client<LightBackend, LightExecutor, runtime::Block, runtime::RuntimeApi>,
sc_client::Client<LightBackend, LightExecutor, substrate_test_runtime::Block, substrate_test_runtime::RuntimeApi>,
Arc<LightBackend>,
) {
let storage = client_db::light::LightStorage::new_test();
let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage));
let storage = sc_client_db::light::LightStorage::new_test();
let blockchain = Arc::new(sc_client::light::blockchain::Blockchain::new(storage));
let backend = Arc::new(LightBackend::new(blockchain.clone()));
let executor = NativeExecutor::new(WasmExecutionMethod::Interpreted, None);
let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor);
let local_call_executor = sc_client::LocalCallExecutor::new(backend.clone(), executor);
let call_executor = LightExecutor::new(
backend.clone(),
local_call_executor,
@@ -21,19 +21,19 @@
use std::sync::Arc;
use client_api::backend::LocalBackend;
use sc_client_api::backend::LocalBackend;
use crate::block_builder_ext::BlockBuilderExt;
use client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend};
use sc_client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend};
use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt};
use generic_test_client::consensus::BlockOrigin;
use primitives::Blake2Hasher;
use runtime::{self, Transfer};
use substrate_test_client::sp_consensus::BlockOrigin;
use sp_core::Blake2Hasher;
use substrate_test_runtime::{self, Transfer};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::Block as BlockT;
/// helper to test the `leaves` implementation for various backends
pub fn test_leaves_for_backend<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5
@@ -149,7 +149,7 @@ pub fn test_leaves_for_backend<B: 'static>(backend: Arc<B>) where
/// helper to test the `children` implementation for various backends
pub fn test_children_for_backend<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5
@@ -240,7 +240,7 @@ pub fn test_children_for_backend<B: 'static>(backend: Arc<B>) where
}
pub fn test_blockchain_query_by_number_gets_canonical<B: 'static>(backend: Arc<B>) where
B: LocalBackend<runtime::Block, Blake2Hasher>,
B: LocalBackend<substrate_test_runtime::Block, Blake2Hasher>,
{
// block tree:
// G -> A1 -> A2 -> A3 -> A4 -> A5
@@ -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(),