diff --git a/Cargo.lock b/Cargo.lock index 51819d7b..ed900c47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8763,6 +8763,7 @@ dependencies = [ "sp-consensus-babe", "sp-core", "sp-inherents", + "sp-io", "sp-keyring", "sp-runtime", "sp-timestamp", diff --git a/substrate/node/Cargo.toml b/substrate/node/Cargo.toml index 8e0c072e..efaa0d7e 100644 --- a/substrate/node/Cargo.toml +++ b/substrate/node/Cargo.toml @@ -23,6 +23,7 @@ sp-core = { git = "https://github.com/serai-dex/substrate" } sp-keyring = { git = "https://github.com/serai-dex/substrate" } sp-inherents = { git = "https://github.com/serai-dex/substrate" } sp-timestamp = { git = "https://github.com/serai-dex/substrate" } +sp-io = { git = "https://github.com/serai-dex/substrate" } sp-runtime = { git = "https://github.com/serai-dex/substrate" } sp-blockchain = { git = "https://github.com/serai-dex/substrate" } sp-api = { git = "https://github.com/serai-dex/substrate" } diff --git a/substrate/node/src/command.rs b/substrate/node/src/command.rs index d2614967..5666eb93 100644 --- a/substrate/node/src/command.rs +++ b/substrate/node/src/command.rs @@ -99,7 +99,29 @@ pub fn run() -> sc_cli::Result<()> { }), Some(Subcommand::Benchmark(cmd)) => cli.create_runner(cmd)?.sync_run(|config| match cmd { - BenchmarkCmd::Pallet(cmd) => cmd.run::(config), + BenchmarkCmd::Pallet(cmd) => { + use sc_executor::{NativeVersion, NativeExecutionDispatch}; + + use serai_runtime as runtime; + + struct ExecutorDispatch; + impl NativeExecutionDispatch for ExecutorDispatch { + #[cfg(feature = "runtime-benchmarks")] + type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; + #[cfg(not(feature = "runtime-benchmarks"))] + type ExtendHostFunctions = (); + + fn dispatch(method: &str, data: &[u8]) -> Option> { + runtime::api::dispatch(method, data) + } + + fn native_version() -> NativeVersion { + runtime::native_version() + } + } + + cmd.run::(config) + } BenchmarkCmd::Block(cmd) => cmd.run(service::new_partial(&config)?.client), diff --git a/substrate/node/src/service.rs b/substrate/node/src/service.rs index b78f8c57..9de0e135 100644 --- a/substrate/node/src/service.rs +++ b/substrate/node/src/service.rs @@ -5,7 +5,8 @@ use futures::stream::StreamExt; use sp_timestamp::InherentDataProvider as TimestampInherent; use sp_consensus_babe::{SlotDuration, inherents::InherentDataProvider as BabeInherent}; -use sc_executor::{NativeVersion, NativeExecutionDispatch, NativeElseWasmExecutor}; +use sp_io::SubstrateHostFunctions; +use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, WasmExecutor}; use sc_network_common::sync::warp::WarpSyncParams; use sc_network::{Event, NetworkEventStream}; @@ -15,29 +16,20 @@ use sc_client_api::BlockBackend; use sc_telemetry::{Telemetry, TelemetryWorker}; -use serai_runtime::{self as runtime, opaque::Block, RuntimeApi}; +use serai_runtime::{opaque::Block, RuntimeApi}; use sc_consensus_babe::{self, SlotProportion}; use sc_consensus_grandpa as grandpa; -pub struct ExecutorDispatch; -impl NativeExecutionDispatch for ExecutorDispatch { - #[cfg(feature = "runtime-benchmarks")] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(not(feature = "runtime-benchmarks"))] - type ExtendHostFunctions = (); - - fn dispatch(method: &str, data: &[u8]) -> Option> { - runtime::api::dispatch(method, data) - } - - fn native_version() -> NativeVersion { - serai_runtime::native_version() - } -} +#[cfg(not(feature = "runtime-benchmarks"))] +pub type Executor = WasmExecutor>; +#[cfg(feature = "runtime-benchmarks")] +pub type Executor = WasmExecutor< + ExtendedHostFunctions, +>; type FullBackend = sc_service::TFullBackend; -pub type FullClient = TFullClient>; +pub type FullClient = TFullClient; type SelectChain = sc_consensus::LongestChain; type GrandpaBlockImport = grandpa::GrandpaBlockImport; @@ -77,10 +69,11 @@ pub fn new_partial(config: &Configuration) -> Result::new( + let executor = Executor::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, + None, config.runtime_cache_size, );