diff --git a/Cargo.lock b/Cargo.lock index b07af1123fd0..47483d2ae351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5144,7 +5144,7 @@ dependencies = [ [[package]] name = "fflonk" version = "0.1.0" -source = "git+https://github.com/w3f/fflonk#26a5045b24e169cffc1f9328ca83d71061145c40" +source = "git+https://github.com/w3f/fflonk#1e854f35e9a65d08b11a86291405cdc95baa0a35" dependencies = [ "ark-ec", "ark-ff", @@ -19316,7 +19316,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] 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, + } } } diff --git a/substrate/primitives/externalities/src/lib.rs b/substrate/primitives/externalities/src/lib.rs index 411ec97a6b82..41ebf8edd150 100644 --- a/substrate/primitives/externalities/src/lib.rs +++ b/substrate/primitives/externalities/src/lib.rs @@ -309,6 +309,11 @@ pub trait Externalities: ExtensionStore { /// /// Get all the keys that have been read or written to during the benchmark. fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)>; + + /// Access to `OverlayChanges` for `gear-tasks`. + fn gear_overlayed_changes(&self) -> Option> { + None + } } /// Extension for the [`Externalities`] trait. diff --git a/substrate/primitives/state-machine/src/ext.rs b/substrate/primitives/state-machine/src/ext.rs index 11df46f2a4a3..b3cee955a1fa 100644 --- a/substrate/primitives/state-machine/src/ext.rs +++ b/substrate/primitives/state-machine/src/ext.rs @@ -159,7 +159,7 @@ where impl<'a, H, B> Externalities for Ext<'a, H, B> where - H: Hasher, + H: Hasher + 'static, H::Out: Ord + 'static + codec::Codec, B: Backend, { @@ -651,6 +651,10 @@ where fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)> { self.backend.get_read_and_written_keys() } + + fn gear_overlayed_changes(&self) -> Option> { + Some(Box::new(self.overlay.clone())) + } } impl<'a, H, B> Ext<'a, H, B> diff --git a/substrate/primitives/state-machine/src/lib.rs b/substrate/primitives/state-machine/src/lib.rs index 0e2b9bfdfffc..a6baf91b3d40 100644 --- a/substrate/primitives/state-machine/src/lib.rs +++ b/substrate/primitives/state-machine/src/lib.rs @@ -223,7 +223,7 @@ mod execution { impl<'a, B, H, Exec> StateMachine<'a, B, H, Exec> where - H: Hasher, + H: Hasher + 'static, H::Out: Ord + 'static + codec::Codec, Exec: CodeExecutor + Clone + 'static, B: Backend, @@ -318,7 +318,7 @@ mod execution { ) -> Result<(Vec, StorageProof), Box> where B: AsTrieBackend, - H: Hasher, + H: Hasher + 'static, H::Out: Ord + 'static + codec::Codec, Exec: CodeExecutor + Clone + 'static, { @@ -354,7 +354,7 @@ mod execution { ) -> Result<(Vec, StorageProof), Box> where S: trie_backend_essence::TrieBackendStorage, - H: Hasher, + H: Hasher + 'static, H::Out: Ord + 'static + codec::Codec, Exec: CodeExecutor + 'static + Clone, { @@ -416,7 +416,7 @@ mod execution { runtime_code: &RuntimeCode, ) -> Result, Box> where - H: Hasher, + H: Hasher + 'static, H::Out: Ord + 'static + codec::Codec, Exec: CodeExecutor + Clone + 'static, {