Restructure frame_support macro related exports (#14745)

* make reexports private

* make reexports private 2

* make reexports private for runtime-benchmarking

* make reexports private for try-runtime

* fix for try-runtime

* make reexports private for tests

* fmt

* make reexports private for tests

* make reexports private for experimental

* fix beefy

* fix ui test

* fix ui test

* fix benches

* ".git/.scripts/commands/fmt/fmt.sh"

* fix contracts use

* wip

* wip

* do not reexport sp_api::metadata_ir

* fix CI checks

* fix support tests

* ".git/.scripts/commands/fmt/fmt.sh"

* Update frame/support/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* import codec directly

* fmt

* fix node-cli tests

---------

Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Juan
2023-08-23 14:30:12 +02:00
committed by GitHub
parent 574592d1cf
commit 878c562cd4
125 changed files with 449 additions and 398 deletions
@@ -275,9 +275,9 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
#frame_support::CloneNoBound,
#frame_support::EqNoBound,
#frame_support::PartialEqNoBound,
#frame_support::codec::Encode,
#frame_support::codec::Decode,
#frame_support::scale_info::TypeInfo,
#frame_support::__private::codec::Encode,
#frame_support::__private::codec::Decode,
#frame_support::__private::scale_info::TypeInfo,
)]
#[codec(encode_bound())]
#[codec(decode_bound())]
@@ -287,7 +287,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
#[doc(hidden)]
#[codec(skip)]
__Ignore(
#frame_support::sp_std::marker::PhantomData<(#type_use_gen,)>,
#frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen,)>,
#frame_support::Never,
),
#(
@@ -394,8 +394,8 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
match self {
#(
Self::#fn_name { #( #args_name_pattern, )* } => {
#frame_support::sp_tracing::enter_span!(
#frame_support::sp_tracing::trace_span!(stringify!(#fn_name))
#frame_support::__private::sp_tracing::enter_span!(
#frame_support::__private::sp_tracing::trace_span!(stringify!(#fn_name))
);
#maybe_allow_attrs
<#pallet_ident<#type_use_gen>>::#fn_name(origin, #( #args_name, )* )
@@ -419,8 +419,8 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clause {
#[doc(hidden)]
pub fn call_functions() -> #frame_support::metadata_ir::PalletCallMetadataIR {
#frame_support::scale_info::meta_type::<#call_ident<#type_use_gen>>().into()
pub fn call_functions() -> #frame_support::__private::metadata_ir::PalletCallMetadataIR {
#frame_support::__private::scale_info::meta_type::<#call_ident<#type_use_gen>>().into()
}
}
)
@@ -54,7 +54,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
default_byte_impl: quote::quote!(
let value = <<T as Config #trait_use_gen>::#ident as
#frame_support::traits::Get<#const_type>>::get();
#frame_support::codec::Encode::encode(&value)
#frame_support::__private::codec::Encode::encode(&value)
),
metadata_name: None,
}
@@ -69,7 +69,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
doc: const_.doc.clone(),
default_byte_impl: quote::quote!(
let value = <Pallet<#type_use_gen>>::#ident();
#frame_support::codec::Encode::encode(&value)
#frame_support::__private::codec::Encode::encode(&value)
),
metadata_name: const_.metadata_name.clone(),
}
@@ -85,11 +85,11 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
let default_byte_impl = &const_.default_byte_impl;
quote::quote!({
#frame_support::metadata_ir::PalletConstantMetadataIR {
#frame_support::__private::metadata_ir::PalletConstantMetadataIR {
name: #ident_str,
ty: #frame_support::scale_info::meta_type::<#const_type>(),
ty: #frame_support::__private::scale_info::meta_type::<#const_type>(),
value: { #default_byte_impl },
docs: #frame_support::sp_std::vec![ #( #doc ),* ],
docs: #frame_support::__private::sp_std::vec![ #( #doc ),* ],
}
})
});
@@ -99,9 +99,9 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream {
#[doc(hidden)]
pub fn pallet_constants_metadata()
-> #frame_support::sp_std::vec::Vec<#frame_support::metadata_ir::PalletConstantMetadataIR>
-> #frame_support::__private::sp_std::vec::Vec<#frame_support::__private::metadata_ir::PalletConstantMetadataIR>
{
#frame_support::sp_std::vec![ #( #consts ),* ]
#frame_support::__private::sp_std::vec![ #( #consts ),* ]
}
}
)
@@ -163,9 +163,9 @@ pub fn expand_documentation(def: &mut Def) -> proc_macro2::TokenStream {
#[doc(hidden)]
pub fn pallet_documentation_metadata()
-> #frame_support::sp_std::vec::Vec<&'static str>
-> #frame_support::__private::sp_std::vec::Vec<&'static str>
{
#frame_support::sp_std::vec![ #( #docs ),* ]
#frame_support::__private::sp_std::vec![ #( #docs ),* ]
}
}
)
@@ -44,7 +44,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
$caller:tt
frame_support = [{ $($frame_support:ident)::* }]
} => {
$($frame_support::)*tt_return! {
$($frame_support::)*__private::tt_return! {
$caller
}
};
@@ -62,7 +62,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
#[doc(hidden)]
#[codec(skip)]
__Ignore(
#frame_support::sp_std::marker::PhantomData<(#type_use_gen)>,
#frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen)>,
#frame_support::Never,
)
);
@@ -98,9 +98,9 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
// derive TypeInfo for error metadata
error_item.attrs.push(syn::parse_quote! {
#[derive(
#frame_support::codec::Encode,
#frame_support::codec::Decode,
#frame_support::scale_info::TypeInfo,
#frame_support::__private::codec::Encode,
#frame_support::__private::codec::Decode,
#frame_support::__private::scale_info::TypeInfo,
#frame_support::PalletError,
)]
});
@@ -115,11 +115,11 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
}
quote::quote_spanned!(error.attr_span =>
impl<#type_impl_gen> #frame_support::sp_std::fmt::Debug for #error_ident<#type_use_gen>
impl<#type_impl_gen> #frame_support::__private::sp_std::fmt::Debug for #error_ident<#type_use_gen>
#config_where_clause
{
fn fmt(&self, f: &mut #frame_support::sp_std::fmt::Formatter<'_>)
-> #frame_support::sp_std::fmt::Result
fn fmt(&self, f: &mut #frame_support::__private::sp_std::fmt::Formatter<'_>)
-> #frame_support::__private::sp_std::fmt::Result
{
f.write_str(self.as_str())
}
@@ -148,7 +148,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
#config_where_clause
{
fn from(err: #error_ident<#type_use_gen>) -> Self {
use #frame_support::codec::Encode;
use #frame_support::__private::codec::Encode;
let index = <
<T as #frame_system::Config>::PalletInfo
as #frame_support::traits::PalletInfo
@@ -172,7 +172,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
$caller:tt
frame_support = [{ $($frame_support:ident)::* }]
} => {
$($frame_support::)*tt_return! {
$($frame_support::)*__private::tt_return! {
$caller
error = [{ #error_ident }]
}
@@ -87,7 +87,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
#[doc(hidden)]
#[codec(skip)]
__Ignore(
#frame_support::sp_std::marker::PhantomData<(#event_use_gen)>,
#frame_support::__private::sp_std::marker::PhantomData<(#event_use_gen)>,
#frame_support::Never,
)
);
@@ -109,9 +109,9 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream {
#frame_support::EqNoBound,
#frame_support::PartialEqNoBound,
#frame_support::RuntimeDebugNoBound,
#frame_support::codec::Encode,
#frame_support::codec::Decode,
#frame_support::scale_info::TypeInfo,
#frame_support::__private::codec::Encode,
#frame_support::__private::codec::Decode,
#frame_support::__private::scale_info::TypeInfo,
)]
));
@@ -39,7 +39,7 @@ pub fn expand_genesis_build(def: &mut Def) -> proc_macro2::TokenStream {
impl<#type_impl_gen> #frame_support::sp_runtime::BuildStorage for #gen_cfg_ident<#gen_cfg_use_gen> #where_clause
{
fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> std::result::Result<(), std::string::String> {
#frame_support::BasicExternalities::execute_with_storage(storage, || {
#frame_support::__private::BasicExternalities::execute_with_storage(storage, || {
self.build();
Ok(())
})
@@ -79,7 +79,7 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream {
let genesis_config_item =
&mut def.item.content.as_mut().expect("Checked by def parser").1[genesis_config.index];
let serde_crate = format!("{}::serde", frame_support);
let serde_crate = format!("{}::__private::serde", frame_support);
match genesis_config_item {
syn::Item::Enum(syn::ItemEnum { attrs, .. }) |
@@ -38,7 +38,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
let log_runtime_upgrade = if has_runtime_upgrade {
// a migration is defined here.
quote::quote! {
#frame_support::log::info!(
#frame_support::__private::log::info!(
target: #frame_support::LOG_TARGET,
"⚠️ {} declares internal migrations (which *might* execute). \
On-chain `{:?}` vs current storage version `{:?}`",
@@ -50,7 +50,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
} else {
// default.
quote::quote! {
#frame_support::log::debug!(
#frame_support::__private::log::debug!(
target: #frame_support::LOG_TARGET,
"✅ no migration for {}",
pallet_name,
@@ -64,7 +64,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
as
#frame_support::traits::PalletInfo
>::name::<Self>().expect("No name found for the pallet! This usually means that the pallet wasn't added to `construct_runtime!`.");
#frame_support::log::debug!(
#frame_support::__private::log::debug!(
target: #frame_support::LOG_TARGET,
"🩺 try-state pallet {:?}",
pallet_name,
@@ -97,7 +97,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
#frame_support::traits::PalletInfo
>::name::<Self>().unwrap_or("<unknown pallet name>");
#frame_support::log::error!(
#frame_support::__private::log::error!(
target: #frame_support::LOG_TARGET,
"{}: On chain storage version {:?} doesn't match current storage version {:?}.",
pallet_name,
@@ -119,7 +119,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
#frame_support::traits::PalletInfo
>::name::<Self>().unwrap_or("<unknown pallet name>");
#frame_support::log::error!(
#frame_support::__private::log::error!(
target: #frame_support::LOG_TARGET,
"{}: On chain storage version {:?} is set to non zero, \
while the pallet is missing the `#[pallet::storage_version(VERSION)]` attribute.",
@@ -141,8 +141,8 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
for #pallet_ident<#type_use_gen> #where_clause
{
fn on_finalize(n: #frame_system::pallet_prelude::BlockNumberFor::<T>) {
#frame_support::sp_tracing::enter_span!(
#frame_support::sp_tracing::trace_span!("on_finalize")
#frame_support::__private::sp_tracing::enter_span!(
#frame_support::__private::sp_tracing::trace_span!("on_finalize")
);
<
Self as #frame_support::traits::Hooks<
@@ -175,8 +175,8 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
fn on_initialize(
n: #frame_system::pallet_prelude::BlockNumberFor::<T>
) -> #frame_support::weights::Weight {
#frame_support::sp_tracing::enter_span!(
#frame_support::sp_tracing::trace_span!("on_initialize")
#frame_support::__private::sp_tracing::enter_span!(
#frame_support::__private::sp_tracing::trace_span!("on_initialize")
);
<
Self as #frame_support::traits::Hooks<
@@ -191,8 +191,8 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
for #pallet_ident<#type_use_gen> #where_clause
{
fn on_runtime_upgrade() -> #frame_support::weights::Weight {
#frame_support::sp_tracing::enter_span!(
#frame_support::sp_tracing::trace_span!("on_runtime_update")
#frame_support::__private::sp_tracing::enter_span!(
#frame_support::__private::sp_tracing::trace_span!("on_runtime_update")
);
// log info about the upgrade.
@@ -211,7 +211,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<#frame_support::sp_std::vec::Vec<u8>, #frame_support::sp_runtime::TryRuntimeError> {
fn pre_upgrade() -> Result<#frame_support::__private::sp_std::vec::Vec<u8>, #frame_support::sp_runtime::TryRuntimeError> {
<
Self
as
@@ -220,7 +220,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(state: #frame_support::sp_std::vec::Vec<u8>) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> {
fn post_upgrade(state: #frame_support::__private::sp_std::vec::Vec<u8>) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> {
#post_storage_version_check
<
@@ -251,7 +251,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
for #pallet_ident<#type_use_gen> #where_clause
{
fn integrity_test() {
#frame_support::sp_io::TestExternalities::default().execute_with(|| {
#frame_support::__private::sp_io::TestExternalities::default().execute_with(|| {
<
Self as #frame_support::traits::Hooks<
#frame_system::pallet_prelude::BlockNumberFor::<T>
@@ -54,7 +54,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
if let Some(field) = pallet_item.fields.iter_mut().next() {
if field.ty == syn::parse_quote!(_) {
field.ty = syn::parse_quote!(
#frame_support::sp_std::marker::PhantomData<(#type_use_gen)>
#frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen)>
);
}
}
@@ -82,9 +82,9 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote_spanned!(def.pallet_struct.attr_span =>
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #config_where_clause {
#[doc(hidden)]
pub fn error_metadata() -> Option<#frame_support::metadata_ir::PalletErrorMetadataIR> {
Some(#frame_support::metadata_ir::PalletErrorMetadataIR {
ty: #frame_support::scale_info::meta_type::<#error_ident<#type_use_gen>>()
pub fn error_metadata() -> Option<#frame_support::__private::metadata_ir::PalletErrorMetadataIR> {
Some(#frame_support::__private::metadata_ir::PalletErrorMetadataIR {
ty: #frame_support::__private::scale_info::meta_type::<#error_ident<#type_use_gen>>()
})
}
}
@@ -93,7 +93,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
quote::quote_spanned!(def.pallet_struct.attr_span =>
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #config_where_clause {
#[doc(hidden)]
pub fn error_metadata() -> Option<#frame_support::metadata_ir::PalletErrorMetadataIR> {
pub fn error_metadata() -> Option<#frame_support::__private::metadata_ir::PalletErrorMetadataIR> {
None
}
}
@@ -139,10 +139,10 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
#storages_where_clauses
{
fn storage_info()
-> #frame_support::sp_std::vec::Vec<#frame_support::traits::StorageInfo>
-> #frame_support::__private::sp_std::vec::Vec<#frame_support::traits::StorageInfo>
{
#[allow(unused_mut)]
let mut res = #frame_support::sp_std::vec![];
let mut res = #frame_support::__private::sp_std::vec![];
#(
#(#storage_cfg_attrs)*
@@ -179,8 +179,8 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
let whitelisted_storage_keys_impl = quote::quote![
use #frame_support::traits::{StorageInfoTrait, TrackedStorageKey, WhitelistedStorageKeys};
impl<#type_impl_gen> WhitelistedStorageKeys for #pallet_ident<#type_use_gen> #storages_where_clauses {
fn whitelisted_storage_keys() -> #frame_support::sp_std::vec::Vec<TrackedStorageKey> {
use #frame_support::sp_std::vec;
fn whitelisted_storage_keys() -> #frame_support::__private::sp_std::vec::Vec<TrackedStorageKey> {
use #frame_support::__private::sp_std::vec;
vec![#(
TrackedStorageKey::new(#whitelisted_storage_idents::<#type_use_gen>::hashed_key().to_vec())
),*]
@@ -264,7 +264,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
#config_where_clause
{
fn count() -> usize { 1 }
fn infos() -> #frame_support::sp_std::vec::Vec<#frame_support::traits::PalletInfoData> {
fn infos() -> #frame_support::__private::sp_std::vec::Vec<#frame_support::traits::PalletInfoData> {
use #frame_support::traits::PalletInfoAccess;
let item = #frame_support::traits::PalletInfoData {
index: Self::index(),
@@ -272,7 +272,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
module_name: Self::module_name(),
crate_version: Self::crate_version(),
};
#frame_support::sp_std::vec![item]
#frame_support::__private::sp_std::vec![item]
}
}
@@ -421,7 +421,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
#(#cfg_attrs)*
{
<#full_ident as #frame_support::storage::StorageEntryMetadataBuilder>::build_metadata(
#frame_support::sp_std::vec![
#frame_support::__private::sp_std::vec![
#( #docs, )*
],
&mut entries,
@@ -492,7 +492,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause {
#[doc = #getter_doc_line]
pub fn #getter<KArg>(k: KArg) -> #query where
KArg: #frame_support::codec::EncodeLike<#key>,
KArg: #frame_support::__private::codec::EncodeLike<#key>,
{
<
#full_ident as #frame_support::storage::StorageMap<#key, #value>
@@ -518,7 +518,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause {
#[doc = #getter_doc_line]
pub fn #getter<KArg>(k: KArg) -> #query where
KArg: #frame_support::codec::EncodeLike<#key>,
KArg: #frame_support::__private::codec::EncodeLike<#key>,
{
// NOTE: we can't use any trait here because CountedStorageMap
// doesn't implement any.
@@ -544,8 +544,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
impl<#type_impl_gen> #pallet_ident<#type_use_gen> #completed_where_clause {
#[doc = #getter_doc_line]
pub fn #getter<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> #query where
KArg1: #frame_support::codec::EncodeLike<#key1>,
KArg2: #frame_support::codec::EncodeLike<#key2>,
KArg1: #frame_support::__private::codec::EncodeLike<#key1>,
KArg2: #frame_support::__private::codec::EncodeLike<#key2>,
{
<
#full_ident as
@@ -791,8 +791,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
#completed_where_clause
{
#[doc(hidden)]
pub fn storage_metadata() -> #frame_support::metadata_ir::PalletStorageMetadataIR {
#frame_support::metadata_ir::PalletStorageMetadataIR {
pub fn storage_metadata() -> #frame_support::__private::metadata_ir::PalletStorageMetadataIR {
#frame_support::__private::metadata_ir::PalletStorageMetadataIR {
prefix: <
<T as #frame_system::Config>::PalletInfo as
#frame_support::traits::PalletInfo
@@ -800,7 +800,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
.expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`."),
entries: {
#[allow(unused_mut)]
let mut entries = #frame_support::sp_std::vec![];
let mut entries = #frame_support::__private::sp_std::vec![];
#( #entries_builder )*
entries
},
@@ -96,7 +96,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
$caller:tt
frame_support = [{ $($frame_support:ident)::* }]
} => {
$($frame_support)*::tt_return! {
$($frame_support)*::__private::tt_return! {
$caller
tokens = [{
expanded::{
@@ -126,7 +126,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream {
$caller:tt
frame_support = [{ $($frame_support:ident)::* }]
} => {
$($frame_support)*::tt_return! {
$($frame_support)*::__private::tt_return! {
$caller
tokens = [{
expanded::{
@@ -120,9 +120,9 @@ impl CompositeDef {
let derive_attr: syn::Attribute = syn::parse_quote! {
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd,
#scrate::codec::Encode, #scrate::codec::Decode, #scrate::codec::MaxEncodedLen,
#scrate::scale_info::TypeInfo,
#scrate::RuntimeDebug,
#scrate::__private::codec::Encode, #scrate::__private::codec::Decode, #scrate::__private::codec::MaxEncodedLen,
#scrate::__private::scale_info::TypeInfo,
#scrate::__private::RuntimeDebug,
)]
};
item.attrs.push(derive_attr);