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

Replace NativeElseWasmExecutor with ParachainExecutor and update dependencies #918

Merged
merged 2 commits into from
Dec 16, 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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ serde_json = { workspace = true, default-features = true }
laos-runtime = { workspace = true, features = ["std"] }

# Substrate
frame-benchmarking ={ workspace = true }
frame-benchmarking-cli = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
sc-basic-authorship = { workspace = true }
Expand All @@ -43,6 +44,7 @@ sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true}
sp-inherents = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -97,6 +99,7 @@ runtime-benchmarks = [
"sc-service/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks"
]
try-runtime = [
"laos-runtime/try-runtime",
Expand Down
20 changes: 6 additions & 14 deletions node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use std::{
use futures::{future, prelude::*};
// Substrate
use sc_client_api::BlockchainEvents;
#[allow(deprecated)]
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch};

use sc_network_sync::SyncingService;
use sc_service::{
Expand All @@ -40,6 +38,8 @@ pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
// Local
use laos_runtime::opaque::Block;

use crate::service::ParachainExecutor;

pub fn db_config_dir(config: &Configuration) -> PathBuf {
config.base_path.config_dir(config.chain_spec.id())
}
Expand Down Expand Up @@ -139,15 +139,11 @@ impl<Api> EthCompatRuntimeApiCollection for Api where
}

#[allow(clippy::too_many_arguments)]
#[allow(deprecated)]
pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
pub async fn spawn_frontier_tasks<RuntimeApi>(
task_manager: &TaskManager,
client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
client: Arc<TFullClient<Block, RuntimeApi, ParachainExecutor>>,
backend: Arc<TFullBackend<Block>>,
frontier_backend: fc_db::Backend<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
frontier_backend: fc_db::Backend<Block, TFullClient<Block, RuntimeApi, ParachainExecutor>>,
filter_pool: Option<FilterPool>,
overrides: Arc<dyn StorageOverride<Block>>,
fee_history_cache: FeeHistoryCache,
Expand All @@ -159,13 +155,9 @@ pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
>,
>,
) where
RuntimeApi: ConstructRuntimeApi<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, ParachainExecutor>>,
RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static,
{
// Spawn main mapping sync worker background task.

Expand Down
38 changes: 13 additions & 25 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImpo
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
StartRelayChainTasksParams,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId, PersistedValidationData};
use cumulus_primitives_parachain_inherent::ParachainInherentData;
Expand All @@ -45,10 +44,7 @@ use laos_runtime::{
};
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
#[allow(deprecated)]
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_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
Expand All @@ -66,23 +62,18 @@ use crate::eth::{
FrontierBlockImport as TFrontierBlockImport, FrontierPartialComponents,
};

/// Native executor type.
pub struct ParachainNativeExecutor;

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

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
laos_runtime::api::dispatch(method, data)
}
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions =
(sp_io::SubstrateHostFunctions, cumulus_client_service::storage_proof_size::HostFunctions);

fn native_version() -> sc_executor::NativeVersion {
laos_runtime::native_version()
}
}
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
cumulus_client_service::storage_proof_size::HostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
);

#[allow(deprecated)]
type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
pub type ParachainExecutor = WasmExecutor<HostFunctions>;

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

Expand Down Expand Up @@ -131,17 +122,14 @@ pub fn new_partial(
let heap_pages = config
.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
Loading