@@ -120,6 +120,14 @@ pub async fn run<Block, P, BI, CIDP, Client, Backend, RClient, SO, Proposer, CS>
120120 P :: Public : AppPublic + Hash + Member + Encode + Decode ,
121121 P :: Signature : TryFrom < Vec < u8 > > + Hash + Member + Encode + Decode ,
122122{
123+ // This is an arbitrary value which is likely guaranteed to exceed any reasonable
124+ // limit, as it would correspond to 10 non-included blocks.
125+ //
126+ // Since we only search for parent blocks which have already been included,
127+ // we can guarantee that all imported blocks respect the unincluded segment
128+ // rules specified by the parachain's runtime and thus will never be too deep.
129+ const PARENT_SEARCH_DEPTH : usize = 10 ;
130+
123131 let mut params = params;
124132
125133 let mut import_notifications = match params. relay_client . import_notification_stream ( ) . await {
@@ -179,8 +187,8 @@ pub async fn run<Block, P, BI, CIDP, Client, Backend, RClient, SO, Proposer, CS>
179187 let parent_search_params = ParentSearchParams {
180188 relay_parent,
181189 para_id : params. para_id ,
182- ancestry_lookback : unimplemented ! ( ) ,
183- max_depth : unimplemented ! ( ) , // max unincluded segment len
190+ ancestry_lookback : max_ancestry_lookback ( relay_parent , & params . relay_client ) . await ,
191+ max_depth : PARENT_SEARCH_DEPTH ,
184192 ignore_alternative_branches : true ,
185193 } ;
186194
@@ -281,7 +289,7 @@ pub async fn run<Block, P, BI, CIDP, Client, Backend, RClient, SO, Proposer, CS>
281289
282290 // TODO [now]: announce to parachain sub-network
283291
284- // TODO [link to github issue when i have internet ]:
292+ // TODO [https:// github.com/paritytech/polkadot/issues/5056 ]:
285293 // announce collation to relay-chain validators.
286294 }
287295 Err ( err) => {
@@ -319,3 +327,17 @@ where
319327
320328 Some ( SlotClaim :: unchecked :: < P > ( author_pub, slot, timestamp) )
321329}
330+
331+ async fn max_ancestry_lookback (
332+ _relay_parent : PHash ,
333+ _relay_client : & impl RelayChainInterface ,
334+ ) -> usize {
335+ // TODO [https://github.com/paritytech/polkadot/pull/5022]
336+ // We need to read the relay-chain state to know what the maximum
337+ // age truly is, but that depends on those pallets existing.
338+ //
339+ // For now, just provide the conservative value of '2'.
340+ // Overestimating can cause problems, as we'd be building on forks of the
341+ // chain that never get included. Underestimating is less of an issue.
342+ 2
343+ }
0 commit comments