Skip to content

Commit

Permalink
Various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Jan 10, 2025
1 parent 2ffbb83 commit 2a13c0c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
7 changes: 4 additions & 3 deletions polkadot/node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ async fn handle_can_second_request<Context>(
let candidate_relay_parent = hypothetical_candidate.relay_parent();
let candidate_para_id = hypothetical_candidate.candidate_para();

let cq = if let Some(core_index) = state
let cq_state = if let Some(core_index) = state
.per_relay_parent
.get(&relay_parent)
.and_then(|rp_state| rp_state.assigned_core)
Expand All @@ -1481,7 +1481,8 @@ async fn handle_can_second_request<Context>(
};

let result =
seconding_sanity_check(ctx, &state.implicit_view, hypothetical_candidate, cq).await;
seconding_sanity_check(ctx, &state.implicit_view, hypothetical_candidate, cq_state)
.await;

match result {
SecondingAllowed::No => false,
Expand All @@ -1491,7 +1492,7 @@ async fn handle_can_second_request<Context>(
// only make claims at the leaves at which we can second the candidate. Calling
// `claim_pending_slot` here might make unnecessary claims.
for leaf in leaves.iter() {
let res = cq.claim_pending_slot_at_leaf(
let res = cq_state.claim_pending_slot_at_leaf(
&leaf,
&candidate_hash,
&candidate_relay_parent,
Expand Down
25 changes: 15 additions & 10 deletions polkadot/node/network/collator-protocol/src/validator_side/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ async fn handle_peer_view_change<Sender>(
});

// Drop claims for all cancelled fetches
sender.send_message(CandidateBackingMessage::DropClaims(removed)).await;
if !removed.is_empty() {
sender.send_message(CandidateBackingMessage::DropClaims(removed)).await;
}
}

/// Request a collation from the network.
Expand Down Expand Up @@ -1369,9 +1371,11 @@ where
}

// Drop claims for all unneeded candidates
sender
.send_message(CandidateBackingMessage::DropClaims(removed_collation_reqs))
.await;
if !removed_collation_reqs.is_empty() {
sender
.send_message(CandidateBackingMessage::DropClaims(removed_collation_reqs))
.await;
}

Ok(())
}
Expand Down Expand Up @@ -1787,10 +1791,8 @@ async fn dequeue_next_collation_and_fetch<Context>(
// The collator we tried to fetch from last, optionally which candidate.
previous_fetch: (CollatorId, Option<CandidateHash>),
) {
let claimed_slots = get_claimed_slots(ctx.sender(), relay_parent).await;

while let Some((next, id)) =
get_next_collation_to_fetch(&previous_fetch, relay_parent, state, &claimed_slots)
get_next_collation_to_fetch(ctx.sender(), &previous_fetch, relay_parent, state).await
{
gum::debug!(
target: LOG_TARGET,
Expand Down Expand Up @@ -2169,11 +2171,11 @@ async fn handle_collation_fetch_response(

/// Returns the next collation to fetch from the `waiting_queue` and reset the status back to
/// `Waiting`.
fn get_next_collation_to_fetch(
async fn get_next_collation_to_fetch(
sender: &mut impl overseer::CollatorProtocolSenderTrait,
finished_one: &(CollatorId, Option<CandidateHash>),
relay_parent: Hash,
state: &mut State,
unfulfilled_entries: &VecDeque<ParaId>,
) -> Option<(PendingCollation, CollatorId)> {
let rp_state = match state.per_relay_parent.get_mut(&relay_parent) {
Some(rp_state) => rp_state,
Expand Down Expand Up @@ -2203,8 +2205,11 @@ fn get_next_collation_to_fetch(
return None
}
}

let unfulfilled_entries = get_claimed_slots(sender, relay_parent).await;

rp_state.collations.status.back_to_waiting();
rp_state.collations.pick_a_collation_to_fetch(unfulfilled_entries)
rp_state.collations.pick_a_collation_to_fetch(&unfulfilled_entries)
}

// Sanity check the candidate descriptor version.
Expand Down
2 changes: 2 additions & 0 deletions polkadot/node/subsystem-util/src/claim_queue_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ impl PerLeafClaimQueueState {
}

/// Claims a slot in pending state for a candidate at a concrete leaf.
/// NOTE: This functions performs a claim only at the specified leaf. The caller needs to ensure
/// that this is correct.
pub fn claim_pending_slot_at_leaf(
&mut self,
leaf: &Hash,
Expand Down

0 comments on commit 2a13c0c

Please sign in to comment.