@@ -105,6 +105,17 @@ pub struct AvailabilityRecoverySubsystem {
105105 req_receiver : IncomingRequestReceiver < request_v1:: AvailableDataFetchingRequest > ,
106106 /// Metrics for this subsystem.
107107 metrics : Metrics ,
108+ /// The type of check to perform after available data was recovered.
109+ post_recovery_check : PostRecoveryCheck ,
110+ }
111+
112+ #[ derive( Clone , PartialEq , Debug ) ]
113+ /// The type of check to perform after available data was recovered.
114+ pub enum PostRecoveryCheck {
115+ /// Reencode the data and check erasure root. For validators.
116+ Reencode ,
117+ /// Only check the pov hash. For collators only.
118+ PovHash ,
108119}
109120
110121/// Expensive erasure coding computations that we want to run on a blocking thread.
@@ -344,6 +355,7 @@ async fn launch_recovery_task<Context>(
344355 metrics : & Metrics ,
345356 recovery_strategies : VecDeque < Box < dyn RecoveryStrategy < <Context as SubsystemContext >:: Sender > > > ,
346357 bypass_availability_store : bool ,
358+ post_recovery_check : PostRecoveryCheck ,
347359) -> error:: Result < ( ) > {
348360 let candidate_hash = receipt. hash ( ) ;
349361 let params = RecoveryParams {
@@ -354,6 +366,8 @@ async fn launch_recovery_task<Context>(
354366 erasure_root : receipt. descriptor . erasure_root ,
355367 metrics : metrics. clone ( ) ,
356368 bypass_availability_store,
369+ post_recovery_check,
370+ pov_hash : receipt. descriptor . pov_hash ,
357371 } ;
358372
359373 let recovery_task = RecoveryTask :: new ( ctx. sender ( ) . clone ( ) , params, recovery_strategies) ;
@@ -390,6 +404,7 @@ async fn handle_recover<Context>(
390404 erasure_task_tx : futures:: channel:: mpsc:: Sender < ErasureTask > ,
391405 recovery_strategy_kind : RecoveryStrategyKind ,
392406 bypass_availability_store : bool ,
407+ post_recovery_check : PostRecoveryCheck ,
393408) -> error:: Result < ( ) > {
394409 let candidate_hash = receipt. hash ( ) ;
395410
@@ -486,6 +501,7 @@ async fn handle_recover<Context>(
486501 metrics,
487502 recovery_strategies,
488503 bypass_availability_store,
504+ post_recovery_check,
489505 )
490506 . await
491507 } ,
@@ -527,15 +543,17 @@ async fn query_chunk_size<Context>(
527543
528544#[ overseer:: contextbounds( AvailabilityRecovery , prefix = self :: overseer) ]
529545impl AvailabilityRecoverySubsystem {
530- /// Create a new instance of `AvailabilityRecoverySubsystem` which never requests the
531- /// `AvailabilityStoreSubsystem` subsystem.
532- pub fn with_availability_store_skip (
546+ /// Create a new instance of `AvailabilityRecoverySubsystem` suitable for collator nodes,
547+ /// which never requests the `AvailabilityStoreSubsystem` subsystem and only checks the POV hash
548+ /// instead of reencoding the available data.
549+ pub fn for_collator (
533550 req_receiver : IncomingRequestReceiver < request_v1:: AvailableDataFetchingRequest > ,
534551 metrics : Metrics ,
535552 ) -> Self {
536553 Self {
537554 recovery_strategy_kind : RecoveryStrategyKind :: BackersFirstIfSizeLower ( SMALL_POV_LIMIT ) ,
538555 bypass_availability_store : true ,
556+ post_recovery_check : PostRecoveryCheck :: PovHash ,
539557 req_receiver,
540558 metrics,
541559 }
@@ -550,6 +568,7 @@ impl AvailabilityRecoverySubsystem {
550568 Self {
551569 recovery_strategy_kind : RecoveryStrategyKind :: BackersFirstAlways ,
552570 bypass_availability_store : false ,
571+ post_recovery_check : PostRecoveryCheck :: Reencode ,
553572 req_receiver,
554573 metrics,
555574 }
@@ -563,6 +582,7 @@ impl AvailabilityRecoverySubsystem {
563582 Self {
564583 recovery_strategy_kind : RecoveryStrategyKind :: ChunksAlways ,
565584 bypass_availability_store : false ,
585+ post_recovery_check : PostRecoveryCheck :: Reencode ,
566586 req_receiver,
567587 metrics,
568588 }
@@ -577,15 +597,21 @@ impl AvailabilityRecoverySubsystem {
577597 Self {
578598 recovery_strategy_kind : RecoveryStrategyKind :: BackersFirstIfSizeLower ( SMALL_POV_LIMIT ) ,
579599 bypass_availability_store : false ,
600+ post_recovery_check : PostRecoveryCheck :: Reencode ,
580601 req_receiver,
581602 metrics,
582603 }
583604 }
584605
585606 async fn run < Context > ( self , mut ctx : Context ) -> SubsystemResult < ( ) > {
586607 let mut state = State :: default ( ) ;
587- let Self { mut req_receiver, metrics, recovery_strategy_kind, bypass_availability_store } =
588- self ;
608+ let Self {
609+ mut req_receiver,
610+ metrics,
611+ recovery_strategy_kind,
612+ bypass_availability_store,
613+ post_recovery_check,
614+ } = self ;
589615
590616 let ( erasure_task_tx, erasure_task_rx) = futures:: channel:: mpsc:: channel ( 16 ) ;
591617 let mut erasure_task_rx = erasure_task_rx. fuse ( ) ;
@@ -675,7 +701,8 @@ impl AvailabilityRecoverySubsystem {
675701 & metrics,
676702 erasure_task_tx. clone( ) ,
677703 recovery_strategy_kind. clone( ) ,
678- bypass_availability_store
704+ bypass_availability_store,
705+ post_recovery_check. clone( )
679706 ) . await {
680707 gum:: warn!(
681708 target: LOG_TARGET ,
0 commit comments