mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 23:31:07 +00:00
Restructure frame_benchmarking macro related exports (#14787)
* make reexports private * make reexports private 2 * make reexports private for runtime-benchmarking * make reexports private for try-runtime * fix for try-runtime * make reexports private for tests * fmt * make reexports private for tests * make reexports private for experimental * fix beefy * fix ui test * fix ui test * fix benches * ".git/.scripts/commands/fmt/fmt.sh" * fix contracts use * wip * wip * do not reexport sp_api::metadata_ir * fix CI checks * fix support tests * ".git/.scripts/commands/fmt/fmt.sh" * Update frame/support/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * import codec directly * fmt * wip * wip * remove benchmarking private exports * fix zepter warning * fix imports * partially fix node-cli tests * fix node-cli tests * fix node-cli build * fix zepter warning * fix test * fix ui test * fix ci * remove unnecessary imports * add import back * add import back --------- Co-authored-by: command-bot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Generated
+5
@@ -4318,6 +4318,7 @@ dependencies = [
|
||||
"sp-staking",
|
||||
"sp-statement-store",
|
||||
"sp-std",
|
||||
"sp-storage",
|
||||
"sp-transaction-pool",
|
||||
"sp-version",
|
||||
"static_assertions",
|
||||
@@ -5825,6 +5826,7 @@ dependencies = [
|
||||
"sp-runtime",
|
||||
"sp-session",
|
||||
"sp-std",
|
||||
"sp-storage",
|
||||
"sp-transaction-pool",
|
||||
"sp-version",
|
||||
"substrate-wasm-builder",
|
||||
@@ -6676,6 +6678,7 @@ dependencies = [
|
||||
"parity-scale-codec",
|
||||
"sp-npos-elections",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7652,6 +7655,7 @@ dependencies = [
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7669,6 +7673,7 @@ dependencies = [
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
"sp-storage",
|
||||
"sp-timestamp",
|
||||
]
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ scale-info = { version = "2.5.0", default-features = false, features = ["derive"
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../../../../frame/benchmarking" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/support" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/system" }
|
||||
sp-std = { version = "8.0.0", default-features = false, path = "../../../../primitives/std" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-core = { version = "21.0.0", path = "../../../../primitives/core" }
|
||||
@@ -37,6 +38,7 @@ std = [
|
||||
"sp-core/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Benchmarking setup for pallet-template
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
use super::*;
|
||||
use sp_std::vec;
|
||||
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Template;
|
||||
|
||||
@@ -36,6 +36,7 @@ sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../.
|
||||
sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" }
|
||||
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" }
|
||||
sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" }
|
||||
sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" }
|
||||
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" }
|
||||
sp-version = { version = "22.0.0", default-features = false, path = "../../../primitives/version" }
|
||||
|
||||
@@ -84,6 +85,7 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
"sp-std/std",
|
||||
"sp-storage/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-version/std",
|
||||
"substrate-wasm-builder",
|
||||
|
||||
@@ -531,8 +531,8 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
|
||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
|
||||
use sp_storage::TrackedStorageKey;
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
use baseline::Pallet as BaselineBench;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ sp-std = { version = "8.0.0", default-features = false, path = "../../../primiti
|
||||
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" }
|
||||
sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" }
|
||||
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" }
|
||||
sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" }
|
||||
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" }
|
||||
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" }
|
||||
sp-statement-store = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/statement-store" }
|
||||
@@ -232,6 +233,7 @@ std = [
|
||||
"sp-staking/std",
|
||||
"sp-statement-store/std",
|
||||
"sp-std/std",
|
||||
"sp-storage/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-version/std",
|
||||
"substrate-wasm-builder",
|
||||
|
||||
@@ -2570,7 +2570,8 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
|
||||
use sp_storage::TrackedStorageKey;
|
||||
|
||||
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
|
||||
// issues. To get around that, we separated the Session benchmarks into its own crate,
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::benchmarks;
|
||||
use frame_system::Pallet as System;
|
||||
use sp_runtime::{
|
||||
traits::{AppVerify, Hash},
|
||||
RuntimeAppPublic,
|
||||
};
|
||||
use sp_std::{vec, vec::Vec};
|
||||
|
||||
mod crypto {
|
||||
use sp_application_crypto::{app_crypto, sr25519, KeyTypeId};
|
||||
@@ -110,7 +110,6 @@ benchmarks! {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod mock {
|
||||
use super::*;
|
||||
use sp_runtime::{testing::H256, BuildStorage};
|
||||
|
||||
type AccountId = u64;
|
||||
|
||||
@@ -28,29 +28,27 @@ mod tests_instance;
|
||||
mod utils;
|
||||
|
||||
pub mod baseline;
|
||||
pub mod v1;
|
||||
|
||||
/// Private exports that are being used by macros.
|
||||
///
|
||||
/// The exports are not stable and should not be relied on.
|
||||
#[doc(hidden)]
|
||||
pub mod __private {
|
||||
pub use codec;
|
||||
pub use frame_support::{storage, traits};
|
||||
pub use log;
|
||||
pub use paste;
|
||||
pub use sp_core::defer;
|
||||
pub use sp_io::storage::root as storage_root;
|
||||
pub use sp_runtime::{traits::Zero, StateVersion};
|
||||
pub use sp_std::{self, boxed::Box, str, vec, vec::Vec};
|
||||
pub use sp_storage::{well_known_keys, TrackedStorageKey};
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector};
|
||||
#[doc(hidden)]
|
||||
pub use frame_support;
|
||||
#[doc(hidden)]
|
||||
pub use log;
|
||||
#[doc(hidden)]
|
||||
pub use paste;
|
||||
#[doc(hidden)]
|
||||
pub use sp_core::defer;
|
||||
#[doc(hidden)]
|
||||
pub use sp_io::storage::root as storage_root;
|
||||
#[doc(hidden)]
|
||||
pub use sp_runtime::traits::Zero;
|
||||
#[doc(hidden)]
|
||||
pub use sp_runtime::StateVersion;
|
||||
#[doc(hidden)]
|
||||
pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec};
|
||||
pub use sp_storage::{well_known_keys, TrackedStorageKey};
|
||||
pub use utils::*;
|
||||
|
||||
pub mod v1;
|
||||
pub use v1::*;
|
||||
|
||||
/// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax.
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use frame_support::{parameter_types, traits::ConstU32};
|
||||
use sp_runtime::{
|
||||
testing::H256,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use frame_support::traits::ConstU32;
|
||||
use sp_runtime::{
|
||||
testing::H256,
|
||||
|
||||
@@ -429,7 +429,7 @@ macro_rules! benchmarks_iter {
|
||||
verify $postcode:block
|
||||
$( $rest:tt )*
|
||||
) => {
|
||||
$crate::paste::paste! {
|
||||
$crate::__private::paste::paste! {
|
||||
$crate::benchmarks_iter! {
|
||||
{ $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? }
|
||||
{ $( $instance: $instance_bound )? }
|
||||
@@ -446,17 +446,17 @@ macro_rules! benchmarks_iter {
|
||||
>:: [< new_call_variant_ $dispatch >] (
|
||||
$($arg),*
|
||||
);
|
||||
let __benchmarked_call_encoded = $crate::frame_support::__private::codec::Encode::encode(
|
||||
let __benchmarked_call_encoded = $crate::__private::codec::Encode::encode(
|
||||
&__call
|
||||
);
|
||||
}: {
|
||||
let __call_decoded = <
|
||||
Call<T $(, $instance )?>
|
||||
as $crate::frame_support::__private::codec::Decode
|
||||
as $crate::__private::codec::Decode
|
||||
>::decode(&mut &__benchmarked_call_encoded[..])
|
||||
.expect("call is encoded above, encoding must be correct");
|
||||
let __origin = $crate::to_origin!($origin $(, $origin_type)?);
|
||||
<Call<T $(, $instance)? > as $crate::frame_support::traits::UnfilteredDispatchable
|
||||
<Call<T $(, $instance)? > as $crate::__private::traits::UnfilteredDispatchable
|
||||
>::dispatch_bypass_filter(__call_decoded, __origin)?;
|
||||
}
|
||||
verify $postcode
|
||||
@@ -776,8 +776,8 @@ macro_rules! benchmark_backend {
|
||||
$crate::BenchmarkingSetup<T $(, $instance)? > for $name
|
||||
where $( $where_clause )*
|
||||
{
|
||||
fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> {
|
||||
$crate::vec! [
|
||||
fn components(&self) -> $crate::__private::Vec<($crate::BenchmarkParameter, u32, u32)> {
|
||||
$crate::__private::vec! [
|
||||
$(
|
||||
($crate::BenchmarkParameter::$param, $param_from, $param_to)
|
||||
),*
|
||||
@@ -788,7 +788,7 @@ macro_rules! benchmark_backend {
|
||||
&self,
|
||||
components: &[($crate::BenchmarkParameter, u32)],
|
||||
verify: bool
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
) -> Result<$crate::__private::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
$(
|
||||
// Prepare instance
|
||||
let $param = components.iter()
|
||||
@@ -802,7 +802,7 @@ macro_rules! benchmark_backend {
|
||||
$( $param_instancer ; )*
|
||||
$( $post )*
|
||||
|
||||
Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkError> {
|
||||
Ok($crate::__private::Box::new(move || -> Result<(), $crate::BenchmarkError> {
|
||||
$eval;
|
||||
if verify {
|
||||
$postcode;
|
||||
@@ -842,15 +842,15 @@ macro_rules! impl_bench_name_tests {
|
||||
{ $( $names_extra:tt )* },
|
||||
{ $name:ident }
|
||||
) => {
|
||||
$crate::paste::paste! {
|
||||
$crate::__private::paste::paste! {
|
||||
#[test]
|
||||
fn [<bench_ $name>] () {
|
||||
$new_test_exec.$exec_name(|| {
|
||||
// Skip all #[extra] benchmarks if $extra is false.
|
||||
if !($extra) {
|
||||
let disabled = $crate::vec![ $( stringify!($names_extra).as_ref() ),* ];
|
||||
let disabled = $crate::__private::vec![ $( stringify!($names_extra).as_ref() ),* ];
|
||||
if disabled.contains(&stringify!($name)) {
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"INFO: extra benchmark skipped - {}",
|
||||
stringify!($name),
|
||||
);
|
||||
@@ -873,21 +873,21 @@ macro_rules! impl_bench_name_tests {
|
||||
},
|
||||
$crate::BenchmarkError::Override(_) => {
|
||||
// This is still considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error overrided - {}",
|
||||
stringify!($name),
|
||||
);
|
||||
},
|
||||
$crate::BenchmarkError::Skip => {
|
||||
// This is considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error skipped - {}",
|
||||
stringify!($name),
|
||||
);
|
||||
},
|
||||
$crate::BenchmarkError::Weightless => {
|
||||
// This is considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark weightless skipped - {}",
|
||||
stringify!($name),
|
||||
);
|
||||
@@ -948,7 +948,7 @@ macro_rules! selected_benchmark {
|
||||
$crate::BenchmarkingSetup<T $(, $instance )? > for SelectedBenchmark
|
||||
where $( $where_clause )*
|
||||
{
|
||||
fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> {
|
||||
fn components(&self) -> $crate::__private::Vec<($crate::BenchmarkParameter, u32, u32)> {
|
||||
match self {
|
||||
$(
|
||||
Self::$bench => <
|
||||
@@ -962,7 +962,7 @@ macro_rules! selected_benchmark {
|
||||
&self,
|
||||
components: &[($crate::BenchmarkParameter, u32)],
|
||||
verify: bool
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
) -> Result<$crate::__private::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
match self {
|
||||
$(
|
||||
Self::$bench => <
|
||||
@@ -992,19 +992,19 @@ macro_rules! impl_benchmark {
|
||||
$crate::Benchmarking for Pallet<T $(, $instance)? >
|
||||
where T: frame_system::Config, $( $where_clause )*
|
||||
{
|
||||
fn benchmarks(extra: bool) -> $crate::Vec<$crate::BenchmarkMetadata> {
|
||||
fn benchmarks(extra: bool) -> $crate::__private::Vec<$crate::BenchmarkMetadata> {
|
||||
$($crate::validate_pov_mode!(
|
||||
$pov_name: $( $storage = $pov_mode )*;
|
||||
);)*
|
||||
let mut all_names = $crate::vec![ $( stringify!($name).as_ref() ),* ];
|
||||
let mut all_names = $crate::__private::vec![ $( stringify!($name).as_ref() ),* ];
|
||||
if !extra {
|
||||
let extra = [ $( stringify!($name_extra).as_ref() ),* ];
|
||||
all_names.retain(|x| !extra.contains(x));
|
||||
}
|
||||
let pov_modes: $crate::Vec<($crate::Vec<u8>, $crate::Vec<($crate::Vec<u8>, $crate::Vec<u8>)>)> = $crate::vec![
|
||||
let pov_modes: $crate::__private::Vec<($crate::__private::Vec<u8>, $crate::__private::Vec<($crate::__private::Vec<u8>, $crate::__private::Vec<u8>)>)> = $crate::__private::vec![
|
||||
$(
|
||||
(stringify!($pov_name).as_bytes().to_vec(),
|
||||
$crate::vec![
|
||||
$crate::__private::vec![
|
||||
$( ( stringify!($storage).as_bytes().to_vec(),
|
||||
stringify!($pov_mode).as_bytes().to_vec() ), )*
|
||||
]),
|
||||
@@ -1025,18 +1025,18 @@ macro_rules! impl_benchmark {
|
||||
components,
|
||||
pov_modes: pov_modes.iter().find(|p| p.0 == name).map(|p| p.1.clone()).unwrap_or_default(),
|
||||
}
|
||||
}).collect::<$crate::Vec<_>>()
|
||||
}).collect::<$crate::__private::Vec<_>>()
|
||||
}
|
||||
|
||||
fn run_benchmark(
|
||||
extrinsic: &[u8],
|
||||
c: &[($crate::BenchmarkParameter, u32)],
|
||||
whitelist: &[$crate::TrackedStorageKey],
|
||||
whitelist: &[$crate::__private::TrackedStorageKey],
|
||||
verify: bool,
|
||||
internal_repeats: u32,
|
||||
) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> {
|
||||
) -> Result<$crate::__private::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> {
|
||||
// Map the input to the selected benchmark.
|
||||
let extrinsic = $crate::str::from_utf8(extrinsic)
|
||||
let extrinsic = $crate::__private::str::from_utf8(extrinsic)
|
||||
.map_err(|_| "`extrinsic` is not a valid utf8 string!")?;
|
||||
let selected_benchmark = match extrinsic {
|
||||
$( stringify!($name) => SelectedBenchmark::$name, )*
|
||||
@@ -1046,34 +1046,34 @@ macro_rules! impl_benchmark {
|
||||
// Add whitelist to DB including whitelisted caller
|
||||
let mut whitelist = whitelist.to_vec();
|
||||
let whitelisted_caller_key =
|
||||
<frame_system::Account::<T> as $crate::frame_support::storage::StorageMap<_,_>>::hashed_key_for(
|
||||
<frame_system::Account::<T> as $crate::__private::storage::StorageMap<_,_>>::hashed_key_for(
|
||||
$crate::whitelisted_caller::<T::AccountId>()
|
||||
);
|
||||
whitelist.push(whitelisted_caller_key.into());
|
||||
// Whitelist the transactional layer.
|
||||
let transactional_layer_key = $crate::TrackedStorageKey::new(
|
||||
$crate::frame_support::storage::transactional::TRANSACTION_LEVEL_KEY.into()
|
||||
let transactional_layer_key = $crate::__private::TrackedStorageKey::new(
|
||||
$crate::__private::storage::transactional::TRANSACTION_LEVEL_KEY.into()
|
||||
);
|
||||
whitelist.push(transactional_layer_key);
|
||||
// Whitelist the `:extrinsic_index`.
|
||||
let extrinsic_index = $crate::TrackedStorageKey::new(
|
||||
$crate::well_known_keys::EXTRINSIC_INDEX.into()
|
||||
let extrinsic_index = $crate::__private::TrackedStorageKey::new(
|
||||
$crate::__private::well_known_keys::EXTRINSIC_INDEX.into()
|
||||
);
|
||||
whitelist.push(extrinsic_index);
|
||||
// Whitelist the `:intrablock_entropy`.
|
||||
let intrablock_entropy = $crate::TrackedStorageKey::new(
|
||||
$crate::well_known_keys::INTRABLOCK_ENTROPY.into()
|
||||
let intrablock_entropy = $crate::__private::TrackedStorageKey::new(
|
||||
$crate::__private::well_known_keys::INTRABLOCK_ENTROPY.into()
|
||||
);
|
||||
whitelist.push(intrablock_entropy);
|
||||
|
||||
$crate::benchmarking::set_whitelist(whitelist.clone());
|
||||
|
||||
let mut results: $crate::Vec<$crate::BenchmarkResult> = $crate::Vec::new();
|
||||
let mut results: $crate::__private::Vec<$crate::BenchmarkResult> = $crate::__private::Vec::new();
|
||||
|
||||
// Always do at least one internal repeat...
|
||||
for _ in 0 .. internal_repeats.max(1) {
|
||||
// Always reset the state after the benchmark.
|
||||
$crate::defer!($crate::benchmarking::wipe_db());
|
||||
$crate::__private::defer!($crate::benchmarking::wipe_db());
|
||||
|
||||
// Set up the externalities environment for the setup we want to
|
||||
// benchmark.
|
||||
@@ -1082,7 +1082,7 @@ macro_rules! impl_benchmark {
|
||||
>::instance(&selected_benchmark, c, verify)?;
|
||||
|
||||
// Set the block number to at least 1 so events are deposited.
|
||||
if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
if $crate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
frame_system::Pallet::<T>::set_block_number(1u32.into());
|
||||
}
|
||||
|
||||
@@ -1093,14 +1093,14 @@ macro_rules! impl_benchmark {
|
||||
// Access all whitelisted keys to get them into the proof recorder since the
|
||||
// recorder does now have a whitelist.
|
||||
for key in &whitelist {
|
||||
$crate::frame_support::storage::unhashed::get_raw(&key.key);
|
||||
$crate::__private::storage::unhashed::get_raw(&key.key);
|
||||
}
|
||||
|
||||
// Reset the read/write counter so we don't count operations in the setup process.
|
||||
$crate::benchmarking::reset_read_write_count();
|
||||
|
||||
// Time the extrinsic logic.
|
||||
$crate::log::trace!(
|
||||
$crate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"Start Benchmark: {} ({:?}) verify {}",
|
||||
extrinsic,
|
||||
@@ -1125,29 +1125,29 @@ macro_rules! impl_benchmark {
|
||||
|
||||
// Commit the changes to get proper write count
|
||||
$crate::benchmarking::commit_db();
|
||||
$crate::log::trace!(
|
||||
$crate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"End Benchmark: {} ns", elapsed_extrinsic
|
||||
);
|
||||
let read_write_count = $crate::benchmarking::read_write_count();
|
||||
$crate::log::trace!(
|
||||
$crate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"Read/Write Count {:?}", read_write_count
|
||||
);
|
||||
$crate::log::trace!(
|
||||
$crate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"Proof sizes: before {:?} after {:?} diff {}", &start_pov, &end_pov, &diff_pov
|
||||
);
|
||||
|
||||
// Time the storage root recalculation.
|
||||
let start_storage_root = $crate::benchmarking::current_time();
|
||||
$crate::storage_root($crate::StateVersion::V1);
|
||||
$crate::__private::storage_root($crate::__private::StateVersion::V1);
|
||||
let finish_storage_root = $crate::benchmarking::current_time();
|
||||
let elapsed_storage_root = finish_storage_root - start_storage_root;
|
||||
|
||||
let skip_meta = [ $( stringify!($name_skip_meta).as_ref() ),* ];
|
||||
let read_and_written_keys = if skip_meta.contains(&extrinsic) {
|
||||
$crate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)]
|
||||
$crate::__private::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)]
|
||||
} else {
|
||||
$crate::benchmarking::get_read_and_written_keys()
|
||||
};
|
||||
@@ -1185,11 +1185,11 @@ macro_rules! impl_benchmark {
|
||||
/// author chooses not to implement benchmarks.
|
||||
#[allow(unused)]
|
||||
fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkError> {
|
||||
let name = $crate::str::from_utf8(name)
|
||||
let name = $crate::__private::str::from_utf8(name)
|
||||
.map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?;
|
||||
match name {
|
||||
$( stringify!($name) => {
|
||||
$crate::paste::paste! { Self::[< test_benchmark_ $name >]() }
|
||||
$crate::__private::paste::paste! { Self::[< test_benchmark_ $name >]() }
|
||||
} )*
|
||||
_ => Err("Could not find test for requested benchmark.".into()),
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ macro_rules! impl_benchmark_test {
|
||||
{ $( $instance:ident: $instance_bound:tt )? }
|
||||
$name:ident
|
||||
) => {
|
||||
$crate::paste::item! {
|
||||
$crate::__private::paste::item! {
|
||||
#[cfg(test)]
|
||||
impl<T: Config $(<$instance>, $instance: $instance_bound )? >
|
||||
Pallet<T $(, $instance)? >
|
||||
@@ -1225,10 +1225,10 @@ macro_rules! impl_benchmark_test {
|
||||
>::components(&selected_benchmark);
|
||||
|
||||
let execute_benchmark = |
|
||||
c: $crate::Vec<($crate::BenchmarkParameter, u32)>
|
||||
c: $crate::__private::Vec<($crate::BenchmarkParameter, u32)>
|
||||
| -> Result<(), $crate::BenchmarkError> {
|
||||
// Always reset the state after the benchmark.
|
||||
$crate::defer!($crate::benchmarking::wipe_db());
|
||||
$crate::__private::defer!($crate::benchmarking::wipe_db());
|
||||
|
||||
// Set up the benchmark, return execution + verification function.
|
||||
let closure_to_verify = <
|
||||
@@ -1236,7 +1236,7 @@ macro_rules! impl_benchmark_test {
|
||||
>::instance(&selected_benchmark, &c, true)?;
|
||||
|
||||
// Set the block number to at least 1 so events are deposited.
|
||||
if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
if $crate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
frame_system::Pallet::<T>::set_block_number(1u32.into());
|
||||
}
|
||||
|
||||
@@ -1266,7 +1266,7 @@ macro_rules! impl_benchmark_test {
|
||||
// and up to num_values-2 more equidistant values in between.
|
||||
// For 0..10 and num_values=6 this would mean: [0, 2, 4, 6, 8, 10]
|
||||
|
||||
let mut values = $crate::vec![low];
|
||||
let mut values = $crate::__private::vec![low];
|
||||
let diff = (high - low).min(num_values - 1);
|
||||
let slope = (high - low) as f32 / diff as f32;
|
||||
|
||||
@@ -1278,7 +1278,7 @@ macro_rules! impl_benchmark_test {
|
||||
|
||||
for component_value in values {
|
||||
// Select the max value for all the other components.
|
||||
let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components
|
||||
let c: $crate::__private::Vec<($crate::BenchmarkParameter, u32)> = components
|
||||
.iter()
|
||||
.map(|(n, _, h)|
|
||||
if *n == name {
|
||||
@@ -1684,7 +1684,7 @@ macro_rules! impl_test_function {
|
||||
Err(err) => {
|
||||
println!(
|
||||
"{}: {:?}",
|
||||
$crate::str::from_utf8(benchmark_name)
|
||||
$crate::__private::str::from_utf8(benchmark_name)
|
||||
.expect("benchmark name is always a valid string!"),
|
||||
err,
|
||||
);
|
||||
@@ -1695,7 +1695,7 @@ macro_rules! impl_test_function {
|
||||
$crate::BenchmarkError::Stop(err) => {
|
||||
println!(
|
||||
"{}: {:?}",
|
||||
$crate::str::from_utf8(benchmark_name)
|
||||
$crate::__private::str::from_utf8(benchmark_name)
|
||||
.expect("benchmark name is always a valid string!"),
|
||||
err,
|
||||
);
|
||||
@@ -1703,25 +1703,25 @@ macro_rules! impl_test_function {
|
||||
},
|
||||
$crate::BenchmarkError::Override(_) => {
|
||||
// This is still considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error overrided - {}",
|
||||
$crate::str::from_utf8(benchmark_name)
|
||||
$crate::__private::str::from_utf8(benchmark_name)
|
||||
.expect("benchmark name is always a valid string!"),
|
||||
);
|
||||
},
|
||||
$crate::BenchmarkError::Skip => {
|
||||
// This is considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error skipped - {}",
|
||||
$crate::str::from_utf8(benchmark_name)
|
||||
$crate::__private::str::from_utf8(benchmark_name)
|
||||
.expect("benchmark name is always a valid string!"),
|
||||
);
|
||||
}
|
||||
$crate::BenchmarkError::Weightless => {
|
||||
// This is considered a success condition.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark weightless skipped - {}",
|
||||
$crate::str::from_utf8(benchmark_name)
|
||||
$crate::__private::str::from_utf8(benchmark_name)
|
||||
.expect("benchmark name is always a valid string!"),
|
||||
);
|
||||
}
|
||||
@@ -1777,7 +1777,7 @@ pub fn show_benchmark_debug_info(
|
||||
/// For values that should be skipped entirely, we can just pass `key.into()`. For example:
|
||||
///
|
||||
/// ```
|
||||
/// use frame_benchmarking::TrackedStorageKey;
|
||||
/// use sp_storage::TrackedStorageKey;
|
||||
/// let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
/// // Block Number
|
||||
/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"),
|
||||
@@ -1850,13 +1850,13 @@ macro_rules! add_benchmark {
|
||||
Ok(results) => Some(results),
|
||||
Err($crate::BenchmarkError::Override(mut result)) => {
|
||||
// Insert override warning as the first storage key.
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error overrided - {}",
|
||||
$crate::str::from_utf8(benchmark)
|
||||
$crate::__private::str::from_utf8(benchmark)
|
||||
.expect("benchmark name is always a valid string!")
|
||||
);
|
||||
result.keys.insert(0, (b"Benchmark Override".to_vec(), 0, 0, false));
|
||||
Some($crate::vec![result])
|
||||
Some($crate::__private::vec![result])
|
||||
},
|
||||
Err($crate::BenchmarkError::Stop(e)) => {
|
||||
$crate::show_benchmark_debug_info(
|
||||
@@ -1869,20 +1869,20 @@ macro_rules! add_benchmark {
|
||||
return Err(e.into())
|
||||
},
|
||||
Err($crate::BenchmarkError::Skip) => {
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark error skipped - {}",
|
||||
$crate::str::from_utf8(benchmark)
|
||||
$crate::__private::str::from_utf8(benchmark)
|
||||
.expect("benchmark name is always a valid string!")
|
||||
);
|
||||
None
|
||||
},
|
||||
Err($crate::BenchmarkError::Weightless) => {
|
||||
$crate::log::error!(
|
||||
$crate::__private::log::error!(
|
||||
"WARNING: benchmark weightless skipped - {}",
|
||||
$crate::str::from_utf8(benchmark)
|
||||
$crate::__private::str::from_utf8(benchmark)
|
||||
.expect("benchmark name is always a valid string!")
|
||||
);
|
||||
Some(vec![$crate::BenchmarkResult {
|
||||
Some($crate::__private::vec![$crate::BenchmarkResult {
|
||||
components: selected_components.clone(),
|
||||
..Default::default()
|
||||
}])
|
||||
|
||||
@@ -983,14 +983,13 @@ mod tests {
|
||||
TransactionValidityError,
|
||||
};
|
||||
use codec::Decode;
|
||||
use frame_benchmarking::Zero;
|
||||
use frame_election_provider_support::IndexAssignment;
|
||||
use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::OffchainWorker};
|
||||
use sp_npos_elections::ElectionScore;
|
||||
use sp_runtime::{
|
||||
bounded_vec,
|
||||
offchain::storage_lock::{BlockAndTime, StorageLock},
|
||||
traits::ValidateUnsigned,
|
||||
traits::{ValidateUnsigned, Zero},
|
||||
ModuleError, PerU16, Perbill,
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ frame-election-provider-support = { version = "4.0.0-dev", default-features = fa
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" }
|
||||
sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/npos-elections" }
|
||||
sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" }
|
||||
sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
@@ -30,6 +31,7 @@ std = [
|
||||
"frame-system/std",
|
||||
"sp-npos-elections/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::Decode;
|
||||
use frame_benchmarking::v1::{benchmarks, Vec};
|
||||
use frame_benchmarking::v1::benchmarks;
|
||||
use frame_election_provider_support::{NposSolver, PhragMMS, SequentialPhragmen};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub struct Pallet<T: Config>(frame_system::Pallet<T>);
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{self as fast_unstake};
|
||||
use frame_benchmarking::frame_support::assert_ok;
|
||||
use frame_support::{
|
||||
assert_ok,
|
||||
pallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{ConstU64, Currency},
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
|
||||
use frame_benchmarking::v1::{
|
||||
account, frame_support::traits::Currency, vec, whitelist_account, Vec,
|
||||
};
|
||||
use frame_benchmarking::v1::{account, whitelist_account};
|
||||
use frame_election_provider_support::SortedListProvider;
|
||||
use frame_support::{assert_ok, ensure, traits::Get};
|
||||
use frame_support::{
|
||||
assert_ok, ensure,
|
||||
traits::{Currency, Get},
|
||||
};
|
||||
use frame_system::RawOrigin as RuntimeOrigin;
|
||||
use pallet_nomination_pools::{
|
||||
BalanceOf, BondExtra, BondedPoolInner, BondedPools, ClaimPermission, ClaimPermissions,
|
||||
@@ -41,6 +42,7 @@ use sp_runtime::{
|
||||
Perbill,
|
||||
};
|
||||
use sp_staking::{EraIndex, StakingInterface};
|
||||
use sp_std::{vec, vec::Vec};
|
||||
// `frame_benchmarking::benchmarks!` macro needs this
|
||||
use pallet_nomination_pools::Call;
|
||||
|
||||
|
||||
@@ -419,7 +419,6 @@ pub fn benchmarks(
|
||||
};
|
||||
|
||||
let krate = generate_crate_access_2018("frame-benchmarking")?;
|
||||
let support = quote!(#krate::frame_support);
|
||||
|
||||
// benchmark name variables
|
||||
let benchmark_names_str: Vec<String> = benchmark_names.iter().map(|n| n.to_string()).collect();
|
||||
@@ -456,7 +455,7 @@ pub fn benchmarks(
|
||||
}
|
||||
|
||||
impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics> for SelectedBenchmark where #where_clause {
|
||||
fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> {
|
||||
fn components(&self) -> #krate::__private::Vec<(#krate::BenchmarkParameter, u32, u32)> {
|
||||
match self {
|
||||
#(
|
||||
Self::#benchmark_names => {
|
||||
@@ -472,7 +471,7 @@ pub fn benchmarks(
|
||||
components: &[(#krate::BenchmarkParameter, u32)],
|
||||
verify: bool,
|
||||
) -> Result<
|
||||
#krate::Box<dyn FnOnce() -> Result<(), #krate::BenchmarkError>>,
|
||||
#krate::__private::Box<dyn FnOnce() -> Result<(), #krate::BenchmarkError>>,
|
||||
#krate::BenchmarkError,
|
||||
> {
|
||||
match self {
|
||||
@@ -493,8 +492,8 @@ pub fn benchmarks(
|
||||
{
|
||||
fn benchmarks(
|
||||
extra: bool,
|
||||
) -> #krate::Vec<#krate::BenchmarkMetadata> {
|
||||
let mut all_names = #krate::vec![
|
||||
) -> #krate::__private::Vec<#krate::BenchmarkMetadata> {
|
||||
let mut all_names = #krate::__private::vec![
|
||||
#(#benchmark_names_str),
|
||||
*
|
||||
];
|
||||
@@ -519,17 +518,17 @@ pub fn benchmarks(
|
||||
// https://github.com/paritytech/substrate/issues/13132
|
||||
pov_modes: vec![],
|
||||
}
|
||||
}).collect::<#krate::Vec<_>>()
|
||||
}).collect::<#krate::__private::Vec<_>>()
|
||||
}
|
||||
|
||||
fn run_benchmark(
|
||||
extrinsic: &[u8],
|
||||
c: &[(#krate::BenchmarkParameter, u32)],
|
||||
whitelist: &[#krate::TrackedStorageKey],
|
||||
whitelist: &[#krate::__private::TrackedStorageKey],
|
||||
verify: bool,
|
||||
internal_repeats: u32,
|
||||
) -> Result<#krate::Vec<#krate::BenchmarkResult>, #krate::BenchmarkError> {
|
||||
let extrinsic = #krate::str::from_utf8(extrinsic).map_err(|_| "`extrinsic` is not a valid utf-8 string!")?;
|
||||
) -> Result<#krate::__private::Vec<#krate::BenchmarkResult>, #krate::BenchmarkError> {
|
||||
let extrinsic = #krate::__private::str::from_utf8(extrinsic).map_err(|_| "`extrinsic` is not a valid utf-8 string!")?;
|
||||
let selected_benchmark = match extrinsic {
|
||||
#(#selected_benchmark_mappings),
|
||||
*,
|
||||
@@ -538,32 +537,32 @@ pub fn benchmarks(
|
||||
let mut whitelist = whitelist.to_vec();
|
||||
let whitelisted_caller_key = <frame_system::Account<
|
||||
T,
|
||||
> as #support::storage::StorageMap<_, _,>>::hashed_key_for(
|
||||
> as #krate::__private::storage::StorageMap<_, _,>>::hashed_key_for(
|
||||
#krate::whitelisted_caller::<T::AccountId>()
|
||||
);
|
||||
whitelist.push(whitelisted_caller_key.into());
|
||||
let transactional_layer_key = #krate::TrackedStorageKey::new(
|
||||
#support::storage::transactional::TRANSACTION_LEVEL_KEY.into(),
|
||||
let transactional_layer_key = #krate::__private::TrackedStorageKey::new(
|
||||
#krate::__private::storage::transactional::TRANSACTION_LEVEL_KEY.into(),
|
||||
);
|
||||
whitelist.push(transactional_layer_key);
|
||||
// Whitelist the `:extrinsic_index`.
|
||||
let extrinsic_index = #krate::TrackedStorageKey::new(
|
||||
#krate::well_known_keys::EXTRINSIC_INDEX.into()
|
||||
let extrinsic_index = #krate::__private::TrackedStorageKey::new(
|
||||
#krate::__private::well_known_keys::EXTRINSIC_INDEX.into()
|
||||
);
|
||||
whitelist.push(extrinsic_index);
|
||||
// Whitelist the `:intrablock_entropy`.
|
||||
let intrablock_entropy = #krate::TrackedStorageKey::new(
|
||||
#krate::well_known_keys::INTRABLOCK_ENTROPY.into()
|
||||
let intrablock_entropy = #krate::__private::TrackedStorageKey::new(
|
||||
#krate::__private::well_known_keys::INTRABLOCK_ENTROPY.into()
|
||||
);
|
||||
whitelist.push(intrablock_entropy);
|
||||
|
||||
#krate::benchmarking::set_whitelist(whitelist.clone());
|
||||
let mut results: #krate::Vec<#krate::BenchmarkResult> = #krate::Vec::new();
|
||||
let mut results: #krate::__private::Vec<#krate::BenchmarkResult> = #krate::__private::Vec::new();
|
||||
|
||||
// Always do at least one internal repeat...
|
||||
for _ in 0 .. internal_repeats.max(1) {
|
||||
// Always reset the state after the benchmark.
|
||||
#krate::defer!(#krate::benchmarking::wipe_db());
|
||||
#krate::__private::defer!(#krate::benchmarking::wipe_db());
|
||||
|
||||
// Set up the externalities environment for the setup we want to
|
||||
// benchmark.
|
||||
@@ -572,7 +571,7 @@ pub fn benchmarks(
|
||||
>::instance(&selected_benchmark, c, verify)?;
|
||||
|
||||
// Set the block number to at least 1 so events are deposited.
|
||||
if #krate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
if #krate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
frame_system::Pallet::<T>::set_block_number(1u32.into());
|
||||
}
|
||||
|
||||
@@ -583,14 +582,14 @@ pub fn benchmarks(
|
||||
// Access all whitelisted keys to get them into the proof recorder since the
|
||||
// recorder does now have a whitelist.
|
||||
for key in &whitelist {
|
||||
#krate::frame_support::storage::unhashed::get_raw(&key.key);
|
||||
#krate::__private::storage::unhashed::get_raw(&key.key);
|
||||
}
|
||||
|
||||
// Reset the read/write counter so we don't count operations in the setup process.
|
||||
#krate::benchmarking::reset_read_write_count();
|
||||
|
||||
// Time the extrinsic logic.
|
||||
#krate::log::trace!(
|
||||
#krate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"Start Benchmark: {} ({:?})",
|
||||
extrinsic,
|
||||
@@ -614,25 +613,25 @@ pub fn benchmarks(
|
||||
|
||||
// Commit the changes to get proper write count
|
||||
#krate::benchmarking::commit_db();
|
||||
#krate::log::trace!(
|
||||
#krate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"End Benchmark: {} ns", elapsed_extrinsic
|
||||
);
|
||||
let read_write_count = #krate::benchmarking::read_write_count();
|
||||
#krate::log::trace!(
|
||||
#krate::__private::log::trace!(
|
||||
target: "benchmark",
|
||||
"Read/Write Count {:?}", read_write_count
|
||||
);
|
||||
|
||||
// Time the storage root recalculation.
|
||||
let start_storage_root = #krate::benchmarking::current_time();
|
||||
#krate::storage_root(#krate::StateVersion::V1);
|
||||
#krate::__private::storage_root(#krate::__private::StateVersion::V1);
|
||||
let finish_storage_root = #krate::benchmarking::current_time();
|
||||
let elapsed_storage_root = finish_storage_root - start_storage_root;
|
||||
|
||||
let skip_meta = [ #(#skip_meta_benchmark_names_str),* ];
|
||||
let read_and_written_keys = if skip_meta.contains(&extrinsic) {
|
||||
#krate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)]
|
||||
#krate::__private::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)]
|
||||
} else {
|
||||
#krate::benchmarking::get_read_and_written_keys()
|
||||
};
|
||||
@@ -667,7 +666,7 @@ pub fn benchmarks(
|
||||
/// author chooses not to implement benchmarks.
|
||||
#[allow(unused)]
|
||||
fn test_bench_by_name(name: &[u8]) -> Result<(), #krate::BenchmarkError> {
|
||||
let name = #krate::str::from_utf8(name)
|
||||
let name = #krate::__private::str::from_utf8(name)
|
||||
.map_err(|_| -> #krate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?;
|
||||
match name {
|
||||
#(#benchmarks_by_name_mappings),
|
||||
@@ -724,8 +723,8 @@ fn expand_benchmark(
|
||||
Ok(ident) => ident,
|
||||
Err(err) => return err.to_compile_error().into(),
|
||||
};
|
||||
let codec = quote!(#krate::frame_support::__private::codec);
|
||||
let traits = quote!(#krate::frame_support::traits);
|
||||
let codec = quote!(#krate::__private::codec);
|
||||
let traits = quote!(#krate::__private::traits);
|
||||
let setup_stmts = benchmark_def.setup_stmts;
|
||||
let verify_stmts = benchmark_def.verify_stmts;
|
||||
let last_stmt = benchmark_def.last_stmt;
|
||||
@@ -894,8 +893,8 @@ fn expand_benchmark(
|
||||
#[allow(unused_variables)]
|
||||
impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics>
|
||||
for #name where #where_clause {
|
||||
fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> {
|
||||
#krate::vec! [
|
||||
fn components(&self) -> #krate::__private::Vec<(#krate::BenchmarkParameter, u32, u32)> {
|
||||
#krate::__private::vec! [
|
||||
#(
|
||||
(#krate::BenchmarkParameter::#param_ranges)
|
||||
),*
|
||||
@@ -906,7 +905,7 @@ fn expand_benchmark(
|
||||
&self,
|
||||
components: &[(#krate::BenchmarkParameter, u32)],
|
||||
verify: bool
|
||||
) -> Result<#krate::Box<dyn FnOnce() -> Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError> {
|
||||
) -> Result<#krate::__private::Box<dyn FnOnce() -> Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError> {
|
||||
#(
|
||||
// prepare instance #param_names
|
||||
let #param_names = components.iter()
|
||||
@@ -920,7 +919,7 @@ fn expand_benchmark(
|
||||
#setup_stmts
|
||||
)*
|
||||
#pre_call
|
||||
Ok(#krate::Box::new(move || -> Result<(), #krate::BenchmarkError> {
|
||||
Ok(#krate::__private::Box::new(move || -> Result<(), #krate::BenchmarkError> {
|
||||
#post_call
|
||||
if verify {
|
||||
#(
|
||||
@@ -941,10 +940,10 @@ fn expand_benchmark(
|
||||
SelectedBenchmark as #krate::BenchmarkingSetup<T, _>
|
||||
>::components(&selected_benchmark);
|
||||
let execute_benchmark = |
|
||||
c: #krate::Vec<(#krate::BenchmarkParameter, u32)>
|
||||
c: #krate::__private::Vec<(#krate::BenchmarkParameter, u32)>
|
||||
| -> Result<(), #krate::BenchmarkError> {
|
||||
// Always reset the state after the benchmark.
|
||||
#krate::defer!(#krate::benchmarking::wipe_db());
|
||||
#krate::__private::defer!(#krate::benchmarking::wipe_db());
|
||||
|
||||
// Set up the benchmark, return execution + verification function.
|
||||
let closure_to_verify = <
|
||||
@@ -952,7 +951,7 @@ fn expand_benchmark(
|
||||
>::instance(&selected_benchmark, &c, true)?;
|
||||
|
||||
// Set the block number to at least 1 so events are deposited.
|
||||
if #krate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
if #krate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
|
||||
frame_system::Pallet::<T>::set_block_number(1u32.into());
|
||||
}
|
||||
|
||||
@@ -985,7 +984,7 @@ fn expand_benchmark(
|
||||
return Err("The start of a `ParamRange` must be less than or equal to the end".into());
|
||||
}
|
||||
|
||||
let mut values = #krate::vec![low];
|
||||
let mut values = #krate::__private::vec![low];
|
||||
let diff = (high - low).min(num_values - 1);
|
||||
let slope = (high - low) as f32 / diff as f32;
|
||||
|
||||
@@ -997,7 +996,7 @@ fn expand_benchmark(
|
||||
|
||||
for component_value in values {
|
||||
// Select the max value for all the other components.
|
||||
let c: #krate::Vec<(#krate::BenchmarkParameter, u32)> = components
|
||||
let c: #krate::__private::Vec<(#krate::BenchmarkParameter, u32)> = components
|
||||
.iter()
|
||||
.map(|(n, _, h)|
|
||||
if *n == name {
|
||||
|
||||
+3
-1
@@ -55,7 +55,9 @@ help: you might have meant to use the associated type
|
||||
|
|
||||
38 | type PalletInfo = Self::PalletInfo;
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
help: consider importing this trait
|
||||
help: consider importing one of these items
|
||||
|
|
||||
1 + use frame_benchmarking::__private::traits::PalletInfo;
|
||||
|
|
||||
1 + use frame_support::traits::PalletInfo;
|
||||
|
|
||||
|
||||
@@ -24,6 +24,7 @@ sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../
|
||||
sp-io = { version = "23.0.0", default-features = false, optional = true, path = "../../primitives/io" }
|
||||
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" }
|
||||
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
|
||||
sp-storage = { version = "13.0.0", default-features = false, path = "../../primitives/storage" }
|
||||
sp-timestamp = { version = "4.0.0-dev", default-features = false, path = "../../primitives/timestamp" }
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -44,6 +45,7 @@ std = [
|
||||
"sp-io?/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-storage/std",
|
||||
"sp-timestamp/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use frame_benchmarking::v1::{benchmarks, TrackedStorageKey};
|
||||
use frame_benchmarking::v1::benchmarks;
|
||||
use frame_support::{ensure, traits::OnFinalize};
|
||||
use frame_system::RawOrigin;
|
||||
use sp_storage::TrackedStorageKey;
|
||||
|
||||
use crate::Pallet as Timestamp;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user