Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport frame crate fixes #4413

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.lock

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

13 changes: 13 additions & 0 deletions prdoc/pr_4413.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: Backport `polkadot-sdk-frame` crate fixes

doc:
- audience: Runtime Dev
description: |
Adds benchmarking and try-runtime support in `polkadot-sdk-frame` crate. Also, fixes
runtime macro usage with the `polkadot-sdk-frame` crate.

crates:
- name: polkadot-sdk-frame
bump: minor
- name: frame-support-procedural
bump: patch
28 changes: 28 additions & 0 deletions substrate/frame/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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, version = "0.37.0" }
sp-consensus-grandpa = { default-features = false, path = "../primitives/consensus/grandpa", optional = true, version = "18.0.0" }
sp-inherents = { default-features = false, path = "../primitives/inherents", optional = true, version = "31.0.0" }
sp-storage = { default-features = false, path = "../primitives/storage", optional = true, version = "21.0.0" }

frame-executive = { default-features = false, path = "executive", optional = true, version = "33.0.0" }
frame-system-rpc-runtime-api = { default-features = false, path = "system/rpc/runtime-api", optional = true, version = "31.0.0" }

# Used for runtime benchmarking
frame-benchmarking = { default-features = false, path = "../frame/benchmarking", optional = true, version = "33.0.0" }
frame-system-benchmarking = { default-features = false, path = "../frame/system/benchmarking", optional = true, version = "33.0.0" }

# Used for try-runtime
frame-try-runtime = { default-features = false, path = "../frame/try-runtime", optional = true, version = "0.39.0" }

docify = "0.2.8"
log = { workspace = true }

Expand All @@ -67,17 +75,21 @@ runtime = [
"sp-inherents",
"sp-offchain",
"sp-session",
"sp-storage",
"sp-transaction-pool",
"sp-version",

"frame-executive",
"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",
Expand All @@ -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",
]
10 changes: 10 additions & 0 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
macro_rules! #default_parts_unique_id_v2 {
{
$caller:tt
frame_support = [{ $($frame_support:ident)::* }]
your_tt_return = [{ $my_tt_return:path }]
} => {
$($frame_support)*::__private::tt_return! {
$my_tt_return! {
$caller
tokens = [{
+ Pallet #call_part_v2 #storage_part_v2 #event_part_v2 #error_part_v2 #origin_part_v2 #config_part_v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn construct_runtime_implicit_to_explicit(
let frame_support = generate_access_from_frame_or_crate("frame-support")?;
let attr = if legacy_ordering { quote!((legacy_ordering)) } else { quote!() };
let mut expansion = quote::quote!(
#[frame_support::runtime #attr]
#[#frame_support::runtime #attr]
#input
);
for pallet in definition.pallet_decls.iter() {
Expand All @@ -103,7 +103,7 @@ fn construct_runtime_implicit_to_explicit(
expansion = quote::quote!(
#frame_support::__private::tt_call! {
macro = [{ #pallet_path::tt_default_parts_v2 }]
frame_support = [{ #frame_support }]
your_tt_return = [{ #frame_support::__private::tt_return }]
~~> #frame_support::match_and_insert! {
target = [{ #expansion }]
pattern = [{ #pallet_name = #pallet_path #pallet_instance }]
Expand Down