mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 19:07:57 +00:00
Add storage size component to weights (#12277)
* Add storage size component to weights * Rename storage_size to proof_size * Update primitives/weights/src/weight_v2.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixes * cargo fmt * Implement custom Decode and CompactAs * Add missing import * Fixes * Remove CompactAs implementation * Properly migrate from 1D weight * Remove #[pallet::compact] from Weight parameters * More #[pallet::compact] removals * Add unit tests * Set appropriate default block proof size * cargo fmt * Remove nonsensical weight constant * Test only for the reference time weight in frame_system::limits * Only check for reference time weight on idle * Use destructuring syntax * Update test expectations * Fixes * Fixes * Fixes * Correctly migrate from 1D weights * cargo fmt * Migrate using extra extrinsics instead of custom Decode * Fixes * Silence dispatch call warnings that were previously allowed * Fix gas_left test * Use OldWeight instead of u64 * Fixes * Only check for reference time weight in election provider * Fix test expectations * Fix test expectations * Use only reference time weight in grandpa test * Use only reference time weight in examples test * Use only reference time weight in examples test * Fix test expectations Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{pallet::Def, COUNTER};
|
||||
use quote::ToTokens;
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
///
|
||||
@@ -158,6 +159,24 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
});
|
||||
}
|
||||
|
||||
// Extracts #[allow] attributes, necessary so that we don't run into compiler warnings
|
||||
let maybe_allow_attrs = methods
|
||||
.iter()
|
||||
.map(|method| {
|
||||
method
|
||||
.attrs
|
||||
.iter()
|
||||
.find(|attr| {
|
||||
if let Ok(syn::Meta::List(syn::MetaList { path, .. })) = attr.parse_meta() {
|
||||
path.segments.last().map(|seg| seg.ident == "allow").unwrap_or(false)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
.map_or(proc_macro2::TokenStream::new(), |attr| attr.to_token_stream())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
quote::quote_spanned!(span =>
|
||||
#[doc(hidden)]
|
||||
pub mod __substrate_call_check {
|
||||
@@ -289,6 +308,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
#frame_support::sp_tracing::enter_span!(
|
||||
#frame_support::sp_tracing::trace_span!(stringify!(#fn_name))
|
||||
);
|
||||
#maybe_allow_attrs
|
||||
<#pallet_ident<#type_use_gen>>::#fn_name(origin, #( #args_name, )* )
|
||||
.map(Into::into).map_err(Into::into)
|
||||
},
|
||||
|
||||
@@ -61,6 +61,8 @@ pub struct CallVariantDef {
|
||||
pub call_index: u8,
|
||||
/// Docs, used for metadata.
|
||||
pub docs: Vec<syn::Lit>,
|
||||
/// Attributes annotated at the top of the dispatchable function.
|
||||
pub attrs: Vec<syn::Attribute>,
|
||||
}
|
||||
|
||||
/// Attributes for functions in call impl block.
|
||||
@@ -287,6 +289,7 @@ impl CallDef {
|
||||
call_index: final_index,
|
||||
args,
|
||||
docs,
|
||||
attrs: method.attrs.clone(),
|
||||
});
|
||||
} else {
|
||||
let msg = "Invalid pallet::call, only method accepted";
|
||||
|
||||
Reference in New Issue
Block a user