mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 14:41:11 +00:00
[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:
committed by
Gavin Wood
parent
f14d98a439
commit
8778ca7dc8
@@ -19,19 +19,19 @@ use codec::{Encode, Decode};
|
||||
use sp_runtime::{
|
||||
generic::BlockId, traits::Block as BlockT, traits::NumberFor,
|
||||
};
|
||||
use state_machine::{
|
||||
use sp_state_machine::{
|
||||
self, OverlayedChanges, Ext, ExecutionManager, StateMachine, ExecutionStrategy,
|
||||
backend::Backend as _, ChangesTrieTransaction, StorageProof,
|
||||
};
|
||||
use executor::{RuntimeVersion, RuntimeInfo, NativeVersion};
|
||||
use externalities::Extensions;
|
||||
use sc_executor::{RuntimeVersion, RuntimeInfo, NativeVersion};
|
||||
use sp_externalities::Extensions;
|
||||
use hash_db::Hasher;
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
H256, Blake2Hasher, NativeOrEncoded, NeverNativeValue,
|
||||
traits::CodeExecutor,
|
||||
};
|
||||
use sp_api::{ProofRecorder, InitializeBlock};
|
||||
use client_api::{backend, call_executor::CallExecutor};
|
||||
use sc_client_api::{backend, call_executor::CallExecutor};
|
||||
|
||||
/// Call executor that executes methods locally, querying all required
|
||||
/// data from local backend.
|
||||
@@ -138,11 +138,11 @@ impl<B, E, Block> CallExecutor<Block, Blake2Hasher> for LocalCallExecutor<B, E>
|
||||
Some(recorder) => {
|
||||
let trie_state = state.as_trie_backend()
|
||||
.ok_or_else(||
|
||||
Box::new(state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<dyn state_machine::Error>
|
||||
Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<dyn sp_state_machine::Error>
|
||||
)?;
|
||||
|
||||
let backend = state_machine::ProvingBackend::new_with_recorder(
|
||||
let backend = sp_state_machine::ProvingBackend::new_with_recorder(
|
||||
trie_state,
|
||||
recorder.clone()
|
||||
);
|
||||
@@ -206,7 +206,7 @@ impl<B, E, Block> CallExecutor<Block, Blake2Hasher> for LocalCallExecutor<B, E>
|
||||
}
|
||||
|
||||
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>,
|
||||
@@ -247,14 +247,14 @@ impl<B, E, Block> CallExecutor<Block, Blake2Hasher> for LocalCallExecutor<B, E>
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
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]
|
||||
) -> Result<(Vec<u8>, StorageProof), sp_blockchain::Error> {
|
||||
state_machine::prove_execution_on_trie_backend(
|
||||
sp_state_machine::prove_execution_on_trie_backend(
|
||||
trie_state,
|
||||
overlay,
|
||||
&self.executor,
|
||||
@@ -269,20 +269,20 @@ impl<B, E, Block> CallExecutor<Block, Blake2Hasher> for LocalCallExecutor<B, E>
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block> runtime_version::GetRuntimeVersion<Block> for LocalCallExecutor<B, E>
|
||||
impl<B, E, Block> sp_version::GetRuntimeVersion<Block> for LocalCallExecutor<B, E>
|
||||
where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CodeExecutor + RuntimeInfo,
|
||||
Block: BlockT<Hash=H256>,
|
||||
{
|
||||
fn native_version(&self) -> &runtime_version::NativeVersion {
|
||||
fn native_version(&self) -> &sp_version::NativeVersion {
|
||||
self.executor.native_version()
|
||||
}
|
||||
|
||||
fn runtime_version(
|
||||
&self,
|
||||
at: &BlockId<Block>,
|
||||
) -> Result<runtime_version::RuntimeVersion, String> {
|
||||
) -> Result<sp_version::RuntimeVersion, String> {
|
||||
CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
use hash_db;
|
||||
use codec::Encode;
|
||||
use trie;
|
||||
use sp_trie;
|
||||
|
||||
use primitives::{H256, convert_hash};
|
||||
use sp_core::{H256, convert_hash};
|
||||
use sp_runtime::traits::{Header as HeaderT, SimpleArithmetic, Zero, One};
|
||||
use state_machine::backend::InMemory as InMemoryState;
|
||||
use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof,
|
||||
use sp_state_machine::backend::InMemory as InMemoryState;
|
||||
use sp_state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof,
|
||||
prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend};
|
||||
|
||||
use sp_blockchain::{Error as ClientError, Result as ClientResult};
|
||||
@@ -76,8 +76,8 @@ pub fn compute_root<Header, Hasher, I>(
|
||||
Hasher::Out: Ord,
|
||||
I: IntoIterator<Item=ClientResult<Option<Header::Hash>>>,
|
||||
{
|
||||
use trie::TrieConfiguration;
|
||||
Ok(trie::trie_types::Layout::<Hasher>::trie_root(
|
||||
use sp_trie::TrieConfiguration;
|
||||
Ok(sp_trie::trie_types::Layout::<Hasher>::trie_root(
|
||||
build_pairs::<Header, I>(cht_size, cht_num, hashes)?
|
||||
))
|
||||
}
|
||||
@@ -317,8 +317,8 @@ pub fn decode_cht_value(value: &[u8]) -> Option<H256> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use primitives::{Blake2Hasher};
|
||||
use test_client::runtime::Header;
|
||||
use sp_core::{Blake2Hasher};
|
||||
use substrate_test_runtime_client::runtime::Header;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -25,7 +25,7 @@ use futures::channel::mpsc;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use codec::{Encode, Decode};
|
||||
use hash_db::{Hasher, Prefix};
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash,
|
||||
NeverNativeValue, ExecutionContext, NativeOrEncoded,
|
||||
storage::{StorageKey, StorageData, well_known_keys, ChildInfo},
|
||||
@@ -40,14 +40,14 @@ use sp_runtime::{
|
||||
ApiRef, ProvideRuntimeApi, SaturatedConversion, One, DigestFor,
|
||||
},
|
||||
};
|
||||
use state_machine::{
|
||||
use sp_state_machine::{
|
||||
DBValue, Backend as StateBackend, ChangesTrieAnchorBlockId, ExecutionStrategy, ExecutionManager,
|
||||
prove_read, prove_child_read, ChangesTrieRootsStorage, ChangesTrieStorage,
|
||||
ChangesTrieTransaction, ChangesTrieConfigurationRange, key_changes, key_changes_proof,
|
||||
OverlayedChanges, BackendTrustLevel, StorageProof, merge_storage_proofs,
|
||||
};
|
||||
use executor::{RuntimeVersion, RuntimeInfo};
|
||||
use consensus::{
|
||||
use sc_executor::{RuntimeVersion, RuntimeInfo};
|
||||
use sp_consensus::{
|
||||
Error as ConsensusError, BlockStatus, BlockImportParams, BlockCheckParams,
|
||||
ImportResult, BlockOrigin, ForkChoiceStrategy,
|
||||
SelectChain, self,
|
||||
@@ -60,9 +60,9 @@ use sp_blockchain::{self as blockchain,
|
||||
};
|
||||
|
||||
use sp_api::{CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder, InitializeBlock};
|
||||
use block_builder::BlockBuilderApi;
|
||||
use sc_block_builder::BlockBuilderApi;
|
||||
|
||||
pub use client_api::{
|
||||
pub use sc_client_api::{
|
||||
backend::{
|
||||
self, BlockImportOperation, PrunableStateChangesTrieStorage,
|
||||
ClientImportOperation, Finalizer, ImportSummary, NewBlockState,
|
||||
@@ -88,7 +88,7 @@ type StorageUpdate<B, Block> = <
|
||||
<
|
||||
<B as backend::Backend<Block, Blake2Hasher>>::BlockImportOperation
|
||||
as BlockImportOperation<Block, Blake2Hasher>
|
||||
>::State as state_machine::Backend<Blake2Hasher>>::Transaction;
|
||||
>::State as sp_state_machine::Backend<Blake2Hasher>>::Transaction;
|
||||
type ChangesUpdate<Block> = ChangesTrieTransaction<Blake2Hasher, NumberFor<Block>>;
|
||||
|
||||
/// Substrate Client
|
||||
@@ -144,7 +144,7 @@ impl<H> PrePostHeader<H> {
|
||||
pub fn new_in_mem<E, Block, S, RA>(
|
||||
executor: E,
|
||||
genesis_storage: S,
|
||||
keystore: Option<primitives::traits::BareCryptoStorePtr>,
|
||||
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
||||
) -> sp_blockchain::Result<Client<
|
||||
in_mem::Backend<Block, Blake2Hasher>,
|
||||
LocalCallExecutor<in_mem::Backend<Block, Blake2Hasher>, E>,
|
||||
@@ -164,7 +164,7 @@ pub fn new_with_backend<B, E, Block, S, RA>(
|
||||
backend: Arc<B>,
|
||||
executor: E,
|
||||
build_genesis_storage: S,
|
||||
keystore: Option<primitives::traits::BareCryptoStorePtr>,
|
||||
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
||||
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<B, E>, Block, RA>>
|
||||
where
|
||||
E: CodeExecutor + RuntimeInfo,
|
||||
@@ -525,7 +525,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
}
|
||||
|
||||
impl<'a, Block: BlockT> ChangesTrieStorage<Blake2Hasher, NumberFor<Block>> for AccessedRootsRecorder<'a, Block> {
|
||||
fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>> {
|
||||
fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>> {
|
||||
self
|
||||
}
|
||||
|
||||
@@ -649,14 +649,14 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
pub fn new_block(
|
||||
&self,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> sp_blockchain::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
) -> sp_blockchain::Result<sc_block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
RA: Send + Sync,
|
||||
Self: ProvideRuntimeApi,
|
||||
<Self as ProvideRuntimeApi>::Api: BlockBuilderApi<Block, Error = Error>
|
||||
{
|
||||
let info = self.info();
|
||||
block_builder::BlockBuilder::new(
|
||||
sc_block_builder::BlockBuilder::new(
|
||||
self,
|
||||
info.chain.best_hash,
|
||||
info.chain.best_number,
|
||||
@@ -670,13 +670,13 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> sp_blockchain::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
) -> sp_blockchain::Result<sc_block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
RA: Send + Sync,
|
||||
Self: ProvideRuntimeApi,
|
||||
<Self as ProvideRuntimeApi>::Api: BlockBuilderApi<Block, Error = Error>
|
||||
{
|
||||
block_builder::BlockBuilder::new(
|
||||
sc_block_builder::BlockBuilder::new(
|
||||
self,
|
||||
self.expect_block_hash_from_id(parent)?,
|
||||
self.expect_block_number_from_id(parent)?,
|
||||
@@ -694,13 +694,13 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> sp_blockchain::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
) -> sp_blockchain::Result<sc_block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
RA: Send + Sync,
|
||||
Self: ProvideRuntimeApi,
|
||||
<Self as ProvideRuntimeApi>::Api: BlockBuilderApi<Block, Error = Error>
|
||||
{
|
||||
block_builder::BlockBuilder::new(
|
||||
sc_block_builder::BlockBuilder::new(
|
||||
self,
|
||||
self.expect_block_hash_from_id(parent)?,
|
||||
self.expect_block_number_from_id(parent)?,
|
||||
@@ -1432,7 +1432,7 @@ impl<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> where
|
||||
/// NOTE: only use this implementation when you are sure there are NO consensus-level BlockImport
|
||||
/// objects. Otherwise, importing blocks directly into the client would be bypassing
|
||||
/// important verification work.
|
||||
impl<'a, B, E, Block, RA> consensus::BlockImport<Block> for &'a Client<B, E, Block, RA> where
|
||||
impl<'a, B, E, Block, RA> sp_consensus::BlockImport<Block> for &'a Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
|
||||
Block: BlockT<Hash=H256>,
|
||||
@@ -1507,7 +1507,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport<Block> for &'a Client<B, E, Blo
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> consensus::BlockImport<Block> for Client<B, E, Block, RA> where
|
||||
impl<B, E, Block, RA> sp_consensus::BlockImport<Block> for Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
|
||||
Block: BlockT<Hash=H256>,
|
||||
@@ -1758,7 +1758,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
impl<BE, E, B, RA> consensus::block_validation::Chain<B> for Client<BE, E, B, RA>
|
||||
impl<BE, E, B, RA> sp_consensus::block_validation::Chain<B> for Client<BE, E, B, RA>
|
||||
where
|
||||
BE: backend::Backend<B, Blake2Hasher>,
|
||||
E: CallExecutor<B, Blake2Hasher>,
|
||||
@@ -1773,13 +1773,13 @@ impl<BE, E, B, RA> consensus::block_validation::Chain<B> for Client<BE, E, B, RA
|
||||
pub(crate) mod tests {
|
||||
use std::collections::HashMap;
|
||||
use super::*;
|
||||
use primitives::blake2_256;
|
||||
use sp_core::blake2_256;
|
||||
use sp_runtime::DigestItem;
|
||||
use consensus::{BlockOrigin, SelectChain, BlockImport};
|
||||
use test_client::{
|
||||
use sp_consensus::{BlockOrigin, SelectChain, BlockImport};
|
||||
use substrate_test_runtime_client::{
|
||||
prelude::*,
|
||||
client_ext::ClientExt,
|
||||
client_db::{Backend, DatabaseSettings, DatabaseSettingsSrc, PruningMode},
|
||||
sc_client_db::{Backend, DatabaseSettings, DatabaseSettingsSrc, PruningMode},
|
||||
runtime::{self, Block, Transfer, RuntimeApi, TestAPI},
|
||||
};
|
||||
|
||||
@@ -1788,7 +1788,7 @@ pub(crate) mod tests {
|
||||
/// 2) roots of changes tries for these blocks
|
||||
/// 3) test cases in form (begin, end, key, vec![(block, extrinsic)]) that are required to pass
|
||||
pub fn prepare_client_with_key_changes() -> (
|
||||
test_client::client::Client<test_client::Backend, test_client::Executor, Block, RuntimeApi>,
|
||||
substrate_test_runtime_client::sc_client::Client<substrate_test_runtime_client::Backend, substrate_test_runtime_client::Executor, Block, RuntimeApi>,
|
||||
Vec<H256>,
|
||||
Vec<(u64, u64, Vec<u8>, Vec<(u64, u32)>)>,
|
||||
) {
|
||||
@@ -1858,7 +1858,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn client_initializes_from_genesis_ok() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
assert_eq!(
|
||||
client.runtime_api().balance_of(
|
||||
@@ -1878,7 +1878,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_builder_works_with_no_transactions() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
let builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
@@ -1889,7 +1889,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_builder_works_with_transactions() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
@@ -1925,7 +1925,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_builder_does_not_include_invalid() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
@@ -1987,7 +1987,7 @@ pub(crate) mod tests {
|
||||
fn uncles_with_only_ancestors() {
|
||||
// block tree:
|
||||
// G -> A1 -> A2
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
// G -> A1
|
||||
let a1 = client.new_block(Default::default()).unwrap().bake().unwrap();
|
||||
@@ -2007,7 +2007,7 @@ pub(crate) mod tests {
|
||||
// A1 -> B2 -> B3 -> B4
|
||||
// B2 -> C3
|
||||
// A1 -> D2
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
// G -> A1
|
||||
let a1 = client.new_block(Default::default()).unwrap().bake().unwrap();
|
||||
@@ -2444,7 +2444,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn import_with_justification() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
// G -> A1
|
||||
let a1 = client.new_block(Default::default()).unwrap().bake().unwrap();
|
||||
@@ -2483,7 +2483,7 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn importing_diverged_finalized_block_should_trigger_reorg() {
|
||||
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
// G -> A1 -> A2
|
||||
// \
|
||||
@@ -2599,7 +2599,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn get_header_by_block_number_doesnt_panic() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
// backend uses u32 for block numbers, make sure we don't panic when
|
||||
// trying to convert
|
||||
@@ -2610,7 +2610,7 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn state_reverted_on_reorg() {
|
||||
let _ = env_logger::try_init();
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
let current_balance = ||
|
||||
client.runtime_api().balance_of(
|
||||
|
||||
@@ -43,27 +43,27 @@ pub fn construct_genesis_block<
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use codec::{Encode, Decode, Joiner};
|
||||
use executor::native_executor_instance;
|
||||
use state_machine::{
|
||||
use sc_executor::native_executor_instance;
|
||||
use sp_state_machine::{
|
||||
StateMachine, OverlayedChanges, ExecutionStrategy, InMemoryChangesTrieStorage,
|
||||
};
|
||||
use state_machine::backend::InMemory;
|
||||
use test_client::{
|
||||
use sp_state_machine::backend::InMemory;
|
||||
use substrate_test_runtime_client::{
|
||||
runtime::genesismap::{GenesisConfig, insert_genesis_block},
|
||||
runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest},
|
||||
AccountKeyring, Sr25519Keyring,
|
||||
};
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_core::Blake2Hasher;
|
||||
use hex_literal::*;
|
||||
|
||||
native_executor_instance!(
|
||||
Executor,
|
||||
test_client::runtime::api::dispatch,
|
||||
test_client::runtime::native_version
|
||||
substrate_test_runtime_client::runtime::api::dispatch,
|
||||
substrate_test_runtime_client::runtime::native_version
|
||||
);
|
||||
|
||||
fn executor() -> executor::NativeExecutor<Executor> {
|
||||
executor::NativeExecutor::new(executor::WasmExecutionMethod::Interpreted, None)
|
||||
fn executor() -> sc_executor::NativeExecutor<Executor> {
|
||||
sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None)
|
||||
}
|
||||
|
||||
fn construct_block(
|
||||
@@ -73,7 +73,7 @@ mod tests {
|
||||
state_root: Hash,
|
||||
txs: Vec<Transfer>
|
||||
) -> (Vec<u8>, Hash) {
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
|
||||
let transactions = txs.into_iter().map(|tx| tx.into_signed_tx()).collect::<Vec<_>>();
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use parking_lot::RwLock;
|
||||
use primitives::{ChangesTrieConfiguration, storage::well_known_keys};
|
||||
use primitives::offchain::storage::{
|
||||
use sp_core::{ChangesTrieConfiguration, storage::well_known_keys};
|
||||
use sp_core::offchain::storage::{
|
||||
InMemOffchainStorage as OffchainStorage
|
||||
};
|
||||
use sp_runtime::generic::{BlockId, DigestItem};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor};
|
||||
use sp_runtime::{Justification, Storage};
|
||||
use state_machine::backend::{Backend as StateBackend, InMemory};
|
||||
use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction};
|
||||
use sp_state_machine::backend::{Backend as StateBackend, InMemory};
|
||||
use sp_state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction};
|
||||
use hash_db::{Hasher, Prefix};
|
||||
use trie::MemoryDB;
|
||||
use sp_trie::MemoryDB;
|
||||
use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata};
|
||||
|
||||
use client_api::{
|
||||
use sc_client_api::{
|
||||
backend::{self, NewBlockState, StorageCollection, ChildStorageCollection},
|
||||
blockchain::{
|
||||
self, BlockStatus, HeaderBackend, well_known_cache_keys::Id as CacheKeyId
|
||||
@@ -398,7 +398,7 @@ impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> client_api::light::Storage<Block> for Blockchain<Block>
|
||||
impl<Block: BlockT> sc_client_api::light::Storage<Block> for Blockchain<Block>
|
||||
where
|
||||
Block::Hash: From<[u8; 32]>,
|
||||
{
|
||||
@@ -752,7 +752,7 @@ impl<Block: BlockT, H: Hasher> backend::PrunableStateChangesTrieStorage<Block, H
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block, H> state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> for ChangesTrieStorage<Block, H>
|
||||
impl<Block, H> sp_state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> for ChangesTrieStorage<Block, H>
|
||||
where
|
||||
Block: BlockT,
|
||||
H: Hasher,
|
||||
@@ -760,7 +760,7 @@ impl<Block, H> state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> for C
|
||||
fn build_anchor(
|
||||
&self,
|
||||
_hash: H::Out,
|
||||
) -> Result<state_machine::ChangesTrieAnchorBlockId<H::Out, NumberFor<Block>>, String> {
|
||||
) -> Result<sp_state_machine::ChangesTrieAnchorBlockId<H::Out, NumberFor<Block>>, String> {
|
||||
Err("Dummy implementation".into())
|
||||
}
|
||||
|
||||
@@ -773,12 +773,12 @@ impl<Block, H> state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> for C
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block, H> state_machine::ChangesTrieStorage<H, NumberFor<Block>> for ChangesTrieStorage<Block, H>
|
||||
impl<Block, H> sp_state_machine::ChangesTrieStorage<H, NumberFor<Block>> for ChangesTrieStorage<Block, H>
|
||||
where
|
||||
Block: BlockT,
|
||||
H: Hasher,
|
||||
{
|
||||
fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> {
|
||||
fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage<H, NumberFor<Block>> {
|
||||
self
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ impl<Block, H> state_machine::ChangesTrieStorage<H, NumberFor<Block>> for Change
|
||||
false
|
||||
}
|
||||
|
||||
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<state_machine::DBValue>, String> {
|
||||
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<sp_state_machine::DBValue>, String> {
|
||||
self.0.get(key, prefix)
|
||||
}
|
||||
}
|
||||
@@ -810,25 +810,25 @@ pub fn check_genesis_storage(storage: &Storage) -> sp_blockchain::Result<()> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use primitives::offchain::{OffchainStorage, storage::InMemOffchainStorage};
|
||||
use sp_core::offchain::{OffchainStorage, storage::InMemOffchainStorage};
|
||||
use std::sync::Arc;
|
||||
use test_client;
|
||||
use primitives::Blake2Hasher;
|
||||
use substrate_test_runtime_client;
|
||||
use sp_core::Blake2Hasher;
|
||||
|
||||
type TestBackend = test_client::client::in_mem::Backend<test_client::runtime::Block, Blake2Hasher>;
|
||||
type TestBackend = substrate_test_runtime_client::sc_client::in_mem::Backend<substrate_test_runtime_client::runtime::Block, Blake2Hasher>;
|
||||
|
||||
#[test]
|
||||
fn test_leaves_with_complex_block_tree() {
|
||||
let backend = Arc::new(TestBackend::new());
|
||||
|
||||
test_client::trait_tests::test_leaves_for_backend(backend);
|
||||
substrate_test_runtime_client::trait_tests::test_leaves_for_backend(backend);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blockchain_query_by_number_gets_canonical() {
|
||||
let backend = Arc::new(TestBackend::new());
|
||||
|
||||
test_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend);
|
||||
substrate_test_runtime_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -47,15 +47,15 @@
|
||||
//! ```
|
||||
//! use std::sync::Arc;
|
||||
//! use sc_client::{Client, in_mem::Backend, LocalCallExecutor};
|
||||
//! use primitives::Blake2Hasher;
|
||||
//! use sp_core::Blake2Hasher;
|
||||
//! use sp_runtime::Storage;
|
||||
//! use executor::{NativeExecutor, WasmExecutionMethod};
|
||||
//! use sc_executor::{NativeExecutor, WasmExecutionMethod};
|
||||
//!
|
||||
//! // In this example, we're using the `Block` and `RuntimeApi` types from the
|
||||
//! // `substrate-test-runtime-client` crate. These types are automatically generated when
|
||||
//! // compiling a runtime. In a typical use-case, these types would have been to be generated
|
||||
//! // from your runtime.
|
||||
//! use test_client::{LocalExecutor, runtime::Block, runtime::RuntimeApi};
|
||||
//! use substrate_test_runtime_client::{LocalExecutor, runtime::Block, runtime::RuntimeApi};
|
||||
//!
|
||||
//! let backend = Arc::new(Backend::<Block, Blake2Hasher>::new());
|
||||
//! let client = Client::<_, _, _, RuntimeApi>::new(
|
||||
@@ -83,7 +83,7 @@ pub mod leaves;
|
||||
mod call_executor;
|
||||
mod client;
|
||||
|
||||
pub use client_api::{
|
||||
pub use sc_client_api::{
|
||||
blockchain,
|
||||
blockchain::well_known_cache_keys,
|
||||
blockchain::Info as ChainInfo,
|
||||
@@ -102,4 +102,4 @@ pub use crate::{
|
||||
},
|
||||
leaves::LeafSet,
|
||||
};
|
||||
pub use state_machine::{ExecutionStrategy, StorageProof};
|
||||
pub use sp_state_machine::{ExecutionStrategy, StorageProof};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user