From 4ff38677e7a10ad3d424d945c8b51b295de8d80d Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Thu, 7 Mar 2024 13:53:06 +0100 Subject: [PATCH] fix(#214): also allow this feature for gtest and g1 --- node/src/service.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/node/src/service.rs b/node/src/service.rs index d9721f247..3c08c1881 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -89,7 +89,9 @@ pub mod gdev_executor { #[allow(dead_code)] #[cfg(feature = "g1")] pub mod g1_executor { + use crate::service::HostFunctions; pub use g1_runtime; + use sc_executor::sp_wasm_interface::{Function, HostFunctionRegistry}; pub struct G1Executor; impl sc_executor::NativeExecutionDispatch for G1Executor { @@ -103,12 +105,26 @@ pub mod g1_executor { g1_runtime::native_version() } } + impl sc_executor::sp_wasm_interface::HostFunctions for G1Executor { + fn host_functions() -> Vec<&'static dyn Function> { + HostFunctions::host_functions() + } + + fn register_static<T>(registry: &mut T) -> Result<(), T::Error> + where + T: HostFunctionRegistry, + { + HostFunctions::register_static(registry) + } + } } #[allow(dead_code)] #[cfg(feature = "gtest")] pub mod gtest_executor { + use crate::service::HostFunctions; pub use gtest_runtime; + use sc_executor::sp_wasm_interface::{Function, HostFunctionRegistry}; pub struct GTestExecutor; impl sc_executor::NativeExecutionDispatch for GTestExecutor { @@ -122,6 +138,18 @@ pub mod gtest_executor { gtest_runtime::native_version() } } + impl sc_executor::sp_wasm_interface::HostFunctions for GTestExecutor { + fn host_functions() -> Vec<&'static dyn Function> { + HostFunctions::host_functions() + } + + fn register_static<T>(registry: &mut T) -> Result<(), T::Error> + where + T: HostFunctionRegistry, + { + HostFunctions::register_static(registry) + } + } } /// /// The minimum period of blocks on which justifications will be -- GitLab