style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -519,7 +519,7 @@ fn validator_index_for_msg(
|
||||
) {
|
||||
match msg {
|
||||
pezkuwi_node_network_protocol::ValidationProtocols::V3(ref message) => match message {
|
||||
pezkuwi_node_network_protocol::v3::ApprovalDistributionMessage::Assignments(msgs) =>
|
||||
pezkuwi_node_network_protocol::v3::ApprovalDistributionMessage::Assignments(msgs) => {
|
||||
if let Ok(validator) = msgs.iter().map(|(msg, _)| msg.validator).all_equal_value() {
|
||||
(Some((validator, msg)), None)
|
||||
} else {
|
||||
@@ -537,8 +537,9 @@ fn validator_index_for_msg(
|
||||
})
|
||||
.collect_vec();
|
||||
(None, Some(split))
|
||||
},
|
||||
pezkuwi_node_network_protocol::v3::ApprovalDistributionMessage::Approvals(msgs) =>
|
||||
}
|
||||
},
|
||||
pezkuwi_node_network_protocol::v3::ApprovalDistributionMessage::Approvals(msgs) => {
|
||||
if let Ok(validator) = msgs.iter().map(|msg| msg.validator).all_equal_value() {
|
||||
(Some((validator, msg)), None)
|
||||
} else {
|
||||
@@ -556,7 +557,8 @@ fn validator_index_for_msg(
|
||||
})
|
||||
.collect_vec();
|
||||
(None, Some(split))
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -733,8 +735,9 @@ impl<T: Send + Sync + 'static + Debug> overseer::SubsystemSender<T> for ToWorker
|
||||
{
|
||||
match P::priority() {
|
||||
pezkuwi_overseer::PriorityLevel::Normal => self.send_message(msg),
|
||||
pezkuwi_overseer::PriorityLevel::High =>
|
||||
async { self.send_unbounded_message(msg) }.boxed(),
|
||||
pezkuwi_overseer::PriorityLevel::High => {
|
||||
async { self.send_unbounded_message(msg) }.boxed()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,10 +824,12 @@ impl<S: SubsystemSender<ApprovalVotingParallelMessage>>
|
||||
) -> Result<(), metered::TrySendError<ApprovalDistributionMessage>> {
|
||||
self.0.try_send_message(msg.into()).map_err(|err| match err {
|
||||
// Safe to unwrap because it was built from the same type.
|
||||
metered::TrySendError::Closed(msg) =>
|
||||
metered::TrySendError::Closed(msg.try_into().unwrap()),
|
||||
metered::TrySendError::Full(msg) =>
|
||||
metered::TrySendError::Full(msg.try_into().unwrap()),
|
||||
metered::TrySendError::Closed(msg) => {
|
||||
metered::TrySendError::Closed(msg.try_into().unwrap())
|
||||
},
|
||||
metered::TrySendError::Full(msg) => {
|
||||
metered::TrySendError::Full(msg.try_into().unwrap())
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -869,10 +874,12 @@ impl<S: SubsystemSender<ApprovalVotingParallelMessage>>
|
||||
) -> Result<(), metered::TrySendError<ApprovalDistributionMessage>> {
|
||||
self.0.try_send_message_with_priority::<P>(msg.into()).map_err(|err| match err {
|
||||
// Safe to unwrap because it was built from the same type.
|
||||
metered::TrySendError::Closed(msg) =>
|
||||
metered::TrySendError::Closed(msg.try_into().unwrap()),
|
||||
metered::TrySendError::Full(msg) =>
|
||||
metered::TrySendError::Full(msg.try_into().unwrap()),
|
||||
metered::TrySendError::Closed(msg) => {
|
||||
metered::TrySendError::Closed(msg.try_into().unwrap())
|
||||
},
|
||||
metered::TrySendError::Full(msg) => {
|
||||
metered::TrySendError::Full(msg.try_into().unwrap())
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +93,9 @@ impl Check {
|
||||
pub fn is_approved(&self, max_assignment_tick: Tick) -> bool {
|
||||
match *self {
|
||||
Check::Unapproved => false,
|
||||
Check::Approved(_, last_assignment_tick) =>
|
||||
last_assignment_tick.map_or(true, |t| t <= max_assignment_tick),
|
||||
Check::Approved(_, last_assignment_tick) => {
|
||||
last_assignment_tick.map_or(true, |t| t <= max_assignment_tick)
|
||||
},
|
||||
Check::ApprovedOneThird => true,
|
||||
}
|
||||
}
|
||||
@@ -304,8 +305,8 @@ impl State {
|
||||
// validators.
|
||||
// If there are a lot then we've got bigger problems and no need to make this
|
||||
// array unnecessarily large.
|
||||
if self.no_show_validators.len() + no_show_validators.len() <
|
||||
MAX_RECORDED_NO_SHOW_VALIDATORS_PER_CANDIDATE
|
||||
if self.no_show_validators.len() + no_show_validators.len()
|
||||
< MAX_RECORDED_NO_SHOW_VALIDATORS_PER_CANDIDATE
|
||||
{
|
||||
self.no_show_validators.extend(no_show_validators);
|
||||
}
|
||||
|
||||
@@ -409,8 +409,9 @@ fn canonicalize_works() {
|
||||
.is_none());
|
||||
continue;
|
||||
},
|
||||
Some(i) =>
|
||||
(load_block_entry_v2(store.as_ref(), &TEST_CONFIG, &hash).unwrap().unwrap(), i),
|
||||
Some(i) => {
|
||||
(load_block_entry_v2(store.as_ref(), &TEST_CONFIG, &hash).unwrap().unwrap(), i)
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(entry.candidates.len(), with_candidates.len());
|
||||
|
||||
@@ -415,8 +415,9 @@ fn canonicalize_works() {
|
||||
.is_none());
|
||||
continue;
|
||||
},
|
||||
Some(i) =>
|
||||
(load_block_entry(store.as_ref(), &TEST_CONFIG, &hash).unwrap().unwrap(), i),
|
||||
Some(i) => {
|
||||
(load_block_entry(store.as_ref(), &TEST_CONFIG, &hash).unwrap().unwrap(), i)
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(entry.candidates.len(), with_candidates.len());
|
||||
|
||||
@@ -132,10 +132,10 @@ impl<'a, B: 'a + Backend> OverlayedBackend<'a, B> {
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.block_entries.is_empty() &&
|
||||
self.candidate_entries.is_empty() &&
|
||||
self.blocks_at_height.is_empty() &&
|
||||
self.stored_block_range == BlockRangeStatus::NotModified
|
||||
self.block_entries.is_empty()
|
||||
&& self.candidate_entries.is_empty()
|
||||
&& self.blocks_at_height.is_empty()
|
||||
&& self.stored_block_range == BlockRangeStatus::NotModified
|
||||
}
|
||||
|
||||
pub fn load_all_blocks(&self) -> SubsystemResult<Vec<Hash>> {
|
||||
|
||||
@@ -241,9 +241,9 @@ pub fn compute_assignments(
|
||||
leaving_cores: impl IntoIterator<Item = (CandidateHash, CoreIndex, GroupIndex)> + Clone,
|
||||
enable_v2_assignments: bool,
|
||||
) -> HashMap<CoreIndex, OurAssignment> {
|
||||
if config.n_cores == 0 ||
|
||||
config.assignment_keys.is_empty() ||
|
||||
config.validator_groups.is_empty()
|
||||
if config.n_cores == 0
|
||||
|| config.assignment_keys.is_empty()
|
||||
|| config.validator_groups.is_empty()
|
||||
{
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -262,8 +262,9 @@ pub fn compute_assignments(
|
||||
Ok(Some(pair)) => Some((ValidatorIndex(i as _), pair)),
|
||||
Ok(None) => None,
|
||||
Err(pezsc_keystore::Error::Unavailable) => None,
|
||||
Err(pezsc_keystore::Error::Io(e)) if e.kind() == std::io::ErrorKind::NotFound =>
|
||||
None,
|
||||
Err(pezsc_keystore::Error::Io(e)) if e.kind() == std::io::ErrorKind::NotFound => {
|
||||
None
|
||||
},
|
||||
Err(e) => {
|
||||
gum::warn!(target: LOG_TARGET, "Encountered keystore error: {:?}", e);
|
||||
None
|
||||
@@ -504,13 +505,14 @@ fn compute_relay_vrf_delay_assignments(
|
||||
let _ = e.insert(our_assignment);
|
||||
true
|
||||
},
|
||||
Entry::Occupied(mut e) =>
|
||||
Entry::Occupied(mut e) => {
|
||||
if e.get().tranche() > our_assignment.tranche() {
|
||||
e.insert(our_assignment);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if used {
|
||||
@@ -556,8 +558,8 @@ pub(crate) fn check_assignment_cert(
|
||||
.map_err(|_| InvalidAssignment(Reason::InvalidAssignmentKey))?;
|
||||
|
||||
// Check that we have all backing groups for claimed cores.
|
||||
if claimed_core_indices.count_ones() == 0 ||
|
||||
claimed_core_indices.count_ones() != backing_groups.len()
|
||||
if claimed_core_indices.count_ones() == 0
|
||||
|| claimed_core_indices.count_ones() != backing_groups.len()
|
||||
{
|
||||
return Err(InvalidAssignment(Reason::InvalidArguments));
|
||||
}
|
||||
@@ -1070,8 +1072,8 @@ mod tests {
|
||||
fn check_rejects_modulo_core_wrong() {
|
||||
check_mutated_assignments(200, 100, 25, |m| {
|
||||
match m.cert.kind.clone() {
|
||||
AssignmentCertKindV2::RelayVRFModulo { .. } |
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { .. } => {
|
||||
AssignmentCertKindV2::RelayVRFModulo { .. }
|
||||
| AssignmentCertKindV2::RelayVRFModuloCompact { .. } => {
|
||||
m.cores = CoreIndex((m.cores.first_one().unwrap() + 1) as u32 % 100).into();
|
||||
|
||||
Some(false)
|
||||
|
||||
@@ -135,15 +135,17 @@ async fn imported_block_info<Sender: SubsystemSender<RuntimeApiMessage>>(
|
||||
let events: Vec<CandidateEvent> = match c_rx.await {
|
||||
Ok(Ok(events)) => events,
|
||||
Ok(Err(error)) => return Err(ImportedBlockInfoError::RuntimeError(error)),
|
||||
Err(error) =>
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("CandidateEvents", error)),
|
||||
Err(error) => {
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("CandidateEvents", error))
|
||||
},
|
||||
};
|
||||
|
||||
events
|
||||
.into_iter()
|
||||
.filter_map(|e| match e {
|
||||
CandidateEvent::CandidateIncluded(receipt, _, core, group) =>
|
||||
Some((receipt.hash(), receipt, core, group)),
|
||||
CandidateEvent::CandidateIncluded(receipt, _, core, group) => {
|
||||
Some((receipt.hash(), receipt, core, group))
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
@@ -163,8 +165,9 @@ async fn imported_block_info<Sender: SubsystemSender<RuntimeApiMessage>>(
|
||||
let session_index = match s_rx.await {
|
||||
Ok(Ok(s)) => s,
|
||||
Ok(Err(error)) => return Err(ImportedBlockInfoError::RuntimeError(error)),
|
||||
Err(error) =>
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("SessionIndexForChild", error)),
|
||||
Err(error) => {
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("SessionIndexForChild", error))
|
||||
},
|
||||
};
|
||||
|
||||
// We can't determine if the block is finalized or not - try processing it
|
||||
@@ -214,8 +217,9 @@ async fn imported_block_info<Sender: SubsystemSender<RuntimeApiMessage>>(
|
||||
match s_rx.await {
|
||||
Ok(Ok(s)) => s,
|
||||
Ok(Err(error)) => return Err(ImportedBlockInfoError::RuntimeError(error)),
|
||||
Err(error) =>
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("CurrentBabeEpoch", error)),
|
||||
Err(error) => {
|
||||
return Err(ImportedBlockInfoError::FutureCancelled("CurrentBabeEpoch", error))
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -941,8 +941,8 @@ impl NoShowStats {
|
||||
// Print the no-show stats if NO_SHOW_DUMP_FREQUENCY blocks have passed since the last
|
||||
// print.
|
||||
fn maybe_print(&mut self, current_block_number: BlockNumber) {
|
||||
if self.last_dumped_block_number > current_block_number ||
|
||||
current_block_number - self.last_dumped_block_number < NO_SHOW_DUMP_FREQUENCY
|
||||
if self.last_dumped_block_number > current_block_number
|
||||
|| current_block_number - self.last_dumped_block_number < NO_SHOW_DUMP_FREQUENCY
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1763,10 +1763,12 @@ fn get_core_indices_on_startup(
|
||||
) -> CoreBitfield {
|
||||
match &assignment {
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } => core_bitfield.clone(),
|
||||
AssignmentCertKindV2::RelayVRFModulo { sample: _ } =>
|
||||
CoreBitfield::try_from(vec![block_entry_core_index]).expect("Not an empty vec; qed"),
|
||||
AssignmentCertKindV2::RelayVRFDelay { core_index } =>
|
||||
CoreBitfield::try_from(vec![*core_index]).expect("Not an empty vec; qed"),
|
||||
AssignmentCertKindV2::RelayVRFModulo { sample: _ } => {
|
||||
CoreBitfield::try_from(vec![block_entry_core_index]).expect("Not an empty vec; qed")
|
||||
},
|
||||
AssignmentCertKindV2::RelayVRFDelay { core_index } => {
|
||||
CoreBitfield::try_from(vec![*core_index]).expect("Not an empty vec; qed")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1779,8 +1781,9 @@ fn get_assignment_core_indices(
|
||||
block_entry: &BlockEntry,
|
||||
) -> Option<CoreBitfield> {
|
||||
match &assignment {
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } =>
|
||||
Some(core_bitfield.clone()),
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } => {
|
||||
Some(core_bitfield.clone())
|
||||
},
|
||||
AssignmentCertKindV2::RelayVRFModulo { sample: _ } => block_entry
|
||||
.candidates()
|
||||
.iter()
|
||||
@@ -1788,8 +1791,9 @@ fn get_assignment_core_indices(
|
||||
.map(|(core_index, _candidate_hash)| {
|
||||
CoreBitfield::try_from(vec![*core_index]).expect("Not an empty vec; qed")
|
||||
}),
|
||||
AssignmentCertKindV2::RelayVRFDelay { core_index } =>
|
||||
Some(CoreBitfield::try_from(vec![*core_index]).expect("Not an empty vec; qed")),
|
||||
AssignmentCertKindV2::RelayVRFDelay { core_index } => {
|
||||
Some(CoreBitfield::try_from(vec![*core_index]).expect("Not an empty vec; qed"))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2701,13 +2705,14 @@ where
|
||||
|
||||
let block_entry = match db.load_block_entry(&assignment.block_hash)? {
|
||||
Some(b) => b,
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::UnknownBlock(
|
||||
assignment.block_hash,
|
||||
)),
|
||||
Vec::new(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
|
||||
let session_info = match get_session_info_by_index(
|
||||
@@ -2719,13 +2724,14 @@ where
|
||||
.await
|
||||
{
|
||||
Some(s) => s,
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::UnknownSessionIndex(
|
||||
block_entry.session(),
|
||||
)),
|
||||
Vec::new(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
|
||||
let n_cores = session_info.n_cores as usize;
|
||||
@@ -2756,25 +2762,27 @@ where
|
||||
let (claimed_core_index, assigned_candidate_hash) =
|
||||
match block_entry.candidate(candidate_index) {
|
||||
Some((c, h)) => (*c, *h),
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::InvalidCandidateIndex(
|
||||
candidate_index as _,
|
||||
)),
|
||||
Vec::new(),
|
||||
)), // no candidate at core.
|
||||
))
|
||||
}, // no candidate at core.
|
||||
};
|
||||
|
||||
let mut candidate_entry = match db.load_candidate_entry(&assigned_candidate_hash)? {
|
||||
Some(c) => c,
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::InvalidCandidate(
|
||||
candidate_index as _,
|
||||
assigned_candidate_hash,
|
||||
)),
|
||||
Vec::new(),
|
||||
)), // no candidate at core.
|
||||
))
|
||||
}, // no candidate at core.
|
||||
};
|
||||
|
||||
if candidate_entry.approval_entry_mut(&assignment.block_hash).is_none() {
|
||||
@@ -2811,26 +2819,28 @@ where
|
||||
{
|
||||
let mut candidate_entry = match db.load_candidate_entry(&assigned_candidate_hash)? {
|
||||
Some(c) => c,
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::InvalidCandidate(
|
||||
candidate_index as _,
|
||||
*assigned_candidate_hash,
|
||||
)),
|
||||
Vec::new(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
|
||||
let approval_entry = match candidate_entry.approval_entry_mut(&assignment.block_hash) {
|
||||
Some(a) => a,
|
||||
None =>
|
||||
None => {
|
||||
return Ok((
|
||||
AssignmentCheckResult::Bad(AssignmentCheckError::Internal(
|
||||
assignment.block_hash,
|
||||
*assigned_candidate_hash,
|
||||
)),
|
||||
Vec::new(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
|
||||
let is_duplicate_for_candidate = approval_entry.is_assigned(assignment.validator);
|
||||
@@ -3024,8 +3034,8 @@ enum ApprovalStateTransition {
|
||||
impl ApprovalStateTransition {
|
||||
fn validator_index(&self) -> Option<ValidatorIndex> {
|
||||
match *self {
|
||||
ApprovalStateTransition::RemoteApproval(v) |
|
||||
ApprovalStateTransition::LocalApproval(v) => Some(v),
|
||||
ApprovalStateTransition::RemoteApproval(v)
|
||||
| ApprovalStateTransition::LocalApproval(v) => Some(v),
|
||||
ApprovalStateTransition::WakeupProcessed => None,
|
||||
}
|
||||
}
|
||||
@@ -3210,9 +3220,9 @@ where
|
||||
.as_ref()
|
||||
.map(|validator_index| fork_approval_entry.is_assigned(*validator_index))
|
||||
.unwrap_or_default();
|
||||
if wakeups.wakeup_for(*fork_block_hash, candidate_hash).is_none() &&
|
||||
!fork_approval_entry.is_approved() &&
|
||||
assigned_on_fork_block
|
||||
if wakeups.wakeup_for(*fork_block_hash, candidate_hash).is_none()
|
||||
&& !fork_approval_entry.is_approved()
|
||||
&& assigned_on_fork_block
|
||||
{
|
||||
let fork_block_entry = db.load_block_entry(fork_block_hash);
|
||||
if let Ok(Some(fork_block_entry)) = fork_block_entry {
|
||||
@@ -3275,8 +3285,8 @@ fn should_trigger_assignment(
|
||||
RequiredTranches::Pending { maximum_broadcast, clock_drift, .. } => {
|
||||
let drifted_tranche_now =
|
||||
tranche_now.saturating_sub(clock_drift as DelayTranche);
|
||||
assignment.tranche() <= maximum_broadcast &&
|
||||
assignment.tranche() <= drifted_tranche_now
|
||||
assignment.tranche() <= maximum_broadcast
|
||||
&& assignment.tranche() <= drifted_tranche_now
|
||||
},
|
||||
RequiredTranches::Exact { .. } => {
|
||||
// indicates that no new assignments are needed at the moment.
|
||||
|
||||
@@ -642,8 +642,8 @@ impl BlockEntry {
|
||||
.map(|val| val.sign_no_later_than_tick);
|
||||
|
||||
if let Some(sign_no_later_than_tick) = sign_no_later_than_tick {
|
||||
if sign_no_later_than_tick <= tick_now ||
|
||||
self.num_candidates_pending_signature() >= max_approval_coalesce_count as usize
|
||||
if sign_no_later_than_tick <= tick_now
|
||||
|| self.num_candidates_pending_signature() >= max_approval_coalesce_count as usize
|
||||
{
|
||||
(
|
||||
self.candidate_indices_pending_signature().and_then(|candidate_indices| {
|
||||
|
||||
@@ -5722,8 +5722,8 @@ fn test_gathering_assignments_statements() {
|
||||
CandidateHash(Hash::repeat_byte(i as u8)),
|
||||
);
|
||||
assert!(
|
||||
state.per_block_assignments_gathering_times.len() <=
|
||||
MAX_BLOCKS_WITH_ASSIGNMENT_TIMESTAMPS as usize
|
||||
state.per_block_assignments_gathering_times.len()
|
||||
<= MAX_BLOCKS_WITH_ASSIGNMENT_TIMESTAMPS as usize
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
||||
@@ -1263,8 +1263,8 @@ async fn has_all_chunks(
|
||||
expect_present: bool,
|
||||
) -> bool {
|
||||
for i in 0..n_validators {
|
||||
if query_chunk(virtual_overseer, candidate_hash, ValidatorIndex(i)).await.is_some() !=
|
||||
expect_present
|
||||
if query_chunk(virtual_overseer, candidate_hash, ValidatorIndex(i)).await.is_some()
|
||||
!= expect_present
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -831,7 +831,7 @@ async fn validate_and_make_available(
|
||||
|
||||
let pov = match pov {
|
||||
PoVData::Ready(pov) => pov,
|
||||
PoVData::FetchFromValidator { from_validator, candidate_hash, pov_hash } =>
|
||||
PoVData::FetchFromValidator { from_validator, candidate_hash, pov_hash } => {
|
||||
match request_pov(
|
||||
&mut sender,
|
||||
relay_parent,
|
||||
@@ -854,7 +854,8 @@ async fn validate_and_make_available(
|
||||
},
|
||||
Err(err) => return Err(err),
|
||||
Ok(pov) => pov,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let v = {
|
||||
@@ -945,10 +946,12 @@ async fn handle_communication<Context>(
|
||||
CandidateBackingMessage::Statement(relay_parent, statement) => {
|
||||
handle_statement_message(ctx, state, relay_parent, statement, metrics).await?;
|
||||
},
|
||||
CandidateBackingMessage::GetBackableCandidates(requested_candidates, tx) =>
|
||||
handle_get_backable_candidates_message(state, requested_candidates, tx, metrics)?,
|
||||
CandidateBackingMessage::CanSecond(request, tx) =>
|
||||
handle_can_second_request(ctx, state, request, tx).await,
|
||||
CandidateBackingMessage::GetBackableCandidates(requested_candidates, tx) => {
|
||||
handle_get_backable_candidates_message(state, requested_candidates, tx, metrics)?
|
||||
},
|
||||
CandidateBackingMessage::CanSecond(request, tx) => {
|
||||
handle_can_second_request(ctx, state, request, tx).await
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -51,8 +51,9 @@ struct TestLeaf {
|
||||
|
||||
fn table_statement_to_primitive(statement: TableStatement) -> Statement {
|
||||
match statement {
|
||||
TableStatement::Seconded(committed_candidate_receipt) =>
|
||||
Statement::Seconded(committed_candidate_receipt),
|
||||
TableStatement::Seconded(committed_candidate_receipt) => {
|
||||
Statement::Seconded(committed_candidate_receipt)
|
||||
},
|
||||
TableStatement::Valid(candidate_hash) => Statement::Valid(candidate_hash),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,8 +421,9 @@ async fn handle_active_leaves_update<Sender>(
|
||||
|
||||
if let Some(activated) = update.activated {
|
||||
let maybe_new_session_index = match (prepare_state.session_index, maybe_session_index) {
|
||||
(Some(existing_index), Some(new_index)) =>
|
||||
(new_index > existing_index).then_some(new_index),
|
||||
(Some(existing_index), Some(new_index)) => {
|
||||
(new_index > existing_index).then_some(new_index)
|
||||
},
|
||||
(None, Some(new_index)) => Some(new_index),
|
||||
_ => None,
|
||||
};
|
||||
@@ -837,12 +838,13 @@ where
|
||||
|
||||
match validation_backend.precheck_pvf(pvf).await {
|
||||
Ok(_) => PreCheckOutcome::Valid,
|
||||
Err(prepare_err) =>
|
||||
Err(prepare_err) => {
|
||||
if prepare_err.is_deterministic() {
|
||||
PreCheckOutcome::Invalid
|
||||
} else {
|
||||
PreCheckOutcome::Failed
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -875,10 +877,11 @@ async fn validate_candidate_exhaustive(
|
||||
|
||||
// We only check the session index for backing.
|
||||
match (exec_kind, candidate_receipt.descriptor.session_index()) {
|
||||
(PvfExecKind::Backing(_) | PvfExecKind::BackingSystemParas(_), Some(session_index)) =>
|
||||
(PvfExecKind::Backing(_) | PvfExecKind::BackingSystemParas(_), Some(session_index)) => {
|
||||
if session_index != expected_session_index {
|
||||
return Ok(ValidationResult::Invalid(InvalidCandidate::InvalidSessionIndex));
|
||||
},
|
||||
}
|
||||
},
|
||||
(_, _) => {},
|
||||
};
|
||||
|
||||
@@ -918,7 +921,7 @@ async fn validate_candidate_exhaustive(
|
||||
)
|
||||
.await
|
||||
},
|
||||
PvfExecKind::Approval | PvfExecKind::Dispute =>
|
||||
PvfExecKind::Approval | PvfExecKind::Dispute => {
|
||||
validation_backend
|
||||
.validate_candidate_with_retry(
|
||||
validation_code.0,
|
||||
@@ -931,7 +934,8 @@ async fn validate_candidate_exhaustive(
|
||||
exec_kind,
|
||||
validation_code_bomb_limit,
|
||||
)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
};
|
||||
|
||||
if let Err(ref error) = result {
|
||||
@@ -949,27 +953,35 @@ async fn validate_candidate_exhaustive(
|
||||
);
|
||||
Err(ValidationFailed(e.to_string()))
|
||||
},
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::HardTimeout)) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::Timeout)),
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::WorkerReportedInvalid(e))) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(e))),
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::PoVDecompressionFailure)) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::PoVDecompressionFailure)),
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::AmbiguousWorkerDeath)) =>
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::HardTimeout)) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::Timeout))
|
||||
},
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::WorkerReportedInvalid(e))) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(e)))
|
||||
},
|
||||
Err(ValidationError::Invalid(WasmInvalidCandidate::PoVDecompressionFailure)) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::PoVDecompressionFailure))
|
||||
},
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::AmbiguousWorkerDeath)) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(
|
||||
"ambiguous worker death".to_string(),
|
||||
))),
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::JobError(err))) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err))),
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::RuntimeConstruction(err))) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err))),
|
||||
Err(ValidationError::PossiblyInvalid(err @ PossiblyInvalidError::CorruptedArtifact)) =>
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err.to_string()))),
|
||||
)))
|
||||
},
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::JobError(err))) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err)))
|
||||
},
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::RuntimeConstruction(err))) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err)))
|
||||
},
|
||||
Err(ValidationError::PossiblyInvalid(err @ PossiblyInvalidError::CorruptedArtifact)) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(err.to_string())))
|
||||
},
|
||||
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::AmbiguousJobDeath(err))) =>
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::AmbiguousJobDeath(err))) => {
|
||||
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(format!(
|
||||
"ambiguous job death: {err}"
|
||||
)))),
|
||||
))))
|
||||
},
|
||||
Err(ValidationError::Preparation(e)) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1005,8 +1017,8 @@ async fn validate_candidate_exhaustive(
|
||||
},
|
||||
};
|
||||
|
||||
if candidate_receipt.commitments_hash !=
|
||||
committed_candidate_receipt.commitments.hash()
|
||||
if candidate_receipt.commitments_hash
|
||||
!= committed_candidate_receipt.commitments.hash()
|
||||
{
|
||||
gum::info!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1158,8 +1170,8 @@ trait ValidationBackend {
|
||||
let mut retry_immediately = false;
|
||||
match validation_result {
|
||||
Err(ValidationError::PossiblyInvalid(
|
||||
PossiblyInvalidError::AmbiguousWorkerDeath |
|
||||
PossiblyInvalidError::AmbiguousJobDeath(_),
|
||||
PossiblyInvalidError::AmbiguousWorkerDeath
|
||||
| PossiblyInvalidError::AmbiguousJobDeath(_),
|
||||
)) => break_if_no_retries_left!(num_death_retries_left),
|
||||
|
||||
Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::JobError(_))) => {
|
||||
@@ -1171,8 +1183,8 @@ trait ValidationBackend {
|
||||
},
|
||||
|
||||
Err(ValidationError::PossiblyInvalid(
|
||||
PossiblyInvalidError::RuntimeConstruction(_) |
|
||||
PossiblyInvalidError::CorruptedArtifact,
|
||||
PossiblyInvalidError::RuntimeConstruction(_)
|
||||
| PossiblyInvalidError::CorruptedArtifact,
|
||||
)) => {
|
||||
break_if_no_retries_left!(num_execution_error_retries_left);
|
||||
self.precheck_pvf(pvf.clone()).await?;
|
||||
@@ -1183,11 +1195,11 @@ trait ValidationBackend {
|
||||
retry_immediately = true;
|
||||
},
|
||||
|
||||
Ok(_) |
|
||||
Err(
|
||||
ValidationError::Invalid(_) |
|
||||
ValidationError::Preparation(_) |
|
||||
ValidationError::ExecutionDeadline,
|
||||
Ok(_)
|
||||
| Err(
|
||||
ValidationError::Invalid(_)
|
||||
| ValidationError::Preparation(_)
|
||||
| ValidationError::ExecutionDeadline,
|
||||
) => break,
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ impl Backend for DbBackend {
|
||||
block_entry.encode(),
|
||||
);
|
||||
},
|
||||
BackendWriteOp::WriteBlocksByNumber(block_number, v) =>
|
||||
BackendWriteOp::WriteBlocksByNumber(block_number, v) => {
|
||||
if v.is_empty() {
|
||||
tx.delete(self.config.col_data, &block_height_key(block_number));
|
||||
} else {
|
||||
@@ -299,7 +299,8 @@ impl Backend for DbBackend {
|
||||
&block_height_key(block_number),
|
||||
v.encode(),
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
BackendWriteOp::WriteViableLeaves(leaves) => {
|
||||
let leaves: LeafEntrySet = leaves.into();
|
||||
if leaves.inner.is_empty() {
|
||||
|
||||
@@ -224,10 +224,11 @@ fn propagate_viability_update(
|
||||
// finalized block is implicitly the viable leaf.
|
||||
continue;
|
||||
},
|
||||
Some(entry) =>
|
||||
Some(entry) => {
|
||||
if entry.children.len() == pivot_count {
|
||||
viable_leaves.insert(entry.leaf_entry());
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,9 +86,9 @@ impl<'a, B: 'a + Backend> OverlayedBackend<'a, B> {
|
||||
|
||||
/// Returns true if the are no write operations to perform.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.earliest_session.is_none() &&
|
||||
self.recent_disputes.is_none() &&
|
||||
self.candidate_votes.is_empty()
|
||||
self.earliest_session.is_none()
|
||||
&& self.recent_disputes.is_none()
|
||||
&& self.candidate_votes.is_empty()
|
||||
}
|
||||
|
||||
/// Load the earliest session, if any.
|
||||
|
||||
@@ -81,8 +81,9 @@ impl<'a> CandidateEnvironment<'a> {
|
||||
.get_session_info_by_index(ctx.sender(), relay_parent, session_index)
|
||||
.await
|
||||
{
|
||||
Ok(extended_session_info) =>
|
||||
(&extended_session_info.session_info, &extended_session_info.executor_params),
|
||||
Ok(extended_session_info) => {
|
||||
(&extended_session_info.session_info, &extended_session_info.executor_params)
|
||||
},
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
@@ -553,8 +554,8 @@ impl ImportResult {
|
||||
/// Whether or not the invalid vote count for the dispute went beyond the byzantine threshold
|
||||
/// after the last import
|
||||
pub fn has_fresh_byzantine_threshold_against(&self) -> bool {
|
||||
!self.old_state().byzantine_threshold_against &&
|
||||
self.new_state().byzantine_threshold_against
|
||||
!self.old_state().byzantine_threshold_against
|
||||
&& self.new_state().byzantine_threshold_against
|
||||
}
|
||||
|
||||
/// Modify this `ImportResult`s, by importing additional approval votes.
|
||||
|
||||
@@ -279,8 +279,9 @@ impl Initialized {
|
||||
self.scraper.process_finalized_block(&n);
|
||||
default_confirm
|
||||
},
|
||||
FromOrchestra::Communication { msg } =>
|
||||
self.handle_incoming(ctx, &mut overlay_db, msg, clock.now()).await?,
|
||||
FromOrchestra::Communication { msg } => {
|
||||
self.handle_incoming(ctx, &mut overlay_db, msg, clock.now()).await?
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -948,8 +949,9 @@ impl Initialized {
|
||||
let candidate_hash = candidate_receipt.hash();
|
||||
let votes_in_db = overlay_db.load_candidate_votes(session, &candidate_hash)?;
|
||||
let relay_parent = match &candidate_receipt {
|
||||
MaybeCandidateReceipt::Provides(candidate_receipt) =>
|
||||
candidate_receipt.descriptor().relay_parent(),
|
||||
MaybeCandidateReceipt::Provides(candidate_receipt) => {
|
||||
candidate_receipt.descriptor().relay_parent()
|
||||
},
|
||||
MaybeCandidateReceipt::AssumeBackingVotePresent(candidate_hash) => match &votes_in_db {
|
||||
Some(votes) => votes.candidate_receipt.descriptor().relay_parent(),
|
||||
None => {
|
||||
@@ -1006,7 +1008,7 @@ impl Initialized {
|
||||
// not have a `CandidateReceipt` available.
|
||||
let old_state = match votes_in_db.map(CandidateVotes::from) {
|
||||
Some(votes) => CandidateVoteState::new(votes, &env, now),
|
||||
None =>
|
||||
None => {
|
||||
if let MaybeCandidateReceipt::Provides(candidate_receipt) = candidate_receipt {
|
||||
CandidateVoteState::new_from_receipt(candidate_receipt)
|
||||
} else {
|
||||
@@ -1017,7 +1019,8 @@ impl Initialized {
|
||||
"Cannot import votes, without `CandidateReceipt` available!"
|
||||
);
|
||||
return Ok(ImportStatementsResult::InvalidImport);
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
gum::trace!(target: LOG_TARGET, ?candidate_hash, ?session, "Loaded votes");
|
||||
@@ -1026,8 +1029,8 @@ impl Initialized {
|
||||
let own_statements = statements
|
||||
.iter()
|
||||
.filter(|(statement, validator_index)| {
|
||||
controlled_indices.contains(validator_index) &&
|
||||
*statement.candidate_hash() == candidate_hash
|
||||
controlled_indices.contains(validator_index)
|
||||
&& *statement.candidate_hash() == candidate_hash
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
@@ -1039,8 +1042,8 @@ impl Initialized {
|
||||
//
|
||||
// See guide: We import on fresh disputes to maximize likelihood of fetching votes for
|
||||
// dead forks and once concluded to maximize time for approval votes to trickle in.
|
||||
if intermediate_result.is_freshly_disputed() ||
|
||||
intermediate_result.is_freshly_concluded()
|
||||
if intermediate_result.is_freshly_disputed()
|
||||
|| intermediate_result.is_freshly_concluded()
|
||||
{
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1587,8 +1590,8 @@ impl Initialized {
|
||||
continue;
|
||||
};
|
||||
// Check if all invalid voters (raising parties) are disabled
|
||||
if !votes.invalid.is_empty() &&
|
||||
votes.invalid.iter().all(|(_, validator_index, _)| {
|
||||
if !votes.invalid.is_empty()
|
||||
&& votes.invalid.iter().all(|(_, validator_index, _)| {
|
||||
self.offchain_disabled_validators.is_disabled(session, *validator_index)
|
||||
}) {
|
||||
disputes_to_remove.push((*dispute_session, *candidate_hash));
|
||||
@@ -1833,9 +1836,9 @@ impl OffchainDisabledValidators {
|
||||
self.per_session
|
||||
.get(&session_index)
|
||||
.map(|session_disputes| {
|
||||
session_disputes.backers_for_invalid.peek(&validator_index).is_some() ||
|
||||
session_disputes.for_invalid.peek(&validator_index).is_some() ||
|
||||
session_disputes.against_valid.peek(&validator_index).is_some()
|
||||
session_disputes.backers_for_invalid.peek(&validator_index).is_some()
|
||||
|| session_disputes.for_invalid.peek(&validator_index).is_some()
|
||||
|| session_disputes.against_valid.peek(&validator_index).is_some()
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
@@ -171,10 +171,10 @@ impl PartialEq for ParticipationRequest {
|
||||
executor_params,
|
||||
request_timer: _,
|
||||
} = self;
|
||||
candidate_receipt == other.candidate_receipt() &&
|
||||
candidate_hash == other.candidate_hash() &&
|
||||
*session == other.session() &&
|
||||
executor_params.hash() == other.executor_params.hash()
|
||||
candidate_receipt == other.candidate_receipt()
|
||||
&& candidate_hash == other.candidate_hash()
|
||||
&& *session == other.session()
|
||||
&& executor_params.hash() == other.executor_params.hash()
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -256,8 +256,8 @@ fn reqs_get_queued_when_out_of_capacity() {
|
||||
let mut recover_available_data_msg_count = 0;
|
||||
let mut block_number_msg_count = 0;
|
||||
|
||||
while recover_available_data_msg_count < MAX_PARALLEL_PARTICIPATIONS + 1 ||
|
||||
block_number_msg_count < 1
|
||||
while recover_available_data_msg_count < MAX_PARALLEL_PARTICIPATIONS + 1
|
||||
|| block_number_msg_count < 1
|
||||
{
|
||||
match ctx_handle.recv().await {
|
||||
AllMessages::AvailabilityRecovery(
|
||||
|
||||
@@ -427,9 +427,9 @@ impl ChainScraper {
|
||||
for (block_number, hash) in block_numbers.zip(&hashes) {
|
||||
// Return if we either met target/cached block or
|
||||
// hit the size limit for the returned ancestry of head.
|
||||
if self.last_observed_blocks.get(hash).is_some() ||
|
||||
block_number <= target_ancestor ||
|
||||
ancestors.len() >= Self::ANCESTRY_SIZE_LIMIT as usize
|
||||
if self.last_observed_blocks.get(hash).is_some()
|
||||
|| block_number <= target_ancestor
|
||||
|| ancestors.len() >= Self::ANCESTRY_SIZE_LIMIT as usize
|
||||
{
|
||||
return Ok(ancestors);
|
||||
}
|
||||
|
||||
@@ -427,8 +427,8 @@ fn scraper_requests_candidates_of_non_finalized_ancestors() {
|
||||
&mut virtual_overseer,
|
||||
&chain,
|
||||
finalized_block_number,
|
||||
BLOCKS_TO_SKIP -
|
||||
(finalized_block_number - DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION) as usize, /* Expect the provider not to go past finalized block. */
|
||||
BLOCKS_TO_SKIP
|
||||
- (finalized_block_number - DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION) as usize, /* Expect the provider not to go past finalized block. */
|
||||
get_backed_and_included_candidate_events,
|
||||
);
|
||||
join(process_active_leaves_update(ctx.sender(), &mut ordering, next_update), overseer_fut)
|
||||
@@ -532,8 +532,8 @@ fn scraper_handles_backed_but_not_included_candidate() {
|
||||
// Bump the finalized block outside `BACKED_CANDIDATE_LIFETIME_AFTER_FINALIZATION`.
|
||||
// The candidate should be removed.
|
||||
assert!(
|
||||
finalized_block_number <
|
||||
TEST_TARGET_BLOCK_NUMBER + DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION
|
||||
finalized_block_number
|
||||
< TEST_TARGET_BLOCK_NUMBER + DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION
|
||||
);
|
||||
finalized_block_number +=
|
||||
TEST_TARGET_BLOCK_NUMBER + DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION;
|
||||
@@ -583,8 +583,8 @@ fn scraper_handles_the_same_candidate_included_in_two_different_block_heights()
|
||||
// Finalize blocks to enforce pruning of scraped events.
|
||||
// The magic candidate was added twice, so it shouldn't be removed if we finalize two more
|
||||
// blocks.
|
||||
finalized_block_number = test_targets.first().expect("there are two block nums") +
|
||||
DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION;
|
||||
finalized_block_number = test_targets.first().expect("there are two block nums")
|
||||
+ DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION;
|
||||
process_finalized_block(&mut scraper, &finalized_block_number);
|
||||
|
||||
let magic_candidate = make_candidate_receipt(get_magic_candidate_hash());
|
||||
|
||||
@@ -123,8 +123,9 @@ async fn generate_opposing_votes_pair(
|
||||
valid_vote_type: VoteType,
|
||||
) -> (SignedDisputeStatement, SignedDisputeStatement) {
|
||||
let valid_vote = match valid_vote_type {
|
||||
VoteType::Backing =>
|
||||
test_state.issue_backing_statement_with_index(valid_voter_idx, candidate_hash, session),
|
||||
VoteType::Backing => {
|
||||
test_state.issue_backing_statement_with_index(valid_voter_idx, candidate_hash, session)
|
||||
},
|
||||
VoteType::Explicit => test_state.issue_explicit_statement_with_index(
|
||||
valid_voter_idx,
|
||||
candidate_hash,
|
||||
|
||||
@@ -768,8 +768,8 @@ impl FragmentChain {
|
||||
|
||||
/// Return whether this candidate is backed in this chain or the unconnected storage.
|
||||
pub fn is_candidate_backed(&self, hash: &CandidateHash) -> bool {
|
||||
self.best_chain.candidates.contains(hash) ||
|
||||
matches!(
|
||||
self.best_chain.candidates.contains(hash)
|
||||
|| matches!(
|
||||
self.unconnected.by_candidate_hash.get(hash),
|
||||
Some(candidate) if candidate.state == CandidateState::Backed
|
||||
)
|
||||
|
||||
@@ -156,10 +156,12 @@ async fn run_iteration<Context>(
|
||||
},
|
||||
FromOrchestra::Signal(OverseerSignal::BlockFinalized(..)) => {},
|
||||
FromOrchestra::Communication { msg } => match msg {
|
||||
ProspectiveTeyrchainsMessage::IntroduceSecondedCandidate(request, tx) =>
|
||||
handle_introduce_seconded_candidate(view, request, tx, metrics).await,
|
||||
ProspectiveTeyrchainsMessage::CandidateBacked(para, candidate_hash) =>
|
||||
handle_candidate_backed(view, para, candidate_hash, metrics).await,
|
||||
ProspectiveTeyrchainsMessage::IntroduceSecondedCandidate(request, tx) => {
|
||||
handle_introduce_seconded_candidate(view, request, tx, metrics).await
|
||||
},
|
||||
ProspectiveTeyrchainsMessage::CandidateBacked(para, candidate_hash) => {
|
||||
handle_candidate_backed(view, para, candidate_hash, metrics).await
|
||||
},
|
||||
ProspectiveTeyrchainsMessage::GetBackableCandidates(
|
||||
relay_parent,
|
||||
para,
|
||||
@@ -167,12 +169,15 @@ async fn run_iteration<Context>(
|
||||
ancestors,
|
||||
tx,
|
||||
) => answer_get_backable_candidates(&view, relay_parent, para, count, ancestors, tx),
|
||||
ProspectiveTeyrchainsMessage::GetHypotheticalMembership(request, tx) =>
|
||||
answer_hypothetical_membership_request(&view, request, tx, metrics),
|
||||
ProspectiveTeyrchainsMessage::GetMinimumRelayParents(relay_parent, tx) =>
|
||||
answer_minimum_relay_parents_request(&view, relay_parent, tx),
|
||||
ProspectiveTeyrchainsMessage::GetProspectiveValidationData(request, tx) =>
|
||||
answer_prospective_validation_data_request(&view, request, tx),
|
||||
ProspectiveTeyrchainsMessage::GetHypotheticalMembership(request, tx) => {
|
||||
answer_hypothetical_membership_request(&view, request, tx, metrics)
|
||||
},
|
||||
ProspectiveTeyrchainsMessage::GetMinimumRelayParents(relay_parent, tx) => {
|
||||
answer_minimum_relay_parents_request(&view, relay_parent, tx)
|
||||
},
|
||||
ProspectiveTeyrchainsMessage::GetProspectiveValidationData(request, tx) => {
|
||||
answer_prospective_validation_data_request(&view, request, tx)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,9 +343,9 @@ async fn handle_leaf_activation(
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
parent,
|
||||
RuntimeApiRequest::BackingConstraints(p_id, tx),
|
||||
)) if parent == *hash &&
|
||||
test_state.runtime_api_version >=
|
||||
RuntimeApiRequest::CONSTRAINTS_RUNTIME_REQUIREMENT =>
|
||||
)) if parent == *hash
|
||||
&& test_state.runtime_api_version
|
||||
>= RuntimeApiRequest::CONSTRAINTS_RUNTIME_REQUIREMENT =>
|
||||
{
|
||||
let PerParaData { min_relay_parent, head_data, pending_availability: _ } =
|
||||
leaf.para_data(p_id);
|
||||
@@ -362,9 +362,9 @@ async fn handle_leaf_activation(
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
parent,
|
||||
RuntimeApiRequest::BackingConstraints(_p_id, tx),
|
||||
)) if parent == *hash &&
|
||||
test_state.runtime_api_version <
|
||||
RuntimeApiRequest::CONSTRAINTS_RUNTIME_REQUIREMENT =>
|
||||
)) if parent == *hash
|
||||
&& test_state.runtime_api_version
|
||||
< RuntimeApiRequest::CONSTRAINTS_RUNTIME_REQUIREMENT =>
|
||||
{
|
||||
tx.send(Err(RUNTIME_API_NOT_SUPPORTED)).unwrap();
|
||||
None
|
||||
|
||||
@@ -332,8 +332,8 @@ fn concluded_onchain(onchain_state: &DisputeState) -> bool {
|
||||
// Check if there are enough onchain votes for or against to conclude the dispute
|
||||
let supermajority = supermajority_threshold(onchain_state.validators_for.len());
|
||||
|
||||
onchain_state.validators_for.count_ones() >= supermajority ||
|
||||
onchain_state.validators_against.count_ones() >= supermajority
|
||||
onchain_state.validators_for.count_ones() >= supermajority
|
||||
|| onchain_state.validators_against.count_ones() >= supermajority
|
||||
}
|
||||
|
||||
fn partition_recent_disputes(
|
||||
@@ -347,7 +347,7 @@ fn partition_recent_disputes(
|
||||
let key = (session_index, candidate_hash);
|
||||
if dispute_is_inactive(&dispute_state, time_now) {
|
||||
match onchain.get(&key) {
|
||||
Some(onchain_state) =>
|
||||
Some(onchain_state) => {
|
||||
if concluded_onchain(onchain_state) {
|
||||
partitioned
|
||||
.inactive_concluded_onchain
|
||||
@@ -356,16 +356,19 @@ fn partition_recent_disputes(
|
||||
partitioned
|
||||
.inactive_unconcluded_onchain
|
||||
.push((session_index, candidate_hash));
|
||||
},
|
||||
}
|
||||
},
|
||||
None => partitioned.inactive_unknown_onchain.push((session_index, candidate_hash)),
|
||||
}
|
||||
} else {
|
||||
match onchain.get(&(session_index, candidate_hash)) {
|
||||
Some(d) => match concluded_onchain(d) {
|
||||
true =>
|
||||
partitioned.active_concluded_onchain.push((session_index, candidate_hash)),
|
||||
false =>
|
||||
partitioned.active_unconcluded_onchain.push((session_index, candidate_hash)),
|
||||
true => {
|
||||
partitioned.active_concluded_onchain.push((session_index, candidate_hash))
|
||||
},
|
||||
false => {
|
||||
partitioned.active_unconcluded_onchain.push((session_index, candidate_hash))
|
||||
},
|
||||
},
|
||||
None => partitioned.active_unknown_onchain.push((session_index, candidate_hash)),
|
||||
}
|
||||
@@ -389,8 +392,8 @@ fn is_vote_worth_to_keep(
|
||||
// punished when misbehaving.
|
||||
if let Some(kind) = valid_kind {
|
||||
match kind {
|
||||
ValidDisputeStatementKind::BackingValid(_) |
|
||||
ValidDisputeStatementKind::BackingSeconded(_) => return true,
|
||||
ValidDisputeStatementKind::BackingValid(_)
|
||||
| ValidDisputeStatementKind::BackingSeconded(_) => return true,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -491,10 +494,12 @@ where
|
||||
.map_err(|_| GetOnchainDisputesError::Channel)
|
||||
.and_then(|res| {
|
||||
res.map_err(|e| match e {
|
||||
RuntimeApiError::Execution { .. } =>
|
||||
GetOnchainDisputesError::Execution(e, relay_parent),
|
||||
RuntimeApiError::NotSupported { .. } =>
|
||||
GetOnchainDisputesError::NotSupported(e, relay_parent),
|
||||
RuntimeApiError::Execution { .. } => {
|
||||
GetOnchainDisputesError::Execution(e, relay_parent)
|
||||
},
|
||||
RuntimeApiError::NotSupported { .. } => {
|
||||
GetOnchainDisputesError::NotSupported(e, relay_parent)
|
||||
},
|
||||
})
|
||||
})
|
||||
.map(|v| v.into_iter().map(|e| ((e.0, e.1), e.2)).collect())
|
||||
|
||||
@@ -666,8 +666,8 @@ fn many_batches() {
|
||||
let vote_count = result.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v);
|
||||
|
||||
assert!(
|
||||
MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count &&
|
||||
vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME,
|
||||
MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count
|
||||
&& vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME,
|
||||
"vote_count: {}",
|
||||
vote_count
|
||||
);
|
||||
@@ -720,8 +720,8 @@ fn votes_above_limit() {
|
||||
let vote_count = result.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v);
|
||||
|
||||
assert!(
|
||||
MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count &&
|
||||
vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME,
|
||||
MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count
|
||||
&& vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME,
|
||||
"vote_count: {}",
|
||||
vote_count
|
||||
);
|
||||
|
||||
@@ -396,8 +396,9 @@ fn note_provisionable_data(
|
||||
provisionable_data: ProvisionableData,
|
||||
) {
|
||||
match provisionable_data {
|
||||
ProvisionableData::Bitfield(_, signed_bitfield) =>
|
||||
per_relay_parent.signed_bitfields.push(signed_bitfield),
|
||||
ProvisionableData::Bitfield(_, signed_bitfield) => {
|
||||
per_relay_parent.signed_bitfields.push(signed_bitfield)
|
||||
},
|
||||
// We choose not to punish these forms of misbehavior for the time being.
|
||||
// Risks from misbehavior are sufficiently mitigated at the protocol level
|
||||
// via reputation changes. Punitive actions here may become desirable
|
||||
|
||||
@@ -572,8 +572,9 @@ mod select_candidates {
|
||||
_parent_hash,
|
||||
PersistedValidationDataReq(_para_id, _assumption, tx),
|
||||
)) => tx.send(Ok(Some(Default::default()))).unwrap(),
|
||||
AllMessages::RuntimeApi(Request(_parent_hash, AvailabilityCores(tx))) =>
|
||||
tx.send(Ok(mock_availability_cores.clone())).unwrap(),
|
||||
AllMessages::RuntimeApi(Request(_parent_hash, AvailabilityCores(tx))) => {
|
||||
tx.send(Ok(mock_availability_cores.clone())).unwrap()
|
||||
},
|
||||
AllMessages::CandidateBacking(CandidateBackingMessage::GetBackableCandidates(
|
||||
hashes,
|
||||
sender,
|
||||
|
||||
@@ -380,14 +380,15 @@ async fn examine_activation(
|
||||
};
|
||||
|
||||
let new_session_index = match runtime_api::session_index_for_child(sender, leaf_hash).await {
|
||||
Ok(session_index) =>
|
||||
Ok(session_index) => {
|
||||
if state.latest_session.map_or(true, |l| l < session_index) {
|
||||
let signing_credentials =
|
||||
check_signing_credentials(sender, keystore, leaf_hash).await;
|
||||
Some((session_index, signing_credentials))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -110,17 +110,17 @@ impl PrepareError {
|
||||
pub fn is_deterministic(&self) -> bool {
|
||||
use PrepareError::*;
|
||||
match self {
|
||||
Prevalidation(_) |
|
||||
Preparation(_) |
|
||||
JobError(_) |
|
||||
OutOfMemory |
|
||||
CouldNotDecompressCodeBlob(_) => true,
|
||||
IoErr(_) |
|
||||
JobDied { .. } |
|
||||
CreateTmpFile(_) |
|
||||
RenameTmpFile { .. } |
|
||||
ClearWorkerDir(_) |
|
||||
Kernel(_) => false,
|
||||
Prevalidation(_)
|
||||
| Preparation(_)
|
||||
| JobError(_)
|
||||
| OutOfMemory
|
||||
| CouldNotDecompressCodeBlob(_) => true,
|
||||
IoErr(_)
|
||||
| JobDied { .. }
|
||||
| CreateTmpFile(_)
|
||||
| RenameTmpFile { .. }
|
||||
| ClearWorkerDir(_)
|
||||
| Kernel(_) => false,
|
||||
// Can occur due to issues with the PVF, but also due to factors like local load.
|
||||
TimedOut => false,
|
||||
// Can occur due to issues with the PVF, but also due to local errors.
|
||||
|
||||
@@ -160,16 +160,17 @@ pub fn params_to_wasmtime_semantics(par: &ExecutorParams) -> (Semantics, Determi
|
||||
|
||||
for p in par.iter() {
|
||||
match p {
|
||||
ExecutorParam::MaxMemoryPages(max_pages) =>
|
||||
ExecutorParam::MaxMemoryPages(max_pages) => {
|
||||
sem.heap_alloc_strategy = HeapAllocStrategy::Dynamic {
|
||||
maximum_pages: Some((*max_pages).saturating_add(DEFAULT_HEAP_PAGES_ESTIMATE)),
|
||||
},
|
||||
}
|
||||
},
|
||||
ExecutorParam::StackLogicalMax(slm) => stack_limit.logical_max = *slm,
|
||||
ExecutorParam::StackNativeMax(snm) => stack_limit.native_stack_max = *snm,
|
||||
ExecutorParam::WasmExtBulkMemory => sem.wasm_bulk_memory = true,
|
||||
ExecutorParam::PrecheckingMaxMemory(_) |
|
||||
ExecutorParam::PvfPrepTimeout(_, _) |
|
||||
ExecutorParam::PvfExecTimeout(_, _) => (), /* Not used here */
|
||||
ExecutorParam::PrecheckingMaxMemory(_)
|
||||
| ExecutorParam::PvfPrepTimeout(_, _)
|
||||
| ExecutorParam::PvfExecTimeout(_, _) => (), /* Not used here */
|
||||
}
|
||||
}
|
||||
sem.deterministic_stack_limit = Some(stack_limit.clone());
|
||||
|
||||
@@ -133,8 +133,8 @@ impl fmt::Debug for PvfPrepData {
|
||||
|
||||
impl PartialEq for PvfPrepData {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.code_hash == other.code_hash &&
|
||||
self.executor_params.hash() == other.executor_params.hash()
|
||||
self.code_hash == other.code_hash
|
||||
&& self.executor_params.hash() == other.executor_params.hash()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -562,8 +562,8 @@ fn recv_worker_handshake(stream: &mut UnixStream) -> io::Result<WorkerHandshake>
|
||||
///
|
||||
/// Returns a `Duration` representing the total CPU time.
|
||||
pub fn get_total_cpu_usage(rusage: Usage) -> Duration {
|
||||
let micros = (((rusage.user_time().tv_sec() + rusage.system_time().tv_sec()) * 1_000_000) +
|
||||
(rusage.system_time().tv_usec() + rusage.user_time().tv_usec()) as i64) as u64;
|
||||
let micros = (((rusage.user_time().tv_sec() + rusage.system_time().tv_sec()) * 1_000_000)
|
||||
+ (rusage.system_time().tv_usec() + rusage.user_time().tv_usec()) as i64) as u64;
|
||||
|
||||
return Duration::from_micros(micros);
|
||||
}
|
||||
|
||||
@@ -121,11 +121,12 @@ fn try_restrict(worker_info: &WorkerInfo) -> Result<()> {
|
||||
worker_dir_path_c.as_ptr(),
|
||||
worker_dir_path_c.as_ptr(),
|
||||
ptr::null(), // ignored when MS_BIND is used
|
||||
libc::MS_BIND |
|
||||
libc::MS_REC | libc::MS_NOEXEC |
|
||||
libc::MS_NODEV | libc::MS_NOSUID |
|
||||
libc::MS_NOATIME |
|
||||
additional_flags,
|
||||
libc::MS_BIND
|
||||
| libc::MS_REC | libc::MS_NOEXEC
|
||||
| libc::MS_NODEV
|
||||
| libc::MS_NOSUID
|
||||
| libc::MS_NOATIME
|
||||
| additional_flags,
|
||||
ptr::null(), // ignored when MS_BIND is used
|
||||
) < 0
|
||||
{
|
||||
|
||||
@@ -82,12 +82,12 @@ fn clone_flags(have_unshare_newuser: bool) -> CloneFlags {
|
||||
// SIGCHLD flag is used to inform clone that the parent process is
|
||||
// expecting a child termination signal, without this flag `waitpid` function
|
||||
// return `ECHILD` error.
|
||||
maybe_clone_newuser |
|
||||
CloneFlags::CLONE_NEWCGROUP |
|
||||
CloneFlags::CLONE_NEWIPC |
|
||||
CloneFlags::CLONE_NEWNET |
|
||||
CloneFlags::CLONE_NEWNS |
|
||||
CloneFlags::CLONE_NEWPID |
|
||||
CloneFlags::CLONE_NEWUTS |
|
||||
CloneFlags::from_bits_retain(libc::SIGCHLD)
|
||||
maybe_clone_newuser
|
||||
| CloneFlags::CLONE_NEWCGROUP
|
||||
| CloneFlags::CLONE_NEWIPC
|
||||
| CloneFlags::CLONE_NEWNET
|
||||
| CloneFlags::CLONE_NEWNS
|
||||
| CloneFlags::CLONE_NEWPID
|
||||
| CloneFlags::CLONE_NEWUTS
|
||||
| CloneFlags::from_bits_retain(libc::SIGCHLD)
|
||||
}
|
||||
|
||||
@@ -319,18 +319,20 @@ fn validate_using_artifact(
|
||||
// [`executor_interface::prepare`].
|
||||
execute_artifact(compiled_artifact_blob, executor_params, params)
|
||||
} {
|
||||
Err(ExecuteError::RuntimeConstruction(wasmerr)) =>
|
||||
return JobResponse::runtime_construction("execute", &wasmerr.to_string()),
|
||||
Err(ExecuteError::RuntimeConstruction(wasmerr)) => {
|
||||
return JobResponse::runtime_construction("execute", &wasmerr.to_string())
|
||||
},
|
||||
Err(err) => return JobResponse::format_invalid("execute", &err.to_string()),
|
||||
Ok(d) => d,
|
||||
};
|
||||
|
||||
let result_descriptor = match ValidationResult::decode(&mut &descriptor_bytes[..]) {
|
||||
Err(err) =>
|
||||
Err(err) => {
|
||||
return JobResponse::format_invalid(
|
||||
"validation result decoding failed",
|
||||
&err.to_string(),
|
||||
),
|
||||
)
|
||||
},
|
||||
Ok(r) => r,
|
||||
};
|
||||
|
||||
@@ -383,8 +385,9 @@ fn handle_clone(
|
||||
pov_size,
|
||||
execution_timeout,
|
||||
),
|
||||
Err(security::clone::Error::Clone(errno)) =>
|
||||
Ok(Err(internal_error_from_errno("clone", errno))),
|
||||
Err(security::clone::Error::Clone(errno)) => {
|
||||
Ok(Err(internal_error_from_errno("clone", errno)))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,8 +243,8 @@ impl Artifacts {
|
||||
let Some(file_name) = path.file_name().and_then(|f| f.to_str()) else { continue };
|
||||
if path.is_dir() && file_name.starts_with(WORKER_DIR_PREFIX) {
|
||||
let _ = fs::remove_dir_all(path);
|
||||
} else if path.extension().map_or(false, |ext| ext == ARTIFACT_EXTENSION) ||
|
||||
file_name.starts_with(ARTIFACT_OLD_PREFIX)
|
||||
} else if path.extension().map_or(false, |ext| ext == ARTIFACT_EXTENSION)
|
||||
|| file_name.starts_with(ARTIFACT_OLD_PREFIX)
|
||||
{
|
||||
let _ = fs::remove_file(path);
|
||||
}
|
||||
|
||||
@@ -524,14 +524,16 @@ async fn handle_job_finish(
|
||||
)
|
||||
},
|
||||
|
||||
Err(WorkerInterfaceError::InternalError(err)) |
|
||||
Err(WorkerInterfaceError::WorkerError(WorkerError::InternalError(err))) =>
|
||||
(None, Err(ValidationError::Internal(err)), None, None, None),
|
||||
Err(WorkerInterfaceError::InternalError(err))
|
||||
| Err(WorkerInterfaceError::WorkerError(WorkerError::InternalError(err))) => {
|
||||
(None, Err(ValidationError::Internal(err)), None, None, None)
|
||||
},
|
||||
// Either the worker or the job timed out. Kill the worker in either case. Treated as
|
||||
// definitely-invalid, because if we timed out, there's no time left for a retry.
|
||||
Err(WorkerInterfaceError::HardTimeout) |
|
||||
Err(WorkerInterfaceError::WorkerError(WorkerError::JobTimedOut)) =>
|
||||
(None, Err(ValidationError::Invalid(InvalidCandidate::HardTimeout)), None, None, None),
|
||||
Err(WorkerInterfaceError::HardTimeout)
|
||||
| Err(WorkerInterfaceError::WorkerError(WorkerError::JobTimedOut)) => {
|
||||
(None, Err(ValidationError::Invalid(InvalidCandidate::HardTimeout)), None, None, None)
|
||||
},
|
||||
// "Maybe invalid" errors (will retry).
|
||||
Err(WorkerInterfaceError::CommunicationErr(_err)) => (
|
||||
None,
|
||||
|
||||
@@ -533,10 +533,12 @@ async fn handle_to_host(
|
||||
handle_execute_pvf(artifacts, prepare_queue, execute_queue, awaiting_prepare, inputs)
|
||||
.await?;
|
||||
},
|
||||
ToHost::HeadsUp { active_pvfs } =>
|
||||
handle_heads_up(artifacts, prepare_queue, active_pvfs).await?,
|
||||
ToHost::UpdateActiveLeaves { update, ancestors } =>
|
||||
handle_update_active_leaves(execute_queue, update, ancestors).await?,
|
||||
ToHost::HeadsUp { active_pvfs } => {
|
||||
handle_heads_up(artifacts, prepare_queue, active_pvfs).await?
|
||||
},
|
||||
ToHost::UpdateActiveLeaves { update, ancestors } => {
|
||||
handle_update_active_leaves(execute_queue, update, ancestors).await?
|
||||
},
|
||||
#[cfg(feature = "test-utils")]
|
||||
ToHost::ReplaceArtifactChecksum { checksum, new_checksum } => {
|
||||
artifacts.replace_artifact_checksum(checksum, new_checksum);
|
||||
@@ -567,8 +569,9 @@ async fn handle_precheck_pvf(
|
||||
*last_time_needed = SystemTime::now();
|
||||
let _ = result_sender.send(Ok(()));
|
||||
},
|
||||
ArtifactState::Preparing { waiting_for_response, num_failures: _ } =>
|
||||
waiting_for_response.push(result_sender),
|
||||
ArtifactState::Preparing { waiting_for_response, num_failures: _ } => {
|
||||
waiting_for_response.push(result_sender)
|
||||
},
|
||||
ArtifactState::FailedToProcess { error, .. } => {
|
||||
// Do not retry an artifact that previously failed preparation.
|
||||
let _ = result_sender.send(PrecheckResult::Err(error.clone()));
|
||||
@@ -887,8 +890,9 @@ async fn handle_prepare_done(
|
||||
}
|
||||
|
||||
*state = match result {
|
||||
Ok(PrepareSuccess { checksum, path, size, .. }) =>
|
||||
ArtifactState::Prepared { checksum, path, last_time_needed: SystemTime::now(), size },
|
||||
Ok(PrepareSuccess { checksum, path, size, .. }) => {
|
||||
ArtifactState::Prepared { checksum, path, last_time_needed: SystemTime::now(), size }
|
||||
},
|
||||
Err(error) => {
|
||||
let last_time_failed = SystemTime::now();
|
||||
let num_failures = *num_failures + 1;
|
||||
@@ -1033,8 +1037,8 @@ fn can_retry_prepare_after_failure(
|
||||
|
||||
// Retry if the retry cooldown has elapsed and if we have already retried less than
|
||||
// `NUM_PREPARE_RETRIES` times. IO errors may resolve themselves.
|
||||
SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN &&
|
||||
num_failures <= NUM_PREPARE_RETRIES
|
||||
SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN
|
||||
&& num_failures <= NUM_PREPARE_RETRIES
|
||||
}
|
||||
|
||||
/// A stream that yields a pulse continuously at a given interval.
|
||||
|
||||
@@ -330,8 +330,9 @@ fn handle_mux(
|
||||
// If we receive an outcome that the worker is unreachable or that an error occurred on
|
||||
// the worker, we attempt to kill the worker process.
|
||||
match outcome {
|
||||
Outcome::Concluded { worker: idle, result } =>
|
||||
handle_concluded_no_rip(from_pool, spawned, worker, idle, result),
|
||||
Outcome::Concluded { worker: idle, result } => {
|
||||
handle_concluded_no_rip(from_pool, spawned, worker, idle, result)
|
||||
},
|
||||
// Return `Concluded`, but do not kill the worker since the error was on the host
|
||||
// side.
|
||||
Outcome::CreateTmpFileErr { worker: idle, err } => handle_concluded_no_rip(
|
||||
|
||||
@@ -271,8 +271,9 @@ async fn handle_from_pool(queue: &mut Queue, from_pool: pool::FromPool) -> Resul
|
||||
use pool::FromPool;
|
||||
match from_pool {
|
||||
FromPool::Spawned(worker) => handle_worker_spawned(queue, worker).await?,
|
||||
FromPool::Concluded { worker, rip, result } =>
|
||||
handle_worker_concluded(queue, worker, rip, result).await?,
|
||||
FromPool::Concluded { worker, rip, result } => {
|
||||
handle_worker_concluded(queue, worker, rip, result).await?
|
||||
},
|
||||
FromPool::Rip(worker) => handle_worker_rip(queue, worker).await?,
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -157,7 +157,7 @@ pub async fn start_work(
|
||||
|
||||
match result {
|
||||
// Received bytes from worker within the time limit.
|
||||
Ok(Ok(prepare_worker_result)) =>
|
||||
Ok(Ok(prepare_worker_result)) => {
|
||||
handle_response(
|
||||
metrics,
|
||||
IdleWorker { stream, pid, worker_dir },
|
||||
@@ -167,7 +167,8 @@ pub async fn start_work(
|
||||
&cache_path,
|
||||
preparation_timeout,
|
||||
)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
Ok(Err(err)) => {
|
||||
// Communication error within the time limit.
|
||||
gum::warn!(
|
||||
|
||||
@@ -105,8 +105,8 @@ impl FullSecurityStatus {
|
||||
}
|
||||
|
||||
fn all_errs_allowed(&self) -> bool {
|
||||
!self.partial.secure_validator_mode ||
|
||||
self.errs.iter().all(|err| err.is_allowed_in_secure_mode(&self.partial))
|
||||
!self.partial.secure_validator_mode
|
||||
|| self.errs.iter().all(|err| err.is_allowed_in_secure_mode(&self.partial))
|
||||
}
|
||||
|
||||
fn errs_string(&self) -> String {
|
||||
@@ -141,8 +141,9 @@ impl SecureModeError {
|
||||
match self {
|
||||
// Landlock is present on relatively recent Linuxes. This is optional if the unshare
|
||||
// capability is present, providing FS sandboxing a different way.
|
||||
CannotEnableLandlock { .. } =>
|
||||
security_status.can_unshare_user_namespace_and_change_root,
|
||||
CannotEnableLandlock { .. } => {
|
||||
security_status.can_unshare_user_namespace_and_change_root
|
||||
},
|
||||
// seccomp should be present on all modern Linuxes unless it's been disabled.
|
||||
CannotEnableSeccomp(_) => false,
|
||||
// Should always be present on modern Linuxes. If not, Landlock also provides FS
|
||||
|
||||
@@ -97,17 +97,21 @@ where
|
||||
use RequestResult::*;
|
||||
|
||||
match result {
|
||||
Authorities(relay_parent, authorities) =>
|
||||
self.requests_cache.cache_authorities(relay_parent, authorities),
|
||||
Validators(relay_parent, validators) =>
|
||||
self.requests_cache.cache_validators(relay_parent, validators),
|
||||
Authorities(relay_parent, authorities) => {
|
||||
self.requests_cache.cache_authorities(relay_parent, authorities)
|
||||
},
|
||||
Validators(relay_parent, validators) => {
|
||||
self.requests_cache.cache_validators(relay_parent, validators)
|
||||
},
|
||||
MinimumBackingVotes(session_index, minimum_backing_votes) => self
|
||||
.requests_cache
|
||||
.cache_minimum_backing_votes(session_index, minimum_backing_votes),
|
||||
ValidatorGroups(relay_parent, groups) =>
|
||||
self.requests_cache.cache_validator_groups(relay_parent, groups),
|
||||
AvailabilityCores(relay_parent, cores) =>
|
||||
self.requests_cache.cache_availability_cores(relay_parent, cores),
|
||||
ValidatorGroups(relay_parent, groups) => {
|
||||
self.requests_cache.cache_validator_groups(relay_parent, groups)
|
||||
},
|
||||
AvailabilityCores(relay_parent, cores) => {
|
||||
self.requests_cache.cache_availability_cores(relay_parent, cores)
|
||||
},
|
||||
PersistedValidationData(relay_parent, para_id, assumption, data) => self
|
||||
.requests_cache
|
||||
.cache_persisted_validation_data((relay_parent, para_id, assumption), data),
|
||||
@@ -123,66 +127,82 @@ where
|
||||
CheckValidationOutputs(relay_parent, para_id, commitments, b) => self
|
||||
.requests_cache
|
||||
.cache_check_validation_outputs((relay_parent, para_id, commitments), b),
|
||||
SessionIndexForChild(relay_parent, session_index) =>
|
||||
self.requests_cache.cache_session_index_for_child(relay_parent, session_index),
|
||||
SessionIndexForChild(relay_parent, session_index) => {
|
||||
self.requests_cache.cache_session_index_for_child(relay_parent, session_index)
|
||||
},
|
||||
ValidationCode(relay_parent, para_id, assumption, code) => self
|
||||
.requests_cache
|
||||
.cache_validation_code((relay_parent, para_id, assumption), code),
|
||||
ValidationCodeByHash(_relay_parent, validation_code_hash, code) =>
|
||||
self.requests_cache.cache_validation_code_by_hash(validation_code_hash, code),
|
||||
ValidationCodeByHash(_relay_parent, validation_code_hash, code) => {
|
||||
self.requests_cache.cache_validation_code_by_hash(validation_code_hash, code)
|
||||
},
|
||||
CandidatePendingAvailability(relay_parent, para_id, candidate) => self
|
||||
.requests_cache
|
||||
.cache_candidate_pending_availability((relay_parent, para_id), candidate),
|
||||
CandidatesPendingAvailability(relay_parent, para_id, candidates) => self
|
||||
.requests_cache
|
||||
.cache_candidates_pending_availability((relay_parent, para_id), candidates),
|
||||
CandidateEvents(relay_parent, events) =>
|
||||
self.requests_cache.cache_candidate_events(relay_parent, events),
|
||||
SessionExecutorParams(_relay_parent, session_index, index) =>
|
||||
self.requests_cache.cache_session_executor_params(session_index, index),
|
||||
SessionInfo(_relay_parent, session_index, info) =>
|
||||
CandidateEvents(relay_parent, events) => {
|
||||
self.requests_cache.cache_candidate_events(relay_parent, events)
|
||||
},
|
||||
SessionExecutorParams(_relay_parent, session_index, index) => {
|
||||
self.requests_cache.cache_session_executor_params(session_index, index)
|
||||
},
|
||||
SessionInfo(_relay_parent, session_index, info) => {
|
||||
if let Some(info) = info {
|
||||
self.requests_cache.cache_session_info(session_index, info);
|
||||
},
|
||||
DmqContents(relay_parent, para_id, messages) =>
|
||||
self.requests_cache.cache_dmq_contents((relay_parent, para_id), messages),
|
||||
}
|
||||
},
|
||||
DmqContents(relay_parent, para_id, messages) => {
|
||||
self.requests_cache.cache_dmq_contents((relay_parent, para_id), messages)
|
||||
},
|
||||
InboundHrmpChannelsContents(relay_parent, para_id, contents) => self
|
||||
.requests_cache
|
||||
.cache_inbound_hrmp_channel_contents((relay_parent, para_id), contents),
|
||||
CurrentBabeEpoch(relay_parent, epoch) =>
|
||||
self.requests_cache.cache_current_babe_epoch(relay_parent, epoch),
|
||||
FetchOnChainVotes(relay_parent, scraped) =>
|
||||
self.requests_cache.cache_on_chain_votes(relay_parent, scraped),
|
||||
PvfsRequirePrecheck(relay_parent, pvfs) =>
|
||||
self.requests_cache.cache_pvfs_require_precheck(relay_parent, pvfs),
|
||||
CurrentBabeEpoch(relay_parent, epoch) => {
|
||||
self.requests_cache.cache_current_babe_epoch(relay_parent, epoch)
|
||||
},
|
||||
FetchOnChainVotes(relay_parent, scraped) => {
|
||||
self.requests_cache.cache_on_chain_votes(relay_parent, scraped)
|
||||
},
|
||||
PvfsRequirePrecheck(relay_parent, pvfs) => {
|
||||
self.requests_cache.cache_pvfs_require_precheck(relay_parent, pvfs)
|
||||
},
|
||||
SubmitPvfCheckStatement(()) => {},
|
||||
ValidationCodeHash(relay_parent, para_id, assumption, hash) => self
|
||||
.requests_cache
|
||||
.cache_validation_code_hash((relay_parent, para_id, assumption), hash),
|
||||
Version(relay_parent, version) =>
|
||||
self.requests_cache.cache_version(relay_parent, version),
|
||||
Disputes(relay_parent, disputes) =>
|
||||
self.requests_cache.cache_disputes(relay_parent, disputes),
|
||||
UnappliedSlashes(relay_parent, unapplied_slashes) =>
|
||||
self.requests_cache.cache_unapplied_slashes(relay_parent, unapplied_slashes),
|
||||
Version(relay_parent, version) => {
|
||||
self.requests_cache.cache_version(relay_parent, version)
|
||||
},
|
||||
Disputes(relay_parent, disputes) => {
|
||||
self.requests_cache.cache_disputes(relay_parent, disputes)
|
||||
},
|
||||
UnappliedSlashes(relay_parent, unapplied_slashes) => {
|
||||
self.requests_cache.cache_unapplied_slashes(relay_parent, unapplied_slashes)
|
||||
},
|
||||
UnappliedSlashesV2(relay_parent, unapplied_slashes_v2) => self
|
||||
.requests_cache
|
||||
.cache_unapplied_slashes_v2(relay_parent, unapplied_slashes_v2),
|
||||
KeyOwnershipProof(relay_parent, validator_id, key_ownership_proof) => self
|
||||
.requests_cache
|
||||
.cache_key_ownership_proof((relay_parent, validator_id), key_ownership_proof),
|
||||
ApprovalVotingParams(_relay_parent, session_index, params) =>
|
||||
self.requests_cache.cache_approval_voting_params(session_index, params),
|
||||
ApprovalVotingParams(_relay_parent, session_index, params) => {
|
||||
self.requests_cache.cache_approval_voting_params(session_index, params)
|
||||
},
|
||||
SubmitReportDisputeLost(_) => {},
|
||||
DisabledValidators(relay_parent, disabled_validators) =>
|
||||
self.requests_cache.cache_disabled_validators(relay_parent, disabled_validators),
|
||||
DisabledValidators(relay_parent, disabled_validators) => {
|
||||
self.requests_cache.cache_disabled_validators(relay_parent, disabled_validators)
|
||||
},
|
||||
ParaBackingState(relay_parent, para_id, constraints) => self
|
||||
.requests_cache
|
||||
.cache_para_backing_state((relay_parent, para_id), constraints),
|
||||
AsyncBackingParams(relay_parent, params) =>
|
||||
self.requests_cache.cache_async_backing_params(relay_parent, params),
|
||||
NodeFeatures(session_index, params) =>
|
||||
self.requests_cache.cache_node_features(session_index, params),
|
||||
AsyncBackingParams(relay_parent, params) => {
|
||||
self.requests_cache.cache_async_backing_params(relay_parent, params)
|
||||
},
|
||||
NodeFeatures(session_index, params) => {
|
||||
self.requests_cache.cache_node_features(session_index, params)
|
||||
},
|
||||
ClaimQueue(relay_parent, sender) => {
|
||||
self.requests_cache.cache_claim_queue(relay_parent, sender);
|
||||
},
|
||||
@@ -192,8 +212,9 @@ where
|
||||
SchedulingLookahead(session_index, scheduling_lookahead) => self
|
||||
.requests_cache
|
||||
.cache_scheduling_lookahead(session_index, scheduling_lookahead),
|
||||
ValidationCodeBombLimit(session_index, limit) =>
|
||||
self.requests_cache.cache_validation_code_bomb_limit(session_index, limit),
|
||||
ValidationCodeBombLimit(session_index, limit) => {
|
||||
self.requests_cache.cache_validation_code_bomb_limit(session_index, limit)
|
||||
},
|
||||
ParaIds(session_index, para_ids) => {
|
||||
self.requests_cache.cache_para_ids(session_index, para_ids);
|
||||
},
|
||||
@@ -227,19 +248,24 @@ where
|
||||
}
|
||||
|
||||
match request {
|
||||
Request::Version(sender) =>
|
||||
query!(version(), sender).map(|sender| Request::Version(sender)),
|
||||
Request::Authorities(sender) =>
|
||||
query!(authorities(), sender).map(|sender| Request::Authorities(sender)),
|
||||
Request::Validators(sender) =>
|
||||
query!(validators(), sender).map(|sender| Request::Validators(sender)),
|
||||
Request::ValidatorGroups(sender) =>
|
||||
query!(validator_groups(), sender).map(|sender| Request::ValidatorGroups(sender)),
|
||||
Request::Version(sender) => {
|
||||
query!(version(), sender).map(|sender| Request::Version(sender))
|
||||
},
|
||||
Request::Authorities(sender) => {
|
||||
query!(authorities(), sender).map(|sender| Request::Authorities(sender))
|
||||
},
|
||||
Request::Validators(sender) => {
|
||||
query!(validators(), sender).map(|sender| Request::Validators(sender))
|
||||
},
|
||||
Request::ValidatorGroups(sender) => {
|
||||
query!(validator_groups(), sender).map(|sender| Request::ValidatorGroups(sender))
|
||||
},
|
||||
Request::AvailabilityCores(sender) => query!(availability_cores(), sender)
|
||||
.map(|sender| Request::AvailabilityCores(sender)),
|
||||
Request::PersistedValidationData(para, assumption, sender) =>
|
||||
Request::PersistedValidationData(para, assumption, sender) => {
|
||||
query!(persisted_validation_data(para, assumption), sender)
|
||||
.map(|sender| Request::PersistedValidationData(para, assumption, sender)),
|
||||
.map(|sender| Request::PersistedValidationData(para, assumption, sender))
|
||||
},
|
||||
Request::AssumedValidationData(
|
||||
para,
|
||||
expected_persisted_validation_data_hash,
|
||||
@@ -255,25 +281,31 @@ where
|
||||
sender,
|
||||
)
|
||||
}),
|
||||
Request::CheckValidationOutputs(para, commitments, sender) =>
|
||||
Request::CheckValidationOutputs(para, commitments, sender) => {
|
||||
query!(check_validation_outputs(para, commitments), sender)
|
||||
.map(|sender| Request::CheckValidationOutputs(para, commitments, sender)),
|
||||
.map(|sender| Request::CheckValidationOutputs(para, commitments, sender))
|
||||
},
|
||||
Request::SessionIndexForChild(sender) => query!(session_index_for_child(), sender)
|
||||
.map(|sender| Request::SessionIndexForChild(sender)),
|
||||
Request::ValidationCode(para, assumption, sender) =>
|
||||
Request::ValidationCode(para, assumption, sender) => {
|
||||
query!(validation_code(para, assumption), sender)
|
||||
.map(|sender| Request::ValidationCode(para, assumption, sender)),
|
||||
Request::ValidationCodeByHash(validation_code_hash, sender) =>
|
||||
.map(|sender| Request::ValidationCode(para, assumption, sender))
|
||||
},
|
||||
Request::ValidationCodeByHash(validation_code_hash, sender) => {
|
||||
query!(validation_code_by_hash(validation_code_hash), sender)
|
||||
.map(|sender| Request::ValidationCodeByHash(validation_code_hash, sender)),
|
||||
Request::CandidatePendingAvailability(para, sender) =>
|
||||
.map(|sender| Request::ValidationCodeByHash(validation_code_hash, sender))
|
||||
},
|
||||
Request::CandidatePendingAvailability(para, sender) => {
|
||||
query!(candidate_pending_availability(para), sender)
|
||||
.map(|sender| Request::CandidatePendingAvailability(para, sender)),
|
||||
Request::CandidatesPendingAvailability(para, sender) =>
|
||||
.map(|sender| Request::CandidatePendingAvailability(para, sender))
|
||||
},
|
||||
Request::CandidatesPendingAvailability(para, sender) => {
|
||||
query!(candidates_pending_availability(para), sender)
|
||||
.map(|sender| Request::CandidatesPendingAvailability(para, sender)),
|
||||
Request::CandidateEvents(sender) =>
|
||||
query!(candidate_events(), sender).map(|sender| Request::CandidateEvents(sender)),
|
||||
.map(|sender| Request::CandidatesPendingAvailability(para, sender))
|
||||
},
|
||||
Request::CandidateEvents(sender) => {
|
||||
query!(candidate_events(), sender).map(|sender| Request::CandidateEvents(sender))
|
||||
},
|
||||
Request::SessionExecutorParams(session_index, sender) => {
|
||||
if let Some(executor_params) =
|
||||
self.requests_cache.session_executor_params(session_index)
|
||||
@@ -294,42 +326,52 @@ where
|
||||
Some(Request::SessionInfo(index, sender))
|
||||
}
|
||||
},
|
||||
Request::DmqContents(id, sender) =>
|
||||
query!(dmq_contents(id), sender).map(|sender| Request::DmqContents(id, sender)),
|
||||
Request::InboundHrmpChannelsContents(id, sender) =>
|
||||
Request::DmqContents(id, sender) => {
|
||||
query!(dmq_contents(id), sender).map(|sender| Request::DmqContents(id, sender))
|
||||
},
|
||||
Request::InboundHrmpChannelsContents(id, sender) => {
|
||||
query!(inbound_hrmp_channels_contents(id), sender)
|
||||
.map(|sender| Request::InboundHrmpChannelsContents(id, sender)),
|
||||
Request::CurrentBabeEpoch(sender) =>
|
||||
query!(current_babe_epoch(), sender).map(|sender| Request::CurrentBabeEpoch(sender)),
|
||||
Request::FetchOnChainVotes(sender) =>
|
||||
query!(on_chain_votes(), sender).map(|sender| Request::FetchOnChainVotes(sender)),
|
||||
.map(|sender| Request::InboundHrmpChannelsContents(id, sender))
|
||||
},
|
||||
Request::CurrentBabeEpoch(sender) => {
|
||||
query!(current_babe_epoch(), sender).map(|sender| Request::CurrentBabeEpoch(sender))
|
||||
},
|
||||
Request::FetchOnChainVotes(sender) => {
|
||||
query!(on_chain_votes(), sender).map(|sender| Request::FetchOnChainVotes(sender))
|
||||
},
|
||||
Request::PvfsRequirePrecheck(sender) => query!(pvfs_require_precheck(), sender)
|
||||
.map(|sender| Request::PvfsRequirePrecheck(sender)),
|
||||
request @ Request::SubmitPvfCheckStatement(_, _, _) => {
|
||||
// This request is side-effecting and thus cannot be cached.
|
||||
Some(request)
|
||||
},
|
||||
Request::ValidationCodeHash(para, assumption, sender) =>
|
||||
Request::ValidationCodeHash(para, assumption, sender) => {
|
||||
query!(validation_code_hash(para, assumption), sender)
|
||||
.map(|sender| Request::ValidationCodeHash(para, assumption, sender)),
|
||||
Request::Disputes(sender) =>
|
||||
query!(disputes(), sender).map(|sender| Request::Disputes(sender)),
|
||||
Request::UnappliedSlashes(sender) =>
|
||||
query!(unapplied_slashes(), sender).map(|sender| Request::UnappliedSlashes(sender)),
|
||||
.map(|sender| Request::ValidationCodeHash(para, assumption, sender))
|
||||
},
|
||||
Request::Disputes(sender) => {
|
||||
query!(disputes(), sender).map(|sender| Request::Disputes(sender))
|
||||
},
|
||||
Request::UnappliedSlashes(sender) => {
|
||||
query!(unapplied_slashes(), sender).map(|sender| Request::UnappliedSlashes(sender))
|
||||
},
|
||||
Request::UnappliedSlashesV2(sender) => query!(unapplied_slashes_v2(), sender)
|
||||
.map(|sender| Request::UnappliedSlashesV2(sender)),
|
||||
Request::KeyOwnershipProof(validator_id, sender) =>
|
||||
Request::KeyOwnershipProof(validator_id, sender) => {
|
||||
query!(key_ownership_proof(validator_id), sender)
|
||||
.map(|sender| Request::KeyOwnershipProof(validator_id, sender)),
|
||||
Request::SubmitReportDisputeLost(dispute_proof, key_ownership_proof, sender) =>
|
||||
.map(|sender| Request::KeyOwnershipProof(validator_id, sender))
|
||||
},
|
||||
Request::SubmitReportDisputeLost(dispute_proof, key_ownership_proof, sender) => {
|
||||
query!(submit_report_dispute_lost(dispute_proof, key_ownership_proof), sender).map(
|
||||
|sender| {
|
||||
Request::SubmitReportDisputeLost(dispute_proof, key_ownership_proof, sender)
|
||||
},
|
||||
),
|
||||
Request::ApprovalVotingParams(session_index, sender) =>
|
||||
)
|
||||
},
|
||||
Request::ApprovalVotingParams(session_index, sender) => {
|
||||
query!(approval_voting_params(session_index), sender)
|
||||
.map(|sender| Request::ApprovalVotingParams(session_index, sender)),
|
||||
.map(|sender| Request::ApprovalVotingParams(session_index, sender))
|
||||
},
|
||||
Request::DisabledValidators(sender) => query!(disabled_validators(), sender)
|
||||
.map(|sender| Request::DisabledValidators(sender)),
|
||||
Request::ParaBackingState(para, sender) => query!(para_backing_state(para), sender)
|
||||
@@ -354,8 +396,9 @@ where
|
||||
Some(Request::NodeFeatures(index, sender))
|
||||
}
|
||||
},
|
||||
Request::ClaimQueue(sender) =>
|
||||
query!(claim_queue(), sender).map(|sender| Request::ClaimQueue(sender)),
|
||||
Request::ClaimQueue(sender) => {
|
||||
query!(claim_queue(), sender).map(|sender| Request::ClaimQueue(sender))
|
||||
},
|
||||
Request::BackingConstraints(para, sender) => query!(backing_constraints(para), sender)
|
||||
.map(|sender| Request::BackingConstraints(para, sender)),
|
||||
Request::SchedulingLookahead(index, sender) => {
|
||||
|
||||
Reference in New Issue
Block a user