mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 08:18:04 +00:00
Consolidate frame benchmarking into a frame crate (#4977)
This prs cleans up some of the frame benchmarking stuff: - Move CLI into `frame-benchmarking-cli`. No frame related CLI should exists in the default Substrate CLI. - Move all traits and types related to frame benchmarking into the `frame-benchmarking` trait. Frame types should be isolated in Frame.
This commit is contained in:
@@ -33,6 +33,7 @@ sp-version = { version = "2.0.0", default-features = false, path = "../../../pri
|
||||
|
||||
# frame dependencies
|
||||
frame-executive = { version = "2.0.0", default-features = false, path = "../../../frame/executive" }
|
||||
frame-benchmarking = { version = "2.0.0", default-features = false, path = "../../../frame/benchmarking" }
|
||||
frame-support = { version = "2.0.0", default-features = false, path = "../../../frame/support" }
|
||||
frame-system = { version = "2.0.0", default-features = false, path = "../../../frame/system" }
|
||||
frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
|
||||
@@ -115,6 +116,7 @@ std = [
|
||||
"sp-session/std",
|
||||
"pallet-sudo/std",
|
||||
"frame-support/std",
|
||||
"frame-benchmarking/std",
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"frame-system/std",
|
||||
"pallet-timestamp/std",
|
||||
|
||||
@@ -31,14 +31,13 @@ pub use node_primitives::{AccountId, Signature};
|
||||
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_runtime::{
|
||||
Permill, Perbill, Percent, ApplyExtrinsicResult, BenchmarkResults,
|
||||
impl_opaque_keys, generic, create_runtime_str,
|
||||
Permill, Perbill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str,
|
||||
};
|
||||
use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::transaction_validity::TransactionValidity;
|
||||
use sp_runtime::traits::{
|
||||
self, BlakeTwo256, Block as BlockT, StaticLookup, SaturatedConversion,
|
||||
ConvertInto, OpaqueKeys, Benchmarking,
|
||||
ConvertInto, OpaqueKeys,
|
||||
};
|
||||
use sp_version::RuntimeVersion;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -816,28 +815,25 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::Benchmark<Block> for Runtime {
|
||||
fn dispatch_benchmark(module: Vec<u8>, extrinsic: Vec<u8>, steps: u32, repeat: u32)
|
||||
-> Option<Vec<BenchmarkResults>>
|
||||
{
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn dispatch_benchmark(
|
||||
module: Vec<u8>,
|
||||
extrinsic: Vec<u8>,
|
||||
steps: u32,
|
||||
repeat: u32,
|
||||
) -> Option<Vec<frame_benchmarking::BenchmarkResults>> {
|
||||
use frame_benchmarking::Benchmarking;
|
||||
|
||||
match module.as_slice() {
|
||||
b"pallet-balances" | b"balances" => Balances::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
b"pallet-identity" | b"identity" => Identity::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
_ => return None,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait Benchmark
|
||||
{
|
||||
fn dispatch_benchmark(module: Vec<u8>, extrinsic: Vec<u8>, steps: u32, repeat: u32)
|
||||
-> Option<Vec<BenchmarkResults>>;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user