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 65b7f5e640
commit 4c8f281051
898 changed files with 8671 additions and 6432 deletions
@@ -732,8 +732,9 @@ pub mod pezpallet {
let weight2 = match next_phase {
Phase::Signed(_) => T::WeightInfo::on_initialize_into_signed(),
Phase::SignedValidation(_) =>
T::WeightInfo::on_initialize_into_signed_validation(),
Phase::SignedValidation(_) => {
T::WeightInfo::on_initialize_into_signed_validation()
},
Phase::Unsigned(_) => T::WeightInfo::on_initialize_into_unsigned(),
_ => T::WeightInfo::on_initialize_nothing(),
};
@@ -777,8 +778,8 @@ pub mod pezpallet {
let max_vote: usize = <SolutionOf<T::MinerConfig> as NposSolution>::LIMIT;
// 2. Maximum sum of [SolutionAccuracy; 16] must fit into `UpperOf<OffchainAccuracy>`.
let maximum_chain_accuracy: Vec<UpperOf<SolutionAccuracyOf<T::MinerConfig>>> = (0..
max_vote)
let maximum_chain_accuracy: Vec<UpperOf<SolutionAccuracyOf<T::MinerConfig>>> = (0
..max_vote)
.map(|_| {
<UpperOf<SolutionAccuracyOf<T::MinerConfig>>>::from(
<SolutionAccuracyOf<T::MinerConfig>>::one().deconstruct(),
@@ -809,8 +810,8 @@ pub mod pezpallet {
"Signed phase not set correct -- both should be set or unset"
);
assert!(
signed_validation.is_zero() ||
signed_validation % T::Pages::get().into() == Zero::zero(),
signed_validation.is_zero()
|| signed_validation % T::Pages::get().into() == Zero::zero(),
"signed validation phase should be a multiple of the number of pages."
);
@@ -1041,8 +1042,8 @@ pub mod pezpallet {
.take(up_to_page as usize)
{
ensure!(
(exists ^ Self::voters(p).is_none()) &&
(exists ^ Self::voters_hash(p).is_none()),
(exists ^ Self::voters(p).is_none())
&& (exists ^ Self::voters_hash(p).is_none()),
"voter page existence mismatch"
);
@@ -1058,8 +1059,8 @@ pub mod pezpallet {
.take((T::Pages::get() - up_to_page) as usize)
{
ensure!(
(exists ^ Self::voters(p).is_some()) &&
(exists ^ Self::voters_hash(p).is_some()),
(exists ^ Self::voters(p).is_some())
&& (exists ^ Self::voters_hash(p).is_some()),
"voter page non-existence mismatch"
);
}
@@ -1079,17 +1080,17 @@ pub mod pezpallet {
ensure!(Self::desired_targets().is_some(), "desired target mismatch");
ensure!(Self::targets_hash().is_some(), "targets hash mismatch");
ensure!(
Self::targets_decode_len().unwrap_or_default() as u32 ==
T::TargetSnapshotPerBlock::get(),
Self::targets_decode_len().unwrap_or_default() as u32
== T::TargetSnapshotPerBlock::get(),
"targets decode length mismatch"
);
// ensure that voter pages that should exist, indeed to exist..
for p in crate::Pezpallet::<T>::lsp()..=crate::Pezpallet::<T>::msp() {
ensure!(
Self::voters_hash(p).is_some() &&
Self::voters_decode_len(p).unwrap_or_default() as u32 ==
T::VoterSnapshotPerBlock::get(),
Self::voters_hash(p).is_some()
&& Self::voters_decode_len(p).unwrap_or_default() as u32
== T::VoterSnapshotPerBlock::get(),
"voter page existence mismatch"
);
}
@@ -1118,21 +1119,23 @@ pub mod pezpallet {
Phase::Off => Self::ensure_snapshot(false, T::Pages::get()),
// we will star the snapshot in the next phase.
Phase::Snapshot(p) if p == T::Pages::get() =>
Self::ensure_snapshot(false, T::Pages::get()),
Phase::Snapshot(p) if p == T::Pages::get() => {
Self::ensure_snapshot(false, T::Pages::get())
},
// we are mid voter snapshot.
Phase::Snapshot(p) if p < T::Pages::get() && p > 0 =>
Self::ensure_snapshot(true, T::Pages::get() - p - 1),
Phase::Snapshot(p) if p < T::Pages::get() && p > 0 => {
Self::ensure_snapshot(true, T::Pages::get() - p - 1)
},
// we cannot check anything in this block -- we take the last page of the snapshot.
Phase::Snapshot(_) => Ok(()),
// full snapshot must exist in these phases.
Phase::Emergency |
Phase::Signed(_) |
Phase::SignedValidation(_) |
Phase::Export(_) |
Phase::Done |
Phase::Unsigned(_) => Self::ensure_snapshot(true, T::Pages::get()),
Phase::Emergency
| Phase::Signed(_)
| Phase::SignedValidation(_)
| Phase::Export(_)
| Phase::Done
| Phase::Unsigned(_) => Self::ensure_snapshot(true, T::Pages::get()),
}?;
Ok(())
@@ -1316,8 +1319,8 @@ impl<T: Config> Pezpallet<T> {
// check the snapshot fingerprint, if asked for.
ensure!(
maybe_snapshot_fingerprint
.map_or(true, |snapshot_fingerprint| Snapshot::<T>::fingerprint() ==
snapshot_fingerprint),
.map_or(true, |snapshot_fingerprint| Snapshot::<T>::fingerprint()
== snapshot_fingerprint),
CommonError::WrongFingerprint
);
@@ -1676,11 +1679,11 @@ impl<T: Config> ElectionProvider for Pezpallet<T> {
Phase::Off => Err(()),
// we're doing sth but not read.
Phase::Signed(_) |
Phase::SignedValidation(_) |
Phase::Unsigned(_) |
Phase::Snapshot(_) |
Phase::Emergency => Ok(false),
Phase::Signed(_)
| Phase::SignedValidation(_)
| Phase::Unsigned(_)
| Phase::Snapshot(_)
| Phase::Emergency => Ok(false),
// we're ready
Phase::Done | Phase::Export(_) => Ok(true),
@@ -285,9 +285,10 @@ impl InstantElectionProvider for MockFallback {
desired_targets: u32,
) -> Result<BoundedSupportsOf<Self>, Self::Error> {
match FallbackMode::get() {
FallbackModes::Continue =>
FallbackModes::Continue => {
crate::Continue::<Runtime>::instant_elect(voters, targets, desired_targets)
.map_err(|x| x.to_string()),
.map_err(|x| x.to_string())
},
FallbackModes::Emergency => crate::InitiateEmergencyPhase::<Runtime>::instant_elect(
voters,
targets,
@@ -334,14 +334,17 @@ impl<T: crate::Config> Phase<T> {
Self::are_we_done()
}
},
Self::Snapshot(non_zero_remaining) =>
Self::Snapshot(non_zero_remaining.defensive_saturating_sub(One::one())),
Self::Snapshot(non_zero_remaining) => {
Self::Snapshot(non_zero_remaining.defensive_saturating_sub(One::one()))
},
// signed phase
Self::Signed(zero) if zero == BlockNumberFor::<T>::zero() =>
Self::SignedValidation(T::SignedValidationPhase::get()),
Self::Signed(non_zero_left) =>
Self::Signed(non_zero_left.defensive_saturating_sub(One::one())),
Self::Signed(zero) if zero == BlockNumberFor::<T>::zero() => {
Self::SignedValidation(T::SignedValidationPhase::get())
},
Self::Signed(non_zero_left) => {
Self::Signed(non_zero_left.defensive_saturating_sub(One::one()))
},
// signed validation
Self::SignedValidation(zero)
@@ -353,21 +356,24 @@ impl<T: crate::Config> Phase<T> {
Self::are_we_done()
}
},
Self::SignedValidation(non_zero_left) =>
Self::SignedValidation(non_zero_left.saturating_sub(One::one())),
Self::SignedValidation(non_zero_left) => {
Self::SignedValidation(non_zero_left.saturating_sub(One::one()))
},
// unsigned phase -- at this phase we will
Self::Unsigned(zero) if zero == BlockNumberFor::<T>::zero() => Self::are_we_done(),
Self::Unsigned(non_zero_left) =>
Self::Unsigned(non_zero_left.defensive_saturating_sub(One::one())),
Self::Unsigned(non_zero_left) => {
Self::Unsigned(non_zero_left.defensive_saturating_sub(One::one()))
},
// Done. Wait for export to start.
Self::Done => Self::Done,
// Export
Self::Export(0) => Self::Off,
Self::Export(non_zero_left) =>
Self::Export(non_zero_left.defensive_saturating_sub(One::one())),
Self::Export(non_zero_left) => {
Self::Export(non_zero_left.defensive_saturating_sub(One::one()))
},
}
}
@@ -925,8 +925,9 @@ impl<T: Config> OffchainWorkerMiner<T> {
|maybe_head: Result<Option<BlockNumberFor<T>>, _>| {
match maybe_head {
Ok(Some(head)) if now < head => Err("fork."),
Ok(Some(head)) if now >= head && now <= head + threshold =>
Err("recently executed."),
Ok(Some(head)) if now >= head && now <= head + threshold => {
Err("recently executed.")
},
Ok(Some(head)) if now > head + threshold => {
// we can run again now. Write the new head.
Ok(now)
@@ -961,8 +962,9 @@ impl<T: Config> OffchainWorkerMiner<T> {
let storage = StorageValueRef::persistent(&Self::OFFCHAIN_CACHED_CALL);
match storage.mutate::<_, (), _>(|_| Ok((call.clone(), snapshot_fingerprint))) {
Ok(_) => Ok(()),
Err(MutateStorageError::ConcurrentModification(_)) =>
Err(OffchainMinerError::FailedToStoreSolution),
Err(MutateStorageError::ConcurrentModification(_)) => {
Err(OffchainMinerError::FailedToStoreSolution)
},
Err(MutateStorageError::ValueFunctionFailed(_)) => {
// this branch should be unreachable according to the definition of
// `StorageValueRef::mutate`: that function should only ever `Err` if the closure we
@@ -240,8 +240,8 @@ mod pezpallet {
"weight of `submit_unsigned` is too high"
);
assert!(
<T as Config>::MinerPages::get() as usize <=
<T as crate::Config>::Pages::get() as usize,
<T as Config>::MinerPages::get() as usize
<= <T as crate::Config>::Pages::get() as usize,
"number of pages in the unsigned phase is too high"
);
}
@@ -341,10 +341,12 @@ pub(crate) mod pezpallet {
// store the valid pages
for (support, page) in supports.into_iter().zip(pages.iter()) {
match Self::valid() {
ValidSolution::X =>
QueuedSolutionX::<T>::insert(Self::round(), page, support),
ValidSolution::Y =>
QueuedSolutionY::<T>::insert(Self::round(), page, support),
ValidSolution::X => {
QueuedSolutionX::<T>::insert(Self::round(), page, support)
},
ValidSolution::Y => {
QueuedSolutionY::<T>::insert(Self::round(), page, support)
},
}
}
QueuedSolutionScore::<T>::insert(Self::round(), score);
@@ -490,8 +492,8 @@ pub(crate) mod pezpallet {
// The number of existing keys in `QueuedSolutionBackings` must always match that of
// the INVALID variant.
ensure!(
QueuedSolutionBackings::<T>::iter_prefix(Self::round()).count() ==
Self::invalid_iter().count(),
QueuedSolutionBackings::<T>::iter_prefix(Self::round()).count()
== Self::invalid_iter().count(),
"incorrect number of backings pages",
);