difftreelog
fix benchmarks
in: master
5 files changed
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -31,7 +31,9 @@
create_collection_raw(
owner,
CollectionMode::Fungible(0),
- |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),
+ |owner: T::CrossAccountId, data| {
+ <Pallet<T>>::init_collection(owner.clone(), owner, data, Default::default())
+ },
FungibleHandle::cast,
)
}
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -62,7 +62,9 @@
create_collection_raw(
owner,
CollectionMode::ReFungible,
- |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),
+ |owner: T::CrossAccountId, data| {
+ <Pallet<T>>::init_collection(owner.clone(), owner, data, Default::default())
+ },
RefungibleHandle::cast,
)
}
pallets/scheduler/src/benchmarking.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license18// This file is part of Substrate.1920// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435//! Scheduler pallet benchmarking.3637use super::*;38use frame_benchmarking::{benchmarks, account};39use frame_support::{40 ensure,41 traits::{OnInitialize},42};43use frame_system::RawOrigin;44use sp_runtime::traits::Hash;45use sp_std::{prelude::*, vec};4647use crate::Pallet as Scheduler;48use frame_system::Pallet as System;49use frame_support::traits::Currency;5051const BLOCK_NUMBER: u32 = 2;5253/// Add `n` named items to the schedule.54///55/// For `resolved`:56/// - `None`: aborted (hash without preimage)57/// - `Some(true)`: hash resolves into call if possible, plain call otherwise58/// - `Some(false)`: plain call59fn fill_schedule<T: Config>(60 when: T::BlockNumber,61 n: u32,62 periodic: bool,63 resolved: Option<bool>,64) -> Result<(), &'static str> {65 let t = DispatchTime::At(when);66 let caller = account("user", 0, 1);6768 // Give the sender account max funds for transfer (their account will never reasonably be killed).69 T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());7071 for i in 0..n {72 let (call, hash) = call_and_hash::<T>(i);73 let call_or_hash = match resolved {74 Some(_) => call.into(),75 None => CallOrHashOf::<T>::Hash(hash),76 };77 let period = match periodic {78 true => Some(((i + 100).into(), 100)),79 false => None,80 };8182 let slice_id: [u8; 4] = i.encode().try_into().unwrap();83 let mut id: [u8; 16] = [0; 16];84 id[..4].clone_from_slice(&slice_id);8586 let origin = frame_system::RawOrigin::Signed(caller.clone()).into();87 Scheduler::<T>::do_schedule_named(id, t, period, 0, origin, call_or_hash)?;88 }89 ensure!(90 Agenda::<T>::get(when).len() == n as usize,91 "didn't fill schedule"92 );93 Ok(())94}9596fn call_and_hash<T: Config>(i: u32) -> (<T as Config>::Call, T::Hash) {97 // Essentially a no-op call.98 let call: <T as Config>::Call = frame_system::Call::remark { remark: i.encode() }.into();99 let hash = T::Hashing::hash_of(&call);100 (call, hash)101}102103benchmarks! {104 on_initialize_periodic_named_resolved {105 let s in 1 .. T::MaxScheduledPerBlock::get();106 let when = BLOCK_NUMBER.into();107 fill_schedule::<T>(when, s, true, Some(true))?;108 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }109 verify {110 assert_eq!(System::<T>::event_count(), s);111 for i in 0..s {112 assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);113 }114 }115116 on_initialize_named_resolved {117 let s in 1 .. T::MaxScheduledPerBlock::get();118 let when = BLOCK_NUMBER.into();119 fill_schedule::<T>(when, s, false, Some(true))?;120 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }121 verify {122 assert_eq!(System::<T>::event_count(), s);123 assert!(Agenda::<T>::iter().count() == 0);124 }125126 on_initialize_periodic {127 let s in 1 .. T::MaxScheduledPerBlock::get();128 let when = BLOCK_NUMBER.into();129 fill_schedule::<T>(when, s, true, Some(false))?;130 }: { Scheduler::<T>::on_initialize(when); }131 verify {132 assert_eq!(System::<T>::event_count(), s);133 for i in 0..s {134 assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);135 }136 }137138 on_initialize_periodic_resolved {139 let s in 1 .. T::MaxScheduledPerBlock::get();140 let when = BLOCK_NUMBER.into();141 fill_schedule::<T>(when, s, true, Some(true))?;142 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }143 verify {144 assert_eq!(System::<T>::event_count(), s );145 for i in 0..s {146 assert_eq!(Agenda::<T>::get(when + (i + 100).into()).len(), 1 as usize);147 }148 }149150 on_initialize_aborted {151 let s in 1 .. T::MaxScheduledPerBlock::get();152 let when = BLOCK_NUMBER.into();153 fill_schedule::<T>(when, s, false, None)?;154 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }155 verify {156 assert_eq!(System::<T>::event_count(), 0);157 }158159 on_initialize_named_aborted {160 let s in 1 .. T::MaxScheduledPerBlock::get();161 let when = BLOCK_NUMBER.into();162 fill_schedule::<T>(when, s, false, Some(false))?;163 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }164 verify {165 }166167 on_initialize_named {168 let s in 1 .. T::MaxScheduledPerBlock::get();169 let when = BLOCK_NUMBER.into();170 fill_schedule::<T>(when, s, false, None)?;171 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }172 verify {173 assert_eq!(System::<T>::event_count(), 0);174 }175176 on_initialize {177 let s in 1 .. T::MaxScheduledPerBlock::get();178 let when = BLOCK_NUMBER.into();179 fill_schedule::<T>(when, s, false, Some(false))?;180 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }181 verify {182 assert_eq!(System::<T>::event_count(), s);183 assert!(Agenda::<T>::iter().count() == 0);184 }185186 on_initialize_resolved {187 let s in 1 .. T::MaxScheduledPerBlock::get();188 let when = BLOCK_NUMBER.into();189 fill_schedule::<T>(when, s, false, Some(true))?;190 }: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }191 verify {192 assert_eq!(System::<T>::event_count(), s);193 assert!(Agenda::<T>::iter().count() == 0);194 }195196 schedule_named {197 let caller: T::AccountId = account("user", 0, 1);198 let origin: RawOrigin<T::AccountId> = frame_system::RawOrigin::Signed(caller.clone());199 let s in 0 .. T::MaxScheduledPerBlock::get();200 let slice_id: [u8; 4] = s.encode().try_into().unwrap();201 let mut id: [u8; 16] = [0; 16];202 id[..4].clone_from_slice(&slice_id);203 let when = BLOCK_NUMBER.into();204 let periodic = Some((T::BlockNumber::one(), 100));205 let priority = 0;206 // Essentially a no-op call.207 let inner_call = frame_system::Call::set_storage { items: vec![] }.into();208 let call = Box::new(CallOrHashOf::<T>::Value(inner_call));209 fill_schedule::<T>(when, s, true, Some(false))?;210 }: _(origin, id, when, periodic, priority, call)211 verify {212 ensure!(213 Agenda::<T>::get(when).len() == (s + 1) as usize,214 "didn't add to schedule"215 );216 }217218 cancel_named {219 let caller: T::AccountId = account("user", 0, 1);220 let origin: RawOrigin<T::AccountId> = frame_system::RawOrigin::Signed(caller.clone());221 let s in 1 .. T::MaxScheduledPerBlock::get();222 let when = BLOCK_NUMBER.into();223 let id = 0.encode().try_into().unwrap_or([0; MAX_TASK_ID_LENGTH_IN_BYTES as usize]);224 fill_schedule::<T>(when, s, true, Some(false))?;225 }: _(origin, id)226 verify {227 ensure!(228 Lookup::<T>::get(id).is_none(),229 "didn't remove from lookup"230 );231 // Removed schedule is NONE232 ensure!(233 Agenda::<T>::get(when)[0].is_none(),234 "didn't remove from schedule"235 );236 }237238 impl_benchmark_test_suite!(Scheduler, crate::mock::new_test_ext(), crate::mock::Test);239}pallets/structure/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -19,7 +19,8 @@
use frame_benchmarking::{benchmarks, account};
use frame_support::traits::{Currency, Get};
use up_data_structs::{
- CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
+ CreateCollectionData, CollectionMode, CreateItemData, CollectionFlags, CreateNftData,
+ budget::Unlimited,
};
use pallet_common::Config as CommonConfig;
use pallet_evm::account::CrossAccountId;
@@ -32,10 +33,15 @@
let caller_cross = T::CrossAccountId::from_sub(caller.clone());
<T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
- T::CollectionDispatch::create(caller_cross.clone(), caller_cross.clone(), CreateCollectionData {
- mode: CollectionMode::NFT,
- ..Default::default()
- })?;
+ T::CollectionDispatch::create(
+ caller_cross.clone(),
+ caller_cross.clone(),
+ CreateCollectionData {
+ mode: CollectionMode::NFT,
+ ..Default::default()
+ },
+ CollectionFlags::default(),
+ )?;
let dispatch = T::CollectionDispatch::dispatch(CollectionHandle::try_get(CollectionId(1))?);
let dispatch = dispatch.as_dyn();
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -683,8 +683,8 @@
#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
list_benchmark!(list, extra, pallet_refungible, Refungible);
- #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
- list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);
+ // #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
+ // list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);
#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);
@@ -743,8 +743,8 @@
#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
add_benchmark!(params, batches, pallet_refungible, Refungible);
- #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
- add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);
+ // #[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
+ // add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);
#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);