Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+2 -2
View File
@@ -20,7 +20,7 @@
#![cfg(feature = "runtime-benchmarks")]
use crate::*;
use frame_benchmarking::{benchmarks, whitelisted_caller, impl_benchmark_test_suite};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_system::RawOrigin;
// To actually run this benchmark on pallet-example, we need to put this pallet into the
@@ -33,7 +33,7 @@ use frame_system::RawOrigin;
// Details on using the benchmarks macro can be seen at:
// https://substrate.dev/rustdocs/v3.0.0/frame_benchmarking/macro.benchmarks.html
benchmarks!{
benchmarks! {
// This will measure the execution time of `set_dummy` for b in [1..1000] range.
set_dummy_benchmark {
// This is the benchmark setup phase
+21 -31
View File
@@ -255,25 +255,21 @@
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::{
prelude::*,
marker::PhantomData
};
use codec::{Decode, Encode};
use frame_support::{
dispatch::DispatchResult, traits::IsSubType,
weights::{DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee, Pays},
};
use frame_system::{ensure_signed};
use codec::{Encode, Decode};
use sp_runtime::{
traits::{
SignedExtension, Bounded, SaturatedConversion, DispatchInfoOf, Saturating
},
transaction_validity::{
ValidTransaction, TransactionValidityError, InvalidTransaction, TransactionValidity,
},
dispatch::DispatchResult,
traits::IsSubType,
weights::{ClassifyDispatch, DispatchClass, Pays, PaysFee, WeighData, Weight},
};
use frame_system::ensure_signed;
use log::info;
use sp_runtime::{
traits::{Bounded, DispatchInfoOf, SaturatedConversion, Saturating, SignedExtension},
transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
},
};
use sp_std::{marker::PhantomData, prelude::*};
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
@@ -312,8 +308,7 @@ const MILLICENTS: u32 = 1_000_000_000;
// fulfilled by running the benchmarking toolchain. Refer to `benchmarking.rs` file.
struct WeightForSetDummy<T: pallet_balances::Config>(BalanceOf<T>);
impl<T: pallet_balances::Config> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
{
impl<T: pallet_balances::Config> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
fn weigh_data(&self, target: (&BalanceOf<T>,)) -> Weight {
let multiplier = self.0;
// *target.0 is the amount passed into the extrinsic
@@ -343,9 +338,9 @@ impl<T: pallet_balances::Config> PaysFee<(&BalanceOf<T>,)> for WeightForSetDummy
#[frame_support::pallet]
pub mod pallet {
// Import various types used to declare pallet in scope.
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use super::*;
/// Our pallet's configuration trait. All our types and constants go in here. If the
/// pallet is dependent on specific other pallets, then their configuration traits
@@ -397,7 +392,7 @@ pub mod pallet {
// but we could dispatch extrinsic (transaction/unsigned/inherent) using
// sp_io::submit_extrinsic.
// To see example on offchain worker, please refer to example-offchain-worker pallet
// accompanied in this repository.
// accompanied in this repository.
}
}
@@ -488,10 +483,7 @@ pub mod pallet {
#[pallet::weight(
<T as pallet::Config>::WeightInfo::accumulate_dummy((*increase_by).saturated_into())
)]
pub fn accumulate_dummy(
origin: OriginFor<T>,
increase_by: T::Balance
) -> DispatchResult {
pub fn accumulate_dummy(origin: OriginFor<T>, increase_by: T::Balance) -> DispatchResult {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
@@ -610,11 +602,7 @@ pub mod pallet {
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
dummy: Default::default(),
bar: Default::default(),
foo: Default::default(),
}
Self { dummy: Default::default(), bar: Default::default(), foo: Default::default() }
}
}
@@ -709,7 +697,9 @@ where
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
Ok(())
}
fn validate(
&self,
@@ -731,7 +721,7 @@ where
let mut valid_tx = ValidTransaction::default();
valid_tx.priority = Bounded::max_value();
Ok(valid_tx)
}
},
_ => Ok(Default::default()),
}
}
+9 -5
View File
@@ -20,14 +20,16 @@
use crate::*;
use frame_support::{
assert_ok, parameter_types,
weights::{DispatchInfo, GetDispatchInfo}, traits::OnInitialize
traits::OnInitialize,
weights::{DispatchInfo, GetDispatchInfo},
};
use sp_core::H256;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use sp_runtime::{
testing::Header, BuildStorage,
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
// Reexport crate as its pallet name for construct_runtime.
use crate as pallet_example;
@@ -115,7 +117,9 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
bar: vec![(1, 2), (2, 3)],
foo: 24,
},
}.build_storage().unwrap();
}
.build_storage()
.unwrap();
t.into()
}
@@ -163,7 +167,8 @@ fn signed_ext_watch_dummy_works() {
let info = DispatchInfo::default();
assert_eq!(
WatchDummy::<Test>(PhantomData).validate(&1, &call, &info, 150)
WatchDummy::<Test>(PhantomData)
.validate(&1, &call, &info, 150)
.unwrap()
.priority,
u64::MAX,
@@ -183,7 +188,6 @@ fn weights_work() {
// aka. `let info = <Call<Test> as GetDispatchInfo>::get_dispatch_info(&default_call);`
assert!(info1.weight > 0);
// `set_dummy` is simpler than `accumulate_dummy`, and the weight
// should be less.
let custom_call = <pallet_example::Call<Test>>::set_dummy(20);
+1
View File
@@ -45,6 +45,7 @@
// ./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]