fixed "missing host function" bug (#225)

* Recovered WasmExecutor for the EVM template
This commit is contained in:
Nikita Khateev
2024-06-13 14:43:37 +04:00
committed by GitHub
parent 26c49797cb
commit f856d5f78e
2 changed files with 18 additions and 22 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ use futures::{future, prelude::*};
use parachain_template_runtime::opaque::Block; use parachain_template_runtime::opaque::Block;
// Substrate // Substrate
use sc_client_api::BlockchainEvents; use sc_client_api::BlockchainEvents;
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_executor::WasmExecutor;
use sc_network_sync::SyncingService; use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi; use sp_api::ConstructRuntimeApi;
@@ -21,7 +21,7 @@ use sp_api::ConstructRuntimeApi;
pub type FullBackend = sc_service::TFullBackend<Block>; pub type FullBackend = sc_service::TFullBackend<Block>;
/// Full client. /// Full client.
pub type FullClient<RuntimeApi, Executor> = pub type FullClient<RuntimeApi, Executor> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>; sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<Executor>>;
/// Frontier DB backend type. /// Frontier DB backend type.
pub type FrontierBackend = fc_db::Backend<Block>; pub type FrontierBackend = fc_db::Backend<Block>;
@@ -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, task_manager: &TaskManager,
client: Arc<FullClient<RuntimeApi, Executor>>, client: Arc<FullClient<RuntimeApi, Functions>>,
backend: Arc<FullBackend>, backend: Arc<FullBackend>,
frontier_backend: FrontierBackend, frontier_backend: FrontierBackend,
filter_pool: Option<FilterPool>, filter_pool: Option<FilterPool>,
@@ -140,10 +140,10 @@ pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
>, >,
>, >,
) where ) where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>>, RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Functions>>,
RuntimeApi: Send + Sync + 'static, RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection, RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static, Functions: sc_executor::sp_wasm_interface::HostFunctions,
{ {
// Spawn main mapping sync worker background task. // Spawn main mapping sync worker background task.
match frontier_backend { match frontier_backend {
+12 -16
View File
@@ -27,7 +27,7 @@ use parachain_template_runtime::{
}; };
use sc_client_api::Backend; use sc_client_api::Backend;
use sc_consensus::ImportQueue; use sc_consensus::ImportQueue;
use sc_executor::NativeElseWasmExecutor; use sc_executor::WasmExecutor;
use sc_network::NetworkBlock; use sc_network::NetworkBlock;
use sc_network_sync::SyncingService; use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
@@ -42,22 +42,18 @@ use crate::eth::{
FrontierBackend, FrontierPartialComponents, FrontierBackend, FrontierPartialComponents,
}; };
/// Native executor type. #[cfg(not(feature = "runtime-benchmarks"))]
pub struct ParachainNativeExecutor; type HostFunctions =
(sp_io::SubstrateHostFunctions, cumulus_client_service::storage_proof_size::HostFunctions);
impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor { #[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; 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>> { type ParachainExecutor = WasmExecutor<HostFunctions>;
parachain_template_runtime::apis::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
parachain_template_runtime::native_version()
}
}
type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>; type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
@@ -100,7 +96,7 @@ pub fn new_partial(
}) })
.transpose()?; .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) = let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>( sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(