From 763134b67a73207dbc94e820e9a89283dc83edbe Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 26 Jul 2023 21:59:55 -0500 Subject: [PATCH] update `find_potential_parents` to account for sessions --- client/consensus/common/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/consensus/common/src/lib.rs b/client/consensus/common/src/lib.rs index dae6024a53c..e0458b023f2 100644 --- a/client/consensus/common/src/lib.rs +++ b/client/consensus/common/src/lib.rs @@ -252,6 +252,7 @@ pub struct PotentialParent { /// parachain block (when `max_depth` >= 1), or all of the following hold: /// * its parent is a potential parent /// * its relay-parent is within `ancestry_lookback` of the targeted relay-parent. +/// * its relay-parent is within the same session as the targeted relay-parent. /// * the block number is within `max_depth` blocks of the included block pub async fn find_potential_parents( params: ParentSearchParams, @@ -262,12 +263,24 @@ pub async fn find_potential_parents( let rp_ancestry = { let mut ancestry = Vec::with_capacity(params.ancestry_lookback + 1); let mut current_rp = params.relay_parent; + let mut required_session = None; + while ancestry.len() <= params.ancestry_lookback { let header = match relay_client.header(RBlockId::hash(current_rp)).await? { None => break, Some(h) => h, }; + let session = relay_client.session_index_for_child(current_rp).await?; + if let Some(required_session) = required_session { + // Respect the relay-chain rule not to cross session boundaries. + if session != required_session { + break + } + } else { + required_session = Some(session); + } + ancestry.push((current_rp, *header.state_root())); current_rp = *header.parent_hash();