diff --git a/node/src/service/executors.rs b/node/src/service/executors.rs index e339a615b..2fe58c798 100644 --- a/node/src/service/executors.rs +++ b/node/src/service/executors.rs @@ -19,22 +19,24 @@ // substrate use sc_executor::{NativeExecutionDispatch, NativeVersion}; +#[cfg(all(feature = "runtime-benchmarks", feature = "evm-tracing"))] +pub type HostFunctions = ( + frame_benchmarking::benchmarking::HostFunctions, + moonbeam_primitives_ext::moonbeam_ext::HostFunctions, +); +#[cfg(all(feature = "runtime-benchmarks", not(feature = "evm-tracing")))] +pub type HostFunctions = frame_benchmarking::benchmarking::HostFunctions; +#[cfg(all(not(feature = "runtime-benchmarks"), feature = "evm-tracing"))] +pub type HostFunctions = moonbeam_primitives_ext::moonbeam_ext::HostFunctions; +#[cfg(not(any(feature = "evm-tracing", feature = "runtime-benchmarks")))] +pub type HostFunctions = (); + /// Darwinia native executor instance. #[cfg(feature = "darwinia-native")] pub struct DarwiniaRuntimeExecutor; #[cfg(feature = "darwinia-native")] impl NativeExecutionDispatch for DarwiniaRuntimeExecutor { - #[cfg(all(feature = "runtime-benchmarks", feature = "evm-tracing"))] - type ExtendHostFunctions = ( - frame_benchmarking::benchmarking::HostFunctions, - moonbeam_primitives_ext::moonbeam_ext::HostFunctions, - ); - #[cfg(all(feature = "runtime-benchmarks", not(feature = "evm-tracing")))] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(all(not(feature = "runtime-benchmarks"), feature = "evm-tracing"))] - type ExtendHostFunctions = moonbeam_primitives_ext::moonbeam_ext::HostFunctions; - #[cfg(not(any(feature = "evm-tracing", feature = "runtime-benchmarks")))] - type ExtendHostFunctions = (); + type ExtendHostFunctions = HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { darwinia_runtime::api::dispatch(method, data) @@ -50,17 +52,7 @@ impl NativeExecutionDispatch for DarwiniaRuntimeExecutor { pub struct CrabRuntimeExecutor; #[cfg(feature = "crab-native")] impl NativeExecutionDispatch for CrabRuntimeExecutor { - #[cfg(all(feature = "runtime-benchmarks", feature = "evm-tracing"))] - type ExtendHostFunctions = ( - frame_benchmarking::benchmarking::HostFunctions, - moonbeam_primitives_ext::moonbeam_ext::HostFunctions, - ); - #[cfg(all(feature = "runtime-benchmarks", not(feature = "evm-tracing")))] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(all(not(feature = "runtime-benchmarks"), feature = "evm-tracing"))] - type ExtendHostFunctions = moonbeam_primitives_ext::moonbeam_ext::HostFunctions; - #[cfg(not(any(feature = "evm-tracing", feature = "runtime-benchmarks")))] - type ExtendHostFunctions = (); + type ExtendHostFunctions = HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { crab_runtime::api::dispatch(method, data) @@ -76,17 +68,7 @@ impl NativeExecutionDispatch for CrabRuntimeExecutor { pub struct PangolinRuntimeExecutor; #[cfg(feature = "pangolin-native")] impl NativeExecutionDispatch for PangolinRuntimeExecutor { - #[cfg(all(feature = "runtime-benchmarks", feature = "evm-tracing"))] - type ExtendHostFunctions = ( - frame_benchmarking::benchmarking::HostFunctions, - moonbeam_primitives_ext::moonbeam_ext::HostFunctions, - ); - #[cfg(all(feature = "runtime-benchmarks", not(feature = "evm-tracing")))] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(all(not(feature = "runtime-benchmarks"), feature = "evm-tracing"))] - type ExtendHostFunctions = moonbeam_primitives_ext::moonbeam_ext::HostFunctions; - #[cfg(not(any(feature = "evm-tracing", feature = "runtime-benchmarks")))] - type ExtendHostFunctions = (); + type ExtendHostFunctions = HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { pangolin_runtime::api::dispatch(method, data) @@ -102,17 +84,7 @@ impl NativeExecutionDispatch for PangolinRuntimeExecutor { pub struct PangoroRuntimeExecutor; #[cfg(feature = "pangoro-native")] impl NativeExecutionDispatch for PangoroRuntimeExecutor { - #[cfg(all(feature = "runtime-benchmarks", feature = "evm-tracing"))] - type ExtendHostFunctions = ( - frame_benchmarking::benchmarking::HostFunctions, - moonbeam_primitives_ext::moonbeam_ext::HostFunctions, - ); - #[cfg(all(feature = "runtime-benchmarks", not(feature = "evm-tracing")))] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(all(not(feature = "runtime-benchmarks"), feature = "evm-tracing"))] - type ExtendHostFunctions = moonbeam_primitives_ext::moonbeam_ext::HostFunctions; - #[cfg(not(any(feature = "evm-tracing", feature = "runtime-benchmarks")))] - type ExtendHostFunctions = (); + type ExtendHostFunctions = HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { pangoro_runtime::api::dispatch(method, data) diff --git a/node/src/service/mod.rs b/node/src/service/mod.rs index e3b9bdce3..ea4fc20ed 100644 --- a/node/src/service/mod.rs +++ b/node/src/service/mod.rs @@ -171,12 +171,17 @@ where Ok((worker, telemetry)) }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); + let heap_pages = + config.default_heap_pages.map_or(sc_executor::DEFAULT_HEAP_ALLOC_STRATEGY, |h| { + sc_executor::HeapAllocStrategy::Static { extra_pages: h as _ } + }); + let executor = sc_executor::WasmExecutor::::builder() + .with_execution_method(config.wasm_method) + .with_max_runtime_instances(config.max_runtime_instances) + .with_runtime_cache_size(config.runtime_cache_size) + .with_onchain_heap_alloc_strategy(heap_pages) + .with_offchain_heap_alloc_strategy(heap_pages) + .build(); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( config,