diff --git a/Cargo.lock b/Cargo.lock index 136f3ae98d9d..47483d2ae351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17590,10 +17590,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "sp-tasks" -version = "0.1.0" - [[package]] name = "sp-test-primitives" version = "2.0.0" diff --git a/substrate/client/executor/src/executor.rs b/substrate/client/executor/src/executor.rs index 7c292a83da08..7410cc1b2ba7 100644 --- a/substrate/client/executor/src/executor.rs +++ b/substrate/client/executor/src/executor.rs @@ -565,6 +565,7 @@ pub struct NativeElseWasmExecutor { /// Fallback wasm executor. wasm: WasmExecutor>, + gear_force_native: bool, } impl NativeElseWasmExecutor { @@ -601,7 +602,11 @@ impl NativeElseWasmExecutor { .with_runtime_cache_size(runtime_cache_size) .build(); - NativeElseWasmExecutor { native_version: D::native_version(), wasm } + NativeElseWasmExecutor { + native_version: D::native_version(), + wasm, + gear_force_native: false, + } } /// Create a new instance using the given [`WasmExecutor`]. @@ -610,7 +615,7 @@ impl NativeElseWasmExecutor { ExtendedHostFunctions, >, ) -> Self { - Self { native_version: D::native_version(), wasm: executor } + Self { native_version: D::native_version(), wasm: executor, gear_force_native: false } } /// Ignore missing function imports if set true. @@ -618,6 +623,10 @@ impl NativeElseWasmExecutor { pub fn allow_missing_host_functions(&mut self, allow_missing_host_functions: bool) { self.wasm.allow_missing_host_functions = allow_missing_host_functions } + + pub fn gear_force_native(&mut self) { + self.gear_force_native = true; + } } impl RuntimeVersionOf for NativeElseWasmExecutor { @@ -645,7 +654,7 @@ impl CodeExecutor for NativeElseWasmExecut runtime_code: &RuntimeCode, method: &str, data: &[u8], - use_native: bool, + mut use_native: bool, context: CallContext, ) -> (Result>, bool) { tracing::trace!( @@ -654,6 +663,10 @@ impl CodeExecutor for NativeElseWasmExecut "Executing function", ); + if self.gear_force_native { + use_native = true; + } + let on_chain_heap_alloc_strategy = if self.wasm.ignore_onchain_heap_pages { self.wasm.default_onchain_heap_alloc_strategy } else { @@ -711,7 +724,11 @@ impl CodeExecutor for NativeElseWasmExecut impl Clone for NativeElseWasmExecutor { fn clone(&self) -> Self { - NativeElseWasmExecutor { native_version: D::native_version(), wasm: self.wasm.clone() } + NativeElseWasmExecutor { + native_version: D::native_version(), + wasm: self.wasm.clone(), + gear_force_native: self.gear_force_native, + } } }