Skip to content

Commit

Permalink
Merge pull request #90 from OriginTrail/hotfix/disable-native-executor
Browse files Browse the repository at this point in the history
Uplift Devnet
  • Loading branch information
NZT48 authored Aug 9, 2024
2 parents d274626 + 3567ccb commit da7292a
Showing 1 changed file with 23 additions and 33 deletions.
56 changes: 23 additions & 33 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use polkadot_service::CollatorPair;
// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_consensus::ImportQueue;
use sc_executor::NativeElseWasmExecutor;
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 @@ -37,37 +37,15 @@ use futures::StreamExt;
use sc_client_api::BlockchainEvents;
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};

/// Extra host functions
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = (
frame_benchmarking::benchmarking::HostFunctions,
cumulus_client_service::storage_proof_size::HostFunctions,
);

/// Extra host functions
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions = (
cumulus_client_service::storage_proof_size::HostFunctions,
);

/// Native executor type.
pub struct ParachainNativeExecutor;

impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
type ExtendHostFunctions = HostFunctions;

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

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

type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;

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

type ParachainBackend = TFullBackend<Block>;

Expand Down Expand Up @@ -143,7 +121,19 @@ pub fn new_partial(
})
.transpose()?;

let executor = sc_service::new_native_or_wasm_executor(&config);
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});

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 (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
Expand Down

0 comments on commit da7292a

Please sign in to comment.