Skip to content

Commit

Permalink
migrate new benchmarking syntax from frame_support::benchmarking to…
Browse files Browse the repository at this point in the history
… `frame_benchmarking::v2` (paritytech#13235)

* * re-export frame_support::benchmarking in frame_benchmarking::
* prefer use frame_benchmarking::*; in examples, etc

* switch to frame_benchmarking::v2

* completely migrate new benchmarking code out of frame_support

* fix doc links

* remove unneeded return

Co-authored-by: Bastian Köcher <[email protected]>

* remove another unneeded return

Co-authored-by: Bastian Köcher <[email protected]>

* properly export all macros in v1

* refactor existing frame_benchmarking imports to use ::v1

---------

Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
2 people authored and ark0f committed Feb 27, 2023
1 parent 8d570f4 commit b41c9ab
Show file tree
Hide file tree
Showing 69 changed files with 2,291 additions and 2,240 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node-template/pallets/template/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

#[allow(unused)]
use crate::Pallet as Template;
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
use frame_system::RawOrigin;

benchmarks! {
Expand Down
2 changes: 1 addition & 1 deletion frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_std::{
prelude::*,
};

use frame_benchmarking::{account, benchmarks_instance_pallet};
use frame_benchmarking::v1::{account, benchmarks_instance_pallet};
use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
use frame_system::{Pallet as System, RawOrigin as SystemOrigin};

Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::{
use frame_benchmarking::v1::{
account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller,
};
use frame_support::{
Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::benchmarks;
use frame_benchmarking::v1::benchmarks;

type Header = sp_runtime::generic::Header<u64, sp_runtime::traits::BlakeTwo256>;

Expand Down
6 changes: 4 additions & 2 deletions frame/bags-list/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

use super::*;
use crate::list::List;
use frame_benchmarking::{account, whitelist_account, whitelisted_caller};
use frame_benchmarking::v1::{
account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller,
};
use frame_election_provider_support::ScoreProvider;
use frame_support::{assert_ok, traits::Get};
use frame_system::RawOrigin as SystemOrigin;
use sp_runtime::traits::One;

frame_benchmarking::benchmarks_instance_pallet! {
benchmarks_instance_pallet! {
rebag_non_terminal {
// An expensive case for rebag-ing (rebag a non-terminal node):
//
Expand Down
3 changes: 1 addition & 2 deletions frame/balances/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
use super::*;
use crate::Pallet as Balances;

use frame_benchmarking::{account, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::benchmarking::*;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;

const SEED: u32 = 0;
Expand Down
2 changes: 2 additions & 0 deletions frame/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ paste = "1.0"
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", optional = true }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "../support/procedural" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" }
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../primitives/application-crypto" }
Expand All @@ -29,6 +30,7 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../../primit
sp-runtime-interface = { version = "7.0.0", default-features = false, path = "../../primitives/runtime-interface" }
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
sp-storage = { version = "7.0.0", default-features = false, path = "../../primitives/storage" }
static_assertions = "1.1.0"

[dev-dependencies]
array-bytes = "4.1"
Expand Down
Loading

0 comments on commit b41c9ab

Please sign in to comment.