mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +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
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user