Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed "missing host function" bug #225

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions evm-template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures::{future, prelude::*};
use parachain_template_runtime::opaque::Block;
// Substrate
use sc_client_api::BlockchainEvents;
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch};
use sc_executor::WasmExecutor;
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi;
Expand All @@ -21,7 +21,7 @@ use sp_api::ConstructRuntimeApi;
pub type FullBackend = sc_service::TFullBackend<Block>;
/// Full client.
pub type FullClient<RuntimeApi, Executor> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>;
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<Executor>>;

/// Frontier DB backend type.
pub type FrontierBackend = fc_db::Backend<Block>;
Expand Down Expand Up @@ -124,9 +124,9 @@ impl<Api> EthCompatRuntimeApiCollection for Api where
{
}

pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
pub async fn spawn_frontier_tasks<RuntimeApi, Functions>(
task_manager: &TaskManager,
client: Arc<FullClient<RuntimeApi, Executor>>,
client: Arc<FullClient<RuntimeApi, Functions>>,
backend: Arc<FullBackend>,
frontier_backend: FrontierBackend,
filter_pool: Option<FilterPool>,
Expand All @@ -140,10 +140,10 @@ pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
>,
>,
) where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>>,
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Functions>>,
RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static,
Functions: sc_executor::sp_wasm_interface::HostFunctions,
{
// Spawn main mapping sync worker background task.
match frontier_backend {
Expand Down
28 changes: 12 additions & 16 deletions evm-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use parachain_template_runtime::{
};
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::NativeElseWasmExecutor;
use sc_executor::WasmExecutor;
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
Expand All @@ -42,22 +42,18 @@ use crate::eth::{
FrontierBackend, FrontierPartialComponents,
};

/// Native executor type.
pub struct ParachainNativeExecutor;
#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions =
(sp_io::SubstrateHostFunctions, cumulus_client_service::storage_proof_size::HostFunctions);

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

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

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

type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainExecutor = WasmExecutor<HostFunctions>;

type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;

Expand Down Expand Up @@ -100,7 +96,7 @@ pub fn new_partial(
})
.transpose()?;

let executor = sc_service::new_native_or_wasm_executor(config);
let executor = sc_service::new_wasm_executor(config);

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
Expand Down
Loading