You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Flag which will be returned. Set to `true` if at least one vote is filtered.
1089
+
letmut filtered = false;
1090
+
1091
+
let minimum_backing_votes = configuration::Pallet::<T>::config().minimum_backing_votes;
1092
+
1093
+
// Process all backed candidates. `validator_indices` in `BackedCandidates` are indices within
1094
+
// the validator group assigned to the parachain. To obtain this group we need:
1095
+
// 1. Core index assigned to the parachain which has produced the candidate
1096
+
// 2. The relay chain block number of the candidate
1097
+
backed_candidates.retain_mut(|bc| {
1098
+
// Get `core_idx` assigned to the `para_id` of the candidate
1099
+
let core_idx = match scheduled.get(&bc.descriptor().para_id){
1100
+
Some(core_idx) => *core_idx,
1101
+
None => {
1102
+
log::debug!(target:LOG_TARGET,"Can't get core idx of a backed candidate for para id {:?}. Dropping the candidate.", bc.descriptor().para_id);
1103
+
returnfalse
1104
+
}
1105
+
};
1106
+
1107
+
// Get relay parent block number of the candidate. We need this to get the group index assigned to this core at this block number
1108
+
let relay_parent_block_number = match allowed_relay_parents
1109
+
.acquire_info(bc.descriptor().relay_parent,None){
1110
+
Some((_, block_num)) => block_num,
1111
+
None => {
1112
+
log::debug!(target:LOG_TARGET,"Relay parent {:?} for candidate is not in the allowed relay parents. Dropping the candidate.", bc.descriptor().relay_parent);
1113
+
returnfalse
1114
+
}
1115
+
};
1116
+
1117
+
// Get the group index for the core
1118
+
let group_idx = match <scheduler::Pallet<T>>::group_assigned_to_core(
1119
+
core_idx,
1120
+
relay_parent_block_number + One::one(),
1121
+
){
1122
+
Some(group_idx) => group_idx,
1123
+
None => {
1124
+
log::debug!(target:LOG_TARGET,"Can't get the group index for core idx {:?}. Dropping the candidate.", core_idx);
1125
+
returnfalse
1126
+
},
1127
+
};
1128
+
1129
+
// And finally get the validator group for this group index
1130
+
let validator_group = match <scheduler::Pallet<T>>::group_validators(group_idx){
1131
+
Some(validator_group) => validator_group,
1132
+
None => {
1133
+
log::debug!(target:LOG_TARGET,"Can't get the validators from group {:?}. Dropping the candidate.", group_idx);
1134
+
returnfalse
1135
+
}
1136
+
};
1137
+
1138
+
// Bitmask with the disabled indices within the validator group
1139
+
let disabled_indices = BitVec::<u8, bitvec::order::Lsb0>::from_iter(validator_group.iter().map(|idx| disabled_validators.contains(idx)));
1140
+
// The indices of statements from disabled validators in `BackedCandidate`. We have to drop these.
1141
+
let indices_to_drop = disabled_indices.clone()&&bc.validator_indices;
1142
+
// Apply the bitmask to drop the disabled validator from `validator_indices`
1143
+
bc.validator_indices &= !disabled_indices;
1144
+
// Remove the corresponding votes from `validity_votes`
1145
+
for idx in indices_to_drop.iter_ones().rev(){
1146
+
bc.validity_votes.remove(idx);
1147
+
}
1148
+
1149
+
// If at least one statement was dropped we need to return `true`
1150
+
if indices_to_drop.count_ones() > 0{
1151
+
filtered = true;
1152
+
}
1153
+
1154
+
// By filtering votes we might render the candidate invalid and cause a failure in
1155
+
// [`process_candidates`]. To avoid this we have to perform a sanity check here. If there
1156
+
// are not enough backing votes after filtering we will remove the whole candidate.
1157
+
if bc.validity_votes.len() < effective_minimum_backing_votes(
1158
+
validator_group.len(),
1159
+
minimum_backing_votes
1160
+
1161
+
){
1162
+
returnfalse
1163
+
}
1164
+
1165
+
true
1166
+
});
1167
+
1168
+
// Also return `true` if a whole candidate was dropped from the set
0 commit comments