Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion PR for 'Make choosing an executor an explicit part of service construction' (#9525) #3615

Merged
14 commits merged into from
Aug 18, 2021
5 changes: 3 additions & 2 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use polkadot_primitives::v1::{
AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, ParachainHost,
};
use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider};
use sc_executor::native_executor_instance;
use sc_executor::{native_executor_instance, NativeExecutor};
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockStatus;
Expand All @@ -37,7 +37,8 @@ use std::sync::Arc;

pub type FullBackend = sc_service::TFullBackend<Block>;

pub type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, Executor>;
pub type FullClient<RuntimeApi, ExecutorInstance> =
sc_service::TFullClient<Block, RuntimeApi, NativeExecutor<ExecutorInstance>>;

native_executor_instance!(
pub PolkadotExecutor,
Expand Down
10 changes: 9 additions & 1 deletion node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub use polkadot_primitives::v1::{Block, BlockId, CollatorPair, Hash, Id as Para
pub use sc_client_api::{Backend, CallExecutor, ExecutionStrategy};
pub use sc_consensus::{BlockImport, LongestChain};
pub use sc_executor::NativeExecutionDispatch;
use sc_executor::NativeExecutor;
pub use service::{
config::{DatabaseSource, PrometheusConfig},
ChainSpec, Configuration, Error as SubstrateServiceError, PruningMode, Role, RuntimeGenesis,
Expand Down Expand Up @@ -366,10 +367,17 @@ where
})
.transpose()?;

let executor = NativeExecutor::<Executor>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
);

let (client, backend, keystore_container, task_manager) =
service::new_full_parts::<Block, RuntimeApi, Executor>(
service::new_full_parts::<Block, RuntimeApi, _>(
&config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
)?;
let client = Arc::new(client);

Expand Down