Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 2fe6bc9

Browse files
juangirinibkchr
andauthored
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 <[email protected]> * 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 <[email protected]>
1 parent 0d8d066 commit 2fe6bc9

File tree

21 files changed

+155
-139
lines changed

21 files changed

+155
-139
lines changed

Cargo.lock

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/pallets/template/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ scale-info = { version = "2.5.0", default-features = false, features = ["derive"
2020
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../../../../frame/benchmarking" }
2121
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/support" }
2222
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/system" }
23+
sp-std = { version = "8.0.0", default-features = false, path = "../../../../primitives/std" }
2324

2425
[dev-dependencies]
2526
sp-core = { version = "21.0.0", path = "../../../../primitives/core" }
@@ -37,6 +38,7 @@ std = [
3738
"sp-core/std",
3839
"sp-io/std",
3940
"sp-runtime/std",
41+
"sp-std/std",
4042
]
4143
runtime-benchmarks = [
4244
"frame-benchmarking/runtime-benchmarks",

bin/node-template/pallets/template/src/benchmarking.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Benchmarking setup for pallet-template
22
#![cfg(feature = "runtime-benchmarks")]
33
use super::*;
4+
use sp_std::vec;
45

56
#[allow(unused)]
67
use crate::Pallet as Template;

bin/node-template/runtime/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../.
3636
sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" }
3737
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" }
3838
sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" }
39+
sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" }
3940
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" }
4041
sp-version = { version = "22.0.0", default-features = false, path = "../../../primitives/version" }
4142

@@ -84,6 +85,7 @@ std = [
8485
"sp-runtime/std",
8586
"sp-session/std",
8687
"sp-std/std",
88+
"sp-storage/std",
8789
"sp-transaction-pool/std",
8890
"sp-version/std",
8991
"substrate-wasm-builder",

bin/node-template/runtime/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ impl_runtime_apis! {
531531
fn dispatch_benchmark(
532532
config: frame_benchmarking::BenchmarkConfig
533533
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
534-
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};
535-
534+
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
535+
use sp_storage::TrackedStorageKey;
536536
use frame_system_benchmarking::Pallet as SystemBench;
537537
use baseline::Pallet as BaselineBench;
538538

bin/node/runtime/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sp-std = { version = "8.0.0", default-features = false, path = "../../../primiti
4040
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" }
4141
sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" }
4242
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" }
43+
sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" }
4344
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" }
4445
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" }
4546
sp-statement-store = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/statement-store" }
@@ -232,6 +233,7 @@ std = [
232233
"sp-staking/std",
233234
"sp-statement-store/std",
234235
"sp-std/std",
236+
"sp-storage/std",
235237
"sp-transaction-pool/std",
236238
"sp-version/std",
237239
"substrate-wasm-builder",

bin/node/runtime/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,8 @@ impl_runtime_apis! {
25702570
fn dispatch_benchmark(
25712571
config: frame_benchmarking::BenchmarkConfig
25722572
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
2573-
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};
2573+
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
2574+
use sp_storage::TrackedStorageKey;
25742575

25752576
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
25762577
// issues. To get around that, we separated the Session benchmarks into its own crate,

frame/benchmarking/src/baseline.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
2121
#![cfg(feature = "runtime-benchmarks")]
2222

23-
use super::*;
2423
use crate::benchmarks;
2524
use frame_system::Pallet as System;
2625
use sp_runtime::{
2726
traits::{AppVerify, Hash},
2827
RuntimeAppPublic,
2928
};
29+
use sp_std::{vec, vec::Vec};
3030

3131
mod crypto {
3232
use sp_application_crypto::{app_crypto, sr25519, KeyTypeId};
@@ -110,7 +110,6 @@ benchmarks! {
110110

111111
#[cfg(test)]
112112
pub mod mock {
113-
use super::*;
114113
use sp_runtime::{testing::H256, BuildStorage};
115114

116115
type AccountId = u64;

frame/benchmarking/src/lib.rs

+17-19
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,27 @@ mod tests_instance;
2828
mod utils;
2929

3030
pub mod baseline;
31+
pub mod v1;
32+
33+
/// Private exports that are being used by macros.
34+
///
35+
/// The exports are not stable and should not be relied on.
36+
#[doc(hidden)]
37+
pub mod __private {
38+
pub use codec;
39+
pub use frame_support::{storage, traits};
40+
pub use log;
41+
pub use paste;
42+
pub use sp_core::defer;
43+
pub use sp_io::storage::root as storage_root;
44+
pub use sp_runtime::{traits::Zero, StateVersion};
45+
pub use sp_std::{self, boxed::Box, str, vec, vec::Vec};
46+
pub use sp_storage::{well_known_keys, TrackedStorageKey};
47+
}
3148

3249
#[cfg(feature = "std")]
3350
pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector};
34-
#[doc(hidden)]
35-
pub use frame_support;
36-
#[doc(hidden)]
37-
pub use log;
38-
#[doc(hidden)]
39-
pub use paste;
40-
#[doc(hidden)]
41-
pub use sp_core::defer;
42-
#[doc(hidden)]
43-
pub use sp_io::storage::root as storage_root;
44-
#[doc(hidden)]
45-
pub use sp_runtime::traits::Zero;
46-
#[doc(hidden)]
47-
pub use sp_runtime::StateVersion;
48-
#[doc(hidden)]
49-
pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec};
50-
pub use sp_storage::{well_known_keys, TrackedStorageKey};
5151
pub use utils::*;
52-
53-
pub mod v1;
5452
pub use v1::*;
5553

5654
/// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax.

frame/benchmarking/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
2020
#![cfg(test)]
2121

22-
use super::*;
2322
use frame_support::{parameter_types, traits::ConstU32};
2423
use sp_runtime::{
2524
testing::H256,

frame/benchmarking/src/tests_instance.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
2020
#![cfg(test)]
2121

22-
use super::*;
2322
use frame_support::traits::ConstU32;
2423
use sp_runtime::{
2524
testing::H256,

0 commit comments

Comments
 (0)