mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-17 10:05:41 +00:00
Refactor ValidationError (#2406)
This commit is contained in:
@@ -140,8 +140,7 @@ pub unsafe fn create_runtime_from_artifact_bytes(
|
||||
executor_params: &ExecutorParams,
|
||||
) -> Result<WasmtimeRuntime, WasmError> {
|
||||
let mut config = DEFAULT_CONFIG.clone();
|
||||
config.semantics =
|
||||
params_to_wasmtime_semantics(executor_params).map_err(|err| WasmError::Other(err))?;
|
||||
config.semantics = params_to_wasmtime_semantics(executor_params);
|
||||
|
||||
sc_executor_wasmtime::create_runtime_from_artifact_bytes::<HostFunctions>(
|
||||
compiled_artifact_blob,
|
||||
@@ -149,13 +148,12 @@ pub unsafe fn create_runtime_from_artifact_bytes(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn params_to_wasmtime_semantics(par: &ExecutorParams) -> Result<Semantics, String> {
|
||||
pub fn params_to_wasmtime_semantics(par: &ExecutorParams) -> Semantics {
|
||||
let mut sem = DEFAULT_CONFIG.semantics.clone();
|
||||
let mut stack_limit = if let Some(stack_limit) = sem.deterministic_stack_limit.clone() {
|
||||
stack_limit
|
||||
} else {
|
||||
return Err("No default stack limit set".to_owned())
|
||||
};
|
||||
let mut stack_limit = sem
|
||||
.deterministic_stack_limit
|
||||
.expect("There is a comment to not change the default stack limit; it should always be available; qed")
|
||||
.clone();
|
||||
|
||||
for p in par.iter() {
|
||||
match p {
|
||||
@@ -172,7 +170,7 @@ pub fn params_to_wasmtime_semantics(par: &ExecutorParams) -> Result<Semantics, S
|
||||
}
|
||||
}
|
||||
sem.deterministic_stack_limit = Some(stack_limit);
|
||||
Ok(sem)
|
||||
sem
|
||||
}
|
||||
|
||||
/// Runs the prevalidation on the given code. Returns a [`RuntimeBlob`] if it succeeds.
|
||||
@@ -191,8 +189,7 @@ pub fn prepare(
|
||||
blob: RuntimeBlob,
|
||||
executor_params: &ExecutorParams,
|
||||
) -> Result<Vec<u8>, sc_executor_common::error::WasmError> {
|
||||
let semantics = params_to_wasmtime_semantics(executor_params)
|
||||
.map_err(|e| sc_executor_common::error::WasmError::Other(e))?;
|
||||
let semantics = params_to_wasmtime_semantics(executor_params);
|
||||
sc_executor_wasmtime::prepare_runtime_artifact(blob, &semantics)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user