mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-08 20:09:54 +00:00
Default to the wasm executor
https://github.com/paritytech/substrate/issues/ 10579 has the rationale for this.
This commit is contained in:
parent
aea6ac104f
commit
17818c2a02
4 changed files with 37 additions and 20 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -8763,6 +8763,7 @@ dependencies = [
|
|||
"sp-consensus-babe",
|
||||
"sp-core",
|
||||
"sp-inherents",
|
||||
"sp-io",
|
||||
"sp-keyring",
|
||||
"sp-runtime",
|
||||
"sp-timestamp",
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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::<Block, service::ExecutorDispatch>(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<Vec<u8>> {
|
||||
runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> NativeVersion {
|
||||
runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
cmd.run::<Block, ExecutorDispatch>(config)
|
||||
}
|
||||
|
||||
BenchmarkCmd::Block(cmd) => cmd.run(service::new_partial(&config)?.client),
|
||||
|
||||
|
|
|
@ -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<Vec<u8>> {
|
||||
runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> NativeVersion {
|
||||
serai_runtime::native_version()
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
pub type Executor = WasmExecutor<ExtendedHostFunctions<SubstrateHostFunctions, ()>>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub type Executor = WasmExecutor<
|
||||
ExtendedHostFunctions<SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions>,
|
||||
>;
|
||||
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
pub type FullClient = TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
|
||||
pub type FullClient = TFullClient<Block, RuntimeApi, Executor>;
|
||||
|
||||
type SelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
type GrandpaBlockImport = grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, SelectChain>;
|
||||
|
@ -77,10 +69,11 @@ pub fn new_partial(config: &Configuration) -> Result<PartialComponents, ServiceE
|
|||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(
|
||||
let executor = Executor::new(
|
||||
config.wasm_method,
|
||||
config.default_heap_pages,
|
||||
config.max_runtime_instances,
|
||||
None,
|
||||
config.runtime_cache_size,
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue