@@ -32,14 +32,14 @@ use cumulus_primitives_core::{
3232 ParaId ,
3333} ;
3434use cumulus_relay_chain_interface:: { OverseerHandle , RelayChainInterface } ;
35- use polkadot_service:: NativeExecutionDispatch ;
3635use sc_consensus:: ImportQueue ;
37- use sc_executor:: NativeElseWasmExecutor ;
36+ use sc_executor:: WasmExecutor ;
3837use sc_network:: NetworkBlock ;
3938use sc_network_sync:: SyncingService ;
4039use sc_service:: { Configuration , TFullBackend , TFullClient , TaskManager } ;
4140use sc_telemetry:: { Telemetry , TelemetryHandle , TelemetryWorker , TelemetryWorkerHandle } ;
4241use sp_api:: ConstructRuntimeApi ;
42+ use sp_io:: SubstrateHostFunctions ;
4343use sp_keystore:: KeystorePtr ;
4444use sp_runtime:: traits:: BlakeTwo256 ;
4545use std:: { sync:: Arc , time:: Duration } ;
@@ -54,26 +54,31 @@ type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::Blake
5454
5555pub ( crate ) type Block = sp_runtime:: generic:: Block < Header , sp_runtime:: OpaqueExtrinsic > ;
5656
57- type ParachainExecutor < Executor > = NativeElseWasmExecutor < Executor > ;
57+ #[ cfg( not( feature = "runtime-benchmarks" ) ) ]
58+ type HostFunctions = SubstrateHostFunctions ;
59+ #[ cfg( feature = "runtime-benchmarks" ) ]
60+ type HostFunctions = ( SubstrateHostFunctions , frame_benchmarking:: benchmarking:: HostFunctions ) ;
5861
59- type ParachainClient < RuntimeApi , Executor > = TFullClient < Block , RuntimeApi , ParachainExecutor < Executor > > ;
62+ type ParachainExecutor = WasmExecutor < HostFunctions > ;
63+
64+ type ParachainClient < RuntimeApi > = TFullClient < Block , RuntimeApi , ParachainExecutor > ;
6065
6166type ParachainBackend = TFullBackend < Block > ;
6267
63- type ParachainBlockImport < RuntimeApi , Executor > =
64- TParachainBlockImport < Block , Arc < ParachainClient < RuntimeApi , Executor > > , ParachainBackend > ;
68+ type ParachainBlockImport < RuntimeApi > =
69+ TParachainBlockImport < Block , Arc < ParachainClient < RuntimeApi > > , ParachainBackend > ;
6570
66- pub ( crate ) type TransactionPool < Block , RuntimeApi , Executor > =
67- sc_transaction_pool:: FullPool < Block , TFullClient < Block , RuntimeApi , Executor > > ;
71+ pub ( crate ) type TransactionPool < Block , RuntimeApi > =
72+ sc_transaction_pool:: FullPool < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ;
6873
69- type PartialComponents < Block , RuntimeApi , Executor , Telemetry , TelemetryWorkerHandle > = sc_service:: PartialComponents <
70- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
74+ type PartialComponents < Block , RuntimeApi , Telemetry , TelemetryWorkerHandle > = sc_service:: PartialComponents <
75+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
7176 TFullBackend < Block > ,
7277 ( ) ,
7378 sc_consensus:: DefaultImportQueue < Block > ,
74- TransactionPool < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
79+ TransactionPool < Block , RuntimeApi > ,
7580 (
76- ParachainBlockImport < RuntimeApi , Executor > ,
81+ ParachainBlockImport < RuntimeApi > ,
7782 Option < Telemetry > ,
7883 Option < TelemetryWorkerHandle > ,
7984 ) ,
@@ -113,26 +118,23 @@ impl sc_executor::NativeExecutionDispatch for PeregrineRuntimeExecutor {
113118///
114119/// Use this macro if you don't actually need the full service, but just the
115120/// builder in order to be able to perform chain operations.
116- pub ( crate ) fn new_partial < RuntimeApi , Executor , BIQ > (
121+ pub ( crate ) fn new_partial < RuntimeApi , BIQ > (
117122 config : & Configuration ,
118123 build_import_queue : BIQ ,
119- ) -> Result < PartialComponents < Block , RuntimeApi , Executor , Telemetry , TelemetryWorkerHandle > , sc_service:: Error >
124+ ) -> Result < PartialComponents < Block , RuntimeApi , Telemetry , TelemetryWorkerHandle > , sc_service:: Error >
120125where
121- RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > >
122- + Send
123- + Sync
124- + ' static ,
126+ RuntimeApi :
127+ ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > + Send + Sync + ' static ,
125128 RuntimeApi :: RuntimeApi : sp_transaction_pool:: runtime_api:: TaggedTransactionQueue < Block >
126129 + sp_api:: Metadata < Block >
127130 + sp_session:: SessionKeys < Block >
128131 + sp_api:: ApiExt < Block >
129132 + sp_offchain:: OffchainWorkerApi < Block >
130133 + sp_block_builder:: BlockBuilder < Block > ,
131134 sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > : sp_state_machine:: Backend < BlakeTwo256 > ,
132- Executor : NativeExecutionDispatch + ' static ,
133135 BIQ : FnOnce (
134- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
135- ParachainBlockImport < RuntimeApi , Executor > ,
136+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
137+ ParachainBlockImport < RuntimeApi > ,
136138 & Configuration ,
137139 Option < TelemetryHandle > ,
138140 & TaskManager ,
@@ -149,7 +151,14 @@ where
149151 } )
150152 . transpose ( ) ?;
151153
152- let executor = sc_service:: new_native_or_wasm_executor ( config) ;
154+ #[ allow( deprecated) ]
155+ let executor = ParachainExecutor :: new (
156+ config. wasm_method ,
157+ config. default_heap_pages ,
158+ config. max_runtime_instances ,
159+ None ,
160+ config. runtime_cache_size ,
161+ ) ;
153162
154163 let ( client, backend, keystore_container, task_manager) = sc_service:: new_full_parts :: < Block , RuntimeApi , _ > (
155164 config,
@@ -173,7 +182,7 @@ where
173182 Arc :: clone ( & client) ,
174183 ) ;
175184
176- let block_import = ParachainBlockImport :: < RuntimeApi , Executor > :: new ( Arc :: clone ( & client) , Arc :: clone ( & backend) ) ;
185+ let block_import = ParachainBlockImport :: < RuntimeApi > :: new ( Arc :: clone ( & client) , Arc :: clone ( & backend) ) ;
177186
178187 let import_queue = build_import_queue (
179188 Arc :: clone ( & client) ,
@@ -202,7 +211,7 @@ where
202211/// runtime api.
203212#[ allow( clippy:: too_many_arguments) ]
204213#[ sc_tracing:: logging:: prefix_logs_with( "Parachain" ) ]
205- async fn start_node_impl < RuntimeApi , Executor , RB , BIQ > (
214+ async fn start_node_impl < RuntimeApi , RB , BIQ > (
206215 parachain_config : Configuration ,
207216 polkadot_config : Configuration ,
208217 collator_options : CollatorOptions ,
@@ -212,13 +221,11 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ>(
212221 hwbench : Option < sc_sysinfo:: HwBench > ,
213222) -> sc_service:: error:: Result < (
214223 TaskManager ,
215- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
224+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
216225) >
217226where
218- RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > >
219- + Send
220- + Sync
221- + ' static ,
227+ RuntimeApi :
228+ ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > + Send + Sync + ' static ,
222229 RuntimeApi :: RuntimeApi : sp_transaction_pool:: runtime_api:: TaggedTransactionQueue < Block >
223230 + sp_api:: Metadata < Block >
224231 + sp_session:: SessionKeys < Block >
@@ -231,23 +238,22 @@ where
231238 + sp_consensus_aura:: AuraApi < Block , AuthorityId >
232239 + cumulus_primitives_aura:: AuraUnincludedSegmentApi < Block > ,
233240 sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > : sp_state_machine:: Backend < BlakeTwo256 > ,
234- Executor : sc_executor:: NativeExecutionDispatch + ' static ,
235241 RB : FnOnce (
236- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
242+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
237243 ) -> Result < RpcModule < ( ) > , sc_service:: Error >
238244 + Send
239245 + ' static ,
240246 BIQ : FnOnce (
241- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
242- ParachainBlockImport < RuntimeApi , Executor > ,
247+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
248+ ParachainBlockImport < RuntimeApi > ,
243249 & Configuration ,
244250 Option < TelemetryHandle > ,
245251 & TaskManager ,
246252 ) -> Result < sc_consensus:: DefaultImportQueue < Block > , sc_service:: Error > ,
247253{
248254 let parachain_config = prepare_node_config ( parachain_config) ;
249255
250- let params = new_partial :: < RuntimeApi , Executor , BIQ > ( & parachain_config, build_import_queue) ?;
256+ let params = new_partial :: < RuntimeApi , BIQ > ( & parachain_config, build_import_queue) ?;
251257 let ( block_import, mut telemetry, telemetry_worker_handle) = params. other ;
252258
253259 let client = Arc :: clone ( & params. client ) ;
@@ -357,7 +363,7 @@ where
357363 } ) ?;
358364
359365 if validator {
360- start_consensus :: < RuntimeApi , Executor > (
366+ start_consensus :: < RuntimeApi > (
361367 Arc :: clone ( & client) ,
362368 Arc :: clone ( & backend) ,
363369 block_import,
@@ -383,16 +389,15 @@ where
383389
384390#[ allow( clippy:: type_complexity) ]
385391/// Build the import queue for THE runtime.
386- pub ( crate ) fn build_import_queue < RE , API > (
387- client : Arc < TFullClient < Block , API , NativeElseWasmExecutor < RE > > > ,
388- block_import : ParachainBlockImport < API , RE > ,
392+ pub ( crate ) fn build_import_queue < API > (
393+ client : Arc < TFullClient < Block , API , WasmExecutor < HostFunctions > > > ,
394+ block_import : ParachainBlockImport < API > ,
389395 config : & Configuration ,
390396 telemetry : Option < TelemetryHandle > ,
391397 task_manager : & TaskManager ,
392398) -> Result < sc_consensus:: DefaultImportQueue < Block > , sc_service:: Error >
393399where
394- RE : sc_executor:: NativeExecutionDispatch + ' static ,
395- API : ConstructRuntimeApi < Block , TFullClient < Block , API , NativeElseWasmExecutor < RE > > > + Send + Sync + ' static ,
400+ API : ConstructRuntimeApi < Block , TFullClient < Block , API , WasmExecutor < HostFunctions > > > + Send + Sync + ' static ,
396401 API :: RuntimeApi : sp_transaction_pool:: runtime_api:: TaggedTransactionQueue < Block >
397402 + sp_api:: Metadata < Block >
398403 + sp_session:: SessionKeys < Block >
@@ -430,16 +435,15 @@ where
430435}
431436
432437/// Start a parachain node.
433- pub ( crate ) async fn start_node < RE , API > (
438+ pub ( crate ) async fn start_node < API > (
434439 parachain_config : Configuration ,
435440 polkadot_config : Configuration ,
436441 collator_options : CollatorOptions ,
437442 id : ParaId ,
438443 hwbench : Option < sc_sysinfo:: HwBench > ,
439- ) -> sc_service:: error:: Result < ( TaskManager , Arc < TFullClient < Block , API , NativeElseWasmExecutor < RE > > > ) >
444+ ) -> sc_service:: error:: Result < ( TaskManager , Arc < TFullClient < Block , API , WasmExecutor < HostFunctions > > > ) >
440445where
441- RE : sc_executor:: NativeExecutionDispatch + ' static ,
442- API : ConstructRuntimeApi < Block , TFullClient < Block , API , NativeElseWasmExecutor < RE > > > + Send + Sync + ' static ,
446+ API : ConstructRuntimeApi < Block , TFullClient < Block , API , WasmExecutor < HostFunctions > > > + Send + Sync + ' static ,
443447 API :: RuntimeApi : sp_transaction_pool:: runtime_api:: TaggedTransactionQueue < Block >
444448 + sp_api:: Metadata < Block >
445449 + sp_session:: SessionKeys < Block >
@@ -453,28 +457,28 @@ where
453457 + cumulus_primitives_aura:: AuraUnincludedSegmentApi < Block > ,
454458 sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > : sp_state_machine:: Backend < BlakeTwo256 > ,
455459{
456- start_node_impl :: < API , RE , _ , _ > (
460+ start_node_impl :: < API , _ , _ > (
457461 parachain_config,
458462 polkadot_config,
459463 collator_options,
460464 id,
461465 |_| Ok ( RpcModule :: new ( ( ) ) ) ,
462- build_import_queue :: < RE , API > ,
466+ build_import_queue :: < API > ,
463467 hwbench,
464468 )
465469 . await
466470}
467471
468472#[ allow( clippy:: too_many_arguments) ]
469- fn start_consensus < RuntimeApi , Executor > (
470- client : Arc < ParachainClient < RuntimeApi , Executor > > ,
473+ fn start_consensus < RuntimeApi > (
474+ client : Arc < ParachainClient < RuntimeApi > > ,
471475 backend : Arc < ParachainBackend > ,
472- block_import : ParachainBlockImport < RuntimeApi , Executor > ,
476+ block_import : ParachainBlockImport < RuntimeApi > ,
473477 prometheus_registry : Option < & Registry > ,
474478 telemetry : Option < TelemetryHandle > ,
475479 task_manager : & TaskManager ,
476480 relay_chain_interface : Arc < dyn RelayChainInterface > ,
477- transaction_pool : Arc < sc_transaction_pool:: FullPool < Block , ParachainClient < RuntimeApi , Executor > > > ,
481+ transaction_pool : Arc < sc_transaction_pool:: FullPool < Block , ParachainClient < RuntimeApi > > > ,
478482 sync_oracle : Arc < SyncingService < Block > > ,
479483 keystore : KeystorePtr ,
480484 relay_chain_slot_duration : Duration ,
@@ -484,10 +488,8 @@ fn start_consensus<RuntimeApi, Executor>(
484488 announce_block : Arc < dyn Fn ( Hash , Option < Vec < u8 > > ) + Send + Sync > ,
485489) -> Result < ( ) , sc_service:: Error >
486490where
487- RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > >
488- + Send
489- + Sync
490- + ' static ,
491+ RuntimeApi :
492+ ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > + Send + Sync + ' static ,
491493 RuntimeApi :: RuntimeApi : sp_transaction_pool:: runtime_api:: TaggedTransactionQueue < Block >
492494 + sp_api:: Metadata < Block >
493495 + sp_session:: SessionKeys < Block >
@@ -499,7 +501,6 @@ where
499501 + substrate_frame_rpc_system:: AccountNonceApi < Block , AccountId , Nonce >
500502 + sp_consensus_aura:: AuraApi < Block , AuthorityId >
501503 + cumulus_primitives_aura:: AuraUnincludedSegmentApi < Block > ,
502- Executor : sc_executor:: NativeExecutionDispatch + ' static ,
503504{
504505 use cumulus_client_consensus_aura:: collators:: lookahead:: { self as aura, Params as AuraParams } ;
505506
0 commit comments