Skip to content

Commit

Permalink
Stop using the native executor
Browse files Browse the repository at this point in the history
The native executor is deprecated and also doesn't work together with the new metadata hash (mentioned in the guide https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/enable_metadata_hash/index.html).
  • Loading branch information
bkchr authored and Roznovjak committed Jul 26, 2024
1 parent 6173aa4 commit eb7a72d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
6 changes: 3 additions & 3 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::chain_spec;
use crate::cli::{Cli, RelayChainCli, Subcommand};
use crate::service::{new_partial, HydraDXNativeExecutor};
use crate::service::new_partial;

use codec::Encode;
use cumulus_primitives_core::ParaId;
Expand All @@ -28,7 +28,7 @@ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams, Result,
RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use sc_executor::sp_wasm_interface::ExtendedHostFunctions;
use sc_service::config::{BasePath, PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
Expand Down Expand Up @@ -197,7 +197,7 @@ pub fn run() -> sc_cli::Result<()> {
runner.sync_run(|config| {
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<HydraDXNativeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
>>(config)
})
} else {
Expand Down
32 changes: 10 additions & 22 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use fc_db::kv::Backend as FrontierBackend;
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
Expand All @@ -53,24 +53,14 @@ use substrate_prometheus_endpoint::Registry;
pub(crate) mod evm;
use crate::{chain_spec, rpc};

/// Native executor type.
pub struct HydraDXNativeExecutor;

impl sc_executor::NativeExecutionDispatch for HydraDXNativeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
hydradx_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
hydradx_runtime::native_version()
}
}

type ParachainExecutor = NativeElseWasmExecutor<HydraDXNativeExecutor>;

type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
type ParachainClient = TFullClient<
Block,
RuntimeApi,
WasmExecutor<(
sp_io::SubstrateHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
)>,
>;

type ParachainBackend = TFullBackend<Block>;

Expand Down Expand Up @@ -117,16 +107,14 @@ pub fn new_partial(
extra_pages: h as _,
});

let wasm = WasmExecutor::builder()
let executor = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();

let executor = ParachainExecutor::new_with_wasm_executor(wasm);

let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
Expand Down

0 comments on commit eb7a72d

Please sign in to comment.