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
@@ -162,11 +162,11 @@ impl<Hash, BlockHash> TransactionStatus<Hash, BlockHash> {
pub fn is_final(&self) -> bool {
// The state must be kept in sync with `crate::graph::Sender`.
match self {
Self::Usurped(_) |
Self::Finalized(_) |
Self::FinalityTimeout(_) |
Self::Invalid |
Self::Dropped => true,
Self::Usurped(_)
| Self::Finalized(_)
| Self::FinalityTimeout(_)
| Self::Invalid
| Self::Dropped => true,
_ => false,
}
}
@@ -103,8 +103,9 @@ impl ChainApi for TestApi {
) -> Result<Option<NumberFor<Self::Block>>, Self::Error> {
Ok(match at {
BlockId::Number(num) => Some(*num),
BlockId::Hash(hash) if *hash == H256::from_low_u64_be(hash.to_low_u64_be()) =>
Some(hash.to_low_u64_be()),
BlockId::Hash(hash) if *hash == H256::from_low_u64_be(hash.to_low_u64_be()) => {
Some(hash.to_low_u64_be())
},
BlockId::Hash(_) => None,
})
}
@@ -107,8 +107,9 @@ where
// do not proceed with txpool maintain if block distance is too high
let skip_maintenance =
match (hash_to_number(new_hash), hash_to_number(self.recent_best_block)) {
(Ok(Some(new)), Ok(Some(current))) =>
new.saturating_sub(current) > SKIP_MAINTENANCE_THRESHOLD.into(),
(Ok(Some(new)), Ok(Some(current))) => {
new.saturating_sub(current) > SKIP_MAINTENANCE_THRESHOLD.into()
},
_ => true,
};
@@ -178,8 +178,9 @@ impl ChainApi for TestApi {
) -> Result<Option<NumberFor<Self>>, Self::Error> {
Ok(match at {
BlockId::Number(num) => Some(*num),
BlockId::Hash(hash) if *hash == H256::from_low_u64_be(hash.to_low_u64_be()) =>
Some(hash.to_low_u64_be()),
BlockId::Hash(hash) if *hash == H256::from_low_u64_be(hash.to_low_u64_be()) => {
Some(hash.to_low_u64_be())
},
BlockId::Hash(_) => None,
})
}
@@ -296,8 +296,9 @@ where
return Some(DroppedTransaction::new_enforced_by_limts(tx_hash));
}
},
TransactionStatus::Usurped(by) =>
return Some(DroppedTransaction::new_usurped(tx_hash, by)),
TransactionStatus::Usurped(by) => {
return Some(DroppedTransaction::new_usurped(tx_hash, by))
},
TransactionStatus::Invalid => {
if let Some(mut views_keeping_tx_valid) = self.transaction_views(tx_hash) {
views_keeping_tx_valid.get_mut().remove(&block_hash);
@@ -748,9 +748,10 @@ where
let insertion = match self.mempool.push_watched(source, at_number, xt.clone()).await {
Ok(result) => result,
Err(TxPoolApiError::ImmediatelyDropped) =>
Err(TxPoolApiError::ImmediatelyDropped) => {
self.attempt_transaction_replacement(source, at_number, true, xt.clone())
.await?,
.await?
},
Err(e) => return Err(e.into()),
};
@@ -803,8 +804,9 @@ where
.zip(xts.clone())
.map(|(result, xt)| async move {
match result {
Err(TxPoolApiError::ImmediatelyDropped) =>
self.attempt_transaction_replacement(source, at_number, false, xt).await,
Err(TxPoolApiError::ImmediatelyDropped) => {
self.attempt_transaction_replacement(source, at_number, false, xt).await
},
_ => result,
}
})
@@ -991,8 +993,9 @@ where
"fatp::submit_one"
);
match self.submit_at(_at, source, vec![xt]).await {
Ok(mut v) =>
v.pop().expect("There is exactly one element in result of submit_at. qed."),
Ok(mut v) => {
v.pop().expect("There is exactly one element in result of submit_at. qed.")
},
Err(e) => Err(e),
}
}
@@ -1279,8 +1282,8 @@ where
return;
};
if at.number.saturating_sub(oldest_block_number).into() <=
self.finality_timeout_threshold.into()
if at.number.saturating_sub(oldest_block_number).into()
<= self.finality_timeout_threshold.into()
{
return;
}
@@ -1511,8 +1514,8 @@ where
// note: There is no point to fetch the transactions from blocks older than threshold.
// All transactions included in these blocks, were already removed from pool
// with FinalityTimeout event.
if at.number.saturating_sub(block.number).into() <=
self.finality_timeout_threshold.into()
if at.number.saturating_sub(block.number).into()
<= self.finality_timeout_threshold.into()
{
all_txs.extend(self.fetch_block_transactions(block).await);
}
@@ -1984,10 +1987,11 @@ where
let compute_tree_route = |from, to| -> Result<TreeRoute<Block>, String> {
match self.api.tree_route(from, to) {
Ok(tree_route) => Ok(tree_route),
Err(e) =>
Err(e) => {
return Err(format!(
"Error occurred while computing tree_route from {from:?} to {to:?}: {e}"
)),
))
},
}
};
let block_id_to_number =
@@ -113,10 +113,10 @@ where
{
fn hash(&self) -> ExtrinsicHash<ChainApi> {
match self {
Self::Invalidated(hash) |
Self::Finalized(hash, _, _) |
Self::Broadcasted(hash, _) |
Self::Dropped(hash, _) => *hash,
Self::Invalidated(hash)
| Self::Finalized(hash, _, _)
| Self::Broadcasted(hash, _)
| Self::Dropped(hash, _) => *hash,
Self::FinalityTimeout(hash, _) => *hash,
}
}
@@ -130,18 +130,24 @@ where
fn into(self) -> TransactionStatus<ExtrinsicHash<ChainApi>, BlockHash<ChainApi>> {
match self {
TransactionStatusUpdate::Invalidated(_) => TransactionStatus::Invalid,
TransactionStatusUpdate::Finalized(_, hash, index) =>
TransactionStatus::Finalized((*hash, *index)),
TransactionStatusUpdate::Broadcasted(_, peers) =>
TransactionStatus::Broadcast(peers.clone()),
TransactionStatusUpdate::Dropped(_, DroppedReason::Usurped(by)) =>
TransactionStatus::Usurped(*by),
TransactionStatusUpdate::Dropped(_, DroppedReason::LimitsEnforced) =>
TransactionStatus::Dropped,
TransactionStatusUpdate::Dropped(_, DroppedReason::Invalid) =>
TransactionStatus::Invalid,
TransactionStatusUpdate::FinalityTimeout(_, block_hash) =>
TransactionStatus::FinalityTimeout(*block_hash),
TransactionStatusUpdate::Finalized(_, hash, index) => {
TransactionStatus::Finalized((*hash, *index))
},
TransactionStatusUpdate::Broadcasted(_, peers) => {
TransactionStatus::Broadcast(peers.clone())
},
TransactionStatusUpdate::Dropped(_, DroppedReason::Usurped(by)) => {
TransactionStatus::Usurped(*by)
},
TransactionStatusUpdate::Dropped(_, DroppedReason::LimitsEnforced) => {
TransactionStatus::Dropped
},
TransactionStatusUpdate::Dropped(_, DroppedReason::Invalid) => {
TransactionStatus::Invalid
},
TransactionStatusUpdate::FinalityTimeout(_, block_hash) => {
TransactionStatus::FinalityTimeout(*block_hash)
},
}
}
}
@@ -390,12 +396,12 @@ where
self.terminate = true;
Some(status)
},
TransactionStatus::FinalityTimeout(_) |
TransactionStatus::Retracted(_) |
TransactionStatus::Broadcast(_) |
TransactionStatus::Usurped(_) |
TransactionStatus::Dropped |
TransactionStatus::Invalid => None,
TransactionStatus::FinalityTimeout(_)
| TransactionStatus::Retracted(_)
| TransactionStatus::Broadcast(_)
| TransactionStatus::Usurped(_)
| TransactionStatus::Dropped
| TransactionStatus::Invalid => None,
}
}
@@ -79,8 +79,9 @@ where
break;
};
match payload {
WorkerPayload::RevalidateView(view, worker_channels) =>
view.revalidate(worker_channels).await,
WorkerPayload::RevalidateView(view, worker_channels) => {
view.revalidate(worker_channels).await
},
WorkerPayload::RevalidateMempool(
mempool,
view_store,
@@ -217,13 +217,13 @@ where
ChainApi: graph::ChainApi<Block = Block> + 'static,
{
fn eq(&self, other: &Self) -> bool {
self.watched == other.watched &&
self.tx == other.tx &&
self.bytes == other.bytes &&
self.source == other.source &&
*self.priority.read() == *other.priority.read() &&
self.validated_at.load(atomic::Ordering::Relaxed) ==
other.validated_at.load(atomic::Ordering::Relaxed)
self.watched == other.watched
&& self.tx == other.tx
&& self.bytes == other.bytes
&& self.source == other.source
&& *self.priority.read() == *other.priority.read()
&& self.validated_at.load(atomic::Ordering::Relaxed)
== other.validated_at.load(atomic::Ordering::Relaxed)
}
}
@@ -427,8 +427,8 @@ where
/// Returns true if provided values would exceed defined limits.
fn is_limit_exceeded(&self, length: usize, current_total_bytes: usize) -> bool {
length > self.max_transactions_count ||
current_total_bytes > self.max_transactions_total_bytes
length > self.max_transactions_count
|| current_total_bytes > self.max_transactions_total_bytes
}
/// Attempts to insert a transaction into the memory pool, ensuring it does not
@@ -451,8 +451,9 @@ where
transactions.insert(tx_hash, Arc::from(tx));
Ok(InsertionInfo::new(tx_hash, source))
},
(_, true) =>
Err(pezsc_transaction_pool_api::error::Error::AlreadyImported(Box::new(tx_hash))),
(_, true) => {
Err(pezsc_transaction_pool_api::error::Error::AlreadyImported(Box::new(tx_hash)))
},
(true, _) => Err(pezsc_transaction_pool_api::error::Error::ImmediatelyDropped),
};
trace!(
@@ -598,9 +599,9 @@ where
self.with_transactions(|iter| {
iter.filter(|(_, xt)| {
let finalized_block_number = finalized_block.number.into().as_u64();
xt.validated_at.load(atomic::Ordering::Relaxed) +
TXMEMPOOL_REVALIDATION_PERIOD <
finalized_block_number
xt.validated_at.load(atomic::Ordering::Relaxed)
+ TXMEMPOOL_REVALIDATION_PERIOD
< finalized_block_number
})
.sorted_by_key(|(_, tx)| tx.validated_at.load(atomic::Ordering::Relaxed))
.take(TXMEMPOOL_MAX_REVALIDATION_BATCH_SIZE)
@@ -633,11 +634,11 @@ where
let invalid_hashes = validation_results
.into_iter()
.filter_map(|(tx_hash, validation_result)| match validation_result {
Ok(Ok(_)) |
Ok(Err(TransactionValidityError::Invalid(InvalidTransaction::Future))) => None,
Err(_) |
Ok(Err(TransactionValidityError::Unknown(_))) |
Ok(Err(TransactionValidityError::Invalid(_))) => {
Ok(Ok(_))
| Ok(Err(TransactionValidityError::Invalid(InvalidTransaction::Future))) => None,
Err(_)
| Ok(Err(TransactionValidityError::Unknown(_)))
| Ok(Err(TransactionValidityError::Invalid(_))) => {
trace!(
target: LOG_TARGET,
?tx_hash,
@@ -330,8 +330,9 @@ where
);
return Err(error);
},
Some(Ok(result)) =>
Ok(ViewStoreSubmitOutcome::from(result).with_watcher(external_watcher)),
Some(Ok(result)) => {
Ok(ViewStoreSubmitOutcome::from(result).with_watcher(external_watcher))
},
None => Ok(ViewStoreSubmitOutcome::new(tx_hash, None).with_watcher(external_watcher)),
}
}
@@ -515,12 +515,13 @@ impl<Hash: hash::Hash + Member + Serialize, Ex: std::fmt::Debug> BasePool<Hash,
worst
}
},
_ =>
_ => {
if worst.imported_at > current.imported_at {
current.clone()
} else {
worst
},
}
},
},
),
});
@@ -83,8 +83,8 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
.filter(|tag| {
// is true if the tag is already satisfied either via transaction in the pool
// or one that was recently included.
let is_provided = provided.contains_key(&**tag) ||
recently_pruned.iter().any(|x| x.contains(&**tag));
let is_provided = provided.contains_key(&**tag)
|| recently_pruned.iter().any(|x| x.contains(&**tag));
!is_provided
})
.cloned()
@@ -553,7 +553,7 @@ impl<B: ChainApi, L: EventHandler<B>> Pool<B, L> {
};
let validity = match status {
Ok(validity) =>
Ok(validity) => {
if validity.provides.is_empty() {
ValidatedTransaction::Invalid(hash, error::Error::NoTagsProvided.into())
} else {
@@ -565,11 +565,14 @@ impl<B: ChainApi, L: EventHandler<B>> Pool<B, L> {
bytes,
validity,
)
},
Err(TransactionValidityError::Invalid(e)) =>
ValidatedTransaction::Invalid(hash, error::Error::InvalidTransaction(e).into()),
Err(TransactionValidityError::Unknown(e)) =>
ValidatedTransaction::Unknown(hash, error::Error::UnknownTransaction(e).into()),
}
},
Err(TransactionValidityError::Invalid(e)) => {
ValidatedTransaction::Invalid(hash, error::Error::InvalidTransaction(e).into())
},
Err(TransactionValidityError::Unknown(e)) => {
ValidatedTransaction::Unknown(hash, error::Error::UnknownTransaction(e).into())
},
};
(hash, validity)
@@ -752,18 +752,18 @@ mod tests {
};
// higher priority = better
assert!(
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 1 } >
TransactionRef { transaction: Arc::new(with_priority(2, 3)), insertion_id: 2 }
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 1 }
> TransactionRef { transaction: Arc::new(with_priority(2, 3)), insertion_id: 2 }
);
// lower validity = better
assert!(
TransactionRef { transaction: Arc::new(with_priority(3, 2)), insertion_id: 1 } >
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 2 }
TransactionRef { transaction: Arc::new(with_priority(3, 2)), insertion_id: 1 }
> TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 2 }
);
// lower insertion_id = better
assert!(
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 1 } >
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 2 }
TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 1 }
> TransactionRef { transaction: Arc::new(with_priority(3, 3)), insertion_id: 2 }
);
}
@@ -318,8 +318,9 @@ impl<B: ChainApi, L: EventHandler<B>> ValidatedPool<B, L> {
results
.into_iter()
.map(|res| match res {
Ok(outcome) if removed.contains(&outcome.hash) =>
Err(error::Error::ImmediatelyDropped.into()),
Ok(outcome) if removed.contains(&outcome.hash) => {
Err(error::Error::ImmediatelyDropped.into())
},
other => other,
})
.collect()
@@ -348,7 +349,7 @@ impl<B: ChainApi, L: EventHandler<B>> ValidatedPool<B, L> {
let sinks = &mut self.import_notification_sinks.lock();
sinks.retain_mut(|sink| match sink.try_send(*hash) {
Ok(()) => true,
Err(e) =>
Err(e) => {
if e.is_full() {
warn!(
target: LOG_TARGET,
@@ -358,7 +359,8 @@ impl<B: ChainApi, L: EventHandler<B>> ValidatedPool<B, L> {
true
} else {
false
},
}
},
});
}
@@ -394,8 +396,8 @@ impl<B: ChainApi, L: EventHandler<B>> ValidatedPool<B, L> {
let ready_limit = &self.options.ready;
let future_limit = &self.options.future;
if ready_limit.is_exceeded(status.ready, status.ready_bytes) ||
future_limit.is_exceeded(status.future, status.future_bytes)
if ready_limit.is_exceeded(status.ready, status.ready_bytes)
|| future_limit.is_exceeded(status.future, status.future_bytes)
{
trace!(
target: LOG_TARGET,
@@ -575,8 +577,8 @@ impl<B: ChainApi, L: EventHandler<B>> ValidatedPool<B, L> {
final_statuses.insert(tx_hash, Status::Failed);
},
},
ValidatedTransaction::Invalid(_, _) |
ValidatedTransaction::Unknown(_, _) => {
ValidatedTransaction::Invalid(_, _)
| ValidatedTransaction::Unknown(_, _) => {
final_statuses.insert(tx_hash, Status::Failed);
},
}
@@ -198,8 +198,9 @@ where
pool_api.clone(),
));
let (revalidation_queue, background_task) = match revalidation_type {
RevalidationType::Light =>
(revalidation::RevalidationQueue::new(pool_api.clone(), pool.clone()), None),
RevalidationType::Light => {
(revalidation::RevalidationQueue::new(pool_api.clone(), pool.clone()), None)
},
RevalidationType::Full => {
let (queue, background) = revalidation::RevalidationQueue::new_background(
pool_api.clone(),
@@ -219,8 +220,9 @@ where
pool,
revalidation_queue: Arc::new(revalidation_queue),
revalidation_strategy: Arc::new(Mutex::new(match revalidation_type {
RevalidationType::Light =>
RevalidationStrategy::Light(RevalidationStatus::NotScheduled),
RevalidationType::Light => {
RevalidationStrategy::Light(RevalidationStatus::NotScheduled)
},
RevalidationType::Full => RevalidationStrategy::Always,
})),
ready_poll: Arc::new(Mutex::new(ReadyPoll::new(best_block_number))),
@@ -582,8 +584,8 @@ impl<N: Clone + Copy + AtLeast32Bit> RevalidationStatus<N> {
},
Self::Scheduled(revalidate_at_time, revalidate_at_block) => {
let is_required =
revalidate_at_time.map(|at| Instant::now() >= at).unwrap_or(false) ||
revalidate_at_block.map(|at| block >= at).unwrap_or(false);
revalidate_at_time.map(|at| Instant::now() >= at).unwrap_or(false)
|| revalidate_at_block.map(|at| block >= at).unwrap_or(false);
if is_required {
*self = Self::InProgress;
}
@@ -777,10 +779,11 @@ where
let compute_tree_route = |from, to| -> Result<TreeRoute<Block>, String> {
match self.api.tree_route(from, to) {
Ok(tree_route) => Ok(tree_route),
Err(e) =>
Err(e) => {
return Err(format!(
"Error occurred while computing tree_route from {from:?} to {to:?}: {e}"
)),
))
},
}
};
let block_id_to_number =
@@ -22,7 +22,7 @@
// https://github.com/pezkuwichain/pezkuwi-sdk/issues/124#issuecomment-2808830472
use crate::zombienet::{BlockSubscriptionType, NetworkSpawner, ScenarioBuilderSharedParams};
use pezcumulus_zombienet_sdk_helpers::{create_assign_core_call};
use pezcumulus_zombienet_sdk_helpers::create_assign_core_call;
use serde_json::json;
use txtesttool::{execution_log::ExecutionLog, scenario::ScenarioBuilder};
use zombienet_sdk::{