From e32b2ab558fe5d6495a34f6e7d1227190c42fff7 Mon Sep 17 00:00:00 2001 From: gupnik Date: Wed, 8 May 2024 17:20:23 +0530 Subject: [PATCH] Adds benchmarking and try-runtime support in frame crate (#4406) --- Cargo.lock | 4 ++++ prdoc/pr_4406.prdoc | 10 ++++++++++ substrate/frame/Cargo.toml | 28 ++++++++++++++++++++++++++++ substrate/frame/src/lib.rs | 10 ++++++++++ 4 files changed, 52 insertions(+) create mode 100644 prdoc/pr_4406.prdoc diff --git a/Cargo.lock b/Cargo.lock index 0dda623c14abb..5ee267d691aa7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13888,10 +13888,13 @@ name = "polkadot-sdk-frame" version = "0.1.0" dependencies = [ "docify", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "log", "pallet-examples", "parity-scale-codec", @@ -13908,6 +13911,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-std 14.0.0", + "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", ] diff --git a/prdoc/pr_4406.prdoc b/prdoc/pr_4406.prdoc new file mode 100644 index 0000000000000..9372b532512b5 --- /dev/null +++ b/prdoc/pr_4406.prdoc @@ -0,0 +1,10 @@ +title: Adds benchmarking and try-runtime support in `polkadot-sdk-frame` crate + +doc: + - audience: Runtime Dev + description: | + Adds benchmarking and try-runtime support in `polkadot-sdk-frame` crate + +crates: + - name: polkadot-sdk-frame + bump: minor diff --git a/substrate/frame/Cargo.toml b/substrate/frame/Cargo.toml index 729df227be03d..44e8d681b01cc 100644 --- a/substrate/frame/Cargo.toml +++ b/substrate/frame/Cargo.toml @@ -46,10 +46,18 @@ sp-session = { default-features = false, path = "../primitives/session", optiona sp-consensus-aura = { default-features = false, path = "../primitives/consensus/aura", optional = true } sp-consensus-grandpa = { default-features = false, path = "../primitives/consensus/grandpa", optional = true } sp-inherents = { default-features = false, path = "../primitives/inherents", optional = true } +sp-storage = { default-features = false, path = "../primitives/storage", optional = true } frame-executive = { default-features = false, path = "../frame/executive", optional = true } frame-system-rpc-runtime-api = { default-features = false, path = "../frame/system/rpc/runtime-api", optional = true } +# Used for runtime benchmarking +frame-benchmarking = { default-features = false, path = "../frame/benchmarking", optional = true } +frame-system-benchmarking = { default-features = false, path = "../frame/system/benchmarking", optional = true } + +# Used for try-runtime +frame-try-runtime = { default-features = false, path = "../frame/try-runtime", optional = true } + docify = "0.2.8" log = { workspace = true } @@ -67,6 +75,7 @@ runtime = [ "sp-inherents", "sp-offchain", "sp-session", + "sp-storage", "sp-transaction-pool", "sp-version", @@ -74,10 +83,13 @@ runtime = [ "frame-system-rpc-runtime-api", ] std = [ + "frame-benchmarking?/std", "frame-executive?/std", "frame-support/std", + "frame-system-benchmarking?/std", "frame-system-rpc-runtime-api?/std", "frame-system/std", + "frame-try-runtime?/std", "log/std", "parity-scale-codec/std", "scale-info/std", @@ -93,6 +105,22 @@ std = [ "sp-runtime/std", "sp-session?/std", "sp-std/std", + "sp-storage/std", "sp-transaction-pool?/std", "sp-version?/std", ] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-executive/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "frame-try-runtime/try-runtime", + "pallet-examples/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 90c446808daff..f6507cd02c71a 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -363,5 +363,15 @@ pub mod deps { #[cfg(feature = "runtime")] pub use sp_offchain; #[cfg(feature = "runtime")] + pub use sp_storage; + #[cfg(feature = "runtime")] pub use sp_version; + + #[cfg(feature = "runtime-benchmarks")] + pub use frame_benchmarking; + #[cfg(feature = "runtime-benchmarks")] + pub use frame_system_benchmarking; + + #[cfg(feature = "frame-try-runtime")] + pub use frame_try_runtime; }