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:
2025-12-22 17:12:58 +03:00
parent 3208f208c0
commit abc4c3989b
898 changed files with 8671 additions and 6432 deletions
@@ -64,8 +64,8 @@ impl PastSystemClock {
impl Clock for PastSystemClock {
fn tick_now(&self) -> Tick {
self.real_system_clock.tick_now() -
self.delta_ticks.load(std::sync::atomic::Ordering::SeqCst)
self.real_system_clock.tick_now()
- self.delta_ticks.load(std::sync::atomic::Ordering::SeqCst)
}
fn wait(
@@ -210,7 +210,7 @@ impl PeerMessagesGenerator {
// Receive all messages and sort them by Tick they have to be sent.
loop {
match rx.try_next() {
Ok(Some((block_hash, messages))) =>
Ok(Some((block_hash, messages))) => {
for message in messages {
let block_info = blocks
.iter()
@@ -223,7 +223,8 @@ impl PeerMessagesGenerator {
);
let to_add = all_messages.entry(tick_to_send).or_default();
to_add.push(message);
},
}
},
Ok(None) => break,
Err(_) => {
std::thread::sleep(Duration::from_millis(50));
@@ -326,8 +327,9 @@ impl PeerMessagesGenerator {
let mut unique_assignments = HashSet::new();
for (core_index, assignment) in assignments {
let assigned_cores = match &assignment.cert().kind {
approval::v2::AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } =>
core_bitfield.iter_ones().map(|val| CoreIndex::from(val as u32)).collect_vec(),
approval::v2::AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } => {
core_bitfield.iter_ones().map(|val| CoreIndex::from(val as u32)).collect_vec()
},
approval::v2::AssignmentCertKindV2::RelayVRFDelay { core_index } => {
vec![*core_index]
},
@@ -495,10 +497,10 @@ fn issue_approvals(
.map(|val| val.assignment.tranche)
.unwrap_or(message.tranche);
if queued_to_sign.len() >= num_coalesce ||
(!queued_to_sign.is_empty() &&
current_validator_index != assignment.0.validator) ||
message.tranche - earliest_tranche >= options.coalesce_tranche_diff
if queued_to_sign.len() >= num_coalesce
|| (!queued_to_sign.is_empty()
&& current_validator_index != assignment.0.validator)
|| message.tranche - earliest_tranche >= options.coalesce_tranche_diff
{
approvals_to_create.push(TestSignInfo::sign_candidates(
&mut queued_to_sign,
@@ -642,23 +644,23 @@ fn neighbours_that_would_sent_message(
.unwrap();
let originator_y = topology_originator.validator_indices_y.iter().find(|validator| {
topology_node_under_test.required_routing_by_index(**validator, false) ==
RequiredRouting::GridY
topology_node_under_test.required_routing_by_index(**validator, false)
== RequiredRouting::GridY
});
assert!(originator_y != Some(&ValidatorIndex(NODE_UNDER_TEST)));
let originator_x = topology_originator.validator_indices_x.iter().find(|validator| {
topology_node_under_test.required_routing_by_index(**validator, false) ==
RequiredRouting::GridX
topology_node_under_test.required_routing_by_index(**validator, false)
== RequiredRouting::GridX
});
assert!(originator_x != Some(&ValidatorIndex(NODE_UNDER_TEST)));
let is_neighbour = topology_originator
.validator_indices_x
.contains(&ValidatorIndex(NODE_UNDER_TEST)) ||
topology_originator
.contains(&ValidatorIndex(NODE_UNDER_TEST))
|| topology_originator
.validator_indices_y
.contains(&ValidatorIndex(NODE_UNDER_TEST));
@@ -45,7 +45,7 @@ impl MockChainSelection {
let msg = ctx.recv().await.expect("Should not fail");
match msg {
orchestra::FromOrchestra::Signal(_) => {},
orchestra::FromOrchestra::Communication { msg } =>
orchestra::FromOrchestra::Communication { msg } => {
if let ChainSelectionMessage::Approved(hash) = msg {
let block_info = self.state.get_info_by_hash(hash);
let approved_number = block_info.block_number;
@@ -55,11 +55,12 @@ impl MockChainSelection {
.last_approved_block
.store(approved_number, std::sync::atomic::Ordering::SeqCst);
let approved_in_tick = self.clock.tick_now() -
slot_number_to_tick(SLOT_DURATION_MILLIS, block_info.slot);
let approved_in_tick = self.clock.tick_now()
- slot_number_to_tick(SLOT_DURATION_MILLIS, block_info.slot);
gum::info!(target: LOG_TARGET, ?hash, "Chain selection approved after {:} ms", approved_in_tick * TICK_DURATION_MILLIS);
},
}
},
}
}
}
@@ -207,8 +207,8 @@ struct CandidateTestData {
impl CandidateTestData {
/// If message in this tranche needs to be sent.
fn should_send_tranche(&self, tranche: u32) -> bool {
self.sent_assignment <= self.needed_approvals ||
tranche <= self.max_tranche + self.num_no_shows
self.sent_assignment <= self.needed_approvals
|| tranche <= self.max_tranche + self.num_no_shows
}
/// Sets max tranche
@@ -233,8 +233,8 @@ impl CandidateTestData {
/// Tells if a message in this tranche should be a no-show.
fn should_no_show(&self, tranche: u32) -> bool {
(self.num_no_shows < self.max_no_shows && self.last_tranche_with_no_show < tranche) ||
(tranche == 0 && self.num_no_shows == 0 && self.max_no_shows > 0)
(self.num_no_shows < self.max_no_shows && self.last_tranche_with_no_show < tranche)
|| (tranche == 0 && self.num_no_shows == 0 && self.max_no_shows > 0)
}
}
@@ -547,8 +547,8 @@ impl PeerMessageProducer {
.blocks
.iter()
.filter(|block_info| {
block_info.slot <= current_slot &&
!initialized_blocks.contains(&block_info.hash)
block_info.slot <= current_slot
&& !initialized_blocks.contains(&block_info.hash)
})
.cloned()
.collect_vec();
@@ -556,8 +556,8 @@ impl PeerMessageProducer {
if !TestEnvironment::metric_lower_than(
&self.registry,
"pezkuwi_teyrchain_imported_candidates_total",
(block_info.total_candidates_before + block_info.candidates.len() as u64 -
1) as f64,
(block_info.total_candidates_before + block_info.candidates.len() as u64
- 1) as f64,
) {
initialized_blocks.insert(block_info.hash);
self.initialize_block(&block_info).await;
@@ -670,8 +670,8 @@ impl PeerMessageProducer {
}
}
}
} else if !block_info.approved.load(std::sync::atomic::Ordering::SeqCst) &&
self.options.num_no_shows_per_candidate > 0
} else if !block_info.approved.load(std::sync::atomic::Ordering::SeqCst)
&& self.options.num_no_shows_per_candidate > 0
{
skipped_messages.push(bundle);
}
@@ -708,9 +708,9 @@ impl PeerMessageProducer {
block_info: &BlockTestData,
block_initialized: bool,
) -> bool {
bundle.tranche_to_send() <= tranche_now &&
current_slot >= block_info.slot &&
block_initialized
bundle.tranche_to_send() <= tranche_now
&& current_slot >= block_info.slot
&& block_initialized
}
// Queue message to be sent by validator `sent_by`
@@ -1011,8 +1011,8 @@ pub async fn bench_approvals_run(
let start_marker = Instant::now();
let real_clock = SystemClock {};
state.delta_tick_from_generated.store(
real_clock.tick_now() -
slot_number_to_tick(SLOT_DURATION_MILLIS, state.generated_state.initial_slot),
real_clock.tick_now()
- slot_number_to_tick(SLOT_DURATION_MILLIS, state.generated_state.initial_slot),
std::sync::atomic::Ordering::SeqCst,
);
let system_clock = PastSystemClock::new(real_clock, state.delta_tick_from_generated.clone());
@@ -1046,8 +1046,8 @@ pub async fn bench_approvals_run(
// Wait for all blocks to be approved before exiting.
// This is an invariant of the benchmark, if this does not happen something went terribly wrong.
while state.last_approved_block.load(std::sync::atomic::Ordering::SeqCst) <
env.config().num_blocks as u32
while state.last_approved_block.load(std::sync::atomic::Ordering::SeqCst)
< env.config().num_blocks as u32
{
gum::info!(
"Waiting for all blocks to be approved current approved {:} num_sent {:} num_unique {:}",
@@ -96,9 +96,9 @@ impl MessagesBundle {
candidates_test_data: &HashMap<(Hash, CandidateIndex), CandidateTestData>,
options: &ApprovalsOptions,
) -> bool {
self.needed_for_approval(candidates_test_data) ||
(!options.stop_when_approved &&
self.min_tranche() <= options.last_considered_tranche)
self.needed_for_approval(candidates_test_data)
|| (!options.stop_when_approved
&& self.min_tranche() <= options.last_considered_tranche)
}
/// Tells if the bundle is needed because we need more messages to approve the candidates.
@@ -218,8 +218,8 @@ impl TestMessageInfo {
assert_eq!(approvals.len(), 1);
for approval in approvals {
should_no_show = should_no_show ||
approval.candidate_indices.iter_ones().all(|candidate_index| {
should_no_show = should_no_show
|| approval.candidate_indices.iter_ones().all(|candidate_index| {
let candidate_test_data = candidates_test_data
.get_mut(&(
approval.block_hash,
@@ -265,7 +265,7 @@ impl TestMessageInfo {
candidates_test_data: &HashMap<(Hash, CandidateIndex), CandidateTestData>,
) -> bool {
match &self.msg {
protocol_v3::ApprovalDistributionMessage::Assignments(assignments) =>
protocol_v3::ApprovalDistributionMessage::Assignments(assignments) => {
assignments.iter().any(|(assignment, candidate_indices)| {
candidate_indices.iter_ones().any(|candidate_index| {
candidates_test_data
@@ -273,8 +273,9 @@ impl TestMessageInfo {
.map(|data| data.should_send_tranche(self.tranche))
.unwrap_or_default()
})
}),
protocol_v3::ApprovalDistributionMessage::Approvals(approvals) =>
})
},
protocol_v3::ApprovalDistributionMessage::Approvals(approvals) => {
approvals.iter().any(|approval| {
approval.candidate_indices.iter_ones().any(|candidate_index| {
candidates_test_data
@@ -282,7 +283,8 @@ impl TestMessageInfo {
.map(|data| data.should_send_tranche(self.tranche))
.unwrap_or_default()
})
}),
})
},
}
}
@@ -220,13 +220,14 @@ pub fn prepare_test(
let (overseer, overseer_handle) = match &mode {
TestDataAvailability::Read(options) => {
let subsystem = match options.strategy {
Strategy::FullFromBackers =>
Strategy::FullFromBackers => {
AvailabilityRecoverySubsystem::with_recovery_strategy_kind(
collation_req_receiver,
&state.req_protocol_names,
Metrics::try_register(&dependencies.registry).unwrap(),
RecoveryStrategyKind::BackersFirstAlways,
),
)
},
Strategy::Chunks => AvailabilityRecoverySubsystem::with_recovery_strategy_kind(
collation_req_receiver,
&state.req_protocol_names,
@@ -436,8 +437,8 @@ pub async fn benchmark_availability_write(
.get(index)
.expect("all validators have keys");
if env.network().is_peer_connected(peer) &&
env.network().send_request_from_peer(peer, request).is_ok()
if env.network().is_peer_connected(peer)
&& env.network().send_request_from_peer(peer, request).is_ok()
{
Some(pending_response_receiver)
} else {
@@ -218,8 +218,8 @@ pub async fn benchmark_dispute_coordinator(
let candidate_hashes =
candidate_receipts.iter().map(|receipt| receipt.hash()).collect::<Vec<_>>();
let requests_expected = candidate_hashes.len() *
(state.config.n_validators * state.config.connectivity / 100 - 1);
let requests_expected = candidate_hashes.len()
* (state.config.n_validators * state.config.connectivity / 100 - 1);
loop {
let requests_sent = candidate_hashes
@@ -47,10 +47,11 @@ impl MockApprovalVotingParallel {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
ApprovalVotingParallelMessage::GetApprovalSignaturesForCandidate(hash, tx) => {
gum::debug!(target: LOG_TARGET, "GetApprovalSignaturesForCandidate for candidate {:?}", hash);
@@ -204,10 +204,11 @@ impl MockAvailabilityStore {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
AvailabilityStoreMessage::QueryAvailableData(candidate_hash, tx) => {
gum::debug!(target: LOG_TARGET, candidate_hash = ?candidate_hash, "Responding to QueryAvailableData");
@@ -51,10 +51,11 @@ impl MockAvailabilityRecovery {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
AvailabilityRecoveryMessage::RecoverAvailableData(receipt, _, _, _, tx) => {
gum::debug!(target: LOG_TARGET, "RecoverAvailableData for candidate {:?}", receipt.hash());
@@ -73,8 +73,8 @@ impl MockCandidateBacking {
.or_insert(1);
let statements_received_count = *statements_tracker.get(&candidate_hash).unwrap();
if statements_received_count == (self.config.minimum_backing_votes - 1) &&
is_own_backing_group
if statements_received_count == (self.config.minimum_backing_votes - 1)
&& is_own_backing_group
{
let statement = Statement::Valid(candidate_hash);
let context = SigningContext { parent_hash: relay_parent, session_index: 0 };
@@ -142,10 +142,11 @@ impl MockCandidateBacking {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => {
gum::trace!(target: LOG_TARGET, msg=?msg, "recv message");
@@ -50,10 +50,11 @@ impl MockCandidateValidation {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
CandidateValidationMessage::ValidateFromExhaustive {
response_sender,
@@ -65,10 +65,11 @@ impl MockChainApi {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => {
gum::debug!(target: LOG_TARGET, msg=?msg, "recv message");
@@ -102,10 +102,11 @@ impl MockNetworkBridgeTx {
loop {
let subsystem_message = ctx.recv().await.expect("Overseer never fails us");
match subsystem_message {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
NetworkBridgeTxMessage::SendRequests(requests, _if_disconnected) => {
for request in requests {
@@ -46,10 +46,11 @@ impl MockProspectiveTeyrchains {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
ProspectiveTeyrchainsMessage::GetMinimumRelayParents(_relay_parent, tx) => {
tx.send(vec![]).unwrap();
@@ -173,10 +173,11 @@ impl MockRuntimeApi {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) =>
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
},
}
},
orchestra::FromOrchestra::Communication { msg } => {
gum::debug!(target: LOG_TARGET, msg=?msg, "recv message");
@@ -323,10 +324,11 @@ impl MockRuntimeApi {
RuntimeApiMessage::Request(
_parent,
RuntimeApiRequest::ApprovalVotingParams(_, tx),
) =>
) => {
if let Err(err) = tx.send(Ok(ApprovalVotingParams::default())) {
gum::error!(target: LOG_TARGET, ?err, "Voting params weren't received");
},
}
},
RuntimeApiMessage::Request(_parent, RuntimeApiRequest::ClaimQueue(tx)) => {
tx.send(Ok(self.state.claim_queue.clone())).unwrap();
},
+34 -24
View File
@@ -165,10 +165,12 @@ impl NetworkMessage {
/// Returns the size of the encoded message or request
pub fn size(&self) -> usize {
match &self {
NetworkMessage::MessageFromPeer(_, ValidationProtocols::V3(message)) =>
message.encoded_size(),
NetworkMessage::MessageFromNode(_peer_id, ValidationProtocols::V3(message)) =>
message.encoded_size(),
NetworkMessage::MessageFromPeer(_, ValidationProtocols::V3(message)) => {
message.encoded_size()
},
NetworkMessage::MessageFromNode(_peer_id, ValidationProtocols::V3(message)) => {
message.encoded_size()
},
NetworkMessage::RequestFromNode(_peer_id, incoming) => incoming.size(),
NetworkMessage::RequestFromPeer(request) => request.payload.encoded_size(),
}
@@ -177,8 +179,8 @@ impl NetworkMessage {
/// Returns the destination peer from the message or `None` if it originates from a peer.
pub fn peer(&self) -> Option<&AuthorityDiscoveryId> {
match &self {
NetworkMessage::MessageFromNode(peer_id, _) |
NetworkMessage::RequestFromNode(peer_id, _) => Some(peer_id),
NetworkMessage::MessageFromNode(peer_id, _)
| NetworkMessage::RequestFromNode(peer_id, _) => Some(peer_id),
_ => None,
}
}
@@ -345,8 +347,9 @@ impl NetworkInterface {
task_tx_limiter.lock().await.reap(size).await;
match peer_message {
NetworkMessage::MessageFromNode(peer, message) =>
tx_network.send_message_to_peer(&peer, message),
NetworkMessage::MessageFromNode(peer, message) => {
tx_network.send_message_to_peer(&peer, message)
},
NetworkMessage::RequestFromNode(peer, request) => {
// Send request through a proxy so we can account and limit bandwidth
// usage for the node.
@@ -1057,8 +1060,9 @@ impl RequestExt for Requests {
fn into_response_sender(self) -> ResponseSender {
match self {
Requests::ChunkFetching(outgoing_request) => outgoing_request.pending_response,
Requests::AvailableDataFetchingV1(outgoing_request) =>
outgoing_request.pending_response,
Requests::AvailableDataFetchingV1(outgoing_request) => {
outgoing_request.pending_response
},
Requests::DisputeSendingV1(outgoing_request) => outgoing_request.pending_response,
_ => unimplemented!("unsupported request type"),
}
@@ -1067,14 +1071,18 @@ impl RequestExt for Requests {
/// Swaps the `ResponseSender` and returns the previous value.
fn swap_response_sender(&mut self, new_sender: ResponseSender) -> ResponseSender {
match self {
Requests::ChunkFetching(outgoing_request) =>
std::mem::replace(&mut outgoing_request.pending_response, new_sender),
Requests::AvailableDataFetchingV1(outgoing_request) =>
std::mem::replace(&mut outgoing_request.pending_response, new_sender),
Requests::AttestedCandidateV2(outgoing_request) =>
std::mem::replace(&mut outgoing_request.pending_response, new_sender),
Requests::DisputeSendingV1(outgoing_request) =>
std::mem::replace(&mut outgoing_request.pending_response, new_sender),
Requests::ChunkFetching(outgoing_request) => {
std::mem::replace(&mut outgoing_request.pending_response, new_sender)
},
Requests::AvailableDataFetchingV1(outgoing_request) => {
std::mem::replace(&mut outgoing_request.pending_response, new_sender)
},
Requests::AttestedCandidateV2(outgoing_request) => {
std::mem::replace(&mut outgoing_request.pending_response, new_sender)
},
Requests::DisputeSendingV1(outgoing_request) => {
std::mem::replace(&mut outgoing_request.pending_response, new_sender)
},
_ => unimplemented!("unsupported request type"),
}
}
@@ -1083,10 +1091,12 @@ impl RequestExt for Requests {
fn size(&self) -> usize {
match self {
Requests::ChunkFetching(outgoing_request) => outgoing_request.payload.encoded_size(),
Requests::AvailableDataFetchingV1(outgoing_request) =>
outgoing_request.payload.encoded_size(),
Requests::AttestedCandidateV2(outgoing_request) =>
outgoing_request.payload.encoded_size(),
Requests::AvailableDataFetchingV1(outgoing_request) => {
outgoing_request.payload.encoded_size()
},
Requests::AttestedCandidateV2(outgoing_request) => {
outgoing_request.payload.encoded_size()
},
Requests::DisputeSendingV1(outgoing_request) => outgoing_request.payload.encoded_size(),
_ => unimplemented!("received an unexpected request"),
}
@@ -1122,8 +1132,8 @@ mod tests {
// Allow up to `budget/max_refill` error tolerance
let lower_bound = budget as u128 * ((end - start).as_millis() / 1000u128);
let upper_bound = budget as u128 *
((end - start).as_millis() / 1000u128 + rate_limiter.max_refill as u128);
let upper_bound = budget as u128
* ((end - start).as_millis() / 1000u128 + rate_limiter.max_refill as u128);
assert!(total_sent as u128 >= lower_bound);
assert!(total_sent as u128 <= upper_bound);
}
@@ -397,10 +397,12 @@ impl HandleNetworkMessage for TestState {
let position_in_group =
backing_group.iter().position(|v| *v == validator_index).unwrap();
match statement.unchecked_payload() {
CompactStatement::Seconded(_) =>
seconded_in_group.set(position_in_group, true),
CompactStatement::Valid(_) =>
validated_in_group.set(position_in_group, true),
CompactStatement::Seconded(_) => {
seconded_in_group.set(position_in_group, true)
},
CompactStatement::Valid(_) => {
validated_in_group.set(position_in_group, true)
},
}
}
}