@@ -28,7 +28,7 @@ use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
2828use polkadot_service:: CollatorPair ;
2929
3030pub use parachains_common:: { AccountId , Balance , Block , Hash , Header , Index as Nonce } ;
31- use sc_executor:: NativeElseWasmExecutor ;
31+ use sc_executor:: WasmExecutor ;
3232
3333use sc_network:: NetworkService ;
3434use sc_service:: {
@@ -51,6 +51,13 @@ pub mod thala;
5151#[ cfg( feature = "shell-native" ) ]
5252pub mod shell;
5353
54+ #[ cfg( not( feature = "runtime-benchmarks" ) ) ]
55+ type HostFunctions = sp_io:: SubstrateHostFunctions ;
56+
57+ #[ cfg( feature = "runtime-benchmarks" ) ]
58+ type HostFunctions =
59+ ( sp_io:: SubstrateHostFunctions , frame_benchmarking:: benchmarking:: HostFunctions ) ;
60+
5461async fn build_relay_chain_interface (
5562 polkadot_config : Configuration ,
5663 parachain_config : & Configuration ,
@@ -75,28 +82,28 @@ async fn build_relay_chain_interface(
7582/// Use this macro if you don't actually need the full service, but just the builder in order to
7683/// be able to perform chain operations.
7784#[ allow( clippy:: type_complexity) ]
78- pub fn new_partial < RuntimeApi , Executor , BIQ > (
85+ pub fn new_partial < RuntimeApi , BIQ > (
7986 config : & Configuration ,
8087 build_import_queue : BIQ ,
8188) -> Result <
8289 PartialComponents <
83- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
90+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
8491 TFullBackend < Block > ,
8592 ( ) ,
8693 sc_consensus:: DefaultImportQueue <
8794 Block ,
88- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
95+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
8996 > ,
9097 sc_transaction_pool:: FullPool <
9198 Block ,
92- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
99+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
93100 > ,
94101 ( Option < Telemetry > , Option < TelemetryWorkerHandle > ) ,
95102 > ,
96103 sc_service:: Error ,
97104>
98105 where
99- RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > >
106+ RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > >
100107 + Send
101108 + Sync
102109 + ' static ,
@@ -109,16 +116,15 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
109116 > + sp_offchain:: OffchainWorkerApi < Block >
110117 + sp_block_builder:: BlockBuilder < Block > ,
111118 sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > : sp_api:: StateBackend < BlakeTwo256 > ,
112- Executor : sc_executor:: NativeExecutionDispatch + ' static ,
113119 BIQ : FnOnce (
114- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
120+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
115121 & Configuration ,
116122 Option < TelemetryHandle > ,
117123 & TaskManager ,
118124 ) -> Result <
119125 sc_consensus:: DefaultImportQueue <
120126 Block ,
121- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
127+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
122128 > ,
123129 sc_service:: Error ,
124130 > ,
@@ -134,16 +140,17 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
134140 } )
135141 . transpose ( ) ?;
136142
137- let executor = sc_executor:: NativeElseWasmExecutor :: < Executor > :: new (
143+ let executor = sc_executor:: WasmExecutor :: < HostFunctions > :: new (
138144 config. wasm_method ,
139145 config. default_heap_pages ,
140146 config. max_runtime_instances ,
147+ None ,
141148 config. runtime_cache_size ,
142149 ) ;
143150
144151 let ( client, backend, keystore_container, task_manager) =
145152 sc_service:: new_full_parts :: < Block , RuntimeApi , _ > (
146- config,
153+ & config,
147154 telemetry. as_ref ( ) . map ( |( _, telemetry) | telemetry. handle ( ) ) ,
148155 executor,
149156 ) ?;
@@ -189,7 +196,7 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
189196///
190197/// This is the actual implementation that is abstract over the executor and the runtime api.
191198#[ sc_tracing:: logging:: prefix_logs_with( "Parachain" ) ]
192- async fn start_node_impl < RuntimeApi , Executor , RB , BIQ , BIC > (
199+ async fn start_node_impl < RuntimeApi , RB , BIQ , BIC > (
193200 parachain_config : Configuration ,
194201 polkadot_config : Configuration ,
195202 collator_options : CollatorOptions ,
@@ -199,10 +206,10 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
199206 build_consensus : BIC ,
200207) -> sc_service:: error:: Result < (
201208 TaskManager ,
202- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
209+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
203210) >
204211 where
205- RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > >
212+ RuntimeApi : ConstructRuntimeApi < Block , TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > >
206213 + Send
207214 + Sync
208215 + ' static ,
@@ -219,34 +226,33 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
219226 + substrate_frame_rpc_system:: AccountNonceApi < Block , AccountId , Nonce >
220227 + pallet_mq_runtime_api:: MqApi < Block > ,
221228 sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > : sp_api:: StateBackend < BlakeTwo256 > ,
222- Executor : sc_executor:: NativeExecutionDispatch + ' static ,
223229 RB : Fn (
224- Arc < TFullClient < Block , RuntimeApi , Executor > > ,
230+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
225231 ) -> Result < jsonrpc_core:: IoHandler < sc_rpc:: Metadata > , sc_service:: Error >
226232 + Send
227233 + ' static ,
228234 BIQ : FnOnce (
229- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
235+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
230236 & Configuration ,
231237 Option < TelemetryHandle > ,
232238 & TaskManager ,
233239 ) -> Result <
234240 sc_consensus:: DefaultImportQueue <
235241 Block ,
236- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
242+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
237243 > ,
238244 sc_service:: Error ,
239245 > + ' static ,
240246 BIC : FnOnce (
241- Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
247+ Arc < TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > > ,
242248 Option < & Registry > ,
243249 Option < TelemetryHandle > ,
244250 & TaskManager ,
245251 Arc < dyn RelayChainInterface > ,
246252 Arc <
247253 sc_transaction_pool:: FullPool <
248254 Block ,
249- TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > ,
255+ TFullClient < Block , RuntimeApi , WasmExecutor < HostFunctions > > ,
250256 > ,
251257 > ,
252258 Arc < NetworkService < Block , Hash > > ,
@@ -260,7 +266,7 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
260266
261267 let parachain_config = prepare_node_config ( parachain_config) ;
262268
263- let params = new_partial :: < RuntimeApi , Executor , BIQ > ( & parachain_config, build_import_queue) ?;
269+ let params = new_partial :: < RuntimeApi , BIQ > ( & parachain_config, build_import_queue) ?;
264270 let ( mut telemetry, telemetry_worker_handle) = params. other ;
265271
266272 let client = params. client . clone ( ) ;
@@ -274,11 +280,11 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
274280 & mut task_manager,
275281 collator_options. clone ( ) ,
276282 )
277- . await
278- . map_err ( |e| match e {
279- RelayChainError :: ServiceError ( polkadot_service:: Error :: Sub ( x) ) => x,
280- s => s. to_string ( ) . into ( ) ,
281- } ) ?;
283+ . await
284+ . map_err ( |e| match e {
285+ RelayChainError :: ServiceError ( polkadot_service:: Error :: Sub ( x) ) => x,
286+ s => s. to_string ( ) . into ( ) ,
287+ } ) ?;
282288
283289 let block_announce_validator = BlockAnnounceValidator :: new ( relay_chain_interface. clone ( ) , id) ;
284290
@@ -363,7 +369,7 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
363369 announce_block,
364370 client : client. clone ( ) ,
365371 task_manager : & mut task_manager,
366- relay_chain_interface,
372+ relay_chain_interface : relay_chain_interface . clone ( ) ,
367373 spawner,
368374 parachain_consensus,
369375 import_queue,
0 commit comments