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
@@ -224,8 +224,8 @@ fn post_process_wasm(input_path: &Path, output_path: &Path) -> Result<()> {
deserialize_file(input_path).with_context(|| format!("Failed to read {:?}", input_path))?;
if let Some(section) = module.export_section_mut() {
section.entries_mut().retain(|entry| {
matches!(entry.internal(), Internal::Function(_)) &&
(entry.field() == "call" || entry.field() == "deploy")
matches!(entry.internal(), Internal::Function(_))
&& (entry.field() == "call" || entry.field() == "deploy")
});
}
@@ -114,8 +114,9 @@ pub mod pezpallet {
max_weight,
Weight::zero(),
) {
Outcome::Error(InstructionError { error, .. }) =>
(Err(error), Event::Fail(Some(hash), error)),
Outcome::Error(InstructionError { error, .. }) => {
(Err(error), Event::Fail(Some(hash), error))
},
Outcome::Complete { used } => (Ok(used), Event::Success(Some(hash))),
// As far as the caller is concerned, this was dispatched without error, so
// we just report the weight used.
@@ -177,8 +177,8 @@ pub fn estimate_weight(number_of_instructions: u64) -> Weight {
pub fn estimate_fee_for_weight(weight: Weight) -> u128 {
let (_, units_per_second, units_per_mb) = TokensPerSecondPerMegabyte::get();
units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128) +
units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)
units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128)
+ units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)
}
pub type LocalBalancesTransactor =
@@ -391,7 +391,8 @@ impl EnvDef {
fn is_valid_special_arg(idx: usize, arg: &FnArg) -> bool {
let FnArg::Typed(pat) = arg else { return false };
let ident = if let syn::Pat::Ident(ref ident) = *pat.pat { &ident.ident } else { return false };
let ident =
if let syn::Pat::Ident(ref ident) = *pat.pat { &ident.ident } else { return false };
let name_ok = match idx {
0 => ident == "ctx" || ident == "_ctx",
1 => ident == "memory" || ident == "_memory",
@@ -568,10 +568,10 @@ mod benchmarks {
// value and value transferred via call should be removed from the caller
assert_eq!(
T::Currency::balance(&instance.caller),
caller_funding::<T>() -
instance.value -
value - deposit -
Pezpallet::<T>::min_balance(),
caller_funding::<T>()
- instance.value
- value - deposit
- Pezpallet::<T>::min_balance(),
);
// contract should have received the value
assert_eq!(T::Currency::balance(&instance.account_id), before + value);
+6 -5
View File
@@ -884,9 +884,9 @@ where
// `Relaxed` will only be ever set in case of off-chain execution.
// Instantiations are never allowed even when executing off-chain.
if !(executable.is_deterministic() ||
(matches!(determinism, Determinism::Relaxed) &&
matches!(entry_point, ExportedFunction::Call)))
if !(executable.is_deterministic()
|| (matches!(determinism, Determinism::Relaxed)
&& matches!(entry_point, ExportedFunction::Call)))
{
return Err(Error::<T>::Indeterministic.into());
}
@@ -1064,8 +1064,9 @@ where
with_transaction(|| -> TransactionOutcome<Result<_, DispatchError>> {
let output = do_transaction();
match &output {
Ok(result) if !result.did_revert() =>
TransactionOutcome::Commit(Ok((true, output))),
Ok(result) if !result.did_revert() => {
TransactionOutcome::Commit(Ok((true, output)))
},
_ => TransactionOutcome::Rollback(Ok((false, output))),
}
});
+10 -8
View File
@@ -694,8 +694,8 @@ pub mod pezpallet {
// We can use storage to store items using the available block ref_time with the
// `set_storage` host function.
let max_storage_size: u32 = ((max_block_ref_time /
(<RuntimeCosts as gas::Token<T>>::weight(&RuntimeCosts::SetStorage {
let max_storage_size: u32 = ((max_block_ref_time
/ (<RuntimeCosts as gas::Token<T>>::weight(&RuntimeCosts::SetStorage {
new_bytes: max_payload_size,
old_bytes: 0,
})
@@ -717,8 +717,8 @@ pub mod pezpallet {
// We can use storage to store events using the available block ref_time with the
// `deposit_event` host function. The overhead of stored events, which is around 100B,
// is not taken into account to simplify calculations, as it does not change much.
let max_events_size: u32 = ((max_block_ref_time /
(<RuntimeCosts as gas::Token<T>>::weight(&RuntimeCosts::DepositEvent {
let max_events_size: u32 = ((max_block_ref_time
/ (<RuntimeCosts as gas::Token<T>>::weight(&RuntimeCosts::DepositEvent {
num_topic: 0,
len: max_payload_size,
})
@@ -1570,12 +1570,13 @@ impl<T: Config> Invokable<T> for CallInput<T> {
let mut storage_meter =
match StorageMeter::new(&origin, common.storage_deposit_limit, common.value) {
Ok(meter) => meter,
Err(err) =>
Err(err) => {
return InternalOutput {
result: Err(err.into()),
gas_meter,
storage_deposit: Default::default(),
},
}
},
};
let schedule = T::Schedule::get();
let result = ExecStack::<T, WasmBlob<T>>::run_call(
@@ -1780,7 +1781,7 @@ impl<T: Config> Pezpallet<T> {
let (module, deposit) = match result {
Ok(result) => result,
Err(error) =>
Err(error) => {
return ContractResult {
gas_consumed: Zero::zero(),
gas_required: Zero::zero(),
@@ -1788,7 +1789,8 @@ impl<T: Config> Pezpallet<T> {
debug_message: debug_message.unwrap_or(Default::default()).into(),
result: Err(error),
events: events(),
},
}
},
};
storage_deposit_limit =
@@ -308,8 +308,8 @@ where
&contract.deposit_account,
);
ensure!(
deposit ==
contract
deposit
== contract
.storage_base_deposit
.saturating_add(contract.storage_item_deposit)
.saturating_add(contract.storage_byte_deposit),
@@ -249,8 +249,8 @@ where
old_balance_allocation.total
);
ensure!(
T::Currency::total_balance(&owner) ==
BalanceOf::<T>::decode(&mut &old_balance_allocation.total.encode()[..])
T::Currency::total_balance(&owner)
== BalanceOf::<T>::decode(&mut &old_balance_allocation.total.encode()[..])
.unwrap(),
"Balance mismatch "
);
@@ -315,18 +315,18 @@ impl<T: Config> MigrationStep for Migration<T> {
"code_hash mismatch"
);
ensure!(
migration_contract_info.storage_byte_deposit ==
crate_contract_info.storage_byte_deposit,
migration_contract_info.storage_byte_deposit
== crate_contract_info.storage_byte_deposit,
"storage_byte_deposit mismatch"
);
ensure!(
migration_contract_info.storage_base_deposit ==
crate_contract_info.storage_base_deposit(),
migration_contract_info.storage_base_deposit
== crate_contract_info.storage_base_deposit(),
"storage_base_deposit mismatch"
);
ensure!(
&migration_contract_info.delegate_dependencies ==
crate_contract_info.delegate_dependencies(),
&migration_contract_info.delegate_dependencies
== crate_contract_info.delegate_dependencies(),
"delegate_dependencies mismatch"
);
}
@@ -200,18 +200,20 @@ where
match (self, rhs) {
(Charge(lhs), Charge(rhs)) => Charge(lhs.saturating_add(*rhs)),
(Refund(lhs), Refund(rhs)) => Refund(lhs.saturating_add(*rhs)),
(Charge(lhs), Refund(rhs)) =>
(Charge(lhs), Refund(rhs)) => {
if lhs >= rhs {
Charge(lhs.saturating_sub(*rhs))
} else {
Refund(rhs.saturating_sub(*lhs))
},
(Refund(lhs), Charge(rhs)) =>
}
},
(Refund(lhs), Charge(rhs)) => {
if lhs > rhs {
Refund(lhs.saturating_sub(*rhs))
} else {
Charge(rhs.saturating_sub(*lhs))
},
}
},
}
}
@@ -221,18 +223,20 @@ where
match (self, rhs) {
(Charge(lhs), Refund(rhs)) => Charge(lhs.saturating_add(*rhs)),
(Refund(lhs), Charge(rhs)) => Refund(lhs.saturating_add(*rhs)),
(Charge(lhs), Charge(rhs)) =>
(Charge(lhs), Charge(rhs)) => {
if lhs >= rhs {
Charge(lhs.saturating_sub(*rhs))
} else {
Refund(rhs.saturating_sub(*lhs))
},
(Refund(lhs), Refund(rhs)) =>
}
},
(Refund(lhs), Refund(rhs)) => {
if lhs > rhs {
Refund(lhs.saturating_sub(*rhs))
} else {
Charge(rhs.saturating_sub(*lhs))
},
}
},
}
}
+5 -4
View File
@@ -198,12 +198,13 @@ impl<T: Config> ContractInfo<T> {
if let Some(storage_meter) = storage_meter {
let mut diff = meter::Diff::default();
match (old_len, new_value.as_ref().map(|v| v.len() as u32)) {
(Some(old_len), Some(new_len)) =>
(Some(old_len), Some(new_len)) => {
if new_len > old_len {
diff.bytes_added = new_len - old_len;
} else {
diff.bytes_removed = old_len - new_len;
},
}
},
(None, Some(new_len)) => {
diff.bytes_added = new_len;
diff.items_added = 1;
@@ -297,8 +298,8 @@ impl<T: Config> ContractInfo<T> {
/// of those keys can be deleted from the deletion queue given the supplied weight limit.
pub fn deletion_budget(meter: &WeightMeter) -> (Weight, u32) {
let base_weight = T::WeightInfo::on_process_deletion_queue_batch();
let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) -
T::WeightInfo::on_initialize_per_trie_key(0);
let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1)
- T::WeightInfo::on_initialize_per_trie_key(0);
// `weight_per_key` being zero makes no sense and would constitute a failure to
// benchmark properly. We opt for not removing any keys at all in this case.
@@ -194,16 +194,20 @@ impl Diff {
info.storage_items =
info.storage_items.saturating_add(items_added).saturating_sub(items_removed);
match &bytes_deposit {
Deposit::Charge(amount) =>
info.storage_byte_deposit = info.storage_byte_deposit.saturating_add(*amount),
Deposit::Refund(amount) =>
info.storage_byte_deposit = info.storage_byte_deposit.saturating_sub(*amount),
Deposit::Charge(amount) => {
info.storage_byte_deposit = info.storage_byte_deposit.saturating_add(*amount)
},
Deposit::Refund(amount) => {
info.storage_byte_deposit = info.storage_byte_deposit.saturating_sub(*amount)
},
}
match &items_deposit {
Deposit::Charge(amount) =>
info.storage_item_deposit = info.storage_item_deposit.saturating_add(*amount),
Deposit::Refund(amount) =>
info.storage_item_deposit = info.storage_item_deposit.saturating_sub(*amount),
Deposit::Charge(amount) => {
info.storage_item_deposit = info.storage_item_deposit.saturating_add(*amount)
},
Deposit::Refund(amount) => {
info.storage_item_deposit = info.storage_item_deposit.saturating_sub(*amount)
},
}
bytes_deposit.saturating_add(&items_deposit)
@@ -265,8 +269,9 @@ impl<T: Config> Contribution<T> {
fn update_contract(&self, info: Option<&mut ContractInfo<T>>) -> DepositOf<T> {
match self {
Self::Alive(diff) => diff.update_contract::<T>(info),
Self::Terminated { deposit, beneficiary: _ } | Self::Checked(deposit) =>
deposit.clone(),
Self::Terminated { deposit, beneficiary: _ } | Self::Checked(deposit) => {
deposit.clone()
},
}
}
}
@@ -346,8 +351,9 @@ where
/// Returns the state of the currently executed contract.
fn contract_state(&self) -> ContractState<T> {
match &self.own_contribution {
Contribution::Terminated { deposit: _, beneficiary } =>
ContractState::Terminated { beneficiary: beneficiary.clone() },
Contribution::Terminated { deposit: _, beneficiary } => {
ContractState::Terminated { beneficiary: beneficiary.clone() }
},
_ => ContractState::Alive,
}
}
@@ -524,8 +530,8 @@ impl<T: Config> Ext<T> for ReservingExt {
let default = max.min(T::DefaultDepositLimit::get());
let limit = limit.unwrap_or(default);
ensure!(
limit <= max &&
matches!(T::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success),
limit <= max
&& matches!(T::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success),
<Error<T>>::StorageDepositNotEnoughFunds,
);
Ok(limit)
+2 -2
View File
@@ -150,8 +150,8 @@ pub mod test_utils {
let code_info_len = CodeInfo::<Test>::max_encoded_len() as u64;
// Calculate deposit to be reserved.
// We add 2 storage items: one for code, other for code_info
DepositPerByte::get().saturating_mul(code_len as u64 + code_info_len) +
DepositPerItem::get().saturating_mul(2)
DepositPerByte::get().saturating_mul(code_len as u64 + code_info_len)
+ DepositPerItem::get().saturating_mul(2)
}
pub fn ensure_stored(code_hash: CodeHash<Test>) -> usize {
// Assert that code_info is stored
@@ -690,8 +690,9 @@ mod tests {
let entry = self.storage.entry(key.clone());
let result = match (entry, take_old) {
(Entry::Vacant(_), _) => WriteOutcome::New,
(Entry::Occupied(entry), false) =>
WriteOutcome::Overwritten(entry.remove().len() as u32),
(Entry::Occupied(entry), false) => {
WriteOutcome::Overwritten(entry.remove().len() as u32)
},
(Entry::Occupied(entry), true) => WriteOutcome::Taken(entry.remove()),
};
if let Some(value) = value {
@@ -133,16 +133,17 @@ impl LoadedModule {
match export.name() {
"call" => call_found = true,
"deploy" => deploy_found = true,
_ =>
_ => {
return Err(
"unknown function export: expecting only deploy and call functions",
),
)
},
}
// Check the signature.
// Both "call" and "deploy" have the () -> () function type.
// We still support () -> (i32) for backwards compatibility.
if !(ft.params().is_empty() &&
(ft.results().is_empty() || ft.results() == [WasmiValueType::I32]))
if !(ft.params().is_empty()
&& (ft.results().is_empty() || ft.results() == [WasmiValueType::I32]))
{
return Err("entry point has wrong signature");
}
@@ -194,9 +195,9 @@ impl LoadedModule {
ExternType::Func(_) => {
import.ty().func().ok_or("expected a function")?;
if !<T as Config>::ChainExtension::enabled() &&
(import.name().as_bytes() == b"seal_call_chain_extension" ||
import.name().as_bytes() == b"call_chain_extension")
if !<T as Config>::ChainExtension::enabled()
&& (import.name().as_bytes() == b"seal_call_chain_extension"
|| import.name().as_bytes() == b"call_chain_extension")
{
return Err(
"Module uses chain extensions but chain extensions are disabled",
@@ -364,8 +364,9 @@ impl<T: Config> Token<T> for RuntimeCosts {
DelegateCallBase => T::WeightInfo::seal_delegate_call(),
CallTransferSurcharge => cost_args!(seal_call, 1, 0),
CallInputCloned(len) => cost_args!(seal_call, 0, len),
Instantiate { input_data_len, salt_len } =>
T::WeightInfo::seal_instantiate(input_data_len, salt_len),
Instantiate { input_data_len, salt_len } => {
T::WeightInfo::seal_instantiate(input_data_len, salt_len)
},
HashSha256(len) => T::WeightInfo::seal_hash_sha2_256(len),
HashKeccak256(len) => T::WeightInfo::seal_hash_keccak_256(len),
HashBlake256(len) => T::WeightInfo::seal_hash_blake2_256(len),
@@ -481,8 +482,9 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
ReturnFlags::from_bits(*flags).ok_or(Error::<E::T>::InvalidCallFlags)?;
return Ok(ExecReturnValue { flags, data: data.to_vec() });
},
Termination =>
return Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: Vec::new() }),
Termination => {
return Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: Vec::new() })
},
SupervisorError(error) => return Err((*error).into()),
}
}
@@ -2271,8 +2273,9 @@ pub mod env {
Environment::new(ctx, memory, id, input_ptr, input_len, output_ptr, output_len_ptr);
let ret = match chain_extension.call(env)? {
RetVal::Converging(val) => Ok(val),
RetVal::Diverging { flags, data } =>
Err(TrapReason::Return(ReturnData { flags: flags.bits(), data })),
RetVal::Diverging { flags, data } => {
Err(TrapReason::Return(ReturnData { flags: flags.bits(), data }))
},
};
ctx.chain_extension = Some(chain_extension);
ret
@@ -308,7 +308,7 @@ mod sys {
// (v1) => [gas_left],
// }
// ```
//
//
// Expands to:
// ```nocompile
// fn gas_left(output: &mut &mut [u8]) {