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

Commit

Permalink
Restructure frame_benchmarking macro related exports (#14787)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
juangirini and bkchr authored Aug 24, 2023
1 parent 0d8d066 commit 2fe6bc9
Show file tree
Hide file tree
Showing 21 changed files with 155 additions and 139 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bin/node-template/pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -37,6 +38,7 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
1 change: 1 addition & 0 deletions bin/node-template/pallets/template/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions bin/node-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions frame/benchmarking/src/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -110,7 +110,6 @@ benchmarks! {

#[cfg(test)]
pub mod mock {
use super::*;
use sp_runtime::{testing::H256, BuildStorage};

type AccountId = u64;
Expand Down
36 changes: 17 additions & 19 deletions frame/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#![cfg(test)]

use super::*;
use frame_support::{parameter_types, traits::ConstU32};
use sp_runtime::{
testing::H256,
Expand Down
1 change: 0 additions & 1 deletion frame/benchmarking/src/tests_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#![cfg(test)]

use super::*;
use frame_support::traits::ConstU32;
use sp_runtime::{
testing::H256,
Expand Down
Loading

0 comments on commit 2fe6bc9

Please sign in to comment.