Renames frame crate to polkadot-sdk-frame (#3813)

Step in https://github.com/paritytech/polkadot-sdk/issues/3155

Needed for https://github.com/paritytech/eng-automation/issues/6

This PR renames `frame` crate to `polkadot-sdk-frame` as `frame` is not
available on crates.io

---------

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
gupnik
2024-04-04 07:50:15 +05:30
committed by GitHub
parent 0f4e849e0a
commit 3836376965
19 changed files with 130 additions and 78 deletions
Generated
+35 -35
View File
@@ -5454,35 +5454,6 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa"
[[package]]
name = "frame"
version = "0.0.1-dev"
dependencies = [
"docify",
"frame-executive",
"frame-support",
"frame-system",
"frame-system-rpc-runtime-api",
"log",
"pallet-examples",
"parity-scale-codec",
"scale-info",
"sp-api",
"sp-arithmetic",
"sp-block-builder",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-io",
"sp-offchain",
"sp-runtime",
"sp-session",
"sp-std 14.0.0",
"sp-transaction-pool",
"sp-version",
]
[[package]]
name = "frame-benchmarking"
version = "28.0.0"
@@ -5820,8 +5791,8 @@ dependencies = [
name = "frame-support-test-stg-frame-crate"
version = "0.1.0"
dependencies = [
"frame",
"parity-scale-codec",
"polkadot-sdk-frame",
"scale-info",
]
@@ -8132,11 +8103,11 @@ name = "minimal-template-node"
version = "0.0.0"
dependencies = [
"clap 4.5.3",
"frame",
"futures",
"futures-timer",
"jsonrpsee",
"minimal-template-runtime",
"polkadot-sdk-frame",
"sc-basic-authorship",
"sc-cli",
"sc-client-api",
@@ -8166,7 +8137,6 @@ dependencies = [
name = "minimal-template-runtime"
version = "0.0.0"
dependencies = [
"frame",
"pallet-balances",
"pallet-minimal-template",
"pallet-sudo",
@@ -8174,6 +8144,7 @@ dependencies = [
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
"parity-scale-codec",
"polkadot-sdk-frame",
"scale-info",
"sp-genesis-builder",
"substrate-wasm-builder",
@@ -9844,8 +9815,8 @@ dependencies = [
name = "pallet-example-frame-crate"
version = "0.0.1"
dependencies = [
"frame",
"parity-scale-codec",
"polkadot-sdk-frame",
"scale-info",
]
@@ -10178,8 +10149,8 @@ dependencies = [
name = "pallet-minimal-template"
version = "0.0.0"
dependencies = [
"frame",
"parity-scale-codec",
"polkadot-sdk-frame",
"scale-info",
]
@@ -13377,7 +13348,6 @@ dependencies = [
"cumulus-pallet-aura-ext",
"cumulus-pallet-parachain-system",
"docify",
"frame",
"frame-executive",
"frame-support",
"frame-system",
@@ -13405,6 +13375,7 @@ dependencies = [
"pallet-uniques",
"pallet-utility",
"parity-scale-codec",
"polkadot-sdk-frame",
"sc-cli",
"sc-client-db",
"sc-consensus-aura",
@@ -13434,6 +13405,35 @@ dependencies = [
"substrate-wasm-builder",
]
[[package]]
name = "polkadot-sdk-frame"
version = "0.1.0"
dependencies = [
"docify",
"frame-executive",
"frame-support",
"frame-system",
"frame-system-rpc-runtime-api",
"log",
"pallet-examples",
"parity-scale-codec",
"scale-info",
"sp-api",
"sp-arithmetic",
"sp-block-builder",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-io",
"sp-offchain",
"sp-runtime",
"sp-session",
"sp-std 14.0.0",
"sp-transaction-pool",
"sp-version",
]
[[package]]
name = "polkadot-service"
version = "7.0.0"
+1 -1
View File
@@ -17,7 +17,7 @@ workspace = true
# Needed for all FRAME-based code
parity-scale-codec = { version = "3.0.0", default-features = false }
scale-info = { version = "2.6.0", default-features = false }
frame = { path = "../../substrate/frame", features = [
frame = { package = "polkadot-sdk-frame", path = "../../substrate/frame", features = [
"experimental",
"runtime",
] }
+14
View File
@@ -0,0 +1,14 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
title: Renames `frame` crate to `polkadot-sdk-frame`
doc:
- audience: Runtime Dev
description: |
This PR renames `frame` crate to `polkadot-sdk-frame` as `frame` is not available on crates.io.
Please note that this crate can only be imported as `polkadot-sdk-frame` or `frame`.
crates:
- name: polkadot-sdk-frame
bump: major
+1 -1
View File
@@ -140,7 +140,7 @@
//! <td>A JSON object that provides an explicit and comprehensive representation of the
//! <code>RuntimeGenesisConfig</code> struct, which is generated by <a
//! href="../frame_support_procedural/macro.construct_runtime.html"
//! ><code>frame::runtime::prelude::construct_runtime</code></a> macro (<a
//! ><code>polkadot_sdk_frame::runtime::prelude::construct_runtime</code></a> macro (<a
//! href="../substrate_test_runtime/struct.RuntimeGenesisConfig.html#"
//! >example of generated struct</a>). Must contain all the keys of
//! the genesis config, no defaults will be used.
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "frame"
version = "0.0.1-dev"
name = "polkadot-sdk-frame"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
@@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
frame = { path = "../..", default-features = false, features = ["experimental", "runtime"] }
frame = { package = "polkadot-sdk-frame", path = "../..", default-features = false, features = ["experimental", "runtime"] }
[features]
+14 -10
View File
@@ -45,16 +45,20 @@
//!
//! In short, this crate only re-exports types and traits from multiple sources. All of these
//! sources are listed (and re-exported again) in [`deps`].
//!
//! ## Usage
//!
//! Please note that this crate can only be imported as `polkadot-sdk-frame` or `frame`.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "experimental")]
/// Exports the main pallet macro. This can wrap a `mod pallet` and will transform it into
/// being a pallet, eg `#[frame::pallet] mod pallet { .. }`.
/// being a pallet, eg `#[polkadot_sdk_frame::pallet] mod pallet { .. }`.
///
/// Note that this is not part of the prelude, in order to make it such that the common way to
/// define a macro is `#[frame::pallet] mod pallet { .. }`, followed by `#[pallet::foo]`,
/// `#[pallet::bar]` inside the mod.
/// define a macro is `#[polkadot_sdk_frame::pallet] mod pallet { .. }`, followed by
/// `#[pallet::foo]`, `#[pallet::bar]` inside the mod.
pub use frame_support::pallet;
pub use frame_support::pallet_macros::{import_section, pallet_section};
@@ -75,7 +79,7 @@ pub mod pallet_macros {
/// This prelude should almost always be the first line of code in any pallet or runtime.
///
/// ```
/// use frame::prelude::*;
/// use polkadot_sdk_frame::prelude::*;
///
/// // rest of your pallet..
/// mod pallet {}
@@ -84,7 +88,7 @@ pub mod prelude {
/// `frame_system`'s parent crate, which is mandatory in all pallets build with this crate.
///
/// Conveniently, the keyword `frame_system` is in scope as one uses `use
/// frame::prelude::*`
/// polkadot_sdk_frame::prelude::*`
#[doc(inline)]
pub use frame_system;
@@ -112,7 +116,7 @@ pub mod prelude {
/// A test setup typically starts with:
///
/// ```
/// use frame::testing_prelude::*;
/// use polkadot_sdk_frame::testing_prelude::*;
/// // rest of your test setup.
/// ```
#[cfg(feature = "std")]
@@ -141,7 +145,7 @@ pub mod runtime {
/// A runtime typically starts with:
///
/// ```
/// use frame::{prelude::*, runtime::prelude::*};
/// use polkadot_sdk_frame::{prelude::*, runtime::prelude::*};
/// ```
pub mod prelude {
/// All of the types related to the FRAME runtime executive.
@@ -186,7 +190,7 @@ pub mod runtime {
/// A non-testing runtime should have this enabled, as such:
///
/// ```
/// use frame::runtime::{prelude::*, apis::{*,}};
/// use polkadot_sdk_frame::runtime::{prelude::*, apis::{*,}};
/// ```
// TODO: This is because of wildcard imports, and it should be not needed once we can avoid
// that. Imports like that are needed because we seem to need some unknown types in the macro
@@ -330,8 +334,8 @@ pub mod derive {
/// In most cases, hopefully the answer is yes.
pub mod deps {
// TODO: It would be great to somehow instruct RA to prefer *not* suggesting auto-imports from
// these. For example, we prefer `frame::derive::CloneNoBound` rather than
// `frame::deps::frame_support::CloneNoBound`.
// these. For example, we prefer `polkadot_sdk_frame::derive::CloneNoBound` rather than
// `polkadot_sdk_frame::deps::frame_support::CloneNoBound`.
pub use frame_support;
pub use frame_system;
@@ -665,9 +665,9 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
"{}::macro_magic",
match generate_access_from_frame_or_crate("frame-support") {
Ok(path) => Ok(path),
Err(_) => generate_access_from_frame_or_crate("frame"),
Err(_) => generate_access_from_frame_or_crate("polkadot-sdk-frame"),
}
.expect("Failed to find either `frame-support` or `frame` in `Cargo.toml` dependencies.")
.expect("Failed to find either `frame-support` or `polkadot-sdk-frame` in `Cargo.toml` dependencies.")
.to_token_stream()
.to_string()
)
@@ -1181,9 +1181,9 @@ pub fn pallet_section(attr: TokenStream, tokens: TokenStream) -> TokenStream {
"{}::macro_magic",
match generate_access_from_frame_or_crate("frame-support") {
Ok(path) => Ok(path),
Err(_) => generate_access_from_frame_or_crate("frame"),
Err(_) => generate_access_from_frame_or_crate("polkadot-sdk-frame"),
}
.expect("Failed to find either `frame-support` or `frame` in `Cargo.toml` dependencies.")
.expect("Failed to find either `frame-support` or `polkadot-sdk-frame` in `Cargo.toml` dependencies.")
.to_token_stream()
.to_string()
)
@@ -275,7 +275,8 @@ fn check_event_type(
}
/// Check that the path to `frame_system::Config` is valid, this is that the path is just
/// `frame_system::Config` or when using the `frame` crate it is `frame::xyz::frame_system::Config`.
/// `frame_system::Config` or when using the `frame` crate it is
/// `polkadot_sdk_frame::xyz::frame_system::Config`.
fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool {
// Check if `frame_system` is actually 'frame_system'.
if path.segments.iter().all(|s| s.ident != "frame_system") {
@@ -293,7 +294,7 @@ fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool
// `frame` re-exports it as such.
syn::parse2::<syn::Path>(quote::quote!(frame_system)).expect("is a valid path; qed"),
(_, _) =>
// They are either both `frame_system` or both `frame::xyz::frame_system`.
// They are either both `frame_system` or both `polkadot_sdk_frame::xyz::frame_system`.
frame_system.clone(),
};
@@ -516,14 +517,28 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_frame() {
let path = syn::parse2::<syn::Path>(quote::quote!(frame_system::Config)).unwrap();
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
assert!(has_expected_system_config(path.clone(), &frame_system));
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(frame_system::Config)).unwrap();
assert!(has_expected_system_config(path, &frame_system));
}
#[test]
fn has_expected_system_config_works_with_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(has_expected_system_config(path, &frame_system));
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
let path =
@@ -533,6 +548,13 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_other_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system::Config))
.unwrap();
assert!(has_expected_system_config(path, &frame_system));
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system)).unwrap();
let path =
@@ -543,18 +565,21 @@ mod tests {
#[test]
fn has_expected_system_config_does_not_works_with_mixed_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}
#[test]
fn has_expected_system_config_does_not_works_with_other_mixed_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}
@@ -562,7 +587,8 @@ mod tests {
fn has_expected_system_config_does_not_work_with_frame_full_path_if_not_frame_crate() {
let frame_system = syn::parse2::<syn::Path>(quote::quote!(frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}
@@ -54,15 +54,19 @@ pub fn generate_crate_access(unique_id: &str, def_crate: &str) -> TokenStream {
///
/// This will usually check the output of [`generate_access_from_frame_or_crate`].
/// We want to know if whatever the `path` takes us to, is exported from `frame` or not. In that
/// case `path` would start with `frame`, something like `frame::x::y:z`.
/// case `path` would start with `frame`, something like `polkadot_sdk_frame::x::y:z` or
/// frame::x::y:z.
pub fn is_using_frame_crate(path: &syn::Path) -> bool {
path.segments.first().map(|s| s.ident == "frame").unwrap_or(false)
path.segments
.first()
.map(|s| s.ident == "polkadot_sdk_frame" || s.ident == "frame")
.unwrap_or(false)
}
/// Generate the crate access for the crate using 2018 syntax.
///
/// If `frame` is in scope, it will use `frame::deps::<def_crate>`. Else, it will try and find
/// `<def_crate>` directly.
/// If `frame` is in scope, it will use `polkadot_sdk_frame::deps::<def_crate>`. Else, it will try
/// and find `<def_crate>` directly.
pub fn generate_access_from_frame_or_crate(def_crate: &str) -> Result<syn::Path, Error> {
if let Some(path) = get_frame_crate_path(def_crate) {
Ok(path)
@@ -114,7 +118,9 @@ pub fn generate_hidden_includes(unique_id: &str, def_crate: &str) -> TokenStream
/// Generates the path to the frame crate deps.
fn get_frame_crate_path(def_crate: &str) -> Option<syn::Path> {
// This does not work if the frame crate is renamed.
if let Ok(FoundCrate::Name(name)) = crate_name(&"frame") {
if let Ok(FoundCrate::Name(name)) =
crate_name(&"polkadot-sdk-frame").or_else(|_| crate_name(&"frame"))
{
let path = format!("{}::deps::{}", name, def_crate.to_string().replace("-", "_"));
Some(syn::parse_str::<syn::Path>(&path).expect("is a valid path; qed"))
} else {
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
frame = { path = "../../..", default-features = false, features = ["experimental", "runtime"] }
frame = { package = "polkadot-sdk-frame", path = "../../..", default-features = false, features = ["experimental", "runtime"] }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
[features]
@@ -17,13 +17,13 @@
#[frame_support::pallet]
mod pallet {
use frame::deps::frame_system::pallet_prelude::BlockNumberFor;
use polkadot_sdk_frame::deps::frame_system::pallet_prelude::BlockNumberFor;
use frame_support::pallet_prelude::{Hooks, IsType};
#[pallet::config]
pub trait Config: frame::deps::frame_system::Config {
pub trait Config: polkadot_sdk_frame::deps::frame_system::Config {
type Bar: Clone + std::fmt::Debug + Eq;
type RuntimeEvent: IsType<<Self as frame::deps::frame_system::Config>::RuntimeEvent>
type RuntimeEvent: IsType<<Self as polkadot_sdk_frame::deps::frame_system::Config>::RuntimeEvent>
+ From<Event<Self>>;
}
@@ -1,5 +1,5 @@
error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `IsType<<Self as frame_system::Config>::RuntimeEvent>`
--> tests/pallet_ui/event_type_invalid_bound_no_frame_crate.rs:26:3
|
26 | type RuntimeEvent: IsType<<Self as frame::deps::frame_system::Config>::RuntimeEvent>
26 | type RuntimeEvent: IsType<<Self as polkadot_sdk_frame::deps::frame_system::Config>::RuntimeEvent>
| ^^^^
@@ -34,7 +34,9 @@ pub fn generate_crate_access() -> TokenStream {
quote!(#renamed_name::__private)
},
Err(e) =>
if let Ok(FoundCrate::Name(name)) = crate_name(&"frame") {
if let Ok(FoundCrate::Name(name)) =
crate_name(&"polkadot-sdk-frame").or_else(|_| crate_name(&"frame"))
{
let path = format!("{}::deps::sp_api::__private", name);
let path = syn::parse_str::<syn::Path>(&path).expect("is a valid path; qed");
quote!( #path )
@@ -48,7 +48,7 @@ use std::{
};
/// Logging target
const LOG_TARGET: &'static str = "frame::benchmark::pallet";
const LOG_TARGET: &'static str = "polkadot_sdk_frame::benchmark::pallet";
/// The inclusive range of a component.
#[derive(Serialize, Debug, Clone, Eq, PartialEq)]
+1 -1
View File
@@ -161,7 +161,7 @@ impl<V: FullCodec> StorageQuery<V> {
/// Send this query over RPC, await the typed result.
///
/// Hash should be `<YourRuntime as frame::Config>::Hash`.
/// Hash should be `<YourRuntime as frame_system::Config>::Hash`.
///
/// # Arguments
///
+1 -1
View File
@@ -49,7 +49,7 @@ substrate-frame-rpc-system = { path = "../../../substrate/utils/frame/rpc/system
# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
# certainly no dependency on the runtime.
frame = { path = "../../../substrate/frame", features = [
frame = { package = "polkadot-sdk-frame", path = "../../../substrate/frame", features = [
"experimental",
"runtime",
] }
@@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
scale-info = { version = "2.11.1", default-features = false, features = [
"derive",
] }
frame = { path = "../../../../substrate/frame", default-features = false, features = [
frame = { package = "polkadot-sdk-frame", path = "../../../../substrate/frame", default-features = false, features = [
"experimental",
"runtime",
] }
+1 -1
View File
@@ -17,7 +17,7 @@ parity-scale-codec = { version = "3.0.0", default-features = false }
scale-info = { version = "2.6.0", default-features = false }
# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
frame = { path = "../../../substrate/frame", default-features = false, features = [
frame = { package = "polkadot-sdk-frame", path = "../../../substrate/frame", default-features = false, features = [
"experimental",
"runtime",
] }