mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Discard Executor (#1855)
closes #622 Pros: * simpler interface, just functions: `create_runtime_from_artifact_bytes()` and `execute_artifact()` Cons: * extra overhead of constructing executor semantics each time I could make it a combination of * `create_runtime_config(params)` (such that we could clone the constructed semantics) * `create_runtime(blob, config)` * `execute_artifact(blob, config, params)` Not sure if it's worth it though. --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -29,20 +29,20 @@ pub fn validate_candidate(
|
||||
code: &[u8],
|
||||
params: &[u8],
|
||||
) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
|
||||
use polkadot_node_core_pvf_execute_worker::Executor;
|
||||
use polkadot_node_core_pvf_execute_worker::execute_artifact;
|
||||
use polkadot_node_core_pvf_prepare_worker::{prepare, prevalidate};
|
||||
|
||||
let code = sp_maybe_compressed_blob::decompress(code, 10 * 1024 * 1024)
|
||||
.expect("Decompressing code failed");
|
||||
|
||||
let blob = prevalidate(&code)?;
|
||||
let compiled_artifact_blob = prepare(blob, &ExecutorParams::default())?;
|
||||
let executor_params = ExecutorParams::default();
|
||||
let compiled_artifact_blob = prepare(blob, &executor_params)?;
|
||||
|
||||
let executor = Executor::new(ExecutorParams::default())?;
|
||||
let result = unsafe {
|
||||
// SAFETY: This is trivially safe since the artifact is obtained by calling `prepare`
|
||||
// and is written into a temporary directory in an unmodified state.
|
||||
executor.execute(&compiled_artifact_blob, params)?
|
||||
execute_artifact(&compiled_artifact_blob, &executor_params, params)?
|
||||
};
|
||||
|
||||
Ok(result)
|
||||
|
||||
Reference in New Issue
Block a user