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
+41 -11
View File
@@ -17,18 +17,43 @@
//! Interfaces, types and utils for benchmarking a FRAME runtime.
use codec::{Encode, Decode};
use sp_std::{vec::Vec, prelude::Box};
use sp_io::hashing::blake2_256;
use sp_storage::TrackedStorageKey;
use codec::{Decode, Encode};
use frame_support::traits::StorageInfo;
use sp_io::hashing::blake2_256;
use sp_std::{prelude::Box, vec::Vec};
use sp_storage::TrackedStorageKey;
/// An alphabet of possible parameters to use for benchmarking.
#[derive(Encode, Decode, Clone, Copy, PartialEq, Debug)]
#[allow(missing_docs)]
#[allow(non_camel_case_types)]
pub enum BenchmarkParameter {
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p,
q,
r,
s,
t,
u,
v,
w,
x,
y,
z,
}
#[cfg(feature = "std")]
@@ -105,7 +130,8 @@ pub trait Benchmarking {
/// WARNING! This is a non-deterministic call. Do not use this within
/// consensus critical logic.
fn current_time() -> u128 {
std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH)
std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.expect("Unix time doesn't go backwards; qed")
.as_nanos()
}
@@ -153,7 +179,7 @@ pub trait Benchmarking {
// If the key does not exist, add it.
None => {
whitelist.push(add);
}
},
}
self.set_whitelist(whitelist);
}
@@ -217,12 +243,16 @@ pub trait BenchmarkingSetup<T, I = ()> {
fn instance(
&self,
components: &[(BenchmarkParameter, u32)],
verify: bool
verify: bool,
) -> Result<Box<dyn FnOnce() -> Result<(), &'static str>>, &'static str>;
}
/// Grab an account, seeded by a name and index.
pub fn account<AccountId: Decode + Default>(name: &'static str, index: u32, seed: u32) -> AccountId {
pub fn account<AccountId: Decode + Default>(
name: &'static str,
index: u32,
seed: u32,
) -> AccountId {
let entropy = (name, index, seed).using_encoded(blake2_256);
AccountId::decode(&mut &entropy[..]).unwrap_or_default()
}
@@ -236,7 +266,7 @@ pub fn whitelisted_caller<AccountId: Decode + Default>() -> AccountId {
macro_rules! whitelist_account {
($acc:ident) => {
frame_benchmarking::benchmarking::add_to_whitelist(
frame_system::Account::<T>::hashed_key_for(&$acc).into()
frame_system::Account::<T>::hashed_key_for(&$acc).into(),
);
}
};
}