mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -32,7 +32,7 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
|
||||
}
|
||||
|
||||
fn add_proxies<T: Config>(n: u32, maybe_who: Option<T::AccountId>) -> Result<(), &'static str> {
|
||||
let caller = maybe_who.unwrap_or_else(|| whitelisted_caller());
|
||||
let caller = maybe_who.unwrap_or_else(whitelisted_caller);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
for i in 0..n {
|
||||
Proxy::<T>::add_proxy(
|
||||
@@ -77,7 +77,7 @@ fn add_announcements<T: Config>(
|
||||
|
||||
benchmarks! {
|
||||
proxy {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
// In this case the caller is the "target" proxy
|
||||
let caller: T::AccountId = account("target", p - 1, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
@@ -91,7 +91,7 @@ benchmarks! {
|
||||
|
||||
proxy_announced {
|
||||
let a in 0 .. T::MaxPending::get() - 1;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
// In this case the caller is the "target" proxy
|
||||
let caller: T::AccountId = account("anonymous", 0, SEED);
|
||||
let delegate: T::AccountId = account("target", p - 1, SEED);
|
||||
@@ -112,7 +112,7 @@ benchmarks! {
|
||||
|
||||
remove_announcement {
|
||||
let a in 0 .. T::MaxPending::get() - 1;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
// In this case the caller is the "target" proxy
|
||||
let caller: T::AccountId = account("target", p - 1, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
@@ -133,7 +133,7 @@ benchmarks! {
|
||||
|
||||
reject_announcement {
|
||||
let a in 0 .. T::MaxPending::get() - 1;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
// In this case the caller is the "target" proxy
|
||||
let caller: T::AccountId = account("target", p - 1, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
@@ -154,7 +154,7 @@ benchmarks! {
|
||||
|
||||
announce {
|
||||
let a in 0 .. T::MaxPending::get() - 1;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
// In this case the caller is the "target" proxy
|
||||
let caller: T::AccountId = account("target", p - 1, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
@@ -169,11 +169,11 @@ benchmarks! {
|
||||
}
|
||||
|
||||
add_proxy {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(
|
||||
RawOrigin::Signed(caller.clone()),
|
||||
account("target", T::MaxProxies::get().into(), SEED),
|
||||
account("target", T::MaxProxies::get(), SEED),
|
||||
T::ProxyType::default(),
|
||||
T::BlockNumber::zero()
|
||||
)
|
||||
@@ -183,7 +183,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
remove_proxy {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(
|
||||
RawOrigin::Signed(caller.clone()),
|
||||
@@ -197,7 +197,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
remove_proxies {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller.clone()))
|
||||
verify {
|
||||
@@ -206,7 +206,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
anonymous {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(
|
||||
RawOrigin::Signed(caller.clone()),
|
||||
@@ -225,7 +225,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
kill_anonymous {
|
||||
let p in 0 .. (T::MaxProxies::get() - 2).into();
|
||||
let p in 0 .. (T::MaxProxies::get() - 2);
|
||||
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
|
||||
@@ -196,7 +196,7 @@ pub mod pallet {
|
||||
/// # </weight>
|
||||
#[pallet::weight({
|
||||
let di = call.get_dispatch_info();
|
||||
(T::WeightInfo::proxy(T::MaxProxies::get().into())
|
||||
(T::WeightInfo::proxy(T::MaxProxies::get())
|
||||
.saturating_add(di.weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
@@ -230,7 +230,7 @@ pub mod pallet {
|
||||
/// # <weight>
|
||||
/// Weight is a function of the number of proxies the user has (P).
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::add_proxy(T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::add_proxy(T::MaxProxies::get()))]
|
||||
pub fn add_proxy(
|
||||
origin: OriginFor<T>,
|
||||
delegate: T::AccountId,
|
||||
@@ -252,7 +252,7 @@ pub mod pallet {
|
||||
/// # <weight>
|
||||
/// Weight is a function of the number of proxies the user has (P).
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::remove_proxy(T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::remove_proxy(T::MaxProxies::get()))]
|
||||
pub fn remove_proxy(
|
||||
origin: OriginFor<T>,
|
||||
delegate: T::AccountId,
|
||||
@@ -273,7 +273,7 @@ pub mod pallet {
|
||||
/// # <weight>
|
||||
/// Weight is a function of the number of proxies the user has (P).
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::remove_proxies(T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::remove_proxies(T::MaxProxies::get()))]
|
||||
pub fn remove_proxies(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let (_, old_deposit) = Proxies::<T>::take(&who);
|
||||
@@ -305,7 +305,7 @@ pub mod pallet {
|
||||
/// Weight is a function of the number of proxies the user has (P).
|
||||
/// # </weight>
|
||||
/// TODO: Might be over counting 1 read
|
||||
#[pallet::weight(T::WeightInfo::anonymous(T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::anonymous(T::MaxProxies::get()))]
|
||||
pub fn anonymous(
|
||||
origin: OriginFor<T>,
|
||||
proxy_type: T::ProxyType,
|
||||
@@ -356,7 +356,7 @@ pub mod pallet {
|
||||
/// # <weight>
|
||||
/// Weight is a function of the number of proxies the user has (P).
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::kill_anonymous(T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::kill_anonymous(T::MaxProxies::get()))]
|
||||
pub fn kill_anonymous(
|
||||
origin: OriginFor<T>,
|
||||
spawner: T::AccountId,
|
||||
@@ -398,7 +398,7 @@ pub mod pallet {
|
||||
/// - A: the number of announcements made.
|
||||
/// - P: the number of proxies the user has.
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::announce(T::MaxPending::get(), T::MaxProxies::get().into()))]
|
||||
#[pallet::weight(T::WeightInfo::announce(T::MaxPending::get(), T::MaxProxies::get()))]
|
||||
pub fn announce(
|
||||
origin: OriginFor<T>,
|
||||
real: T::AccountId,
|
||||
@@ -408,12 +408,12 @@ pub mod pallet {
|
||||
Proxies::<T>::get(&real)
|
||||
.0
|
||||
.into_iter()
|
||||
.find(|x| &x.delegate == &who)
|
||||
.find(|x| x.delegate == who)
|
||||
.ok_or(Error::<T>::NotProxy)?;
|
||||
|
||||
let announcement = Announcement {
|
||||
real: real.clone(),
|
||||
call_hash: call_hash.clone(),
|
||||
call_hash,
|
||||
height: system::Pallet::<T>::block_number(),
|
||||
};
|
||||
|
||||
@@ -452,9 +452,10 @@ pub mod pallet {
|
||||
/// - A: the number of announcements made.
|
||||
/// - P: the number of proxies the user has.
|
||||
/// # </weight>
|
||||
#[pallet::weight(
|
||||
T::WeightInfo::remove_announcement(T::MaxPending::get(), T::MaxProxies::get().into())
|
||||
)]
|
||||
#[pallet::weight(T::WeightInfo::remove_announcement(
|
||||
T::MaxPending::get(),
|
||||
T::MaxProxies::get()
|
||||
))]
|
||||
pub fn remove_announcement(
|
||||
origin: OriginFor<T>,
|
||||
real: T::AccountId,
|
||||
@@ -482,9 +483,10 @@ pub mod pallet {
|
||||
/// - A: the number of announcements made.
|
||||
/// - P: the number of proxies the user has.
|
||||
/// # </weight>
|
||||
#[pallet::weight(
|
||||
T::WeightInfo::reject_announcement(T::MaxPending::get(), T::MaxProxies::get().into())
|
||||
)]
|
||||
#[pallet::weight(T::WeightInfo::reject_announcement(
|
||||
T::MaxPending::get(),
|
||||
T::MaxProxies::get()
|
||||
))]
|
||||
pub fn reject_announcement(
|
||||
origin: OriginFor<T>,
|
||||
delegate: T::AccountId,
|
||||
@@ -517,7 +519,7 @@ pub mod pallet {
|
||||
/// # </weight>
|
||||
#[pallet::weight({
|
||||
let di = call.get_dispatch_info();
|
||||
(T::WeightInfo::proxy_announced(T::MaxPending::get(), T::MaxProxies::get().into())
|
||||
(T::WeightInfo::proxy_announced(T::MaxPending::get(), T::MaxProxies::get())
|
||||
.saturating_add(di.weight)
|
||||
// AccountData for inner call origin accountdata.
|
||||
.saturating_add(T::DbWeight::get().reads_writes(1, 1)),
|
||||
@@ -759,9 +761,9 @@ impl<T: Config> Pallet<T> {
|
||||
let new_deposit =
|
||||
if len == 0 { BalanceOf::<T>::zero() } else { base + factor * (len as u32).into() };
|
||||
if new_deposit > old_deposit {
|
||||
T::Currency::reserve(&who, new_deposit - old_deposit)?;
|
||||
T::Currency::reserve(who, new_deposit - old_deposit)?;
|
||||
} else if new_deposit < old_deposit {
|
||||
T::Currency::unreserve(&who, old_deposit - new_deposit);
|
||||
T::Currency::unreserve(who, old_deposit - new_deposit);
|
||||
}
|
||||
Ok(if len == 0 { None } else { Some(new_deposit) })
|
||||
}
|
||||
@@ -816,7 +818,7 @@ impl<T: Config> Pallet<T> {
|
||||
// has.
|
||||
Some(Call::add_proxy { ref proxy_type, .. }) |
|
||||
Some(Call::remove_proxy { ref proxy_type, .. })
|
||||
if !def.proxy_type.is_superset(&proxy_type) =>
|
||||
if !def.proxy_type.is_superset(proxy_type) =>
|
||||
false,
|
||||
// Proxy call cannot remove all proxies or kill anonymous proxies unless it has full
|
||||
// permissions.
|
||||
|
||||
Reference in New Issue
Block a user