Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,26 +246,25 @@ impl CollationManager {
else {
continue;
};
let session_index =
match recv_runtime(request_session_index_for_child(*leaf, sender).await)
.await
.map_err(Error::Runtime)
{
Ok(session_index) => session_index,
Err(err) => {
err.split()?.log();
continue;
},
};

// Includes the leaf
for (idx, ancestor) in allowed_ancestry.iter().enumerate() {
if self.per_scheduling_parent.contains_key(&ancestor) {
continue;
}

let session_index =
match recv_runtime(request_session_index_for_child(*ancestor, sender).await)
.await
.map_err(Error::Runtime)
{
Ok(session_index) => session_index,
Err(err) => {
err.split()?.log();
continue;
},
};

let core = match self.get_our_core(sender, leaf, session_index).await {
let core = match self.get_our_core(sender, ancestor, session_index).await {
Ok(assignments) => assignments,
Err(err) => {
err.split()?.log();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3732,6 +3732,47 @@ async fn v3_descriptor_unknown_rejected_when_v3_disabled() {
test_state.assert_no_messages().await;
}

#[tokio::test]
// Check that the core is computed correctly for ancestors.
async fn core_assignment_uses_ancestor_not_leaf() {
let mut test_state = TestState::default();
test_state
.session_info
.get_mut(&1)
.unwrap()
.group_rotation_info
.group_rotation_frequency = 1;
test_state
.node_features
.resize(node_features::FeatureIndex::CandidateReceiptV3 as usize + 1, false);
test_state
.node_features
.set(node_features::FeatureIndex::CandidateReceiptV3 as u8 as usize, true);

let db = MockDb::default();
let mut state = make_state(db.clone(), &mut test_state, get_hash(10)).await;
let mut sender = test_state.sender.clone();

let peer_id = PeerId::random();
let (ccr, adv) = dummy_candidate_v3(
get_hash(8),
get_hash(9),
600.into(),
peer_id,
CoreIndex(2),
1,
dummy_pvd().hash(),
);

state.handle_peer_connected(&mut sender, peer_id, CollationVersion::V3).await;
state.handle_declare(&mut sender, peer_id, 600.into()).await;

test_state
.handle_fetched_collation(&mut state, adv, ccr.to_plain(), None, get_hash(8))
.await;
assert!(db.witnessed_slash().is_none());
}

// Launching new collations:
// - multiple candidates per relay parent (including from implicit view and which occupy future
// claims, including which will make claims across different leaves)
Expand Down
9 changes: 9 additions & 0 deletions prdoc/pr_11485.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Fix per-ancestor core assignment and add regression test
doc:
- audience: Node Dev
description: '`get_our_core` was called with the leaf hash instead of the ancestor
hash when computing core assignments in update_view. This caused all scheduling
parent to get leaf''s core.'
crates:
- name: polkadot-collator-protocol
bump: minor
Loading