@@ -498,43 +498,26 @@ pub async fn start_shell_node<Net: NetworkBackend<Block, Hash>>(
498498 . await
499499}
500500
501- enum BuildOnAccess < R > {
502- Uninitialized ( Option < Box < dyn FnOnce ( ) -> R + Send + Sync > > ) ,
503- Initialized ( R ) ,
504- }
505-
506- impl < R > BuildOnAccess < R > {
507- fn get_mut ( & mut self ) -> & mut R {
508- loop {
509- match self {
510- Self :: Uninitialized ( f) => {
511- * self = Self :: Initialized ( ( f. take ( ) . unwrap ( ) ) ( ) ) ;
512- } ,
513- Self :: Initialized ( ref mut r) => return r,
514- }
515- }
516- }
517- }
518-
519501struct Verifier < Client , AuraId > {
520502 client : Arc < Client > ,
521- aura_verifier : BuildOnAccess < Box < dyn VerifierT < Block > > > ,
503+ aura_verifier : Box < dyn VerifierT < Block > > ,
522504 relay_chain_verifier : Box < dyn VerifierT < Block > > ,
523505 _phantom : PhantomData < AuraId > ,
524506}
525507
526508#[ async_trait:: async_trait]
527- impl < Client , AuraId : AuraIdT > VerifierT < Block > for Verifier < Client , AuraId >
509+ impl < Client , AuraId > VerifierT < Block > for Verifier < Client , AuraId >
528510where
529- Client : sp_api :: ProvideRuntimeApi < Block > + Send + Sync ,
511+ Client : ProvideRuntimeApi < Block > + Send + Sync ,
530512 Client :: Api : AuraRuntimeApi < Block , AuraId > ,
513+ AuraId : AuraIdT + Sync ,
531514{
532515 async fn verify (
533- & mut self ,
516+ & self ,
534517 block_import : BlockImportParams < Block > ,
535518 ) -> Result < BlockImportParams < Block > , String > {
536519 if self . client . runtime_api ( ) . has_aura_api ( * block_import. header . parent_hash ( ) ) {
537- self . aura_verifier . get_mut ( ) . verify ( block_import) . await
520+ self . aura_verifier . verify ( block_import) . await
538521 } else {
539522 self . relay_chain_verifier . verify ( block_import) . await
540523 }
@@ -543,7 +526,7 @@ where
543526
544527/// Build the import queue for parachain runtimes that started with relay chain consensus and
545528/// switched to aura.
546- pub fn build_relay_to_aura_import_queue < RuntimeApi , AuraId : AuraIdT > (
529+ pub fn build_relay_to_aura_import_queue < RuntimeApi , AuraId > (
547530 client : Arc < ParachainClient < RuntimeApi > > ,
548531 block_import : ParachainBlockImport < RuntimeApi > ,
549532 config : & Configuration ,
@@ -553,46 +536,43 @@ pub fn build_relay_to_aura_import_queue<RuntimeApi, AuraId: AuraIdT>(
553536where
554537 RuntimeApi : ConstructNodeRuntimeApi < Block , ParachainClient < RuntimeApi > > ,
555538 RuntimeApi :: RuntimeApi : AuraRuntimeApi < Block , AuraId > ,
539+ AuraId : AuraIdT + Sync ,
556540{
557541 let verifier_client = client. clone ( ) ;
558542
559- let aura_verifier = move || {
560- Box :: new ( cumulus_client_consensus_aura:: build_verifier :: <
561- <AuraId as AppCrypto >:: Pair ,
562- _ ,
563- _ ,
564- _ ,
565- > ( cumulus_client_consensus_aura:: BuildVerifierParams {
566- client : verifier_client. clone ( ) ,
567- create_inherent_data_providers : move |parent_hash, _| {
568- let cidp_client = verifier_client. clone ( ) ;
569- async move {
570- let slot_duration = cumulus_client_consensus_aura:: slot_duration_at (
571- & * cidp_client,
572- parent_hash,
573- ) ?;
574- let timestamp = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
575-
576- let slot =
577- sp_consensus_aura:: inherents:: InherentDataProvider :: from_timestamp_and_slot_duration (
578- * timestamp,
579- slot_duration,
580- ) ;
581-
582- Ok ( ( slot, timestamp) )
583- }
584- } ,
585- telemetry : telemetry_handle,
586- } ) ) as Box < _ >
587- } ;
543+ let aura_verifier = cumulus_client_consensus_aura:: build_verifier :: <
544+ <AuraId as AppCrypto >:: Pair ,
545+ _ ,
546+ _ ,
547+ _ ,
548+ > ( cumulus_client_consensus_aura:: BuildVerifierParams {
549+ client : verifier_client. clone ( ) ,
550+ create_inherent_data_providers : move |parent_hash, _| {
551+ let cidp_client = verifier_client. clone ( ) ;
552+ async move {
553+ let slot_duration =
554+ cumulus_client_consensus_aura:: slot_duration_at ( & * cidp_client, parent_hash) ?;
555+ let timestamp = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
556+
557+ let slot =
558+ sp_consensus_aura:: inherents:: InherentDataProvider :: from_timestamp_and_slot_duration (
559+ * timestamp,
560+ slot_duration,
561+ ) ;
562+
563+ Ok ( ( slot, timestamp) )
564+ }
565+ } ,
566+ telemetry : telemetry_handle,
567+ } ) ;
588568
589569 let relay_chain_verifier =
590570 Box :: new ( RelayChainVerifier :: new ( client. clone ( ) , |_, _| async { Ok ( ( ) ) } ) ) as Box < _ > ;
591571
592572 let verifier = Verifier {
593573 client,
594574 relay_chain_verifier,
595- aura_verifier : BuildOnAccess :: Uninitialized ( Some ( Box :: new ( aura_verifier) ) ) ,
575+ aura_verifier : Box :: new ( aura_verifier) ,
596576 _phantom : PhantomData ,
597577 } ;
598578
@@ -632,7 +612,7 @@ pub async fn start_generic_aura_lookahead_node<Net: NetworkBackend<Block, Hash>>
632612///
633613/// Uses the lookahead collator to support async backing.
634614#[ sc_tracing:: logging:: prefix_logs_with( "Parachain" ) ]
635- pub async fn start_asset_hub_lookahead_node < RuntimeApi , AuraId : AuraIdT , Net > (
615+ pub async fn start_asset_hub_lookahead_node < RuntimeApi , AuraId , Net > (
636616 parachain_config : Configuration ,
637617 polkadot_config : Configuration ,
638618 collator_options : CollatorOptions ,
@@ -644,6 +624,7 @@ where
644624 RuntimeApi :: RuntimeApi : AuraRuntimeApi < Block , AuraId >
645625 + pallet_transaction_payment_rpc:: TransactionPaymentRuntimeApi < Block , Balance >
646626 + substrate_frame_rpc_system:: AccountNonceApi < Block , AccountId , Nonce > ,
627+ AuraId : AuraIdT + Sync ,
647628 Net : NetworkBackend < Block , Hash > ,
648629{
649630 start_node_impl :: < RuntimeApi , _ , _ , _ , Net > (
0 commit comments