1
1
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
2
2
3
3
use crate :: cli:: Sealing ;
4
- use crate :: client:: { FullBackend , FullClient , RuntimeApiCollection } ;
4
+ use crate :: client:: { FullBackend , FullClient } ;
5
5
use crate :: ethereum:: {
6
6
db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType , EthConfiguration ,
7
7
FrontierBackend , FrontierBlockImport , FrontierPartialComponents , StorageOverride ,
@@ -12,24 +12,20 @@ use sc_client_api::{Backend as BackendT, BlockBackend};
12
12
use sc_consensus:: { BasicQueue , BoxBlockImport } ;
13
13
use sc_consensus_grandpa:: BlockNumberOps ;
14
14
use sc_consensus_slots:: BackoffAuthoringOnFinalizedHeadLagging ;
15
- use sc_executor:: HostFunctions as HostFunctionsT ;
16
15
use sc_network_sync:: strategy:: warp:: { WarpSyncConfig , WarpSyncProvider } ;
17
16
use sc_service:: { error:: Error as ServiceError , Configuration , PartialComponents , TaskManager } ;
18
17
use sc_telemetry:: { log, Telemetry , TelemetryHandle , TelemetryWorker } ;
19
18
use sc_transaction_pool:: FullPool ;
20
19
use sc_transaction_pool_api:: OffchainTransactionPoolFactory ;
21
- use sp_api:: ConstructRuntimeApi ;
22
- use sp_consensus_aura:: sr25519:: { AuthorityId as AuraId , AuthorityPair as AuraPair } ;
23
- use sp_core:: { H256 , U256 } ;
20
+ use sp_consensus_aura:: sr25519:: AuthorityPair as AuraPair ;
21
+ use sp_core:: U256 ;
24
22
use sp_runtime:: traits:: { Block as BlockT , NumberFor } ;
25
23
use std:: { cell:: RefCell , path:: Path } ;
26
24
use std:: { sync:: Arc , time:: Duration } ;
27
25
use substrate_prometheus_endpoint:: Registry ;
28
26
29
27
// Runtime
30
- use node_subtensor_runtime:: {
31
- opaque:: Block , AccountId , Balance , Nonce , RuntimeApi , TransactionConverter ,
32
- } ;
28
+ use node_subtensor_runtime:: { opaque:: Block , RuntimeApi , TransactionConverter } ;
33
29
34
30
/// The minimum period of blocks on which justifications will be
35
31
/// imported and generated.
@@ -53,41 +49,41 @@ type GrandpaBlockImport<B, C> =
53
49
sc_consensus_grandpa:: GrandpaBlockImport < FullBackend < B > , B , C , FullSelectChain < B > > ;
54
50
type GrandpaLinkHalf < B , C > = sc_consensus_grandpa:: LinkHalf < B , C , FullSelectChain < B > > ;
55
51
56
- pub fn new_partial < B , RA , HF , BIQ > (
52
+ pub fn new_partial < BIQ > (
57
53
config : & Configuration ,
58
54
eth_config : & EthConfiguration ,
59
55
build_import_queue : BIQ ,
60
56
) -> Result <
61
57
PartialComponents <
62
- FullClient < B , RA , HF > ,
63
- FullBackend < B > ,
64
- FullSelectChain < B > ,
65
- BasicQueue < B > ,
66
- FullPool < B , FullClient < B , RA , HF > > ,
58
+ Client ,
59
+ FullBackend < Block > ,
60
+ FullSelectChain < Block > ,
61
+ BasicQueue < Block > ,
62
+ FullPool < Block , Client > ,
67
63
(
68
64
Option < Telemetry > ,
69
- BoxBlockImport < B > ,
70
- GrandpaLinkHalf < B , FullClient < B , RA , HF > > ,
71
- FrontierBackend < B , FullClient < B , RA , HF > > ,
72
- Arc < dyn StorageOverride < B > > ,
65
+ BoxBlockImport < Block > ,
66
+ GrandpaLinkHalf < Block , Client > ,
67
+ FrontierBackend < Block , Client > ,
68
+ Arc < dyn StorageOverride < Block > > ,
73
69
) ,
74
70
> ,
75
71
ServiceError ,
76
72
>
77
73
where
78
- B : BlockT < Hash = H256 > ,
79
- RA : ConstructRuntimeApi < B , FullClient < B , RA , HF > > ,
80
- RA : Send + Sync + ' static ,
81
- RA :: RuntimeApi : RuntimeApiCollection < B , AuraId , AccountId , Nonce , Balance > ,
82
- HF : HostFunctionsT + ' static ,
74
+ // B: BlockT<Hash = H256>,
75
+ // RA: ConstructRuntimeApi<Block, Client >,
76
+ // RA: Send + Sync + 'static,
77
+ // RA::RuntimeApi: RuntimeApiCollection<B, AuraId, AccountId, Nonce, Balance>,
78
+ // HF: HostFunctionsT + 'static,
83
79
BIQ : FnOnce (
84
- Arc < FullClient < B , RA , HF > > ,
80
+ Arc < Client > ,
85
81
& Configuration ,
86
82
& EthConfiguration ,
87
83
& TaskManager ,
88
84
Option < TelemetryHandle > ,
89
- GrandpaBlockImport < B , FullClient < B , RA , HF > > ,
90
- ) -> Result < ( BasicQueue < B > , BoxBlockImport < B > ) , ServiceError > ,
85
+ GrandpaBlockImport < Block , Client > ,
86
+ ) -> Result < ( BasicQueue < Block > , BoxBlockImport < Block > ) , ServiceError > ,
91
87
{
92
88
let telemetry = config
93
89
. telemetry_endpoints
@@ -100,12 +96,13 @@ where
100
96
} )
101
97
. transpose ( ) ?;
102
98
103
- let executor = sc_service:: new_wasm_executor :: < HostFunctions > ( & config. executor ) ;
104
- let ( client, backend, keystore_container, task_manager) = sc_service:: new_full_parts :: < B , RA , _ > (
105
- config,
106
- telemetry. as_ref ( ) . map ( |( _, telemetry) | telemetry. handle ( ) ) ,
107
- executor,
108
- ) ?;
99
+ let executor = sc_service:: new_wasm_executor ( & config. executor ) ;
100
+ let ( client, backend, keystore_container, task_manager) =
101
+ sc_service:: new_full_parts :: < Block , RuntimeApi , _ > (
102
+ config,
103
+ telemetry. as_ref ( ) . map ( |( _, telemetry) | telemetry. handle ( ) ) ,
104
+ executor,
105
+ ) ?;
109
106
let client = Arc :: new ( client) ;
110
107
111
108
let telemetry = telemetry. map ( |( worker, telemetry) | {
@@ -124,7 +121,7 @@ where
124
121
telemetry. as_ref ( ) . map ( |x| x. handle ( ) ) ,
125
122
) ?;
126
123
127
- let storage_override = Arc :: new ( StorageOverrideHandler :: < B , _ , _ > :: new ( client. clone ( ) ) ) ;
124
+ let storage_override = Arc :: new ( StorageOverrideHandler :: < _ , _ , _ > :: new ( client. clone ( ) ) ) ;
128
125
let frontier_backend = match eth_config. frontier_backend_type {
129
126
BackendType :: KeyValue => FrontierBackend :: KeyValue ( Arc :: new ( fc_db:: kv:: Backend :: open (
130
127
Arc :: clone ( & client) ,
@@ -190,21 +187,21 @@ where
190
187
}
191
188
192
189
/// Build the import queue for the template runtime (aura + grandpa).
193
- pub fn build_aura_grandpa_import_queue < B , RA , HF > (
194
- client : Arc < FullClient < B , RA , HF > > ,
190
+ pub fn build_aura_grandpa_import_queue (
191
+ client : Arc < Client > ,
195
192
config : & Configuration ,
196
193
eth_config : & EthConfiguration ,
197
194
task_manager : & TaskManager ,
198
195
telemetry : Option < TelemetryHandle > ,
199
- grandpa_block_import : GrandpaBlockImport < B , FullClient < B , RA , HF > > ,
200
- ) -> Result < ( BasicQueue < B > , BoxBlockImport < B > ) , ServiceError >
196
+ grandpa_block_import : GrandpaBlockImport < Block , Client > ,
197
+ ) -> Result < ( BasicQueue < Block > , BoxBlockImport < Block > ) , ServiceError >
201
198
where
202
- B : BlockT ,
203
- NumberFor < B > : BlockNumberOps ,
204
- RA : ConstructRuntimeApi < B , FullClient < B , RA , HF > > ,
205
- RA : Send + Sync + ' static ,
206
- RA :: RuntimeApi : RuntimeApiCollection < B , AuraId , AccountId , Nonce , Balance > ,
207
- HF : HostFunctionsT + ' static ,
199
+ // B: BlockT,
200
+ NumberFor < Block > : BlockNumberOps ,
201
+ // RA: ConstructRuntimeApi<B, FullClient<B, RA, HF>>,
202
+ // RA: Send + Sync + 'static,
203
+ // RA::RuntimeApi: RuntimeApiCollection<B, AuraId, AccountId, Nonce, Balance>,
204
+ // HF: HostFunctionsT + 'static,
208
205
{
209
206
let frontier_block_import =
210
207
FrontierBlockImport :: new ( grandpa_block_import. clone ( ) , client. clone ( ) ) ;
@@ -241,20 +238,20 @@ where
241
238
}
242
239
243
240
/// Build the import queue for the template runtime (manual seal).
244
- pub fn build_manual_seal_import_queue < B , RA , HF > (
245
- client : Arc < FullClient < B , RA , HF > > ,
241
+ pub fn build_manual_seal_import_queue (
242
+ client : Arc < Client > ,
246
243
config : & Configuration ,
247
244
_eth_config : & EthConfiguration ,
248
245
task_manager : & TaskManager ,
249
246
_telemetry : Option < TelemetryHandle > ,
250
- _grandpa_block_import : GrandpaBlockImport < B , FullClient < B , RA , HF > > ,
251
- ) -> Result < ( BasicQueue < B > , BoxBlockImport < B > ) , ServiceError >
252
- where
253
- B : BlockT ,
254
- RA : ConstructRuntimeApi < B , FullClient < B , RA , HF > > ,
255
- RA : Send + Sync + ' static ,
256
- RA :: RuntimeApi : RuntimeApiCollection < B , AuraId , AccountId , Nonce , Balance > ,
257
- HF : HostFunctionsT + ' static ,
247
+ _grandpa_block_import : GrandpaBlockImport < Block , Client > ,
248
+ ) -> Result < ( BasicQueue < Block > , BoxBlockImport < Block > ) , ServiceError >
249
+ // where
250
+ // B: BlockT,
251
+ // RA: ConstructRuntimeApi<B, FullClient<B, RA, HF>>,
252
+ // RA: Send + Sync + 'static,
253
+ // RA::RuntimeApi: RuntimeApiCollection<B, AuraId, AccountId, Nonce, Balance>,
254
+ // HF: HostFunctionsT + 'static,
258
255
{
259
256
let frontier_block_import = FrontierBlockImport :: new ( client. clone ( ) , client) ;
260
257
Ok ( (
@@ -268,25 +265,25 @@ where
268
265
}
269
266
270
267
/// Builds a new service for a full client.
271
- pub async fn new_full < B , RA , HF , NB > (
268
+ pub async fn new_full < NB > (
272
269
mut config : Configuration ,
273
270
eth_config : EthConfiguration ,
274
271
sealing : Option < Sealing > ,
275
272
) -> Result < TaskManager , ServiceError >
276
273
where
277
- B : BlockT < Hash = H256 > ,
278
- NumberFor < B > : BlockNumberOps ,
279
- <B as BlockT >:: Header : Unpin ,
280
- RA : ConstructRuntimeApi < B , FullClient < B , RA , HF > > ,
281
- RA : Send + Sync + ' static ,
282
- RA :: RuntimeApi : RuntimeApiCollection < B , AuraId , AccountId , Nonce , Balance > ,
283
- HF : HostFunctionsT + ' static ,
284
- NB : sc_network:: NetworkBackend < B , <B as sp_runtime :: traits :: Block >:: Hash > ,
274
+ // B: BlockT<Hash = H256>,
275
+ NumberFor < Block > : BlockNumberOps ,
276
+ // <B as BlockT>::Header: Unpin,
277
+ // RA: ConstructRuntimeApi<B, FullClient<B, RA, HF>>,
278
+ // RA: Send + Sync + 'static,
279
+ // RA::RuntimeApi: RuntimeApiCollection<B, AuraId, AccountId, Nonce, Balance>,
280
+ // HF: HostFunctionsT + 'static,
281
+ NB : sc_network:: NetworkBackend < Block , <Block as BlockT >:: Hash > ,
285
282
{
286
283
let build_import_queue = if sealing. is_some ( ) {
287
- build_manual_seal_import_queue :: < B , RA , HF >
284
+ build_manual_seal_import_queue
288
285
} else {
289
- build_aura_grandpa_import_queue :: < B , RA , HF >
286
+ build_aura_grandpa_import_queue
290
287
} ;
291
288
292
289
let PartialComponents {
@@ -315,9 +312,7 @@ where
315
312
let metrics = NB :: register_notification_metrics ( maybe_registry) ;
316
313
317
314
let grandpa_protocol_name = sc_consensus_grandpa:: protocol_standard_name (
318
- & client
319
- . block_hash ( 0u32 . into ( ) ) ?
320
- . expect ( "Genesis block exists; qed" ) ,
315
+ & client. block_hash ( 0u32 ) ?. expect ( "Genesis block exists; qed" ) ,
321
316
& config. chain_spec ,
322
317
) ;
323
318
@@ -332,7 +327,7 @@ where
332
327
None
333
328
} else {
334
329
net_config. add_notification_protocol ( grandpa_protocol_config) ;
335
- let warp_sync: Arc < dyn WarpSyncProvider < B > > =
330
+ let warp_sync: Arc < dyn WarpSyncProvider < Block > > =
336
331
Arc :: new ( sc_consensus_grandpa:: warp_proof:: NetworkProvider :: new (
337
332
backend. clone ( ) ,
338
333
grandpa_link. shared_authority_set ( ) . clone ( ) ,
@@ -378,10 +373,11 @@ where
378
373
379
374
let role = config. role ;
380
375
let force_authoring = config. force_authoring ;
381
- let backoff_authoring_blocks = Some ( BackoffAuthoringOnFinalizedHeadLagging :: < NumberFor < B > > {
382
- unfinalized_slack : 6u32 . into ( ) ,
383
- ..Default :: default ( )
384
- } ) ;
376
+ let backoff_authoring_blocks =
377
+ Some ( BackoffAuthoringOnFinalizedHeadLagging :: < NumberFor < Block > > {
378
+ unfinalized_slack : 6u32 ,
379
+ ..Default :: default ( )
380
+ } ) ;
385
381
let name = config. network . node_name . clone ( ) ;
386
382
let frontier_backend = Arc :: new ( frontier_backend) ;
387
383
let enable_grandpa = !config. disable_grandpa && sealing. is_none ( ) ;
@@ -395,7 +391,7 @@ where
395
391
// The MappingSyncWorker sends through the channel on block import and the subscription emits a notification to the subscriber on receiving a message through this channel.
396
392
// This way we avoid race conditions when using native substrate block import notification stream.
397
393
let pubsub_notification_sinks: fc_mapping_sync:: EthereumBlockNotificationSinks <
398
- fc_mapping_sync:: EthereumBlockNotification < B > ,
394
+ fc_mapping_sync:: EthereumBlockNotification < Block > ,
399
395
> = Default :: default ( ) ;
400
396
let pubsub_notification_sinks = Arc :: new ( pubsub_notification_sinks) ;
401
397
@@ -447,7 +443,7 @@ where
447
443
client : client. clone ( ) ,
448
444
pool : pool. clone ( ) ,
449
445
graph : pool. pool ( ) . clone ( ) ,
450
- converter : Some ( TransactionConverter :: < B > :: default ( ) ) ,
446
+ converter : Some ( TransactionConverter :: < Block > :: default ( ) ) ,
451
447
is_authority,
452
448
enable_dev_signer,
453
449
network : network. clone ( ) ,
@@ -640,16 +636,10 @@ pub async fn build_full(
640
636
) -> Result < TaskManager , ServiceError > {
641
637
match config. network . network_backend {
642
638
sc_network:: config:: NetworkBackendType :: Libp2p => {
643
- new_full :: < Block , RuntimeApi , HostFunctions , sc_network:: NetworkWorker < _ , _ > > (
644
- config, eth_config, sealing,
645
- )
646
- . await
639
+ new_full :: < sc_network:: NetworkWorker < _ , _ > > ( config, eth_config, sealing) . await
647
640
}
648
641
sc_network:: config:: NetworkBackendType :: Litep2p => {
649
- new_full :: < Block , RuntimeApi , HostFunctions , sc_network:: Litep2pNetworkBackend > (
650
- config, eth_config, sealing,
651
- )
652
- . await
642
+ new_full :: < sc_network:: NetworkWorker < _ , _ > > ( config, eth_config, sealing) . await
653
643
}
654
644
}
655
645
}
@@ -675,35 +665,31 @@ pub fn new_chain_ops(
675
665
task_manager,
676
666
other,
677
667
..
678
- } = new_partial :: < Block , RuntimeApi , HostFunctions , _ > (
679
- config,
680
- eth_config,
681
- build_aura_grandpa_import_queue,
682
- ) ?;
668
+ } = new_partial ( config, eth_config, build_aura_grandpa_import_queue) ?;
683
669
Ok ( ( client, backend, import_queue, task_manager, other. 3 ) )
684
670
}
685
671
686
672
#[ allow( clippy:: too_many_arguments) ]
687
- fn run_manual_seal_authorship < B , RA , HF > (
673
+ fn run_manual_seal_authorship (
688
674
eth_config : & EthConfiguration ,
689
675
sealing : Sealing ,
690
- client : Arc < FullClient < B , RA , HF > > ,
691
- transaction_pool : Arc < FullPool < B , FullClient < B , RA , HF > > > ,
692
- select_chain : FullSelectChain < B > ,
693
- block_import : BoxBlockImport < B > ,
676
+ client : Arc < Client > ,
677
+ transaction_pool : Arc < FullPool < Block , Client > > ,
678
+ select_chain : FullSelectChain < Block > ,
679
+ block_import : BoxBlockImport < Block > ,
694
680
task_manager : & TaskManager ,
695
681
prometheus_registry : Option < & Registry > ,
696
682
telemetry : Option < & Telemetry > ,
697
683
commands_stream : mpsc:: Receiver <
698
- sc_consensus_manual_seal:: rpc:: EngineCommand < <B as BlockT >:: Hash > ,
684
+ sc_consensus_manual_seal:: rpc:: EngineCommand < <Block as BlockT >:: Hash > ,
699
685
> ,
700
686
) -> Result < ( ) , ServiceError >
701
- where
702
- B : BlockT ,
703
- RA : ConstructRuntimeApi < B , FullClient < B , RA , HF > > ,
704
- RA : Send + Sync + ' static ,
705
- RA :: RuntimeApi : RuntimeApiCollection < B , AuraId , AccountId , Nonce , Balance > ,
706
- HF : HostFunctionsT + ' static ,
687
+ // where
688
+ // B: BlockT,
689
+ // RA: ConstructRuntimeApi<B, FullClient<B, RA, HF>>,
690
+ // RA: Send + Sync + 'static,
691
+ // RA::RuntimeApi: RuntimeApiCollection<B, AuraId, AccountId, Nonce, Balance>,
692
+ // HF: HostFunctionsT + 'static,
707
693
{
708
694
let proposer_factory = sc_basic_authorship:: ProposerFactory :: new (
709
695
task_manager. spawn_handle ( ) ,
0 commit comments