From 1dfc9b4f09ff53d2a5ef17d2c284d133a25f4b3d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 09:08:19 +0200 Subject: [PATCH 01/42] make reexports private --- frame/support/procedural/src/benchmark.rs | 2 +- .../procedural/src/pallet/expand/call.rs | 16 ++--- .../procedural/src/pallet/expand/constants.rs | 14 ++-- .../src/pallet/expand/documentation.rs | 4 +- .../procedural/src/pallet/expand/error.rs | 16 ++--- .../procedural/src/pallet/expand/event.rs | 8 +-- .../procedural/src/pallet/expand/hooks.rs | 26 +++---- .../src/pallet/expand/pallet_struct.rs | 22 +++--- .../procedural/src/pallet/expand/storage.rs | 16 ++--- frame/support/src/dispatch.rs | 26 ++++--- frame/support/src/hash.rs | 2 +- frame/support/src/lib.rs | 71 ++++++++----------- frame/support/src/storage/child.rs | 4 +- .../support/src/storage/storage_noop_guard.rs | 4 +- .../support/src/storage/types/counted_map.rs | 2 +- frame/support/src/storage/types/double_map.rs | 2 +- frame/support/src/storage/types/key.rs | 6 +- frame/support/src/storage/types/map.rs | 2 +- frame/support/src/storage/types/mod.rs | 2 +- frame/support/src/storage/types/nmap.rs | 2 +- frame/support/src/storage/types/value.rs | 2 +- frame/support/src/traits/misc.rs | 6 +- frame/support/src/traits/storage.rs | 7 +- frame/support/src/traits/validation.rs | 4 +- frame/system/src/migrations/mod.rs | 2 +- frame/system/src/offchain.rs | 2 +- 26 files changed, 128 insertions(+), 142 deletions(-) diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 9f28e7129d2e1..5a5bafa0929c6 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -724,7 +724,7 @@ fn expand_benchmark( Ok(ident) => ident, Err(err) => return err.to_compile_error().into(), }; - let codec = quote!(#krate::frame_support::codec); + let codec = quote!(#krate::frame_support::__private::codec); let traits = quote!(#krate::frame_support::traits); let setup_stmts = benchmark_def.setup_stmts; let verify_stmts = benchmark_def.verify_stmts; diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 031fa02bb9d6d..cc00319fb900b 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -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, ), #( @@ -398,8 +398,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, )* ) @@ -423,8 +423,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() } } ) diff --git a/frame/support/procedural/src/pallet/expand/constants.rs b/frame/support/procedural/src/pallet/expand/constants.rs index 6e1cd3df627f3..57fa8b7f3cd9a 100644 --- a/frame/support/procedural/src/pallet/expand/constants.rs +++ b/frame/support/procedural/src/pallet/expand/constants.rs @@ -54,7 +54,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream { default_byte_impl: quote::quote!( let value = <::#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 = >::#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 ),* ] } } ) diff --git a/frame/support/procedural/src/pallet/expand/documentation.rs b/frame/support/procedural/src/pallet/expand/documentation.rs index 4e6347e83bb73..ec19f889a9f20 100644 --- a/frame/support/procedural/src/pallet/expand/documentation.rs +++ b/frame/support/procedural/src/pallet/expand/documentation.rs @@ -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 ),* ] } } ) diff --git a/frame/support/procedural/src/pallet/expand/error.rs b/frame/support/procedural/src/pallet/expand/error.rs index 376a6a9f51c6d..31c4d3e6fedca 100644 --- a/frame/support/procedural/src/pallet/expand/error.rs +++ b/frame/support/procedural/src/pallet/expand/error.rs @@ -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 = < ::PalletInfo as #frame_support::traits::PalletInfo diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index f94bdef332d9d..fbb699b4d41cc 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -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, )] )); diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index d2d2b2967fafb..174abb24950de 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -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::().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::().unwrap_or(""); - #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::().unwrap_or(""); - #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::) { - #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:: ) -> #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, #frame_support::sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result<#frame_support::__private::sp_std::vec::Vec, #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) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { + fn post_upgrade(state: #frame_support::__private::sp_std::vec::Vec) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { #post_storage_version_check < diff --git a/frame/support/procedural/src/pallet/expand/pallet_struct.rs b/frame/support/procedural/src/pallet/expand/pallet_struct.rs index 800e23388c1af..e519e34d1dfd9 100644 --- a/frame/support/procedural/src/pallet/expand/pallet_struct.rs +++ b/frame/support/procedural/src/pallet/expand/pallet_struct.rs @@ -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 { - use #frame_support::sp_std::vec; + fn whitelisted_storage_keys() -> #frame_support::__private::sp_std::vec::Vec { + 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] } } diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index f3c394d731f5c..1a941f6cb3f5c 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -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(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(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(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: < ::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 }, diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index e462066a84605..f1b2071334b81 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -18,21 +18,14 @@ //! Dispatch system. Contains a macro for defining runtime modules and //! generating values representing lazy module function calls. -pub use crate::{ - codec::{ - Codec, Decode, Encode, EncodeAsRef, EncodeLike, HasCompact, Input, MaxEncodedLen, Output, - }, - scale_info::TypeInfo, - sp_std::{ - fmt, marker, - prelude::{Clone, Eq, PartialEq, Vec}, - result, - }, - traits::{ - CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, - UnfilteredDispatchable, - }, +pub use crate::traits::{ + CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, + UnfilteredDispatchable, }; +use codec::{ + Codec, Decode, Encode, EncodeAsRef, EncodeLike, HasCompact, Input, MaxEncodedLen, Output, +}; +use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::{ @@ -42,6 +35,11 @@ use sp_runtime::{ pub use sp_runtime::{ traits::Dispatchable, transaction_validity::TransactionPriority, DispatchError, RuntimeDebug, }; +use sp_std::{ + fmt, marker, + prelude::{Clone, Eq, PartialEq, Vec}, + result, +}; pub use sp_weights::Weight; /// The return type of a `Dispatchable` in frame. When returned explicitly from diff --git a/frame/support/src/hash.rs b/frame/support/src/hash.rs index 115ce605d542e..d419890e87a6c 100644 --- a/frame/support/src/hash.rs +++ b/frame/support/src/hash.rs @@ -17,8 +17,8 @@ //! Hash utilities. -use crate::metadata_ir; use codec::{Codec, MaxEncodedLen}; +use sp_api::metadata_ir; use sp_io::hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64}; use sp_std::prelude::Vec; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index d37490c341724..988073f76a9aa 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -33,37 +33,26 @@ extern crate self as frame_support; #[doc(hidden)] -pub use sp_tracing; - -#[doc(hidden)] -pub use codec; -#[doc(hidden)] -pub use frame_metadata as metadata; -#[doc(hidden)] -pub use log; -#[doc(hidden)] -pub use paste; -#[doc(hidden)] -pub use scale_info; -pub use serde; -pub use sp_api::metadata_ir; -pub use sp_core::{OpaqueMetadata, Void}; -#[doc(hidden)] -pub use sp_core_hashing_proc_macro; -#[doc(hidden)] -pub use sp_io::{self, storage::root as storage_root}; -#[cfg(feature = "std")] -#[doc(hidden)] -pub use sp_runtime::{bounded_btree_map, bounded_vec}; -#[doc(hidden)] -pub use sp_runtime::{RuntimeDebug, StateVersion}; -#[cfg(feature = "std")] -#[doc(hidden)] -pub use sp_state_machine::BasicExternalities; -#[doc(hidden)] -pub use sp_std; -#[doc(hidden)] -pub use tt_call::*; +pub mod __private { + pub use codec; + pub use frame_metadata as metadata; + pub use log; + pub use paste; + pub use scale_info; + pub use serde; + pub use sp_api::metadata_ir; + pub use sp_core::{OpaqueMetadata, Void}; + pub use sp_core_hashing_proc_macro; + pub use sp_io::{self, storage::root as storage_root}; + #[cfg(feature = "std")] + pub use sp_runtime::{bounded_btree_map, bounded_vec}; + pub use sp_runtime::{RuntimeDebug, StateVersion}; + #[cfg(feature = "std")] + pub use sp_state_machine::BasicExternalities; + pub use sp_std; + pub use sp_tracing; + pub use tt_call::*; +} #[macro_use] pub mod dispatch; @@ -283,7 +272,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL_CONST $name , $type , $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -295,7 +284,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL $name, $type, $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -307,7 +296,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL_STORAGE $name, $type, $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -490,7 +479,7 @@ macro_rules! ord_parameter_types { (IMPL $name:ident , $type:ty , $value:expr) => { impl $crate::traits::SortedMembers<$type> for $name { fn contains(t: &$type) -> bool { &$value == t } - fn sorted_members() -> $crate::sp_std::prelude::Vec<$type> { vec![$value] } + fn sorted_members() -> $crate::__private::sp_std::prelude::Vec<$type> { vec![$value] } fn count() -> usize { 1 } #[cfg(feature = "runtime-benchmarks")] fn add(_: &$type) {} @@ -513,9 +502,9 @@ macro_rules! runtime_print { ($($arg:tt)+) => { { use core::fmt::Write; - let mut w = $crate::sp_std::Writer::default(); + let mut w = $crate::__private::sp_std::Writer::default(); let _ = core::write!(&mut w, $($arg)+); - $crate::sp_io::misc::print_utf8(&w.inner()) + $crate::__private::sp_io::misc::print_utf8(&w.inner()) } } } @@ -1526,10 +1515,10 @@ pub mod _private { pub mod testing_prelude { pub use super::{ assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_error_encoded_size, - assert_noop, assert_ok, assert_storage_noop, bounded_btree_map, bounded_vec, - parameter_types, traits::Get, + assert_noop, assert_ok, assert_storage_noop, parameter_types, traits::Get, }; pub use sp_arithmetic::assert_eq_error_rate; + pub use sp_runtime::{bounded_btree_map, bounded_vec}; } /// Prelude to be used alongside pallet macro, for ease of use. @@ -1555,7 +1544,7 @@ pub mod pallet_prelude { IsType, PalletInfoAccess, StorageInfoTrait, StorageVersion, TypedGet, }, Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity, - PartialEqNoBound, RuntimeDebug, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat, + PartialEqNoBound, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat, }; pub use codec::{Decode, Encode, MaxEncodedLen}; pub use frame_support::pallet_macros::*; @@ -1569,7 +1558,7 @@ pub mod pallet_prelude { TransactionTag, TransactionValidity, TransactionValidityError, UnknownTransaction, ValidTransaction, }, - MAX_MODULE_ERROR_ENCODED_SIZE, + RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE, }; pub use sp_std::marker::PhantomData; pub use sp_weights::Weight; diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index 76b9c554d65f9..499c32c5b2a5a 100644 --- a/frame/support/src/storage/child.rs +++ b/frame/support/src/storage/child.rs @@ -21,10 +21,10 @@ // NOTE: could replace unhashed by having only one kind of storage (top trie being the child info // of null length parent storage key). -pub use crate::sp_io::{KillStorageResult, MultiRemovalResults}; -use crate::sp_std::prelude::*; use codec::{Codec, Decode, Encode}; pub use sp_core::storage::{ChildInfo, ChildType, StateVersion}; +use sp_io::{KillStorageResult, MultiRemovalResults}; +use sp_std::prelude::*; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(child_info: &ChildInfo, key: &[u8]) -> Option { diff --git a/frame/support/src/storage/storage_noop_guard.rs b/frame/support/src/storage/storage_noop_guard.rs index f2fb60027ec37..d00e6e18ecc48 100644 --- a/frame/support/src/storage/storage_noop_guard.rs +++ b/frame/support/src/storage/storage_noop_guard.rs @@ -41,7 +41,7 @@ pub struct StorageNoopGuard(sp_std::vec::Vec); impl Default for StorageNoopGuard { fn default() -> Self { - Self(frame_support::storage_root(frame_support::StateVersion::V1)) + Self(sp_io::storage::root(sp_runtime::StateVersion::V1)) } } @@ -52,7 +52,7 @@ impl Drop for StorageNoopGuard { return } assert_eq!( - frame_support::storage_root(frame_support::StateVersion::V1), + sp_io::storage::root(sp_runtime::StateVersion::V1), self.0, "StorageNoopGuard detected wrongful storage changes.", ); diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index 081f99fa16b0b..8b867a14f453a 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -18,7 +18,6 @@ //! Storage counted map type. use crate::{ - metadata_ir::StorageEntryMetadataIR, storage::{ generator::StorageMap as _, types::{ @@ -31,6 +30,7 @@ use crate::{ Never, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref}; +use sp_api::metadata_ir::StorageEntryMetadataIR; use sp_io::MultiRemovalResults; use sp_runtime::traits::Saturating; use sp_std::prelude::*; diff --git a/frame/support/src/storage/types/double_map.rs b/frame/support/src/storage/types/double_map.rs index 08ac1709c4b68..b2c956d4e823c 100644 --- a/frame/support/src/storage/types/double_map.rs +++ b/frame/support/src/storage/types/double_map.rs @@ -19,7 +19,6 @@ //! StoragePrefixedDoubleMap traits and their methods directly. use crate::{ - metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend, @@ -28,6 +27,7 @@ use crate::{ StorageHasher, Twox128, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; use sp_std::prelude::*; diff --git a/frame/support/src/storage/types/key.rs b/frame/support/src/storage/types/key.rs index ec055aba803ec..dd528b7f8bb5c 100755 --- a/frame/support/src/storage/types/key.rs +++ b/frame/support/src/storage/types/key.rs @@ -41,7 +41,7 @@ pub trait KeyGenerator { type HashFn: FnOnce(&[u8]) -> Vec; type HArg; - const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR]; + const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR]; /// Given a `key` tuple, calculate the final key by encoding each element individually and /// hashing them using the corresponding hasher in the `KeyGenerator`. @@ -74,7 +74,7 @@ impl KeyGenerator for Key type HashFn = Box Vec>; type HArg = (Self::HashFn,); - const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = &[H::METADATA]; + const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR] = &[H::METADATA]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { H::hash(&key.to_encoded_iter().next().expect("should have at least one element!")) @@ -114,7 +114,7 @@ impl KeyGenerator for Tuple { for_tuples!( type HArg = ( #(Tuple::HashFn),* ); ); type HashFn = Box Vec>; - const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = + const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR] = &[for_tuples!( #(Tuple::Hasher::METADATA),* )]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { diff --git a/frame/support/src/storage/types/map.rs b/frame/support/src/storage/types/map.rs index c919dc6745d78..4b41db79fad77 100644 --- a/frame/support/src/storage/types/map.rs +++ b/frame/support/src/storage/types/map.rs @@ -19,7 +19,6 @@ //! methods directly. use crate::{ - metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend, @@ -28,6 +27,7 @@ use crate::{ StorageHasher, Twox128, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; use sp_std::prelude::*; diff --git a/frame/support/src/storage/types/mod.rs b/frame/support/src/storage/types/mod.rs index 99b0455fc6748..c390d262288e3 100644 --- a/frame/support/src/storage/types/mod.rs +++ b/frame/support/src/storage/types/mod.rs @@ -18,8 +18,8 @@ //! Storage types to build abstraction on storage, they implements storage traits such as //! StorageMap and others. -use crate::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; use codec::FullCodec; +use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; use sp_std::prelude::*; mod counted_map; diff --git a/frame/support/src/storage/types/nmap.rs b/frame/support/src/storage/types/nmap.rs index 0fac1fc933706..3ae7dad83ee82 100755 --- a/frame/support/src/storage/types/nmap.rs +++ b/frame/support/src/storage/types/nmap.rs @@ -19,7 +19,6 @@ //! traits and their methods directly. use crate::{ - metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ types::{ EncodeLikeTuple, HasKeyPrefix, HasReversibleKeyPrefix, OptionQuery, QueryKindTrait, @@ -30,6 +29,7 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInstance}, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_runtime::SaturatedConversion; use sp_std::prelude::*; diff --git a/frame/support/src/storage/types/value.rs b/frame/support/src/storage/types/value.rs index d5fbb0656bbd1..171b2c8a567fd 100644 --- a/frame/support/src/storage/types/value.rs +++ b/frame/support/src/storage/types/value.rs @@ -18,7 +18,6 @@ //! Storage value type. Implements StorageValue trait and its method directly. use crate::{ - metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}, storage::{ generator::StorageValue as StorageValueT, types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder}, @@ -27,6 +26,7 @@ use crate::{ traits::{GetDefault, StorageInfo, StorageInstance}, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; use sp_std::prelude::*; diff --git a/frame/support/src/traits/misc.rs b/frame/support/src/traits/misc.rs index 85eb7b47e26da..eb704de4353c7 100644 --- a/frame/support/src/traits/misc.rs +++ b/frame/support/src/traits/misc.rs @@ -42,7 +42,7 @@ pub const DEFENSIVE_OP_INTERNAL_ERROR: &str = "Defensive failure has been trigge #[macro_export] macro_rules! defensive { () => { - frame_support::log::error!( + frame_support::__private::log::error!( target: "runtime", "{}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR @@ -50,7 +50,7 @@ macro_rules! defensive { debug_assert!(false, "{}", $crate::traits::DEFENSIVE_OP_INTERNAL_ERROR); }; ($error:expr $(,)?) => { - frame_support::log::error!( + frame_support::__private::log::error!( target: "runtime", "{}: {:?}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR, @@ -59,7 +59,7 @@ macro_rules! defensive { debug_assert!(false, "{}: {:?}", $crate::traits::DEFENSIVE_OP_INTERNAL_ERROR, $error); }; ($error:expr, $proof:expr $(,)?) => { - frame_support::log::error!( + frame_support::__private::log::error!( target: "runtime", "{}: {:?}: {:?}", $crate::traits::DEFENSIVE_OP_PUBLIC_ERROR, diff --git a/frame/support/src/traits/storage.rs b/frame/support/src/traits/storage.rs index 829cd31e4c370..64eddf51b7fab 100644 --- a/frame/support/src/traits/storage.rs +++ b/frame/support/src/traits/storage.rs @@ -17,11 +17,10 @@ //! Traits for encoding data related to pallet's storage items. -use crate::sp_std::collections::btree_set::BTreeSet; use impl_trait_for_tuples::impl_for_tuples; pub use sp_core::storage::TrackedStorageKey; -use sp_runtime::traits::Saturating; -use sp_std::prelude::*; +use sp_runtime::{traits::Saturating, RuntimeDebug}; +use sp_std::{collections::btree_set::BTreeSet, prelude::*}; /// An instance of a pallet in the storage. /// @@ -61,7 +60,7 @@ pub trait StorageInstance { /// Metadata about storage from the runtime. #[derive( - codec::Encode, codec::Decode, crate::RuntimeDebug, Eq, PartialEq, Clone, scale_info::TypeInfo, + codec::Encode, codec::Decode, RuntimeDebug, Eq, PartialEq, Clone, scale_info::TypeInfo, )] pub struct StorageInfo { /// Encoded string of pallet name. diff --git a/frame/support/src/traits/validation.rs b/frame/support/src/traits/validation.rs index 84430901b9783..617cdb2d3f461 100644 --- a/frame/support/src/traits/validation.rs +++ b/frame/support/src/traits/validation.rs @@ -210,8 +210,8 @@ pub trait KeyOwnerProofSystem { impl KeyOwnerProofSystem for () { // The proof and identification tuples is any bottom type to guarantee that the methods of this // implementation can never be called or return anything other than `None`. - type Proof = crate::Void; - type IdentificationTuple = crate::Void; + type Proof = sp_core::Void; + type IdentificationTuple = sp_core::Void; fn prove(_key: Key) -> Option { None diff --git a/frame/system/src/migrations/mod.rs b/frame/system/src/migrations/mod.rs index 6f873061dbab9..945bbc5395525 100644 --- a/frame/system/src/migrations/mod.rs +++ b/frame/system/src/migrations/mod.rs @@ -22,8 +22,8 @@ use crate::{Config, Pallet}; use codec::{Decode, Encode, FullCodec}; use frame_support::{ pallet_prelude::ValueQuery, traits::PalletInfoAccess, weights::Weight, Blake2_128Concat, - RuntimeDebug, }; +use sp_runtime::RuntimeDebug; use sp_std::prelude::*; /// Type used to encode the number of references an account has. diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 313a557c44d76..dd4ac6782a55e 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -57,10 +57,10 @@ #![warn(missing_docs)] use codec::Encode; -use frame_support::RuntimeDebug; use sp_runtime::{ app_crypto::RuntimeAppPublic, traits::{Extrinsic as ExtrinsicT, IdentifyAccount, One}, + RuntimeDebug, }; use sp_std::{collections::btree_set::BTreeSet, prelude::*}; From dccfaebf673deb3cd69603bc6cdf9420aa3fd36e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 12:27:51 +0200 Subject: [PATCH 02/42] make reexports private 2 --- Cargo.lock | 2 + bin/node/runtime/src/lib.rs | 3 +- frame/alliance/src/lib.rs | 4 +- frame/assets/Cargo.toml | 2 + frame/assets/src/migration.rs | 3 +- frame/balances/src/types.rs | 7 +-- frame/collective/src/lib.rs | 2 +- frame/contracts/src/migration.rs | 1 - frame/contracts/src/migration/v09.rs | 2 +- frame/contracts/src/migration/v10.rs | 1 - frame/contracts/src/migration/v11.rs | 2 +- frame/contracts/src/migration/v12.rs | 2 +- frame/contracts/src/migration/v13.rs | 2 +- frame/contracts/src/migration/v14.rs | 1 - frame/contracts/src/wasm/runtime.rs | 7 ++- frame/core-fellowship/src/lib.rs | 3 +- frame/election-provider-support/src/lib.rs | 7 ++- frame/elections-phragmen/src/lib.rs | 3 +- frame/elections-phragmen/src/migrations/v3.rs | 3 +- frame/lottery/src/lib.rs | 4 +- frame/merkle-mountain-range/Cargo.toml | 2 + frame/merkle-mountain-range/src/lib.rs | 3 +- .../merkle-mountain-range/src/mmr/storage.rs | 2 +- frame/multisig/src/lib.rs | 4 +- frame/nfts/src/migration.rs | 3 +- frame/proxy/src/lib.rs | 3 +- frame/ranked-collective/src/lib.rs | 2 +- frame/recovery/src/lib.rs | 7 ++- frame/salary/src/lib.rs | 3 +- frame/session/src/lib.rs | 2 +- frame/support/procedural/src/benchmark.rs | 6 +-- .../src/construct_runtime/expand/call.rs | 10 ++-- .../src/construct_runtime/expand/config.rs | 6 +-- .../construct_runtime/expand/freeze_reason.rs | 6 +-- .../construct_runtime/expand/hold_reason.rs | 6 +-- .../src/construct_runtime/expand/inherent.rs | 8 +-- .../src/construct_runtime/expand/lock_id.rs | 6 +-- .../src/construct_runtime/expand/metadata.rs | 50 +++++++++---------- .../src/construct_runtime/expand/origin.rs | 38 +++++++------- .../construct_runtime/expand/outer_enums.rs | 14 +++--- .../construct_runtime/expand/slash_reason.rs | 6 +-- .../procedural/src/construct_runtime/mod.rs | 30 +++++------ .../procedural/src/pallet/expand/error.rs | 4 +- .../src/pallet/expand/genesis_build.rs | 2 +- .../src/pallet/expand/genesis_config.rs | 2 +- .../procedural/src/pallet/expand/hooks.rs | 2 +- .../src/pallet/expand/tt_default_parts.rs | 4 +- .../procedural/src/pallet/parse/composite.rs | 6 +-- frame/support/procedural/src/pallet_error.rs | 2 +- frame/support/procedural/src/storage_alias.rs | 4 +- frame/support/procedural/src/tt_macro.rs | 10 ++-- frame/support/src/dispatch.rs | 19 +++---- 52 files changed, 174 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52b47621e5e69..363eb08cf5395 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5668,6 +5668,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "pallet-balances", "parity-scale-codec", "scale-info", @@ -6452,6 +6453,7 @@ dependencies = [ "frame-support", "frame-system", "itertools", + "log", "parity-scale-codec", "scale-info", "sp-core", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 29aaaf5fdad5a..499b6b794d3bb 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -46,7 +46,7 @@ use frame_support::{ }, ConstantMultiplier, IdentityFee, Weight, }, - BoundedVec, PalletId, RuntimeDebug, + BoundedVec, PalletId, }; use frame_system::{ limits::{BlockLength, BlockWeights}, @@ -77,6 +77,7 @@ use sp_runtime::{ }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Percent, Permill, Perquintill, + RuntimeDebug, }; use sp_std::prelude::*; #[cfg(any(feature = "std", test))] diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index c103f975f23be..1986354a0941c 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -94,6 +94,7 @@ pub mod migration; mod types; pub mod weights; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::{ @@ -103,13 +104,11 @@ use sp_runtime::{ use sp_std::{convert::TryInto, prelude::*}; use frame_support::{ - codec::{Decode, Encode, MaxEncodedLen}, dispatch::{ DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, PostDispatchInfo, }, ensure, - scale_info::TypeInfo, traits::{ ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced, ReservableCurrency, @@ -117,6 +116,7 @@ use frame_support::{ weights::Weight, }; use pallet_identity::IdentityField; +use scale_info::TypeInfo; pub use pallet::*; pub use types::*; diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 4bef7195958f9..adf78b118a084 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } +log = { version = "0.4.17", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } # Needed for various traits. In our case, `OnFinalize`. @@ -34,6 +35,7 @@ pallet-balances = { version = "4.0.0-dev", path = "../balances" } default = ["std"] std = [ "codec/std", + "log/std", "scale-info/std", "sp-core/std", "sp-std/std", diff --git a/frame/assets/src/migration.rs b/frame/assets/src/migration.rs index d854a64afb57f..efe77714c524d 100644 --- a/frame/assets/src/migration.rs +++ b/frame/assets/src/migration.rs @@ -16,7 +16,8 @@ // limitations under the License. use super::*; -use frame_support::{log, traits::OnRuntimeUpgrade}; +use frame_support::traits::OnRuntimeUpgrade; +use log; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; diff --git a/frame/balances/src/types.rs b/frame/balances/src/types.rs index 389124402a8f1..cd100d0df6c6d 100644 --- a/frame/balances/src/types.rs +++ b/frame/balances/src/types.rs @@ -20,12 +20,9 @@ use crate::{Config, CreditOf, Event, Pallet}; use codec::{Decode, Encode, MaxEncodedLen}; use core::ops::BitOr; -use frame_support::{ - traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons}, - RuntimeDebug, -}; +use frame_support::traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons}; use scale_info::TypeInfo; -use sp_runtime::Saturating; +use sp_runtime::{RuntimeDebug, Saturating}; /// Simplified reasons for withdrawing balance. #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 1084091173934..ac6ad39eac5a4 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -42,13 +42,13 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_io::storage; use sp_runtime::{traits::Hash, RuntimeDebug}; use sp_std::{marker::PhantomData, prelude::*, result}; use frame_support::{ - codec::{Decode, Encode, MaxEncodedLen}, dispatch::{ DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo, diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 106b68dc4416e..79d1c64cf7863 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -68,7 +68,6 @@ include!(concat!(env!("OUT_DIR"), "/migration_codegen.rs")); use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; use codec::{Codec, Decode}; use frame_support::{ - codec, pallet_prelude::*, traits::{ConstU32, OnRuntimeUpgrade}, }; diff --git a/frame/contracts/src/migration/v09.rs b/frame/contracts/src/migration/v09.rs index e6c6642955642..98fcccc2c0bec 100644 --- a/frame/contracts/src/migration/v09.rs +++ b/frame/contracts/src/migration/v09.rs @@ -23,7 +23,7 @@ use crate::{ CodeHash, Config, Determinism, Pallet, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; -use frame_support::{codec, pallet_prelude::*, storage_alias, DefaultNoBound, Identity}; +use frame_support::{pallet_prelude::*, storage_alias, DefaultNoBound, Identity}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_std::prelude::*; diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 3fc7cabe94942..d91c229d6dd48 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -28,7 +28,6 @@ use crate::{ use codec::{Decode, Encode}; use core::cmp::{max, min}; use frame_support::{ - codec, pallet_prelude::*, storage_alias, traits::{ diff --git a/frame/contracts/src/migration/v11.rs b/frame/contracts/src/migration/v11.rs index 8123d73aee560..a5b11f6e08977 100644 --- a/frame/contracts/src/migration/v11.rs +++ b/frame/contracts/src/migration/v11.rs @@ -27,7 +27,7 @@ use crate::{ use sp_runtime::TryRuntimeError; use codec::{Decode, Encode}; -use frame_support::{codec, pallet_prelude::*, storage_alias, DefaultNoBound}; +use frame_support::{pallet_prelude::*, storage_alias, DefaultNoBound}; use sp_std::{marker::PhantomData, prelude::*}; mod old { use super::*; diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index 75018f943d100..eb045aa42e9d7 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -25,7 +25,7 @@ use crate::{ }; use codec::{Decode, Encode}; use frame_support::{ - codec, pallet_prelude::*, storage_alias, traits::ReservableCurrency, DefaultNoBound, Identity, + pallet_prelude::*, storage_alias, traits::ReservableCurrency, DefaultNoBound, Identity, }; use scale_info::prelude::format; use sp_core::hexdisplay::HexDisplay; diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index ade837f46e9b1..f90f1f97e59a3 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -25,7 +25,7 @@ use crate::{ BalanceOf, CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; -use frame_support::{codec, pallet_prelude::*, storage_alias, DefaultNoBound}; +use frame_support::{pallet_prelude::*, storage_alias, DefaultNoBound}; use sp_runtime::BoundedBTreeMap; use sp_std::prelude::*; diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index ebf97af562ed4..642299c6dbc51 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -29,7 +29,6 @@ use environmental::Vec; #[cfg(feature = "try-runtime")] use frame_support::traits::fungible::{Inspect, InspectHold}; use frame_support::{ - codec, pallet_prelude::*, storage_alias, traits::{fungible::MutateHold, ReservableCurrency}, diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 9d29da70a87d9..ca23ab9fe5dd0 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -26,11 +26,14 @@ use crate::{ use bitflags::bitflags; use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen}; -use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weight, RuntimeDebug}; +use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weight}; use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pallet_contracts_proc_macro::define_env; use sp_io::hashing::{blake2_128, blake2_256, keccak_256, sha2_256}; -use sp_runtime::traits::{Bounded, Zero}; +use sp_runtime::{ + traits::{Bounded, Zero}, + RuntimeDebug, +}; use sp_std::{fmt, prelude::*}; use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index 8f3d9633fcf22..5eb7bf8caba0e 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -61,6 +61,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_arithmetic::traits::{Saturating, Zero}; +use sp_runtime::RuntimeDebug; use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ @@ -69,7 +70,7 @@ use frame_support::{ traits::{ tokens::Balance as BalanceTrait, EnsureOrigin, EnsureOriginWithArg, Get, RankedMembers, }, - BoundedVec, RuntimeDebug, + BoundedVec, }; #[cfg(test)] diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 978a5df427244..991d575d61eec 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -175,12 +175,15 @@ pub mod onchain; pub mod traits; -use sp_runtime::traits::{Bounded, Saturating, Zero}; +use sp_runtime::{ + traits::{Bounded, Saturating, Zero}, + RuntimeDebug, +}; use sp_std::{fmt::Debug, prelude::*}; /// Re-export the solution generation macro. pub use frame_election_provider_solution_type::generate_solution_type; -pub use frame_support::{traits::Get, weights::Weight, BoundedVec, RuntimeDebug}; +pub use frame_support::{traits::Get, weights::Weight, BoundedVec}; /// Re-export some type as they are used in the interface. pub use sp_arithmetic::PerThing; pub use sp_npos_elections::{ diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index b23ddda4e8d1c..6912649bd122d 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -107,6 +107,7 @@ use frame_support::{ }, weights::Weight, }; +use log; use scale_info::TypeInfo; use sp_npos_elections::{ElectionResult, ExtendedBalance}; use sp_runtime::{ @@ -309,7 +310,7 @@ pub mod pallet { frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND as f32 }; - frame_support::log::debug!( + log::debug!( target: LOG_TARGET, "election weight {}s ({:?}) // chain's block weight {}s ({:?})", to_seconds(&election_weight), diff --git a/frame/elections-phragmen/src/migrations/v3.rs b/frame/elections-phragmen/src/migrations/v3.rs index 204614a5b46cb..cdca1138ebbd2 100644 --- a/frame/elections-phragmen/src/migrations/v3.rs +++ b/frame/elections-phragmen/src/migrations/v3.rs @@ -21,8 +21,9 @@ use super::super::LOG_TARGET; use crate::{Config, Pallet}; use codec::{Decode, Encode, FullCodec}; use frame_support::{ - pallet_prelude::ValueQuery, traits::StorageVersion, weights::Weight, RuntimeDebug, Twox64Concat, + pallet_prelude::ValueQuery, traits::StorageVersion, weights::Weight, Twox64Concat, }; +use sp_runtime::RuntimeDebug; use sp_std::prelude::*; #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index a6a94b4ab19af..c9c0254042424 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -61,12 +61,12 @@ use frame_support::{ pallet_prelude::MaxEncodedLen, storage::bounded_vec::BoundedVec, traits::{Currency, ExistenceRequirement::KeepAlive, Get, Randomness, ReservableCurrency}, - PalletId, RuntimeDebug, + PalletId, }; pub use pallet::*; use sp_runtime::{ traits::{AccountIdConversion, Saturating, Zero}, - ArithmeticError, DispatchError, + ArithmeticError, DispatchError, RuntimeDebug, }; use sp_std::prelude::*; pub use weights::WeightInfo; diff --git a/frame/merkle-mountain-range/Cargo.toml b/frame/merkle-mountain-range/Cargo.toml index 1d7739eb93c2c..82a24904cc92d 100644 --- a/frame/merkle-mountain-range/Cargo.toml +++ b/frame/merkle-mountain-range/Cargo.toml @@ -13,6 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } +log = { version = "0.4.17", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } @@ -32,6 +33,7 @@ itertools = "0.10.3" default = ["std"] std = [ "codec/std", + "log/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 2edef9a35d57a..664f4bc73901b 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -56,8 +56,9 @@ //! NOTE This pallet is experimental and not proven to work in production. #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{log, weights::Weight}; +use frame_support::weights::Weight; use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; +use log; use sp_mmr_primitives::utils; use sp_runtime::{ traits::{self, One, Saturating}, diff --git a/frame/merkle-mountain-range/src/mmr/storage.rs b/frame/merkle-mountain-range/src/mmr/storage.rs index d7466784e4ab8..03039be83ac1a 100644 --- a/frame/merkle-mountain-range/src/mmr/storage.rs +++ b/frame/merkle-mountain-range/src/mmr/storage.rs @@ -18,7 +18,7 @@ //! An MMR storage implementation. use codec::Encode; -use frame_support::log::{debug, trace}; +use log::{debug, trace}; use sp_core::offchain::StorageKind; use sp_io::offchain_index; use sp_mmr_primitives::{mmr_lib, mmr_lib::helper, utils::NodesUtils}; diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index ab117315f8985..e4426c64b4125 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -57,14 +57,14 @@ use frame_support::{ ensure, traits::{Currency, Get, ReservableCurrency}, weights::Weight, - BoundedVec, RuntimeDebug, + BoundedVec, }; use frame_system::{self as system, pallet_prelude::BlockNumberFor, RawOrigin}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{Dispatchable, TrailingZeroInput, Zero}, - DispatchError, + DispatchError, RuntimeDebug, }; use sp_std::prelude::*; pub use weights::WeightInfo; diff --git a/frame/nfts/src/migration.rs b/frame/nfts/src/migration.rs index ba14492be84ca..d210679b6d54b 100644 --- a/frame/nfts/src/migration.rs +++ b/frame/nfts/src/migration.rs @@ -16,7 +16,8 @@ // limitations under the License. use super::*; -use frame_support::{log, traits::OnRuntimeUpgrade}; +use frame_support::traits::OnRuntimeUpgrade; +use log; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 33e9fcfade35a..586d52fb62bdd 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -38,7 +38,6 @@ use frame_support::{ dispatch::{DispatchError, GetDispatchInfo}, ensure, traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency}, - RuntimeDebug, }; use frame_system::{self as system, ensure_signed, pallet_prelude::BlockNumberFor}; pub use pallet::*; @@ -46,7 +45,7 @@ use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{Dispatchable, Hash, Saturating, StaticLookup, TrailingZeroInput, Zero}, - DispatchResult, + DispatchResult, RuntimeDebug, }; use sp_std::prelude::*; pub use weights::WeightInfo; diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index fe1308cd034f4..d94932a1dac71 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -41,6 +41,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_arithmetic::traits::Saturating; use sp_runtime::{ @@ -51,7 +52,6 @@ use sp_runtime::{ use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ - codec::{Decode, Encode, MaxEncodedLen}, dispatch::{DispatchError, DispatchResultWithPostInfo, PostDispatchInfo}, ensure, impl_ensure_origin_with_arg_ignoring_arg, traits::{EnsureOrigin, EnsureOriginWithArg, PollStatus, Polling, RankedMembers, VoteTally}, diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 9c01d25d4f76b..5673147c8e005 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -152,13 +152,16 @@ use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversion, StaticLookup}; +use sp_runtime::{ + traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversion, StaticLookup}, + RuntimeDebug, +}; use sp_std::prelude::*; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, traits::{BalanceStatus, Currency, ReservableCurrency}, - BoundedVec, RuntimeDebug, + BoundedVec, }; pub use pallet::*; diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 53dd7224909a8..75d6fdd329ac8 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -23,7 +23,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_arithmetic::traits::{Saturating, Zero}; -use sp_runtime::Perbill; +use sp_runtime::{Perbill, RuntimeDebug}; use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ @@ -33,7 +33,6 @@ use frame_support::{ tokens::{GetSalary, Pay, PaymentStatus}, RankedMembers, }, - RuntimeDebug, }; #[cfg(test)] diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index d2b1c2b744674..1c0093c1df64f 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -115,8 +115,8 @@ mod mock; mod tests; pub mod weights; +use codec::{Decode, MaxEncodedLen}; use frame_support::{ - codec::{Decode, MaxEncodedLen}, dispatch::{DispatchError, DispatchResult}, ensure, traits::{ diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 5a5bafa0929c6..57a8e5a5a6d57 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -590,7 +590,7 @@ pub fn benchmarks( #krate::benchmarking::reset_read_write_count(); // Time the extrinsic logic. - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "Start Benchmark: {} ({:?})", extrinsic, @@ -614,12 +614,12 @@ pub fn benchmarks( // Commit the changes to get proper write count #krate::benchmarking::commit_db(); - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic ); let read_write_count = #krate::benchmarking::read_write_count(); - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "Read/Write Count {:?}", read_write_count ); diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index 5ec665682ddaa..d58064bf4d427 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -68,10 +68,10 @@ pub fn expand_outer_dispatch( #[derive( Clone, PartialEq, Eq, - #scrate::codec::Encode, - #scrate::codec::Decode, - #scrate::scale_info::TypeInfo, - #scrate::RuntimeDebug, + #scrate::__private::codec::Encode, + #scrate::__private::codec::Decode, + #scrate::__private::scale_info::TypeInfo, + #scrate::__private::RuntimeDebug, )] pub enum RuntimeCall { #variant_defs @@ -168,7 +168,7 @@ pub fn expand_outer_dispatch( type PostInfo = #scrate::dispatch::PostDispatchInfo; fn dispatch(self, origin: RuntimeOrigin) -> #scrate::dispatch::DispatchResultWithPostInfo { if !::filter_call(&origin, &self) { - return #scrate::sp_std::result::Result::Err( + return #scrate::__private::sp_std::result::Result::Err( #system_path::Error::<#runtime>::CallFiltered.into() ); } diff --git a/frame/support/procedural/src/construct_runtime/expand/config.rs b/frame/support/procedural/src/construct_runtime/expand/config.rs index 440e856221a36..ffe55bceb80ef 100644 --- a/frame/support/procedural/src/construct_runtime/expand/config.rs +++ b/frame/support/procedural/src/construct_runtime/expand/config.rs @@ -67,8 +67,8 @@ pub fn expand_outer_config( #types - use #scrate::serde as __genesis_config_serde_import__; - #[derive(#scrate::serde::Serialize, #scrate::serde::Deserialize, Default)] + use #scrate::__private::serde as __genesis_config_serde_import__; + #[derive(#scrate::__private::serde::Serialize, #scrate::__private::serde::Deserialize, Default)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] #[serde(crate = "__genesis_config_serde_import__")] @@ -86,7 +86,7 @@ pub fn expand_outer_config( &self, storage: &mut #scrate::sp_runtime::Storage, ) -> std::result::Result<(), String> { - #scrate::BasicExternalities::execute_with_storage(storage, || { + #scrate::__private::BasicExternalities::execute_with_storage(storage, || { ::build(&self); Ok(()) }) diff --git a/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs b/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs index d357fab72115b..b142f8e84c92f 100644 --- a/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs +++ b/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs @@ -38,9 +38,9 @@ pub fn expand_outer_freeze_reason(pallet_decls: &[Pallet], scrate: &TokenStream) /// A reason for placing a freeze on funds. #[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, )] pub enum RuntimeFreezeReason { #( #freeze_reason_variants )* diff --git a/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs b/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs index 6acfe5382f18a..ed7183c4a150d 100644 --- a/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs +++ b/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs @@ -38,9 +38,9 @@ pub fn expand_outer_hold_reason(pallet_decls: &[Pallet], scrate: &TokenStream) - /// A reason for placing a hold on funds. #[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, )] pub enum RuntimeHoldReason { #( #hold_reason_variants )* diff --git a/frame/support/procedural/src/construct_runtime/expand/inherent.rs b/frame/support/procedural/src/construct_runtime/expand/inherent.rs index 1dc51d9cd2bc4..a77aad66dcfc2 100644 --- a/frame/support/procedural/src/construct_runtime/expand/inherent.rs +++ b/frame/support/procedural/src/construct_runtime/expand/inherent.rs @@ -58,17 +58,17 @@ pub fn expand_outer_inherent( trait InherentDataExt { fn create_extrinsics(&self) -> - #scrate::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>; + #scrate::__private::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>; fn check_extrinsics(&self, block: &#block) -> #scrate::inherent::CheckInherentsResult; } impl InherentDataExt for #scrate::inherent::InherentData { fn create_extrinsics(&self) -> - #scrate::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic> + #scrate::__private::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic> { use #scrate::inherent::ProvideInherent; - let mut inherents = #scrate::sp_std::vec::Vec::new(); + let mut inherents = #scrate::__private::sp_std::vec::Vec::new(); #( #pallet_attrs @@ -91,7 +91,7 @@ pub fn expand_outer_inherent( use #scrate::traits::{IsSubType, ExtrinsicCall}; use #scrate::sp_runtime::traits::Block as _; use #scrate::_private::sp_inherents::Error; - use #scrate::log; + use #scrate::__private::log; let mut result = #scrate::inherent::CheckInherentsResult::new(); diff --git a/frame/support/procedural/src/construct_runtime/expand/lock_id.rs b/frame/support/procedural/src/construct_runtime/expand/lock_id.rs index d7031dcaf552b..ba35147a051fb 100644 --- a/frame/support/procedural/src/construct_runtime/expand/lock_id.rs +++ b/frame/support/procedural/src/construct_runtime/expand/lock_id.rs @@ -38,9 +38,9 @@ pub fn expand_outer_lock_id(pallet_decls: &[Pallet], scrate: &TokenStream) -> To /// An identifier for each lock placed on funds. #[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, )] pub enum RuntimeLockId { #( #lock_id_variants )* diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index 0975fedb35d5b..0e76f9a92469a 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -61,7 +61,7 @@ pub fn expand_runtime_metadata( quote! { #attr - #scrate::metadata_ir::PalletMetadataIR { + #scrate::__private::metadata_ir::PalletMetadataIR { name: stringify!(#name), index: #index, storage: #storage, @@ -77,7 +77,7 @@ pub fn expand_runtime_metadata( quote! { impl #runtime { - fn metadata_ir() -> #scrate::metadata_ir::MetadataIR { + fn metadata_ir() -> #scrate::__private::metadata_ir::MetadataIR { // Each runtime must expose the `runtime_metadata()` to fetch the runtime API metadata. // The function is implemented by calling `impl_runtime_apis!`. // @@ -96,23 +96,23 @@ pub fn expand_runtime_metadata( // `Deref` needs a reference for resolving the function call. let rt = #runtime; - let ty = #scrate::scale_info::meta_type::<#extrinsic>(); - let address_ty = #scrate::scale_info::meta_type::< + let ty = #scrate::__private::scale_info::meta_type::<#extrinsic>(); + let address_ty = #scrate::__private::scale_info::meta_type::< <<#extrinsic as #scrate::sp_runtime::traits::Extrinsic>::SignaturePayload as #scrate::sp_runtime::traits::SignaturePayload>::SignatureAddress >(); - let call_ty = #scrate::scale_info::meta_type::< + let call_ty = #scrate::__private::scale_info::meta_type::< <#extrinsic as #scrate::sp_runtime::traits::Extrinsic>::Call >(); - let signature_ty = #scrate::scale_info::meta_type::< + let signature_ty = #scrate::__private::scale_info::meta_type::< <<#extrinsic as #scrate::sp_runtime::traits::Extrinsic>::SignaturePayload as #scrate::sp_runtime::traits::SignaturePayload>::Signature >(); - let extra_ty = #scrate::scale_info::meta_type::< + let extra_ty = #scrate::__private::scale_info::meta_type::< <<#extrinsic as #scrate::sp_runtime::traits::Extrinsic>::SignaturePayload as #scrate::sp_runtime::traits::SignaturePayload>::SignatureExtra >(); - #scrate::metadata_ir::MetadataIR { - pallets: #scrate::sp_std::vec![ #(#pallets),* ], - extrinsic: #scrate::metadata_ir::ExtrinsicMetadataIR { + #scrate::__private::metadata_ir::MetadataIR { + pallets: #scrate::__private::sp_std::vec![ #(#pallets),* ], + extrinsic: #scrate::__private::metadata_ir::ExtrinsicMetadataIR { ty, version: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSION, address_ty, @@ -125,39 +125,39 @@ pub fn expand_runtime_metadata( >::SignedExtensions as #scrate::sp_runtime::traits::SignedExtension >::metadata() .into_iter() - .map(|meta| #scrate::metadata_ir::SignedExtensionMetadataIR { + .map(|meta| #scrate::__private::metadata_ir::SignedExtensionMetadataIR { identifier: meta.identifier, ty: meta.ty, additional_signed: meta.additional_signed, }) .collect(), }, - ty: #scrate::scale_info::meta_type::<#runtime>(), + ty: #scrate::__private::scale_info::meta_type::<#runtime>(), apis: (&rt).runtime_metadata(), - outer_enums: #scrate::metadata_ir::OuterEnumsIR { - call_enum_ty: #scrate::scale_info::meta_type::< + outer_enums: #scrate::__private::metadata_ir::OuterEnumsIR { + call_enum_ty: #scrate::__private::scale_info::meta_type::< <#runtime as #system_path::Config>::RuntimeCall >(), - event_enum_ty: #scrate::scale_info::meta_type::(), - error_enum_ty: #scrate::scale_info::meta_type::(), + event_enum_ty: #scrate::__private::scale_info::meta_type::(), + error_enum_ty: #scrate::__private::scale_info::meta_type::(), } } } - pub fn metadata() -> #scrate::metadata::RuntimeMetadataPrefixed { + pub fn metadata() -> #scrate::__private::metadata::RuntimeMetadataPrefixed { // Note: this always returns the V14 version. The runtime API function // must be deprecated. - #scrate::metadata_ir::into_v14(#runtime::metadata_ir()) + #scrate::__private::metadata_ir::into_v14(#runtime::metadata_ir()) } - pub fn metadata_at_version(version: u32) -> Option<#scrate::OpaqueMetadata> { - #scrate::metadata_ir::into_version(#runtime::metadata_ir(), version).map(|prefixed| { - #scrate::OpaqueMetadata::new(prefixed.into()) + pub fn metadata_at_version(version: u32) -> Option<#scrate::__private::OpaqueMetadata> { + #scrate::__private::metadata_ir::into_version(#runtime::metadata_ir(), version).map(|prefixed| { + #scrate::__private::OpaqueMetadata::new(prefixed.into()) }) } - pub fn metadata_versions() -> #scrate::sp_std::vec::Vec { - #scrate::metadata_ir::supported_versions() + pub fn metadata_versions() -> #scrate::__private::sp_std::vec::Vec { + #scrate::__private::metadata_ir::supported_versions() } } } @@ -220,8 +220,8 @@ fn expand_pallet_metadata_events( quote! { Some( - #scrate::metadata_ir::PalletEventMetadataIR { - ty: #scrate::scale_info::meta_type::<#pallet_event>() + #scrate::__private::metadata_ir::PalletEventMetadataIR { + ty: #scrate::__private::scale_info::meta_type::<#pallet_event>() } ) } diff --git a/frame/support/procedural/src/construct_runtime/expand/origin.rs b/frame/support/procedural/src/construct_runtime/expand/origin.rs index 0eaa73f603068..b421d2aaffabe 100644 --- a/frame/support/procedural/src/construct_runtime/expand/origin.rs +++ b/frame/support/procedural/src/construct_runtime/expand/origin.rs @@ -105,25 +105,25 @@ pub fn expand_outer_origin( #[derive(Clone)] pub struct RuntimeOrigin { caller: OriginCaller, - filter: #scrate::sp_std::rc::Rc::RuntimeCall) -> bool>>, + filter: #scrate::__private::sp_std::rc::Rc::RuntimeCall) -> bool>>, } #[cfg(not(feature = "std"))] - impl #scrate::sp_std::fmt::Debug for RuntimeOrigin { + impl #scrate::__private::sp_std::fmt::Debug for RuntimeOrigin { fn fmt( &self, - fmt: &mut #scrate::sp_std::fmt::Formatter, - ) -> #scrate::sp_std::result::Result<(), #scrate::sp_std::fmt::Error> { + fmt: &mut #scrate::__private::sp_std::fmt::Formatter, + ) -> #scrate::__private::sp_std::result::Result<(), #scrate::__private::sp_std::fmt::Error> { fmt.write_str("") } } #[cfg(feature = "std")] - impl #scrate::sp_std::fmt::Debug for RuntimeOrigin { + impl #scrate::__private::sp_std::fmt::Debug for RuntimeOrigin { fn fmt( &self, - fmt: &mut #scrate::sp_std::fmt::Formatter, - ) -> #scrate::sp_std::result::Result<(), #scrate::sp_std::fmt::Error> { + fmt: &mut #scrate::__private::sp_std::fmt::Formatter, + ) -> #scrate::__private::sp_std::result::Result<(), #scrate::__private::sp_std::fmt::Error> { fmt.debug_struct("Origin") .field("caller", &self.caller) .field("filter", &"[function ptr]") @@ -139,7 +139,7 @@ pub fn expand_outer_origin( fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static) { let f = self.filter.clone(); - self.filter = #scrate::sp_std::rc::Rc::new(Box::new(move |call| { + self.filter = #scrate::__private::sp_std::rc::Rc::new(Box::new(move |call| { f(call) && filter(call) })); } @@ -150,7 +150,7 @@ pub fn expand_outer_origin( as #scrate::traits::Contains<<#runtime as #system_path::Config>::RuntimeCall> >::contains; - self.filter = #scrate::sp_std::rc::Rc::new(Box::new(filter)); + self.filter = #scrate::__private::sp_std::rc::Rc::new(Box::new(filter)); } fn set_caller_from(&mut self, other: impl Into) { @@ -197,8 +197,8 @@ pub fn expand_outer_origin( } #[derive( - Clone, PartialEq, Eq, #scrate::RuntimeDebug, #scrate::codec::Encode, - #scrate::codec::Decode, #scrate::scale_info::TypeInfo, #scrate::codec::MaxEncodedLen, + Clone, PartialEq, Eq, #scrate::__private::RuntimeDebug, #scrate::__private::codec::Encode, + #scrate::__private::codec::Decode, #scrate::__private::scale_info::TypeInfo, #scrate::__private::codec::MaxEncodedLen, )] #[allow(non_camel_case_types)] pub enum OriginCaller { @@ -206,7 +206,7 @@ pub fn expand_outer_origin( system(#system_path::Origin<#runtime>), #caller_variants #[allow(dead_code)] - Void(#scrate::Void) + Void(#scrate::__private::Void) } // For backwards compatibility and ease of accessing these functions. @@ -252,7 +252,7 @@ pub fn expand_outer_origin( impl TryFrom for #system_path::Origin<#runtime> { type Error = OriginCaller; fn try_from(x: OriginCaller) - -> #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, OriginCaller> + -> #scrate::__private::sp_std::result::Result<#system_path::Origin<#runtime>, OriginCaller> { if let OriginCaller::system(l) = x { Ok(l) @@ -275,7 +275,7 @@ pub fn expand_outer_origin( fn from(x: OriginCaller) -> Self { let mut o = RuntimeOrigin { caller: x, - filter: #scrate::sp_std::rc::Rc::new(Box::new(|_| true)), + filter: #scrate::__private::sp_std::rc::Rc::new(Box::new(|_| true)), }; #scrate::traits::OriginTrait::reset_filter(&mut o); @@ -284,7 +284,7 @@ pub fn expand_outer_origin( } } - impl From for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> { + impl From for #scrate::__private::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> { /// NOTE: converting to pallet origin loses the origin filter information. fn from(val: RuntimeOrigin) -> Self { if let OriginCaller::system(l) = val.caller { @@ -394,7 +394,7 @@ fn expand_origin_pallet_conversions( } #attr - impl From for #scrate::sp_std::result::Result<#pallet_origin, RuntimeOrigin> { + impl From for #scrate::__private::sp_std::result::Result<#pallet_origin, RuntimeOrigin> { /// NOTE: converting to pallet origin loses the origin filter information. fn from(val: RuntimeOrigin) -> Self { if let OriginCaller::#variant_name(l) = val.caller { @@ -410,7 +410,7 @@ fn expand_origin_pallet_conversions( type Error = OriginCaller; fn try_from( x: OriginCaller, - ) -> #scrate::sp_std::result::Result<#pallet_origin, OriginCaller> { + ) -> #scrate::__private::sp_std::result::Result<#pallet_origin, OriginCaller> { if let OriginCaller::#variant_name(l) = x { Ok(l) } else { @@ -424,7 +424,7 @@ fn expand_origin_pallet_conversions( type Error = (); fn try_from( x: &'a OriginCaller, - ) -> #scrate::sp_std::result::Result<&'a #pallet_origin, ()> { + ) -> #scrate::__private::sp_std::result::Result<&'a #pallet_origin, ()> { if let OriginCaller::#variant_name(l) = x { Ok(&l) } else { @@ -438,7 +438,7 @@ fn expand_origin_pallet_conversions( type Error = (); fn try_from( x: &'a RuntimeOrigin, - ) -> #scrate::sp_std::result::Result<&'a #pallet_origin, ()> { + ) -> #scrate::__private::sp_std::result::Result<&'a #pallet_origin, ()> { if let OriginCaller::#variant_name(l) = &x.caller { Ok(&l) } else { diff --git a/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs b/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs index b78360d5fc052..df69c19a4b617 100644 --- a/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs +++ b/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs @@ -159,10 +159,10 @@ pub fn expand_outer_enum( #[derive( #event_custom_derives - #scrate::codec::Encode, - #scrate::codec::Decode, - #scrate::scale_info::TypeInfo, - #scrate::RuntimeDebug, + #scrate::__private::codec::Encode, + #scrate::__private::codec::Decode, + #scrate::__private::scale_info::TypeInfo, + #scrate::__private::RuntimeDebug, )] #[allow(non_camel_case_types)] pub enum #enum_name_ident { @@ -247,7 +247,7 @@ fn expand_enum_conversion( impl TryInto<#pallet_enum> for #enum_name_ident { type Error = (); - fn try_into(self) -> #scrate::sp_std::result::Result<#pallet_enum, Self::Error> { + fn try_into(self) -> #scrate::__private::sp_std::result::Result<#pallet_enum, Self::Error> { match self { Self::#variant_name(evt) => Ok(evt), _ => Err(()), @@ -273,8 +273,8 @@ fn generate_error_impl(scrate: &TokenStream, enum_ty: OuterEnumType) -> TokenStr pub fn from_dispatch_error(err: #scrate::sp_runtime::DispatchError) -> Option { let #scrate::sp_runtime::DispatchError::Module(module_error) = err else { return None }; - let bytes = #scrate::codec::Encode::encode(&module_error); - #scrate::codec::Decode::decode(&mut &bytes[..]).ok() + let bytes = #scrate::__private::codec::Encode::encode(&module_error); + #scrate::__private::codec::Decode::decode(&mut &bytes[..]).ok() } } } diff --git a/frame/support/procedural/src/construct_runtime/expand/slash_reason.rs b/frame/support/procedural/src/construct_runtime/expand/slash_reason.rs index abffb97d43981..2a3283230ad84 100644 --- a/frame/support/procedural/src/construct_runtime/expand/slash_reason.rs +++ b/frame/support/procedural/src/construct_runtime/expand/slash_reason.rs @@ -38,9 +38,9 @@ pub fn expand_outer_slash_reason(pallet_decls: &[Pallet], scrate: &TokenStream) /// A reason for slashing funds. #[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, )] pub enum RuntimeSlashReason { #( #slash_reason_variants )* diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index efc2244154479..df518a7145728 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -94,11 +94,11 @@ //! ``` //! This call has some implicit pallet parts, thus it will expand to: //! ```ignore -//! frame_support::tt_call! { +//! frame_support::__private::tt_call! { //! macro = [{ pallet_balances::tt_default_parts }] //! ~~> frame_support::match_and_insert! { //! target = [{ -//! frame_support::tt_call! { +//! frame_support::__private::tt_call! { //! macro = [{ frame_system::tt_default_parts }] //! ~~> frame_support::match_and_insert! { //! target = [{ @@ -280,7 +280,7 @@ fn construct_runtime_implicit_to_explicit( let pallet_name = &pallet.name; let pallet_instance = pallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>)); expansion = quote::quote!( - #frame_support::tt_call! { + #frame_support::__private::tt_call! { macro = [{ #pallet_path::tt_default_parts }] frame_support = [{ #frame_support }] ~~> #frame_support::match_and_insert! { @@ -316,7 +316,7 @@ fn construct_runtime_explicit_to_explicit_expanded( let pallet_name = &pallet.name; let pallet_instance = pallet.instance.as_ref().map(|instance| quote::quote!(::<#instance>)); expansion = quote::quote!( - #frame_support::tt_call! { + #frame_support::__private::tt_call! { macro = [{ #pallet_path::tt_extra_parts }] frame_support = [{ #frame_support }] ~~> #frame_support::match_and_insert! { @@ -428,7 +428,7 @@ fn construct_runtime_final_expansion( #[derive( Clone, Copy, PartialEq, Eq, #scrate::sp_runtime::RuntimeDebug, - #scrate::scale_info::TypeInfo + #scrate::__private::scale_info::TypeInfo )] pub struct #name; impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name { @@ -453,7 +453,7 @@ fn construct_runtime_final_expansion( #[doc(hidden)] trait InternalConstructRuntime { #[inline(always)] - fn runtime_metadata(&self) -> #scrate::sp_std::vec::Vec<#scrate::metadata_ir::RuntimeApiMetadataIR> { + fn runtime_metadata(&self) -> #scrate::__private::sp_std::vec::Vec<#scrate::__private::metadata_ir::RuntimeApiMetadataIR> { Default::default() } } @@ -700,10 +700,10 @@ fn decl_pallet_runtime_setup( impl #scrate::traits::PalletInfo for PalletInfo { fn index() -> Option { - let type_id = #scrate::sp_std::any::TypeId::of::

(); + let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::sp_std::any::TypeId::of::<#names>() { + if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { return Some(#indices) } )* @@ -712,10 +712,10 @@ fn decl_pallet_runtime_setup( } fn name() -> Option<&'static str> { - let type_id = #scrate::sp_std::any::TypeId::of::

(); + let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::sp_std::any::TypeId::of::<#names>() { + if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { return Some(#name_strings) } )* @@ -724,10 +724,10 @@ fn decl_pallet_runtime_setup( } fn module_name() -> Option<&'static str> { - let type_id = #scrate::sp_std::any::TypeId::of::

(); + let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::sp_std::any::TypeId::of::<#names>() { + if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { return Some(#module_names) } )* @@ -736,10 +736,10 @@ fn decl_pallet_runtime_setup( } fn crate_version() -> Option<#scrate::traits::CrateVersion> { - let type_id = #scrate::sp_std::any::TypeId::of::

(); + let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::sp_std::any::TypeId::of::<#names>() { + if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { return Some( <#pallet_structs as #scrate::traits::PalletInfoAccess>::crate_version() ) @@ -781,7 +781,7 @@ fn decl_static_assertions( ); quote! { - #scrate::tt_call! { + #scrate::__private::tt_call! { macro = [{ #path::tt_error_token }] frame_support = [{ #scrate }] ~~> #scrate::assert_error_encoded_size! { diff --git a/frame/support/procedural/src/pallet/expand/error.rs b/frame/support/procedural/src/pallet/expand/error.rs index 31c4d3e6fedca..d3aa0b762bc52 100644 --- a/frame/support/procedural/src/pallet/expand/error.rs +++ b/frame/support/procedural/src/pallet/expand/error.rs @@ -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 } }; @@ -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 }] } diff --git a/frame/support/procedural/src/pallet/expand/genesis_build.rs b/frame/support/procedural/src/pallet/expand/genesis_build.rs index f54d308fce304..15ddfcf1d49d4 100644 --- a/frame/support/procedural/src/pallet/expand/genesis_build.rs +++ b/frame/support/procedural/src/pallet/expand/genesis_build.rs @@ -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(()) }) diff --git a/frame/support/procedural/src/pallet/expand/genesis_config.rs b/frame/support/procedural/src/pallet/expand/genesis_config.rs index cbe47bd8505f6..b00f9bcd1a662 100644 --- a/frame/support/procedural/src/pallet/expand/genesis_config.rs +++ b/frame/support/procedural/src/pallet/expand/genesis_config.rs @@ -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, .. }) | diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 174abb24950de..2825756f270f0 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -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:: diff --git a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs index 356bdbf67e923..86db56c776dfe 100644 --- a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs +++ b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs @@ -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::{ diff --git a/frame/support/procedural/src/pallet/parse/composite.rs b/frame/support/procedural/src/pallet/parse/composite.rs index 2bbfcd2e998ab..cb554a116175c 100644 --- a/frame/support/procedural/src/pallet/parse/composite.rs +++ b/frame/support/procedural/src/pallet/parse/composite.rs @@ -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); diff --git a/frame/support/procedural/src/pallet_error.rs b/frame/support/procedural/src/pallet_error.rs index 246a5bd4a219a..7fd02240a628a 100644 --- a/frame/support/procedural/src/pallet_error.rs +++ b/frame/support/procedural/src/pallet_error.rs @@ -124,7 +124,7 @@ fn generate_field_types( res = Some(None); } else if meta.path.is_ident("compact") { let field_ty = &field.ty; - res = Some(Some(quote::quote!(#scrate::codec::Compact<#field_ty>))); + res = Some(Some(quote::quote!(#scrate::__private::codec::Compact<#field_ty>))); } else if meta.path.is_ident("compact") { res = Some(Some(meta.value()?.parse()?)); } diff --git a/frame/support/procedural/src/storage_alias.rs b/frame/support/procedural/src/storage_alias.rs index b44a7ee997fe2..e35160413495f 100644 --- a/frame/support/procedural/src/storage_alias.rs +++ b/frame/support/procedural/src/storage_alias.rs @@ -603,7 +603,7 @@ fn generate_storage_instance( quote! { #visibility struct #counter_name< #impl_generics >( - #crate_::sp_std::marker::PhantomData<(#type_generics)> + #crate_::__private::sp_std::marker::PhantomData<(#type_generics)> ) #where_clause; impl<#impl_generics> #crate_::traits::StorageInstance @@ -628,7 +628,7 @@ fn generate_storage_instance( let code = quote! { #[allow(non_camel_case_types)] #visibility struct #name< #impl_generics >( - #crate_::sp_std::marker::PhantomData<(#type_generics)> + #crate_::__private::sp_std::marker::PhantomData<(#type_generics)> ) #where_clause; impl<#impl_generics> #crate_::traits::StorageInstance diff --git a/frame/support/procedural/src/tt_macro.rs b/frame/support/procedural/src/tt_macro.rs index 69b5eb3d5521a..01611f5dc4a4d 100644 --- a/frame/support/procedural/src/tt_macro.rs +++ b/frame/support/procedural/src/tt_macro.rs @@ -49,9 +49,9 @@ impl syn::parse::Parse for CreateTtReturnMacroDef { } /// A proc macro that accepts a name and any number of key-value pairs, to be used to create a -/// declarative macro that follows tt-call conventions and simply calls [`tt_call::tt_return`], -/// accepting an optional `frame-support` argument and returning the key-value pairs that were -/// supplied to the proc macro. +/// declarative macro that follows tt-call conventions and simply calls +/// [`tt_call::tt_return`], accepting an optional `frame-support` argument and returning +/// the key-value pairs that were supplied to the proc macro. /// /// # Example /// ```ignore @@ -67,7 +67,7 @@ impl syn::parse::Parse for CreateTtReturnMacroDef { /// $caller:tt /// $(frame_support = [{ $($frame_support:ident)::* }])? /// } => { -/// frame_support::tt_return! { +/// frame_support::__private::tt_return! { /// $caller /// foo = [{ bar }] /// } @@ -94,7 +94,7 @@ pub fn create_tt_return_macro(input: proc_macro::TokenStream) -> proc_macro::Tok $caller:tt $(frame_support = [{ $($frame_support:ident)::* }])? } => { - #frame_support::tt_return! { + #frame_support::__private::tt_return! { $caller #( #keys = [{ #values }] diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index f1b2071334b81..0388a9adb3948 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -22,26 +22,27 @@ pub use crate::traits::{ CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, UnfilteredDispatchable, }; -use codec::{ +pub use codec::{ Codec, Decode, Encode, EncodeAsRef, EncodeLike, HasCompact, Input, MaxEncodedLen, Output, }; -use scale_info::TypeInfo; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; -use sp_runtime::{ - generic::{CheckedExtrinsic, UncheckedExtrinsic}, - traits::SignedExtension, -}; +pub use scale_info::TypeInfo; pub use sp_runtime::{ traits::Dispatchable, transaction_validity::TransactionPriority, DispatchError, RuntimeDebug, }; -use sp_std::{ +pub use sp_std::{ fmt, marker, prelude::{Clone, Eq, PartialEq, Vec}, result, }; pub use sp_weights::Weight; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; +use sp_runtime::{ + generic::{CheckedExtrinsic, UncheckedExtrinsic}, + traits::SignedExtension, +}; + /// The return type of a `Dispatchable` in frame. When returned explicitly from /// a dispatchable function it allows overriding the default `PostDispatchInfo` /// returned from a dispatch. From 97063534084dddf360e6f1586676224e1693ac6c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 13:04:15 +0200 Subject: [PATCH 03/42] make reexports private for runtime-benchmarking --- frame/benchmarking/src/v1.rs | 4 ++-- frame/session/benchmarking/src/lib.rs | 6 ++---- frame/staking/src/migrations.rs | 2 +- frame/support/procedural/src/benchmark.rs | 6 +++--- frame/support/src/lib.rs | 14 +++++++++----- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/frame/benchmarking/src/v1.rs b/frame/benchmarking/src/v1.rs index d9f1c7dde0059..c8c50515c0a04 100644 --- a/frame/benchmarking/src/v1.rs +++ b/frame/benchmarking/src/v1.rs @@ -446,13 +446,13 @@ macro_rules! benchmarks_iter { >:: [< new_call_variant_ $dispatch >] ( $($arg),* ); - let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode( + let __benchmarked_call_encoded = $crate::frame_support::__private::codec::Encode::encode( &__call ); }: { let __call_decoded = < Call - as $crate::frame_support::codec::Decode + as $crate::frame_support::__private::codec::Decode >::decode(&mut &__benchmarked_call_encoded[..]) .expect("call is encoded above, encoding must be correct"); let __origin = $crate::to_origin!($origin $(, $origin_type)?); diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index f27136e820d41..70ce52bbd30f5 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -26,11 +26,9 @@ mod mock; use sp_runtime::traits::{One, StaticLookup, TrailingZeroInput}; use sp_std::{prelude::*, vec}; +use sp_runtime::codec::Decode; use frame_benchmarking::v1::benchmarks; -use frame_support::{ - codec::Decode, - traits::{Get, KeyOwnerProofSystem, OnInitialize}, -}; +use frame_support::traits::{Get, KeyOwnerProofSystem, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_session::{historical::Pallet as Historical, Pallet as Session, *}; use pallet_staking::{ diff --git a/frame/staking/src/migrations.rs b/frame/staking/src/migrations.rs index 0a27290daacd8..332da506f01ed 100644 --- a/frame/staking/src/migrations.rs +++ b/frame/staking/src/migrations.rs @@ -296,7 +296,7 @@ pub mod v10 { pub mod v9 { use super::*; #[cfg(feature = "try-runtime")] - use frame_support::codec::{Decode, Encode}; + use codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 57a8e5a5a6d57..5a5bafa0929c6 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -590,7 +590,7 @@ pub fn benchmarks( #krate::benchmarking::reset_read_write_count(); // Time the extrinsic logic. - #krate::__private::log::trace!( + #krate::log::trace!( target: "benchmark", "Start Benchmark: {} ({:?})", extrinsic, @@ -614,12 +614,12 @@ pub fn benchmarks( // Commit the changes to get proper write count #krate::benchmarking::commit_db(); - #krate::__private::log::trace!( + #krate::log::trace!( target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic ); let read_write_count = #krate::benchmarking::read_write_count(); - #krate::__private::log::trace!( + #krate::log::trace!( target: "benchmark", "Read/Write Count {:?}", read_write_count ); diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 988073f76a9aa..e3f687ff5d3f5 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -124,7 +124,7 @@ impl TypeId for PalletId { /// /// ``` /// # use frame_support::storage_alias; -/// use frame_support::codec; +/// use codec; /// use frame_support::Twox64Concat; /// // generate a storage value with type u32. /// #[storage_alias] @@ -701,9 +701,13 @@ macro_rules! assert_noop { $x:expr, $y:expr $(,)? ) => { - let h = $crate::storage_root($crate::StateVersion::V1); + let h = $crate::__private::storage_root($crate::__private::StateVersion::V1); $crate::assert_err!($x, $y); - assert_eq!(h, $crate::storage_root($crate::StateVersion::V1), "storage has been mutated"); + assert_eq!( + h, + $crate::__private::storage_root($crate::__private::StateVersion::V1), + "storage has been mutated" + ); }; } @@ -716,9 +720,9 @@ macro_rules! assert_storage_noop { ( $x:expr ) => { - let h = $crate::storage_root($crate::StateVersion::V1); + let h = $crate::__private::storage_root($crate::__private::StateVersion::V1); $x; - assert_eq!(h, $crate::storage_root($crate::StateVersion::V1)); + assert_eq!(h, $crate::__private::storage_root($crate::__private::StateVersion::V1)); }; } From 7d6c124c960bb5d0e6e9f3bef29adc5c7027e300 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 13:10:49 +0200 Subject: [PATCH 04/42] make reexports private for try-runtime --- Cargo.lock | 1 + frame/executive/Cargo.toml | 2 ++ frame/executive/src/lib.rs | 9 +++++---- frame/support/src/traits/try_runtime.rs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 363eb08cf5395..c371454705d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2446,6 +2446,7 @@ dependencies = [ "frame-support", "frame-system", "frame-try-runtime", + "log", "pallet-balances", "pallet-transaction-payment", "parity-scale-codec", diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index fa466dd2041ea..71ec08472d63b 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [ "derive", ] } +log = { version = "0.4.17", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } @@ -40,6 +41,7 @@ default = ["std"] with-tracing = ["sp-tracing/with-tracing"] std = [ "codec/std", + "log/std", "frame-support/std", "frame-system/std", "frame-try-runtime/std", diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 4e24717a39e93..b1ecfc1df08ab 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -127,6 +127,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; +use log; use sp_runtime::{ generic::Digest, traits::{ @@ -252,7 +253,7 @@ where signature_check: bool, select: frame_try_runtime::TryStateSelect, ) -> Result { - frame_support::log::info!( + log::info!( target: LOG_TARGET, "try-runtime: executing block #{:?} / state root check: {:?} / signature check: {:?} / try-state-select: {:?}", block.header().number(), @@ -289,7 +290,7 @@ where for e in extrinsics { if let Err(err) = try_apply_extrinsic(e.clone()) { - frame_support::log::error!( + log::error!( target: LOG_TARGET, "executing transaction {:?} failed due to {:?}. Aborting the rest of the block execution.", e, err, @@ -308,7 +309,7 @@ where BlockNumberFor, >>::try_state(*header.number(), select) .map_err(|e| { - frame_support::log::error!(target: LOG_TARGET, "failure: {:?}", e); + log::error!(target: LOG_TARGET, "failure: {:?}", e); e })?; drop(_guard); @@ -338,7 +339,7 @@ where ); } - frame_support::log::info!( + log::info!( target: LOG_TARGET, "try-runtime: Block #{:?} successfully executed", header.number(), diff --git a/frame/support/src/traits/try_runtime.rs b/frame/support/src/traits/try_runtime.rs index cb18f9d5b71c0..31aebeeb4d99b 100644 --- a/frame/support/src/traits/try_runtime.rs +++ b/frame/support/src/traits/try_runtime.rs @@ -175,7 +175,7 @@ impl TryState Date: Thu, 10 Aug 2023 13:30:26 +0200 Subject: [PATCH 05/42] fix for try-runtime --- frame/executive/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index b1ecfc1df08ab..1d9afdfa60aa4 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -127,7 +127,6 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use log; use sp_runtime::{ generic::Digest, traits::{ @@ -139,6 +138,8 @@ use sp_runtime::{ }; use sp_std::{marker::PhantomData, prelude::*}; +#[cfg(feature = "try-runtime")] +use log; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; From 1ffc743e6a65d2404a24a6a5f540b69d03cd9aa0 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 15:49:31 +0200 Subject: [PATCH 06/42] make reexports private for tests --- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- frame/support/src/lib.rs | 4 ++-- frame/support/src/storage/bounded_vec.rs | 3 ++- frame/support/src/storage/types/counted_map.rs | 2 +- frame/support/src/storage/types/double_map.rs | 7 ++----- frame/support/src/storage/types/map.rs | 2 +- frame/support/src/storage/types/nmap.rs | 2 +- frame/support/src/storage/types/value.rs | 3 ++- frame/support/src/traits/filter.rs | 2 +- frame/support/src/traits/preimages.rs | 3 ++- frame/support/test/tests/runtime_metadata.rs | 10 ++++------ 11 files changed, 19 insertions(+), 21 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index df518a7145728..f42dd837e3a95 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -760,7 +760,7 @@ fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 { #[test] pub fn runtime_integrity_tests() { - #scrate::sp_tracing::try_init_simple(); + #scrate::__private::sp_tracing::try_init_simple(); ::integrity_test(); } } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index e3f687ff5d3f5..f140769258997 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -349,7 +349,7 @@ macro_rules! parameter_types { impl< $($ty_params),* > $name< $($ty_params),* > { /// Returns the key for this parameter type. pub fn key() -> [u8; 16] { - $crate::sp_core_hashing_proc_macro::twox_128!(b":", $name, b":") + $crate::__private::sp_core_hashing_proc_macro::twox_128!(b":", $name, b":") } /// Set the value of this parameter type in the storage. @@ -814,7 +814,7 @@ pub use macro_magic; #[cfg(test)] pub mod tests { use super::*; - use crate::metadata_ir::{ + use sp_api::metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR, }; diff --git a/frame/support/src/storage/bounded_vec.rs b/frame/support/src/storage/bounded_vec.rs index 59b716b3ae5c6..06c58915a94d1 100644 --- a/frame/support/src/storage/bounded_vec.rs +++ b/frame/support/src/storage/bounded_vec.rs @@ -35,8 +35,9 @@ impl> StorageTryAppend for BoundedVec { #[cfg(test)] pub mod test { use super::*; - use crate::{bounded_vec, traits::ConstU32, Twox128}; + use crate::{traits::ConstU32, Twox128}; use sp_io::TestExternalities; + use sp_runtime::bounded_vec; #[crate::storage_alias] type Foo = StorageValue>>; diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index 8b867a14f453a..0f7f48b9cf4b8 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -512,10 +512,10 @@ mod test { use super::*; use crate::{ hash::*, - metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, storage::{bounded_vec::BoundedVec, types::ValueQuery}, traits::ConstU32, }; + use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/double_map.rs b/frame/support/src/storage/types/double_map.rs index b2c956d4e823c..1d8f9addce35b 100644 --- a/frame/support/src/storage/types/double_map.rs +++ b/frame/support/src/storage/types/double_map.rs @@ -734,11 +734,8 @@ where #[cfg(test)] mod test { use super::*; - use crate::{ - hash::*, - metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, - storage::types::ValueQuery, - }; + use crate::{hash::*, storage::types::ValueQuery}; + use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/map.rs b/frame/support/src/storage/types/map.rs index 4b41db79fad77..ba5536617c6ee 100644 --- a/frame/support/src/storage/types/map.rs +++ b/frame/support/src/storage/types/map.rs @@ -511,9 +511,9 @@ mod test { use super::*; use crate::{ hash::*, - metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, storage::{types::ValueQuery, IterableStorageMap}, }; + use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/nmap.rs b/frame/support/src/storage/types/nmap.rs index 3ae7dad83ee82..f3292a0c4ba54 100755 --- a/frame/support/src/storage/types/nmap.rs +++ b/frame/support/src/storage/types/nmap.rs @@ -620,9 +620,9 @@ mod test { use super::*; use crate::{ hash::{StorageHasher as _, *}, - metadata_ir::{StorageEntryModifierIR, StorageHasherIR}, storage::types::{Key as NMapKey, ValueQuery}, }; + use sp_api::metadata_ir::{StorageEntryModifierIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/value.rs b/frame/support/src/storage/types/value.rs index 171b2c8a567fd..150db08c38860 100644 --- a/frame/support/src/storage/types/value.rs +++ b/frame/support/src/storage/types/value.rs @@ -278,7 +278,8 @@ where #[cfg(test)] mod test { use super::*; - use crate::{metadata_ir::StorageEntryModifierIR, storage::types::ValueQuery}; + use crate::storage::types::ValueQuery; + use sp_api::metadata_ir::StorageEntryModifierIR; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/traits/filter.rs b/frame/support/src/traits/filter.rs index 91efafef2f971..44f9f136cfc2a 100644 --- a/frame/support/src/traits/filter.rs +++ b/frame/support/src/traits/filter.rs @@ -103,7 +103,7 @@ macro_rules! impl_filter_stack { mod $module { #[allow(unused_imports)] use super::*; - use $crate::sp_std::{boxed::Box, cell::RefCell, mem::{swap, take}, vec::Vec}; + use $crate::__private::sp_std::{boxed::Box, cell::RefCell, mem::{swap, take}, vec::Vec}; use $crate::traits::filter::{Contains, FilterStack}; thread_local! { diff --git a/frame/support/src/traits/preimages.rs b/frame/support/src/traits/preimages.rs index db8abdbdc79bb..3e78116202b4f 100644 --- a/frame/support/src/traits/preimages.rs +++ b/frame/support/src/traits/preimages.rs @@ -279,7 +279,8 @@ impl StorePreimage for () { #[cfg(test)] mod tests { use super::*; - use crate::{bounded_vec, BoundedVec}; + use crate::BoundedVec; + use sp_runtime::bounded_vec; #[test] fn bounded_size_is_correct() { diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 50bad87d32eb0..75e9f56f75c07 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -15,13 +15,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::{ - metadata_ir::{ - RuntimeApiMetadataIR, RuntimeApiMethodMetadataIR, RuntimeApiMethodParamMetadataIR, - }, - traits::ConstU32, -}; +use frame_support::traits::ConstU32; use scale_info::{form::MetaForm, meta_type}; +use sp_api::metadata_ir::{ + RuntimeApiMetadataIR, RuntimeApiMethodMetadataIR, RuntimeApiMethodParamMetadataIR, +}; use sp_runtime::traits::Block as BlockT; pub type BlockNumber = u64; From e7955573efe517a7cf7101656f2fd5c16c3050ba Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 16:11:13 +0200 Subject: [PATCH 07/42] fmt --- frame/session/benchmarking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index c304e1cbdb55e..b6a426b7a860c 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -26,7 +26,6 @@ mod mock; use sp_runtime::traits::{One, StaticLookup, TrailingZeroInput}; use sp_std::{prelude::*, vec}; -use sp_runtime::codec::Decode; use frame_benchmarking::v1::benchmarks; use frame_support::traits::{Get, KeyOwnerProofSystem, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; @@ -35,6 +34,7 @@ use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, MaxNominationsOf, RewardDestination, }; +use sp_runtime::codec::Decode; const MAX_VALIDATORS: u32 = 1000; From 4c9ef133ec16c71920cedbd7b03c8ff80894b06d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 16:57:54 +0200 Subject: [PATCH 08/42] make reexports private for tests --- Cargo.lock | 1 + frame/support/src/lib.rs | 4 ++-- frame/support/test/Cargo.toml | 2 ++ frame/support/test/tests/construct_runtime.rs | 2 +- frame/support/test/tests/instance.rs | 8 ++++---- frame/support/test/tests/pallet.rs | 4 ++-- frame/support/test/tests/pallet_instance.rs | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e8145ed95781..0fd9f5ce8a6e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2670,6 +2670,7 @@ version = "3.0.0" dependencies = [ "frame-benchmarking", "frame-executive", + "frame-metadata", "frame-support", "frame-support-test-pallet", "frame-system", diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index f140769258997..321c5db789948 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -414,7 +414,7 @@ macro_rules! parameter_types_impl_thread_local { $crate::parameter_types_impl_thread_local!( IMPL_THREAD_LOCAL $( $vis, $name, $type, $value, )* ); - $crate::paste::item! { + $crate::__private::paste::item! { $crate::parameter_types!( $( $( #[ $attr ] )* @@ -449,7 +449,7 @@ macro_rules! parameter_types_impl_thread_local { } }; (IMPL_THREAD_LOCAL $( $vis:vis, $name:ident, $type:ty, $value:expr, )* ) => { - $crate::paste::item! { + $crate::__private::paste::item! { thread_local! { $( pub static [<$name:snake:upper>]: std::cell::RefCell<$type> = diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index af4d3afd4da98..8dcb501cc6cdf 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -16,6 +16,7 @@ static_assertions = "1.1.0" serde = { version = "1.0.163", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +frame-metadata = { version = "16.0.0", default-features = false, features = ["current"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" } sp-arithmetic = { version = "16.0.0", default-features = false, path = "../../../primitives/arithmetic" } sp-io = { version = "23.0.0", path = "../../../primitives/io", default-features = false } @@ -46,6 +47,7 @@ std = [ "serde/std", "sp-api/std", "sp-arithmetic/std", + "frame-metadata/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index ff207ddf977c6..a14276fa4d2ff 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -636,7 +636,7 @@ fn call_subtype_conversion() { #[test] fn test_metadata() { - use frame_support::metadata::{v14::*, *}; + use frame_metadata::{v14::*, *}; use scale_info::meta_type; use sp_core::Encode; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 2fb6d7658d6ab..f92e0ea0e142c 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -20,13 +20,13 @@ use frame_support::{ derive_impl, inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent}, - metadata_ir::{ - PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, - StorageEntryTypeIR, StorageHasherIR, - }, traits::ConstU32, }; use frame_system::pallet_prelude::BlockNumberFor; +use sp_api::metadata_ir::{ + PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, + StorageHasherIR, +}; use sp_core::sr25519; use sp_runtime::{ generic, diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index cb78bded1a358..8c85cd5695953 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -1378,7 +1378,7 @@ fn migrate_from_pallet_version_to_storage_version() { #[test] fn metadata() { use codec::Decode; - use frame_support::metadata::{v15::*, *}; + use frame_metadata::{v15::*, *}; fn maybe_docs(doc: Vec<&'static str>) -> Vec<&'static str> { if cfg!(feature = "no-metadata-docs") { @@ -1860,7 +1860,7 @@ fn metadata() { #[test] fn metadata_at_version() { - use frame_support::metadata::*; + use frame_metadata::*; use sp_core::Decode; // Metadata always returns the V14.3 diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 4ecb9bcb58ae9..be675a562cec5 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -721,7 +721,7 @@ fn pallet_on_genesis() { #[test] fn metadata() { - use frame_support::metadata::{v14::*, *}; + use frame_metadata::{v14::*, *}; let system_pallet_metadata = PalletMetadata { index: 0, From 4d0b806a9e592db822e38080b1231b25db06698f Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 17:24:34 +0200 Subject: [PATCH 09/42] make reexports private for experimental --- Cargo.lock | 1 + frame/aura/Cargo.toml | 2 ++ frame/aura/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0fd9f5ce8a6e1..7da1ba92dacd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5799,6 +5799,7 @@ version = "4.0.0-dev" dependencies = [ "frame-support", "frame-system", + "log", "pallet-timestamp", "parity-scale-codec", "scale-info", diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 99c8c2fb497f0..0c2b812c43d03 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } +log = { version = "0.4.17", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } @@ -31,6 +32,7 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" } default = ["std"] std = [ "codec/std", + "log/std", "frame-support/std", "frame-system/std", "pallet-timestamp/std", diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 641d5fc47e90e..b314a3601e15f 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -40,10 +40,10 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - log, traits::{DisabledValidators, FindAuthor, Get, OnTimestampSet, OneSessionHandler}, BoundedSlice, BoundedVec, ConsensusEngineId, Parameter, }; +use log; use sp_consensus_aura::{AuthorityIndex, ConsensusLog, Slot, AURA_ENGINE_ID}; use sp_runtime::{ generic::DigestItem, From e32c82f73112cbea5fb8b2714f0f0d96f8ce8d42 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 17:59:21 +0200 Subject: [PATCH 10/42] fix beefy --- Cargo.lock | 2 ++ frame/beefy/Cargo.toml | 6 +++++- frame/beefy/src/equivocation.rs | 5 +---- frame/beefy/src/lib.rs | 2 +- frame/beefy/src/mock.rs | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7da1ba92dacd2..1aafda7f855df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5943,6 +5943,7 @@ dependencies = [ "frame-election-provider-support", "frame-support", "frame-system", + "log", "pallet-authorship", "pallet-balances", "pallet-offences", @@ -5959,6 +5960,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", + "sp-state-machine", "sp-std", ] diff --git a/frame/beefy/Cargo.toml b/frame/beefy/Cargo.toml index 9f331f74f778f..91cb8e072ca11 100644 --- a/frame/beefy/Cargo.toml +++ b/frame/beefy/Cargo.toml @@ -10,6 +10,7 @@ homepage = "https://substrate.io" [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } +log = { version = "0.4.17", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] } serde = { version = "1.0.163", optional = true } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } @@ -32,11 +33,13 @@ pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } sp-core = { version = "21.0.0", path = "../../primitives/core" } sp-io = { version = "23.0.0", path = "../../primitives/io" } sp-staking = { version = "4.0.0-dev", path = "../../primitives/staking" } +sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" } [features] default = ["std"] std = [ "codec/std", + "log/std", "frame-support/std", "frame-system/std", "pallet-authorship/std", @@ -54,7 +57,8 @@ std = [ "pallet-staking/std", "pallet-timestamp/std", "sp-core/std", - "sp-io/std" + "sp-io/std", + "sp-state-machine/std" ] try-runtime = [ "frame-support/try-runtime", diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index 84c62fc47f50a..0a7ede327c9e6 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -35,10 +35,7 @@ //! definition. use codec::{self as codec, Decode, Encode}; -use frame_support::{ - log, - traits::{Get, KeyOwnerProofSystem}, -}; +use frame_support::traits::{Get, KeyOwnerProofSystem}; use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE as BEEFY_KEY_TYPE}; diff --git a/frame/beefy/src/lib.rs b/frame/beefy/src/lib.rs index 35d3273e1ef76..77e74436dd671 100644 --- a/frame/beefy/src/lib.rs +++ b/frame/beefy/src/lib.rs @@ -21,7 +21,6 @@ use codec::{Encode, MaxEncodedLen}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, - log, pallet_prelude::*, traits::{Get, OneSessionHandler}, weights::Weight, @@ -31,6 +30,7 @@ use frame_system::{ ensure_none, ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}, }; +use log; use sp_runtime::{ generic::DigestItem, traits::{IsMember, Member}, diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index f2d8415bc01f7..b55a65dbd73af 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -23,12 +23,11 @@ use frame_election_provider_support::{ }; use frame_support::{ construct_runtime, parameter_types, - sp_io::TestExternalities, traits::{ConstU16, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize}, - BasicExternalities, }; use pallet_session::historical as pallet_session_historical; use sp_core::{crypto::KeyTypeId, ConstU128, H256}; +use sp_io::TestExternalities; use sp_runtime::{ app_crypto::ecdsa::Public, curve::PiecewiseLinear, @@ -38,6 +37,7 @@ use sp_runtime::{ BuildStorage, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; +use sp_state_machine::BasicExternalities; use crate as pallet_beefy; From 4386de37c64324d3330fe941185e59d27c1e2899 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 18:18:42 +0200 Subject: [PATCH 11/42] fix ui test --- .../tests/construct_runtime_ui/deprecated_where_block.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr index 946277e9068e3..e16ab1172f240 100644 --- a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr @@ -374,7 +374,7 @@ note: required by a bound in `Result` | | pub enum Result { | ^ required by this bound in `Result` - = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::__private::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 @@ -439,4 +439,4 @@ note: required by a bound in `Result` | | pub enum Result { | ^ required by this bound in `Result` - = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::__private::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) From 54657c0324e635a8fa1d5b40e664b157ffa0ab39 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 10 Aug 2023 18:28:37 +0200 Subject: [PATCH 12/42] fix ui test --- .../tests/construct_runtime_ui/deprecated_where_block.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr index e16ab1172f240..0aee2cbceb9a1 100644 --- a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr @@ -374,7 +374,7 @@ note: required by a bound in `Result` | | pub enum Result { | ^ required by this bound in `Result` - = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::__private::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::__private::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 @@ -439,4 +439,4 @@ note: required by a bound in `Result` | | pub enum Result { | ^ required by this bound in `Result` - = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::__private::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::__private::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) From 356696111e3e9f1ad32277292a0cefe052c2f100 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 14 Aug 2023 16:31:59 +0200 Subject: [PATCH 13/42] fix benches --- Cargo.lock | 3 +++ frame/balances/src/tests/mod.rs | 4 ++-- frame/beefy-mmr/Cargo.toml | 4 +++- frame/beefy-mmr/src/mock.rs | 4 ++-- frame/election-provider-multi-phase/src/mock.rs | 3 ++- frame/election-provider-multi-phase/src/unsigned.rs | 5 ++--- frame/election-provider-support/src/onchain.rs | 3 ++- frame/membership/src/lib.rs | 4 ++-- frame/nomination-pools/src/tests.rs | 6 +++--- frame/nomination-pools/test-staking/src/lib.rs | 4 ++-- frame/paged-list/Cargo.toml | 3 ++- frame/paged-list/src/paged_list.rs | 2 +- frame/preimage/src/tests.rs | 3 ++- frame/proxy/src/tests.rs | 3 +-- frame/recovery/src/tests.rs | 4 ++-- frame/scored-pool/src/mock.rs | 3 ++- frame/session/Cargo.toml | 2 ++ frame/session/src/historical/mod.rs | 6 ++---- frame/session/src/historical/offchain.rs | 6 ++---- frame/session/src/mock.rs | 2 +- frame/staking/src/tests.rs | 4 ++-- frame/state-trie-migration/src/lib.rs | 4 ++-- 22 files changed, 44 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1aafda7f855df..af7f64dbbd3b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5985,6 +5985,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", + "sp-state-machine", "sp-std", ] @@ -6824,6 +6825,7 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", + "sp-api", "sp-core", "sp-io", "sp-runtime", @@ -7048,6 +7050,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", + "sp-state-machine", "sp-std", "sp-trie", ] diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 45f34110a6e9e..cefc6e9e8f51f 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -30,7 +30,6 @@ use frame_support::{ StorageMapShim, StoredMap, WhitelistedStorageKeys, }, weights::{IdentityFee, Weight}, - RuntimeDebug, }; use frame_system::{self as system, RawOrigin}; use pallet_transaction_payment::{ChargeTransactionPayment, CurrencyAdapter, Multiplier}; @@ -39,7 +38,8 @@ use sp_core::{hexdisplay::HexDisplay, H256}; use sp_io; use sp_runtime::{ traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, - ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError, + ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, RuntimeDebug, + TokenError, }; use std::collections::BTreeSet; diff --git a/frame/beefy-mmr/Cargo.toml b/frame/beefy-mmr/Cargo.toml index 5691a5d735272..97ad80fa7ac6a 100644 --- a/frame/beefy-mmr/Cargo.toml +++ b/frame/beefy-mmr/Cargo.toml @@ -26,6 +26,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } +sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" } [dev-dependencies] array-bytes = "6.1" @@ -51,7 +52,8 @@ std = [ "sp-runtime/std", "sp-std/std", "sp-api/std", - "sp-staking/std" + "sp-staking/std", + "sp-state-machine/std" ] try-runtime = [ "frame-support/try-runtime", diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 2c37ad4483f6b..b2d8758a04be6 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -20,18 +20,18 @@ use std::vec; use codec::Encode; use frame_support::{ construct_runtime, parameter_types, - sp_io::TestExternalities, traits::{ConstU16, ConstU32, ConstU64}, - BasicExternalities, }; use sp_consensus_beefy::mmr::MmrLeafVersion; use sp_core::H256; +use sp_io::TestExternalities; use sp_runtime::{ app_crypto::ecdsa::Public, impl_opaque_keys, traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, BuildStorage, }; +use sp_state_machine::BasicExternalities; use crate as pallet_beefy_mmr; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 82c7279879feb..05d151e51ecc5 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -23,7 +23,7 @@ use frame_election_provider_support::{ }; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::GetDefault}; use frame_support::{ - bounded_vec, parameter_types, + parameter_types, traits::{ConstU32, Hooks}, weights::{constants, Weight}, BoundedVec, @@ -42,6 +42,7 @@ use sp_npos_elections::{ ElectionResult, EvaluateSupport, }; use sp_runtime::{ + bounded_vec, testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, PerU16, diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index e21e6c5e6d229..5eeac26fb1323 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -985,11 +985,10 @@ mod tests { use codec::Decode; use frame_benchmarking::Zero; use frame_election_provider_support::IndexAssignment; - use frame_support::{ - assert_noop, assert_ok, bounded_vec, dispatch::Dispatchable, traits::OffchainWorker, - }; + use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::OffchainWorker}; use sp_npos_elections::ElectionScore; use sp_runtime::{ + bounded_vec, offchain::storage_lock::{BlockAndTime, StorageLock}, traits::ValidateUnsigned, ModuleError, PerU16, Perbill, diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 21ee710ea304d..8ac245a360bb5 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -254,7 +254,8 @@ mod tests { } mod mock_data_provider { - use frame_support::{bounded_vec, traits::ConstU32}; + use frame_support::traits::ConstU32; + use sp_runtime::bounded_vec; use super::*; use crate::{data_provider, VoterOf}; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 24b9fb5fe9069..232e0c0bd319b 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -526,11 +526,11 @@ mod tests { use sp_core::H256; use sp_runtime::{ traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - BuildStorage, + bounded_vec, BuildStorage, }; use frame_support::{ - assert_noop, assert_ok, bounded_vec, ord_parameter_types, parameter_types, + assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::{ConstU32, ConstU64, StorageVersion}, }; use frame_system::EnsureSignedBy; diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index ac8fa5c4dbc0c..d0fe4e40a18b7 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -17,9 +17,9 @@ use super::*; use crate::{mock::*, Event}; -use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_btree_map}; +use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop}; use pallet_balances::Event as BEvent; -use sp_runtime::{traits::Dispatchable, FixedU128}; +use sp_runtime::{bounded_btree_map, traits::Dispatchable, FixedU128}; macro_rules! unbonding_pools_with_era { ($($k:expr => $v:expr),* $(,)?) => {{ @@ -3260,7 +3260,7 @@ mod pool_withdraw_unbonded { mod withdraw_unbonded { use super::*; - use frame_support::bounded_btree_map; + use sp_runtime::bounded_btree_map; #[test] fn withdraw_unbonded_works_against_slashed_no_era_sub_pool() { diff --git a/frame/nomination-pools/test-staking/src/lib.rs b/frame/nomination-pools/test-staking/src/lib.rs index 1587492582143..9108da510a3a5 100644 --- a/frame/nomination-pools/test-staking/src/lib.rs +++ b/frame/nomination-pools/test-staking/src/lib.rs @@ -19,14 +19,14 @@ mod mock; -use frame_support::{assert_noop, assert_ok, bounded_btree_map, traits::Currency}; +use frame_support::{assert_noop, assert_ok, traits::Currency}; use mock::*; use pallet_nomination_pools::{ BondedPools, Error as PoolsError, Event as PoolsEvent, LastPoolId, PoolMember, PoolMembers, PoolState, }; use pallet_staking::{CurrentEra, Event as StakingEvent, Payee, RewardDestination}; -use sp_runtime::traits::Zero; +use sp_runtime::{bounded_btree_map, traits::Zero}; #[test] fn pool_lifecycle_e2e() { diff --git a/frame/paged-list/Cargo.toml b/frame/paged-list/Cargo.toml index 3d7010d331b2e..cc043ab040a2a 100644 --- a/frame/paged-list/Cargo.toml +++ b/frame/paged-list/Cargo.toml @@ -20,6 +20,7 @@ frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } +sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } sp-core = { version = "21.0.0", path = "../../primitives/core", default-features = false } @@ -28,7 +29,7 @@ sp-io = { version = "23.0.0", path = "../../primitives/io", default-features = f [features] default = ["std"] -std = ["codec/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "scale-info/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std"] +std = ["codec/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "scale-info/std", "sp-api/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std"] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks"] diff --git a/frame/paged-list/src/paged_list.rs b/frame/paged-list/src/paged_list.rs index 37ebe80d93448..21c0fbce9ae57 100644 --- a/frame/paged-list/src/paged_list.rs +++ b/frame/paged-list/src/paged_list.rs @@ -408,11 +408,11 @@ where pub(crate) mod mock { pub use super::*; pub use frame_support::{ - metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}, parameter_types, storage::{types::ValueQuery, StorageList as _}, StorageNoopGuard, }; + pub use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; pub use sp_io::{hashing::twox_128, TestExternalities}; parameter_types! { diff --git a/frame/preimage/src/tests.rs b/frame/preimage/src/tests.rs index 63a178c408a3f..fa621c8f5589e 100644 --- a/frame/preimage/src/tests.rs +++ b/frame/preimage/src/tests.rs @@ -23,12 +23,13 @@ use super::*; use crate::mock::*; use frame_support::{ - assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_vec, + assert_err, assert_noop, assert_ok, assert_storage_noop, traits::{Bounded, BoundedInline, Hash as PreimageHash}, StorageNoopGuard, }; use pallet_balances::Error as BalancesError; use sp_core::{blake2_256, H256}; +use sp_runtime::bounded_vec; /// Returns one `Inline`, `Lookup` and `Legacy` item each with different data and hash. pub fn make_bounded_values() -> (Bounded>, Bounded>, Bounded>) { diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 1f4d2617700e6..4a00bd16e6859 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -27,12 +27,11 @@ use frame_support::{ assert_noop, assert_ok, dispatch::DispatchError, traits::{ConstU32, ConstU64, Contains}, - RuntimeDebug, }; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, + BuildStorage, RuntimeDebug, }; type Block = frame_system::mocking::MockBlock; diff --git a/frame/recovery/src/tests.rs b/frame/recovery/src/tests.rs index 85024d0bc4a9d..93df07015852e 100644 --- a/frame/recovery/src/tests.rs +++ b/frame/recovery/src/tests.rs @@ -18,12 +18,12 @@ //! Tests for the module. use super::*; -use frame_support::{assert_noop, assert_ok, bounded_vec, traits::Currency}; +use frame_support::{assert_noop, assert_ok, traits::Currency}; use mock::{ new_test_ext, run_to_block, Balances, BalancesCall, MaxFriends, Recovery, RecoveryCall, RuntimeCall, RuntimeOrigin, Test, }; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{bounded_vec, traits::BadOrigin}; #[test] fn basic_setup_works() { diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index d8c6ef9b0f444..591c910488b16 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -21,12 +21,13 @@ use super::*; use crate as pallet_scored_pool; use frame_support::{ - bounded_vec, construct_runtime, ord_parameter_types, parameter_types, + construct_runtime, ord_parameter_types, parameter_types, traits::{ConstU32, ConstU64}, }; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ + bounded_vec, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index 0858ae6656540..a2a04e76a9f91 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -27,6 +27,7 @@ sp-session = { version = "4.0.0-dev", default-features = false, path = "../../pr sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking", features = ["serde"] } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } sp-trie = { version = "22.0.0", default-features = false, optional = true, path = "../../primitives/trie" } +sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" } [features] default = ["historical", "std"] @@ -45,6 +46,7 @@ std = [ "sp-staking/std", "sp-std/std", "sp-trie/std", + "sp-state-machine/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/frame/session/src/historical/mod.rs b/frame/session/src/historical/mod.rs index 04129e4eba130..d74e9dd0b7c54 100644 --- a/frame/session/src/historical/mod.rs +++ b/frame/session/src/historical/mod.rs @@ -378,11 +378,9 @@ pub(crate) mod tests { }; use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId, BuildStorage}; + use sp_state_machine::BasicExternalities; - use frame_support::{ - traits::{KeyOwnerProofSystem, OnInitialize}, - BasicExternalities, - }; + use frame_support::traits::{KeyOwnerProofSystem, OnInitialize}; type Historical = Pallet; diff --git a/frame/session/src/historical/offchain.rs b/frame/session/src/historical/offchain.rs index c44eea2f374c0..1b4d53b74b45e 100644 --- a/frame/session/src/historical/offchain.rs +++ b/frame/session/src/historical/offchain.rs @@ -150,11 +150,9 @@ mod tests { offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt, StorageKind}, }; use sp_runtime::{testing::UintAuthorityId, BuildStorage}; + use sp_state_machine::BasicExternalities; - use frame_support::{ - traits::{KeyOwnerProofSystem, OnInitialize}, - BasicExternalities, - }; + use frame_support::traits::{KeyOwnerProofSystem, OnInitialize}; type Historical = Pallet; diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index b45ebfd25c44a..2db54e1a59756 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -32,11 +32,11 @@ use sp_runtime::{ BuildStorage, }; use sp_staking::SessionIndex; +use sp_state_machine::BasicExternalities; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, - BasicExternalities, }; impl_opaque_keys! { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 29539cbb84cf7..fd7dabac74d8d 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -23,7 +23,7 @@ use frame_election_provider_support::{ ElectionProvider, SortedListProvider, Support, }; use frame_support::{ - assert_noop, assert_ok, assert_storage_noop, bounded_vec, + assert_noop, assert_ok, assert_storage_noop, dispatch::{extract_actual_weight, GetDispatchInfo, WithPostDispatchInfo}, pallet_prelude::*, traits::{Currency, Get, ReservableCurrency}, @@ -31,7 +31,7 @@ use frame_support::{ use mock::*; use pallet_balances::Error as BalancesError; use sp_runtime::{ - assert_eq_error_rate, + assert_eq_error_rate, bounded_vec, traits::{BadOrigin, Dispatchable}, Perbill, Percent, Rounding, TokenError, }; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index c5b41cd9a4439..e22a47458b7d5 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1268,8 +1268,8 @@ mod mock { #[cfg(test)] mod test { use super::{mock::*, *}; - use frame_support::{bounded_vec, dispatch::*}; - use sp_runtime::{traits::Bounded, StateVersion}; + use frame_support::dispatch::*; + use sp_runtime::{bounded_vec, traits::Bounded, StateVersion}; #[test] fn fails_if_no_migration() { From c419d4ac9d53699c3816c940c33890a7a64f5daf Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 14 Aug 2023 14:37:51 +0000 Subject: [PATCH 14/42] ".git/.scripts/commands/fmt/fmt.sh" --- frame/membership/src/lib.rs | 3 ++- frame/proxy/src/tests.rs | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 232e0c0bd319b..6fb61f0e491be 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -525,8 +525,9 @@ mod tests { use sp_core::H256; use sp_runtime::{ + bounded_vec, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - bounded_vec, BuildStorage, + BuildStorage, }; use frame_support::{ diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 7de8c422d8452..48a2a4ed0cc33 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -29,9 +29,7 @@ use frame_support::{ traits::{ConstU32, ConstU64, Contains}, }; use sp_core::H256; -use sp_runtime::{ - traits::BlakeTwo256, BuildStorage, RuntimeDebug, -}; +use sp_runtime::{traits::BlakeTwo256, BuildStorage, RuntimeDebug}; type Block = frame_system::mocking::MockBlock; From b931ecb6301c5d4566dc92e90fa70db8cfa569f3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 15 Aug 2023 11:52:49 +0200 Subject: [PATCH 15/42] fix contracts use --- frame/contracts/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 37b79c2d585ad..7c0f7aabc6cb0 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -122,7 +122,7 @@ use frame_support::{ ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, - BoundedVec, RuntimeDebug, RuntimeDebugNoBound, + BoundedVec, RuntimeDebugNoBound, }; use frame_system::{ensure_signed, pallet_prelude::OriginFor, EventRecord, Pallet as System}; use pallet_contracts_primitives::{ @@ -132,7 +132,10 @@ use pallet_contracts_primitives::{ }; use scale_info::TypeInfo; use smallvec::Array; -use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, Zero}; +use sp_runtime::{ + traits::{Convert, Hash, Saturating, StaticLookup, Zero}, + RuntimeDebug, +}; use sp_std::{fmt::Debug, prelude::*}; pub use crate::{ From f4e5f5502ad04a12622c6f821600fedf8e9867cd Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 15 Aug 2023 12:40:57 +0200 Subject: [PATCH 16/42] wip --- frame/democracy/src/migrations/v1.rs | 2 +- frame/preimage/src/migration.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index 27a500a615cff..708b975f6f744 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -159,7 +159,7 @@ mod test { tests::{Test as T, *}, types::*, }; - use frame_support::bounded_vec; + use sp_core::bounded_vec; #[allow(deprecated)] #[test] diff --git a/frame/preimage/src/migration.rs b/frame/preimage/src/migration.rs index 46e555498cd2d..9b16233f92043 100644 --- a/frame/preimage/src/migration.rs +++ b/frame/preimage/src/migration.rs @@ -192,7 +192,7 @@ mod test { use super::*; use crate::mock::{Test as T, *}; - use frame_support::bounded_vec; + use sp_core::bounded_vec; #[test] fn migration_works() { From 4ecbfff3d3036e0728194a8e3b45ebe3385d7877 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 15 Aug 2023 13:28:46 +0200 Subject: [PATCH 17/42] wip --- frame/democracy/src/migrations/v1.rs | 2 +- frame/election-provider-support/src/lib.rs | 2 +- frame/preimage/src/migration.rs | 2 +- frame/support/src/storage/child.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index 708b975f6f744..c27f437901b7e 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -159,7 +159,7 @@ mod test { tests::{Test as T, *}, types::*, }; - use sp_core::bounded_vec; + use sp_runtime::bounded_vec; #[allow(deprecated)] #[test] diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index f1bf39a6d0e51..2e9ee3b8a48b5 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -82,7 +82,7 @@ //! # use frame_election_provider_support::{*, data_provider}; //! # use sp_npos_elections::{Support, Assignment}; //! # use frame_support::traits::ConstU32; -//! # use frame_support::bounded_vec; +//! # use sp_runtime::bounded_vec; //! //! type AccountId = u64; //! type Balance = u64; diff --git a/frame/preimage/src/migration.rs b/frame/preimage/src/migration.rs index 9b16233f92043..0f3337e39bf50 100644 --- a/frame/preimage/src/migration.rs +++ b/frame/preimage/src/migration.rs @@ -192,7 +192,7 @@ mod test { use super::*; use crate::mock::{Test as T, *}; - use sp_core::bounded_vec; + use sp_runtime::bounded_vec; #[test] fn migration_works() { diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index 499c32c5b2a5a..e54002d18db3d 100644 --- a/frame/support/src/storage/child.rs +++ b/frame/support/src/storage/child.rs @@ -23,7 +23,7 @@ use codec::{Codec, Decode, Encode}; pub use sp_core::storage::{ChildInfo, ChildType, StateVersion}; -use sp_io::{KillStorageResult, MultiRemovalResults}; +pub use sp_io::{KillStorageResult, MultiRemovalResults}; use sp_std::prelude::*; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. From 095356c4707857467eb6873a74f078590089bc09 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 16 Aug 2023 12:09:40 +0200 Subject: [PATCH 18/42] do not reexport sp_api::metadata_ir --- Cargo.lock | 3 ++- frame/paged-list/Cargo.toml | 18 ++++++++++++++++-- frame/paged-list/src/paged_list.rs | 2 +- frame/support/Cargo.toml | 4 +++- frame/support/src/hash.rs | 2 +- frame/support/src/lib.rs | 6 +++--- frame/support/src/storage/types/counted_map.rs | 4 ++-- .../support/src/storage/types/counted_nmap.rs | 4 ++-- frame/support/src/storage/types/double_map.rs | 4 ++-- frame/support/src/storage/types/key.rs | 6 +++--- frame/support/src/storage/types/map.rs | 4 ++-- frame/support/src/storage/types/mod.rs | 2 +- frame/support/src/storage/types/nmap.rs | 4 ++-- frame/support/src/storage/types/value.rs | 4 ++-- frame/support/test/tests/instance.rs | 4 ++-- frame/support/test/tests/runtime_metadata.rs | 2 +- 16 files changed, 45 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 708dda245e3fa..33960fc797bf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2618,6 +2618,7 @@ dependencies = [ "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-staking", "sp-state-machine", @@ -6826,9 +6827,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-api", "sp-core", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-std", ] diff --git a/frame/paged-list/Cargo.toml b/frame/paged-list/Cargo.toml index cc043ab040a2a..441ffd4bf0ba8 100644 --- a/frame/paged-list/Cargo.toml +++ b/frame/paged-list/Cargo.toml @@ -20,16 +20,26 @@ frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } -sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } sp-core = { version = "21.0.0", path = "../../primitives/core", default-features = false } sp-io = { version = "23.0.0", path = "../../primitives/io", default-features = false } +sp-metadata-ir = { version = "0.1.0", default-features = false, optional = true, path = "../../primitives/metadata-ir" } [features] default = ["std"] -std = ["codec/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "scale-info/std", "sp-api/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std"] +std = [ + "codec/std", + "frame-benchmarking?/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std" +] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks"] @@ -38,3 +48,7 @@ try-runtime = [ "frame-system/try-runtime", "sp-runtime/try-runtime" ] + +frame-metadata = [ + "sp-metadata-ir" +] diff --git a/frame/paged-list/src/paged_list.rs b/frame/paged-list/src/paged_list.rs index 21c0fbce9ae57..3597c3dea6823 100644 --- a/frame/paged-list/src/paged_list.rs +++ b/frame/paged-list/src/paged_list.rs @@ -412,8 +412,8 @@ pub(crate) mod mock { storage::{types::ValueQuery, StorageList as _}, StorageNoopGuard, }; - pub use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; pub use sp_io::{hashing::twox_128, TestExternalities}; + pub use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; parameter_types! { pub const ValuesPerNewPage: u32 = 5; diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index fab6167f3d50f..ad72d0f55390f 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -28,6 +28,7 @@ sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../ sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } sp-weights = { version = "20.0.0", default-features = false, path = "../../primitives/weights" } sp-debug-derive = { default-features = false, path = "../../primitives/debug-derive" } +sp-metadata-ir = { version = "0.1.0", default-features = false, path = "../../primitives/metadata-ir" } tt-call = "1.0.8" macro_magic = "0.4.2" frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" } @@ -75,7 +76,8 @@ std = [ "environmental/std", "sp-genesis-builder/std", "frame-system/std", - "sp-debug-derive/std" + "sp-debug-derive/std", + "sp-metadata-ir/std" ] runtime-benchmarks = [ "frame-system/runtime-benchmarks", diff --git a/frame/support/src/hash.rs b/frame/support/src/hash.rs index d419890e87a6c..9c48f4b187ad3 100644 --- a/frame/support/src/hash.rs +++ b/frame/support/src/hash.rs @@ -18,8 +18,8 @@ //! Hash utilities. use codec::{Codec, MaxEncodedLen}; -use sp_api::metadata_ir; use sp_io::hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64}; +use sp_metadata_ir as metadata_ir; use sp_std::prelude::Vec; // This trait must be kept coherent with frame-support-procedural HasherKind usage diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 321c5db789948..287d9de3c9fff 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -40,10 +40,10 @@ pub mod __private { pub use paste; pub use scale_info; pub use serde; - pub use sp_api::metadata_ir; pub use sp_core::{OpaqueMetadata, Void}; pub use sp_core_hashing_proc_macro; pub use sp_io::{self, storage::root as storage_root}; + pub use sp_metadata_ir as metadata_ir; #[cfg(feature = "std")] pub use sp_runtime::{bounded_btree_map, bounded_vec}; pub use sp_runtime::{RuntimeDebug, StateVersion}; @@ -814,11 +814,11 @@ pub use macro_magic; #[cfg(test)] pub mod tests { use super::*; - use sp_api::metadata_ir::{ + use sp_io::{MultiRemovalResults, TestExternalities}; + use sp_metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR, }; - use sp_io::{MultiRemovalResults, TestExternalities}; use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; use sp_std::result; diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index 0f7f48b9cf4b8..a5dd11fa7c84c 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -30,8 +30,8 @@ use crate::{ Never, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref}; -use sp_api::metadata_ir::StorageEntryMetadataIR; use sp_io::MultiRemovalResults; +use sp_metadata_ir::StorageEntryMetadataIR; use sp_runtime::traits::Saturating; use sp_std::prelude::*; @@ -515,7 +515,7 @@ mod test { storage::{bounded_vec::BoundedVec, types::ValueQuery}, traits::ConstU32, }; - use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/counted_nmap.rs b/frame/support/src/storage/types/counted_nmap.rs index 43a243cc5d681..c7a5cd298374d 100644 --- a/frame/support/src/storage/types/counted_nmap.rs +++ b/frame/support/src/storage/types/counted_nmap.rs @@ -29,7 +29,7 @@ use crate::{ Never, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref}; -use sp_api::metadata_ir::StorageEntryMetadataIR; +use sp_metadata_ir::StorageEntryMetadataIR; use sp_runtime::traits::Saturating; use sp_std::prelude::*; @@ -638,7 +638,7 @@ mod test { hash::{StorageHasher as _, *}, storage::types::{Key as NMapKey, ValueQuery}, }; - use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; struct Prefix; diff --git a/frame/support/src/storage/types/double_map.rs b/frame/support/src/storage/types/double_map.rs index 1d8f9addce35b..e787921841032 100644 --- a/frame/support/src/storage/types/double_map.rs +++ b/frame/support/src/storage/types/double_map.rs @@ -27,8 +27,8 @@ use crate::{ StorageHasher, Twox128, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; -use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; +use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_std::prelude::*; /// A type that allow to store values for `(key1, key2)` couple. Similar to `StorageMap` but allow @@ -735,8 +735,8 @@ where mod test { use super::*; use crate::{hash::*, storage::types::ValueQuery}; - use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; struct Prefix; impl StorageInstance for Prefix { diff --git a/frame/support/src/storage/types/key.rs b/frame/support/src/storage/types/key.rs index dd528b7f8bb5c..90cf09dd1d341 100755 --- a/frame/support/src/storage/types/key.rs +++ b/frame/support/src/storage/types/key.rs @@ -41,7 +41,7 @@ pub trait KeyGenerator { type HashFn: FnOnce(&[u8]) -> Vec; type HArg; - const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR]; + const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR]; /// Given a `key` tuple, calculate the final key by encoding each element individually and /// hashing them using the corresponding hasher in the `KeyGenerator`. @@ -74,7 +74,7 @@ impl KeyGenerator for Key type HashFn = Box Vec>; type HArg = (Self::HashFn,); - const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR] = &[H::METADATA]; + const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR] = &[H::METADATA]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { H::hash(&key.to_encoded_iter().next().expect("should have at least one element!")) @@ -114,7 +114,7 @@ impl KeyGenerator for Tuple { for_tuples!( type HArg = ( #(Tuple::HashFn),* ); ); type HashFn = Box Vec>; - const HASHER_METADATA: &'static [sp_api::metadata_ir::StorageHasherIR] = + const HASHER_METADATA: &'static [sp_metadata_ir::StorageHasherIR] = &[for_tuples!( #(Tuple::Hasher::METADATA),* )]; fn final_key + TupleToEncodedIter>(key: KArg) -> Vec { diff --git a/frame/support/src/storage/types/map.rs b/frame/support/src/storage/types/map.rs index ba5536617c6ee..816b90162f644 100644 --- a/frame/support/src/storage/types/map.rs +++ b/frame/support/src/storage/types/map.rs @@ -27,8 +27,8 @@ use crate::{ StorageHasher, Twox128, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; -use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; +use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_std::prelude::*; /// A type that allow to store value for given key. Allowing to insert/remove/iterate on values. @@ -513,8 +513,8 @@ mod test { hash::*, storage::{types::ValueQuery, IterableStorageMap}, }; - use sp_api::metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; struct Prefix; impl StorageInstance for Prefix { diff --git a/frame/support/src/storage/types/mod.rs b/frame/support/src/storage/types/mod.rs index c390d262288e3..c7f2557099b36 100644 --- a/frame/support/src/storage/types/mod.rs +++ b/frame/support/src/storage/types/mod.rs @@ -19,7 +19,7 @@ //! StorageMap and others. use codec::FullCodec; -use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; +use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; use sp_std::prelude::*; mod counted_map; diff --git a/frame/support/src/storage/types/nmap.rs b/frame/support/src/storage/types/nmap.rs index f3292a0c4ba54..e9a4b12dd43a1 100755 --- a/frame/support/src/storage/types/nmap.rs +++ b/frame/support/src/storage/types/nmap.rs @@ -29,7 +29,7 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInstance}, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; -use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; +use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_runtime::SaturatedConversion; use sp_std::prelude::*; @@ -622,8 +622,8 @@ mod test { hash::{StorageHasher as _, *}, storage::types::{Key as NMapKey, ValueQuery}, }; - use sp_api::metadata_ir::{StorageEntryModifierIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageHasherIR}; struct Prefix; impl StorageInstance for Prefix { diff --git a/frame/support/src/storage/types/value.rs b/frame/support/src/storage/types/value.rs index 150db08c38860..14be6bb402e38 100644 --- a/frame/support/src/storage/types/value.rs +++ b/frame/support/src/storage/types/value.rs @@ -26,8 +26,8 @@ use crate::{ traits::{GetDefault, StorageInfo, StorageInstance}, }; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; -use sp_api::metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_arithmetic::traits::SaturatedConversion; +use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_std::prelude::*; /// A type that allow to store a value. @@ -279,8 +279,8 @@ where mod test { use super::*; use crate::storage::types::ValueQuery; - use sp_api::metadata_ir::StorageEntryModifierIR; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::StorageEntryModifierIR; struct Prefix; impl StorageInstance for Prefix { diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index f92e0ea0e142c..43a93df9dea49 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -23,11 +23,11 @@ use frame_support::{ traits::ConstU32, }; use frame_system::pallet_prelude::BlockNumberFor; -use sp_api::metadata_ir::{ +use sp_core::sr25519; +use sp_metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR, }; -use sp_core::sr25519; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 75e9f56f75c07..a545735f2b1e8 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -17,7 +17,7 @@ use frame_support::traits::ConstU32; use scale_info::{form::MetaForm, meta_type}; -use sp_api::metadata_ir::{ +use sp_metadata_ir::{ RuntimeApiMetadataIR, RuntimeApiMethodMetadataIR, RuntimeApiMethodParamMetadataIR, }; use sp_runtime::traits::Block as BlockT; From 3816fc48e97a1eaabdf052758d5d41e9ab2d6421 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 16 Aug 2023 13:04:49 +0200 Subject: [PATCH 19/42] fix CI checks --- frame/paged-list/Cargo.toml | 3 ++- frame/support/src/tests/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/paged-list/Cargo.toml b/frame/paged-list/Cargo.toml index 441ffd4bf0ba8..d2b3db0080c33 100644 --- a/frame/paged-list/Cargo.toml +++ b/frame/paged-list/Cargo.toml @@ -38,7 +38,8 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std" + "sp-std/std", + "sp-metadata-ir/std" ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks"] diff --git a/frame/support/src/tests/mod.rs b/frame/support/src/tests/mod.rs index cb4b4e82418b1..5ba9aef7fad16 100644 --- a/frame/support/src/tests/mod.rs +++ b/frame/support/src/tests/mod.rs @@ -16,11 +16,11 @@ // limitations under the License. use super::*; -use crate::metadata_ir::{ +use sp_io::{MultiRemovalResults, TestExternalities}; +use sp_metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR, }; -use sp_io::{MultiRemovalResults, TestExternalities}; use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; pub use self::frame_system::{pallet_prelude::*, Config, Pallet}; From 32f74a6e5d050363ff03734f7ec4ea2c4159d63e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 16 Aug 2023 13:39:24 +0200 Subject: [PATCH 20/42] fix support tests --- Cargo.lock | 1 + frame/support/test/Cargo.toml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 71217708a3e1d..88220bc6ba0c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3025,6 +3025,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-state-machine", "sp-std", diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 8dcb501cc6cdf..f6b665b1c7b3b 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -27,6 +27,7 @@ sp-runtime = { version = "24.0.0", default-features = false, path = "../../../pr sp-core = { version = "21.0.0", default-features = false, path = "../../../primitives/core" } sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" } sp-version = { version = "22.0.0", default-features = false, path = "../../../primitives/version" } +sp-metadata-ir = { version = "0.1.0", default-features = false, path = "../../../primitives/metadata-ir" } trybuild = { version = "1.0.74", features = [ "diff" ] } pretty_assertions = "1.3.0" rustversion = "1.0.6" @@ -54,7 +55,8 @@ std = [ "sp-std/std", "sp-version/std", "test-pallet/std", - "sp-state-machine/std" + "sp-state-machine/std", + "sp-metadata-ir/std" ] experimental = ["frame-support/experimental"] try-runtime = [ From 7d7d73bea9132e704a1d8b3d335f8d81d9de16c5 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 16 Aug 2023 14:08:54 +0000 Subject: [PATCH 21/42] ".git/.scripts/commands/fmt/fmt.sh" --- frame/support/src/storage/types/counted_map.rs | 2 +- frame/support/src/storage/types/counted_nmap.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index a5dd11fa7c84c..5b750a74098b8 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -515,8 +515,8 @@ mod test { storage::{bounded_vec::BoundedVec, types::ValueQuery}, traits::ConstU32, }; - use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; struct Prefix; impl StorageInstance for Prefix { diff --git a/frame/support/src/storage/types/counted_nmap.rs b/frame/support/src/storage/types/counted_nmap.rs index c7a5cd298374d..7dbcb74f00053 100644 --- a/frame/support/src/storage/types/counted_nmap.rs +++ b/frame/support/src/storage/types/counted_nmap.rs @@ -638,8 +638,8 @@ mod test { hash::{StorageHasher as _, *}, storage::types::{Key as NMapKey, ValueQuery}, }; - use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; use sp_io::{hashing::twox_128, TestExternalities}; + use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; struct Prefix; impl StorageInstance for Prefix { From 86ddd81927c32561b54ddade2d3f23148e2087d1 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 17 Aug 2023 10:03:55 +0200 Subject: [PATCH 22/42] Update frame/support/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/support/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 6df8f29ec736a..a031f70f9ea45 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -32,6 +32,9 @@ /// Export ourself as `frame_support` to make tests happy. extern crate self as frame_support; +/// Private exports that are being used by macros. +/// +/// The exports are not stable and should not be relied on. #[doc(hidden)] pub mod __private { pub use codec; From 5d00dfdeb4ee54e53068cd2ce704d4fb0e1a110e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 17 Aug 2023 10:43:01 +0200 Subject: [PATCH 23/42] import codec directly --- frame/session/benchmarking/Cargo.toml | 1 + frame/session/benchmarking/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/session/benchmarking/Cargo.toml b/frame/session/benchmarking/Cargo.toml index a26cacc561e82..81e4c2ff590b1 100644 --- a/frame/session/benchmarking/Cargo.toml +++ b/frame/session/benchmarking/Cargo.toml @@ -13,6 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } rand = { version = "0.8.5", default-features = false, features = ["std_rng"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index b6a426b7a860c..cd78fbae34ede 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -34,7 +34,7 @@ use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, MaxNominationsOf, RewardDestination, }; -use sp_runtime::codec::Decode; +use codec::Decode; const MAX_VALIDATORS: u32 = 1000; From a6a4e3dadde6d9c4f18774c2c7a719f317633b0e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 17 Aug 2023 11:58:48 +0200 Subject: [PATCH 24/42] fmt --- frame/session/benchmarking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index cd78fbae34ede..722bb14fb56ed 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -26,6 +26,7 @@ mod mock; use sp_runtime::traits::{One, StaticLookup, TrailingZeroInput}; use sp_std::{prelude::*, vec}; +use codec::Decode; use frame_benchmarking::v1::benchmarks; use frame_support::traits::{Get, KeyOwnerProofSystem, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; @@ -34,7 +35,6 @@ use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, MaxNominationsOf, RewardDestination, }; -use codec::Decode; const MAX_VALIDATORS: u32 = 1000; From d32e625261a0ce088b45297f5c2431243e39aabb Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 17 Aug 2023 12:32:52 +0200 Subject: [PATCH 25/42] wip --- frame/benchmarking/src/lib.rs | 37 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 8864cd1d88ddf..981ac426bcd60 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -29,26 +29,25 @@ mod utils; pub mod baseline; -#[cfg(feature = "std")] -pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector}; -#[doc(hidden)] -pub use frame_support; -#[doc(hidden)] -pub use log; -#[doc(hidden)] -pub use paste; -#[doc(hidden)] -pub use sp_core::defer; -#[doc(hidden)] -pub use sp_io::storage::root as storage_root; -#[doc(hidden)] -pub use sp_runtime::traits::Zero; -#[doc(hidden)] -pub use sp_runtime::StateVersion; +/// Private exports that are being used by macros. +/// +/// The exports are not stable and should not be relied on. #[doc(hidden)] -pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; -pub use sp_storage::{well_known_keys, TrackedStorageKey}; -pub use utils::*; +pub mod __private { + #[cfg(feature = "std")] + pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector}; + pub use codec::{ Decode, Encode }; + pub use frame_support; + pub use log; + pub use paste; + pub use sp_core::defer; + pub use sp_io::storage::root as storage_root; + pub use sp_runtime::traits::Zero; + pub use sp_runtime::StateVersion ; + pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; + pub use sp_storage::{well_known_keys, TrackedStorageKey}; + pub use utils::*; +} pub mod v1; pub use v1::*; From 5eb43f1ae7398d74f28dd23aedb1acc9880ac5ea Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 17 Aug 2023 17:03:35 +0200 Subject: [PATCH 26/42] wip --- frame/benchmarking/src/baseline.rs | 1 - frame/benchmarking/src/lib.rs | 15 ++-- frame/benchmarking/src/v1.rs | 122 ++++++++++++++--------------- frame/fast-unstake/src/mock.rs | 2 +- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 94c066269d91b..c56a3447dbb4d 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -20,7 +20,6 @@ #![cfg(feature = "runtime-benchmarks")] -use super::*; use crate::benchmarks; use frame_system::Pallet as System; use sp_runtime::{ diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 981ac426bcd60..52589ef3955c9 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -28,28 +28,27 @@ mod tests_instance; mod utils; pub mod baseline; +pub mod v1; /// Private exports that are being used by macros. /// /// The exports are not stable and should not be relied on. #[doc(hidden)] pub mod __private { - #[cfg(feature = "std")] - pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector}; - pub use codec::{ Decode, Encode }; - pub use frame_support; + pub use codec::{Decode, Encode}; + pub use frame_support::{storage, traits}; pub use log; pub use paste; pub use sp_core::defer; pub use sp_io::storage::root as storage_root; - pub use sp_runtime::traits::Zero; - pub use sp_runtime::StateVersion ; + pub use sp_runtime::{traits::Zero, StateVersion}; pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; pub use sp_storage::{well_known_keys, TrackedStorageKey}; - pub use utils::*; } -pub mod v1; +#[cfg(feature = "std")] +pub use analysis::{Analysis, AnalysisChoice, BenchmarkSelector}; +pub use utils::*; pub use v1::*; /// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax. diff --git a/frame/benchmarking/src/v1.rs b/frame/benchmarking/src/v1.rs index c8c50515c0a04..f1313555a241b 100644 --- a/frame/benchmarking/src/v1.rs +++ b/frame/benchmarking/src/v1.rs @@ -446,17 +446,17 @@ macro_rules! benchmarks_iter { >:: [< new_call_variant_ $dispatch >] ( $($arg),* ); - let __benchmarked_call_encoded = $crate::frame_support::__private::codec::Encode::encode( + let __benchmarked_call_encoded = $crate::__private::codec::Encode::encode( &__call ); }: { let __call_decoded = < Call - as $crate::frame_support::__private::codec::Decode + as $crate::__private::codec::Decode >::decode(&mut &__benchmarked_call_encoded[..]) .expect("call is encoded above, encoding must be correct"); let __origin = $crate::to_origin!($origin $(, $origin_type)?); - as $crate::frame_support::traits::UnfilteredDispatchable + as $crate::traits::UnfilteredDispatchable >::dispatch_bypass_filter(__call_decoded, __origin)?; } verify $postcode @@ -776,8 +776,8 @@ macro_rules! benchmark_backend { $crate::BenchmarkingSetup for $name where $( $where_clause )* { - fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { - $crate::vec! [ + fn components(&self) -> $crate::__private::Vec<($crate::BenchmarkParameter, u32, u32)> { + $crate::__private::vec! [ $( ($crate::BenchmarkParameter::$param, $param_from, $param_to) ),* @@ -788,7 +788,7 @@ macro_rules! benchmark_backend { &self, components: &[($crate::BenchmarkParameter, u32)], verify: bool - ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { + ) -> Result<$crate::__private::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { $( // Prepare instance let $param = components.iter() @@ -802,7 +802,7 @@ macro_rules! benchmark_backend { $( $param_instancer ; )* $( $post )* - Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkError> { + Ok($crate::__private::Box::new(move || -> Result<(), $crate::BenchmarkError> { $eval; if verify { $postcode; @@ -842,15 +842,15 @@ macro_rules! impl_bench_name_tests { { $( $names_extra:tt )* }, { $name:ident } ) => { - $crate::paste::paste! { + $crate::__private::paste::paste! { #[test] fn [] () { $new_test_exec.$exec_name(|| { // Skip all #[extra] benchmarks if $extra is false. if !($extra) { - let disabled = $crate::vec![ $( stringify!($names_extra).as_ref() ),* ]; + let disabled = $crate::__private::vec![ $( stringify!($names_extra).as_ref() ),* ]; if disabled.contains(&stringify!($name)) { - $crate::log::error!( + $crate::__private::log::error!( "INFO: extra benchmark skipped - {}", stringify!($name), ); @@ -873,21 +873,21 @@ macro_rules! impl_bench_name_tests { }, $crate::BenchmarkError::Override(_) => { // This is still considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error overrided - {}", stringify!($name), ); }, $crate::BenchmarkError::Skip => { // This is considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error skipped - {}", stringify!($name), ); }, $crate::BenchmarkError::Weightless => { // This is considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark weightless skipped - {}", stringify!($name), ); @@ -948,7 +948,7 @@ macro_rules! selected_benchmark { $crate::BenchmarkingSetup for SelectedBenchmark where $( $where_clause )* { - fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { + fn components(&self) -> $crate::__private::Vec<($crate::BenchmarkParameter, u32, u32)> { match self { $( Self::$bench => < @@ -962,7 +962,7 @@ macro_rules! selected_benchmark { &self, components: &[($crate::BenchmarkParameter, u32)], verify: bool - ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { + ) -> Result<$crate::__private::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { match self { $( Self::$bench => < @@ -992,19 +992,19 @@ macro_rules! impl_benchmark { $crate::Benchmarking for Pallet where T: frame_system::Config, $( $where_clause )* { - fn benchmarks(extra: bool) -> $crate::Vec<$crate::BenchmarkMetadata> { + fn benchmarks(extra: bool) -> $crate::__private::Vec<$crate::BenchmarkMetadata> { $($crate::validate_pov_mode!( $pov_name: $( $storage = $pov_mode )*; );)* - let mut all_names = $crate::vec![ $( stringify!($name).as_ref() ),* ]; + let mut all_names = $crate::__private::vec![ $( stringify!($name).as_ref() ),* ]; if !extra { let extra = [ $( stringify!($name_extra).as_ref() ),* ]; all_names.retain(|x| !extra.contains(x)); } - let pov_modes: $crate::Vec<($crate::Vec, $crate::Vec<($crate::Vec, $crate::Vec)>)> = $crate::vec![ + let pov_modes: $crate::__private::Vec<($crate::__private::Vec, $crate::__private::Vec<($crate::__private::Vec, $crate::__private::Vec)>)> = $crate::__private::vec![ $( (stringify!($pov_name).as_bytes().to_vec(), - $crate::vec![ + $crate::__private::vec![ $( ( stringify!($storage).as_bytes().to_vec(), stringify!($pov_mode).as_bytes().to_vec() ), )* ]), @@ -1025,18 +1025,18 @@ macro_rules! impl_benchmark { components, pov_modes: pov_modes.iter().find(|p| p.0 == name).map(|p| p.1.clone()).unwrap_or_default(), } - }).collect::<$crate::Vec<_>>() + }).collect::<$crate::__private::Vec<_>>() } fn run_benchmark( extrinsic: &[u8], c: &[($crate::BenchmarkParameter, u32)], - whitelist: &[$crate::TrackedStorageKey], + whitelist: &[$crate::__private::TrackedStorageKey], verify: bool, internal_repeats: u32, - ) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> { + ) -> Result<$crate::__private::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> { // Map the input to the selected benchmark. - let extrinsic = $crate::str::from_utf8(extrinsic) + let extrinsic = $crate::__private::str::from_utf8(extrinsic) .map_err(|_| "`extrinsic` is not a valid utf8 string!")?; let selected_benchmark = match extrinsic { $( stringify!($name) => SelectedBenchmark::$name, )* @@ -1046,34 +1046,34 @@ macro_rules! impl_benchmark { // Add whitelist to DB including whitelisted caller let mut whitelist = whitelist.to_vec(); let whitelisted_caller_key = - as $crate::frame_support::storage::StorageMap<_,_>>::hashed_key_for( + as $crate::__private::storage::StorageMap<_,_>>::hashed_key_for( $crate::whitelisted_caller::() ); whitelist.push(whitelisted_caller_key.into()); // Whitelist the transactional layer. - let transactional_layer_key = $crate::TrackedStorageKey::new( - $crate::frame_support::storage::transactional::TRANSACTION_LEVEL_KEY.into() + let transactional_layer_key = $crate::__private::TrackedStorageKey::new( + $crate::__private::storage::transactional::TRANSACTION_LEVEL_KEY.into() ); whitelist.push(transactional_layer_key); // Whitelist the `:extrinsic_index`. - let extrinsic_index = $crate::TrackedStorageKey::new( - $crate::well_known_keys::EXTRINSIC_INDEX.into() + let extrinsic_index = $crate::__private::TrackedStorageKey::new( + $crate::__private::well_known_keys::EXTRINSIC_INDEX.into() ); whitelist.push(extrinsic_index); // Whitelist the `:intrablock_entropy`. - let intrablock_entropy = $crate::TrackedStorageKey::new( - $crate::well_known_keys::INTRABLOCK_ENTROPY.into() + let intrablock_entropy = $crate::__private::TrackedStorageKey::new( + $crate::__private::well_known_keys::INTRABLOCK_ENTROPY.into() ); whitelist.push(intrablock_entropy); $crate::benchmarking::set_whitelist(whitelist.clone()); - let mut results: $crate::Vec<$crate::BenchmarkResult> = $crate::Vec::new(); + let mut results: $crate::__private::Vec<$crate::BenchmarkResult> = $crate::__private::Vec::new(); // Always do at least one internal repeat... for _ in 0 .. internal_repeats.max(1) { // Always reset the state after the benchmark. - $crate::defer!($crate::benchmarking::wipe_db()); + $crate::__private::defer!($crate::benchmarking::wipe_db()); // Set up the externalities environment for the setup we want to // benchmark. @@ -1082,7 +1082,7 @@ macro_rules! impl_benchmark { >::instance(&selected_benchmark, c, verify)?; // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + if $crate::__private::Zero::is_zero(&frame_system::Pallet::::block_number()) { frame_system::Pallet::::set_block_number(1u32.into()); } @@ -1093,14 +1093,14 @@ macro_rules! impl_benchmark { // Access all whitelisted keys to get them into the proof recorder since the // recorder does now have a whitelist. for key in &whitelist { - $crate::frame_support::storage::unhashed::get_raw(&key.key); + $crate::__private::storage::unhashed::get_raw(&key.key); } // Reset the read/write counter so we don't count operations in the setup process. $crate::benchmarking::reset_read_write_count(); // Time the extrinsic logic. - $crate::log::trace!( + $crate::__private::log::trace!( target: "benchmark", "Start Benchmark: {} ({:?}) verify {}", extrinsic, @@ -1125,29 +1125,29 @@ macro_rules! impl_benchmark { // Commit the changes to get proper write count $crate::benchmarking::commit_db(); - $crate::log::trace!( + $crate::__private::log::trace!( target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic ); let read_write_count = $crate::benchmarking::read_write_count(); - $crate::log::trace!( + $crate::__private::log::trace!( target: "benchmark", "Read/Write Count {:?}", read_write_count ); - $crate::log::trace!( + $crate::__private::log::trace!( target: "benchmark", "Proof sizes: before {:?} after {:?} diff {}", &start_pov, &end_pov, &diff_pov ); // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); - $crate::storage_root($crate::StateVersion::V1); + $crate::__private::storage_root($crate::__private::StateVersion::V1); let finish_storage_root = $crate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; let skip_meta = [ $( stringify!($name_skip_meta).as_ref() ),* ]; let read_and_written_keys = if skip_meta.contains(&extrinsic) { - $crate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] + $crate::__private::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] } else { $crate::benchmarking::get_read_and_written_keys() }; @@ -1185,7 +1185,7 @@ macro_rules! impl_benchmark { /// author chooses not to implement benchmarks. #[allow(unused)] fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkError> { - let name = $crate::str::from_utf8(name) + let name = $crate::__private::str::from_utf8(name) .map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; match name { $( stringify!($name) => { @@ -1225,10 +1225,10 @@ macro_rules! impl_benchmark_test { >::components(&selected_benchmark); let execute_benchmark = | - c: $crate::Vec<($crate::BenchmarkParameter, u32)> + c: $crate::__private::Vec<($crate::BenchmarkParameter, u32)> | -> Result<(), $crate::BenchmarkError> { // Always reset the state after the benchmark. - $crate::defer!($crate::benchmarking::wipe_db()); + $crate::__private::defer!($crate::benchmarking::wipe_db()); // Set up the benchmark, return execution + verification function. let closure_to_verify = < @@ -1266,7 +1266,7 @@ macro_rules! impl_benchmark_test { // and up to num_values-2 more equidistant values in between. // For 0..10 and num_values=6 this would mean: [0, 2, 4, 6, 8, 10] - let mut values = $crate::vec![low]; + let mut values = $crate::__private::vec![low]; let diff = (high - low).min(num_values - 1); let slope = (high - low) as f32 / diff as f32; @@ -1278,7 +1278,7 @@ macro_rules! impl_benchmark_test { for component_value in values { // Select the max value for all the other components. - let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components + let c: $crate::__private::Vec<($crate::BenchmarkParameter, u32)> = components .iter() .map(|(n, _, h)| if *n == name { @@ -1684,7 +1684,7 @@ macro_rules! impl_test_function { Err(err) => { println!( "{}: {:?}", - $crate::str::from_utf8(benchmark_name) + $crate::__private::str::from_utf8(benchmark_name) .expect("benchmark name is always a valid string!"), err, ); @@ -1695,7 +1695,7 @@ macro_rules! impl_test_function { $crate::BenchmarkError::Stop(err) => { println!( "{}: {:?}", - $crate::str::from_utf8(benchmark_name) + $crate::__private::str::from_utf8(benchmark_name) .expect("benchmark name is always a valid string!"), err, ); @@ -1703,25 +1703,25 @@ macro_rules! impl_test_function { }, $crate::BenchmarkError::Override(_) => { // This is still considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error overrided - {}", - $crate::str::from_utf8(benchmark_name) + $crate::__private::str::from_utf8(benchmark_name) .expect("benchmark name is always a valid string!"), ); }, $crate::BenchmarkError::Skip => { // This is considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error skipped - {}", - $crate::str::from_utf8(benchmark_name) + $crate::__private::str::from_utf8(benchmark_name) .expect("benchmark name is always a valid string!"), ); } $crate::BenchmarkError::Weightless => { // This is considered a success condition. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark weightless skipped - {}", - $crate::str::from_utf8(benchmark_name) + $crate::__private::str::from_utf8(benchmark_name) .expect("benchmark name is always a valid string!"), ); } @@ -1850,13 +1850,13 @@ macro_rules! add_benchmark { Ok(results) => Some(results), Err($crate::BenchmarkError::Override(mut result)) => { // Insert override warning as the first storage key. - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error overrided - {}", - $crate::str::from_utf8(benchmark) + $crate::__private::str::from_utf8(benchmark) .expect("benchmark name is always a valid string!") ); result.keys.insert(0, (b"Benchmark Override".to_vec(), 0, 0, false)); - Some($crate::vec![result]) + Some($crate::__private::vec![result]) }, Err($crate::BenchmarkError::Stop(e)) => { $crate::show_benchmark_debug_info( @@ -1869,20 +1869,20 @@ macro_rules! add_benchmark { return Err(e.into()) }, Err($crate::BenchmarkError::Skip) => { - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark error skipped - {}", - $crate::str::from_utf8(benchmark) + $crate::__private::str::from_utf8(benchmark) .expect("benchmark name is always a valid string!") ); None }, Err($crate::BenchmarkError::Weightless) => { - $crate::log::error!( + $crate::__private::log::error!( "WARNING: benchmark weightless skipped - {}", - $crate::str::from_utf8(benchmark) + $crate::__private::str::from_utf8(benchmark) .expect("benchmark name is always a valid string!") ); - Some(vec![$crate::BenchmarkResult { + Some($crate::__private::vec![$crate::BenchmarkResult { components: selected_components.clone(), ..Default::default() }]) diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 3a3d9e2d4b133..dc24a823c0db0 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -16,8 +16,8 @@ // limitations under the License. use crate::{self as fast_unstake}; -use frame_benchmarking::frame_support::assert_ok; use frame_support::{ + assert_ok, pallet_prelude::*, parameter_types, traits::{ConstU64, Currency}, From b09e9136ddb4529af97d162eee20b356c9ff76d7 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 13:07:47 +0200 Subject: [PATCH 27/42] remove benchmarking private exports --- Cargo.lock | 2 + frame/benchmarking/src/lib.rs | 2 +- frame/benchmarking/src/v1.rs | 10 +-- .../src/unsigned.rs | 3 +- .../benchmarking/Cargo.toml | 2 + .../benchmarking/src/lib.rs | 3 +- frame/support/procedural/src/benchmark.rs | 73 +++++++++---------- frame/timestamp/Cargo.toml | 1 + frame/timestamp/src/benchmarking.rs | 3 +- 9 files changed, 52 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88220bc6ba0c6..6afe6184490ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6695,6 +6695,7 @@ dependencies = [ "parity-scale-codec", "sp-npos-elections", "sp-runtime", + "sp-std", ] [[package]] @@ -7688,6 +7689,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-storage", "sp-timestamp", ] diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 52589ef3955c9..8fc0162311276 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -35,7 +35,7 @@ pub mod v1; /// The exports are not stable and should not be relied on. #[doc(hidden)] pub mod __private { - pub use codec::{Decode, Encode}; + pub use codec; pub use frame_support::{storage, traits}; pub use log; pub use paste; diff --git a/frame/benchmarking/src/v1.rs b/frame/benchmarking/src/v1.rs index f1313555a241b..b9cf82e7326ba 100644 --- a/frame/benchmarking/src/v1.rs +++ b/frame/benchmarking/src/v1.rs @@ -429,7 +429,7 @@ macro_rules! benchmarks_iter { verify $postcode:block $( $rest:tt )* ) => { - $crate::paste::paste! { + $crate::__private::paste::paste! { $crate::benchmarks_iter! { { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } { $( $instance: $instance_bound )? } @@ -456,7 +456,7 @@ macro_rules! benchmarks_iter { >::decode(&mut &__benchmarked_call_encoded[..]) .expect("call is encoded above, encoding must be correct"); let __origin = $crate::to_origin!($origin $(, $origin_type)?); - as $crate::traits::UnfilteredDispatchable + as $crate::__private::traits::UnfilteredDispatchable >::dispatch_bypass_filter(__call_decoded, __origin)?; } verify $postcode @@ -1189,7 +1189,7 @@ macro_rules! impl_benchmark { .map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; match name { $( stringify!($name) => { - $crate::paste::paste! { Self::[< test_benchmark_ $name >]() } + $crate::__private::paste::paste! { Self::[< test_benchmark_ $name >]() } } )* _ => Err("Could not find test for requested benchmark.".into()), } @@ -1211,7 +1211,7 @@ macro_rules! impl_benchmark_test { { $( $instance:ident: $instance_bound:tt )? } $name:ident ) => { - $crate::paste::item! { + $crate::__private::paste::item! { #[cfg(test)] impl, $instance: $instance_bound )? > Pallet @@ -1236,7 +1236,7 @@ macro_rules! impl_benchmark_test { >::instance(&selected_benchmark, &c, true)?; // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + if $crate::__private::Zero::is_zero(&frame_system::Pallet::::block_number()) { frame_system::Pallet::::set_block_number(1u32.into()); } diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 5eeac26fb1323..af8f632f8a9e3 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -983,14 +983,13 @@ mod tests { TransactionValidityError, }; use codec::Decode; - use frame_benchmarking::Zero; use frame_election_provider_support::IndexAssignment; use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::OffchainWorker}; use sp_npos_elections::ElectionScore; use sp_runtime::{ bounded_vec, offchain::storage_lock::{BlockAndTime, StorageLock}, - traits::ValidateUnsigned, + traits::{ValidateUnsigned, Zero}, ModuleError, PerU16, Perbill, }; diff --git a/frame/election-provider-support/benchmarking/Cargo.toml b/frame/election-provider-support/benchmarking/Cargo.toml index 2614c61d4352d..3d7006074b5ea 100644 --- a/frame/election-provider-support/benchmarking/Cargo.toml +++ b/frame/election-provider-support/benchmarking/Cargo.toml @@ -20,6 +20,7 @@ frame-election-provider-support = { version = "4.0.0-dev", default-features = fa frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/npos-elections" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" } [features] default = ["std"] @@ -30,6 +31,7 @@ std = [ "frame-system/std", "sp-npos-elections/std", "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/frame/election-provider-support/benchmarking/src/lib.rs b/frame/election-provider-support/benchmarking/src/lib.rs index 774b7036fd413..6c75aed0a911d 100644 --- a/frame/election-provider-support/benchmarking/src/lib.rs +++ b/frame/election-provider-support/benchmarking/src/lib.rs @@ -22,8 +22,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Decode; -use frame_benchmarking::v1::{benchmarks, Vec}; +use frame_benchmarking::v1::benchmarks; use frame_election_provider_support::{NposSolver, PhragMMS, SequentialPhragmen}; +use sp_std::vec::Vec; pub struct Pallet(frame_system::Pallet); pub trait Config: frame_system::Config {} diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 5a5bafa0929c6..6f8f1d155e1e5 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -419,7 +419,6 @@ pub fn benchmarks( }; let krate = generate_crate_access_2018("frame-benchmarking")?; - let support = quote!(#krate::frame_support); // benchmark name variables let benchmark_names_str: Vec = benchmark_names.iter().map(|n| n.to_string()).collect(); @@ -456,7 +455,7 @@ pub fn benchmarks( } impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics> for SelectedBenchmark where #where_clause { - fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> { + fn components(&self) -> #krate::__private::Vec<(#krate::BenchmarkParameter, u32, u32)> { match self { #( Self::#benchmark_names => { @@ -472,7 +471,7 @@ pub fn benchmarks( components: &[(#krate::BenchmarkParameter, u32)], verify: bool, ) -> Result< - #krate::Box Result<(), #krate::BenchmarkError>>, + #krate::__private::Box Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError, > { match self { @@ -493,8 +492,8 @@ pub fn benchmarks( { fn benchmarks( extra: bool, - ) -> #krate::Vec<#krate::BenchmarkMetadata> { - let mut all_names = #krate::vec![ + ) -> #krate::__private::Vec<#krate::BenchmarkMetadata> { + let mut all_names = #krate::__private::vec![ #(#benchmark_names_str), * ]; @@ -519,17 +518,17 @@ pub fn benchmarks( // https://github.com/paritytech/substrate/issues/13132 pov_modes: vec![], } - }).collect::<#krate::Vec<_>>() + }).collect::<#krate::__private::Vec<_>>() } fn run_benchmark( extrinsic: &[u8], c: &[(#krate::BenchmarkParameter, u32)], - whitelist: &[#krate::TrackedStorageKey], + whitelist: &[#krate::__private::TrackedStorageKey], verify: bool, internal_repeats: u32, - ) -> Result<#krate::Vec<#krate::BenchmarkResult>, #krate::BenchmarkError> { - let extrinsic = #krate::str::from_utf8(extrinsic).map_err(|_| "`extrinsic` is not a valid utf-8 string!")?; + ) -> Result<#krate::__private::Vec<#krate::BenchmarkResult>, #krate::BenchmarkError> { + let extrinsic = #krate::__private::str::from_utf8(extrinsic).map_err(|_| "`extrinsic` is not a valid utf-8 string!")?; let selected_benchmark = match extrinsic { #(#selected_benchmark_mappings), *, @@ -538,32 +537,32 @@ pub fn benchmarks( let mut whitelist = whitelist.to_vec(); let whitelisted_caller_key = as #support::storage::StorageMap<_, _,>>::hashed_key_for( + > as #krate::__private::storage::StorageMap<_, _,>>::hashed_key_for( #krate::whitelisted_caller::() ); whitelist.push(whitelisted_caller_key.into()); - let transactional_layer_key = #krate::TrackedStorageKey::new( - #support::storage::transactional::TRANSACTION_LEVEL_KEY.into(), + let transactional_layer_key = #krate::__private::TrackedStorageKey::new( + #krate::__private::storage::transactional::TRANSACTION_LEVEL_KEY.into(), ); whitelist.push(transactional_layer_key); // Whitelist the `:extrinsic_index`. - let extrinsic_index = #krate::TrackedStorageKey::new( - #krate::well_known_keys::EXTRINSIC_INDEX.into() + let extrinsic_index = #krate::__private::TrackedStorageKey::new( + #krate::__private::well_known_keys::EXTRINSIC_INDEX.into() ); whitelist.push(extrinsic_index); // Whitelist the `:intrablock_entropy`. - let intrablock_entropy = #krate::TrackedStorageKey::new( - #krate::well_known_keys::INTRABLOCK_ENTROPY.into() + let intrablock_entropy = #krate::__private::TrackedStorageKey::new( + #krate::__private::well_known_keys::INTRABLOCK_ENTROPY.into() ); whitelist.push(intrablock_entropy); #krate::benchmarking::set_whitelist(whitelist.clone()); - let mut results: #krate::Vec<#krate::BenchmarkResult> = #krate::Vec::new(); + let mut results: #krate::__private::Vec<#krate::BenchmarkResult> = #krate::__private::Vec::new(); // Always do at least one internal repeat... for _ in 0 .. internal_repeats.max(1) { // Always reset the state after the benchmark. - #krate::defer!(#krate::benchmarking::wipe_db()); + #krate::__private::defer!(#krate::benchmarking::wipe_db()); // Set up the externalities environment for the setup we want to // benchmark. @@ -572,7 +571,7 @@ pub fn benchmarks( >::instance(&selected_benchmark, c, verify)?; // Set the block number to at least 1 so events are deposited. - if #krate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + if #krate::__private::Zero::is_zero(&frame_system::Pallet::::block_number()) { frame_system::Pallet::::set_block_number(1u32.into()); } @@ -583,14 +582,14 @@ pub fn benchmarks( // Access all whitelisted keys to get them into the proof recorder since the // recorder does now have a whitelist. for key in &whitelist { - #krate::frame_support::storage::unhashed::get_raw(&key.key); + #krate::__private::storage::unhashed::get_raw(&key.key); } // Reset the read/write counter so we don't count operations in the setup process. #krate::benchmarking::reset_read_write_count(); // Time the extrinsic logic. - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "Start Benchmark: {} ({:?})", extrinsic, @@ -614,25 +613,25 @@ pub fn benchmarks( // Commit the changes to get proper write count #krate::benchmarking::commit_db(); - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic ); let read_write_count = #krate::benchmarking::read_write_count(); - #krate::log::trace!( + #krate::__private::log::trace!( target: "benchmark", "Read/Write Count {:?}", read_write_count ); // Time the storage root recalculation. let start_storage_root = #krate::benchmarking::current_time(); - #krate::storage_root(#krate::StateVersion::V1); + #krate::__private::storage_root(#krate::__private::StateVersion::V1); let finish_storage_root = #krate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; let skip_meta = [ #(#skip_meta_benchmark_names_str),* ]; let read_and_written_keys = if skip_meta.contains(&extrinsic) { - #krate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] + #krate::__private::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] } else { #krate::benchmarking::get_read_and_written_keys() }; @@ -667,7 +666,7 @@ pub fn benchmarks( /// author chooses not to implement benchmarks. #[allow(unused)] fn test_bench_by_name(name: &[u8]) -> Result<(), #krate::BenchmarkError> { - let name = #krate::str::from_utf8(name) + let name = #krate::__private::str::from_utf8(name) .map_err(|_| -> #krate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; match name { #(#benchmarks_by_name_mappings), @@ -724,8 +723,8 @@ fn expand_benchmark( Ok(ident) => ident, Err(err) => return err.to_compile_error().into(), }; - let codec = quote!(#krate::frame_support::__private::codec); - let traits = quote!(#krate::frame_support::traits); + let codec = quote!(#krate::__private::codec); + let traits = quote!(#krate::__private::traits); let setup_stmts = benchmark_def.setup_stmts; let verify_stmts = benchmark_def.verify_stmts; let last_stmt = benchmark_def.last_stmt; @@ -894,8 +893,8 @@ fn expand_benchmark( #[allow(unused_variables)] impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics> for #name where #where_clause { - fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> { - #krate::vec! [ + fn components(&self) -> #krate::__private::Vec<(#krate::BenchmarkParameter, u32, u32)> { + #krate::__private::vec! [ #( (#krate::BenchmarkParameter::#param_ranges) ),* @@ -906,7 +905,7 @@ fn expand_benchmark( &self, components: &[(#krate::BenchmarkParameter, u32)], verify: bool - ) -> Result<#krate::Box Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError> { + ) -> Result<#krate::__private::Box Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError> { #( // prepare instance #param_names let #param_names = components.iter() @@ -920,7 +919,7 @@ fn expand_benchmark( #setup_stmts )* #pre_call - Ok(#krate::Box::new(move || -> Result<(), #krate::BenchmarkError> { + Ok(#krate::__private::Box::new(move || -> Result<(), #krate::BenchmarkError> { #post_call if verify { #( @@ -941,10 +940,10 @@ fn expand_benchmark( SelectedBenchmark as #krate::BenchmarkingSetup >::components(&selected_benchmark); let execute_benchmark = | - c: #krate::Vec<(#krate::BenchmarkParameter, u32)> + c: #krate::__private::Vec<(#krate::BenchmarkParameter, u32)> | -> Result<(), #krate::BenchmarkError> { // Always reset the state after the benchmark. - #krate::defer!(#krate::benchmarking::wipe_db()); + #krate::__private::defer!(#krate::benchmarking::wipe_db()); // Set up the benchmark, return execution + verification function. let closure_to_verify = < @@ -952,7 +951,7 @@ fn expand_benchmark( >::instance(&selected_benchmark, &c, true)?; // Set the block number to at least 1 so events are deposited. - if #krate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + if #krate::__private::Zero::is_zero(&frame_system::Pallet::::block_number()) { frame_system::Pallet::::set_block_number(1u32.into()); } @@ -985,7 +984,7 @@ fn expand_benchmark( return Err("The start of a `ParamRange` must be less than or equal to the end".into()); } - let mut values = #krate::vec![low]; + let mut values = #krate::__private::vec![low]; let diff = (high - low).min(num_values - 1); let slope = (high - low) as f32 / diff as f32; @@ -997,7 +996,7 @@ fn expand_benchmark( for component_value in values { // Select the max value for all the other components. - let c: #krate::Vec<(#krate::BenchmarkParameter, u32)> = components + let c: #krate::__private::Vec<(#krate::BenchmarkParameter, u32)> = components .iter() .map(|(n, _, h)| if *n == name { diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index c92fb6b75b1b9..ccdddf2055906 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -24,6 +24,7 @@ sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../ sp-io = { version = "23.0.0", default-features = false, optional = true, path = "../../primitives/io" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } +sp-storage = { version = "13.0.0", default-features = false, path = "../../primitives/storage" } sp-timestamp = { version = "4.0.0-dev", default-features = false, path = "../../primitives/timestamp" } [dev-dependencies] diff --git a/frame/timestamp/src/benchmarking.rs b/frame/timestamp/src/benchmarking.rs index 8a7febed4d12f..82dfdfa8b3120 100644 --- a/frame/timestamp/src/benchmarking.rs +++ b/frame/timestamp/src/benchmarking.rs @@ -20,9 +20,10 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::v1::{benchmarks, TrackedStorageKey}; +use frame_benchmarking::v1::benchmarks; use frame_support::{ensure, traits::OnFinalize}; use frame_system::RawOrigin; +use sp_storage::TrackedStorageKey; use crate::Pallet as Timestamp; From 50651b7c46635df17abbc00e1777c4abce4e7d61 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 13:19:52 +0200 Subject: [PATCH 28/42] fix zepter warning --- frame/timestamp/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index ccdddf2055906..9fe5ffb3706f8 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -42,6 +42,7 @@ std = [ "log/std", "scale-info/std", "sp-inherents/std", + "sp-storage/std", "sp-runtime/std", "sp-std/std", "sp-timestamp/std", From 6889b65651392a815c95881e08b32bfae7c607e8 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 13:53:04 +0200 Subject: [PATCH 29/42] fix imports --- frame/benchmarking/src/baseline.rs | 1 - frame/benchmarking/src/lib.rs | 2 +- frame/benchmarking/src/tests.rs | 1 - frame/benchmarking/src/tests_instance.rs | 1 - frame/nomination-pools/benchmarking/src/lib.rs | 10 ++++++---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index c56a3447dbb4d..eb18ef663cc9d 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -109,7 +109,6 @@ benchmarks! { #[cfg(test)] pub mod mock { - use super::*; use sp_runtime::{testing::H256, BuildStorage}; type AccountId = u64; diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 8fc0162311276..f79582d03e51c 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -42,7 +42,7 @@ pub mod __private { pub use sp_core::defer; pub use sp_io::storage::root as storage_root; pub use sp_runtime::{traits::Zero, StateVersion}; - pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; + pub use sp_std::{self, boxed::Box, str, vec, vec::Vec}; pub use sp_storage::{well_known_keys, TrackedStorageKey}; } diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 4b8339f65913d..e5bacbdb2361a 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -19,7 +19,6 @@ #![cfg(test)] -use super::*; use frame_support::{parameter_types, traits::ConstU32}; use sp_runtime::{ testing::H256, diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 822efa70a2597..f2c721c8114c4 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -19,7 +19,6 @@ #![cfg(test)] -use super::*; use frame_support::traits::ConstU32; use sp_runtime::{ testing::H256, diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index e757f66e725a0..45f0ca0ecfe6e 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -23,11 +23,12 @@ #[cfg(test)] mod mock; -use frame_benchmarking::v1::{ - account, frame_support::traits::Currency, vec, whitelist_account, Vec, -}; +use frame_benchmarking::v1::{account, whitelist_account}; use frame_election_provider_support::SortedListProvider; -use frame_support::{assert_ok, ensure, traits::Get}; +use frame_support::{ + assert_ok, ensure, + traits::{Currency, Get}, +}; use frame_system::RawOrigin as RuntimeOrigin; use pallet_nomination_pools::{ BalanceOf, BondExtra, BondedPoolInner, BondedPools, ClaimPermission, ClaimPermissions, @@ -41,6 +42,7 @@ use sp_runtime::{ Perbill, }; use sp_staking::{EraIndex, StakingInterface}; +use sp_std::{vec, vec::Vec}; // `frame_benchmarking::benchmarks!` macro needs this use pallet_nomination_pools::Call; From 024765e3b68382339670c8432299dacd973b649d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 15:29:48 +0200 Subject: [PATCH 30/42] partially fix node-cli tests --- frame/benchmarking/src/baseline.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index eb18ef663cc9d..6cd23ebe028a3 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -26,6 +26,7 @@ use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; +use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; From 0fcc322bb995619441b6eba27aa88555411f94ce Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 16:02:08 +0200 Subject: [PATCH 31/42] fix node-cli tests --- frame/asset-rate/src/benchmarking.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/asset-rate/src/benchmarking.rs b/frame/asset-rate/src/benchmarking.rs index 0e13697806043..12edcf5aee025 100644 --- a/frame/asset-rate/src/benchmarking.rs +++ b/frame/asset-rate/src/benchmarking.rs @@ -25,6 +25,7 @@ use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_system::RawOrigin; use sp_core::crypto::FromEntropy; +use sp_std::vec; /// Trait describing the factory function for the `AssetKind` parameter. pub trait AssetKindFactory { From fdb2be4ef369d3abdba98e75528966c9f358a666 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 16:47:57 +0200 Subject: [PATCH 32/42] fix node-cli build --- Cargo.lock | 3 +++ bin/node-template/pallets/template/Cargo.toml | 4 +++- bin/node-template/pallets/template/src/benchmarking.rs | 1 + bin/node-template/runtime/Cargo.toml | 1 + bin/node-template/runtime/src/lib.rs | 4 ++-- bin/node/runtime/Cargo.toml | 1 + bin/node/runtime/src/lib.rs | 3 ++- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6afe6184490ce..e49a1b6f70d81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4296,6 +4296,7 @@ dependencies = [ "sp-staking", "sp-statement-store", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", "static_assertions", @@ -5818,6 +5819,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", "substrate-wasm-builder", @@ -7672,6 +7674,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] diff --git a/bin/node-template/pallets/template/Cargo.toml b/bin/node-template/pallets/template/Cargo.toml index f468374c2ff9f..e751d104bb3b8 100644 --- a/bin/node-template/pallets/template/Cargo.toml +++ b/bin/node-template/pallets/template/Cargo.toml @@ -20,6 +20,7 @@ scale-info = { version = "2.5.0", default-features = false, features = ["derive" frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../../../../frame/benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/system" } +sp-std = { version = "8.0.0", default-features = false, path = "../../../../primitives/std" } [dev-dependencies] sp-core = { version = "21.0.0", path = "../../../../primitives/core" } @@ -36,7 +37,8 @@ std = [ "scale-info/std", "sp-core/std", "sp-io/std", - "sp-runtime/std" + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index 5a262417629c5..6c3cae6066b41 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -1,6 +1,7 @@ //! Benchmarking setup for pallet-template #![cfg(feature = "runtime-benchmarks")] use super::*; +use sp_std::vec; #[allow(unused)] use crate::Pallet as Template; diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 51e30187c9d63..2c5be4b10b126 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -36,6 +36,7 @@ sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../. sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" } sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" } sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" } +sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" } sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" } sp-version = { version = "22.0.0", default-features = false, path = "../../../primitives/version" } diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index c3375d2ee601a..216be9588bca1 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -531,8 +531,8 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey}; - + use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch}; + use sp_storage::TrackedStorageKey; use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index de0ec1a5489a8..d71986552ffbd 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -40,6 +40,7 @@ sp-std = { version = "8.0.0", default-features = false, path = "../../../primiti sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" } +sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" } sp-session = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/session" } sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" } sp-statement-store = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/statement-store" } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 927d520ef6d1d..0b9a1baf0b62f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2570,7 +2570,8 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch}; + use sp_storage::TrackedStorageKey; // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, From 8c725094c8ca5a9ab474bd59ae3283af24bfcbf9 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 16:59:06 +0200 Subject: [PATCH 33/42] fix zepter warning --- bin/node-template/runtime/Cargo.toml | 1 + bin/node/runtime/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 2c5be4b10b126..10242c27b3a5b 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -85,6 +85,7 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-std/std", + "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index d71986552ffbd..6199d65969610 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -190,6 +190,7 @@ std = [ "sp-core/std", "pallet-insecure-randomness-collective-flip/std", "sp-std/std", + "sp-storage/std", "pallet-session/std", "pallet-session-benchmarking?/std", "sp-api/std", From fb6f332a51824a5ea72eb74d8e802d0aed879d46 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 17:40:17 +0200 Subject: [PATCH 34/42] fix test --- frame/benchmarking/src/v1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/benchmarking/src/v1.rs b/frame/benchmarking/src/v1.rs index b9cf82e7326ba..4ad8cc0edd46c 100644 --- a/frame/benchmarking/src/v1.rs +++ b/frame/benchmarking/src/v1.rs @@ -1777,7 +1777,7 @@ pub fn show_benchmark_debug_info( /// For values that should be skipped entirely, we can just pass `key.into()`. For example: /// /// ``` -/// use frame_benchmarking::TrackedStorageKey; +/// use sp_storage::TrackedStorageKey; /// let whitelist: Vec = vec![ /// // Block Number /// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), From 713a8efe6779d8ceda8d790e293d93ba753427f6 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 18 Aug 2023 17:58:02 +0200 Subject: [PATCH 35/42] fix ui test --- .../number_of_pallets_exceeds_tuple_size.stderr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr index 55cef6704ee3f..75d0ce0546583 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr @@ -55,7 +55,9 @@ help: you might have meant to use the associated type | 38 | type PalletInfo = Self::PalletInfo; | ~~~~~~~~~~~~~~~~ -help: consider importing this trait +help: consider importing one of these items + | +1 + use frame_benchmarking::__private::traits::PalletInfo; | 1 + use frame_support::traits::PalletInfo; | From 0b429e20d0fcb01d260db4d538c083019c422fb4 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 23 Aug 2023 14:46:45 +0200 Subject: [PATCH 36/42] restructure dispatch macro related exports --- Cargo.lock | 1 - frame/alliance/src/lib.rs | 9 ++---- frame/assets/src/benchmarking.rs | 5 +-- frame/assets/src/lib.rs | 4 +-- frame/benchmarking/src/utils.rs | 8 ++--- frame/collective/src/lib.rs | 8 +++-- frame/contracts/src/exec.rs | 11 ++++--- frame/contracts/src/gas.rs | 6 ++-- frame/contracts/src/lib.rs | 9 ++---- frame/contracts/src/migration/v15.rs | 4 ++- frame/contracts/src/storage.rs | 3 +- frame/contracts/src/storage/meter.rs | 5 ++- frame/contracts/src/tests.rs | 4 +-- frame/contracts/src/wasm/mod.rs | 4 +-- frame/contracts/src/wasm/runtime.rs | 4 +-- frame/conviction-voting/src/lib.rs | 13 ++++++-- .../src/unsigned.rs | 4 +-- .../test-staking-e2e/src/mock.rs | 3 +- frame/lottery/src/lib.rs | 4 +-- frame/multisig/src/migrations.rs | 3 +- frame/nfts/runtime-api/Cargo.toml | 2 -- frame/nfts/runtime-api/src/lib.rs | 2 +- frame/nfts/src/benchmarking.rs | 3 +- frame/nfts/src/tests.rs | 6 ++-- frame/offences/src/migration.rs | 3 +- frame/proxy/src/lib.rs | 4 +-- frame/proxy/src/tests.rs | 3 +- frame/ranked-collective/src/benchmarking.rs | 2 +- frame/ranked-collective/src/lib.rs | 4 +-- frame/referenda/src/benchmarking.rs | 3 +- frame/referenda/src/tests.rs | 7 ++-- frame/scheduler/src/lib.rs | 8 ++--- frame/session/src/lib.rs | 4 +-- frame/staking/src/benchmarking.rs | 3 +- frame/staking/src/migrations.rs | 5 +-- frame/staking/src/pallet/mod.rs | 2 +- frame/state-trie-migration/src/lib.rs | 1 - .../src/construct_runtime/expand/call.rs | 12 +++---- .../procedural/src/pallet/expand/call.rs | 4 +-- frame/support/src/dispatch.rs | 32 ++++++++----------- frame/support/src/dispatch_context.rs | 8 ++--- frame/support/src/lib.rs | 7 ++-- frame/support/src/traits/tokens/currency.rs | 7 ++-- .../src/traits/tokens/currency/reservable.rs | 3 +- .../src/traits/tokens/fungible/regular.rs | 3 +- .../src/traits/tokens/fungibles/regular.rs | 3 +- .../support/src/traits/tokens/nonfungibles.rs | 4 +-- .../src/traits/tokens/nonfungibles_v2.rs | 4 +-- frame/support/src/traits/voting.rs | 4 +-- frame/support/test/tests/construct_runtime.rs | 8 ++--- frame/transaction-storage/src/lib.rs | 4 +-- frame/treasury/src/benchmarking.rs | 3 +- frame/uniques/src/benchmarking.rs | 3 +- frame/uniques/src/tests.rs | 3 +- frame/utility/src/tests.rs | 6 ++-- frame/vesting/src/lib.rs | 4 +-- frame/vesting/src/tests.rs | 3 +- 57 files changed, 136 insertions(+), 163 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b96a76a65597c..382dd15ea917c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7066,7 +7066,6 @@ dependencies = [ name = "pallet-nfts-runtime-api" version = "4.0.0-dev" dependencies = [ - "frame-support", "pallet-nfts", "parity-scale-codec", "sp-api", diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 1986354a0941c..627399f805b31 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -98,16 +98,13 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::{ - traits::{Saturating, StaticLookup, Zero}, - RuntimeDebug, + traits::{Dispatchable, Saturating, StaticLookup, Zero}, + DispatchError, RuntimeDebug, }; use sp_std::{convert::TryInto, prelude::*}; use frame_support::{ - dispatch::{ - DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, - PostDispatchInfo, - }, + dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, ensure, traits::{ ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced, diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 376f19139ab9b..c9b0825542de7 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -23,10 +23,7 @@ use super::*; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; -use frame_support::{ - dispatch::UnfilteredDispatchable, - traits::{EnsureOrigin, Get}, -}; +use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::traits::Bounded; use sp_std::prelude::*; diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 363a99701b56a..79e4fe3001872 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -160,12 +160,12 @@ pub use types::*; use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero}, - ArithmeticError, TokenError, + ArithmeticError, DispatchError, TokenError, }; use sp_std::prelude::*; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, ensure, pallet_prelude::DispatchResultWithPostInfo, storage::KeyPrefixIterator, diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 59e5192b427b0..b9b3f91e2dd7b 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -17,16 +17,12 @@ //! Interfaces, types and utils for benchmarking a FRAME runtime. use codec::{Decode, Encode}; -use frame_support::{ - dispatch::{DispatchError, DispatchErrorWithPostInfo}, - pallet_prelude::*, - traits::StorageInfo, -}; +use frame_support::{dispatch::DispatchErrorWithPostInfo, pallet_prelude::*, traits::StorageInfo}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_io::hashing::blake2_256; -use sp_runtime::traits::TrailingZeroInput; +use sp_runtime::{traits::TrailingZeroInput, DispatchError}; use sp_std::{prelude::Box, vec::Vec}; use sp_storage::TrackedStorageKey; diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index ac6ad39eac5a4..10f989e5c4cc6 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -45,13 +45,15 @@ use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_io::storage; -use sp_runtime::{traits::Hash, RuntimeDebug}; +use sp_runtime::{ + traits::{Dispatchable, Hash}, + DispatchError, RuntimeDebug, +}; use sp_std::{marker::PhantomData, prelude::*, result}; use frame_support::{ dispatch::{ - DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, - Pays, PostDispatchInfo, + DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, Pays, PostDispatchInfo, }, ensure, impl_ensure_origin_with_arg_ignoring_arg, traits::{ diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index a4d0760e6c0ac..c5ef106ebe708 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -26,9 +26,7 @@ use crate::{ }; use frame_support::{ crypto::ecdsa::ECDSAExt, - dispatch::{ - fmt::Debug, DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, - }, + dispatch::{DispatchResult, DispatchResultWithPostInfo}, ensure, storage::{with_transaction, TransactionOutcome}, traits::{ @@ -48,8 +46,11 @@ use sp_core::{ Get, }; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; -use sp_runtime::traits::{Convert, Hash, Zero}; -use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; +use sp_runtime::{ + traits::{Convert, Dispatchable, Hash, Zero}, + DispatchError, +}; +use sp_std::{fmt::Debug, marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index 7d17642d92e54..363ddfad975b1 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -17,14 +17,12 @@ use crate::{exec::ExecError, Config, Error}; use frame_support::{ - dispatch::{ - DispatchError, DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo, - }, + dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo}, weights::Weight, DefaultNoBound, }; use sp_core::Get; -use sp_runtime::traits::Zero; +use sp_runtime::{traits::Zero, DispatchError}; use sp_std::marker::PhantomData; #[cfg(test)] diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index f18fff0e939f4..5a93dd6aeef79 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -111,10 +111,7 @@ use crate::{ use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen}; use environmental::*; use frame_support::{ - dispatch::{ - DispatchError, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, - WithPostDispatchInfo, - }, + dispatch::{GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, WithPostDispatchInfo}, ensure, error::BadOrigin, traits::{ @@ -133,8 +130,8 @@ use pallet_contracts_primitives::{ use scale_info::TypeInfo; use smallvec::Array; use sp_runtime::{ - traits::{Convert, Hash, Saturating, StaticLookup, Zero}, - RuntimeDebug, + traits::{Convert, Dispatchable, Hash, Saturating, StaticLookup, Zero}, + DispatchError, RuntimeDebug, }; use sp_std::{fmt::Debug, prelude::*}; diff --git a/frame/contracts/src/migration/v15.rs b/frame/contracts/src/migration/v15.rs index efece62905ff8..180fe855ca667 100644 --- a/frame/contracts/src/migration/v15.rs +++ b/frame/contracts/src/migration/v15.rs @@ -28,7 +28,7 @@ use crate::{ AccountIdOf, BalanceOf, CodeHash, Config, HoldReason, Pallet, TrieId, Weight, LOG_TARGET, }; #[cfg(feature = "try-runtime")] -use frame_support::{dispatch::Vec, traits::fungible::InspectHold}; +use frame_support::traits::fungible::InspectHold; use frame_support::{ pallet_prelude::*, storage_alias, @@ -43,6 +43,8 @@ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Saturating}; +#[cfg(feature = "try-runtime")] +use sp_std::vec::Vec; mod old { use super::*; diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index d58fd0fe9dbdf..d4d261f4ec1ff 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -27,7 +27,6 @@ use crate::{ }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::DispatchError, storage::child::{self, ChildInfo}, weights::Weight, CloneNoBound, DefaultNoBound, @@ -37,7 +36,7 @@ use sp_core::Get; use sp_io::KillStorageResult; use sp_runtime::{ traits::{Hash, Saturating, Zero}, - BoundedBTreeMap, DispatchResult, RuntimeDebug, + BoundedBTreeMap, DispatchError, DispatchResult, RuntimeDebug, }; use sp_std::{marker::PhantomData, prelude::*}; diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 2a9a083412b00..9f098090bc8bb 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -23,7 +23,6 @@ use crate::{ }; use frame_support::{ - dispatch::{fmt::Debug, DispatchError}, ensure, traits::{ fungible::{Mutate, MutateHold}, @@ -37,9 +36,9 @@ use frame_support::{ use sp_api::HashT; use sp_runtime::{ traits::{Saturating, Zero}, - FixedPointNumber, FixedU128, + DispatchError, FixedPointNumber, FixedU128, }; -use sp_std::{marker::PhantomData, vec, vec::Vec}; +use sp_std::{fmt::Debug, marker::PhantomData, vec, vec::Vec}; /// Deposit that uses the native fungible's balance type. pub type DepositOf = Deposit>; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 5c8fca43ab746..163382ccbc7d8 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -39,7 +39,7 @@ use assert_matches::assert_matches; use codec::Encode; use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok, - dispatch::{DispatchError, DispatchErrorWithPostInfo, PostDispatchInfo}, + dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, parameter_types, storage::child, traits::{ @@ -58,7 +58,7 @@ use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ testing::H256, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, - AccountId32, BuildStorage, Perbill, TokenError, + AccountId32, BuildStorage, DispatchError, Perbill, TokenError, }; type Block = frame_system::mocking::MockBlock; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 291f39f7fa797..5fc65e314ad9f 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -42,12 +42,12 @@ use crate::{ }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, ensure, traits::{fungible::MutateHold, tokens::Precision::BestEffort}, }; use sp_core::Get; -use sp_runtime::RuntimeDebug; +use sp_runtime::{DispatchError, RuntimeDebug}; use sp_std::prelude::*; use wasmi::{Instance, Linker, Memory, MemoryType, StackLimits, Store}; diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index ca23ab9fe5dd0..4bc00388f726f 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -26,13 +26,13 @@ use crate::{ use bitflags::bitflags; use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen}; -use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weight}; +use frame_support::{ensure, traits::Get, weights::Weight}; use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pallet_contracts_proc_macro::define_env; use sp_io::hashing::{blake2_128, blake2_256, keccak_256, sha2_256}; use sp_runtime::{ traits::{Bounded, Zero}, - RuntimeDebug, + DispatchError, RuntimeDebug, }; use sp_std::{fmt, prelude::*}; use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 9c2993fc5cae1..1d6fbaa386942 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -28,7 +28,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, ensure, traits::{ fungible, Currency, Get, LockIdentifier, LockableCurrency, PollStatus, Polling, @@ -38,7 +38,7 @@ use frame_support::{ use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, - ArithmeticError, Perbill, + ArithmeticError, DispatchError, Perbill, }; use sp_std::prelude::*; @@ -86,8 +86,15 @@ type ClassOf = <>::Polls as Polling>>::C #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{pallet_prelude::*, traits::ClassCountOf}; + use frame_support::{ + pallet_prelude::{ + DispatchResultWithPostInfo, IsType, StorageDoubleMap, StorageMap, ValueQuery, + }, + traits::ClassCountOf, + Twox64Concat, + }; use frame_system::pallet_prelude::*; + use sp_runtime::BoundedVec; #[pallet::pallet] pub struct Pallet(_); diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 5eeac26fb1323..3c58c42d6b42e 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -985,12 +985,12 @@ mod tests { use codec::Decode; use frame_benchmarking::Zero; use frame_election_provider_support::IndexAssignment; - use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::OffchainWorker}; + use frame_support::{assert_noop, assert_ok, traits::OffchainWorker}; use sp_npos_elections::ElectionScore; use sp_runtime::{ bounded_vec, offchain::storage_lock::{BlockAndTime, StorageLock}, - traits::ValidateUnsigned, + traits::{Dispatchable, ValidateUnsigned}, ModuleError, PerU16, Perbill, }; diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 9c3511ae35751..8e37d55c0deec 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -18,7 +18,8 @@ #![allow(dead_code)] use frame_support::{ - assert_ok, dispatch::UnfilteredDispatchable, parameter_types, traits, traits::Hooks, + assert_ok, parameter_types, traits, + traits::{Hooks, UnfilteredDispatchable}, weights::constants, }; use frame_system::EnsureRoot; diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index c9c0254042424..c54f6d76803ff 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -56,7 +56,7 @@ pub mod weights; use codec::{Decode, Encode}; use frame_support::{ - dispatch::{DispatchResult, Dispatchable, GetDispatchInfo}, + dispatch::{DispatchResult, GetDispatchInfo}, ensure, pallet_prelude::MaxEncodedLen, storage::bounded_vec::BoundedVec, @@ -65,7 +65,7 @@ use frame_support::{ }; pub use pallet::*; use sp_runtime::{ - traits::{AccountIdConversion, Saturating, Zero}, + traits::{AccountIdConversion, Dispatchable, Saturating, Zero}, ArithmeticError, DispatchError, RuntimeDebug, }; use sp_std::prelude::*; diff --git a/frame/multisig/src/migrations.rs b/frame/multisig/src/migrations.rs index 298e73c5d7576..3be55080b2407 100644 --- a/frame/multisig/src/migrations.rs +++ b/frame/multisig/src/migrations.rs @@ -19,8 +19,7 @@ use super::*; use frame_support::{ - dispatch::GetStorageVersion, - traits::{OnRuntimeUpgrade, WrapperKeepOpaque}, + traits::{GetStorageVersion, OnRuntimeUpgrade, WrapperKeepOpaque}, Identity, }; diff --git a/frame/nfts/runtime-api/Cargo.toml b/frame/nfts/runtime-api/Cargo.toml index bf5f9f0ec001f..0158e45a07f65 100644 --- a/frame/nfts/runtime-api/Cargo.toml +++ b/frame/nfts/runtime-api/Cargo.toml @@ -14,7 +14,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } pallet-nfts = { version = "4.0.0-dev", default-features = false, path = "../../nfts" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" } @@ -22,7 +21,6 @@ sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../pri default = ["std"] std = [ "codec/std", - "frame-support/std", "pallet-nfts/std", "sp-api/std", ] diff --git a/frame/nfts/runtime-api/src/lib.rs b/frame/nfts/runtime-api/src/lib.rs index 0c23d178107e7..deec6bff8d275 100644 --- a/frame/nfts/runtime-api/src/lib.rs +++ b/frame/nfts/runtime-api/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; -use frame_support::dispatch::Vec; +use sp_api::vec::Vec; sp_api::decl_runtime_apis! { pub trait NftsApi diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 995c842036746..8792af675fc16 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -26,8 +26,7 @@ use frame_benchmarking::v1::{ }; use frame_support::{ assert_ok, - dispatch::UnfilteredDispatchable, - traits::{EnsureOrigin, Get}, + traits::{EnsureOrigin, Get, UnfilteredDispatchable}, BoundedVec, }; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index f7879570a4cb7..6e264048f11a6 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -21,7 +21,6 @@ use crate::{mock::*, Event, *}; use enumflags2::BitFlags; use frame_support::{ assert_noop, assert_ok, - dispatch::Dispatchable, traits::{ tokens::nonfungibles_v2::{Create, Destroy, Mutate}, Currency, Get, @@ -29,7 +28,10 @@ use frame_support::{ }; use pallet_balances::Error as BalancesError; use sp_core::{bounded::BoundedVec, Pair}; -use sp_runtime::{traits::IdentifyAccount, MultiSignature, MultiSigner}; +use sp_runtime::{ + traits::{Dispatchable, IdentifyAccount}, + MultiSignature, MultiSigner, +}; use sp_std::prelude::*; type AccountIdOf = ::AccountId; diff --git a/frame/offences/src/migration.rs b/frame/offences/src/migration.rs index 3c0d243a55d98..3b5cf3ce92695 100644 --- a/frame/offences/src/migration.rs +++ b/frame/offences/src/migration.rs @@ -17,10 +17,9 @@ use super::{Config, Kind, OffenceDetails, Pallet, Perbill, SessionIndex, LOG_TARGET}; use frame_support::{ - dispatch::GetStorageVersion, pallet_prelude::ValueQuery, storage_alias, - traits::{Get, OnRuntimeUpgrade}, + traits::{Get, GetStorageVersion, OnRuntimeUpgrade}, weights::Weight, Twox64Concat, }; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 586d52fb62bdd..4d4da0433afa0 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -35,7 +35,7 @@ pub mod weights; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{DispatchError, GetDispatchInfo}, + dispatch::GetDispatchInfo, ensure, traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency}, }; @@ -45,7 +45,7 @@ use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{Dispatchable, Hash, Saturating, StaticLookup, TrailingZeroInput, Zero}, - DispatchResult, RuntimeDebug, + DispatchError, DispatchResult, RuntimeDebug, }; use sp_std::prelude::*; pub use weights::WeightInfo; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 48a2a4ed0cc33..0667be6e1e52b 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -25,11 +25,10 @@ use crate as proxy; use codec::{Decode, Encode}; use frame_support::{ assert_noop, assert_ok, derive_impl, - dispatch::DispatchError, traits::{ConstU32, ConstU64, Contains}, }; use sp_core::H256; -use sp_runtime::{traits::BlakeTwo256, BuildStorage, RuntimeDebug}; +use sp_runtime::{traits::BlakeTwo256, BuildStorage, DispatchError, RuntimeDebug}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index b610d10009a08..518428880e4de 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -24,7 +24,7 @@ use crate::Pallet as RankedCollective; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, }; -use frame_support::{assert_ok, dispatch::UnfilteredDispatchable}; +use frame_support::{assert_ok, traits::UnfilteredDispatchable}; use frame_system::RawOrigin as SystemOrigin; const SEED: u32 = 0; diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index d94932a1dac71..deb1ccf23578b 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -47,12 +47,12 @@ use sp_arithmetic::traits::Saturating; use sp_runtime::{ traits::{Convert, StaticLookup}, ArithmeticError::Overflow, - Perbill, RuntimeDebug, + DispatchError, Perbill, RuntimeDebug, }; use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ - dispatch::{DispatchError, DispatchResultWithPostInfo, PostDispatchInfo}, + dispatch::{DispatchResultWithPostInfo, PostDispatchInfo}, ensure, impl_ensure_origin_with_arg_ignoring_arg, traits::{EnsureOrigin, EnsureOriginWithArg, PollStatus, Polling, RankedMembers, VoteTally}, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 78d14bd99d2ee..e884a0bb6ec92 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -25,8 +25,7 @@ use frame_benchmarking::v1::{ }; use frame_support::{ assert_ok, - dispatch::UnfilteredDispatchable, - traits::{Bounded, Currency, EnsureOrigin, EnsureOriginWithArg}, + traits::{Bounded, Currency, EnsureOrigin, EnsureOriginWithArg, UnfilteredDispatchable}, }; use frame_system::RawOrigin; use sp_runtime::traits::Bounded as ArithBounded; diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index c7469946c2dab..d748c524605a8 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -21,12 +21,9 @@ use super::*; use crate::mock::{RefState::*, *}; use assert_matches::assert_matches; use codec::Decode; -use frame_support::{ - assert_noop, assert_ok, - dispatch::{DispatchError::BadOrigin, RawOrigin}, - traits::Contains, -}; +use frame_support::{assert_noop, assert_ok, dispatch::RawOrigin, traits::Contains}; use pallet_balances::Error as BalancesError; +use sp_runtime::DispatchError::BadOrigin; #[test] fn params_should_work() { diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 3538331bbd4ca..14b51839dec99 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -87,9 +87,7 @@ pub mod weights; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{ - DispatchError, DispatchResult, Dispatchable, GetDispatchInfo, Parameter, RawOrigin, - }, + dispatch::{DispatchResult, GetDispatchInfo, Parameter, RawOrigin}, ensure, traits::{ schedule::{self, DispatchTime, MaybeHashed}, @@ -105,8 +103,8 @@ use frame_system::{ use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ - traits::{BadOrigin, One, Saturating, Zero}, - BoundedVec, RuntimeDebug, + traits::{BadOrigin, Dispatchable, One, Saturating, Zero}, + BoundedVec, DispatchError, RuntimeDebug, }; use sp_std::{borrow::Borrow, cmp::Ordering, marker::PhantomData, prelude::*}; diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 1c0093c1df64f..bf4671a247f0d 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -117,7 +117,7 @@ pub mod weights; use codec::{Decode, MaxEncodedLen}; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, ensure, traits::{ EstimateNextNewSession, EstimateNextSessionRotation, FindAuthor, Get, OneSessionHandler, @@ -129,7 +129,7 @@ use frame_support::{ use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Convert, Member, One, OpaqueKeys, Zero}, - ConsensusEngineId, KeyTypeId, Permill, RuntimeAppPublic, + ConsensusEngineId, DispatchError, KeyTypeId, Permill, RuntimeAppPublic, }; use sp_staking::SessionIndex; use sp_std::{ diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index e72a9baf044fe..ce5c35524c747 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -24,9 +24,8 @@ use testing_utils::*; use codec::Decode; use frame_election_provider_support::{bounds::DataProviderBounds, SortedListProvider}; use frame_support::{ - dispatch::UnfilteredDispatchable, pallet_prelude::*, - traits::{Currency, Get, Imbalance}, + traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; use sp_runtime::{ traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, diff --git a/frame/staking/src/migrations.rs b/frame/staking/src/migrations.rs index 332da506f01ed..89520028b901c 100644 --- a/frame/staking/src/migrations.rs +++ b/frame/staking/src/migrations.rs @@ -19,8 +19,9 @@ use super::*; use frame_election_provider_support::SortedListProvider; use frame_support::{ - dispatch::GetStorageVersion, pallet_prelude::ValueQuery, storage_alias, - traits::OnRuntimeUpgrade, + pallet_prelude::ValueQuery, + storage_alias, + traits::{GetStorageVersion, OnRuntimeUpgrade}, }; #[cfg(feature = "try-runtime")] diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 40a2f5cf73eb1..c6c75326b80cd 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -17,11 +17,11 @@ //! Staking FRAME Pallet. +use codec::Codec; use frame_election_provider_support::{ ElectionProvider, ElectionProviderBase, SortedListProvider, VoteWeight, }; use frame_support::{ - dispatch::Codec, pallet_prelude::*, traits::{ Currency, Defensive, DefensiveResult, DefensiveSaturating, EnsureOrigin, diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index e22a47458b7d5..3e69b219bb527 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1268,7 +1268,6 @@ mod mock { #[cfg(test)] mod test { use super::{mock::*, *}; - use frame_support::dispatch::*; use sp_runtime::{bounded_vec, traits::Bounded, StateVersion}; #[test] diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index cbf2ea9078535..b8741034f0fe4 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -124,16 +124,16 @@ pub fn expand_outer_dispatch( } } - impl #scrate::dispatch::GetCallMetadata for RuntimeCall { - fn get_call_metadata(&self) -> #scrate::dispatch::CallMetadata { - use #scrate::dispatch::GetCallName; + impl #scrate::traits::GetCallMetadata for RuntimeCall { + fn get_call_metadata(&self) -> #scrate::traits::CallMetadata { + use #scrate::traits::GetCallName; match self { #( #pallet_attrs #variant_patterns => { let function_name = call.get_call_name(); let pallet_name = stringify!(#pallet_names); - #scrate::dispatch::CallMetadata { function_name, pallet_name } + #scrate::traits::CallMetadata { function_name, pallet_name } } )* } @@ -147,7 +147,7 @@ pub fn expand_outer_dispatch( } fn get_call_names(module: &str) -> &'static [&'static str] { - use #scrate::dispatch::{Callable, GetCallName}; + use #scrate::{dispatch::Callable, traits::GetCallName}; match module { #( #pallet_attrs @@ -159,7 +159,7 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::Dispatchable for RuntimeCall { + impl #scrate::dispatch::__private::Dispatchable for RuntimeCall { type RuntimeOrigin = RuntimeOrigin; type Config = RuntimeCall; type Info = #scrate::dispatch::DispatchInfo; diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 6489949ed5c33..3ed5509863e91 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -351,7 +351,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { } } - impl<#type_impl_gen> #frame_support::dispatch::GetCallName for #call_ident<#type_use_gen> + impl<#type_impl_gen> #frame_support::traits::GetCallName for #call_ident<#type_use_gen> #where_clause { fn get_call_name(&self) -> &'static str { @@ -366,7 +366,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { } } - impl<#type_impl_gen> #frame_support::dispatch::GetCallIndex for #call_ident<#type_use_gen> + impl<#type_impl_gen> #frame_support::traits::GetCallIndex for #call_ident<#type_use_gen> #where_clause { fn get_call_index(&self) -> u8 { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 0388a9adb3948..130aa429ea606 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -18,30 +18,26 @@ //! Dispatch system. Contains a macro for defining runtime modules and //! generating values representing lazy module function calls. -pub use crate::traits::{ - CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion, - UnfilteredDispatchable, -}; -pub use codec::{ - Codec, Decode, Encode, EncodeAsRef, EncodeLike, HasCompact, Input, MaxEncodedLen, Output, -}; -pub use scale_info::TypeInfo; -pub use sp_runtime::{ - traits::Dispatchable, transaction_validity::TransactionPriority, DispatchError, RuntimeDebug, -}; -pub use sp_std::{ - fmt, marker, - prelude::{Clone, Eq, PartialEq, Vec}, - result, -}; -pub use sp_weights::Weight; - +use crate::traits::UnfilteredDispatchable; +use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::{ generic::{CheckedExtrinsic, UncheckedExtrinsic}, traits::SignedExtension, + DispatchError, RuntimeDebug, }; +use sp_std::fmt; +use sp_weights::Weight; + +/// Private exports that are being used by macros. +/// +/// The exports are not stable and should not be relied on. +#[doc(hidden)] +pub mod __private { + pub use sp_runtime::traits::Dispatchable; +} /// The return type of a `Dispatchable` in frame. When returned explicitly from /// a dispatchable function it allows overriding the default `PostDispatchInfo` diff --git a/frame/support/src/dispatch_context.rs b/frame/support/src/dispatch_context.rs index 31278ea9f8194..608187b722063 100644 --- a/frame/support/src/dispatch_context.rs +++ b/frame/support/src/dispatch_context.rs @@ -26,11 +26,11 @@ //! //! # FRAME integration //! -//! The FRAME macros implement [`UnfilteredDispatchable`](crate::traits::UnfilteredDispatchable) for -//! each pallet `Call` enum. Part of this implementation is the call to [`run_in_context`], so that -//! each call to +//! The FRAME macros implement +//! [`UnfilteredDispatchable`](frame_support::traits::UnfilteredDispatchable) for each pallet `Call` +//! enum. Part of this implementation is the call to [`run_in_context`], so that each call to //! [`UnfilteredDispatchable::dispatch_bypass_filter`](crate::traits::UnfilteredDispatchable::dispatch_bypass_filter) -//! or [`Dispatchable::dispatch`](crate::dispatch::Dispatchable::dispatch) will run in a dispatch +//! or [`Dispatchable::dispatch`](sp_runtime::traits::Dispatchable::dispatch) will run in a dispatch //! context. //! //! # Example diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index eee68233f3a56..f9c0d0f9ca1ab 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -806,10 +806,7 @@ pub mod testing_prelude { /// Prelude to be used alongside pallet macro, for ease of use. pub mod pallet_prelude { pub use crate::{ - dispatch::{ - DispatchClass, DispatchError, DispatchResult, DispatchResultWithPostInfo, Parameter, - Pays, - }, + dispatch::{DispatchClass, DispatchResult, DispatchResultWithPostInfo, Parameter, Pays}, ensure, inherent::{InherentData, InherentIdentifier, ProvideInherent}, storage, @@ -840,7 +837,7 @@ pub mod pallet_prelude { TransactionTag, TransactionValidity, TransactionValidityError, UnknownTransaction, ValidTransaction, }, - RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE, + DispatchError, RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE, }; pub use sp_std::marker::PhantomData; pub use sp_weights::Weight; diff --git a/frame/support/src/traits/tokens/currency.rs b/frame/support/src/traits/tokens/currency.rs index e6a7284a74b7f..0030e1261dac1 100644 --- a/frame/support/src/traits/tokens/currency.rs +++ b/frame/support/src/traits/tokens/currency.rs @@ -21,11 +21,8 @@ use super::{ imbalance::{Imbalance, SignedImbalance}, misc::{Balance, ExistenceRequirement, WithdrawReasons}, }; -use crate::{ - dispatch::{DispatchError, DispatchResult}, - traits::Get, -}; -use sp_runtime::traits::MaybeSerializeDeserialize; +use crate::{dispatch::DispatchResult, traits::Get}; +use sp_runtime::{traits::MaybeSerializeDeserialize, DispatchError}; mod reservable; pub use reservable::{NamedReservableCurrency, ReservableCurrency}; diff --git a/frame/support/src/traits/tokens/currency/reservable.rs b/frame/support/src/traits/tokens/currency/reservable.rs index 79129cecdd696..ff8b0c6eea838 100644 --- a/frame/support/src/traits/tokens/currency/reservable.rs +++ b/frame/support/src/traits/tokens/currency/reservable.rs @@ -22,9 +22,10 @@ use sp_core::Get; use super::{super::misc::BalanceStatus, Currency}; use crate::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, traits::{ExistenceRequirement, SignedImbalance, WithdrawReasons}, }; +use sp_runtime::DispatchError; /// A currency where funds can be reserved from the user. pub trait ReservableCurrency: Currency { diff --git a/frame/support/src/traits/tokens/fungible/regular.rs b/frame/support/src/traits/tokens/fungible/regular.rs index 2838bed540aa2..c3f621b914f88 100644 --- a/frame/support/src/traits/tokens/fungible/regular.rs +++ b/frame/support/src/traits/tokens/fungible/regular.rs @@ -18,7 +18,6 @@ //! `Inspect` and `Mutate` traits for working with regular balances. use crate::{ - dispatch::DispatchError, ensure, traits::{ tokens::{ @@ -36,7 +35,7 @@ use crate::{ }, }; use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One}; -use sp_runtime::{traits::Saturating, ArithmeticError, TokenError}; +use sp_runtime::{traits::Saturating, ArithmeticError, DispatchError, TokenError}; use sp_std::marker::PhantomData; use super::{Credit, Debt, HandleImbalanceDrop, Imbalance}; diff --git a/frame/support/src/traits/tokens/fungibles/regular.rs b/frame/support/src/traits/tokens/fungibles/regular.rs index b6cea15284d39..b027aee2f7d42 100644 --- a/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/frame/support/src/traits/tokens/fungibles/regular.rs @@ -20,7 +20,6 @@ use sp_std::marker::PhantomData; use crate::{ - dispatch::DispatchError, ensure, traits::{ tokens::{ @@ -38,7 +37,7 @@ use crate::{ }, }; use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One}; -use sp_runtime::{traits::Saturating, ArithmeticError, TokenError}; +use sp_runtime::{traits::Saturating, ArithmeticError, DispatchError, TokenError}; use super::{Credit, Debt, HandleImbalanceDrop, Imbalance}; diff --git a/frame/support/src/traits/tokens/nonfungibles.rs b/frame/support/src/traits/tokens/nonfungibles.rs index e9538d14f5471..615e79c29c85f 100644 --- a/frame/support/src/traits/tokens/nonfungibles.rs +++ b/frame/support/src/traits/tokens/nonfungibles.rs @@ -27,9 +27,9 @@ //! Implementations of these traits may be converted to implementations of corresponding //! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter. -use crate::dispatch::{DispatchError, DispatchResult}; +use crate::dispatch::DispatchResult; use codec::{Decode, Encode}; -use sp_runtime::TokenError; +use sp_runtime::{DispatchError, TokenError}; use sp_std::prelude::*; /// Trait for providing an interface to many read-only NFT-like sets of items. diff --git a/frame/support/src/traits/tokens/nonfungibles_v2.rs b/frame/support/src/traits/tokens/nonfungibles_v2.rs index 345cce237b67b..ec064bdebf62a 100644 --- a/frame/support/src/traits/tokens/nonfungibles_v2.rs +++ b/frame/support/src/traits/tokens/nonfungibles_v2.rs @@ -27,9 +27,9 @@ //! Implementations of these traits may be converted to implementations of corresponding //! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter. -use crate::dispatch::{DispatchError, DispatchResult, Parameter}; +use crate::dispatch::{DispatchResult, Parameter}; use codec::{Decode, Encode}; -use sp_runtime::TokenError; +use sp_runtime::{DispatchError, TokenError}; use sp_std::prelude::*; /// Trait for providing an interface to many read-only NFT-like sets of items. diff --git a/frame/support/src/traits/voting.rs b/frame/support/src/traits/voting.rs index 4201b8d48d157..f5c9e285ef3a6 100644 --- a/frame/support/src/traits/voting.rs +++ b/frame/support/src/traits/voting.rs @@ -18,10 +18,10 @@ //! Traits and associated data structures concerned with voting, and moving between tokens and //! votes. -use crate::dispatch::{DispatchError, Parameter}; +use crate::dispatch::Parameter; use codec::{HasCompact, MaxEncodedLen}; use sp_arithmetic::Perbill; -use sp_runtime::traits::Member; +use sp_runtime::{traits::Member, DispatchError}; use sp_std::prelude::*; pub trait VoteTally { diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index a14276fa4d2ff..9ad51ad530ebd 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -578,14 +578,14 @@ fn call_weight_should_attach_to_call_enum() { #[test] fn call_name() { - use frame_support::dispatch::GetCallName; + use frame_support::traits::GetCallName; let name = module3::Call::::aux_4 {}.get_call_name(); assert_eq!("aux_4", name); } #[test] fn call_metadata() { - use frame_support::dispatch::{CallMetadata, GetCallMetadata}; + use frame_support::traits::{CallMetadata, GetCallMetadata}; let call = RuntimeCall::Module3(module3::Call::::aux_4 {}); let metadata = call.get_call_metadata(); let expected = CallMetadata { function_name: "aux_4".into(), pallet_name: "Module3".into() }; @@ -594,14 +594,14 @@ fn call_metadata() { #[test] fn get_call_names() { - use frame_support::dispatch::GetCallName; + use frame_support::traits::GetCallName; let call_names = module3::Call::::get_call_names(); assert_eq!(["fail", "aux_1", "aux_2", "aux_3", "aux_4", "operational"], call_names); } #[test] fn get_module_names() { - use frame_support::dispatch::GetCallMetadata; + use frame_support::traits::GetCallMetadata; let module_names = RuntimeCall::get_module_names(); assert_eq!( [ diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index e784d20a0cfd7..753f5ca0c7b52 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -30,10 +30,10 @@ mod tests; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{Dispatchable, GetDispatchInfo}, + dispatch::GetDispatchInfo, traits::{Currency, OnUnbalanced, ReservableCurrency}, }; -use sp_runtime::traits::{BlakeTwo256, Hash, One, Saturating, Zero}; +use sp_runtime::traits::{BlakeTwo256, Dispatchable, Hash, One, Saturating, Zero}; use sp_std::{prelude::*, result}; use sp_transaction_storage_proof::{ encode_index, random_chunk, InherentError, TransactionStorageProof, CHUNK_SIZE, diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index b8a53e06f2092..24c290ddb665e 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -23,9 +23,8 @@ use super::{Pallet as Treasury, *}; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::{ - dispatch::UnfilteredDispatchable, ensure, - traits::{EnsureOrigin, OnInitialize}, + traits::{EnsureOrigin, OnInitialize, UnfilteredDispatchable}, }; use frame_system::RawOrigin; diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 4e63f69281e5d..821ca1794b865 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -24,8 +24,7 @@ use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; use frame_support::{ - dispatch::UnfilteredDispatchable, - traits::{EnsureOrigin, Get}, + traits::{EnsureOrigin, Get, UnfilteredDispatchable}, BoundedVec, }; use frame_system::RawOrigin as SystemOrigin; diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index 993552c3a2aaa..52f7df3b5efbc 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -18,8 +18,9 @@ //! Tests for Uniques pallet. use crate::{mock::*, Event, *}; -use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::Currency}; +use frame_support::{assert_noop, assert_ok, traits::Currency}; use pallet_balances::Error as BalancesError; +use sp_runtime::traits::Dispatchable; use sp_std::prelude::*; fn items() -> Vec<(u64, u32, u32)> { diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index c2fd3a851c319..183853c4e8ac6 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -24,7 +24,7 @@ use super::*; use crate as utility; use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, - dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable, Pays}, + dispatch::{DispatchErrorWithPostInfo, Pays}, error::BadOrigin, parameter_types, storage, traits::{ConstU32, ConstU64, Contains}, @@ -33,8 +33,8 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Hash, IdentityLookup}, - BuildStorage, TokenError, + traits::{BlakeTwo256, Dispatchable, Hash, IdentityLookup}, + BuildStorage, DispatchError, TokenError, }; type BlockNumber = u64; diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index eb829121e9797..ee67a038e4d7b 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -58,7 +58,7 @@ pub mod weights; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, ensure, storage::bounded_vec::BoundedVec, traits::{ @@ -74,7 +74,7 @@ use sp_runtime::{ AtLeast32BitUnsigned, Bounded, Convert, MaybeSerializeDeserialize, One, Saturating, StaticLookup, Zero, }, - RuntimeDebug, + DispatchError, RuntimeDebug, }; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; diff --git a/frame/vesting/src/tests.rs b/frame/vesting/src/tests.rs index 46afe895f6fcc..c35686bd5146c 100644 --- a/frame/vesting/src/tests.rs +++ b/frame/vesting/src/tests.rs @@ -15,7 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::{assert_noop, assert_ok, assert_storage_noop, dispatch::EncodeLike}; +use codec::EncodeLike; +use frame_support::{assert_noop, assert_ok, assert_storage_noop}; use frame_system::RawOrigin; use sp_runtime::{ traits::{BadOrigin, Identity}, From 55f3ab2959dd63c2eefddf3248ba49a1e7aeb389 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 23 Aug 2023 17:49:27 +0200 Subject: [PATCH 37/42] fix ci --- frame/timestamp/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 5dd1b6e05b67a..76896ae9411b4 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -45,7 +45,7 @@ std = [ "sp-io?/std", "sp-runtime/std", "sp-std/std", - "sp-storage/std", + "sp-storage/std", "sp-timestamp/std", ] runtime-benchmarks = [ From a8081023100622a8eac1146a5fbad3f4ef087fb4 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 24 Aug 2023 13:54:55 +0200 Subject: [PATCH 38/42] remove unnecessary imports --- bin/node-template/pallets/template/src/benchmarking.rs | 1 - frame/benchmarking/src/baseline.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index 6c3cae6066b41..5a262417629c5 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -1,7 +1,6 @@ //! Benchmarking setup for pallet-template #![cfg(feature = "runtime-benchmarks")] use super::*; -use sp_std::vec; #[allow(unused)] use crate::Pallet as Template; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 6cd23ebe028a3..eb18ef663cc9d 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -26,7 +26,6 @@ use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; -use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; From 08c6e5bacca89478986973aca295d4c9ef69b72a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 24 Aug 2023 13:56:13 +0200 Subject: [PATCH 39/42] remove unnecessary imports --- bin/node-template/pallets/template/src/benchmarking.rs | 1 - frame/benchmarking/src/baseline.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index 6c3cae6066b41..5a262417629c5 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -1,7 +1,6 @@ //! Benchmarking setup for pallet-template #![cfg(feature = "runtime-benchmarks")] use super::*; -use sp_std::vec; #[allow(unused)] use crate::Pallet as Template; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 6cd23ebe028a3..eb18ef663cc9d 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -26,7 +26,6 @@ use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; -use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; From b6414ca038700c7858bdfc6535416175433986a1 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 24 Aug 2023 14:09:54 +0200 Subject: [PATCH 40/42] add import back --- frame/benchmarking/src/baseline.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index eb18ef663cc9d..6cd23ebe028a3 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -26,6 +26,7 @@ use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; +use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; From 0cd5bc9639bbd3cd2678a2567158b7b22e8c87c9 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 24 Aug 2023 15:24:08 +0200 Subject: [PATCH 41/42] add import back --- bin/node-template/pallets/template/src/benchmarking.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index 5a262417629c5..6c3cae6066b41 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -1,6 +1,7 @@ //! Benchmarking setup for pallet-template #![cfg(feature = "runtime-benchmarks")] use super::*; +use sp_std::vec; #[allow(unused)] use crate::Pallet as Template; From 4fff5dd72fa6b4d5f4ec9a1c8301858e0e9878a1 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 24 Aug 2023 15:25:26 +0200 Subject: [PATCH 42/42] add import back --- bin/node-template/pallets/template/src/benchmarking.rs | 1 + frame/benchmarking/src/baseline.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index 5a262417629c5..6c3cae6066b41 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -1,6 +1,7 @@ //! Benchmarking setup for pallet-template #![cfg(feature = "runtime-benchmarks")] use super::*; +use sp_std::vec; #[allow(unused)] use crate::Pallet as Template; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index eb18ef663cc9d..6cd23ebe028a3 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -26,6 +26,7 @@ use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; +use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId};