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:
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user