Make ValidationPool accepts execution mode to run custom command or in process validation (#1622)

* Initial commit

Forked at: cc19f13468
Parent branch: origin/master

* Propagate test mode all the way down to ValidationPool

* Update validation/src/validation_service/mod.rs

* Fix test

* WIP

Forked at: cc19f13468
Parent branch: origin/master

* Update service/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Adapt code to review suggestions

* Run validation inside the same process

* Add test

* CLEANUP

Forked at: cc19f13468
Parent branch: origin/master

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Cecile Tonglet
2020-09-09 12:17:22 +02:00
committed by GitHub
parent 4d31f8159d
commit 5338b23ca3
5 changed files with 121 additions and 56 deletions
+2 -15
View File
@@ -28,7 +28,7 @@ use sp_externalities::Extensions;
use sp_wasm_interface::HostFunctions as _;
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
pub use validation_host::{run_worker, ValidationPool, EXECUTION_TIMEOUT_SEC};
pub use validation_host::{run_worker, ValidationPool, EXECUTION_TIMEOUT_SEC, ValidationExecutionMode};
mod validation_host;
@@ -66,8 +66,6 @@ pub enum ExecutionMode<'a> {
Local,
/// Remote execution in a spawned process.
Remote(&'a ValidationPool),
/// Remote execution in a spawned test runner.
RemoteTest(&'a ValidationPool),
}
#[derive(Debug, derive_more::Display, derive_more::From)]
@@ -143,11 +141,7 @@ pub fn validate_candidate(
},
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
ExecutionMode::Remote(pool) => {
pool.validate_candidate(validation_code, params, false)
},
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
ExecutionMode::RemoteTest(pool) => {
pool.validate_candidate(validation_code, params, true)
pool.validate_candidate(validation_code, params)
},
#[cfg(any(target_os = "android", target_os = "unknown"))]
ExecutionMode::Remote(_pool) =>
@@ -156,13 +150,6 @@ pub fn validate_candidate(
"Remote validator not available".to_string()
) as Box<_>
))),
#[cfg(any(target_os = "android", target_os = "unknown"))]
ExecutionMode::RemoteTest(_pool) =>
Err(ValidationError::Internal(InternalError::System(
Box::<dyn std::error::Error + Send + Sync>::from(
"Remote validator not available".to_string()
) as Box<_>
))),
}
}