@@ -6,9 +6,8 @@ use sc_client_api::{Backend, BlockBackend};
66use sc_consensus_aura:: { ImportQueueParams , SlotProportion , StartAuraParams } ;
77use sc_consensus_grandpa:: SharedVoterState ;
88use sc_consensus_slots:: BackoffAuthoringOnFinalizedHeadLagging ;
9- use sc_executor:: sp_wasm_interface:: { Function , HostFunctionRegistry , HostFunctions } ;
10- pub use sc_executor:: NativeElseWasmExecutor ;
11- use sc_service:: { error:: Error as ServiceError , Configuration , TaskManager , WarpSyncParams } ;
9+ pub use sc_executor:: WasmExecutor ;
10+ use sc_service:: { error:: Error as ServiceError , Configuration , TaskManager , WarpSyncConfig } ;
1211use sc_telemetry:: { Telemetry , TelemetryWorker } ;
1312use sc_transaction_pool_api:: OffchainTransactionPoolFactory ;
1413use sp_consensus_aura:: sr25519:: AuthorityPair as AuraPair ;
@@ -18,42 +17,8 @@ use std::{sync::Arc, time::Duration};
1817/// imported and generated.
1918const GRANDPA_JUSTIFICATION_PERIOD : u32 = 512 ;
2019
21- // Our native executor instance.
22- pub struct ExecutorDispatch ;
23-
24- // appeasing the compiler, this is a no-op
25- impl HostFunctions for ExecutorDispatch {
26- fn host_functions ( ) -> Vec < & ' static dyn Function > {
27- vec ! [ ]
28- }
29-
30- fn register_static < T > ( _registry : & mut T ) -> core:: result:: Result < ( ) , T :: Error >
31- where
32- T : HostFunctionRegistry ,
33- {
34- Ok ( ( ) )
35- }
36- }
37-
38- impl sc_executor:: NativeExecutionDispatch for ExecutorDispatch {
39- // Always enable runtime benchmark host functions, the genesis state
40- // was built with them so we're stuck with them forever.
41- //
42- // They're just a noop, never actually get used if the runtime was not compiled with
43- // `runtime-benchmarks`.
44- type ExtendHostFunctions = frame_benchmarking:: benchmarking:: HostFunctions ;
45-
46- fn dispatch ( method : & str , data : & [ u8 ] ) -> Option < Vec < u8 > > {
47- node_subtensor_runtime:: api:: dispatch ( method, data)
48- }
49-
50- fn native_version ( ) -> sc_executor:: NativeVersion {
51- node_subtensor_runtime:: native_version ( )
52- }
53- }
54-
5520pub ( crate ) type FullClient =
56- sc_service:: TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < ExecutorDispatch > > ;
21+ sc_service:: TFullClient < Block , RuntimeApi , WasmExecutor < sp_io :: SubstrateHostFunctions > > ;
5722type FullBackend = sc_service:: TFullBackend < Block > ;
5823type FullSelectChain = sc_consensus:: LongestChain < FullBackend , Block > ;
5924
@@ -90,7 +55,7 @@ pub fn new_partial(
9055 } )
9156 . transpose ( ) ?;
9257
93- let executor = sc_service:: new_native_or_wasm_executor ( config) ;
58+ let executor = sc_service:: new_wasm_executor :: < sp_io :: SubstrateHostFunctions > ( & config. executor ) ;
9459
9560 let ( client, backend, keystore_container, task_manager) =
9661 sc_service:: new_full_parts :: < Block , RuntimeApi , _ > (
@@ -163,7 +128,11 @@ pub fn new_partial(
163128}
164129
165130// Builds a new service for a full client.
166- pub fn new_full ( config : Configuration ) -> Result < TaskManager , ServiceError > {
131+ pub fn new_full <
132+ N : sc_network:: NetworkBackend < Block , <Block as sp_runtime:: traits:: Block >:: Hash > ,
133+ > (
134+ config : Configuration ,
135+ ) -> Result < TaskManager , ServiceError > {
167136 let sc_service:: PartialComponents {
168137 client,
169138 backend,
@@ -175,7 +144,12 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
175144 other : ( block_import, grandpa_link, mut telemetry) ,
176145 } = new_partial ( & config) ?;
177146
178- let mut net_config = sc_network:: config:: FullNetworkConfiguration :: new ( & config. network ) ;
147+ let mut net_config = sc_network:: config:: FullNetworkConfiguration :: <
148+ Block ,
149+ <Block as sp_runtime:: traits:: Block >:: Hash ,
150+ N ,
151+ > :: new ( & config. network , config. prometheus_registry ( ) . cloned ( ) ) ;
152+ let metrics = N :: register_notification_metrics ( config. prometheus_registry ( ) ) ;
179153
180154 let grandpa_protocol_name = sc_consensus_grandpa:: protocol_standard_name (
181155 & client
@@ -186,8 +160,13 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
186160 & config. chain_spec ,
187161 ) ;
188162
163+ let peer_store_handle = net_config. peer_store_handle ( ) ;
189164 let ( grandpa_protocol_config, grandpa_notification_service) =
190- sc_consensus_grandpa:: grandpa_peers_set_config ( grandpa_protocol_name. clone ( ) ) ;
165+ sc_consensus_grandpa:: grandpa_peers_set_config :: < _ , N > (
166+ grandpa_protocol_name. clone ( ) ,
167+ metrics. clone ( ) ,
168+ peer_store_handle,
169+ ) ;
191170 net_config. add_notification_protocol ( grandpa_protocol_config) ;
192171
193172 let warp_sync = Arc :: new ( sc_consensus_grandpa:: warp_proof:: NetworkProvider :: new (
@@ -205,8 +184,9 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
205184 spawn_handle : task_manager. spawn_handle ( ) ,
206185 import_queue,
207186 block_announce_validator_builder : None ,
208- warp_sync_params : Some ( WarpSyncParams :: WithProvider ( warp_sync) ) ,
187+ warp_sync_config : Some ( WarpSyncConfig :: WithProvider ( warp_sync) ) ,
209188 block_relay : None ,
189+ metrics,
210190 } ) ?;
211191
212192 if config. offchain_worker . enabled {
@@ -221,7 +201,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
221201 transaction_pool : Some ( OffchainTransactionPoolFactory :: new (
222202 transaction_pool. clone ( ) ,
223203 ) ) ,
224- network_provider : network. clone ( ) ,
204+ network_provider : Arc :: new ( network. clone ( ) ) ,
225205 enable_http_requests : true ,
226206 custom_extensions : |_| vec ! [ ] ,
227207 } )
@@ -239,7 +219,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
239219 let shared_authority_set = grandpa_link. shared_authority_set ( ) . clone ( ) ;
240220 let shared_voter_state = SharedVoterState :: empty ( ) ;
241221
242- let role = config. role . clone ( ) ;
222+ let role = config. role ;
243223 let force_authoring = config. force_authoring ;
244224 let backoff_authoring_blocks = Some ( BackoffAuthoringOnFinalizedHeadLagging {
245225 unfinalized_slack : 6 ,
@@ -254,11 +234,10 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
254234 let pool = transaction_pool. clone ( ) ;
255235
256236 Box :: new (
257- move |deny_unsafe , subscription_executor : sc_rpc:: SubscriptionTaskExecutor | {
237+ move |subscription_executor : sc_rpc:: SubscriptionTaskExecutor | {
258238 let deps = crate :: rpc:: FullDeps {
259239 client : client. clone ( ) ,
260240 pool : pool. clone ( ) ,
261- deny_unsafe,
262241 grandpa : crate :: rpc:: GrandpaDeps {
263242 shared_voter_state : shared_voter_state. clone ( ) ,
264243 shared_authority_set : shared_authority_set. clone ( ) ,
0 commit comments