Skip to content

Commit b8369d4

Browse files
committed
Remove pointless GetMinimumRelayParents message
+ Refactor/cleanup + some docs.
1 parent dea725b commit b8369d4

File tree

3 files changed

+116
-197
lines changed

3 files changed

+116
-197
lines changed

polkadot/node/core/prospective-parachains/src/lib.rs

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ async fn run_iteration<Context>(
167167
) => answer_get_backable_candidates(&view, relay_parent, para, count, ancestors, tx),
168168
ProspectiveParachainsMessage::GetHypotheticalMembership(request, tx) =>
169169
answer_hypothetical_membership_request(&view, request, tx, metrics),
170-
ProspectiveParachainsMessage::GetMinimumRelayParents(relay_parent, tx) =>
171-
answer_minimum_relay_parents_request(&view, relay_parent, tx),
172170
ProspectiveParachainsMessage::GetProspectiveValidationData(request, tx) =>
173171
answer_prospective_validation_data_request(&view, request, tx),
174172
},
@@ -238,19 +236,25 @@ async fn handle_active_leaves_update<Context>(
238236
.await?
239237
.saturating_sub(1);
240238

241-
let ancestry =
242-
fetch_ancestry(ctx, &mut temp_header_cache, hash, ancestry_len as usize, session_index)
243-
.await?;
239+
let ancestors = fetch_ancestors(
240+
ctx,
241+
&mut temp_header_cache,
242+
hash,
243+
ancestry_len as usize,
244+
session_index,
245+
)
246+
.await?;
244247

245-
let prev_fragment_chains =
246-
ancestry.first().and_then(|prev_leaf| view.get_fragment_chains(&prev_leaf.hash));
248+
let prev_fragment_chains = ancestors
249+
.first()
250+
.and_then(|prev_leaf| view.get_fragment_chains(&prev_leaf.hash));
247251

248252
// Create the relay chain scope once for this relay parent.
249253
// All paras share the same relay chain ancestry.
250254
// The ancestry is already limited by session boundaries and scheduling lookahead.
251255
let relay_chain_scope = match fragment_chain::RelayChainScope::with_ancestors(
252256
block_info.clone().into(),
253-
ancestry
257+
ancestors
254258
.iter()
255259
.map(|a| RelayChainBlockInfo::from(a.clone()))
256260
.collect::<Vec<_>>(),
@@ -259,7 +263,7 @@ async fn handle_active_leaves_update<Context>(
259263
Err(unexpected_ancestors) => {
260264
gum::warn!(
261265
target: LOG_TARGET,
262-
?ancestry,
266+
?ancestors,
263267
leaf = ?hash,
264268
"Relay chain ancestors have wrong order: {:?}",
265269
unexpected_ancestors
@@ -328,7 +332,7 @@ async fn handle_active_leaves_update<Context>(
328332
// The runtime's min_relay_parent_number should match: now - ancestry_len
329333
let min_relay_parent_number = constraints.min_relay_parent_number;
330334
debug_assert_eq!(
331-
block_info.number.saturating_sub(ancestry.len() as u32),
335+
block_info.number.saturating_sub(ancestors.len() as u32),
332336
min_relay_parent_number,
333337
"Fetched ancestry length should match runtime's min_relay_parent calculation"
334338
);
@@ -342,7 +346,7 @@ async fn handle_active_leaves_update<Context>(
342346
min_relay_parent = min_relay_parent_number,
343347
max_backable_chain_len,
344348
para_id = ?para,
345-
ancestors = ?ancestry,
349+
ancestors = ?ancestors,
346350
"Creating fragment chain"
347351
);
348352

@@ -847,23 +851,6 @@ fn answer_hypothetical_membership_request(
847851
let _ = tx.send(response);
848852
}
849853

850-
fn answer_minimum_relay_parents_request(
851-
view: &View,
852-
relay_parent: Hash,
853-
tx: oneshot::Sender<Vec<(ParaId, BlockNumber)>>,
854-
) {
855-
let mut v = Vec::new();
856-
if view.active_leaves.contains(&relay_parent) {
857-
if let Some(leaf_data) = view.per_relay_parent.get(&relay_parent) {
858-
for (para_id, fragment_chain) in &leaf_data.fragment_chains {
859-
v.push((*para_id, fragment_chain.min_relay_parent_number()));
860-
}
861-
}
862-
}
863-
864-
let _ = tx.send(v);
865-
}
866-
867854
fn answer_prospective_validation_data_request(
868855
view: &View,
869856
request: ProspectiveValidationDataRequest,
@@ -992,9 +979,18 @@ async fn fetch_backing_constraints_and_candidates_inner<Context>(
992979
Ok(Some((From::from(constraints), pending_availability)))
993980
}
994981

995-
// Fetch ancestors in descending order, up to the amount requested.
982+
/// Fetches block information for ancestors of a given relay chain block.
983+
///
984+
/// Returns up to `ancestors` ancestor blocks in descending order (from most recent to oldest),
985+
/// stopping early if an ancestor is from a different session than `required_session`, if block
986+
/// info cannot be fetched, or if genesis is reached.
987+
///
988+
/// # Returns
989+
///
990+
/// A vector of `BlockInfo` containing block hashes, numbers, and storage roots for all
991+
/// ancestors within `required_session`, in descending order by block number.
996992
#[overseer::contextbounds(ProspectiveParachains, prefix = self::overseer)]
997-
async fn fetch_ancestry<Context>(
993+
async fn fetch_ancestors<Context>(
998994
ctx: &mut Context,
999995
cache: &mut HashMap<Hash, Header>,
1000996
relay_hash: Hash,

polkadot/node/subsystem-types/src/messages.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,20 +1447,6 @@ pub enum ProspectiveParachainsMessage {
14471447
HypotheticalMembershipRequest,
14481448
oneshot::Sender<Vec<(HypotheticalCandidate, HypotheticalMembership)>>,
14491449
),
1450-
/// Get the minimum accepted relay-parent number for each para in the fragment chain
1451-
/// for the given relay-chain block hash.
1452-
///
1453-
/// That is, if the block hash is known and is an active leaf, this returns the
1454-
/// minimum relay-parent block number in the same branch of the relay chain which
1455-
/// is accepted in the fragment chain for each para-id.
1456-
///
1457-
/// If the block hash is not an active leaf, this will return an empty vector.
1458-
///
1459-
/// Para-IDs which are omitted from this list can be assumed to have no
1460-
/// valid candidate relay-parents under the given relay-chain block hash.
1461-
///
1462-
/// Para-IDs are returned in no particular order.
1463-
GetMinimumRelayParents(Hash, oneshot::Sender<Vec<(ParaId, BlockNumber)>>),
14641450
/// Get the validation data of some prospective candidate. The candidate doesn't need
14651451
/// to be part of any fragment chain, but this only succeeds if the parent head-data and
14661452
/// relay-parent are part of the `CandidateStorage` (meaning that it's a candidate which is

0 commit comments

Comments
 (0)