diff --git a/pallets/gas-transaction-payment/Cargo.toml b/pallets/gas-transaction-payment/Cargo.toml index 21540d6..8950324 100644 --- a/pallets/gas-transaction-payment/Cargo.toml +++ b/pallets/gas-transaction-payment/Cargo.toml @@ -26,6 +26,14 @@ sp-io = {workspace = true} [features] default = ["std"] +runtime-benchmarks=[ + "fc-traits-gas-tank/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] std = [ "codec/std", "fc-traits-gas-tank/std", diff --git a/pallets/gas-transaction-payment/src/extensions.rs b/pallets/gas-transaction-payment/src/extensions.rs index 8e2d093..088649a 100644 --- a/pallets/gas-transaction-payment/src/extensions.rs +++ b/pallets/gas-transaction-payment/src/extensions.rs @@ -99,7 +99,7 @@ where info: &DispatchInfoOf, len: usize, ) -> frame_support::pallet_prelude::TransactionValidity { - if let Some(_) = T::GasBurner::check_available_gas(who, &info.weight) { + if T::GasBurner::check_available_gas(who, &info.weight).is_some() { Ok(ValidTransaction::default()) } else { self.0.validate(who, call, info, len) @@ -115,13 +115,9 @@ where ) -> Result<(), frame_support::pallet_prelude::TransactionValidityError> { if let Some((who, pre)) = pre { match pre { - Pre::Inner(inner_pre) => S::post_dispatch( - Some(inner_pre), - &info.clone().into(), - post_info, - len, - result, - )?, + Pre::Inner(inner_pre) => { + S::post_dispatch(Some(inner_pre), info, post_info, len, result)? + } Pre::Burner(expected_remaining) => { let used_gas = post_info.actual_weight.unwrap_or(info.weight); let should_burn_gas = post_info.pays_fee == Pays::Yes; diff --git a/pallets/pass/src/benchmarking.rs b/pallets/pass/src/benchmarking.rs index 38f750f..7772ce8 100644 --- a/pallets/pass/src/benchmarking.rs +++ b/pallets/pass/src/benchmarking.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "runtime-benchmarks")] - use super::*; use crate::Pallet; use frame_benchmarking::v2::*; @@ -29,7 +27,6 @@ where #[instance_benchmarks( where - T: frame_system::Config + crate::Config, OriginFor: From>, T::Hash: Into, RuntimeEventFor: From>, @@ -41,7 +38,7 @@ mod benchmarks { pub fn register() -> Result<(), BenchmarkError> { // Setup code let origin = T::BenchmarkHelper::register_origin(); - let user_id = hash::(&*b"my-account"); + let user_id = hash::(b"my-account"); let account_id = Pallet::::account_id_for(user_id)?; let device_id = [0u8; 32]; diff --git a/pallets/pass/src/lib.rs b/pallets/pass/src/lib.rs index ff6a078..e191006 100644 --- a/pallets/pass/src/lib.rs +++ b/pallets/pass/src/lib.rs @@ -150,9 +150,6 @@ pub mod pallet { } #[pallet::call_index(3)] - // #[pallet::feeless_if( - // |_: &OriginFor, _: &DeviceId, _: &CredentialOf, _: &Option>| true - // )] pub fn authenticate( origin: OriginFor, device_id: DeviceId, @@ -166,7 +163,7 @@ pub mod pallet { Error::::AccountNotFound ); - let device = Devices::::get(&account_id, &device_id) + let device = Devices::::get(&account_id, device_id) .ok_or(Error::::DeviceNotFound)?; device .verify_user(&credential) @@ -259,13 +256,10 @@ impl, I: 'static> Pallet { .ok_or(Error::::DeviceAttestationInvalid)?; Devices::::insert(who, device_id, device); - Self::deposit_event( - Event::::AddedDevice { - who: who.clone(), - device_id: device_id.clone(), - } - .into(), - ); + Self::deposit_event(Event::::AddedDevice { + who: who.clone(), + device_id: *device_id, + }); Ok(()) } @@ -315,12 +309,9 @@ impl, I: 'static> Pallet { Sessions::::insert(session_key.clone(), (account_id.clone(), until)); - Self::deposit_event( - Event::::SessionCreated { - session_key: session_key.clone(), - until, - } - .into(), - ); + Self::deposit_event(Event::::SessionCreated { + session_key: session_key.clone(), + until, + }); } } diff --git a/pallets/referenda-tracks/src/benchmarking.rs b/pallets/referenda-tracks/src/benchmarking.rs index e25240f..27edf40 100644 --- a/pallets/referenda-tracks/src/benchmarking.rs +++ b/pallets/referenda-tracks/src/benchmarking.rs @@ -17,8 +17,6 @@ //! Benchmarks for remarks pallet -#![cfg(feature = "runtime-benchmarks")] - use super::*; use crate::{Event, OriginToTrackId, Pallet as ReferendaTracks, Tracks, TracksIds}; use frame_benchmarking::v2::*; @@ -82,8 +80,8 @@ fn prepare_tracks, I: 'static>(full: bool) { *tracks_ids = BoundedVec::truncate_from(ids.clone()); }); ids.iter().for_each(|id| { - Tracks::::insert(id.clone(), track.clone()); - OriginToTrackId::::insert(origin.clone(), id.clone()); + Tracks::::insert(id, track.clone()); + OriginToTrackId::::insert(origin.clone(), id); }); if full { diff --git a/pallets/referenda-tracks/src/impls.rs b/pallets/referenda-tracks/src/impls.rs index 25d5439..cf39e1a 100644 --- a/pallets/referenda-tracks/src/impls.rs +++ b/pallets/referenda-tracks/src/impls.rs @@ -38,7 +38,7 @@ impl, I> fc_traits_tracks::MutateTracks, BlockNumbe origin: Self::RuntimeOrigin, ) -> DispatchResult { ensure!( - Tracks::::get(id) == None, + Tracks::::get(id).is_none(), Error::::TrackIdAlreadyExisting ); @@ -93,6 +93,6 @@ impl, I> fc_traits_tracks::MutateTracks, BlockNumbe })?; Self::deposit_event(Event::Removed { id }); - Ok(().into()) + Ok(()) } } diff --git a/pallets/referenda-tracks/src/lib.rs b/pallets/referenda-tracks/src/lib.rs index 24b67d8..02b1bb4 100644 --- a/pallets/referenda-tracks/src/lib.rs +++ b/pallets/referenda-tracks/src/lib.rs @@ -83,7 +83,7 @@ pub mod pallet { type TrackId: Parameter + Member + Copy + MaxEncodedLen + Ord; type MaxTracks: Get; - /// + type WeightInfo: WeightInfo; #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/template/src/benchmarking.rs b/pallets/template/src/benchmarking.rs index 3cc8d35..c13403f 100644 --- a/pallets/template/src/benchmarking.rs +++ b/pallets/template/src/benchmarking.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "runtime-benchmarks")] - use super::*; use crate::Pallet; use frame_benchmarking::v2::*; diff --git a/traits/gas-tank/Cargo.toml b/traits/gas-tank/Cargo.toml index 67a3d26..c49d421 100644 --- a/traits/gas-tank/Cargo.toml +++ b/traits/gas-tank/Cargo.toml @@ -20,6 +20,13 @@ sp-io.workspace = true [features] default = ["std"] +runtime-benchmarks=[ + "pallet-balances/runtime-benchmarks", + "pallet-nfts/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] std = [ "codec/std", "pallet-balances/std", diff --git a/traits/memberships/src/lib.rs b/traits/memberships/src/lib.rs index f0de079..25d6e77 100644 --- a/traits/memberships/src/lib.rs +++ b/traits/memberships/src/lib.rs @@ -95,7 +95,7 @@ impl GenericRank { Self(self.0.saturating_add(n.get()).min(Self::MAX.0)) } pub fn demote_by(self, n: NonZeroU8) -> Self { - Self(self.0.saturating_sub(n.get()).max(Self::MIN.0)) + Self(self.0.saturating_sub(n.get())) } } impl From for u8 {