Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statement-distribution: RFC103 implementation #5883

Merged
merged 171 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 167 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
793142e
WIP primitives
sandreim Jul 17, 2024
3a29fdf
WIP
sandreim Aug 5, 2024
4a53577
Working version.
sandreim Aug 7, 2024
8285ae7
Better version
sandreim Aug 8, 2024
2831c5e
Add missing primitives and fix things
sandreim Aug 8, 2024
c767d60
Implement v2 receipts in polkadot-runtime-parachains
sandreim Aug 8, 2024
96999e3
add missing stuff
sandreim Aug 12, 2024
c5f2dc3
Switch parachains runtime to use new primitives
sandreim Aug 12, 2024
dbb0160
use vstaging primitives
sandreim Aug 12, 2024
5efab68
update rococo and westend
sandreim Aug 12, 2024
c2232e4
client keeps using the old primitives
sandreim Aug 12, 2024
87b079f
no unsafe pls
sandreim Aug 12, 2024
00e8c13
move async backing primtiives to own file
sandreim Aug 12, 2024
cd4d02f
fix
sandreim Aug 12, 2024
5509e33
fix test build
sandreim Aug 12, 2024
f8b86d2
fix test-runtime
sandreim Aug 12, 2024
fe2fbfb
self review feedback
sandreim Aug 13, 2024
975e13b
review feedback
sandreim Aug 13, 2024
1c7ac55
feedback
sandreim Aug 13, 2024
653873b
feedback
sandreim Aug 13, 2024
dc98149
clippy
sandreim Aug 13, 2024
0a6bce3
chores
sandreim Aug 13, 2024
5e4dac2
Filter v2 candidate descriptors
sandreim Aug 14, 2024
f12ca7a
fix
sandreim Aug 14, 2024
13734de
fix prospective parachains tests
sandreim Aug 14, 2024
effb1cc
fix fix
sandreim Aug 14, 2024
3f75cba
fmt
sandreim Aug 14, 2024
75a47bb
fix comment
sandreim Aug 14, 2024
12ed853
another one
sandreim Aug 14, 2024
f2c0882
fix build
sandreim Aug 15, 2024
768e034
.
sandreim Aug 15, 2024
4bf0706
improve test and add comment
sandreim Aug 15, 2024
0c83201
add log
sandreim Aug 15, 2024
4296942
simplify check()
sandreim Aug 19, 2024
e1a7509
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 20, 2024
6fb7790
impl<H>
sandreim Aug 20, 2024
e6add9c
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 20, 2024
d0b3961
comment
sandreim Aug 20, 2024
66f7a96
add some tests
sandreim Aug 20, 2024
5c0c919
update
sandreim Aug 20, 2024
38ce589
prdoc
sandreim Aug 21, 2024
9f1d611
can't be happy if CI is sad
sandreim Aug 21, 2024
a6a7329
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Aug 21, 2024
663817d
remove newlines
sandreim Aug 21, 2024
a1dacc1
match rfc 103 reserved field naming
sandreim Aug 21, 2024
33b80ea
remove default cq offset
sandreim Aug 21, 2024
d5b165f
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 21, 2024
29e4b47
Ignore UMP signals when checking and processing UMP queue
sandreim Aug 16, 2024
ab85fe3
wip
sandreim Aug 20, 2024
7d5636b
refactor a bit
sandreim Aug 20, 2024
2954bba
use descriptor core_index in `map_candidates_to_cores`
sandreim Aug 20, 2024
e7abe8b
nits
sandreim Aug 20, 2024
1db5eb0
Para Inherent: filter v2 candidate descriptors (#5362)
sandreim Aug 22, 2024
cdb49a6
increase test coverage
sandreim Aug 22, 2024
f6f714a
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 22, 2024
aa925cd
Improve usability of primitives
sandreim Aug 23, 2024
00d7c71
use committed core index if available in v1 receipts
sandreim Aug 23, 2024
af9f561
typo
sandreim Aug 23, 2024
fb2cefb
fix check
sandreim Aug 23, 2024
b53787d
typo
sandreim Aug 23, 2024
e2ef46e
add test for mixed v1 v2 scenario
sandreim Aug 26, 2024
2dfc542
comment
sandreim Aug 26, 2024
a38a243
add ump test
sandreim Aug 26, 2024
da381da
avoid one storage read
sandreim Aug 26, 2024
ca5c618
store claim queue snapshot in allowed relay parent info
sandreim Aug 27, 2024
4266665
check v2 receipts using claim queue snapshots
sandreim Aug 27, 2024
e93b983
typo
sandreim Aug 27, 2024
e01bf53
it was a bad idea to process commitments of v1 receipts
sandreim Aug 28, 2024
fb9fbe6
fmt
sandreim Aug 28, 2024
c507488
remove unused
sandreim Aug 28, 2024
178e201
Validate session index
sandreim Aug 28, 2024
984e8e1
add unknown version
sandreim Aug 29, 2024
fab215d
add check for unknown version and test
sandreim Aug 29, 2024
7300552
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 29, 2024
9bbe2cc
typo
sandreim Aug 29, 2024
4dda9df
adjust comments
sandreim Aug 29, 2024
cd3eb5f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Aug 30, 2024
f8ef4ce
fix merge damage
sandreim Aug 30, 2024
04e31a1
unused
sandreim Aug 30, 2024
5fd1279
fix
sandreim Aug 30, 2024
19d6f32
fix benchmark build
sandreim Sep 2, 2024
552078a
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Sep 2, 2024
4ec3fc8
typos
sandreim Sep 2, 2024
2ba0a27
fmt
sandreim Sep 2, 2024
e468d62
fix comment
sandreim Sep 2, 2024
3fe368f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Sep 3, 2024
18a0496
mixed v1, v2, v2 without select core tests,
sandreim Sep 4, 2024
d320269
Add allowed relay parents storage migration
sandreim Sep 4, 2024
8490488
fix migration
sandreim Sep 5, 2024
db67486
fix
sandreim Sep 5, 2024
03cf8c1
clippy
sandreim Sep 5, 2024
43f6de7
feedback
sandreim Sep 5, 2024
70e48d2
sir, make it faster
sandreim Sep 5, 2024
1e26c73
fix
sandreim Sep 5, 2024
f4e3fb5
one last fix
sandreim Sep 5, 2024
2e87ad3
fixes
sandreim Sep 5, 2024
54432be
remove println
sandreim Sep 5, 2024
cfbecb0
add prdoc
sandreim Sep 6, 2024
3a518f2
fix comment
sandreim Sep 6, 2024
54106e2
refactor map_candidates_to_cores
sandreim Sep 6, 2024
b44a604
doc updates
sandreim Sep 9, 2024
4c5c707
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Sep 9, 2024
0cc2e6c
switch nodes to vstaging primitives
sandreim Sep 11, 2024
f9ddb15
test fixes
sandreim Sep 11, 2024
add4592
fmt
sandreim Sep 11, 2024
ef51144
extract test helpers in MutateDescriptorV2
sandreim Sep 12, 2024
3981425
fix tests
sandreim Sep 12, 2024
32af174
more fixes
sandreim Sep 12, 2024
9eba1ef
more wip
sandreim Sep 13, 2024
caff543
feedback
sandreim Sep 13, 2024
218f530
refactor
sandreim Sep 13, 2024
216937a
fix try-runtime
sandreim Sep 13, 2024
e169d0d
Finally all tests compile
sandreim Sep 16, 2024
ceac8b2
:facepalm:
sandreim Sep 16, 2024
c0aee8c
check ump signal count and test
sandreim Sep 16, 2024
1ef7952
remove unused
sandreim Sep 18, 2024
5790b8e
fix prdoc
sandreim Sep 19, 2024
ba9d3ff
more tests cases
sandreim Sep 19, 2024
888880f
Merge branch 'sandreim/runtime_v2_descriptor_support' into sandreim/n…
sandreim Sep 19, 2024
0dcf739
workaround #64
sandreim Sep 20, 2024
604273b
stricter UMP signal checks and tests
sandreim Sep 23, 2024
9c4e2ae
stricter UMP signal checks and tests
sandreim Sep 23, 2024
43bbb9d
type alias
sandreim Sep 24, 2024
64febf4
Merge branch 'sandreim/runtime_v2_descriptor_support' of github.com:p…
sandreim Sep 24, 2024
a493225
remove unused
sandreim Sep 24, 2024
d7e57fd
Merge branch 'master' into sandreim/runtime_v2_descriptor_support
sandreim Sep 24, 2024
7e3a943
Merge branch 'sandreim/runtime_v2_descriptor_support' of github.com:p…
sandreim Sep 24, 2024
7352577
add prdoc
sandreim Sep 24, 2024
c9e44d1
fix merge damage
sandreim Sep 24, 2024
bf948a7
fix
sandreim Sep 24, 2024
fd9dfee
fix some builds
sandreim Sep 26, 2024
5bd465b
fix the fix
sandreim Sep 26, 2024
53bb5b8
toml fixes
sandreim Sep 27, 2024
19c9607
draft
sandreim Oct 1, 2024
7a1f382
missing feedback
sandreim Oct 2, 2024
4757dab
Merge remote-tracking branch 'origin' into sandreim/runtime_v2_descri…
sandreim Oct 2, 2024
a2a0795
Merge branch 'sandreim/runtime_v2_descriptor_support' of github.com:p…
sandreim Oct 2, 2024
01ce087
:facepalm:
sandreim Oct 2, 2024
c0b36b1
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Oct 2, 2024
9bd1963
claim queue is always available
sandreim Oct 2, 2024
555c91b
remove bogus code
sandreim Oct 17, 2024
90932b3
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Oct 17, 2024
4b2c06f
fix build
sandreim Oct 17, 2024
320318a
fmt and feedback
sandreim Oct 17, 2024
dfde71f
more fixes
sandreim Oct 21, 2024
cb93bb6
delete PRDoc
sandreim Oct 21, 2024
a402509
Update from sandreim running command 'prdoc --audience node_dev runti…
actions-user Oct 21, 2024
6371454
adjust generated PRDoc
sandreim Oct 21, 2024
9c5097d
fix build again
sandreim Oct 22, 2024
2a736e5
Merge branch 'sandreim/node_v2_descriptors' of github.com:paritytech/…
sandreim Oct 22, 2024
b2818f3
fix test
sandreim Oct 22, 2024
f647249
fix example
sandreim Oct 23, 2024
267624c
Merge branch 'sandreim/runtime_v2_descriptor_support' of github.com:p…
sandreim Oct 23, 2024
928bdf3
use rp session info
sandreim Oct 23, 2024
d9edcd2
fix test
sandreim Oct 23, 2024
82da09a
fmt
sandreim Oct 24, 2024
c4e50a3
Merge branch 'sandreim/node_v2_descriptors' of github.com:paritytech/…
sandreim Oct 24, 2024
b8bafb9
refactor and more testing
sandreim Oct 25, 2024
7908369
Update from sandreim running command 'prdoc --audience node_dev --bum…
actions-user Oct 25, 2024
dbd59e7
prdoc
sandreim Oct 25, 2024
0c5240c
typo
sandreim Oct 25, 2024
4d6c45a
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Oct 25, 2024
1bd9375
feedback
sandreim Nov 1, 2024
f8b2b89
add comment
sandreim Nov 1, 2024
146f2c1
remove av cores completely.
sandreim Nov 1, 2024
8fe1266
fix clippy and tests
sandreim Nov 4, 2024
3d94a92
fix prdoc
sandreim Nov 4, 2024
ea8bec2
fix test helpers build
sandreim Nov 4, 2024
6a25bba
rename
sandreim Nov 4, 2024
7424248
update prdoc
sandreim Nov 4, 2024
076c1a5
fmt
sandreim Nov 4, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn make_committed_candidate(
persisted_validation_data_hash: persisted_validation_data.hash(),
pov_hash: Hash::repeat_byte(1),
erasure_root: Hash::repeat_byte(1),
signature: test_helpers::dummy_collator_signature(),
signature: test_helpers::zero_collator_signature(),
para_head: para_head.hash(),
validation_code_hash: Hash::repeat_byte(42).into(),
}
Expand Down
1 change: 1 addition & 0 deletions polkadot/node/network/statement-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ polkadot-primitives = { workspace = true, features = ["test"] }
polkadot-primitives-test-helpers = { workspace = true }
rand_chacha = { workspace = true, default-features = true }
polkadot-subsystem-bench = { workspace = true }
rstest = { workspace = true }

[[bench]]
name = "statement-distribution-regression-bench"
Expand Down
5 changes: 1 addition & 4 deletions polkadot/node/network/statement-distribution/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@ pub enum Error {
#[error("Fetching session info failed {0:?}")]
FetchSessionInfo(RuntimeApiError),

#[error("Fetching availability cores failed {0:?}")]
FetchAvailabilityCores(RuntimeApiError),

#[error("Fetching disabled validators failed {0:?}")]
FetchDisabledValidators(runtime::Error),

#[error("Fetching validator groups failed {0:?}")]
FetchValidatorGroups(RuntimeApiError),

#[error("Fetching claim queue failed {0:?}")]
FetchClaimQueue(runtime::Error),
FetchClaimQueue(RuntimeApiError),

#[error("Attempted to share statement when not a validator or not assigned")]
InvalidShare,
Expand Down
153 changes: 72 additions & 81 deletions polkadot/node/network/statement-distribution/src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ use polkadot_node_subsystem_util::{
backing_implicit_view::View as ImplicitView,
reputation::ReputationAggregator,
runtime::{
fetch_claim_queue, request_min_backing_votes, ClaimQueueSnapshot, ProspectiveParachainsMode,
request_min_backing_votes, request_node_features, ClaimQueueSnapshot,
ProspectiveParachainsMode,
},
};
use polkadot_primitives::{
vstaging::CoreState, AuthorityDiscoveryId, CandidateHash, CompactStatement, CoreIndex,
GroupIndex, GroupRotationInfo, Hash, Id as ParaId, IndexedVec, SessionIndex, SessionInfo,
node_features::FeatureIndex,
vstaging::{transpose_claim_queue, CandidateDescriptorVersion, TransposedClaimQueue},
AuthorityDiscoveryId, CandidateHash, CompactStatement, CoreIndex, GroupIndex,
GroupRotationInfo, Hash, Id as ParaId, IndexedVec, NodeFeatures, SessionIndex, SessionInfo,
SignedStatement, SigningContext, UncheckedSignedStatement, ValidatorId, ValidatorIndex,
};

Expand Down Expand Up @@ -137,6 +140,12 @@ const COST_UNREQUESTED_RESPONSE_STATEMENT: Rep =
Rep::CostMajor("Un-requested Statement In Response");
const COST_INACCURATE_ADVERTISEMENT: Rep =
Rep::CostMajor("Peer advertised a candidate inaccurately");
const COST_UNSUPPORTED_DESCRIPTOR_VERSION: Rep =
Rep::CostMajor("Candidate Descriptor version is not supported");
const COST_INVALID_CORE_INDEX: Rep =
Rep::CostMajor("Candidate Descriptor contains an invalid core index");
const COST_INVALID_SESSION_INDEX: Rep =
Rep::CostMajor("Candidate Descriptor contains an invalid session index");

const COST_INVALID_REQUEST: Rep = Rep::CostMajor("Peer sent unparsable request");
const COST_INVALID_REQUEST_BITFIELD_SIZE: Rep =
Expand All @@ -156,6 +165,7 @@ struct PerRelayParentState {
statement_store: StatementStore,
seconding_limit: usize,
session: SessionIndex,
transposed_cq: TransposedClaimQueue,
groups_per_para: HashMap<ParaId, Vec<GroupIndex>>,
disabled_validators: HashSet<ValidatorIndex>,
}
Expand Down Expand Up @@ -219,10 +229,17 @@ struct PerSessionState {
// getting the topology from the gossip-support subsystem
grid_view: Option<grid::SessionTopologyView>,
local_validator: Option<LocalValidatorIndex>,
// `true` if v2 candidate receipts are allowed by the runtime
v2_receipts: bool,
sandreim marked this conversation as resolved.
Show resolved Hide resolved
}

impl PerSessionState {
fn new(session_info: SessionInfo, keystore: &KeystorePtr, backing_threshold: u32) -> Self {
fn new(
session_info: SessionInfo,
keystore: &KeystorePtr,
backing_threshold: u32,
v2_receipts: bool,
) -> Self {
let groups = Groups::new(session_info.validator_groups.clone(), backing_threshold);
let mut authority_lookup = HashMap::new();
for (i, ad) in session_info.discovery_keys.iter().cloned().enumerate() {
Expand All @@ -235,7 +252,14 @@ impl PerSessionState {
)
.map(|(_, index)| LocalValidatorIndex::Active(index));

PerSessionState { session_info, groups, authority_lookup, grid_view: None, local_validator }
PerSessionState {
session_info,
groups,
authority_lookup,
grid_view: None,
local_validator,
v2_receipts,
}
}

fn supply_topology(
Expand Down Expand Up @@ -271,6 +295,11 @@ impl PerSessionState {
fn is_not_validator(&self) -> bool {
self.grid_view.is_some() && self.local_validator.is_none()
}

/// Returns `true` if v2 candidate receipts are enabled
fn candidate_receipt_v2_enabled(&self) -> bool {
self.v2_receipts
}
}

pub(crate) struct State {
Expand Down Expand Up @@ -615,8 +644,18 @@ pub(crate) async fn handle_active_leaves_update<Context>(

let minimum_backing_votes =
request_min_backing_votes(new_relay_parent, session_index, ctx.sender()).await?;
let mut per_session_state =
PerSessionState::new(session_info, &state.keystore, minimum_backing_votes);
let node_features =
request_node_features(new_relay_parent, session_index, ctx.sender()).await?;
let mut per_session_state = PerSessionState::new(
session_info,
&state.keystore,
minimum_backing_votes,
node_features
.unwrap_or(NodeFeatures::EMPTY)
.get(FeatureIndex::CandidateReceiptV2 as usize)
.map(|b| *b)
.unwrap_or(false),
);
if let Some(topology) = state.unused_topologies.remove(&session_index) {
per_session_state.supply_topology(&topology.topology, topology.local_index);
}
Expand All @@ -642,18 +681,6 @@ pub(crate) async fn handle_active_leaves_update<Context>(
continue
}

// New leaf: fetch info from runtime API and initialize
// `per_relay_parent`.

let availability_cores = polkadot_node_subsystem_util::request_availability_cores(
new_relay_parent,
ctx.sender(),
)
.await
.await
.map_err(JfyiError::RuntimeApiUnavailable)?
.map_err(JfyiError::FetchAvailabilityCores)?;

let group_rotation_info =
polkadot_node_subsystem_util::request_validator_groups(new_relay_parent, ctx.sender())
.await
Expand All @@ -662,37 +689,37 @@ pub(crate) async fn handle_active_leaves_update<Context>(
.map_err(JfyiError::FetchValidatorGroups)?
.1;

let maybe_claim_queue = fetch_claim_queue(ctx.sender(), new_relay_parent)
.await
.unwrap_or_else(|err| {
gum::debug!(target: LOG_TARGET, ?new_relay_parent, ?err, "handle_active_leaves_update: `claim_queue` API not available");
None
});
let claim_queue = ClaimQueueSnapshot(
polkadot_node_subsystem_util::request_claim_queue(new_relay_parent, ctx.sender())
.await
.await
.map_err(JfyiError::RuntimeApiUnavailable)?
.map_err(JfyiError::FetchClaimQueue)?,
);

let local_validator = per_session.local_validator.and_then(|v| {
if let LocalValidatorIndex::Active(idx) = v {
find_active_validator_state(
idx,
&per_session.groups,
&availability_cores,
&group_rotation_info,
&maybe_claim_queue,
&claim_queue,
seconding_limit,
max_candidate_depth,
)
} else {
Some(LocalValidatorState { grid_tracker: GridTracker::default(), active: None })
}
});

let groups_per_para = determine_groups_per_para(
availability_cores,
per_session.groups.all().len(),
group_rotation_info,
&maybe_claim_queue,
max_candidate_depth,
&claim_queue,
)
.await;

let transposed_cq = transpose_claim_queue(claim_queue.0);

state.per_relay_parent.insert(
new_relay_parent,
PerRelayParentState {
Expand All @@ -702,6 +729,7 @@ pub(crate) async fn handle_active_leaves_update<Context>(
session: session_index,
groups_per_para,
disabled_validators,
transposed_cq,
},
);
}
Expand Down Expand Up @@ -741,35 +769,18 @@ pub(crate) async fn handle_active_leaves_update<Context>(
fn find_active_validator_state(
validator_index: ValidatorIndex,
groups: &Groups,
availability_cores: &[CoreState],
group_rotation_info: &GroupRotationInfo,
maybe_claim_queue: &Option<ClaimQueueSnapshot>,
claim_queue: &ClaimQueueSnapshot,
seconding_limit: usize,
max_candidate_depth: usize,
) -> Option<LocalValidatorState> {
if groups.all().is_empty() {
return None
}

let our_group = groups.by_validator_index(validator_index)?;

let core_index = group_rotation_info.core_for_group(our_group, availability_cores.len());
let paras_assigned_to_core = if let Some(claim_queue) = maybe_claim_queue {
claim_queue.iter_claims_for_core(&core_index).copied().collect()
} else {
availability_cores
sandreim marked this conversation as resolved.
Show resolved Hide resolved
.get(core_index.0 as usize)
.and_then(|core_state| match core_state {
CoreState::Scheduled(scheduled_core) => Some(scheduled_core.para_id),
CoreState::Occupied(occupied_core) if max_candidate_depth >= 1 => occupied_core
.next_up_on_available
.as_ref()
.map(|scheduled_core| scheduled_core.para_id),
CoreState::Free | CoreState::Occupied(_) => None,
})
.into_iter()
.collect()
};
let core_index = group_rotation_info.core_for_group(our_group, groups.all().len());
let paras_assigned_to_core = claim_queue.iter_claims_for_core(&core_index).copied().collect();
sandreim marked this conversation as resolved.
Show resolved Hide resolved
let group_validators = groups.get(our_group)?.to_owned();

Some(LocalValidatorState {
Expand Down Expand Up @@ -2174,39 +2185,16 @@ async fn provide_candidate_to_grid<Context>(

// Utility function to populate per relay parent `ParaId` to `GroupIndex` mappings.
async fn determine_groups_per_para(
availability_cores: Vec<CoreState>,
n_cores: usize,
group_rotation_info: GroupRotationInfo,
maybe_claim_queue: &Option<ClaimQueueSnapshot>,
max_candidate_depth: usize,
claim_queue: &ClaimQueueSnapshot,
) -> HashMap<ParaId, Vec<GroupIndex>> {
let n_cores = availability_cores.len();

// Determine the core indices occupied by each para at the current relay parent. To support
// on-demand parachains we also consider the core indices at next blocks.
let schedule: HashMap<CoreIndex, Vec<ParaId>> = if let Some(claim_queue) = maybe_claim_queue {
claim_queue
.iter_all_claims()
.map(|(core_index, paras)| (*core_index, paras.iter().copied().collect()))
.collect()
} else {
availability_cores
.into_iter()
.enumerate()
.filter_map(|(index, core)| match core {
CoreState::Scheduled(scheduled_core) =>
Some((CoreIndex(index as u32), vec![scheduled_core.para_id])),
CoreState::Occupied(occupied_core) =>
if max_candidate_depth >= 1 {
occupied_core.next_up_on_available.map(|scheduled_core| {
(CoreIndex(index as u32), vec![scheduled_core.para_id])
})
} else {
None
},
CoreState::Free => None,
})
.collect()
};
let schedule: HashMap<CoreIndex, Vec<ParaId>> = claim_queue
.iter_all_claims()
.map(|(core_index, paras)| (*core_index, paras.iter().copied().collect()))
.collect();

let mut groups_per_para = HashMap::new();
// Map from `CoreIndex` to `GroupIndex` and collect as `HashMap`.
Expand Down Expand Up @@ -3106,11 +3094,12 @@ pub(crate) async fn handle_response<Context>(
) {
let &requests::CandidateIdentifier { relay_parent, candidate_hash, group_index } =
response.candidate_identifier();
let peer = *response.requested_peer();

gum::trace!(
target: LOG_TARGET,
?candidate_hash,
peer = ?response.requested_peer(),
?peer,
"Received response",
);

Expand Down Expand Up @@ -3145,6 +3134,8 @@ pub(crate) async fn handle_response<Context>(
expected_groups.iter().any(|g| g == &g_index)
},
disabled_mask,
&relay_parent_state.transposed_cq,
per_session.candidate_receipt_v2_enabled(),
);

for (peer, rep) in res.reputation_changes {
Expand Down
Loading
Loading