@@ -6,9 +6,8 @@ use sc_client_api::{Backend, BlockBackend};
6
6
use sc_consensus_aura:: { ImportQueueParams , SlotProportion , StartAuraParams } ;
7
7
use sc_consensus_grandpa:: SharedVoterState ;
8
8
use 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 } ;
12
11
use sc_telemetry:: { Telemetry , TelemetryWorker } ;
13
12
use sc_transaction_pool_api:: OffchainTransactionPoolFactory ;
14
13
use sp_consensus_aura:: sr25519:: AuthorityPair as AuraPair ;
@@ -18,42 +17,8 @@ use std::{sync::Arc, time::Duration};
18
17
/// imported and generated.
19
18
const GRANDPA_JUSTIFICATION_PERIOD : u32 = 512 ;
20
19
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
-
55
20
pub ( crate ) type FullClient =
56
- sc_service:: TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < ExecutorDispatch > > ;
21
+ sc_service:: TFullClient < Block , RuntimeApi , WasmExecutor < sp_io :: SubstrateHostFunctions > > ;
57
22
type FullBackend = sc_service:: TFullBackend < Block > ;
58
23
type FullSelectChain = sc_consensus:: LongestChain < FullBackend , Block > ;
59
24
@@ -90,7 +55,7 @@ pub fn new_partial(
90
55
} )
91
56
. transpose ( ) ?;
92
57
93
- let executor = sc_service:: new_native_or_wasm_executor ( config) ;
58
+ let executor = sc_service:: new_wasm_executor :: < sp_io :: SubstrateHostFunctions > ( & config. executor ) ;
94
59
95
60
let ( client, backend, keystore_container, task_manager) =
96
61
sc_service:: new_full_parts :: < Block , RuntimeApi , _ > (
@@ -163,7 +128,11 @@ pub fn new_partial(
163
128
}
164
129
165
130
// 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 > {
167
136
let sc_service:: PartialComponents {
168
137
client,
169
138
backend,
@@ -175,7 +144,12 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
175
144
other : ( block_import, grandpa_link, mut telemetry) ,
176
145
} = new_partial ( & config) ?;
177
146
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 ( ) ) ;
179
153
180
154
let grandpa_protocol_name = sc_consensus_grandpa:: protocol_standard_name (
181
155
& client
@@ -186,8 +160,13 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
186
160
& config. chain_spec ,
187
161
) ;
188
162
163
+ let peer_store_handle = net_config. peer_store_handle ( ) ;
189
164
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
+ ) ;
191
170
net_config. add_notification_protocol ( grandpa_protocol_config) ;
192
171
193
172
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> {
205
184
spawn_handle : task_manager. spawn_handle ( ) ,
206
185
import_queue,
207
186
block_announce_validator_builder : None ,
208
- warp_sync_params : Some ( WarpSyncParams :: WithProvider ( warp_sync) ) ,
187
+ warp_sync_config : Some ( WarpSyncConfig :: WithProvider ( warp_sync) ) ,
209
188
block_relay : None ,
189
+ metrics,
210
190
} ) ?;
211
191
212
192
if config. offchain_worker . enabled {
@@ -221,7 +201,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
221
201
transaction_pool : Some ( OffchainTransactionPoolFactory :: new (
222
202
transaction_pool. clone ( ) ,
223
203
) ) ,
224
- network_provider : network. clone ( ) ,
204
+ network_provider : Arc :: new ( network. clone ( ) ) ,
225
205
enable_http_requests : true ,
226
206
custom_extensions : |_| vec ! [ ] ,
227
207
} )
@@ -239,7 +219,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
239
219
let shared_authority_set = grandpa_link. shared_authority_set ( ) . clone ( ) ;
240
220
let shared_voter_state = SharedVoterState :: empty ( ) ;
241
221
242
- let role = config. role . clone ( ) ;
222
+ let role = config. role ;
243
223
let force_authoring = config. force_authoring ;
244
224
let backoff_authoring_blocks = Some ( BackoffAuthoringOnFinalizedHeadLagging {
245
225
unfinalized_slack : 6 ,
@@ -254,11 +234,10 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
254
234
let pool = transaction_pool. clone ( ) ;
255
235
256
236
Box :: new (
257
- move |deny_unsafe , subscription_executor : sc_rpc:: SubscriptionTaskExecutor | {
237
+ move |subscription_executor : sc_rpc:: SubscriptionTaskExecutor | {
258
238
let deps = crate :: rpc:: FullDeps {
259
239
client : client. clone ( ) ,
260
240
pool : pool. clone ( ) ,
261
- deny_unsafe,
262
241
grandpa : crate :: rpc:: GrandpaDeps {
263
242
shared_voter_state : shared_voter_state. clone ( ) ,
264
243
shared_authority_set : shared_authority_set. clone ( ) ,
0 commit comments