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

Restructure frame_benchmarking macro related exports #14787

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1dfc9b4
make reexports private
juangirini Aug 10, 2023
dccfaeb
make reexports private 2
juangirini Aug 10, 2023
9706353
make reexports private for runtime-benchmarking
juangirini Aug 10, 2023
7d6c124
make reexports private for try-runtime
juangirini Aug 10, 2023
87fd6de
fix for try-runtime
juangirini Aug 10, 2023
1ffc743
make reexports private for tests
juangirini Aug 10, 2023
222b45d
rebase and fix conflicts
juangirini Aug 10, 2023
e795557
fmt
juangirini Aug 10, 2023
4c9ef13
make reexports private for tests
juangirini Aug 10, 2023
4d0b806
make reexports private for experimental
juangirini Aug 10, 2023
e32c82f
fix beefy
juangirini Aug 10, 2023
4386de3
fix ui test
juangirini Aug 10, 2023
54657c0
fix ui test
juangirini Aug 10, 2023
3566961
fix benches
juangirini Aug 14, 2023
08de067
Merge branch 'master' into jg/restructure-macro-related-exports
juangirini Aug 14, 2023
c419d4a
".git/.scripts/commands/fmt/fmt.sh"
Aug 14, 2023
b931ecb
fix contracts use
juangirini Aug 15, 2023
f4e5f55
wip
juangirini Aug 15, 2023
4ecbfff
wip
juangirini Aug 15, 2023
b7eaa34
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
juangirini Aug 15, 2023
095356c
do not reexport sp_api::metadata_ir
juangirini Aug 16, 2023
3bc2ddc
Merge branch 'master' into jg/restructure-macro-related-exports
juangirini Aug 16, 2023
3816fc4
fix CI checks
juangirini Aug 16, 2023
32f74a6
fix support tests
juangirini Aug 16, 2023
7d7d73b
".git/.scripts/commands/fmt/fmt.sh"
Aug 16, 2023
86ddd81
Update frame/support/src/lib.rs
juangirini Aug 17, 2023
5d00dfd
import codec directly
juangirini Aug 17, 2023
a6a4e3d
fmt
juangirini Aug 17, 2023
4df379c
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 17, 2023
d32e625
wip
juangirini Aug 17, 2023
5eb43f1
wip
juangirini Aug 17, 2023
b09e913
remove benchmarking private exports
juangirini Aug 18, 2023
50651b7
fix zepter warning
juangirini Aug 18, 2023
6889b65
fix imports
juangirini Aug 18, 2023
024765e
partially fix node-cli tests
juangirini Aug 18, 2023
0fcc322
fix node-cli tests
juangirini Aug 18, 2023
8c95104
Merge branch 'jg/restructure-macro-related-exports' into jg/restructu…
juangirini Aug 18, 2023
fdb2be4
fix node-cli build
juangirini Aug 18, 2023
8c72509
fix zepter warning
juangirini Aug 18, 2023
fb6f332
fix test
juangirini Aug 18, 2023
713a8ef
fix ui test
juangirini Aug 18, 2023
daf3dcb
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 21, 2023
ea40484
Merge branch 'jg/restructure-macro-related-exports' into jg/restructu…
juangirini Aug 21, 2023
e94e54b
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 22, 2023
96c726e
Merge remote-tracking branch 'origin/jg/restructure-macro-related-exp…
Aug 22, 2023
d8c10ce
Merge branch 'master' into jg/restructure-benchmarking-macro-related-…
juangirini Aug 23, 2023
6398e06
Merge branch 'master' into jg/restructure-benchmarking-macro-related-…
juangirini Aug 23, 2023
55f3ab2
fix ci
juangirini Aug 23, 2023
08c6e5b
remove unnecessary imports
juangirini Aug 24, 2023
b6414ca
add import back
juangirini Aug 24, 2023
0cd5bc9
add import back
juangirini Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong? I don't see any usage of the macro in here. Maybe some macro needs this? If yes, it should pull this in automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is expected here https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3434676

[2023-08-24 12:21:48]   error: cannot find macro `vec` in this scope
[2023-08-24 12:21:48]     --> /builds/parity/mirrors/substrate/bin/node-template/pallets/template/src/benchmarking.rs:10:1
[2023-08-24 12:21:48]      |
[2023-08-24 12:21:48]   10 | #[benchmarks]
[2023-08-24 12:21:48]      | ^^^^^^^^^^^^^
[2023-08-24 12:21:48]      |
[2023-08-24 12:21:48]      = help: consider importing one of these items:
[2023-08-24 12:21:48]              crate::benchmarking::__private::vec
[2023-08-24 12:21:48]              frame_benchmarking::__private::vec
[2023-08-24 12:21:48]              scale_info::prelude::vec
[2023-08-24 12:21:48]              sp_std::vec
[2023-08-24 12:21:48]      = note: this error originates in the attribute macro `benchmarks` (in Nightly builds, run with -Z macro-backtrace for more info)


#[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 @@ -2571,7 +2571,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};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually required https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3434492

[2023-08-24 12:02:10]   error: cannot find macro `vec` in this scope
[2023-08-24 12:02:10]     --> /builds/parity/mirrors/substrate/frame/benchmarking/src/baseline.rs:93:14
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   93 |             let msg = vec![j, j];
[2023-08-24 12:02:10]      |                       ^^^
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]      = help: consider importing one of these items:
[2023-08-24 12:02:10]              crate::__private::vec
[2023-08-24 12:02:10]              scale_info::prelude::vec
[2023-08-24 12:02:10]              sp_api::vec
[2023-08-24 12:02:10]              sp_std::vec
[2023-08-24 12:02:10] 
[2023-08-24 12:02:10]   error[E0412]: cannot find type `Vec` in this scope
[2023-08-24 12:02:10]     --> /builds/parity/mirrors/substrate/frame/benchmarking/src/baseline.rs:92:21
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   92 |         let msg_and_sigs: Vec<_> = (0..sigs_count).map(|j| {
[2023-08-24 12:02:10]      |                           ^^^ not found in this scope
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   help: consider importing one of these items
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   23 + use crate::__private::Vec;
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   23 + use frame_support::dispatch::Vec;
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   23 + use scale_info::prelude::vec::Vec;
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]   23 + use sp_api::vec::Vec;
[2023-08-24 12:02:10]      |
[2023-08-24 12:02:10]        and 2 other candidates


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};
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
#[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