@@ -43,10 +43,9 @@ use futures::FutureExt;
43
43
// darwinia
44
44
use dc_primitives:: * ;
45
45
// substrate
46
- use sc_client_api:: { Backend , HeaderBackend } ;
46
+ use sc_client_api:: Backend ;
47
47
use sc_consensus:: ImportQueue ;
48
48
use sc_network:: NetworkBlock ;
49
- use sp_core:: Encode ;
50
49
51
50
/// Full client backend type.
52
51
type FullBackend = sc_service:: TFullBackend < Block > ;
@@ -95,8 +94,7 @@ impl IdentifyVariant for Box<dyn sc_service::ChainSpec> {
95
94
96
95
/// A set of APIs that darwinia-like runtimes must implement.
97
96
pub trait RuntimeApiCollection :
98
- cumulus_primitives_aura:: AuraUnincludedSegmentApi < Block >
99
- + cumulus_primitives_core:: CollectCollationInfo < Block >
97
+ cumulus_primitives_core:: CollectCollationInfo < Block >
100
98
+ fp_rpc:: ConvertTransactionRuntimeApi < Block >
101
99
+ fp_rpc:: EthereumRuntimeRPCApi < Block >
102
100
+ moonbeam_rpc_primitives_debug:: DebugRuntimeApi < Block >
@@ -112,8 +110,7 @@ pub trait RuntimeApiCollection:
112
110
{
113
111
}
114
112
impl < Api > RuntimeApiCollection for Api where
115
- Api : cumulus_primitives_aura:: AuraUnincludedSegmentApi < Block >
116
- + cumulus_primitives_core:: CollectCollationInfo < Block >
113
+ Api : cumulus_primitives_core:: CollectCollationInfo < Block >
117
114
+ fp_rpc:: ConvertTransactionRuntimeApi < Block >
118
115
+ fp_rpc:: EthereumRuntimeRPCApi < Block >
119
116
+ moonbeam_rpc_primitives_debug:: DebugRuntimeApi < Block >
@@ -264,7 +261,6 @@ where
264
261
Executor : ' static + sc_executor:: NativeExecutionDispatch ,
265
262
SC : FnOnce (
266
263
Arc < FullClient < RuntimeApi , Executor > > ,
267
- Arc < FullBackend > ,
268
264
ParachainBlockImport < RuntimeApi , Executor > ,
269
265
Option < & substrate_prometheus_endpoint:: Registry > ,
270
266
Option < sc_telemetry:: TelemetryHandle > ,
@@ -300,6 +296,7 @@ where
300
296
telemetry_worker_handle,
301
297
) ,
302
298
} = new_partial :: < RuntimeApi , Executor > ( & parachain_config, eth_rpc_config) ?;
299
+
303
300
let ( relay_chain_interface, collator_key) =
304
301
cumulus_client_service:: build_relay_chain_interface (
305
302
polkadot_config,
@@ -311,10 +308,12 @@ where
311
308
)
312
309
. await
313
310
. map_err ( |e| sc_service:: Error :: Application ( Box :: new ( e) as Box < _ > ) ) ?;
311
+
314
312
let validator = parachain_config. role . is_authority ( ) ;
315
313
let prometheus_registry = parachain_config. prometheus_registry ( ) . cloned ( ) ;
316
314
let import_queue_service = import_queue. service ( ) ;
317
315
let net_config = sc_network:: config:: FullNetworkConfiguration :: new ( & parachain_config. network ) ;
316
+
318
317
let ( network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
319
318
cumulus_client_service:: build_network ( cumulus_client_service:: BuildNetworkParams {
320
319
parachain_config : & parachain_config,
@@ -522,7 +521,6 @@ where
522
521
if validator {
523
522
start_consensus (
524
523
client. clone ( ) ,
525
- backend. clone ( ) ,
526
524
block_import,
527
525
prometheus_registry. as_ref ( ) ,
528
526
telemetry. as_ref ( ) . map ( |t| t. handle ( ) ) ,
@@ -616,7 +614,6 @@ where
616
614
cumulus_client_service:: CollatorSybilResistance :: Resistant , // Aura
617
615
para_id,
618
616
|client,
619
- backend,
620
617
block_import,
621
618
prometheus_registry,
622
619
telemetry,
@@ -645,17 +642,11 @@ where
645
642
announce_block,
646
643
client. clone ( ) ,
647
644
) ;
648
- let params = cumulus_client_consensus_aura:: collators:: lookahead :: Params {
645
+ let params = cumulus_client_consensus_aura:: collators:: basic :: Params {
649
646
create_inherent_data_providers : move |_, ( ) | async move { Ok ( ( ) ) } ,
650
647
block_import,
651
- para_client : client. clone ( ) ,
652
- para_backend : backend. clone ( ) ,
648
+ para_client : client,
653
649
relay_client : relay_chain_interface,
654
- code_hash_provider : move |block_hash| {
655
- client. code_at ( block_hash) . ok ( ) . map ( |c| {
656
- cumulus_primitives_core:: relay_chain:: ValidationCode :: from ( c) . hash ( )
657
- } )
658
- } ,
659
650
sync_oracle,
660
651
keystore,
661
652
collator_key,
@@ -666,9 +657,9 @@ where
666
657
proposer,
667
658
collator_service,
668
659
// Very limited proposal time.
669
- authoring_duration : Duration :: from_millis ( 1_500 ) ,
660
+ authoring_duration : Duration :: from_millis ( 500 ) ,
670
661
} ;
671
- let fut = cumulus_client_consensus_aura:: collators:: lookahead :: run :: <
662
+ let fut = cumulus_client_consensus_aura:: collators:: basic :: run :: <
672
663
Block ,
673
664
sp_consensus_aura:: sr25519:: AuthorityPair ,
674
665
_ ,
@@ -678,8 +669,6 @@ where
678
669
_ ,
679
670
_ ,
680
671
_ ,
681
- _ ,
682
- _ ,
683
672
> ( params) ;
684
673
685
674
task_manager. spawn_essential_handle ( ) . spawn ( "aura" , None , fut) ;
@@ -696,19 +685,21 @@ where
696
685
/// !!! WARNING: DO NOT USE ELSEWHERE
697
686
pub fn start_dev_node < RuntimeApi , Executor > (
698
687
mut config : sc_service:: Configuration ,
699
- para_id : cumulus_primitives_core:: ParaId ,
700
688
eth_rpc_config : & crate :: cli:: EthRpcConfig ,
701
689
) -> Result < sc_service:: TaskManager , sc_service:: error:: Error >
702
690
where
703
- RuntimeApi : ' static
691
+ RuntimeApi : sp_api :: ConstructRuntimeApi < Block , FullClient < RuntimeApi , Executor > >
704
692
+ Send
705
693
+ Sync
706
- + sp_api :: ConstructRuntimeApi < Block , FullClient < RuntimeApi , Executor > > ,
694
+ + ' static ,
707
695
RuntimeApi :: RuntimeApi : RuntimeApiCollection ,
708
696
RuntimeApi :: RuntimeApi :
709
697
sp_consensus_aura:: AuraApi < Block , sp_consensus_aura:: sr25519:: AuthorityId > ,
710
698
Executor : ' static + sc_executor:: NativeExecutionDispatch ,
711
699
{
700
+ // substrate
701
+ use sc_client_api:: HeaderBackend ;
702
+
712
703
let sc_service:: PartialComponents {
713
704
client,
714
705
backend,
@@ -729,6 +720,7 @@ where
729
720
) ,
730
721
} = new_partial :: < RuntimeApi , Executor > ( & config, eth_rpc_config) ?;
731
722
let net_config = sc_network:: config:: FullNetworkConfiguration :: new ( & config. network ) ;
723
+
732
724
let ( network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
733
725
sc_service:: build_network ( sc_service:: BuildNetworkParams {
734
726
config : & config,
@@ -765,17 +757,17 @@ where
765
757
}
766
758
767
759
let force_authoring = config. force_authoring ;
768
- let backoff_authoring_blocks = <Option < ( ) > >:: None ;
769
- let slot_duration = sc_consensus_aura:: slot_duration ( & * client) ?;
760
+ let backoff_authoring_blocks: Option < ( ) > = None ;
770
761
let proposer_factory = sc_basic_authorship:: ProposerFactory :: new (
771
762
task_manager. spawn_handle ( ) ,
772
763
client. clone ( ) ,
773
764
transaction_pool. clone ( ) ,
774
765
None ,
775
766
None ,
776
767
) ;
777
- let client_for_cidp = client. clone ( ) ;
778
768
769
+ let slot_duration = sc_consensus_aura:: slot_duration ( & * client) ?;
770
+ let client_for_cidp = client. clone ( ) ;
779
771
if config. role . is_authority ( ) {
780
772
let aura = sc_consensus_aura:: start_aura :: <
781
773
sp_consensus_aura:: sr25519:: AuthorityPair ,
@@ -790,54 +782,41 @@ where
790
782
_ ,
791
783
_ ,
792
784
> ( sc_consensus_aura:: StartAuraParams {
793
- slot_duration,
785
+ slot_duration : sc_consensus_aura :: slot_duration ( & * client ) ? ,
794
786
client : client. clone ( ) ,
795
787
select_chain,
796
788
block_import : instant_finalize:: InstantFinalizeBlockImport :: new ( client. clone ( ) ) ,
797
789
proposer_factory,
798
790
create_inherent_data_providers : move |block : Hash , ( ) | {
799
- let maybe_current_para_block = client_for_cidp. number ( block) ;
800
- let maybe_current_block_head = client_for_cidp. expect_header ( block) ;
791
+ let current_para_block = client_for_cidp
792
+ . number ( block)
793
+ . expect ( "Header lookup should succeed" )
794
+ . expect ( "Header passed in as parent should be present in backend." ) ;
801
795
let client_for_xcm = client_for_cidp. clone ( ) ;
802
- // TODO: hack for now.
803
- let additional_key_values = Some ( vec ! [ (
804
- array_bytes:: hex2bytes_unchecked(
805
- "1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed" ,
806
- ) ,
807
- cumulus_primitives_aura:: Slot :: from_timestamp(
808
- sp_timestamp:: Timestamp :: current( ) ,
809
- slot_duration,
810
- )
811
- . encode( ) ,
812
- ) ] ) ;
813
796
814
797
async move {
815
- let current_para_block = maybe_current_para_block?
816
- . ok_or ( sp_blockchain:: Error :: UnknownBlock ( block. to_string ( ) ) ) ?;
817
- let current_para_block_head =
818
- Some ( polkadot_primitives:: HeadData ( maybe_current_block_head?. encode ( ) ) ) ;
819
798
let timestamp = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
799
+
820
800
let slot = sp_consensus_aura:: inherents:: InherentDataProvider :: from_timestamp_and_slot_duration (
821
801
* timestamp,
822
802
slot_duration,
823
803
) ;
804
+
824
805
let mocked_parachain =
825
806
cumulus_primitives_parachain_inherent:: MockValidationDataInherentDataProvider {
826
807
current_para_block,
827
- current_para_block_head,
828
808
relay_offset : 1000 ,
829
809
relay_blocks_per_para_block : 2 ,
830
810
para_blocks_per_relay_epoch : 0 ,
831
811
relay_randomness_config : ( ) ,
832
812
xcm_config : cumulus_primitives_parachain_inherent:: MockXcmConfig :: new (
833
813
& * client_for_xcm,
834
814
block,
835
- para_id ,
815
+ Default :: default ( ) ,
836
816
Default :: default ( ) ,
837
817
) ,
838
818
raw_downward_messages : Vec :: new ( ) ,
839
819
raw_horizontal_messages : Vec :: new ( ) ,
840
- additional_key_values,
841
820
} ;
842
821
843
822
Ok ( ( slot, timestamp, mocked_parachain) )
@@ -908,6 +887,8 @@ where
908
887
let collator = config. role . is_authority ( ) ;
909
888
let eth_rpc_config = eth_rpc_config. clone ( ) ;
910
889
let sync_service = sync_service. clone ( ) ;
890
+
891
+ let slot_duration = sc_consensus_aura:: slot_duration ( & * client) ?;
911
892
let pending_create_inherent_data_providers = move |_, ( ) | async move {
912
893
let current = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
913
894
let next_slot = current. timestamp ( ) . as_millis ( ) + slot_duration. as_millis ( ) ;
0 commit comments