create parallel tasks extension (#5249)

This commit is contained in:
Nikolay Volf
2020-03-16 08:30:39 -07:00
committed by GitHub
parent 418b7b8bc2
commit 372745705d
25 changed files with 189 additions and 26 deletions
@@ -573,7 +573,6 @@ mod tests {
const CHILD_UUID_1: &[u8] = b"unique_id_1";
const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(CHILD_UUID_1);
fn prepare_overlay_with_changes() -> OverlayedChanges {
OverlayedChanges {
prospective: vec![
@@ -74,6 +74,7 @@ pub use trie_backend::TrieBackend;
pub use error::{Error, ExecutionError};
pub use in_memory_backend::InMemory as InMemoryBackend;
pub use stats::{UsageInfo, UsageUnit};
pub use sp_core::traits::CloneableSpawn;
type CallResult<R, E> = Result<NativeOrEncoded<R>, E>;
@@ -210,8 +211,10 @@ impl<'a, B, H, N, Exec> StateMachine<'a, B, H, N, Exec> where
call_data: &'a [u8],
mut extensions: Extensions,
runtime_code: &'a RuntimeCode,
spawn_handle: Box<dyn CloneableSpawn>,
) -> Self {
extensions.register(CallInWasmExt::new(exec.clone()));
extensions.register(sp_core::traits::TaskExecutorExt::new(spawn_handle));
Self {
backend,
@@ -437,6 +440,7 @@ pub fn prove_execution<B, H, N, Exec>(
mut backend: B,
overlay: &mut OverlayedChanges,
exec: &Exec,
spawn_handle: Box<dyn CloneableSpawn>,
method: &str,
call_data: &[u8],
runtime_code: &RuntimeCode,
@@ -454,6 +458,7 @@ where
trie_backend,
overlay,
exec,
spawn_handle,
method,
call_data,
runtime_code,
@@ -473,6 +478,7 @@ pub fn prove_execution_on_trie_backend<S, H, N, Exec>(
trie_backend: &TrieBackend<S, H>,
overlay: &mut OverlayedChanges,
exec: &Exec,
spawn_handle: Box<dyn CloneableSpawn>,
method: &str,
call_data: &[u8],
runtime_code: &RuntimeCode,
@@ -494,6 +500,7 @@ where
call_data,
Extensions::default(),
runtime_code,
spawn_handle,
);
let result = sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
@@ -510,6 +517,7 @@ pub fn execution_proof_check<H, N, Exec>(
proof: StorageProof,
overlay: &mut OverlayedChanges,
exec: &Exec,
spawn_handle: Box<dyn CloneableSpawn>,
method: &str,
call_data: &[u8],
runtime_code: &RuntimeCode,
@@ -525,6 +533,7 @@ where
&trie_backend,
overlay,
exec,
spawn_handle,
method,
call_data,
runtime_code,
@@ -536,6 +545,7 @@ pub fn execution_proof_check_on_trie_backend<H, N, Exec>(
trie_backend: &TrieBackend<MemoryDB<H>, H>,
overlay: &mut OverlayedChanges,
exec: &Exec,
spawn_handle: Box<dyn CloneableSpawn>,
method: &str,
call_data: &[u8],
runtime_code: &RuntimeCode,
@@ -555,6 +565,7 @@ where
call_data,
Extensions::default(),
runtime_code,
spawn_handle,
);
sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
@@ -820,6 +831,7 @@ mod tests {
&[],
Default::default(),
&wasm_code,
sp_core::tasks::executor(),
);
assert_eq!(
@@ -849,6 +861,7 @@ mod tests {
&[],
Default::default(),
&wasm_code,
sp_core::tasks::executor(),
);
assert_eq!(state_machine.execute(ExecutionStrategy::NativeElseWasm).unwrap(), vec![66]);
@@ -875,6 +888,7 @@ mod tests {
&[],
Default::default(),
&wasm_code,
sp_core::tasks::executor(),
);
assert!(
@@ -905,6 +919,7 @@ mod tests {
remote_backend,
&mut Default::default(),
&executor,
sp_core::tasks::executor(),
"test",
&[],
&RuntimeCode::empty(),
@@ -916,6 +931,7 @@ mod tests {
remote_proof,
&mut Default::default(),
&executor,
sp_core::tasks::executor(),
"test",
&[],
&RuntimeCode::empty(),