@@ -55,7 +55,7 @@ use polkadot_node_subsystem_util::{
5555} ;
5656use polkadot_primitives:: {
5757 AuthorityDiscoveryId , CandidateHash , CandidateReceipt , CollatorPair , CoreIndex , CoreState ,
58- GroupIndex , Hash , Id as ParaId , SessionIndex ,
58+ GroupIndex , Hash , HeadData , Id as ParaId , SessionIndex ,
5959} ;
6060
6161use super :: LOG_TARGET ;
@@ -347,6 +347,7 @@ async fn distribute_collation<Context>(
347347 receipt : CandidateReceipt ,
348348 parent_head_data_hash : Hash ,
349349 pov : PoV ,
350+ parent_head_data : HeadData ,
350351 result_sender : Option < oneshot:: Sender < CollationSecondedSignal > > ,
351352) -> Result < ( ) > {
352353 let candidate_relay_parent = receipt. descriptor . relay_parent ;
@@ -465,7 +466,13 @@ async fn distribute_collation<Context>(
465466
466467 per_relay_parent. collations . insert (
467468 candidate_hash,
468- Collation { receipt, parent_head_data_hash, pov, status : CollationStatus :: Created } ,
469+ Collation {
470+ receipt,
471+ parent_head_data_hash,
472+ pov,
473+ parent_head_data,
474+ status : CollationStatus :: Created ,
475+ } ,
469476 ) ;
470477
471478 // If prospective parachains are disabled, a leaf should be known to peer.
@@ -763,20 +770,26 @@ async fn process_msg<Context>(
763770 CollateOn ( id) => {
764771 state. collating_on = Some ( id) ;
765772 } ,
766- DistributeCollation ( receipt, parent_head_data_hash, pov, result_sender) => {
773+ DistributeCollation {
774+ candidate_receipt,
775+ parent_head_data_hash,
776+ pov,
777+ parent_head_data,
778+ result_sender,
779+ } => {
767780 let _span1 = state
768781 . span_per_relay_parent
769- . get ( & receipt . descriptor . relay_parent )
782+ . get ( & candidate_receipt . descriptor . relay_parent )
770783 . map ( |s| s. child ( "distributing-collation" ) ) ;
771784 let _span2 = jaeger:: Span :: new ( & pov, "distributing-collation" ) ;
772785
773786 match state. collating_on {
774- Some ( id) if receipt . descriptor . para_id != id => {
787+ Some ( id) if candidate_receipt . descriptor . para_id != id => {
775788 // If the ParaId of a collation requested to be distributed does not match
776789 // the one we expect, we ignore the message.
777790 gum:: warn!(
778791 target: LOG_TARGET ,
779- para_id = %receipt . descriptor. para_id,
792+ para_id = %candidate_receipt . descriptor. para_id,
780793 collating_on = %id,
781794 "DistributeCollation for unexpected para_id" ,
782795 ) ;
@@ -788,17 +801,18 @@ async fn process_msg<Context>(
788801 runtime,
789802 state,
790803 id,
791- receipt ,
804+ candidate_receipt ,
792805 parent_head_data_hash,
793806 pov,
807+ parent_head_data,
794808 result_sender,
795809 )
796810 . await ?;
797811 } ,
798812 None => {
799813 gum:: warn!(
800814 target: LOG_TARGET ,
801- para_id = %receipt . descriptor. para_id,
815+ para_id = %candidate_receipt . descriptor. para_id,
802816 "DistributeCollation message while not collating on any" ,
803817 ) ;
804818 } ,
@@ -835,20 +849,30 @@ async fn send_collation(
835849 request : VersionedCollationRequest ,
836850 receipt : CandidateReceipt ,
837851 pov : PoV ,
852+ _parent_head_data : HeadData ,
838853) {
839854 let ( tx, rx) = oneshot:: channel ( ) ;
840855
841856 let relay_parent = request. relay_parent ( ) ;
842857 let peer_id = request. peer_id ( ) ;
843858 let candidate_hash = receipt. hash ( ) ;
844859
845- // The response payload is the same for both versions of protocol
860+ // The response payload is the same for v1 and v2 versions of protocol
846861 // and doesn't have v2 alias for simplicity.
847- let response = OutgoingResponse {
848- result : Ok ( request_v1:: CollationFetchingResponse :: Collation ( receipt, pov) ) ,
849- reputation_changes : Vec :: new ( ) ,
850- sent_feedback : Some ( tx) ,
851- } ;
862+ // For now, we don't send parent head data to the collation requester.
863+ let result =
864+ // if assigned_multiple_cores {
865+ // Ok(request_v1::CollationFetchingResponse::CollationWithParentHeadData {
866+ // receipt,
867+ // pov,
868+ // parent_head_data,
869+ // })
870+ // } else {
871+ Ok ( request_v1:: CollationFetchingResponse :: Collation ( receipt, pov) )
872+ // }
873+ ;
874+ let response =
875+ OutgoingResponse { result, reputation_changes : Vec :: new ( ) , sent_feedback : Some ( tx) } ;
852876
853877 if let Err ( _) = request. send_outgoing_response ( response) {
854878 gum:: warn!( target: LOG_TARGET , "Sending collation response failed" ) ;
@@ -1027,9 +1051,13 @@ async fn handle_incoming_request<Context>(
10271051 return Ok ( ( ) )
10281052 } ,
10291053 } ;
1030- let ( receipt, pov) = if let Some ( collation) = collation {
1054+ let ( receipt, pov, parent_head_data ) = if let Some ( collation) = collation {
10311055 collation. status . advance_to_requested ( ) ;
1032- ( collation. receipt . clone ( ) , collation. pov . clone ( ) )
1056+ (
1057+ collation. receipt . clone ( ) ,
1058+ collation. pov . clone ( ) ,
1059+ collation. parent_head_data . clone ( ) ,
1060+ )
10331061 } else {
10341062 gum:: warn!(
10351063 target: LOG_TARGET ,
@@ -1068,7 +1096,7 @@ async fn handle_incoming_request<Context>(
10681096 waiting. collation_fetch_active = true ;
10691097 // Obtain a timer for sending collation
10701098 let _ = state. metrics . time_collation_distribution ( "send" ) ;
1071- send_collation ( state, req, receipt, pov) . await ;
1099+ send_collation ( state, req, receipt, pov, parent_head_data ) . await ;
10721100 }
10731101 } ,
10741102 Some ( our_para_id) => {
@@ -1453,8 +1481,9 @@ async fn run_inner<Context>(
14531481 if let Some ( collation) = next_collation {
14541482 let receipt = collation. receipt. clone( ) ;
14551483 let pov = collation. pov. clone( ) ;
1484+ let parent_head_data = collation. parent_head_data. clone( ) ;
14561485
1457- send_collation( & mut state, next, receipt, pov) . await ;
1486+ send_collation( & mut state, next, receipt, pov, parent_head_data ) . await ;
14581487 }
14591488 } ,
14601489 ( candidate_hash, peer_id) = state. advertisement_timeouts. select_next_some( ) => {
0 commit comments