Skip to content

Commit

Permalink
remove native
Browse files Browse the repository at this point in the history
  • Loading branch information
enddynayn committed Jul 31, 2024
1 parent 5538f61 commit 672b981
Showing 1 changed file with 41 additions and 40 deletions.
81 changes: 41 additions & 40 deletions node/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_network::RequireSecondedInBlockAnnounce;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartCollatorParams,
StartFullNodeParams, StartRelayChainTasksParams,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
StartCollatorParams, StartFullNodeParams, StartRelayChainTasksParams,
};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
Expand Down Expand Up @@ -54,52 +54,55 @@ type FullBackend = TFullBackend<Block>;

type MaybeFullSelectChain = Option<LongestChain<FullBackend, Block>>;

pub use frequency_runtime;

/// Native executor instance for frequency.
pub mod frequency_executor {
pub use frequency_runtime;
use log::debug;
use sc_executor::{
sp_wasm_interface,
sp_wasm_interface::{Function, HostFunctionRegistry, HostFunctions},
};
// pub mod frequency_executor {
// pub use frequency_runtime;
// use log::debug;
// use sc_executor::{
// sp_wasm_interface,
// sp_wasm_interface::{Function, HostFunctionRegistry, HostFunctions},
// };

/// Native executor instance for frequency mainnet.
pub struct FrequencyExecutorDispatch;
// pub struct FrequencyExecutorDispatch;

impl sc_executor::NativeExecutionDispatch for FrequencyExecutorDispatch {
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = (
frame_benchmarking::benchmarking::HostFunctions,
cumulus_client_service::storage_proof_size::HostFunctions,
);
// impl sc_executor::NativeExecutionDispatch for FrequencyExecutorDispatch {
// #[cfg(feature = "runtime-benchmarks")]
// type ExtendHostFunctions = (
// frame_benchmarking::benchmarking::HostFunctions,
// cumulus_client_service::storage_proof_size::HostFunctions,
// );

#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = cumulus_client_service::storage_proof_size::HostFunctions;
// #[cfg(not(feature = "runtime-benchmarks"))]
// type ExtendHostFunctions = cumulus_client_service::storage_proof_size::HostFunctions;

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

fn native_version() -> sc_executor::NativeVersion {
frequency_runtime::native_version()
}
}
// fn native_version() -> sc_executor::NativeVersion {
// frequency_runtime::native_version()
// }
// }

#[cfg(feature = "try-runtime")]
impl HostFunctions for FrequencyExecutorDispatch {
fn host_functions() -> Vec<&'static dyn Function> {
Vec::new()
}
// #[cfg(feature = "try-runtime")]
// impl HostFunctions for FrequencyExecutorDispatch {
// fn host_functions() -> Vec<&'static dyn Function> {
// Vec::new()
// }

fn register_static<T: HostFunctionRegistry>(_registry: &mut T) -> Result<(), T::Error> {
Ok(())
}
}
}
// fn register_static<T: HostFunctionRegistry>(_registry: &mut T) -> Result<(), T::Error> {
// Ok(())
// }
// }
// }

pub use frequency_executor::*;
// pub use frequency_executor::*;

type ParachainExecutor = NativeElseWasmExecutor<FrequencyExecutorDispatch>;
// type ParachainExecutor = NativeElseWasmExecutor<FrequencyExecutorDispatch>;
type ParachainExecutor = WasmExecutor<ParachainHostFunctions>;

/// Frequency parachain
pub type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
Expand Down Expand Up @@ -142,16 +145,14 @@ pub fn new_partial(
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });

let wasm = WasmExecutor::builder()
let executor = ParachainExecutor::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,
Expand Down

0 comments on commit 672b981

Please sign in to comment.