From e0f4cc7d6b01e463c549af6b280a2ad6503dd6a8 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 15 May 2023 10:38:02 +0530 Subject: [PATCH 01/67] Initial setup --- bin/node-template/runtime/src/lib.rs | 3 ++- .../procedural/src/construct_runtime/expand/inherent.rs | 2 +- frame/support/procedural/src/construct_runtime/mod.rs | 5 ++++- frame/support/procedural/src/construct_runtime/parse.rs | 4 +--- frame/system/src/lib.rs | 5 ++++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index c138b390b4a94..86d05a8a3ed73 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -154,6 +154,8 @@ parameter_types! { impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = frame_support::traits::Everything; + /// The block type for the runtime. + type Block = Block; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). @@ -278,7 +280,6 @@ impl pallet_template::Config for Runtime { construct_runtime!( pub struct Runtime where - Block = Block, NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic, { diff --git a/frame/support/procedural/src/construct_runtime/expand/inherent.rs b/frame/support/procedural/src/construct_runtime/expand/inherent.rs index 52586bd691d4e..124696ec964af 100644 --- a/frame/support/procedural/src/construct_runtime/expand/inherent.rs +++ b/frame/support/procedural/src/construct_runtime/expand/inherent.rs @@ -23,7 +23,7 @@ use syn::{Ident, TypePath}; pub fn expand_outer_inherent( runtime: &Ident, - block: &TypePath, + block: &TokenStream, unchecked_extrinsic: &TypePath, pallet_decls: &[Pallet], scrate: &TokenStream, diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 1af44fc00a0ec..d8aaef2520259 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -216,7 +216,7 @@ fn construct_runtime_final_expansion( ) -> Result { let ExplicitRuntimeDeclaration { name, - where_section: WhereSection { block, node_block, unchecked_extrinsic }, + where_section: WhereSection { node_block, unchecked_extrinsic }, pallets, pallets_token, } = definition; @@ -256,6 +256,9 @@ fn construct_runtime_final_expansion( let scrate = generate_crate_access(hidden_crate_name, "frame-support"); let scrate_decl = generate_hidden_includes(hidden_crate_name, "frame-support"); + let frame_system = generate_crate_access_2018("frame-system")?; + let block = quote!(<#name as #frame_system::Config>::Block); + let outer_event = expand::expand_outer_event(&name, &pallets, &scrate)?; let outer_origin = expand::expand_outer_origin(&name, system_pallet, &pallets, &scrate)?; diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index f819a90d1b5cd..1dc6710fed0d0 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -112,7 +112,6 @@ impl Parse for RuntimeDeclaration { #[derive(Debug)] pub struct WhereSection { - pub block: syn::TypePath, pub node_block: syn::TypePath, pub unchecked_extrinsic: syn::TypePath, } @@ -132,7 +131,6 @@ impl Parse for WhereSection { } input.parse::()?; } - let block = remove_kind(input, WhereKind::Block, &mut definitions)?.value; let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; let unchecked_extrinsic = remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; @@ -143,7 +141,7 @@ impl Parse for WhereSection { ); return Err(Error::new(*kind_span, msg)) } - Ok(Self { block, node_block, unchecked_extrinsic }) + Ok(Self { node_block, unchecked_extrinsic }) } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 1b830105bb154..4e9df2a539968 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -71,7 +71,7 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::{ generic, traits::{ - self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded, + self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, Block, BlockNumberProvider, Bounded, CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, @@ -208,6 +208,9 @@ pub mod pallet { /// except Root. type BaseCallFilter: Contains; + /// The Block type used by the runtime + type Block: Block; + /// Block & extrinsics weights: base values and limits. #[pallet::constant] type BlockWeights: Get; From 5d688f87bb752fc37c80d13d92ce3ac67845567b Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 15 May 2023 10:41:10 +0530 Subject: [PATCH 02/67] Adds node block --- bin/node-template/runtime/src/lib.rs | 3 ++- frame/support/procedural/src/construct_runtime/mod.rs | 3 ++- frame/support/procedural/src/construct_runtime/parse.rs | 4 +--- frame/system/src/lib.rs | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 86d05a8a3ed73..d575187772ea4 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,6 +156,8 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; /// The block type for the runtime. type Block = Block; + /// The block type for the node. + type NodeBlock = Block; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). @@ -280,7 +282,6 @@ impl pallet_template::Config for Runtime { construct_runtime!( pub struct Runtime where - NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system, diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index d8aaef2520259..f1b29b155628a 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -216,7 +216,7 @@ fn construct_runtime_final_expansion( ) -> Result { let ExplicitRuntimeDeclaration { name, - where_section: WhereSection { node_block, unchecked_extrinsic }, + where_section: WhereSection { unchecked_extrinsic }, pallets, pallets_token, } = definition; @@ -258,6 +258,7 @@ fn construct_runtime_final_expansion( let frame_system = generate_crate_access_2018("frame-system")?; let block = quote!(<#name as #frame_system::Config>::Block); + let node_block = quote!(<#name as #frame_system::Config>::NodeBlock); let outer_event = expand::expand_outer_event(&name, &pallets, &scrate)?; diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 1dc6710fed0d0..576da73d8d807 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -112,7 +112,6 @@ impl Parse for RuntimeDeclaration { #[derive(Debug)] pub struct WhereSection { - pub node_block: syn::TypePath, pub unchecked_extrinsic: syn::TypePath, } @@ -131,7 +130,6 @@ impl Parse for WhereSection { } input.parse::()?; } - let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; let unchecked_extrinsic = remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; if let Some(WhereDefinition { ref kind_span, ref kind, .. }) = definitions.first() { @@ -141,7 +139,7 @@ impl Parse for WhereSection { ); return Err(Error::new(*kind_span, msg)) } - Ok(Self { node_block, unchecked_extrinsic }) + Ok(Self { unchecked_extrinsic }) } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 4e9df2a539968..01d8906e061c6 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -208,9 +208,12 @@ pub mod pallet { /// except Root. type BaseCallFilter: Contains; - /// The Block type used by the runtime + /// The Block type used by the runtime. type Block: Block; + /// The Block type used by the node. + type NodeBlock: Block; + /// Block & extrinsics weights: base values and limits. #[pallet::constant] type BlockWeights: Get; From 1681e65bc89f33576c25432cdf504cb135c68448 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 15 May 2023 10:54:22 +0530 Subject: [PATCH 03/67] Uses UncheckedExtrinsic and removes Where section --- bin/node-template/runtime/src/lib.rs | 4 +- .../src/construct_runtime/expand/inherent.rs | 4 +- .../src/construct_runtime/expand/metadata.rs | 4 +- .../procedural/src/construct_runtime/mod.rs | 3 +- .../procedural/src/construct_runtime/parse.rs | 94 +------------------ frame/system/src/lib.rs | 5 +- 6 files changed, 12 insertions(+), 102 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index d575187772ea4..0cde21a69f63f 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -158,6 +158,8 @@ impl frame_system::Config for Runtime { type Block = Block; /// The block type for the node. type NodeBlock = Block; + /// The UncheckedExtrinsic type for the runtime. + type UncheckedExtrinsic = UncheckedExtrinsic; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). @@ -281,8 +283,6 @@ impl pallet_template::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub struct Runtime - where - UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system, Timestamp: pallet_timestamp, diff --git a/frame/support/procedural/src/construct_runtime/expand/inherent.rs b/frame/support/procedural/src/construct_runtime/expand/inherent.rs index 124696ec964af..90430dd68279d 100644 --- a/frame/support/procedural/src/construct_runtime/expand/inherent.rs +++ b/frame/support/procedural/src/construct_runtime/expand/inherent.rs @@ -19,12 +19,12 @@ use crate::construct_runtime::Pallet; use proc_macro2::TokenStream; use quote::quote; use std::str::FromStr; -use syn::{Ident, TypePath}; +use syn::Ident; pub fn expand_outer_inherent( runtime: &Ident, block: &TokenStream, - unchecked_extrinsic: &TypePath, + unchecked_extrinsic: &TokenStream, pallet_decls: &[Pallet], scrate: &TokenStream, ) -> TokenStream { diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index 81fc93ba3c9ef..e23e4d1fe75b8 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -19,13 +19,13 @@ use crate::construct_runtime::Pallet; use proc_macro2::TokenStream; use quote::quote; use std::str::FromStr; -use syn::{Ident, TypePath}; +use syn::Ident; pub fn expand_runtime_metadata( runtime: &Ident, pallet_declarations: &[Pallet], scrate: &TokenStream, - extrinsic: &TypePath, + extrinsic: &TokenStream, ) -> TokenStream { let pallets = pallet_declarations .iter() diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index f1b29b155628a..c34db20c45aa5 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -151,7 +151,6 @@ use frame_support_procedural_tools::{ use itertools::Itertools; use parse::{ ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration, - WhereSection, }; use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; @@ -216,7 +215,6 @@ fn construct_runtime_final_expansion( ) -> Result { let ExplicitRuntimeDeclaration { name, - where_section: WhereSection { unchecked_extrinsic }, pallets, pallets_token, } = definition; @@ -259,6 +257,7 @@ fn construct_runtime_final_expansion( let frame_system = generate_crate_access_2018("frame-system")?; let block = quote!(<#name as #frame_system::Config>::Block); let node_block = quote!(<#name as #frame_system::Config>::NodeBlock); + let unchecked_extrinsic = quote!(<#name as #frame_system::Config>::UncheckedExtrinsic); let outer_event = expand::expand_outer_event(&name, &pallets, &scrate)?; diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 576da73d8d807..cfccc1b546874 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -16,7 +16,7 @@ // limitations under the License. use frame_support_procedural_tools::syn_ext as ext; -use proc_macro2::{Span, TokenStream}; +use proc_macro2::TokenStream; use quote::ToTokens; use std::collections::{HashMap, HashSet}; use syn::{ @@ -62,7 +62,6 @@ pub enum RuntimeDeclaration { #[derive(Debug)] pub struct ImplicitRuntimeDeclaration { pub name: Ident, - pub where_section: WhereSection, pub pallets: Vec, } @@ -70,7 +69,6 @@ pub struct ImplicitRuntimeDeclaration { #[derive(Debug)] pub struct ExplicitRuntimeDeclaration { pub name: Ident, - pub where_section: WhereSection, pub pallets: Vec, pub pallets_token: token::Brace, } @@ -87,7 +85,6 @@ impl Parse for RuntimeDeclaration { } let name = input.parse::()?; - let where_section = input.parse()?; let pallets = input.parse::>>()?; let pallets_token = pallets.token; @@ -96,13 +93,11 @@ impl Parse for RuntimeDeclaration { PalletsConversion::Implicit(pallets) => Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { name, - where_section, pallets, })), PalletsConversion::Explicit(pallets) => Ok(RuntimeDeclaration::Explicit(ExplicitRuntimeDeclaration { name, - where_section, pallets, pallets_token, })), @@ -110,77 +105,6 @@ impl Parse for RuntimeDeclaration { } } -#[derive(Debug)] -pub struct WhereSection { - pub unchecked_extrinsic: syn::TypePath, -} - -impl Parse for WhereSection { - fn parse(input: ParseStream) -> Result { - input.parse::()?; - let mut definitions = Vec::new(); - while !input.peek(token::Brace) { - let definition: WhereDefinition = input.parse()?; - definitions.push(definition); - if !input.peek(Token![,]) { - if !input.peek(token::Brace) { - return Err(input.error("Expected `,` or `{`")) - } - break - } - input.parse::()?; - } - let unchecked_extrinsic = - remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; - if let Some(WhereDefinition { ref kind_span, ref kind, .. }) = definitions.first() { - let msg = format!( - "`{:?}` was declared above. Please use exactly one declaration for `{:?}`.", - kind, kind - ); - return Err(Error::new(*kind_span, msg)) - } - Ok(Self { unchecked_extrinsic }) - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] -pub enum WhereKind { - Block, - NodeBlock, - UncheckedExtrinsic, -} - -#[derive(Debug)] -pub struct WhereDefinition { - pub kind_span: Span, - pub kind: WhereKind, - pub value: syn::TypePath, -} - -impl Parse for WhereDefinition { - fn parse(input: ParseStream) -> Result { - let lookahead = input.lookahead1(); - let (kind_span, kind) = if lookahead.peek(keyword::Block) { - (input.parse::()?.span(), WhereKind::Block) - } else if lookahead.peek(keyword::NodeBlock) { - (input.parse::()?.span(), WhereKind::NodeBlock) - } else if lookahead.peek(keyword::UncheckedExtrinsic) { - (input.parse::()?.span(), WhereKind::UncheckedExtrinsic) - } else { - return Err(lookahead.error()) - }; - - Ok(Self { - kind_span, - kind, - value: { - let _: Token![=] = input.parse()?; - input.parse()? - }, - }) - } -} - /// The declaration of a pallet. #[derive(Debug, Clone)] pub struct PalletDeclaration { @@ -498,22 +422,6 @@ impl PalletPart { } } -fn remove_kind( - input: ParseStream, - kind: WhereKind, - definitions: &mut Vec, -) -> Result { - if let Some(pos) = definitions.iter().position(|d| d.kind == kind) { - Ok(definitions.remove(pos)) - } else { - let msg = format!( - "Missing associated type for `{:?}`. Add `{:?}` = ... to where section.", - kind, kind - ); - Err(input.error(msg)) - } -} - /// The declaration of a part without its generics #[derive(Debug, Clone)] pub struct PalletPartNoGeneric { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 01d8906e061c6..9a4059c937a5f 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -72,7 +72,7 @@ use sp_runtime::{ generic, traits::{ self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, Block, BlockNumberProvider, Bounded, - CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, + CheckEqual, Dispatchable, Extrinsic, Hash, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, DispatchError, RuntimeDebug, @@ -214,6 +214,9 @@ pub mod pallet { /// The Block type used by the node. type NodeBlock: Block; + /// The UncheckedExtrinsic type used by the runtime. + type UncheckedExtrinsic: Extrinsic; + /// Block & extrinsics weights: base values and limits. #[pallet::constant] type BlockWeights: Get; From 2590f4340b125d47bc4969acaa24cee591f6eed2 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 5 Jun 2023 13:47:26 +0530 Subject: [PATCH 04/67] Updates frame_system to use Block --- bin/node-template/runtime/src/lib.rs | 4 ---- .../procedural/src/construct_runtime/mod.rs | 6 +----- frame/system/src/lib.rs | 18 +++++++----------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index fe8bac06a3b64..ff41d88df642d 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,10 +156,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; /// The block type for the runtime. type Block = Block; - /// The block type for the node. - type NodeBlock = Block; - /// The UncheckedExtrinsic type for the runtime. - type UncheckedExtrinsic = UncheckedExtrinsic; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index c2aa963d1ac37..e1c1bcb8bbef6 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -256,8 +256,7 @@ fn construct_runtime_final_expansion( let frame_system = generate_crate_access_2018("frame-system")?; let block = quote!(<#name as #frame_system::Config>::Block); - let node_block = quote!(<#name as #frame_system::Config>::NodeBlock); - let unchecked_extrinsic = quote!(<#name as #frame_system::Config>::UncheckedExtrinsic); + let unchecked_extrinsic = quote!(<#block as #scrate::sp_runtime::traits::Block>::Extrinsic); let outer_event = expand::expand_outer_event(&name, &pallets, &scrate)?; @@ -292,9 +291,6 @@ fn construct_runtime_final_expansion( #scrate::scale_info::TypeInfo )] pub struct #name; - impl #scrate::sp_runtime::traits::GetNodeBlockType for #name { - type NodeBlock = #node_block; - } impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name { type RuntimeBlock = #block; } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index f42b52ae13275..d49fbdee01ad5 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -72,8 +72,8 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::{ generic, traits::{ - self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, Block, BlockNumberProvider, Bounded, - CheckEqual, Dispatchable, Extrinsic, Hash, Lookup, LookupError, MaybeDisplay, + self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded, + CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, DispatchError, RuntimeDebug, @@ -218,6 +218,7 @@ pub mod pallet { type Index = u32; type BlockNumber = u32; type Header = sp_runtime::generic::Header; + type Block = sp_runtime::generic::Block; type Hash = sp_core::hash::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; @@ -252,15 +253,6 @@ pub mod pallet { #[pallet::no_default] type BaseCallFilter: Contains; - /// The Block type used by the runtime. - type Block: Block; - - /// The Block type used by the node. - type NodeBlock: Block; - - /// The UncheckedExtrinsic type used by the runtime. - type UncheckedExtrinsic: Extrinsic; - /// Block & extrinsics weights: base values and limits. #[pallet::constant] type BlockWeights: Get; @@ -349,6 +341,10 @@ pub mod pallet { /// The block header. type Header: Parameter + traits::Header; + /// The Block type used by the runtime. This is used by `construct_runtime` to retrieve the + /// extrinsics or other block specific data as needed. + type Block: Parameter + traits::Block
; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). #[pallet::constant] type BlockHashCount: Get; From f4e772a64bf4b0a2f050b4674178169254604a35 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:42:17 +0530 Subject: [PATCH 05/67] Adds deprecation warning --- .../procedural/src/construct_runtime/mod.rs | 16 +++ .../procedural/src/construct_runtime/parse.rs | 104 +++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index e1c1bcb8bbef6..ccf742d9e49bf 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -217,6 +217,7 @@ fn construct_runtime_final_expansion( name, pallets, pallets_token, + where_section, } = definition; let system_pallet = @@ -277,7 +278,22 @@ fn construct_runtime_final_expansion( let integrity_test = decl_integrity_test(&scrate); let static_assertions = decl_static_assertions(&name, &pallets, &scrate); + let warning = if let Some(where_section) = where_section { + Some(proc_macro_warning::Warning::new_deprecated("WhereSection") + .old("use where section") + .new("use `frame_system::Config` to set the `Block` type and remove this section") + .help_links(&[ + "https://github.com/paritytech/substrate/pull/14193" + ]) + .span(where_section.span) + .build()) + } else { + None + }; + let res = quote!( + #warning + #scrate_decl // Prevent UncheckedExtrinsic to print unused warning. diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index cfccc1b546874..00f15daa9d823 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -16,7 +16,7 @@ // limitations under the License. use frame_support_procedural_tools::syn_ext as ext; -use proc_macro2::TokenStream; +use proc_macro2::{Span, TokenStream}; use quote::ToTokens; use std::collections::{HashMap, HashSet}; use syn::{ @@ -62,6 +62,7 @@ pub enum RuntimeDeclaration { #[derive(Debug)] pub struct ImplicitRuntimeDeclaration { pub name: Ident, + pub where_section: Option, pub pallets: Vec, } @@ -69,6 +70,7 @@ pub struct ImplicitRuntimeDeclaration { #[derive(Debug)] pub struct ExplicitRuntimeDeclaration { pub name: Ident, + pub where_section: Option, pub pallets: Vec, pub pallets_token: token::Brace, } @@ -85,6 +87,11 @@ impl Parse for RuntimeDeclaration { } let name = input.parse::()?; + let where_section = if input.peek(token::Where) { + Some(input.parse()?) + } else { + None + }; let pallets = input.parse::>>()?; let pallets_token = pallets.token; @@ -93,11 +100,13 @@ impl Parse for RuntimeDeclaration { PalletsConversion::Implicit(pallets) => Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { name, + where_section, pallets, })), PalletsConversion::Explicit(pallets) => Ok(RuntimeDeclaration::Explicit(ExplicitRuntimeDeclaration { name, + where_section, pallets, pallets_token, })), @@ -105,6 +114,83 @@ impl Parse for RuntimeDeclaration { } } +#[derive(Debug)] +pub struct WhereSection { + pub span: Span, + pub block: syn::TypePath, + pub node_block: syn::TypePath, + pub unchecked_extrinsic: syn::TypePath, +} + +impl Parse for WhereSection { + fn parse(input: ParseStream) -> Result { + input.parse::()?; + + let mut definitions = Vec::new(); + while !input.peek(token::Brace) { + let definition: WhereDefinition = input.parse()?; + definitions.push(definition); + if !input.peek(Token![,]) { + if !input.peek(token::Brace) { + return Err(input.error("Expected `,` or `{`")) + } + break + } + input.parse::()?; + } + let block = remove_kind(input, WhereKind::Block, &mut definitions)?.value; + let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; + let unchecked_extrinsic = + remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; + if let Some(WhereDefinition { ref kind_span, ref kind, .. }) = definitions.first() { + let msg = format!( + "`{:?}` was declared above. Please use exactly one declaration for `{:?}`.", + kind, kind + ); + return Err(Error::new(*kind_span, msg)) + } + Ok(Self { span: input.span(), block, node_block, unchecked_extrinsic }) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] +pub enum WhereKind { + Block, + NodeBlock, + UncheckedExtrinsic, +} + +#[derive(Debug)] +pub struct WhereDefinition { + pub kind_span: Span, + pub kind: WhereKind, + pub value: syn::TypePath, +} + +impl Parse for WhereDefinition { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + let (kind_span, kind) = if lookahead.peek(keyword::Block) { + (input.parse::()?.span(), WhereKind::Block) + } else if lookahead.peek(keyword::NodeBlock) { + (input.parse::()?.span(), WhereKind::NodeBlock) + } else if lookahead.peek(keyword::UncheckedExtrinsic) { + (input.parse::()?.span(), WhereKind::UncheckedExtrinsic) + } else { + return Err(lookahead.error()) + }; + + Ok(Self { + kind_span, + kind, + value: { + let _: Token![=] = input.parse()?; + input.parse()? + }, + }) + } +} + /// The declaration of a pallet. #[derive(Debug, Clone)] pub struct PalletDeclaration { @@ -422,6 +508,22 @@ impl PalletPart { } } +fn remove_kind( + input: ParseStream, + kind: WhereKind, + definitions: &mut Vec, +) -> Result { + if let Some(pos) = definitions.iter().position(|d| d.kind == kind) { + Ok(definitions.remove(pos)) + } else { + let msg = format!( + "Missing associated type for `{:?}`. Add `{:?}` = ... to where section.", + kind, kind + ); + Err(input.error(msg)) + } +} + /// The declaration of a part without its generics #[derive(Debug, Clone)] pub struct PalletPartNoGeneric { From b6ca21e7c688387f4dd3dcaee4ffd9c63749925e Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:22:21 +0530 Subject: [PATCH 06/67] Fixes pallet-timestamp --- frame/system/src/lib.rs | 5 ++++- frame/timestamp/src/mock.rs | 7 ++----- primitives/runtime/src/generic/block.rs | 10 +++++++++- primitives/runtime/src/testing.rs | 8 ++++++++ primitives/runtime/src/traits.rs | 10 +++++++++- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 22bdbb73c9516..f0ce96f59ecdd 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -219,7 +219,6 @@ pub mod pallet { type Index = u32; type BlockNumber = u32; type Header = sp_runtime::generic::Header; - type Block = sp_runtime::generic::Block; type Hash = sp_core::hash::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; @@ -344,6 +343,7 @@ pub mod pallet { /// The Block type used by the runtime. This is used by `construct_runtime` to retrieve the /// extrinsics or other block specific data as needed. + #[pallet::no_default] type Block: Parameter + traits::Block
; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). @@ -1838,4 +1838,7 @@ pub mod pallet_prelude { /// Type alias for the `BlockNumber` associated type of system config. pub type BlockNumberFor = ::BlockNumber; + + /// Type alias for the `Header`. + pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; } diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 6f681788236c3..fa2851e1ca4e6 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -31,15 +31,11 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Moment = u64; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -60,6 +56,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 6261e412eb8ad..1b6003535fceb 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -79,13 +79,21 @@ impl fmt::Display for BlockId { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -pub struct Block { +pub struct Block { /// The block header. pub header: Header, /// The accompanying extrinsics. pub extrinsics: Vec, } +impl traits::HeaderProvider for Block +where + Header: HeaderT +{ + type HeaderT = Header; + type HashT = ::Hash; +} + impl traits::Block for Block where Header: HeaderT, diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index 6d02e23094f90..472636fce8c72 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -243,6 +243,14 @@ pub struct Block { pub extrinsics: Vec, } +impl< + Xt + > traits::HeaderProvider for Block +{ + type HeaderT = Header; + type HashT =
::Hash; +} + impl< Xt: 'static + Codec + Sized + Send + Sync + Serialize + Clone + Eq + Debug + traits::Extrinsic, > traits::Block for Block diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 9c09bad21d9bc..69a7d11bc8a85 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1210,11 +1210,19 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 's } } +/// Something that provides the Header Type. +pub trait HeaderProvider { + /// Header type. + type HeaderT: Header; + /// Block hash type. + type HashT: HashOutput; +} + /// Something which fulfills the abstract idea of a Substrate block. It has types for /// `Extrinsic` pieces of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. -pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Block: HeaderProvider::Header, HashT = ::Hash> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. From 1333eb312d0b705a1d2e95b5d7208fb8f84b3744 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:52:02 +0530 Subject: [PATCH 07/67] Removes Header and BlockNumber --- .../procedural/src/pallet/expand/hooks.rs | 40 ++++++------ frame/system/src/extensions/check_genesis.rs | 4 +- .../system/src/extensions/check_mortality.rs | 4 +- frame/system/src/lib.rs | 61 +++++++------------ frame/system/src/mocking.rs | 2 +- frame/timestamp/src/lib.rs | 2 +- frame/timestamp/src/mock.rs | 7 +-- primitives/runtime/src/generic/block.rs | 12 +++- primitives/runtime/src/generic/header.rs | 9 ++- primitives/runtime/src/traits.rs | 19 ++++-- 10 files changed, 80 insertions(+), 80 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index ef22f5a3af5be..76e1fe76116b2 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -75,7 +75,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let frame_system = &def.frame_system; quote::quote! { impl<#type_impl_gen> - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause {} } } else { @@ -137,50 +137,50 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #hooks_impl impl<#type_impl_gen> - #frame_support::traits::OnFinalize<::BlockNumber> + #frame_support::traits::OnFinalize<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { - fn on_finalize(n: ::BlockNumber) { + fn on_finalize(n: #frame_system::pallet_prelude::BlockNumberFor::) { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("on_finalize") ); < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_finalize(n) } } impl<#type_impl_gen> - #frame_support::traits::OnIdle<::BlockNumber> + #frame_support::traits::OnIdle<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn on_idle( - n: ::BlockNumber, + n: #frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: #frame_support::weights::Weight ) -> #frame_support::weights::Weight { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_idle(n, remaining_weight) } } impl<#type_impl_gen> - #frame_support::traits::OnInitialize<::BlockNumber> + #frame_support::traits::OnInitialize<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn on_initialize( - n: ::BlockNumber + n: #frame_system::pallet_prelude::BlockNumberFor:: ) -> #frame_support::weights::Weight { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("on_initialize") ); < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_initialize(n) } @@ -205,7 +205,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_runtime_upgrade() } @@ -215,7 +215,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> >::pre_upgrade() } @@ -226,19 +226,19 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> >::post_upgrade(state) } } impl<#type_impl_gen> - #frame_support::traits::OffchainWorker<::BlockNumber> + #frame_support::traits::OffchainWorker<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { - fn offchain_worker(n: ::BlockNumber) { + fn offchain_worker(n: #frame_system::pallet_prelude::BlockNumberFor::) { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::offchain_worker(n) } @@ -253,7 +253,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { fn integrity_test() { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::integrity_test() } @@ -262,17 +262,17 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #[cfg(feature = "try-runtime")] impl<#type_impl_gen> - #frame_support::traits::TryState<::BlockNumber> + #frame_support::traits::TryState<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn try_state( - n: ::BlockNumber, + n: #frame_system::pallet_prelude::BlockNumberFor::, _s: #frame_support::traits::TryStateSelect ) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { #log_try_state < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::try_state(n) } diff --git a/frame/system/src/extensions/check_genesis.rs b/frame/system/src/extensions/check_genesis.rs index 5964ec452842f..39c061e0fa87f 100644 --- a/frame/system/src/extensions/check_genesis.rs +++ b/frame/system/src/extensions/check_genesis.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Config, Pallet}; +use crate::{Config, Pallet, pallet_prelude::BlockNumberFor}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ @@ -60,7 +60,7 @@ impl SignedExtension for CheckGenesis { const IDENTIFIER: &'static str = "CheckGenesis"; fn additional_signed(&self) -> Result { - Ok(>::block_hash(T::BlockNumber::zero())) + Ok(>::block_hash(BlockNumberFor::::zero())) } fn pre_dispatch( diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 23c357d481350..7d4f280606db1 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{BlockHash, Config, Pallet}; +use crate::{BlockHash, Config, Pallet, pallet_prelude::BlockNumberFor}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ @@ -78,7 +78,7 @@ impl SignedExtension for CheckMortality { fn additional_signed(&self) -> Result { let current_u64 = >::block_number().saturated_into::(); - let n = self.0.birth(current_u64).saturated_into::(); + let n = self.0.birth(current_u64).saturated_into::>(); if !>::contains_key(n) { Err(InvalidTransaction::AncientBirthBlock.into()) } else { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index f0ce96f59ecdd..0f8141479d0f3 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -64,6 +64,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +use pallet_prelude::{BlockNumberFor, HeaderFor}; #[cfg(feature = "std")] use serde::Serialize; use sp_io::hashing::blake2_256; @@ -72,8 +73,8 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::{ generic, traits::{ - self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded, - CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, + self, AtLeast32Bit, BadOrigin, BlockNumberProvider, Bounded, + CheckEqual, Dispatchable, Hash, Header, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, DispatchError, RuntimeDebug, @@ -217,13 +218,10 @@ pub mod pallet { #[frame_support::register_default_impl(TestDefaultConfig)] impl DefaultConfig for TestDefaultConfig { type Index = u32; - type BlockNumber = u32; - type Header = sp_runtime::generic::Header; type Hash = sp_core::hash::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type BlockHashCount = frame_support::traits::ConstU32<10>; type MaxConsumers = frame_support::traits::ConstU32<16>; type AccountData = (); type OnNewAccount = (); @@ -287,21 +285,6 @@ pub mod pallet { + Copy + MaxEncodedLen; - /// The block number type used by the runtime. - type BlockNumber: Parameter - + Member - + MaybeSerializeDeserialize - + Debug - + MaybeDisplay - + AtLeast32BitUnsigned - + Default - + Bounded - + Copy - + sp_std::hash::Hash - + sp_std::str::FromStr - + MaxEncodedLen - + TypeInfo; - /// The output of the `Hashing` function. type Hash: Parameter + Member @@ -338,17 +321,15 @@ pub mod pallet { /// functional/efficient alternatives. type Lookup: StaticLookup; - /// The block header. - type Header: Parameter + traits::Header; - /// The Block type used by the runtime. This is used by `construct_runtime` to retrieve the /// extrinsics or other block specific data as needed. #[pallet::no_default] - type Block: Parameter + traits::Block
; + type Block: Parameter + Member + traits::Block; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). #[pallet::constant] - type BlockHashCount: Get; + #[pallet::no_default] + type BlockHashCount: Get>; /// The weight of runtime database operations the runtime can invoke. #[pallet::constant] @@ -595,7 +576,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn block_hash)] pub type BlockHash = - StorageMap<_, Twox64Concat, T::BlockNumber, T::Hash, ValueQuery>; + StorageMap<_, Twox64Concat, BlockNumberFor, T::Hash, ValueQuery>; /// Extrinsics data for the current block (maps an extrinsic's index to its data). #[pallet::storage] @@ -608,7 +589,7 @@ pub mod pallet { #[pallet::storage] #[pallet::whitelist_storage] #[pallet::getter(fn block_number)] - pub(super) type Number = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type Number = StorageValue<_, BlockNumberFor, ValueQuery>; /// Hash of the previous block. #[pallet::storage] @@ -647,14 +628,14 @@ pub mod pallet { /// allows light-clients to leverage the changes trie storage tracking mechanism and /// in case of changes fetch the list of events of interest. /// - /// The value has the type `(T::BlockNumber, EventIndex)` because if we used only just + /// The value has the type `(BlockNumberFor, EventIndex)` because if we used only just /// the `EventIndex` then in case if the topic has the same contents on the next block /// no notification will be triggered thus the event might be lost. #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn event_topics)] pub(super) type EventTopics = - StorageMap<_, Blake2_128Concat, T::Hash, Vec<(T::BlockNumber, EventIndex)>, ValueQuery>; + StorageMap<_, Blake2_128Concat, T::Hash, Vec<(BlockNumberFor, EventIndex)>, ValueQuery>; /// Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened. #[pallet::storage] @@ -685,7 +666,7 @@ pub mod pallet { #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { - >::insert::<_, T::Hash>(T::BlockNumber::zero(), hash69()); + >::insert::<_, T::Hash>(BlockNumberFor::::zero(), hash69()); >::put::(hash69()); >::put(LastRuntimeUpgradeInfo::from(T::Version::get())); >::put(true); @@ -1393,7 +1374,7 @@ impl Pallet { } /// Start the execution of a particular block. - pub fn initialize(number: &T::BlockNumber, parent_hash: &T::Hash, digest: &generic::Digest) { + pub fn initialize(number: &BlockNumberFor, parent_hash: &T::Hash, digest: &generic::Digest) { // populate environment ExecutionPhase::::put(Phase::Initialization); storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); @@ -1410,7 +1391,7 @@ impl Pallet { /// Remove temporary "environment" entries in storage, compute the storage root and return the /// resulting header for this block. - pub fn finalize() -> T::Header { + pub fn finalize() -> HeaderFor { log::debug!( target: LOG_TARGET, "[{:?}] {} extrinsics, length: {} (normal {}%, op: {}%, mandatory {}%) / normal weight:\ @@ -1482,7 +1463,7 @@ impl Pallet { let storage_root = T::Hash::decode(&mut &sp_io::storage::root(version)[..]) .expect("Node is configured to use the same hash; qed"); - ::new( + HeaderFor::::new( number, extrinsics_root, storage_root, @@ -1501,8 +1482,8 @@ impl Pallet { pub fn externalities() -> TestExternalities { TestExternalities::new(sp_core::storage::Storage { top: map![ - >::hashed_key_for(T::BlockNumber::zero()) => [69u8; 32].encode(), - >::hashed_key().to_vec() => T::BlockNumber::one().encode(), + >::hashed_key_for(BlockNumberFor::::zero()) => [69u8; 32].encode(), + >::hashed_key().to_vec() => BlockNumberFor::::one().encode(), >::hashed_key().to_vec() => [69u8; 32].encode() ], children_default: map![], @@ -1547,7 +1528,7 @@ impl Pallet { /// Set the block number to something in particular. Can be used as an alternative to /// `initialize` for tests that don't need to bother with the other environment entries. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] - pub fn set_block_number(n: T::BlockNumber) { + pub fn set_block_number(n: BlockNumberFor) { >::put(n); } @@ -1765,7 +1746,7 @@ impl HandleLifetime for Consumer { } impl BlockNumberProvider for Pallet { - type BlockNumber = ::BlockNumber; + type BlockNumber = BlockNumberFor; fn current_block_number() -> Self::BlockNumber { Pallet::::block_number() @@ -1836,9 +1817,9 @@ pub mod pallet_prelude { /// Type alias for the `Origin` associated type of system config. pub type OriginFor = ::RuntimeOrigin; - /// Type alias for the `BlockNumber` associated type of system config. - pub type BlockNumberFor = ::BlockNumber; - /// Type alias for the `Header`. pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + /// Type alias for the `BlockNumber` associated type of system config. + pub type BlockNumberFor = sp_runtime::traits::NumberFor<::Block>; } diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index 8f76c1b8e08ba..b02a1b1d683dd 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -29,6 +29,6 @@ pub type MockUncheckedExtrinsic = generic::Unchec /// An implementation of `sp_runtime::traits::Block` to be used in tests. pub type MockBlock = generic::Block< - generic::Header<::BlockNumber, sp_runtime::traits::BlakeTwo256>, + generic::Header, MockUncheckedExtrinsic, >; diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index e707764beb95c..4eb95941d7828 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -130,7 +130,7 @@ pub mod pallet { type Moment: Parameter + Default + AtLeast32Bit - + Scale + + Scale, Output = Self::Moment> + Copy + MaxEncodedLen + scale_info::StaticTypeInfo; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index fa2851e1ca4e6..d111d946ef798 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -26,10 +26,7 @@ use frame_support::{ }; use sp_core::H256; use sp_io::TestExternalities; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; type Moment = u64; @@ -49,13 +46,11 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 1b6003535fceb..9929e2d2b8b6e 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize}; use crate::{ codec::{Codec, Decode, Encode}, - traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor}, + traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, NumberFor}, Justifications, }; use sp_core::RuntimeDebug; @@ -97,7 +97,15 @@ where impl traits::Block for Block where Header: HeaderT, - Extrinsic: Member + Codec + traits::Extrinsic, + Extrinsic: sp_std::fmt::Debug + + Clone + + Send + + Sync + + Codec + + traits::Extrinsic + + MaybeSerialize + + Eq + + 'static, { type Extrinsic = Extrinsic; type Header = Header; diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index 6fdf43ac08105..82ab9a61f96d8 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -26,6 +26,7 @@ use crate::{ MaybeSerializeDeserialize, Member, }, }; +use codec::{FullCodec, MaxEncodedLen}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use sp_core::U256; @@ -33,6 +34,7 @@ use sp_std::fmt::Debug; /// Abstraction over a block header for a substrate chain. #[derive(Encode, Decode, PartialEq, Eq, Clone, sp_core::RuntimeDebug, TypeInfo)] +#[scale_info(skip_type_params(Hash))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] @@ -81,13 +83,16 @@ where + MaybeSerializeDeserialize + MaybeFromStr + Debug + + Default + sp_std::hash::Hash + MaybeDisplay + AtLeast32BitUnsigned - + Codec + + FullCodec + Copy + + MaxEncodedLen + Into - + TryFrom, + + TryFrom + + TypeInfo, Hash: HashT, { type Number = Number; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 69a7d11bc8a85..78524f5561923 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -26,7 +26,7 @@ use crate::{ }, DispatchResult, }; -use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use codec::{Codec, Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use impl_trait_for_tuples::impl_for_tuples; #[cfg(feature = "serde")] use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -1154,7 +1154,7 @@ pub trait IsMember { /// `parent_hash`, as well as a `digest` and a block `number`. /// /// You can also create a `new` one from those fields. -pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + TypeInfo + 'static { /// Header number. type Number: Member + MaybeSerializeDeserialize @@ -1164,7 +1164,10 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 's + Copy + MaybeDisplay + AtLeast32BitUnsigned - + Codec; + + Default + + TypeInfo + + MaxEncodedLen + + FullCodec; /// Header hash type type Hash: HashOutput; /// Hashing algorithm @@ -1224,7 +1227,15 @@ pub trait HeaderProvider { /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. pub trait Block: HeaderProvider::Header, HashT = ::Hash> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Type for extrinsics. - type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; + type Extrinsic: Debug + + Clone + + Send + + Sync + + Codec + + Extrinsic + + MaybeSerialize + + Eq + + PartialEq; /// Header type. type Header: Header; /// Block hash type. From 373af3033be298601ff7cecec6fd4a82e831dabc Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sat, 24 Jun 2023 17:29:43 +0530 Subject: [PATCH 08/67] Addresses review comments --- frame/system/src/lib.rs | 2 +- primitives/runtime/src/generic/block.rs | 1 - primitives/runtime/src/testing.rs | 1 - primitives/runtime/src/traits.rs | 6 ++---- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 0f8141479d0f3..c03c125b2121f 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1821,5 +1821,5 @@ pub mod pallet_prelude { pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; /// Type alias for the `BlockNumber` associated type of system config. - pub type BlockNumberFor = sp_runtime::traits::NumberFor<::Block>; + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 9929e2d2b8b6e..4326b32996fe1 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -91,7 +91,6 @@ where Header: HeaderT { type HeaderT = Header; - type HashT = ::Hash; } impl traits::Block for Block diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index 472636fce8c72..bc9675fe0561e 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -248,7 +248,6 @@ impl< > traits::HeaderProvider for Block { type HeaderT = Header; - type HashT =
::Hash; } impl< diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 78524f5561923..c98e9d7f9cd36 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1216,16 +1216,14 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + Ty /// Something that provides the Header Type. pub trait HeaderProvider { /// Header type. - type HeaderT: Header; - /// Block hash type. - type HashT: HashOutput; + type HeaderT: Header; } /// Something which fulfills the abstract idea of a Substrate block. It has types for /// `Extrinsic` pieces of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. -pub trait Block: HeaderProvider::Header, HashT = ::Hash> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Block: HeaderProvider::Header> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Type for extrinsics. type Extrinsic: Debug + Clone From 55a698cc51f218aa44542091943b1a09ba4f9b07 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sat, 24 Jun 2023 17:33:41 +0530 Subject: [PATCH 09/67] Addresses review comments --- primitives/runtime/src/generic/block.rs | 12 ++---------- primitives/runtime/src/traits.rs | 10 +--------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 4326b32996fe1..d8602769d9a66 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize}; use crate::{ codec::{Codec, Decode, Encode}, - traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, NumberFor}, + traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor}, Justifications, }; use sp_core::RuntimeDebug; @@ -96,15 +96,7 @@ where impl traits::Block for Block where Header: HeaderT, - Extrinsic: sp_std::fmt::Debug - + Clone - + Send - + Sync - + Codec - + traits::Extrinsic - + MaybeSerialize - + Eq - + 'static, + Extrinsic: Member + Codec + traits::Extrinsic, { type Extrinsic = Extrinsic; type Header = Header; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index c98e9d7f9cd36..df491eefd02ec 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1225,15 +1225,7 @@ pub trait HeaderProvider { /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. pub trait Block: HeaderProvider::Header> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Type for extrinsics. - type Extrinsic: Debug - + Clone - + Send - + Sync - + Codec - + Extrinsic - + MaybeSerialize - + Eq - + PartialEq; + type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. type Header: Header; /// Block hash type. From c1db41a169f9e29b2cb5be8ceb2a7c70bbba41bf Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sat, 24 Jun 2023 17:42:12 +0530 Subject: [PATCH 10/67] Adds comment about compiler bug --- primitives/runtime/src/traits.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index df491eefd02ec..4caa904699901 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1214,6 +1214,21 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + Ty } /// Something that provides the Header Type. +// This is needed to fix the "cyclical" issue in loading Header/BlockNumber as part of a +// `pallet::call`. Essentially, `construct_runtime` aggregates all calls to create a `RuntimeCall` +// that is then used to define `UncheckedExtrinsic`. +// ```ignore +// pub type UncheckedExtrinsic = +// generic::UncheckedExtrinsic; +// ``` +// This `UncheckedExtrinsic` is supplied to the `Block`. +// ```ignore +// pub type Block = generic::Block; +// ``` +// So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a +// recursive loop leading to a build error. +// +// Note that this is a workaround and should be removed once we have a better solution. pub trait HeaderProvider { /// Header type. type HeaderT: Header; From a36245cfae65477f3685ed8beaf45e1ab0601d5e Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:05:07 +0530 Subject: [PATCH 11/67] Removes where clause --- bin/node/runtime/src/lib.rs | 5 +---- frame/alliance/src/mock.rs | 5 +---- frame/asset-conversion/src/mock.rs | 5 +---- frame/asset-rate/src/mock.rs | 5 +---- frame/assets/src/mock.rs | 5 +---- frame/atomic-swap/src/tests.rs | 5 +---- frame/aura/src/mock.rs | 5 +---- frame/authority-discovery/src/lib.rs | 5 +---- frame/authorship/src/lib.rs | 5 +---- frame/babe/src/mock.rs | 5 +---- frame/bags-list/src/mock.rs | 5 +---- frame/balances/src/tests/mod.rs | 5 +---- frame/beefy-mmr/src/mock.rs | 5 +---- frame/beefy/src/mock.rs | 5 +---- frame/benchmarking/pov/src/benchmarking.rs | 5 +---- frame/benchmarking/pov/src/tests.rs | 5 +---- frame/benchmarking/src/baseline.rs | 5 +---- frame/benchmarking/src/tests.rs | 5 +---- frame/benchmarking/src/tests_instance.rs | 5 +---- frame/bounties/src/tests.rs | 5 +---- frame/child-bounties/src/tests.rs | 5 +---- frame/collective/src/tests.rs | 5 +---- frame/contracts/src/tests.rs | 5 +---- frame/conviction-voting/src/tests.rs | 5 +---- frame/core-fellowship/src/tests.rs | 5 +---- frame/democracy/src/tests.rs | 5 +---- frame/election-provider-multi-phase/src/mock.rs | 5 +---- .../test-staking-e2e/src/mock.rs | 5 +---- frame/election-provider-support/src/onchain.rs | 5 +---- frame/elections-phragmen/src/lib.rs | 5 +---- frame/examples/basic/src/tests.rs | 5 +---- frame/examples/default-config/src/lib.rs | 5 +---- frame/examples/dev-mode/src/tests.rs | 5 +---- frame/examples/kitchensink/src/tests.rs | 5 +---- frame/examples/offchain-worker/src/tests.rs | 5 +---- frame/glutton/src/mock.rs | 5 +---- frame/grandpa/src/mock.rs | 5 +---- frame/identity/src/tests.rs | 5 +---- frame/im-online/src/mock.rs | 5 +---- frame/indices/src/mock.rs | 5 +---- frame/insecure-randomness-collective-flip/src/lib.rs | 5 +---- frame/lottery/src/mock.rs | 5 +---- frame/membership/src/lib.rs | 5 +---- frame/merkle-mountain-range/src/mock.rs | 5 +---- frame/message-queue/src/integration_test.rs | 5 +---- frame/message-queue/src/mock.rs | 5 +---- frame/multisig/src/tests.rs | 5 +---- frame/nft-fractionalization/src/mock.rs | 5 +---- frame/nfts/src/mock.rs | 5 +---- frame/nicks/src/lib.rs | 5 +---- frame/nis/src/mock.rs | 5 +---- frame/nomination-pools/benchmarking/src/mock.rs | 5 +---- frame/nomination-pools/src/mock.rs | 5 +---- frame/nomination-pools/test-staking/src/mock.rs | 5 +---- frame/offences/benchmarking/src/mock.rs | 5 +---- frame/offences/src/mock.rs | 5 +---- frame/preimage/src/mock.rs | 5 +---- frame/proxy/src/tests.rs | 5 +---- frame/ranked-collective/src/tests.rs | 5 +---- frame/recovery/src/mock.rs | 5 +---- frame/referenda/src/mock.rs | 5 +---- frame/remark/src/mock.rs | 5 +---- frame/root-offences/src/mock.rs | 5 +---- frame/salary/src/tests.rs | 5 +---- frame/scheduler/src/mock.rs | 5 +---- frame/scored-pool/src/mock.rs | 5 +---- frame/session/benchmarking/src/mock.rs | 5 +---- frame/session/src/mock.rs | 10 ++-------- frame/society/src/mock.rs | 5 +---- frame/staking/src/mock.rs | 5 +---- frame/state-trie-migration/src/lib.rs | 5 +---- frame/statement/src/mock.rs | 5 +---- frame/sudo/src/mock.rs | 5 +---- frame/support/test/tests/construct_runtime.rs | 5 +---- .../both_use_and_excluded_parts.rs | 5 +---- .../construct_runtime_ui/conflicting_module_name.rs | 5 +---- .../tests/construct_runtime_ui/double_module_parts.rs | 5 +---- .../tests/construct_runtime_ui/empty_pallet_path.rs | 5 +---- .../construct_runtime_ui/exclude_undefined_part.rs | 5 +---- .../feature_gated_system_pallet.rs | 5 +---- .../construct_runtime_ui/generics_in_invalid_module.rs | 5 +---- .../tests/construct_runtime_ui/invalid_meta_literal.rs | 5 +---- .../construct_runtime_ui/invalid_module_details.rs | 5 +---- .../invalid_module_details_keyword.rs | 5 +---- .../tests/construct_runtime_ui/invalid_module_entry.rs | 5 +---- .../construct_runtime_ui/invalid_token_after_module.rs | 5 +---- .../construct_runtime_ui/invalid_token_after_name.rs | 5 +---- .../missing_event_generic_on_module_with_instance.rs | 5 +---- .../construct_runtime_ui/missing_module_instance.rs | 5 +---- .../missing_origin_generic_on_module_with_instance.rs | 5 +---- .../construct_runtime_ui/missing_system_module.rs | 5 +---- .../number_of_pallets_exceeds_tuple_size.rs | 5 +---- .../construct_runtime_ui/pallet_error_too_large.rs | 5 +---- .../tests/construct_runtime_ui/undefined_call_part.rs | 5 +---- .../tests/construct_runtime_ui/undefined_event_part.rs | 5 +---- .../undefined_genesis_config_part.rs | 5 +---- .../construct_runtime_ui/undefined_inherent_part.rs | 5 +---- .../construct_runtime_ui/undefined_origin_part.rs | 5 +---- .../undefined_validate_unsigned_part.rs | 5 +---- .../construct_runtime_ui/unsupported_meta_structure.rs | 5 +---- .../construct_runtime_ui/unsupported_pallet_attr.rs | 5 +---- .../tests/construct_runtime_ui/use_undefined_part.rs | 5 +---- frame/support/test/tests/instance.rs | 5 +---- frame/support/test/tests/origin.rs | 5 +---- frame/support/test/tests/pallet.rs | 5 +---- frame/support/test/tests/pallet_instance.rs | 5 +---- .../test/tests/pallet_ui/pass/dev_mode_valid.rs | 5 +---- .../test/tests/pallet_ui/pass/no_std_genesis_config.rs | 5 +---- frame/support/test/tests/runtime_metadata.rs | 5 +---- frame/system/benches/bench.rs | 5 +---- frame/system/benchmarking/src/mock.rs | 5 +---- frame/system/src/mock.rs | 5 +---- frame/tips/src/tests.rs | 5 +---- frame/transaction-payment/src/mock.rs | 5 +---- frame/transaction-storage/src/mock.rs | 5 +---- frame/treasury/src/tests.rs | 5 +---- frame/uniques/src/mock.rs | 5 +---- frame/utility/src/tests.rs | 5 +---- frame/vesting/src/mock.rs | 5 +---- frame/whitelist/src/mock.rs | 5 +---- 120 files changed, 121 insertions(+), 484 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 7d16a1afa1f2d..cc0f85e05375b 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1860,10 +1860,7 @@ impl pallet_statement::Config for Runtime { } construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = node_primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system, Utility: pallet_utility, diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index e1da028f44576..5e40116912765 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -242,10 +242,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 34d2eeb273ca8..2b51c685317d0 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -39,10 +39,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 2d90fcfecd79e..47342a4949ca4 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -29,10 +29,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, AssetRate: pallet_asset_rate, diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 09d2bd2296088..428d36b2840c9 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -36,10 +36,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 53ccd64bb2731..96b18d2b9eb9f 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -14,10 +14,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index c95b7451d0bd4..3f3fe743e0d1c 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -35,10 +35,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 6365c95359472..3262afa8e9dae 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -184,10 +184,7 @@ mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 4bb8ba587ac8b..54ec0e0cc73b9 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -112,10 +112,7 @@ mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Authorship: pallet_authorship::{Pallet, Storage}, diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c0ccc9a8acd32..330ab38186152 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -46,10 +46,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index efbb2ed94c49f..082e7e333771e 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -89,10 +89,7 @@ impl bags_list::Config for Runtime { type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Event, Config}, BagsList: bags_list::{Pallet, Call, Storage, Event}, diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 6deb9885b79e5..1f216e03ee082 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -73,10 +73,7 @@ pub enum TestId { } frame_support::construct_runtime!( - pub struct Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 31484aaa6be70..551600fc23ce8 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -49,10 +49,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 7edf4d339758c..62ead054668f3 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -55,10 +55,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 27191e37219fd..cd7b98001e2e0 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -349,10 +349,7 @@ mod mock { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index b908925cccd8e..95e1e2cd19b10 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -168,10 +168,7 @@ mod mock { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 25336b6974d9f..bae87e353684b 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -121,10 +121,7 @@ pub mod mock { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index c3f51aeb53d5a..5060f39f59d2b 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -70,10 +70,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage}, diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 7e02cbf834d08..65e7c2eadd8df 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -80,10 +80,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage, Event}, diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 9fe34b16029cb..407d7113e9a92 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -43,10 +43,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index a8f0e16ea2136..6240ee3c21c65 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -45,10 +45,7 @@ type Block = frame_system::mocking::MockBlock; type BountiesError = pallet_bounties::Error; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 8d4e0a4a82cd7..019ab381f2279 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -36,10 +36,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: frame_system::{Pallet, Call, Event}, Collective: pallet_collective::::{Pallet, Call, Event, Origin, Config}, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 48b56128d5298..97d71db90cde8 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -60,10 +60,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 1ea3a56adacb7..852303603883d 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -36,10 +36,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 87c0de112ac33..47aec4e2d4083 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -41,10 +41,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, CoreFellowship: pallet_core_fellowship::{Pallet, Call, Storage, Event}, diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index dd726004648ef..2522b61dacbac 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -55,10 +55,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index cf797aea845f4..95845fc4ca0e2 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -54,10 +54,7 @@ pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event, Config}, Balances: pallet_balances::{Pallet, Call, Event, Config}, 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 da7ccf6dce9ce..16154564c467a 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 @@ -54,10 +54,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic type Extrinsic = testing::TestXt; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { System: frame_system, ElectionProviderMultiPhase: pallet_election_provider_multi_phase, diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index a312562d4944c..89034b0bd85ec 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -197,10 +197,7 @@ mod tests { pub type Block = sp_runtime::generic::Block; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index ee8bcc1de50a4..375133800cc69 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1446,10 +1446,7 @@ mod tests { sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: frame_system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Event, Config}, diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 621d93b97cd01..8b46f36589e1e 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -39,10 +39,7 @@ type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 5112f3d72d59e..e7e8ca1c4bbd5 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -114,10 +114,7 @@ pub mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, DefaultPallet: pallet_default_config_example, diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index 8a1ca6628b91c..dd1b1205af57b 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -33,10 +33,7 @@ type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index 9f1cdda9ea228..debc17d95d8ee 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -28,10 +28,7 @@ type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 3df7f4a8d5439..1e4107b2f80ad 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -40,10 +40,7 @@ type Block = frame_system::mocking::MockBlock; // For testing the module, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Example: example_offchain_worker::{Pallet, Call, Storage, Event, ValidateUnsigned}, diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index f2ce53b206fa8..ff59bc8d98e48 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -32,10 +32,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Glutton: pallet_glutton::{Pallet, Event}, diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index df012ab9dc6e8..292753a70fbe5 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -46,10 +46,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 83035c402a7dc..0f3fee40e6a9b 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -37,10 +37,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 78a86edf54598..1a99302f6e309 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -43,10 +43,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index f54e4dfa088dc..b4adada76fa30 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -28,10 +28,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index ad39c4c4fd885..46f2d4ecf50ca 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -178,10 +178,7 @@ mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, CollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage}, diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index d89c9d6890ee2..7e1779e9148fc 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -37,10 +37,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 74891186a4e22..eeffe51f2baf8 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -538,10 +538,7 @@ mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Membership: pallet_membership::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index cea426368c35c..d55bd91a36100 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -34,10 +34,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MMR: pallet_mmr::{Pallet, Storage}, diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index 255098b3b1415..b2c084a762f8f 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -47,10 +47,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index 71f0b0fa20e30..8dac0fa9b9205 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -38,10 +38,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index cc0fbc8098936..a15d71ebf4218 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -37,10 +37,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 62ff3df5b1a0f..7b555ad80a698 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -42,10 +42,7 @@ type AccountId = ::AccountId; // Configure a mock runtime to test the pallet. construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, NftFractionalization: pallet_nft_fractionalization, diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 79f0b341e9fd3..71e51757484f2 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -36,10 +36,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 7a7b33051b22e..10403ac66d5ab 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -247,10 +247,7 @@ mod tests { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 60aa0f756e9c6..342f54011e412 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -42,10 +42,7 @@ pub type Balance = u64; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances::, diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index d94c63d1bf5b5..6dd379f616d0a 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -177,10 +177,7 @@ impl crate::Config for Runtime {} type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index f0b73bbea28da..6fc9696aa2bfa 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -248,10 +248,7 @@ impl pools::Config for Runtime { type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Event, Config}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index a9c64508564cd..fbdc5b709b081 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -190,10 +190,7 @@ type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 6bb3b9d7f4ee8..ae5c38967a40a 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -219,10 +219,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 17480be76c1d8..a3390200501e9 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -70,10 +70,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Offences: offences::{Pallet, Storage, Event}, diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 7c645da2c51d8..bda894a3921df 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -36,10 +36,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 54b76413bcff4..e9ae32b388cee 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -39,10 +39,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 338dcaacedcf7..dcd387cae6cc3 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -39,10 +39,7 @@ type Block = frame_system::mocking::MockBlock; type Class = Rank; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Club: pallet_ranked_collective::{Pallet, Call, Storage, Event}, diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 523dd3aa3e8dc..e9b136b702d54 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -34,10 +34,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 1a43257cb94e1..0778b591c32f3 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -40,10 +40,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 569c383928189..7467b5b10c8e1 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -31,10 +31,7 @@ pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Remark: pallet_remark::{ Pallet, Call, Event }, diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 8c48e34e4e04a..d5bd98db85099 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -43,10 +43,7 @@ pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 7bad2cf77ace5..b53f870a44eda 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -40,10 +40,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Salary: pallet_salary::{Pallet, Call, Storage, Event}, diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 1b0fb8112469c..f12fd7cdb1d1a 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -97,10 +97,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Logger: logger::{Pallet, Call, Event}, diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 83bc939e8230d..1f553349c1372 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -35,10 +35,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 3b027492e0a6a..8ecab94d72612 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -35,10 +35,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index d6b8d9e207e02..fb5f3e0d54c88 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -80,10 +80,7 @@ type Block = frame_system::mocking::MockBlock; #[cfg(feature = "historical")] frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -93,10 +90,7 @@ frame_support::construct_runtime!( #[cfg(not(feature = "historical"))] frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index ed04aa181e161..a03968823f74f 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -38,10 +38,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index f9af9f5003b43..783580696d3ae 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -86,10 +86,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 05ca21c1de752..f14f95193d8aa 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1070,10 +1070,7 @@ mod mock { // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 8b9e7a1a7d965..447a53cace0a2 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -41,10 +41,7 @@ pub const MIN_ALLOWED_BYTES: u32 = 1024; pub const MAX_ALLOWED_BYTES: u32 = 4096; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 856cb35c8718c..4c397ba361ecd 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -94,10 +94,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Sudo: sudo::{Pallet, Call, Config, Storage, Event}, diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 85e790095eb31..ff999e8d41687 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -253,10 +253,7 @@ pub type Block = generic::Block; use frame_support_test as system; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs index ea468d6de13ee..215f242323c9d 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs @@ -20,10 +20,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs index dd8340daa0233..513fbcfb51354 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs index 3269d22434fdf..68a2523d3bcb2 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Config, Call, Config, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs index 44b7fd0ba25f7..23badd76276e2 100644 --- a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs +++ b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: , } diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs index 83a166fc00552..bcb9075f08bd4 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs @@ -25,10 +25,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, Pallet: pallet exclude_parts { Call }, diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs index 7ab4329110d8b..7e58ff90e5c79 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { #[cfg(test)] System: frame_system::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs index 0912ffc98d54b..1ad1f8e0b1d5f 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::::{Call, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs index c253444ee31db..bce87c51336eb 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[cfg(feature = 1)] diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs index 9fb3169e1df77..bf6919f5a58ef 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::(), } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs index 6ba268b73eea6..51f14e6883e4a 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::{enum}, } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs index d627ffd5b66f7..f70b5b0d63a27 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Error}, diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs index 09c316e6ebaed..c132fa01b2297 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System ? } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs index 18d367d102d3a..42e7759f87f2b 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system ? } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs index 3cd2f157d0475..e1b2d0098d902 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::::{Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs index 24e4ee979bd76..afd96a04854f2 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::<>, } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs index 787ba20117678..33e92c07ee201 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::::{Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs index 7ab902c3aadd8..685f9059b1be2 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { } } diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs index 5dfc67c83836a..d43ebed01f17f 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet1: pallet::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 866c3f0de6c3c..7d32c73820e6b 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -72,10 +72,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 0010f5277bb40..8129dd3656f0b 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Call}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 35212df8f457c..c0cf1ce8bad4c 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index ec753e9a03129..483b1ab21b98b 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Config}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 22eaccca42d97..6165fc00107a3 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Inherent}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index 1705fff49dda8..a13218b748f87 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 8f64d30940725..73257e5842a64 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -47,10 +47,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, ValidateUnsigned}, diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs index e5fd284dc8722..e4e2d3dca021e 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[cfg(feature(test))] diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs index 03363d30a6429..491cc2c90533d 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[attr] diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs index 971e2b831ae08..1490e26b98187 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs @@ -25,10 +25,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, Pallet: pallet use_parts { Call }, diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 28611ddbf599c..555602771fa40 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -277,10 +277,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { System: frame_support_test::{Pallet, Call, Event}, Module1_1: module1::::{ diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 47451157b352c..0bfba2dcce1a1 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -154,10 +154,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum RuntimeOriginTest where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum RuntimeOriginTest { System: frame_support_test, NestedModule: nested::module, diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index d0efcb3b5c18f..7fcb2d1e05e7c 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -701,10 +701,7 @@ pub type UncheckedExtrinsic = sp_runtime::testing::TestXt>; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Pallet, Storage }, diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 0747753289af0..8afe1bbdf22ec 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -334,10 +334,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Storage }, diff --git a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs index 28b901213943c..db7fe7cae7d1c 100644 --- a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs +++ b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs @@ -89,10 +89,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Pallet, Storage }, diff --git a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs index 9c9c49c4b2740..b51b1a14d2b46 100644 --- a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs +++ b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs @@ -38,10 +38,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: test_pallet::{Pallet, Config}, diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 70ca307d4428c..9f9414a193e52 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -58,10 +58,7 @@ impl frame_system::Config for Runtime { } frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { System: frame_system, } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index e2fed3e51855d..85b07abe3e48f 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -47,10 +47,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Module: module::{Pallet, Event}, diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 8b05c5a8ba82a..8e8f061e1c2df 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -30,10 +30,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index b484c22ad4fe4..6cb35dad8f1ba 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -31,10 +31,7 @@ type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; type Block = mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 25043b413db07..e718ee206e824 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -43,10 +43,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 28d57065eca18..c350ead2a74f0 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -37,10 +37,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 1f8a4e2d09ba8..641e7a4148000 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -34,10 +34,7 @@ pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 0659c2f5941b1..1668344c87334 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -42,10 +42,7 @@ type UtilityCall = pallet_utility::Call; type TreasuryCall = crate::Call; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index e783f0b7cf4d9..2cb200ffb139a 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -34,10 +34,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index ced50f828d564..1de5deb44fee6 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -129,10 +129,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Call, Inherent}, diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 31f35bbdab604..effa6c1da1c17 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -32,10 +32,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index afb9d00861563..2db6800c44301 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -37,10 +37,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, From d4e113f0d991734fecdcb1d9501610485e962c84 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:43:35 +0530 Subject: [PATCH 12/67] Refactors code --- .../pallets/template/src/mock.rs | 8 +- bin/node-template/runtime/src/lib.rs | 1 - bin/node/runtime/src/lib.rs | 3 +- frame/alliance/src/benchmarking.rs | 4 +- frame/alliance/src/lib.rs | 4 +- frame/alliance/src/mock.rs | 3 +- frame/asset-conversion/src/mock.rs | 3 +- frame/asset-rate/src/mock.rs | 3 +- frame/assets/src/mock.rs | 3 +- frame/atomic-swap/src/lib.rs | 4 +- frame/atomic-swap/src/tests.rs | 3 +- frame/aura/src/lib.rs | 2 +- frame/aura/src/mock.rs | 3 +- frame/authority-discovery/src/lib.rs | 5 +- frame/authorship/src/lib.rs | 8 +- frame/babe/src/equivocation.rs | 8 +- frame/babe/src/lib.rs | 44 +++--- frame/babe/src/mock.rs | 3 +- frame/babe/src/randomness.rs | 16 +- frame/bags-list/src/mock.rs | 3 +- frame/balances/README.md | 2 +- frame/balances/src/impl_currency.rs | 2 +- frame/balances/src/lib.rs | 4 +- frame/balances/src/tests/mod.rs | 3 +- frame/beefy-mmr/src/lib.rs | 2 +- frame/beefy-mmr/src/mock.rs | 5 +- frame/beefy/src/equivocation.rs | 4 +- frame/beefy/src/mock.rs | 3 +- frame/benchmarking/pov/src/benchmarking.rs | 5 +- frame/benchmarking/pov/src/tests.rs | 2 +- frame/benchmarking/src/baseline.rs | 5 +- frame/benchmarking/src/tests.rs | 3 +- frame/benchmarking/src/tests_instance.rs | 3 +- frame/bounties/src/benchmarking.rs | 16 +- frame/bounties/src/lib.rs | 6 +- frame/bounties/src/tests.rs | 3 +- frame/child-bounties/src/benchmarking.rs | 6 +- frame/child-bounties/src/lib.rs | 4 +- frame/child-bounties/src/tests.rs | 3 +- frame/collective/src/benchmarking.rs | 6 +- frame/collective/src/lib.rs | 4 +- frame/collective/src/tests.rs | 3 +- frame/contracts/src/exec.rs | 6 +- frame/contracts/src/lib.rs | 4 +- frame/contracts/src/tests.rs | 3 +- frame/contracts/src/wasm/runtime.rs | 2 +- frame/conviction-voting/src/lib.rs | 10 +- frame/conviction-voting/src/tests.rs | 3 +- frame/core-fellowship/src/benchmarking.rs | 4 +- frame/core-fellowship/src/lib.rs | 4 +- frame/core-fellowship/src/tests.rs | 3 +- frame/democracy/src/benchmarking.rs | 8 +- frame/democracy/src/lib.rs | 66 ++++----- frame/democracy/src/migrations/v1.rs | 4 +- frame/democracy/src/tests.rs | 3 +- .../src/benchmarking.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 28 ++-- .../election-provider-multi-phase/src/mock.rs | 5 +- .../src/signed.rs | 4 +- .../src/unsigned.rs | 4 +- .../test-staking-e2e/src/mock.rs | 3 +- .../election-provider-support/src/onchain.rs | 12 +- frame/elections-phragmen/src/lib.rs | 11 +- frame/examples/basic/src/lib.rs | 6 +- frame/examples/basic/src/tests.rs | 3 +- frame/examples/default-config/src/lib.rs | 2 +- frame/examples/dev-mode/src/tests.rs | 3 +- frame/examples/kitchensink/src/lib.rs | 14 +- frame/examples/offchain-worker/src/lib.rs | 30 ++-- frame/examples/offchain-worker/src/tests.rs | 7 +- frame/executive/src/lib.rs | 74 ++++----- frame/fast-unstake/src/lib.rs | 6 +- frame/fast-unstake/src/mock.rs | 8 +- frame/glutton/src/mock.rs | 3 +- frame/grandpa/src/equivocation.rs | 8 +- frame/grandpa/src/lib.rs | 36 ++--- frame/grandpa/src/mock.rs | 3 +- frame/identity/src/tests.rs | 3 +- frame/im-online/src/benchmarking.rs | 4 +- frame/im-online/src/lib.rs | 18 +-- frame/im-online/src/mock.rs | 3 +- frame/indices/src/mock.rs | 3 +- .../src/lib.rs | 11 +- frame/lottery/src/lib.rs | 10 +- frame/lottery/src/mock.rs | 3 +- frame/membership/src/lib.rs | 2 +- frame/merkle-mountain-range/src/lib.rs | 18 +-- frame/merkle-mountain-range/src/mock.rs | 3 +- frame/merkle-mountain-range/src/tests.rs | 2 +- frame/message-queue/src/integration_test.rs | 3 +- frame/message-queue/src/mock.rs | 5 +- frame/multisig/src/lib.rs | 18 +-- frame/multisig/src/tests.rs | 3 +- .../nft-fractionalization/src/benchmarking.rs | 6 +- frame/nft-fractionalization/src/mock.rs | 3 +- frame/nfts/src/benchmarking.rs | 6 +- frame/nfts/src/features/approvals.rs | 2 +- frame/nfts/src/features/atomic_swap.rs | 2 +- frame/nfts/src/features/settings.rs | 2 +- frame/nfts/src/lib.rs | 18 +-- frame/nfts/src/mock.rs | 3 +- frame/nfts/src/types.rs | 8 +- frame/nicks/src/lib.rs | 2 +- frame/nis/src/lib.rs | 18 +-- frame/nis/src/mock.rs | 3 +- frame/node-authorization/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 8 +- .../nomination-pools/benchmarking/src/mock.rs | 3 +- frame/nomination-pools/src/lib.rs | 12 +- frame/nomination-pools/src/mock.rs | 3 +- .../nomination-pools/test-staking/src/mock.rs | 3 +- frame/offences/benchmarking/src/mock.rs | 3 +- frame/offences/src/mock.rs | 3 +- frame/preimage/src/mock.rs | 3 +- frame/proxy/src/benchmarking.rs | 12 +- frame/proxy/src/lib.rs | 30 ++-- frame/proxy/src/tests.rs | 3 +- frame/ranked-collective/src/lib.rs | 2 +- frame/ranked-collective/src/tests.rs | 3 +- frame/recovery/src/lib.rs | 6 +- frame/recovery/src/mock.rs | 3 +- frame/referenda/src/benchmarking.rs | 2 +- frame/referenda/src/lib.rs | 50 +++---- frame/referenda/src/migration.rs | 2 +- frame/referenda/src/mock.rs | 3 +- frame/referenda/src/types.rs | 12 +- frame/remark/src/mock.rs | 3 +- frame/root-offences/src/mock.rs | 3 +- frame/salary/src/lib.rs | 10 +- frame/salary/src/tests.rs | 3 +- frame/scheduler/src/benchmarking.rs | 8 +- frame/scheduler/src/lib.rs | 140 +++++++++--------- frame/scheduler/src/migration.rs | 14 +- frame/scheduler/src/mock.rs | 3 +- frame/scored-pool/src/lib.rs | 4 +- frame/scored-pool/src/mock.rs | 3 +- frame/session/benchmarking/src/lib.rs | 6 +- frame/session/benchmarking/src/mock.rs | 3 +- frame/session/src/lib.rs | 12 +- frame/session/src/mock.rs | 3 +- frame/society/src/lib.rs | 24 +-- frame/society/src/migrations.rs | 2 +- frame/society/src/mock.rs | 3 +- frame/staking/src/mock.rs | 3 +- frame/staking/src/pallet/impls.rs | 6 +- frame/staking/src/pallet/mod.rs | 8 +- frame/state-trie-migration/src/lib.rs | 2 +- frame/statement/src/mock.rs | 3 +- frame/sudo/src/mock.rs | 3 +- frame/support/procedural/src/lib.rs | 6 +- frame/support/src/dispatch.rs | 15 +- frame/support/src/lib.rs | 25 ++-- frame/support/src/storage/generator/mod.rs | 7 +- frame/support/test/compile_pass/src/lib.rs | 8 +- frame/support/test/src/lib.rs | 4 +- frame/support/test/tests/construct_runtime.rs | 1 - .../number_of_pallets_exceeds_tuple_size.rs | 2 +- .../pallet_error_too_large.rs | 2 +- .../undefined_call_part.rs | 2 +- .../undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- frame/support/test/tests/final_keys.rs | 22 ++- frame/support/test/tests/genesisconfig.rs | 10 +- frame/support/test/tests/instance.rs | 9 +- frame/support/test/tests/issue2219.rs | 30 ++-- frame/support/test/tests/origin.rs | 1 - frame/support/test/tests/pallet.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 2 +- .../tests/pallet_ui/pass/dev_mode_valid.rs | 2 +- .../pallet_ui/pass/no_std_genesis_config.rs | 2 +- frame/support/test/tests/runtime_metadata.rs | 2 +- frame/support/test/tests/storage_layers.rs | 8 +- .../support/test/tests/storage_transaction.rs | 6 +- frame/system/benches/bench.rs | 3 +- frame/system/benchmarking/src/mock.rs | 3 +- frame/system/src/mock.rs | 3 +- frame/tips/src/benchmarking.rs | 2 +- frame/tips/src/lib.rs | 10 +- frame/tips/src/tests.rs | 3 +- .../asset-tx-payment/src/mock.rs | 8 +- frame/transaction-payment/src/lib.rs | 2 +- frame/transaction-payment/src/mock.rs | 3 +- frame/transaction-storage/src/benchmarking.rs | 6 +- frame/transaction-storage/src/lib.rs | 14 +- frame/transaction-storage/src/mock.rs | 3 +- frame/treasury/src/benchmarking.rs | 2 +- frame/treasury/src/lib.rs | 4 +- frame/treasury/src/tests.rs | 3 +- frame/uniques/src/mock.rs | 3 +- frame/utility/src/tests.rs | 3 +- frame/vesting/src/benchmarking.rs | 8 +- frame/vesting/src/lib.rs | 42 +++--- frame/vesting/src/migrations.rs | 4 +- frame/vesting/src/mock.rs | 3 +- frame/whitelist/src/mock.rs | 3 +- test-utils/runtime/src/lib.rs | 3 +- utils/frame/rpc/support/src/lib.rs | 2 +- 200 files changed, 707 insertions(+), 847 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index b4d6905378a5d..30cf45cf6e4f5 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -11,10 +11,7 @@ type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, TemplateModule: pallet_template, @@ -29,12 +26,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index a26fcd4e4ad0a..60dc11d37262f 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -170,7 +170,6 @@ impl frame_system::Config for Runtime { /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. - type BlockNumber = BlockNumber; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index cc0f85e05375b..0ff3f3443d6a6 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -227,12 +227,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = Indices; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 92bf1ae4468df..07c0ab6a80949 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -432,7 +432,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { @@ -504,7 +504,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 6c034454cf7c0..2ab541a6d858e 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -309,7 +309,7 @@ pub mod pallet { /// The number of blocks a member must wait between giving a retirement notice and retiring. /// Supposed to be greater than time required to `kick_member`. - type RetirementPeriod: Get; + type RetirementPeriod: Get>; } #[pallet::error] @@ -476,7 +476,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn retiring_members)] pub type RetiringMembers, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber, OptionQuery>; + StorageMap<_, Blake2_128Concat, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; /// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit /// candidacy. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 5e40116912765..e79f70685e561 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -53,12 +53,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = BlockNumber; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 2b51c685317d0..ac5e4b281f439 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -56,12 +56,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 47342a4949ca4..a97cbbc3011d5 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -45,12 +45,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 428d36b2840c9..182a4c6882f70 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -54,12 +54,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 2d93887b82596..734bbcf456803 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -69,7 +69,7 @@ pub struct PendingSwap { /// Action of this swap. pub action: T::SwapAction, /// End block of the lock. - pub end_block: T::BlockNumber, + pub end_block: frame_system::pallet_prelude::BlockNumberFor::, } /// Hashed proof type. @@ -249,7 +249,7 @@ pub mod pallet { target: T::AccountId, hashed_proof: HashedProof, action: T::SwapAction, - duration: T::BlockNumber, + duration: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { let source = ensure_signed(origin)?; ensure!( diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 96b18d2b9eb9f..53a6671449153 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -29,13 +29,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 3cd0e9ec2e6cc..da960496e1447 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -102,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: T::BlockNumber) -> Weight { + fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { if let Some(new_slot) = Self::current_slot_from_digests() { let current_slot = CurrentSlot::::get(); diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 3f3fe743e0d1c..90908262b5785 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -50,13 +50,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 3262afa8e9dae..1d0597d42b869 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -231,13 +231,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 54ec0e0cc73b9..8ba5875c800f3 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -45,7 +45,7 @@ pub mod pallet { /// Find the author of a block. type FindAuthor: FindAuthor; /// An event handler for authored blocks. - type EventHandler: EventHandler; + type EventHandler: EventHandler>; } #[pallet::pallet] @@ -53,7 +53,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: T::BlockNumber) -> Weight { + fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { if let Some(author) = Self::author() { T::EventHandler::note_author(author); } @@ -61,7 +61,7 @@ pub mod pallet { Weight::zero() } - fn on_finalize(_: T::BlockNumber) { + fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor::) { // ensure we never go to trie with these values. >::kill(); } @@ -132,7 +132,7 @@ mod tests { type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index 3a14cacc905d2..018eddf0dff1b 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -106,7 +106,7 @@ impl Offence for EquivocationOffence { pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); impl - OffenceReportSystem, (EquivocationProof, T::KeyOwnerProof)> + OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -122,7 +122,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -140,7 +140,7 @@ where } fn check_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -159,7 +159,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 8001450b43583..9b3ec4fa1db3a 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -78,7 +78,7 @@ pub trait WeightInfo { pub trait EpochChangeTrigger { /// Trigger an epoch change, if any should take place. This should be called /// during every block, after initialization is done. - fn trigger(now: T::BlockNumber); + fn trigger(now: frame_system::pallet_prelude::BlockNumberFor::); } /// A type signifying to BABE that an external trigger @@ -86,7 +86,7 @@ pub trait EpochChangeTrigger { pub struct ExternalTrigger; impl EpochChangeTrigger for ExternalTrigger { - fn trigger(_: T::BlockNumber) {} // nothing - trigger is external. + fn trigger(_: frame_system::pallet_prelude::BlockNumberFor::) {} // nothing - trigger is external. } /// A type signifying to BABE that it should perform epoch changes @@ -94,7 +94,7 @@ impl EpochChangeTrigger for ExternalTrigger { pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { - fn trigger(now: T::BlockNumber) { + fn trigger(now: frame_system::pallet_prelude::BlockNumberFor::) { if >::should_epoch_change(now) { let authorities = >::authorities(); let next_authorities = authorities.clone(); @@ -162,7 +162,7 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } @@ -279,7 +279,7 @@ pub mod pallet { /// slots, which may be skipped, the block numbers may not line up with the slot numbers. #[pallet::storage] pub(super) type EpochStart = - StorageValue<_, (T::BlockNumber, T::BlockNumber), ValueQuery>; + StorageValue<_, (frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::), ValueQuery>; /// How late the current block is compared to its parent. /// @@ -288,7 +288,7 @@ pub mod pallet { /// execution context should always yield zero. #[pallet::storage] #[pallet::getter(fn lateness)] - pub(super) type Lateness = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type Lateness = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -407,7 +407,7 @@ pub mod pallet { ))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -433,7 +433,7 @@ pub mod pallet { ))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -503,8 +503,8 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession for Pallet { - fn should_end_session(now: T::BlockNumber) -> bool { +impl pallet_session::ShouldEndSession> for Pallet { + fn should_end_session(now: frame_system::pallet_prelude::BlockNumberFor::) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's // possible that babe's own `on_initialize` has not run yet, so let's ensure that we @@ -524,7 +524,7 @@ impl Pallet { /// Determine whether an epoch change should take place at this block. /// Assumes that initialization has already taken place. - pub fn should_epoch_change(now: T::BlockNumber) -> bool { + pub fn should_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor::) -> bool { // The epoch has technically ended during the passage of time // between this block and the last, but we have to "end" the epoch now, // since there is no earlier possible block we could have done it. @@ -554,11 +554,11 @@ impl Pallet { // // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. - pub fn next_expected_epoch_change(now: T::BlockNumber) -> Option { + pub fn next_expected_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor::) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: T::BlockNumber = slots_remaining.saturated_into(); + let blocks_remaining: frame_system::pallet_prelude::BlockNumberFor:: = slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) } @@ -776,7 +776,7 @@ impl Pallet { Self::deposit_consensus(ConsensusLog::NextEpochData(next)); } - fn initialize(now: T::BlockNumber) { + fn initialize(now: frame_system::pallet_prelude::BlockNumberFor::) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block let initialized = Self::initialized().is_some(); @@ -811,7 +811,7 @@ impl Pallet { // how many slots were skipped between current and last block let lateness = current_slot.saturating_sub(CurrentSlot::::get() + 1); - let lateness = T::BlockNumber::from(*lateness as u32); + let lateness = frame_system::pallet_prelude::BlockNumberFor::::from(*lateness as u32); Lateness::::put(lateness); CurrentSlot::::put(current_slot); @@ -877,7 +877,7 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() @@ -899,12 +899,12 @@ impl OnTimestampSet for Pallet { } } -impl frame_support::traits::EstimateNextSessionRotation for Pallet { - fn average_session_length() -> T::BlockNumber { +impl frame_support::traits::EstimateNextSessionRotation> for Pallet { + fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor:: { T::EpochDuration::get().saturated_into() } - fn estimate_current_session_progress(_now: T::BlockNumber) -> (Option, Weight) { + fn estimate_current_session_progress(_now: frame_system::pallet_prelude::BlockNumberFor::) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; ( @@ -914,7 +914,7 @@ impl frame_support::traits::EstimateNextSessionRotation (Option, Weight) { + fn estimate_next_session_rotation(now: frame_system::pallet_prelude::BlockNumberFor::) -> (Option>, Weight) { ( Self::next_expected_epoch_change(now), // Read: Current Slot, Epoch Index, Genesis Slot @@ -923,8 +923,8 @@ impl frame_support::traits::EstimateNextSessionRotation frame_support::traits::Lateness for Pallet { - fn lateness(&self) -> T::BlockNumber { +impl frame_support::traits::Lateness> for Pallet { + fn lateness(&self) -> frame_system::pallet_prelude::BlockNumberFor:: { Self::lateness() } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 330ab38186152..9b4bd390c47f0 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -67,14 +67,13 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = DummyValidatorId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index b9b24786b7a74..112c4b4237d39 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -129,8 +129,8 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT for RandomnessFromTwoEpochsAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromTwoEpochsAgo { + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); @@ -139,8 +139,8 @@ impl RandomnessT for RandomnessFromTwoEpochs } } -impl RandomnessT for RandomnessFromOneEpochAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromOneEpochAgo { + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); @@ -149,8 +149,8 @@ impl RandomnessT for RandomnessFromOneEpochA } } -impl RandomnessT, T::BlockNumber> for ParentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor::> for ParentBlockRandomness { + fn random(subject: &[u8]) -> (Option, frame_system::pallet_prelude::BlockNumberFor::) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -164,8 +164,8 @@ impl RandomnessT, T::BlockNumber> for ParentBlockRand } #[allow(deprecated)] -impl RandomnessT, T::BlockNumber> for CurrentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor::> for CurrentBlockRandomness { + fn random(subject: &[u8]) -> (Option, frame_system::pallet_prelude::BlockNumberFor::) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 082e7e333771e..2f4755af057a9 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -52,13 +52,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); diff --git a/frame/balances/README.md b/frame/balances/README.md index dd56ab3fadfb5..fa1ee622d48ce 100644 --- a/frame/balances/README.md +++ b/frame/balances/README.md @@ -94,7 +94,7 @@ The Staking module uses the `LockableCurrency` trait to lock a stash account's f use frame_support::traits::{WithdrawReasons, LockableCurrency}; use sp_runtime::traits::Bounded; pub trait Config: frame_system::Config { - type Currency: LockableCurrency; + type Currency: LockableCurrency>; } fn update_ledger( diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index baa153c119b20..32369ee988798 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -842,7 +842,7 @@ impl, I: 'static> LockableCurrency for Pallet where T::Balance: MaybeSerializeDeserialize + Debug, { - type Moment = T::BlockNumber; + type Moment = frame_system::pallet_prelude::BlockNumberFor::; type MaxLocks = T::MaxLocks; diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 33a336e7c94e5..6faeabec75991 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -120,7 +120,7 @@ //! use frame_support::traits::{WithdrawReasons, LockableCurrency}; //! use sp_runtime::traits::Bounded; //! pub trait Config: frame_system::Config { -//! type Currency: LockableCurrency; +//! type Currency: LockableCurrency>; //! } //! # struct StakingLedger { //! # stash: ::AccountId, @@ -517,7 +517,7 @@ pub mod pallet { } #[pallet::hooks] - impl, I: 'static> Hooks for Pallet { + impl, I: 'static> Hooks> for Pallet { #[cfg(not(feature = "insecure_zero_ed"))] fn integrity_test() { assert!( diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 1f216e03ee082..c521c5a240743 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -95,13 +95,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/beefy-mmr/src/lib.rs b/frame/beefy-mmr/src/lib.rs index ba416922e2563..494e8b67ff88d 100644 --- a/frame/beefy-mmr/src/lib.rs +++ b/frame/beefy-mmr/src/lib.rs @@ -139,7 +139,7 @@ pub mod pallet { impl LeafDataProvider for Pallet { type LeafData = MmrLeaf< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::Hash, MerkleRootOf, T::LeafExtra, diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 551600fc23ce8..e9a6aeec406ba 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -66,13 +66,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -99,7 +98,7 @@ impl pallet_session::Config for Test { } pub type MmrLeaf = sp_consensus_beefy::mmr::MmrLeaf< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::Hash, crate::MerkleRootOf, Vec, diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index f83b037dcd26e..f7ed8136e8fa5 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -126,7 +126,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, /// Equivocation evidence convenience alias. pub type EquivocationEvidenceFor = ( EquivocationProof< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::BeefyId, <::BeefyId as RuntimeAppPublic>::Signature, >, @@ -140,7 +140,7 @@ where R: ReportOffence< T::AccountId, P::IdentificationTuple, - EquivocationOffence, + EquivocationOffence>, >, P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, P::IdentificationTuple: Clone, diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 62ead054668f3..9e7d322a37168 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -76,13 +76,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index cd7b98001e2e0..7a7ccdc0a63d3 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -363,13 +363,12 @@ mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index 95e1e2cd19b10..a5f5fd08ea75d 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -188,7 +188,7 @@ mod mock { type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u32; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index bae87e353684b..8d0bdfe5abbaa 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -134,13 +134,12 @@ pub mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 5060f39f59d2b..57e2cb4a62070 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -84,13 +84,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 65e7c2eadd8df..ebfac7a0a8dbc 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -94,12 +94,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 0675328c3d3c2..a1e1681d2df40 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -77,7 +77,7 @@ fn create_bounty, I: 'static>( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup.clone(), fee)?; Bounties::::accept_curator(RawOrigin::Signed(curator).into(), bounty_id)?; Ok((curator_lookup, bounty_id)) @@ -115,14 +115,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); }: _(approve_origin, bounty_id, curator_lookup, fee) // Worst case when curator is inactive and any sender unassigns the curator. unassign_curator { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 2u32.into()); let caller = whitelisted_caller(); @@ -136,14 +136,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup, fee)?; }: _(RawOrigin::Signed(curator), bounty_id) award_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -154,7 +154,7 @@ benchmarks_instance_pallet! { claim_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -183,7 +183,7 @@ benchmarks_instance_pallet! { close_bounty_active { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let approve_origin = T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; @@ -195,7 +195,7 @@ benchmarks_instance_pallet! { extend_bounty_expiry { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 07ac23a9d8010..738cd41cf11ad 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -201,11 +201,11 @@ pub mod pallet { /// The delay period for which a bounty beneficiary need to wait before claim the payout. #[pallet::constant] - type BountyDepositPayoutDelay: Get; + type BountyDepositPayoutDelay: Get>; /// Bounty duration in blocks. #[pallet::constant] - type BountyUpdatePeriod: Get; + type BountyUpdatePeriod: Get>; /// The curator deposit is calculated as a percentage of the curator fee. /// @@ -305,7 +305,7 @@ pub mod pallet { _, Twox64Concat, BountyIndex, - Bounty, T::BlockNumber>, + Bounty, frame_system::pallet_prelude::BlockNumberFor::>, >; /// The description of each bounty. diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 407d7113e9a92..e285755125c75 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -67,13 +67,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index e49d9c836125d..3bdd6ff51c2bd 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -114,7 +114,7 @@ fn activate_bounty( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin, child_bounty_setup.bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); Bounties::::propose_curator( RawOrigin::Root.into(), child_bounty_setup.bounty_id, @@ -229,7 +229,7 @@ benchmarks! { unassign_curator { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), bounty_setup.bounty_id, @@ -303,7 +303,7 @@ benchmarks! { close_child_bounty_active { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { assert_last_event::(Event::Canceled { diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 14c1907af2c46..7fd181adc2256 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { BountyIndex, Twox64Concat, BountyIndex, - ChildBounty, T::BlockNumber>, + ChildBounty, frame_system::pallet_prelude::BlockNumberFor::>, >; /// The description of each child-bounty. @@ -816,7 +816,7 @@ impl Pallet { fn ensure_bounty_active( bounty_id: BountyIndex, - ) -> Result<(T::AccountId, T::BlockNumber), DispatchError> { + ) -> Result<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor::), DispatchError> { let parent_bounty = pallet_bounties::Pallet::::bounties(bounty_id) .ok_or(BountiesError::::InvalidIndex)?; if let BountyStatus::Active { curator, update_due } = parent_bounty.get_status() { diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 6240ee3c21c65..a8cdd7b07740b 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -70,13 +70,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 8a4495ef4095b..88313696bacdf 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -516,7 +516,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime nay will close it as disapproved @@ -588,7 +588,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime aye will close it as approved @@ -637,7 +637,7 @@ benchmarks_instance_pallet! { last_hash = T::Hashing::hash_of(&proposal); } - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); }: _(SystemOrigin::Root, last_hash) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index fc4ab0c4f1bbd..3cb0aeeba1820 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -201,7 +201,7 @@ pub mod pallet { + IsType<::RuntimeEvent>; /// The time-out for council motions. - type MotionDuration: Get; + type MotionDuration: Get>; /// Maximum number of proposals allowed to be active in parallel. type MaxProposals: Get; @@ -273,7 +273,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn voting)] pub type Voting, I: 'static = ()> = - StorageMap<_, Identity, T::Hash, Votes, OptionQuery>; + StorageMap<_, Identity, T::Hash, Votes>, OptionQuery>; /// Proposals so far. #[pallet::storage] diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 019ab381f2279..ae96ae7deca49 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -97,13 +97,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index a81a633f740ab..afab8cc94b42c 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -48,7 +48,7 @@ use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; pub type SeedOf = ::Hash; -pub type BlockNumberOf = ::BlockNumber; +pub type BlockNumberOf = frame_system::pallet_prelude::BlockNumberFor; pub type ExecResult = Result; /// A type that represents a topic of an event. At the moment a hash is used. @@ -394,7 +394,7 @@ pub struct Stack<'a, T: Config, E> { /// The timestamp at the point of call stack instantiation. timestamp: MomentOf, /// The block number at the time of call stack instantiation. - block_number: T::BlockNumber, + block_number: frame_system::pallet_prelude::BlockNumberFor::, /// The nonce is cached here when accessed. It is written back when the call stack /// finishes executing. Please refer to [`Nonce`] to a description of /// the nonce itself. @@ -1356,7 +1356,7 @@ where ); } - fn block_number(&self) -> T::BlockNumber { + fn block_number(&self) -> frame_system::pallet_prelude::BlockNumberFor:: { self.block_number } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 0b765a2e89956..82775baf32fac 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -207,7 +207,7 @@ pub mod pallet { /// be instantiated from existing codes that use this deprecated functionality. It will /// be removed eventually. Hence for new `pallet-contracts` deployments it is okay /// to supply a dummy implementation for this type (because it is never used). - type Randomness: Randomness; + type Randomness: Randomness>; /// The currency in which fees are paid and contract balances are held. type Currency: ReservableCurrency // TODO: Move to fungible traits @@ -341,7 +341,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_idle(_block: T::BlockNumber, mut remaining_weight: Weight) -> Weight { + fn on_idle(_block: frame_system::pallet_prelude::BlockNumberFor::, mut remaining_weight: Weight) -> Weight { use migration::MigrateResult::*; loop { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 97d71db90cde8..dbfc81b0adf13 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -288,13 +288,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index ae02e5badbf39..52ea296ff2745 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2093,7 +2093,7 @@ pub mod env { /// `out_ptr`. This call overwrites it with the size of the value. If the available /// space at `out_ptr` is less than the size of the value a trap is triggered. /// - /// The data is encoded as (T::Hash, T::BlockNumber). + /// The data is encoded as (T::Hash, frame_system::pallet_prelude::BlockNumberFor::). /// /// # Changes from v0 /// diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 3ad81486ed26d..3dd8f4d7d5656 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -68,7 +68,7 @@ type BalanceOf = type VotingOf = Voting< BalanceOf, ::AccountId, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, PollIndexOf, >::MaxVotes, >; @@ -76,7 +76,7 @@ type VotingOf = Voting< type DelegatingOf = Delegating< BalanceOf, ::AccountId, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, >; pub type TallyOf = Tally, >::MaxTurnout>; pub type VotesOf = BalanceOf; @@ -103,14 +103,14 @@ pub mod pallet { type WeightInfo: WeightInfo; /// Currency type with which voting happens. type Currency: ReservableCurrency - + LockableCurrency + + LockableCurrency> + fungible::Inspect; /// The implementation of the logic which conducts polls. type Polls: Polling< TallyOf, Votes = BalanceOf, - Moment = Self::BlockNumber, + Moment = frame_system::pallet_prelude::BlockNumberFor, >; /// The maximum amount of tokens which may be used for voting. May just be @@ -130,7 +130,7 @@ pub mod pallet { /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get; + type VoteLockingPeriod: Get>; } /// All voting for a particular voter in a particular voting class. We store the balance for the diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 852303603883d..a3a0ce782f7e7 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -59,13 +59,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs index c49f50d4cc115..0005b20934728 100644 --- a/frame/core-fellowship/src/benchmarking.rs +++ b/frame/core-fellowship/src/benchmarking.rs @@ -75,7 +75,7 @@ mod benchmarks { let member = make_member::(0)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); @@ -92,7 +92,7 @@ mod benchmarks { let member = make_member::(2)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); assert_eq!(T::Members::rank_of(&member), Some(2)); diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index ba02627ec11b9..98e34527431af 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -194,8 +194,8 @@ pub mod pallet { } pub type ParamsOf = - ParamsType<>::Balance, ::BlockNumber, RANK_COUNT>; - pub type MemberStatusOf = MemberStatus<::BlockNumber>; + ParamsType<>::Balance, frame_system::pallet_prelude::BlockNumberFor, RANK_COUNT>; + pub type MemberStatusOf = MemberStatus>; pub type RankOf = <>::Members as RankedMembers>::Rank; /// The overall status of the system. diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 47aec4e2d4083..708630c803f5c 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -59,13 +59,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 9a67ba698a662..36ab6c5da8ecc 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -258,7 +258,7 @@ benchmarks! { .collect::>() .try_into() .unwrap(); - Blacklist::::insert(proposal.hash(), (T::BlockNumber::zero(), addresses)); + Blacklist::::insert(proposal.hash(), (frame_system::pallet_prelude::BlockNumberFor::::zero(), addresses)); }: _(origin, proposal) verify { // External proposal created @@ -332,7 +332,7 @@ benchmarks! { vetoers.try_push(account::("vetoer", i, SEED)).unwrap(); } vetoers.sort(); - Blacklist::::insert(proposal_hash, (T::BlockNumber::zero(), vetoers)); + Blacklist::::insert(proposal_hash, (frame_system::pallet_prelude::BlockNumberFor::::zero(), vetoers)); let origin = T::VetoOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; ensure!(NextExternal::::get().is_some(), "no external proposal"); @@ -816,7 +816,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ReferendumInfo::Finished { end: frame_system::pallet_prelude::BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let caller = funded_account::("caller", 0); @@ -833,7 +833,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ReferendumInfo::Finished { end: frame_system::pallet_prelude::BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let hash = note_preimage::(); diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 7ce3bb5611915..d537d6aa542e3 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -226,14 +226,14 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Scheduler. - type Scheduler: ScheduleNamed, Self::PalletsOrigin>; + type Scheduler: ScheduleNamed, CallOf, Self::PalletsOrigin>; /// The Preimage provider. type Preimages: QueryPreimage + StorePreimage; /// Currency type for this pallet. type Currency: ReservableCurrency - + LockableCurrency; + + LockableCurrency>; /// The period between a proposal being approved and enacted. /// @@ -241,22 +241,22 @@ pub mod pallet { /// voting stakers have an opportunity to remove themselves from the system in the case /// where they are on the losing side of a vote. #[pallet::constant] - type EnactmentPeriod: Get; + type EnactmentPeriod: Get>; /// How often (in blocks) new public referenda are launched. #[pallet::constant] - type LaunchPeriod: Get; + type LaunchPeriod: Get>; /// How often (in blocks) to check for new votes. #[pallet::constant] - type VotingPeriod: Get; + type VotingPeriod: Get>; /// The minimum period of vote locking. /// /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get; + type VoteLockingPeriod: Get>; /// The minimum amount to be used as a deposit for a public referendum proposal. #[pallet::constant] @@ -270,11 +270,11 @@ pub mod pallet { /// Minimum voting period allowed for a fast-track referendum. #[pallet::constant] - type FastTrackVotingPeriod: Get; + type FastTrackVotingPeriod: Get>; /// Period in blocks where an external proposal may not be re-submitted after being vetoed. #[pallet::constant] - type CooloffPeriod: Get; + type CooloffPeriod: Get>; /// The maximum number of votes for an account. /// @@ -387,7 +387,7 @@ pub mod pallet { _, Twox64Concat, ReferendumIndex, - ReferendumInfo, BalanceOf>, + ReferendumInfo, BoundedCallOf, BalanceOf>, >; /// All votes for a particular voter. We store the balance for the number of votes that we @@ -399,7 +399,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - Voting, T::AccountId, T::BlockNumber, T::MaxVotes>, + Voting, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, T::MaxVotes>, ValueQuery, >; @@ -422,7 +422,7 @@ pub mod pallet { _, Identity, H256, - (T::BlockNumber, BoundedVec), + (frame_system::pallet_prelude::BlockNumberFor::, BoundedVec), >; /// Record of all proposals that have been subject to emergency cancellation. @@ -475,7 +475,7 @@ pub mod pallet { /// An account has cancelled a previous delegation operation. Undelegated { account: T::AccountId }, /// An external proposal has been vetoed. - Vetoed { who: T::AccountId, proposal_hash: H256, until: T::BlockNumber }, + Vetoed { who: T::AccountId, proposal_hash: H256, until: frame_system::pallet_prelude::BlockNumberFor:: }, /// A proposal_hash has been blacklisted permanently. Blacklisted { proposal_hash: H256 }, /// An account has voted in a referendum @@ -565,7 +565,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Weight: see `begin_block` - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { Self::begin_block(n) } } @@ -775,8 +775,8 @@ pub mod pallet { pub fn fast_track( origin: OriginFor, proposal_hash: H256, - voting_period: T::BlockNumber, - delay: T::BlockNumber, + voting_period: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { // Rather complicated bit of code to ensure that either: // - `voting_period` is at least `FastTrackVotingPeriod` and `origin` is @@ -794,7 +794,7 @@ pub mod pallet { ensure!(T::InstantAllowed::get(), Error::::InstantNotAllowed); } - ensure!(voting_period > T::BlockNumber::zero(), Error::::VotingPeriodLow); + ensure!(voting_period > frame_system::pallet_prelude::BlockNumberFor::::zero(), Error::::VotingPeriodLow); let (ext_proposal, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( @@ -1047,7 +1047,7 @@ pub mod pallet { T::BlacklistOrigin::ensure_origin(origin)?; // Insert the proposal into the blacklist. - let permanent = (T::BlockNumber::max_value(), BoundedVec::::default()); + let permanent = (frame_system::pallet_prelude::BlockNumberFor::::max_value(), BoundedVec::::default()); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. @@ -1200,17 +1200,17 @@ impl Pallet { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( - n: T::BlockNumber, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BalanceOf>)> { + n: frame_system::pallet_prelude::BlockNumberFor::, + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> { let next = Self::lowest_unbaked(); let last = Self::referendum_count(); Self::maturing_referenda_at_inner(n, next..last) } fn maturing_referenda_at_inner( - n: T::BlockNumber, + n: frame_system::pallet_prelude::BlockNumberFor::, range: core::ops::Range, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BalanceOf>)> { + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> { range .into_iter() .map(|i| (i, Self::referendum_info(i))) @@ -1228,7 +1228,7 @@ impl Pallet { pub fn internal_start_referendum( proposal: BoundedCallOf, threshold: VoteThreshold, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> ReferendumIndex { >::inject_referendum( >::block_number().saturating_add(T::VotingPeriod::get()), @@ -1249,8 +1249,8 @@ impl Pallet { /// Ok if the given referendum is active, Err otherwise fn ensure_ongoing( - r: ReferendumInfo, BalanceOf>, - ) -> Result, BalanceOf>, DispatchError> { + r: ReferendumInfo, BoundedCallOf, BalanceOf>, + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> { match r { ReferendumInfo::Ongoing(s) => Ok(s), _ => Err(Error::::ReferendumInvalid.into()), @@ -1259,7 +1259,7 @@ impl Pallet { fn referendum_status( ref_index: ReferendumIndex, - ) -> Result, BalanceOf>, DispatchError> { + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> { let info = ReferendumInfoOf::::get(ref_index).ok_or(Error::::ReferendumInvalid)?; Self::ensure_ongoing(info) } @@ -1514,10 +1514,10 @@ impl Pallet { /// Start a referendum fn inject_referendum( - end: T::BlockNumber, + end: frame_system::pallet_prelude::BlockNumberFor::, proposal: BoundedCallOf, threshold: VoteThreshold, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> ReferendumIndex { let ref_index = Self::referendum_count(); ReferendumCount::::put(ref_index + 1); @@ -1530,7 +1530,7 @@ impl Pallet { } /// Table the next waiting proposal for a vote. - fn launch_next(now: T::BlockNumber) -> DispatchResult { + fn launch_next(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { if LastTabledWasExternal::::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { @@ -1540,7 +1540,7 @@ impl Pallet { } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: T::BlockNumber) -> DispatchResult { + fn launch_external(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); Self::deposit_event(Event::::ExternalTabled); @@ -1558,7 +1558,7 @@ impl Pallet { } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: T::BlockNumber) -> DispatchResult { + fn launch_public(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter().enumerate().max_by_key( // defensive only: All current public proposals have an amount locked @@ -1591,9 +1591,9 @@ impl Pallet { } fn bake_referendum( - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, index: ReferendumIndex, - status: ReferendumStatus, BalanceOf>, + status: ReferendumStatus, BoundedCallOf, BalanceOf>, ) -> bool { let total_issuance = T::Currency::total_issuance(); let approved = status.threshold.approved(status.tally, total_issuance); @@ -1628,7 +1628,7 @@ impl Pallet { /// ## Complexity: /// If a referendum is launched or maturing, this will take full block weight if queue is not /// empty. Otherwise, `O(R)` where `R` is the number of unbaked referenda. - fn begin_block(now: T::BlockNumber) -> Weight { + fn begin_block(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let max_block_weight = T::BlockWeights::get().max_block; let mut weight = Weight::zero(); diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index f3d29511ff659..cd66922a5815e 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -46,7 +46,7 @@ mod v0 { frame_support::Twox64Concat, ReferendumIndex, ReferendumInfo< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::Hash, BalanceOf, >, @@ -87,7 +87,7 @@ pub mod v1 { } ReferendumInfoOf::::translate( - |index, old: ReferendumInfo>| { + |index, old: ReferendumInfo, T::Hash, BalanceOf>| { weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); log::info!(target: TARGET, "migrating referendum #{:?}", &index); Some(match old { diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 2522b61dacbac..54fdfeaa43c66 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -86,13 +86,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index a5946c6a1d3c1..1284d0b873ea6 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -313,7 +313,7 @@ frame_benchmarking::benchmarks! { assert!(>::get().is_none()); assert!(>::get().is_none()); assert!(>::get().is_none()); - assert_eq!(>::get(), >::Off); + assert_eq!(>::get(), >>::Off); } submit { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 1960c458b983e..03c761cb51559 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -585,10 +585,10 @@ pub mod pallet { /// Duration of the unsigned phase. #[pallet::constant] - type UnsignedPhase: Get; + type UnsignedPhase: Get>; /// Duration of the signed phase. #[pallet::constant] - type SignedPhase: Get; + type SignedPhase: Get>; /// The minimum amount of improvement to the solution score that defines a solution as /// "better" in the Signed phase. @@ -605,7 +605,7 @@ pub mod pallet { /// For example, if it is 5, that means that at least 5 blocks will elapse between attempts /// to submit the worker's solution. #[pallet::constant] - type OffchainRepeat: Get; + type OffchainRepeat: Get>; /// The priority of the unsigned transaction submitted in the unsigned-phase #[pallet::constant] @@ -685,13 +685,13 @@ pub mod pallet { /// Something that will provide the election data. type DataProvider: ElectionDataProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, >; /// Configuration for the fallback. type Fallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; @@ -702,7 +702,7 @@ pub mod pallet { /// BoundedExecution<_>` if the test-net is not expected to have thousands of nominators. type GovernanceFallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; @@ -747,7 +747,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let next_election = T::DataProvider::next_election_prediction(now).max(now); let signed_deadline = T::SignedPhase::get() + T::UnsignedPhase::get(); @@ -824,7 +824,7 @@ pub mod pallet { } } - fn offchain_worker(now: T::BlockNumber) { + fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { use sp_runtime::offchain::storage_lock::{BlockAndTime, StorageLock}; // Create a lock with the maximum deadline of number of blocks in the unsigned phase. @@ -886,7 +886,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1155,7 +1155,7 @@ pub mod pallet { /// An account has been slashed for submitting an invalid signed submission. Slashed { account: ::AccountId, value: BalanceOf }, /// There was a phase transition in a given round. - PhaseTransitioned { from: Phase, to: Phase, round: u32 }, + PhaseTransitioned { from: Phase>, to: Phase>, round: u32 }, } /// Error of the pallet that can be returned in response to dispatches. @@ -1257,7 +1257,7 @@ pub mod pallet { /// Current phase. #[pallet::storage] #[pallet::getter(fn current_phase)] - pub type CurrentPhase = StorageValue<_, Phase, ValueQuery>; + pub type CurrentPhase = StorageValue<_, Phase>, ValueQuery>; /// Current best solution, signed or unsigned, queued to be returned upon `elect`. /// @@ -1349,7 +1349,7 @@ pub mod pallet { impl Pallet { /// Internal logic of the offchain worker, to be executed only when the offchain lock is /// acquired with success. - fn do_synchronized_offchain_worker(now: T::BlockNumber) { + fn do_synchronized_offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { let current_phase = Self::current_phase(); log!(trace, "lock for offchain worker acquired. Phase = {:?}", current_phase); match current_phase { @@ -1375,7 +1375,7 @@ impl Pallet { } /// Phase transition helper. - pub(crate) fn phase_transition(to: Phase) { + pub(crate) fn phase_transition(to: Phase>) { log!(info, "Starting phase {:?}, round {}.", to, Self::round()); Self::deposit_event(Event::PhaseTransitioned { from: >::get(), @@ -1672,7 +1672,7 @@ impl Pallet { impl ElectionProviderBase for Pallet { type AccountId = T::AccountId; - type BlockNumber = T::BlockNumber; + type BlockNumber = frame_system::pallet_prelude::BlockNumberFor::; type Error = ElectionError; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 95845fc4ca0e2..2c01d501ec983 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -209,13 +209,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); @@ -320,7 +319,6 @@ impl onchain::Config for OnChainSeqPhragmen { pub struct MockFallback; impl ElectionProviderBase for MockFallback { type AccountId = AccountId; - type BlockNumber = u64; type Error = &'static str; type DataProvider = StakingMock; type MaxWinners = MaxWinners; @@ -434,7 +432,6 @@ pub struct ExtBuilder {} pub struct StakingMock; impl ElectionDataProvider for StakingMock { type AccountId = AccountId; - type BlockNumber = u64; type MaxVotesPerVoter = MaxNominations; fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index bde985518d53e..5a66ac9d7575d 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -101,7 +101,7 @@ pub type SignedSubmissionOf = SignedSubmission< /// Always sorted vector of a score, submitted at the given block number, which can be found at the /// given index (`u32`) of the `SignedSubmissionsMap`. pub type SubmissionIndicesOf = BoundedVec< - (ElectionScore, ::BlockNumber, u32), + (ElectionScore, frame_system::pallet_prelude::BlockNumberFor, u32), ::SignedMaxSubmissions, >; @@ -216,7 +216,7 @@ impl SignedSubmissions { fn swap_out_submission( &mut self, remove_pos: usize, - insert: Option<(ElectionScore, T::BlockNumber, u32)>, + insert: Option<(ElectionScore, frame_system::pallet_prelude::BlockNumberFor::, u32)>, ) -> Option> { if remove_pos >= self.indices.len() { return None diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 9c09cb48c7c05..78d6b4f08ec91 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -298,12 +298,12 @@ impl Pallet { /// /// Returns `Ok(())` if offchain worker limit is respected, `Err(reason)` otherwise. If `Ok()` /// is returned, `now` is written in storage and will be used in further calls as the baseline. - pub fn ensure_offchain_repeat_frequency(now: T::BlockNumber) -> Result<(), MinerError> { + pub fn ensure_offchain_repeat_frequency(now: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), MinerError> { let threshold = T::OffchainRepeat::get(); let last_block = StorageValueRef::persistent(OFFCHAIN_LAST_BLOCK); let mutate_stat = last_block.mutate::<_, &'static str, _>( - |maybe_head: Result, _>| { + |maybe_head: Result>, _>| { match maybe_head { Ok(Some(head)) if now < head => Err("fork."), Ok(Some(head)) if now >= head && now <= head + threshold => 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 16154564c467a..71eada1a44668 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 @@ -82,13 +82,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 89034b0bd85ec..aa4ad7dc6586e 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -73,7 +73,7 @@ pub trait Config { /// Something that provides the data for election. type DataProvider: ElectionDataProvider< AccountId = ::AccountId, - BlockNumber = ::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, >; /// Weight information for extrinsics in this pallet. @@ -151,7 +151,7 @@ fn elect_with_input_bounds( impl ElectionProviderBase for OnChainExecution { type AccountId = ::AccountId; - type BlockNumber = ::BlockNumber; + type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; type Error = Error; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; @@ -208,13 +208,12 @@ mod tests { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = AccountId; - type BlockNumber = BlockNumber; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = (); type BlockHashCount = (); type DbWeight = (); @@ -267,8 +266,7 @@ mod tests { pub struct DataProvider; impl ElectionDataProvider for DataProvider { type AccountId = AccountId; - type BlockNumber = BlockNumber; - type MaxVotesPerVoter = ConstU32<2>; + type MaxVotesPerVoter = ConstU32<2>; fn electing_voters(_: Option) -> data_provider::Result>> { Ok(vec![ (1, 10, bounded_vec![10, 20]), diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 375133800cc69..3680dce013f13 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -203,7 +203,7 @@ pub mod pallet { type PalletId: Get; /// The currency that people are electing with. - type Currency: LockableCurrency + type Currency: LockableCurrency> + ReservableCurrency; /// What to do when the members change. @@ -249,7 +249,7 @@ pub mod pallet { /// round will happen. If set to zero, no elections are ever triggered and the module will /// be in passive mode. #[pallet::constant] - type TermDuration: Get; + type TermDuration: Get>; /// The maximum number of candidates in a phragmen election. /// @@ -285,7 +285,7 @@ pub mod pallet { /// What to do at the end of each block. /// /// Checks if an election needs to happen or not. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let term_duration = T::TermDuration::get(); if !term_duration.is_zero() && (n % term_duration).is_zero() { Self::do_phragmen() @@ -330,7 +330,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1323,13 +1323,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index af159c0f4bc98..53caf9cc81562 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -388,21 +388,21 @@ pub mod pallet { // dispatched. // // This function must return the weight consumed by `on_initialize` and `on_finalize`. - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { // Anything that needs to be done at the start of the block. // We don't do anything here. Weight::zero() } // `on_finalize` is executed at the end of block after all extrinsic are dispatched. - fn on_finalize(_n: T::BlockNumber) { + fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor::) { // Perform necessary data/state clean up here. } // A runtime code run after every block and have access to extended set of APIs. // // For instance you can generate extrinsics for the upcoming produced block. - fn offchain_worker(_n: T::BlockNumber) { + fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor::) { // We don't do anything here. // but we could dispatch extrinsic (transaction/unsigned/inherent) using // sp_io::submit_extrinsic. diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 8b46f36589e1e..5a846427d6a7b 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -54,13 +54,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index e7e8ca1c4bbd5..b978241704e04 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -137,7 +137,7 @@ pub mod tests { // type Index = u32; // type BlockNumber = u32; - // type Header = sp_runtime::generic::Header; + // type Header = sp_runtime::generic::Header, Self::Hashing>; // type Hash = sp_core::hash::H256; // type Hashing = sp_runtime::traits::BlakeTwo256; // type AccountId = u64; diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index dd1b1205af57b..d7db1003d51bc 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -48,13 +48,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index c60e126181a95..87ef5bb318125 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -183,7 +183,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub foo: u32, - pub bar: T::BlockNumber, + pub bar: frame_system::pallet_prelude::BlockNumberFor::, } impl Default for GenesisConfig { @@ -249,22 +249,22 @@ pub mod pallet { /// All the possible hooks that a pallet can have. See [`frame_support::traits::Hooks`] for more /// info. #[pallet::hooks] - impl Hooks for Pallet { + impl Hooks> for Pallet { fn integrity_test() {} - fn offchain_worker(_n: T::BlockNumber) { + fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor::) { unimplemented!() } - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { unimplemented!() } - fn on_finalize(_n: T::BlockNumber) { + fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor::) { unimplemented!() } - fn on_idle(_n: T::BlockNumber, _remaining_weight: Weight) -> Weight { + fn on_idle(_n: frame_system::pallet_prelude::BlockNumberFor::, _remaining_weight: Weight) -> Weight { unimplemented!() } @@ -283,7 +283,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { unimplemented!() } } diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 6ce8524174200..8a3e1ba4ea480 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -136,14 +136,14 @@ pub mod pallet { /// every `GRACE_PERIOD` blocks. We use Local Storage to coordinate /// sending between distinct runs of this offchain worker. #[pallet::constant] - type GracePeriod: Get; + type GracePeriod: Get>; /// Number of blocks of cooldown after unsigned transaction is included. /// /// This ensures that we only accept unsigned transactions once, every `UnsignedInterval` /// blocks. #[pallet::constant] - type UnsignedInterval: Get; + type UnsignedInterval: Get>; /// A configuration for base priority of unsigned transactions. /// @@ -171,7 +171,7 @@ pub mod pallet { /// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs), /// so the code should be able to handle that. /// You can use `Local Storage` API to coordinate runs of the worker. - fn offchain_worker(block_number: T::BlockNumber) { + fn offchain_worker(block_number: frame_system::pallet_prelude::BlockNumberFor::) { // Note that having logs compiled to WASM may cause the size of the blob to increase // significantly. You can use `RuntimeDebug` custom derive to hide details of the types // in WASM. The `sp-api` crate also provides a feature `disable-logging` to disable @@ -258,7 +258,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned( origin: OriginFor, - _block_number: T::BlockNumber, + _block_number: frame_system::pallet_prelude::BlockNumberFor::, price: u32, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -275,7 +275,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned_with_signed_payload( origin: OriginFor, - price_payload: PricePayload, + price_payload: PricePayload>, _signature: T::Signature, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -341,7 +341,7 @@ pub mod pallet { /// This storage entry defines when new transaction is going to be accepted. #[pallet::storage] #[pallet::getter(fn next_unsigned_at)] - pub(super) type NextUnsignedAt = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type NextUnsignedAt = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; } /// Payload used by this example crate to hold price @@ -353,7 +353,7 @@ pub struct PricePayload { public: Public, } -impl SignedPayload for PricePayload { +impl SignedPayload for PricePayload> { fn public(&self) -> T::Public { self.public.clone() } @@ -374,7 +374,7 @@ impl Pallet { /// and local storage usage. /// /// Returns a type of transaction that should be produced in current run. - fn choose_transaction_type(block_number: T::BlockNumber) -> TransactionType { + fn choose_transaction_type(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> TransactionType { /// A friendlier name for the error that is going to be returned in case we are in the grace /// period. const RECENTLY_SENT: () = (); @@ -389,7 +389,7 @@ impl Pallet { // low-level method of local storage API, which means that only one worker // will be able to "acquire a lock" and send a transaction if multiple workers // happen to be executed concurrently. - let res = val.mutate(|last_send: Result, StorageRetrievalError>| { + let res = val.mutate(|last_send: Result>, StorageRetrievalError>| { match last_send { // If we already have a value in storage and the block number is recent enough // we avoid sending another transaction at this time. @@ -419,9 +419,9 @@ impl Pallet { let transaction_type = block_number % 4u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed - } else if transaction_type == T::BlockNumber::from(1u32) { + } else if transaction_type == frame_system::pallet_prelude::BlockNumberFor::::from(1u32) { TransactionType::UnsignedForAny - } else if transaction_type == T::BlockNumber::from(2u32) { + } else if transaction_type == frame_system::pallet_prelude::BlockNumberFor::::from(2u32) { TransactionType::UnsignedForAll } else { TransactionType::Raw @@ -472,7 +472,7 @@ impl Pallet { } /// A helper function to fetch the price and send a raw unsigned transaction. - fn fetch_price_and_send_raw_unsigned(block_number: T::BlockNumber) -> Result<(), &'static str> { + fn fetch_price_and_send_raw_unsigned(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. let next_unsigned_at = >::get(); @@ -505,7 +505,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_any_account( - block_number: T::BlockNumber, + block_number: frame_system::pallet_prelude::BlockNumberFor::, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -535,7 +535,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_all_accounts( - block_number: T::BlockNumber, + block_number: frame_system::pallet_prelude::BlockNumberFor::, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -669,7 +669,7 @@ impl Pallet { } fn validate_transaction_parameters( - block_number: &T::BlockNumber, + block_number: &frame_system::pallet_prelude::BlockNumberFor::, new_price: &u32, ) -> TransactionValidity { // Now let's check if the transaction has any chance to succeed. diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 1e4107b2f80ad..665fe0612710c 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -55,12 +55,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -271,7 +270,7 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() { let signature_valid = ::Public, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, > as SignedPayload>::verify::(&price_payload, signature); assert!(signature_valid); @@ -325,7 +324,7 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() { let signature_valid = ::Public, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, > as SignedPayload>::verify::(&price_payload, signature); assert!(signature_valid); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 31cbb0ee7ba0d..4a40f13616cf1 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -178,14 +178,14 @@ pub struct Executive< impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block
, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > ExecuteBlock for Executive @@ -212,15 +212,15 @@ where #[cfg(feature = "try-runtime")] impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block
, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker - + frame_support::traits::TryState, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker> + + frame_support::traits::TryState>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -297,7 +297,7 @@ where // run the try-state checks of all pallets, ensuring they don't alter any state. let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( + >>::try_state( *header.number(), select, ) @@ -344,7 +344,7 @@ where ) -> Result { if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -357,7 +357,7 @@ where if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -369,14 +369,14 @@ where impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block
, Hash = System::Hash>, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -393,14 +393,14 @@ where } /// Start the execution of a particular block. - pub fn initialize_block(header: &System::Header) { + pub fn initialize_block(header: &frame_system::pallet_prelude::HeaderFor) { sp_io::init_tracing(); sp_tracing::enter_span!(sp_tracing::Level::TRACE, "init_block"); let digests = Self::extract_pre_digest(header); Self::initialize_block_impl(header.number(), header.parent_hash(), &digests); } - fn extract_pre_digest(header: &System::Header) -> Digest { + fn extract_pre_digest(header: &frame_system::pallet_prelude::HeaderFor) -> Digest { let mut digest = ::default(); header.digest().logs().iter().for_each(|d| { if d.as_pre_runtime().is_some() { @@ -411,7 +411,7 @@ where } fn initialize_block_impl( - block_number: &System::BlockNumber, + block_number: &frame_system::pallet_prelude::BlockNumberFor, parent_hash: &System::Hash, digest: &Digest, ) { @@ -426,7 +426,7 @@ where } >::initialize(block_number, parent_hash, digest); weight = weight.saturating_add(, >>::on_initialize(*block_number)); weight = weight.saturating_add( >::get().base_block, @@ -461,8 +461,8 @@ where // Check that `parent_hash` is correct. let n = *header.number(); assert!( - n > System::BlockNumber::zero() && - >::block_hash(n - System::BlockNumber::one()) == + n > frame_system::pallet_prelude::BlockNumberFor::::zero() && + >::block_hash(n - frame_system::pallet_prelude::BlockNumberFor::::one()) == *header.parent_hash(), "Parent hash should be valid.", ); @@ -512,7 +512,7 @@ where /// Finalize the block - it is up the caller to ensure that all header fields are valid /// except state-root. - pub fn finalize_block() -> System::Header { + pub fn finalize_block() -> frame_system::pallet_prelude::HeaderFor { sp_io::init_tracing(); sp_tracing::enter_span!(sp_tracing::Level::TRACE, "finalize_block"); >::note_finished_extrinsics(); @@ -529,7 +529,7 @@ where let remaining_weight = max_weight.saturating_sub(weight.total()); if remaining_weight.all_gt(Weight::zero()) { - let used_weight = >::on_idle( + let used_weight = >>::on_idle( block_number, remaining_weight, ); @@ -539,7 +539,7 @@ where ); } - >::on_finalize(block_number); + >>::on_finalize(block_number); } /// Apply extrinsic outside of the block execution function. @@ -579,7 +579,7 @@ where Ok(r.map(|_| ()).map_err(|e| e.error)) } - fn final_checks(header: &System::Header) { + fn final_checks(header: &frame_system::pallet_prelude::HeaderFor) { sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks"); // remove temporaries let new_header = >::finalize(); @@ -651,7 +651,7 @@ where } /// Start an offchain worker and generate extrinsics. - pub fn offchain_worker(header: &System::Header) { + pub fn offchain_worker(header: &frame_system::pallet_prelude::HeaderFor) { sp_io::init_tracing(); // We need to keep events available for offchain workers, // hence we initialize the block manually. @@ -665,7 +665,7 @@ where // as well. frame_system::BlockHash::::insert(header.number(), header.hash()); - >::offchain_worker( + >>::offchain_worker( *header.number(), ) } @@ -712,17 +712,17 @@ mod tests { impl Hooks> for Pallet { // module hooks. // one with block number arg and one without - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { println!("on_initialize({})", n); Weight::from_parts(175, 0) } - fn on_idle(n: T::BlockNumber, remaining_weight: Weight) -> Weight { + fn on_idle(n: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight) -> Weight { println!("on_idle{}, {})", n, remaining_weight); Weight::from_parts(175, 0) } - fn on_finalize(n: T::BlockNumber) { + fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::) { println!("on_finalize({})", n); } @@ -731,8 +731,8 @@ mod tests { Weight::from_parts(200, 0) } - fn offchain_worker(n: T::BlockNumber) { - assert_eq!(T::BlockNumber::from(1u32), n); + fn offchain_worker(n: frame_system::pallet_prelude::BlockNumberFor::) { + assert_eq!(frame_system::pallet_prelude::BlockNumberFor::::from(1u32), n); } } @@ -859,7 +859,7 @@ mod tests { type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index 9be5878f2e199..b14ed6ce56b34 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -272,8 +272,8 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks for Pallet { - fn on_idle(_: T::BlockNumber, remaining_weight: Weight) -> Weight { + impl Hooks> for Pallet { + fn on_idle(_: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight) -> Weight { if remaining_weight.any_lt(T::DbWeight::get().reads(2)) { return Weight::from_parts(0, 0) } @@ -295,7 +295,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { // ensure that the value of `ErasToCheckPerBlock` is less than // `T::MaxErasToCheckPerBlock`. ensure!( diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 101ad90881171..d29143cfb7fa8 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -48,13 +48,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); @@ -198,10 +197,7 @@ type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime!( pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_system, Timestamp: pallet_timestamp, diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index ff59bc8d98e48..d4775947b52cc 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -46,13 +46,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index 44d0266375230..cd4d7b9afdf7b 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -118,7 +118,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, impl OffenceReportSystem< Option, - (EquivocationProof, T::KeyOwnerProof), + (EquivocationProof>, T::KeyOwnerProof), > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -134,7 +134,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -152,7 +152,7 @@ where } fn check_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -172,7 +172,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 8311131e97347..950613b83e276 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -113,13 +113,13 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(block_number: T::BlockNumber) { + fn on_finalize(block_number: frame_system::pallet_prelude::BlockNumberFor::) { // check for scheduled pending authority set changes if let Some(pending_change) = >::get() { // emit signal if we're at the block that scheduled the change @@ -191,7 +191,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -217,7 +217,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -245,8 +245,8 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::note_stalled())] pub fn note_stalled( origin: OriginFor, - delay: T::BlockNumber, - best_finalized_block_number: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, + best_finalized_block_number: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { ensure_root(origin)?; @@ -287,7 +287,7 @@ pub mod pallet { } #[pallet::type_value] - pub(super) fn DefaultForState() -> StoredState { + pub(super) fn DefaultForState() -> StoredState> { StoredState::Live } @@ -295,23 +295,23 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn state)] pub(super) type State = - StorageValue<_, StoredState, ValueQuery, DefaultForState>; + StorageValue<_, StoredState>, ValueQuery, DefaultForState>; /// Pending change: (signaled at, scheduled change). #[pallet::storage] #[pallet::getter(fn pending_change)] pub(super) type PendingChange = - StorageValue<_, StoredPendingChange>; + StorageValue<_, StoredPendingChange, T::MaxAuthorities>>; /// next block number where we can force a change. #[pallet::storage] #[pallet::getter(fn next_forced)] - pub(super) type NextForced = StorageValue<_, T::BlockNumber>; + pub(super) type NextForced = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::>; /// `true` if we are currently stalled. #[pallet::storage] #[pallet::getter(fn stalled)] - pub(super) type Stalled = StorageValue<_, (T::BlockNumber, T::BlockNumber)>; + pub(super) type Stalled = StorageValue<_, (frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::)>; /// The number of changes (both in terms of keys and underlying economic responsibilities) /// in the "set" of Grandpa validators from genesis. @@ -427,7 +427,7 @@ impl Pallet { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult { + pub fn schedule_pause(in_blocks: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at }); @@ -439,7 +439,7 @@ impl Pallet { } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult { + pub fn schedule_resume(in_blocks: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at }); @@ -466,8 +466,8 @@ impl Pallet { /// an error if a change is already pending. pub fn schedule_change( next_authorities: AuthorityList, - in_blocks: T::BlockNumber, - forced: Option, + in_blocks: frame_system::pallet_prelude::BlockNumberFor::, + forced: Option>, ) -> DispatchResult { if !>::exists() { let scheduled_at = >::block_number(); @@ -504,7 +504,7 @@ impl Pallet { } /// Deposit one of this module's logs. - fn deposit_log(log: ConsensusLog) { + fn deposit_log(log: ConsensusLog>) { let log = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); >::deposit_log(log); } @@ -528,13 +528,13 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() } - fn on_stalled(further_wait: T::BlockNumber, median: T::BlockNumber) { + fn on_stalled(further_wait: frame_system::pallet_prelude::BlockNumberFor::, median: frame_system::pallet_prelude::BlockNumberFor::) { // when we record old authority sets we could try to figure out _who_ // failed. until then, we can't meaningfully guard against // `next == last` the way that normal session changes do. diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 292753a70fbe5..c0c1f43c90a89 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -73,13 +73,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 0f3fee40e6a9b..bd3a1d9edb3cf 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -51,13 +51,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/im-online/src/benchmarking.rs b/frame/im-online/src/benchmarking.rs index 4766e5edaadcf..16c0eb5b2f5d3 100644 --- a/frame/im-online/src/benchmarking.rs +++ b/frame/im-online/src/benchmarking.rs @@ -36,7 +36,7 @@ const MAX_KEYS: u32 = 1000; pub fn create_heartbeat( k: u32, ) -> Result< - (crate::Heartbeat, ::Signature), + (crate::Heartbeat>, ::Signature), &'static str, > { let mut keys = Vec::new(); @@ -48,7 +48,7 @@ pub fn create_heartbeat( Keys::::put(bounded_keys); let input_heartbeat = Heartbeat { - block_number: T::BlockNumber::zero(), + block_number: frame_system::pallet_prelude::BlockNumberFor::::zero(), session_index: 0, authority_index: k - 1, validators_len: keys.len() as u32, diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 1f9557a427293..0aae15ee6fe82 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -245,7 +245,7 @@ pub type IdentificationTuple = ( >>::Identification, ); -type OffchainResult = Result::BlockNumber>>; +type OffchainResult = Result>>; #[frame_support::pallet] pub mod pallet { @@ -287,7 +287,7 @@ pub mod pallet { /// rough time when we should start considering sending heartbeats, since the workers /// avoids sending them at the very beginning of the session, assuming there is a /// chance the authority will produce a block and they won't be necessary. - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// A type that gives us the ability to submit unresponsiveness offence reports. type ReportUnresponsiveness: ReportOffence< @@ -339,7 +339,7 @@ pub mod pallet { /// more accurate then the value we calculate for `HeartbeatAfter`. #[pallet::storage] #[pallet::getter(fn heartbeat_after)] - pub(super) type HeartbeatAfter = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type HeartbeatAfter = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; /// The current set of keys that may issue a heartbeat. #[pallet::storage] @@ -393,7 +393,7 @@ pub mod pallet { ))] pub fn heartbeat( origin: OriginFor, - heartbeat: Heartbeat, + heartbeat: Heartbeat>, // since signature verification is done in `validate_unsigned` // we can skip doing it here again. _signature: ::Signature, @@ -505,7 +505,7 @@ pub mod pallet { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of being online. impl - pallet_authorship::EventHandler, T::BlockNumber> for Pallet + pallet_authorship::EventHandler, frame_system::pallet_prelude::BlockNumberFor::> for Pallet { fn note_author(author: ValidatorId) { Self::note_authorship(author); @@ -551,7 +551,7 @@ impl Pallet { } pub(crate) fn send_heartbeats( - block_number: T::BlockNumber, + block_number: frame_system::pallet_prelude::BlockNumberFor::, ) -> OffchainResult>> { const START_HEARTBEAT_RANDOM_PERIOD: Permill = Permill::from_percent(10); const START_HEARTBEAT_FINAL_PERIOD: Permill = Permill::from_percent(80); @@ -614,7 +614,7 @@ impl Pallet { authority_index: u32, key: T::AuthorityId, session_index: SessionIndex, - block_number: T::BlockNumber, + block_number: frame_system::pallet_prelude::BlockNumberFor::, validators_len: u32, ) -> OffchainResult { // A helper function to prepare heartbeat call. @@ -677,7 +677,7 @@ impl Pallet { fn with_heartbeat_lock( authority_index: u32, session_index: SessionIndex, - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, f: impl FnOnce() -> OffchainResult, ) -> OffchainResult { let key = { @@ -687,7 +687,7 @@ impl Pallet { }; let storage = StorageValueRef::persistent(&key); let res = storage.mutate( - |status: Result>, StorageRetrievalError>| { + |status: Result>>, StorageRetrievalError>| { // Check if there is already a lock for that particular block. // This means that the heartbeat has already been sent, and we are just waiting // for it to be included. However if it doesn't get included for INCLUDE_THRESHOLD diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 1a99302f6e309..dae4ac1f05ac9 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -121,13 +121,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index b4adada76fa30..708181f4890a6 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -44,12 +44,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = Indices; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 46f2d4ecf50ca..44395849cc1dd 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -78,7 +78,7 @@ use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; -fn block_number_to_index(block_number: T::BlockNumber) -> usize { +fn block_number_to_index(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> usize { // on_initialize is called on the first block after genesis let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); index.try_into().ok().expect("Something % 81 is always smaller than usize; qed") @@ -100,7 +100,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(block_number: T::BlockNumber) -> Weight { + fn on_initialize(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let parent_hash = >::parent_hash(); >::mutate(|ref mut values| { @@ -123,7 +123,7 @@ pub mod pallet { StorageValue<_, BoundedVec>, ValueQuery>; } -impl Randomness for Pallet { +impl Randomness> for Pallet { /// This randomness uses a low-influence function, drawing upon the block hashes from the /// previous 81 blocks. Its result for any given subject will be known far in advance by anyone /// observing the chain. Any block producer has significant influence over their block hashes @@ -134,7 +134,7 @@ impl Randomness for Pallet { /// WARNING: Hashing the result of this function will remove any low-influence properties it has /// and mean that all bits of the resulting value are entirely manipulatable by the author of /// the parent block, who can determine the value of `parent_hash`. - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { let block_number = >::block_number(); let index = block_number_to_index::(block_number); @@ -197,13 +197,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 178f221a8946f..86012c8f789cb 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -142,7 +142,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness>; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -208,7 +208,7 @@ pub mod pallet { /// The configuration for the current lottery. #[pallet::storage] pub(crate) type Lottery = - StorageValue<_, LotteryConfig>>; + StorageValue<_, LotteryConfig, BalanceOf>>; /// Users who have purchased a ticket. (Lottery Index, Tickets Purchased) #[pallet::storage] @@ -239,7 +239,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { Lottery::::mutate(|mut lottery| -> Weight { if let Some(config) = &mut lottery { let payout_block = @@ -350,8 +350,8 @@ pub mod pallet { pub fn start_lottery( origin: OriginFor, price: BalanceOf, - length: T::BlockNumber, - delay: T::BlockNumber, + length: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor::, repeat: bool, ) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 7e1779e9148fc..75fcb54690329 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -57,12 +57,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Index = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index eeffe51f2baf8..1f8e729561f96 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -563,7 +563,7 @@ mod tests { type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 3adad1e955481..bc19280e64dda 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -91,7 +91,7 @@ pub struct ParentNumberAndHash { } impl LeafDataProvider for ParentNumberAndHash { - type LeafData = (::BlockNumber, ::Hash); + type LeafData = (frame_system::pallet_prelude::BlockNumberFor, ::Hash); fn leaf_data() -> Self::LeafData { ( @@ -201,7 +201,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { use primitives::LeafDataProvider; let leaves = Self::mmr_leaves(); let peaks_before = sp_mmr_primitives::utils::NodesUtils::new(leaves).number_of_peaks(); @@ -266,7 +266,7 @@ impl, I: 'static> Pallet { pos: NodeIndex, parent_hash: ::Hash, ) -> sp_std::prelude::Vec { - NodesUtils::node_temp_offchain_key::<::Header>( + NodesUtils::node_temp_offchain_key::>( &T::INDEXING_PREFIX, pos, parent_hash, @@ -286,7 +286,7 @@ impl, I: 'static> Pallet { fn leaf_index_to_parent_block_num( leaf_index: LeafIndex, leaves_count: LeafIndex, - ) -> ::BlockNumber { + ) -> frame_system::pallet_prelude::BlockNumberFor { // leaves are zero-indexed and were added one per block since pallet activation, // while block numbers are one-indexed, so block number that added `leaf_idx` is: // `block_num = block_num_when_pallet_activated + leaf_idx + 1` @@ -298,16 +298,16 @@ impl, I: 'static> Pallet { } /// Convert a block number into a leaf index. - fn block_num_to_leaf_index(block_num: T::BlockNumber) -> Result + fn block_num_to_leaf_index(block_num: frame_system::pallet_prelude::BlockNumberFor::) -> Result where T: frame_system::Config, { - let first_mmr_block = utils::first_mmr_block_num::( + let first_mmr_block = utils::first_mmr_block_num::>( >::block_number(), Self::mmr_leaves(), )?; - utils::block_num_to_leaf_index::(block_num, first_mmr_block) + utils::block_num_to_leaf_index::>(block_num, first_mmr_block) } /// Generate an MMR proof for the given `block_numbers`. @@ -320,8 +320,8 @@ impl, I: 'static> Pallet { /// all the leaves to be present. /// It may return an error or panic if used incorrectly. pub fn generate_proof( - block_numbers: Vec, - best_known_block_number: Option, + block_numbers: Vec>, + best_known_block_number: Option>, ) -> Result<(Vec>, primitives::Proof>), primitives::Error> { // check whether best_known_block_number provided, else use current best block let best_known_block_number = diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index d55bd91a36100..cb62bc201cf0b 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -46,12 +46,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/merkle-mountain-range/src/tests.rs b/frame/merkle-mountain-range/src/tests.rs index b628b51d2938b..75296fab820bf 100644 --- a/frame/merkle-mountain-range/src/tests.rs +++ b/frame/merkle-mountain-range/src/tests.rs @@ -53,7 +53,7 @@ pub(crate) fn hex(s: &str) -> H256 { s.parse().unwrap() } -type BlockNumber = ::BlockNumber; +type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; fn decode_node( v: Vec, diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index b2c084a762f8f..98d70653a65fa 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -61,13 +61,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index 8dac0fa9b9205..2a0632041f61c 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -51,13 +51,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -272,7 +271,7 @@ impl OnQueueChanged for RecordingQueueChangeHandler { /// Is generic since it is used by the unit test, integration tests and benchmarks. pub fn new_test_ext() -> sp_io::TestExternalities where - ::BlockNumber: From, + frame_system::pallet_prelude::BlockNumberFor: From, { sp_tracing::try_init_simple(); WeightForCall::take(); diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 64058be9c8fbf..ef475100b9bfa 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -183,7 +183,7 @@ pub mod pallet { T::AccountId, Blake2_128Concat, [u8; 32], - Multisig, T::AccountId, T::MaxSignatories>, + Multisig, BalanceOf, T::AccountId, T::MaxSignatories>, >; #[pallet::error] @@ -226,14 +226,14 @@ pub mod pallet { /// A multisig operation has been approved by someone. MultisigApproval { approving: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, /// A multisig operation has been executed. MultisigExecuted { approving: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, result: DispatchResult, @@ -241,7 +241,7 @@ pub mod pallet { /// A multisig operation has been cancelled. MultisigCancelled { cancelling: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, @@ -366,7 +366,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call: Box<::RuntimeCall>, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -423,7 +423,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call_hash: [u8; 32], max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -465,7 +465,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - timepoint: Timepoint, + timepoint: Timepoint>, call_hash: [u8; 32], ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -511,7 +511,7 @@ impl Pallet { who: T::AccountId, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call_or_hash: CallOrHash, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -637,7 +637,7 @@ impl Pallet { } /// The current `Timepoint`. - pub fn timepoint() -> Timepoint { + pub fn timepoint() -> Timepoint> { Timepoint { height: >::block_number(), index: >::extrinsic_index().unwrap_or_default(), diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index a15d71ebf4218..901c7724475c8 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -52,13 +52,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 50bb6039eb6ec..51927aaa1b4a8 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -41,7 +41,7 @@ type BalanceOf = type CollectionConfigOf = CollectionConfig< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::NftCollectionId, >; @@ -58,7 +58,7 @@ where fn mint_nft(nft_id: T::NftId) -> (T::AccountId, AccountIdLookupOf) where - T::Nfts: Create, T::BlockNumber, T::NftCollectionId>> + T::Nfts: Create, frame_system::pallet_prelude::BlockNumberFor::, T::NftCollectionId>> + Mutate, { let caller: T::AccountId = whitelisted_caller(); @@ -84,7 +84,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { benchmarks! { where_clause { where - T::Nfts: Create, T::BlockNumber, T::NftCollectionId>> + T::Nfts: Create, frame_system::pallet_prelude::BlockNumberFor::, T::NftCollectionId>> + Mutate, } diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 7b555ad80a698..208fd1e6f32d0 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -58,12 +58,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 45390bf032bd6..4b955c6129c09 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -589,7 +589,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); - let deadline = T::BlockNumber::max_value(); + let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup, Some(deadline)) verify { assert_last_event::(Event::TransferApproved { collection, item, owner: caller, delegate, deadline: Some(deadline) }.into()); @@ -601,7 +601,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = T::BlockNumber::max_value(); + let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) verify { @@ -614,7 +614,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = T::BlockNumber::max_value(); + let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { diff --git a/frame/nfts/src/features/approvals.rs b/frame/nfts/src/features/approvals.rs index 634436a8562d8..c78dd2d96b089 100644 --- a/frame/nfts/src/features/approvals.rs +++ b/frame/nfts/src/features/approvals.rs @@ -24,7 +24,7 @@ impl, I: 'static> Pallet { collection: T::CollectionId, item: T::ItemId, delegate: T::AccountId, - maybe_deadline: Option<::BlockNumber>, + maybe_deadline: Option>, ) -> DispatchResult { ensure!( Self::is_pallet_feature_enabled(PalletFeature::Approvals), diff --git a/frame/nfts/src/features/atomic_swap.rs b/frame/nfts/src/features/atomic_swap.rs index 505056be95353..5b0096d72a3d6 100644 --- a/frame/nfts/src/features/atomic_swap.rs +++ b/frame/nfts/src/features/atomic_swap.rs @@ -29,7 +29,7 @@ impl, I: 'static> Pallet { desired_collection_id: T::CollectionId, maybe_desired_item_id: Option, maybe_price: Option>>, - duration: ::BlockNumber, + duration: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { ensure!( Self::is_pallet_feature_enabled(PalletFeature::Swaps), diff --git a/frame/nfts/src/features/settings.rs b/frame/nfts/src/features/settings.rs index 080d7b97f13b1..3d96a411ae708 100644 --- a/frame/nfts/src/features/settings.rs +++ b/frame/nfts/src/features/settings.rs @@ -61,7 +61,7 @@ impl, I: 'static> Pallet { collection: T::CollectionId, mint_settings: MintSettings< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, T::CollectionId, >, ) -> DispatchResult { diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index f2812674a5408..137fd33ec40a2 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -171,7 +171,7 @@ pub mod pallet { /// The max duration in blocks for deadlines. #[pallet::constant] - type MaxDeadlineDuration: Get<::BlockNumber>; + type MaxDeadlineDuration: Get>; /// The max number of attributes a user could set per call. #[pallet::constant] @@ -343,7 +343,7 @@ pub mod pallet { T::CollectionId, T::ItemId, PriceWithDirection>, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, >, OptionQuery, >; @@ -414,7 +414,7 @@ pub mod pallet { item: T::ItemId, owner: T::AccountId, delegate: T::AccountId, - deadline: Option<::BlockNumber>, + deadline: Option>, }, /// An approval for a `delegate` account to transfer the `item` of an item /// `collection` was cancelled by its `owner`. @@ -509,7 +509,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: ::BlockNumber, + deadline: frame_system::pallet_prelude::BlockNumberFor, }, /// The swap was cancelled. SwapCancelled { @@ -518,7 +518,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: ::BlockNumber, + deadline: frame_system::pallet_prelude::BlockNumberFor, }, /// The swap has been claimed. SwapClaimed { @@ -529,7 +529,7 @@ pub mod pallet { received_item: T::ItemId, received_item_owner: T::AccountId, price: Option>>, - deadline: ::BlockNumber, + deadline: frame_system::pallet_prelude::BlockNumberFor, }, /// New attributes have been set for an `item` of the `collection`. PreSignedAttributesSet { @@ -1236,7 +1236,7 @@ pub mod pallet { collection: T::CollectionId, item: T::ItemId, delegate: AccountIdLookupOf, - maybe_deadline: Option<::BlockNumber>, + maybe_deadline: Option>, ) -> DispatchResult { let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) @@ -1661,7 +1661,7 @@ pub mod pallet { collection: T::CollectionId, mint_settings: MintSettings< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, T::CollectionId, >, ) -> DispatchResult { @@ -1759,7 +1759,7 @@ pub mod pallet { desired_collection: T::CollectionId, maybe_desired_item: Option, maybe_price: Option>>, - duration: ::BlockNumber, + duration: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { let origin = ensure_signed(origin)?; Self::do_create_swap( diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 71e51757484f2..987601d1f601c 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -55,12 +55,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index ab966f0d73828..7c29f07e2222e 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -34,7 +34,7 @@ pub(super) type CollectionDetailsFor = CollectionDetails<::AccountId, DepositBalanceOf>; pub(super) type ApprovalsOf = BoundedBTreeMap< ::AccountId, - Option<::BlockNumber>, + Option>, >::ApprovalsLimit, >; pub(super) type ItemAttributesApprovals = @@ -58,21 +58,21 @@ pub(super) type ItemTipOf = ItemTip< >; pub(super) type CollectionConfigFor = CollectionConfig< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, >::CollectionId, >; pub(super) type PreSignedMintOf = PreSignedMint< >::CollectionId, >::ItemId, ::AccountId, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BalanceOf, >; pub(super) type PreSignedAttributesOf = PreSignedAttributes< >::CollectionId, >::ItemId, ::AccountId, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, >; /// Information about a collection. diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 10403ac66d5ab..d3636403da924 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -268,7 +268,7 @@ mod tests { type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 48d322545a635..2bebd28ee649f 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -188,11 +188,11 @@ pub mod pallet { fungible::Debt<::AccountId, ::Currency>; type ReceiptRecordOf = ReceiptRecord< ::AccountId, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BalanceOf, >; type IssuanceInfoOf = IssuanceInfo>; - type SummaryRecordOf = SummaryRecord<::BlockNumber, BalanceOf>; + type SummaryRecordOf = SummaryRecord, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; @@ -275,7 +275,7 @@ pub mod pallet { /// The base period for the duration queues. This is the common multiple across all /// supported freezing durations that can be bid upon. #[pallet::constant] - type BasePeriod: Get; + type BasePeriod: Get>; /// The minimum amount of funds that may be placed in a bid. Note that this /// does not actually limit the amount which may be represented in a receipt since bids may @@ -296,7 +296,7 @@ pub mod pallet { /// A larger value results in fewer storage hits each block, but a slower period to get to /// the target. #[pallet::constant] - type IntakePeriod: Get; + type IntakePeriod: Get>; /// The maximum amount of bids that can consolidated into receipts in a single intake. A /// larger value here means less of the block available for transactions should there be a @@ -306,7 +306,7 @@ pub mod pallet { /// The maximum proportion which may be thawed and the period over which it is reset. #[pallet::constant] - type ThawThrottle: Get<(Perquintill, Self::BlockNumber)>; + type ThawThrottle: Get<(Perquintill, frame_system::pallet_prelude::BlockNumberFor)>; } #[pallet::pallet] @@ -413,7 +413,7 @@ pub mod pallet { /// The identity of the receipt. index: ReceiptIndex, /// The block number at which the receipt may be thawed. - expiry: T::BlockNumber, + expiry: frame_system::pallet_prelude::BlockNumberFor::, /// The owner of the receipt. who: T::AccountId, /// The proportion of the effective total issuance which the receipt represents. @@ -508,7 +508,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let mut weight_counter = WeightCounter { used: Weight::zero(), limit: T::MaxIntakeWeight::get() }; if T::IntakePeriod::get().is_zero() || (n % T::IntakePeriod::get()).is_zero() { @@ -1062,7 +1062,7 @@ pub mod pallet { pub(crate) fn process_queue( duration: u32, - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, our_account: &T::AccountId, issuance: &IssuanceInfo>, max_bids: u32, @@ -1106,7 +1106,7 @@ pub mod pallet { pub(crate) fn process_bid( mut bid: BidOf, - expiry: T::BlockNumber, + expiry: frame_system::pallet_prelude::BlockNumberFor::, _our_account: &T::AccountId, issuance: &IssuanceInfo>, remaining: &mut BalanceOf, diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 342f54011e412..e36e67dab5ec7 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -58,12 +58,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 6ccc142431e61..2ee10d55c5390 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -169,7 +169,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Set reserved node every block. It may not be enabled depends on the offchain /// worker settings when starting the node. - fn offchain_worker(now: T::BlockNumber) { + fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { let network_state = sp_io::offchain::network_state(); match network_state { Err(_) => log::error!( diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index b7c5957e15dee..b4c48fc1137f0 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -35,10 +35,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, NodeAuthorization: pallet_node_authorization::{ @@ -54,13 +51,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 6dd379f616d0a..eb69ed1989e02 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -35,13 +35,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 66c5f786f1e25..556600ebf9f4e 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -676,10 +676,10 @@ pub struct Commission { pub max: Option, /// Optional configuration around how often commission can be updated, and when the last /// commission update took place. - pub change_rate: Option>, + pub change_rate: Option>>, /// The block from where throttling should be checked from. This value will be updated on all /// commission updates and when setting an initial `change_rate`. - pub throttle_from: Option, + pub throttle_from: Option>, } impl Commission { @@ -813,7 +813,7 @@ impl Commission { /// throttling can be checked from this block. fn try_update_change_rate( &mut self, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, ) -> DispatchResult { ensure!(!&self.less_restrictive(&change_rate), Error::::CommissionChangeRateNotAllowed); @@ -833,7 +833,7 @@ impl Commission { /// /// No change rate will always be less restrictive than some change rate, so where no /// `change_rate` is currently set, `false` is returned. - fn less_restrictive(&self, new: &CommissionChangeRate) -> bool { + fn less_restrictive(&self, new: &CommissionChangeRate>) -> bool { self.change_rate .as_ref() .map(|c| new.max_increase > c.max_increase || new.min_delay < c.min_delay) @@ -1761,7 +1761,7 @@ pub mod pallet { /// A pool's commission `change_rate` has been changed. PoolCommissionChangeRateUpdated { pool_id: PoolId, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, }, /// Pool commission has been claimed. PoolCommissionClaimed { pool_id: PoolId, commission: BalanceOf }, @@ -2597,7 +2597,7 @@ pub mod pallet { pub fn set_commission_change_rate( origin: OriginFor, pool_id: PoolId, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, ) -> DispatchResult { let who = ensure_signed(origin)?; let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 6fc9696aa2bfa..4723a484b2f0c 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -168,13 +168,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index fbdc5b709b081..453e667a54ce2 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -45,13 +45,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index ae5c38967a40a..a1ff758caf01a 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -44,13 +44,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index a3390200501e9..d843e7640810d 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -84,13 +84,12 @@ impl frame_system::Config for Runtime { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index bda894a3921df..6917c9b8494d1 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -52,12 +52,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 7244dd5f17472..72c61dd6d5de3 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -41,7 +41,7 @@ fn add_proxies(n: u32, maybe_who: Option) -> Result<(), RawOrigin::Signed(caller.clone()).into(), real, T::ProxyType::default(), - T::BlockNumber::zero(), + frame_system::pallet_prelude::BlockNumberFor::::zero(), )?; } Ok(()) @@ -64,7 +64,7 @@ fn add_announcements( RawOrigin::Signed(real.clone()).into(), caller_lookup, T::ProxyType::default(), - T::BlockNumber::zero(), + frame_system::pallet_prelude::BlockNumberFor::::zero(), )?; real }; @@ -187,7 +187,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), real, T::ProxyType::default(), - T::BlockNumber::zero() + frame_system::pallet_prelude::BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -202,7 +202,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), delegate, T::ProxyType::default(), - T::BlockNumber::zero() + frame_system::pallet_prelude::BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -224,7 +224,7 @@ benchmarks! { }: _( RawOrigin::Signed(caller.clone()), T::ProxyType::default(), - T::BlockNumber::zero(), + frame_system::pallet_prelude::BlockNumberFor::::zero(), 0 ) verify { @@ -246,7 +246,7 @@ benchmarks! { Pallet::::create_pure( RawOrigin::Signed(whitelisted_caller()).into(), T::ProxyType::default(), - T::BlockNumber::zero(), + frame_system::pallet_prelude::BlockNumberFor::::zero(), 0 )?; let height = system::Pallet::::block_number(); diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 76ff2662bd0f4..c38c00e1d6aa0 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -227,7 +227,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -247,7 +247,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -291,7 +291,7 @@ pub mod pallet { pub fn create_pure( origin: OriginFor, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, index: u16, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -341,7 +341,7 @@ pub mod pallet { spawner: AccountIdLookupOf, proxy_type: T::ProxyType, index: u16, - #[pallet::compact] height: T::BlockNumber, + #[pallet::compact] height: frame_system::pallet_prelude::BlockNumberFor::, #[pallet::compact] ext_index: u32, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -535,14 +535,14 @@ pub mod pallet { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, }, /// A proxy was removed. ProxyRemoved { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, }, } @@ -575,7 +575,7 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec, T::MaxProxies>, + BoundedVec>, T::MaxProxies>, BalanceOf, ), ValueQuery, @@ -589,7 +589,7 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec, T::BlockNumber>, T::MaxPending>, + BoundedVec, frame_system::pallet_prelude::BlockNumberFor::>, T::MaxPending>, BalanceOf, ), ValueQuery, @@ -612,7 +612,7 @@ impl Pallet { who: &T::AccountId, proxy_type: &T::ProxyType, index: u16, - maybe_when: Option<(T::BlockNumber, u32)>, + maybe_when: Option<(frame_system::pallet_prelude::BlockNumberFor::, u32)>, ) -> T::AccountId { let (height, ext_index) = maybe_when.unwrap_or_else(|| { ( @@ -638,7 +638,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { ensure!(delegator != &delegatee, Error::::NoSelfProxy); Proxies::::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| { @@ -678,7 +678,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { Proxies::::try_mutate_exists(delegator, |x| { let (mut proxies, old_deposit) = x.take().ok_or(Error::::NotFound)?; @@ -734,7 +734,7 @@ impl Pallet { } fn edit_announcements< - F: FnMut(&Announcement, T::BlockNumber>) -> bool, + F: FnMut(&Announcement, frame_system::pallet_prelude::BlockNumberFor::>) -> bool, >( delegate: &T::AccountId, f: F, @@ -760,8 +760,8 @@ impl Pallet { real: &T::AccountId, delegate: &T::AccountId, force_proxy_type: Option, - ) -> Result, DispatchError> { - let f = |x: &ProxyDefinition| -> bool { + ) -> Result>, DispatchError> { + let f = |x: &ProxyDefinition>| -> bool { &x.delegate == delegate && force_proxy_type.as_ref().map_or(true, |y| &x.proxy_type == y) }; @@ -769,7 +769,7 @@ impl Pallet { } fn do_proxy( - def: ProxyDefinition, + def: ProxyDefinition>, real: T::AccountId, call: ::RuntimeCall, ) { diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index e9ae32b388cee..b9f61c4780458 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -55,13 +55,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 6fe9fc221a7df..2a8ab209ae85f 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -391,7 +391,7 @@ pub mod pallet { type DemoteOrigin: EnsureOrigin; /// The polling system used for our voting. - type Polls: Polling, Votes = Votes, Moment = Self::BlockNumber>; + type Polls: Polling, Votes = Votes, Moment = frame_system::pallet_prelude::BlockNumberFor>; /// Convert the tally class into the minimum rank required to vote on the poll. If /// `Polls::Class` is the same type as `Rank`, then `Identity` can be used here to mean diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index dcd387cae6cc3..347a993706ea4 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -53,13 +53,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index d66b5725fd4f7..6d0fe55925899 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -338,7 +338,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - RecoveryConfig, FriendsOf>, + RecoveryConfig, BalanceOf, FriendsOf>, >; /// Active recovery attempts. @@ -353,7 +353,7 @@ pub mod pallet { T::AccountId, Twox64Concat, T::AccountId, - ActiveRecovery, FriendsOf>, + ActiveRecovery, BalanceOf, FriendsOf>, >; /// The list of allowed proxy accounts. @@ -444,7 +444,7 @@ pub mod pallet { origin: OriginFor, friends: Vec, threshold: u16, - delay_period: T::BlockNumber, + delay_period: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { let who = ensure_signed(origin)?; // Check account is not already set up for recovery diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index e9b136b702d54..e77932de1491a 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -50,12 +50,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 4c332a3048d0b..574116d042de0 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -172,7 +172,7 @@ fn skip_timeout_period, I: 'static>(index: ReferendumIndex) { frame_system::Pallet::::set_block_number(timeout_period_over); } -fn alarm_time, I: 'static>(index: ReferendumIndex) -> T::BlockNumber { +fn alarm_time, I: 'static>(index: ReferendumIndex) -> frame_system::pallet_prelude::BlockNumberFor:: { let status = Referenda::::ensure_ongoing(index).unwrap(); status.alarm.unwrap().0 } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 3756257c33fe5..83d70a0494ec2 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -161,8 +161,8 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// The Scheduler. - type Scheduler: ScheduleAnon, PalletsOriginOf> - + ScheduleNamed, PalletsOriginOf>; + type Scheduler: ScheduleAnon, CallOf, PalletsOriginOf> + + ScheduleNamed, CallOf, PalletsOriginOf>; /// Currency type for this pallet. type Currency: ReservableCurrency; // Origins and unbalances. @@ -201,25 +201,25 @@ pub mod pallet { /// The number of blocks after submission that a referendum must begin being decided by. /// Once this passes, then anyone may cancel the referendum. #[pallet::constant] - type UndecidingTimeout: Get; + type UndecidingTimeout: Get>; /// Quantization level for the referendum wakeup scheduler. A higher number will result in /// fewer storage reads/writes needed for smaller voters, but also result in delays to the /// automatic referendum status changes. Explicit servicing instructions are unaffected. #[pallet::constant] - type AlarmInterval: Get; + type AlarmInterval: Get>; // The other stuff. /// Information concerning the different referendum tracks. #[pallet::constant] type Tracks: Get< Vec<( - , Self::BlockNumber>>::Id, - TrackInfo, Self::BlockNumber>, + , frame_system::pallet_prelude::BlockNumberFor>>::Id, + TrackInfo, frame_system::pallet_prelude::BlockNumberFor>, )>, > + TracksInfo< BalanceOf, - Self::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, RuntimeOrigin = ::PalletsOrigin, >; @@ -432,7 +432,7 @@ pub mod pallet { origin: OriginFor, proposal_origin: Box>, proposal: BoundedCallOf, - enactment_moment: DispatchTime, + enactment_moment: DispatchTime>, ) -> DispatchResult { let proposal_origin = *proposal_origin; let who = T::SubmitOrigin::ensure_origin(origin, &proposal_origin)?; @@ -704,7 +704,7 @@ pub mod pallet { impl, I: 'static> Polling for Pallet { type Index = ReferendumIndex; type Votes = VotesOf; - type Moment = T::BlockNumber; + type Moment = frame_system::pallet_prelude::BlockNumberFor::; type Class = TrackIdOf; fn classes() -> Vec { @@ -713,7 +713,7 @@ impl, I: 'static> Polling for Pallet { fn access_poll( index: Self::Index, - f: impl FnOnce(PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf>) -> R, + f: impl FnOnce(PollStatus<&mut T::Tally, frame_system::pallet_prelude::BlockNumberFor::, TrackIdOf>) -> R, ) -> R { match ReferendumInfoFor::::get(index) { Some(ReferendumInfo::Ongoing(mut status)) => { @@ -732,7 +732,7 @@ impl, I: 'static> Polling for Pallet { fn try_access_poll( index: Self::Index, f: impl FnOnce( - PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf>, + PollStatus<&mut T::Tally, frame_system::pallet_prelude::BlockNumberFor::, TrackIdOf>, ) -> Result, ) -> Result { match ReferendumInfoFor::::get(index) { @@ -849,7 +849,7 @@ impl, I: 'static> Pallet { fn schedule_enactment( index: ReferendumIndex, track: &TrackInfoOf, - desired: DispatchTime, + desired: DispatchTime>, origin: PalletsOriginOf, call: BoundedCallOf, ) { @@ -871,8 +871,8 @@ impl, I: 'static> Pallet { /// Set an alarm to dispatch `call` at block number `when`. fn set_alarm( call: BoundedCallOf, - when: T::BlockNumber, - ) -> Option<(T::BlockNumber, ScheduleAddressOf)> { + when: frame_system::pallet_prelude::BlockNumberFor::, + ) -> Option<(frame_system::pallet_prelude::BlockNumberFor::, ScheduleAddressOf)> { let alarm_interval = T::AlarmInterval::get().max(One::one()); // Alarm must go off no earlier than `when`. // This rounds `when` upwards to the next multiple of `alarm_interval`. @@ -905,9 +905,9 @@ impl, I: 'static> Pallet { fn begin_deciding( status: &mut ReferendumStatusOf, index: ReferendumIndex, - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, track: &TrackInfoOf, - ) -> (Option, BeginDecidingBranch) { + ) -> (Option>, BeginDecidingBranch) { let is_passing = Self::is_passing( &status.tally, Zero::zero(), @@ -943,11 +943,11 @@ impl, I: 'static> Pallet { /// /// If `None`, then it is queued and should be nudged automatically as the queue gets drained. fn ready_for_deciding( - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, track: &TrackInfoOf, index: ReferendumIndex, status: &mut ReferendumStatusOf, - ) -> (Option, ServiceBranch) { + ) -> (Option>, ServiceBranch) { let deciding_count = DecidingCount::::get(status.track); if deciding_count < track.max_deciding { // Begin deciding. @@ -1004,7 +1004,7 @@ impl, I: 'static> Pallet { fn ensure_alarm_at( status: &mut ReferendumStatusOf, index: ReferendumIndex, - alarm: T::BlockNumber, + alarm: frame_system::pallet_prelude::BlockNumberFor::, ) -> bool { if status.alarm.as_ref().map_or(true, |&(when, _)| when != alarm) { // Either no alarm or one that was different @@ -1049,7 +1049,7 @@ impl, I: 'static> Pallet { /// `TrackQueue`. Basically this happens when a referendum is in the deciding queue and receives /// a vote, or when it moves into the deciding queue. fn service_referendum( - now: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, index: ReferendumIndex, mut status: ReferendumStatusOf, ) -> (ReferendumInfoOf, bool, ServiceBranch) { @@ -1061,7 +1061,7 @@ impl, I: 'static> Pallet { }; // Default the alarm to the end of the world. let timeout = status.submitted + T::UndecidingTimeout::get(); - let mut alarm = T::BlockNumber::max_value(); + let mut alarm = frame_system::pallet_prelude::BlockNumberFor::::max_value(); let branch; match &mut status.deciding { None => { @@ -1192,7 +1192,7 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = if alarm < T::BlockNumber::max_value() { + let dirty_alarm = if alarm < frame_system::pallet_prelude::BlockNumberFor::::max_value() { Self::ensure_alarm_at(&mut status, index, alarm) } else { Self::ensure_no_alarm(&mut status) @@ -1207,7 +1207,7 @@ impl, I: 'static> Pallet { tally: &T::Tally, track_id: TrackIdOf, track: &TrackInfoOf, - ) -> T::BlockNumber { + ) -> frame_system::pallet_prelude::BlockNumberFor:: { deciding.confirming.unwrap_or_else(|| { // Set alarm to the point where the current voting would make it pass. let approval = tally.approval(track_id); @@ -1266,8 +1266,8 @@ impl, I: 'static> Pallet { /// `approval_needed`. fn is_passing( tally: &T::Tally, - elapsed: T::BlockNumber, - period: T::BlockNumber, + elapsed: frame_system::pallet_prelude::BlockNumberFor::, + period: frame_system::pallet_prelude::BlockNumberFor::, support_needed: &Curve, approval_needed: &Curve, id: TrackIdOf, diff --git a/frame/referenda/src/migration.rs b/frame/referenda/src/migration.rs index 6f796ca40d9be..6f5e42cd49657 100644 --- a/frame/referenda/src/migration.rs +++ b/frame/referenda/src/migration.rs @@ -37,7 +37,7 @@ pub mod v0 { pub type ReferendumInfoOf = ReferendumInfo< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 0778b591c32f3..e2d94a0ce9603 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -68,13 +68,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index d61b8955443c2..b9c30879cfaf1 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -42,7 +42,7 @@ pub type PalletsOriginOf = pub type ReferendumInfoOf = ReferendumInfo< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, @@ -52,22 +52,22 @@ pub type ReferendumInfoOf = ReferendumInfo< pub type ReferendumStatusOf = ReferendumStatus< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, ::AccountId, ScheduleAddressOf, >; -pub type DecidingStatusOf = DecidingStatus<::BlockNumber>; +pub type DecidingStatusOf = DecidingStatus>; pub type TrackInfoOf = - TrackInfo, ::BlockNumber>; + TrackInfo, frame_system::pallet_prelude::BlockNumberFor>; pub type TrackIdOf = <>::Tracks as TracksInfo< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, >>::Id; pub type ScheduleAddressOf = <>::Scheduler as Anon< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, CallOf, PalletsOriginOf, >>::Address; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 7467b5b10c8e1..d912b6f7758cc 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -45,12 +45,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index d5bd98db85099..4cca2cbe76391 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -88,13 +88,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 1279a30717752..0d0ed2f761a3e 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -126,14 +126,14 @@ pub mod pallet { /// The number of blocks between sequential payout cycles is the sum of this and /// `PayoutPeriod`. #[pallet::constant] - type RegistrationPeriod: Get; + type RegistrationPeriod: Get>; /// The number of blocks within a cycle which accounts have to claim the payout. /// /// The number of blocks between sequential payout cycles is the sum of this and /// `RegistrationPeriod`. #[pallet::constant] - type PayoutPeriod: Get; + type PayoutPeriod: Get>; /// The total budget per cycle. /// @@ -142,11 +142,11 @@ pub mod pallet { type Budget: Get>; } - pub type CycleIndexOf = ::BlockNumber; + pub type CycleIndexOf = frame_system::pallet_prelude::BlockNumberFor; pub type BalanceOf = <>::Paymaster as Pay>::Balance; pub type IdOf = <>::Paymaster as Pay>::Id; pub type StatusOf = - StatusType, ::BlockNumber, BalanceOf>; + StatusType, frame_system::pallet_prelude::BlockNumberFor, BalanceOf>; pub type ClaimantStatusOf = ClaimantStatus, BalanceOf, IdOf>; /// The overall status of the system. @@ -389,7 +389,7 @@ pub mod pallet { pub fn last_active(who: &T::AccountId) -> Result, DispatchError> { Ok(Claimant::::get(&who).ok_or(Error::::NotInducted)?.last_active) } - pub fn cycle_period() -> T::BlockNumber { + pub fn cycle_period() -> frame_system::pallet_prelude::BlockNumberFor:: { T::RegistrationPeriod::get() + T::PayoutPeriod::get() } fn do_payout(who: T::AccountId, beneficiary: T::AccountId) -> DispatchResult { diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index b53f870a44eda..9e5f63afa121f 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -58,13 +58,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index d56e007ec9a2a..b67f896b4b8e7 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -42,7 +42,7 @@ type SystemOrigin = ::RuntimeOrigin; /// - `None`: aborted (hash without preimage) /// - `Some(true)`: hash resolves into call if possible, plain call otherwise /// - `Some(false)`: plain call -fn fill_schedule(when: T::BlockNumber, n: u32) -> Result<(), &'static str> { +fn fill_schedule(when: frame_system::pallet_prelude::BlockNumberFor::, n: u32) -> Result<(), &'static str> { let t = DispatchTime::At(when); let origin: ::PalletsOrigin = frame_system::RawOrigin::Root.into(); for i in 0..n { @@ -125,7 +125,7 @@ fn make_origin(signed: bool) -> ::PalletsOrigin { benchmarks! { // `service_agendas` when no work is done. service_agendas_base { - let now = T::BlockNumber::from(BLOCK_NUMBER); + let now = frame_system::pallet_prelude::BlockNumberFor::::from(BLOCK_NUMBER); IncompleteSince::::put(now - One::one()); }: { Scheduler::::service_agendas(&mut WeightMeter::max_limit(), now, 0); @@ -224,7 +224,7 @@ benchmarks! { schedule { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let when = BLOCK_NUMBER.into(); - let periodic = Some((T::BlockNumber::one(), 100)); + let periodic = Some((frame_system::pallet_prelude::BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); @@ -267,7 +267,7 @@ benchmarks! { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let id = u32_to_name(s); let when = BLOCK_NUMBER.into(); - let periodic = Some((T::BlockNumber::one(), 100)); + let periodic = Some((frame_system::pallet_prelude::BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 8194f286c8323..255882040b68c 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -123,7 +123,7 @@ use crate::{Scheduled as ScheduledV3, Scheduled as ScheduledV2}; pub type ScheduledV2Of = ScheduledV2< Vec, ::RuntimeCall, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -131,7 +131,7 @@ pub type ScheduledV2Of = ScheduledV2< pub type ScheduledV3Of = ScheduledV3< Vec, CallOrHashOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -139,7 +139,7 @@ pub type ScheduledV3Of = ScheduledV3< pub type ScheduledOf = Scheduled< TaskName, Bounded<::RuntimeCall>, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -231,14 +231,14 @@ pub mod pallet { } #[pallet::storage] - pub type IncompleteSince = StorageValue<_, T::BlockNumber>; + pub type IncompleteSince = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::>; /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] pub type Agenda = StorageMap< _, Twox64Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, BoundedVec>, T::MaxScheduledPerBlock>, ValueQuery, >; @@ -249,28 +249,28 @@ pub mod pallet { /// identities. #[pallet::storage] pub(crate) type Lookup = - StorageMap<_, Twox64Concat, TaskName, TaskAddress>; + StorageMap<_, Twox64Concat, TaskName, TaskAddress>>; /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Scheduled some task. - Scheduled { when: T::BlockNumber, index: u32 }, + Scheduled { when: frame_system::pallet_prelude::BlockNumberFor::, index: u32 }, /// Canceled some task. - Canceled { when: T::BlockNumber, index: u32 }, + Canceled { when: frame_system::pallet_prelude::BlockNumberFor::, index: u32 }, /// Dispatched some task. Dispatched { - task: TaskAddress, + task: TaskAddress>, id: Option, result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. - CallUnavailable { task: TaskAddress, id: Option }, + CallUnavailable { task: TaskAddress>, id: Option }, /// The given task was unable to be renewed since the agenda is full at that block. - PeriodicFailed { task: TaskAddress, id: Option }, + PeriodicFailed { task: TaskAddress>, id: Option }, /// The given task can never be executed since it is overweight. - PermanentlyOverweight { task: TaskAddress, id: Option }, + PermanentlyOverweight { task: TaskAddress>, id: Option }, } #[pallet::error] @@ -290,7 +290,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Execute the scheduled calls - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let mut weight_counter = WeightMeter::from_limit(T::MaximumWeight::get()); Self::service_agendas(&mut weight_counter, now, u32::max_value()); weight_counter.consumed @@ -304,8 +304,8 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule( origin: OriginFor, - when: T::BlockNumber, - maybe_periodic: Option>, + when: frame_system::pallet_prelude::BlockNumberFor::, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -324,7 +324,7 @@ pub mod pallet { /// Cancel an anonymously scheduled task. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] - pub fn cancel(origin: OriginFor, when: T::BlockNumber, index: u32) -> DispatchResult { + pub fn cancel(origin: OriginFor, when: frame_system::pallet_prelude::BlockNumberFor::, index: u32) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; let origin = ::RuntimeOrigin::from(origin); Self::do_cancel(Some(origin.caller().clone()), (when, index))?; @@ -337,8 +337,8 @@ pub mod pallet { pub fn schedule_named( origin: OriginFor, id: TaskName, - when: T::BlockNumber, - maybe_periodic: Option>, + when: frame_system::pallet_prelude::BlockNumberFor::, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -370,8 +370,8 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule_after( origin: OriginFor, - after: T::BlockNumber, - maybe_periodic: Option>, + after: frame_system::pallet_prelude::BlockNumberFor::, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -393,8 +393,8 @@ pub mod pallet { pub fn schedule_named_after( origin: OriginFor, id: TaskName, - after: T::BlockNumber, - maybe_periodic: Option>, + after: frame_system::pallet_prelude::BlockNumberFor::, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -434,7 +434,7 @@ impl> Pallet { } Agenda::::translate::< - Vec::RuntimeCall, T::BlockNumber>>>, + Vec::RuntimeCall, frame_system::pallet_prelude::BlockNumberFor::>>>, _, >(|_, agenda| { Some(BoundedVec::truncate_from( @@ -669,7 +669,7 @@ impl Pallet { Scheduled< TaskName, Bounded<::RuntimeCall>, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, OldOrigin, T::AccountId, >, @@ -695,7 +695,7 @@ impl Pallet { }); } - fn resolve_time(when: DispatchTime) -> Result { + fn resolve_time(when: DispatchTime>) -> Result, DispatchError> { let now = frame_system::Pallet::::block_number(); let when = match when { @@ -713,9 +713,9 @@ impl Pallet { } fn place_task( - when: T::BlockNumber, + when: frame_system::pallet_prelude::BlockNumberFor::, what: ScheduledOf, - ) -> Result, (DispatchError, ScheduledOf)> { + ) -> Result>, (DispatchError, ScheduledOf)> { let maybe_name = what.maybe_id; let index = Self::push_to_agenda(when, what)?; let address = (when, index); @@ -727,7 +727,7 @@ impl Pallet { } fn push_to_agenda( - when: T::BlockNumber, + when: frame_system::pallet_prelude::BlockNumberFor::, what: ScheduledOf, ) -> Result)> { let mut agenda = Agenda::::get(when); @@ -749,7 +749,7 @@ impl Pallet { /// Remove trailing `None` items of an agenda at `when`. If all items are `None` remove the /// agenda record entirely. - fn cleanup_agenda(when: T::BlockNumber) { + fn cleanup_agenda(when: frame_system::pallet_prelude::BlockNumberFor::) { let mut agenda = Agenda::::get(when); match agenda.iter().rposition(|i| i.is_some()) { Some(i) if agenda.len() > i + 1 => { @@ -764,12 +764,12 @@ impl Pallet { } fn do_schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result, DispatchError> { + ) -> Result>, DispatchError> { let when = Self::resolve_time(when)?; let lookup_hash = call.lookup_hash(); @@ -799,7 +799,7 @@ impl Pallet { fn do_cancel( origin: Option, - (when, index): TaskAddress, + (when, index): TaskAddress>, ) -> Result<(), DispatchError> { let scheduled = Agenda::::try_mutate(when, |agenda| { agenda.get_mut(index as usize).map_or( @@ -831,9 +831,9 @@ impl Pallet { } fn do_reschedule( - (when, index): TaskAddress, - new_time: DispatchTime, - ) -> Result, DispatchError> { + (when, index): TaskAddress>, + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; if new_time == when { @@ -853,12 +853,12 @@ impl Pallet { fn do_schedule_named( id: TaskName, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result, DispatchError> { + ) -> Result>, DispatchError> { // ensure id it is unique if Lookup::::contains_key(&id) { return Err(Error::::FailedToSchedule.into()) @@ -922,8 +922,8 @@ impl Pallet { fn do_reschedule_named( id: TaskName, - new_time: DispatchTime, - ) -> Result, DispatchError> { + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; let lookup = Lookup::::get(id); @@ -953,7 +953,7 @@ use ServiceTaskError::*; impl Pallet { /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. - fn service_agendas(weight: &mut WeightMeter, now: T::BlockNumber, max: u32) { + fn service_agendas(weight: &mut WeightMeter, now: frame_system::pallet_prelude::BlockNumberFor::, max: u32) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { return } @@ -983,8 +983,8 @@ impl Pallet { fn service_agenda( weight: &mut WeightMeter, executed: &mut u32, - now: T::BlockNumber, - when: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, + when: frame_system::pallet_prelude::BlockNumberFor::, max: u32, ) -> bool { let mut agenda = Agenda::::get(when); @@ -1052,8 +1052,8 @@ impl Pallet { /// - Rescheduling the task for execution in a later agenda if periodic. fn service_task( weight: &mut WeightMeter, - now: T::BlockNumber, - when: T::BlockNumber, + now: frame_system::pallet_prelude::BlockNumberFor::, + when: frame_system::pallet_prelude::BlockNumberFor::, agenda_index: u32, is_first: bool, mut task: ScheduledOf, @@ -1161,14 +1161,14 @@ impl Pallet { } impl> - schedule::v2::Anon::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1184,26 +1184,26 @@ impl> fn reschedule( address: Self::Address, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when) } - fn next_dispatch_time((when, index): Self::Address) -> Result { + fn next_dispatch_time((when, index): Self::Address) -> Result, ()> { Agenda::::get(when).get(index as usize).ok_or(()).map(|_| when) } } impl> - schedule::v2::Named::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule_named( id: Vec, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1221,13 +1221,13 @@ impl> fn reschedule_named( id: Vec, - when: DispatchTime, + when: DispatchTime>, ) -> Result { let name = blake2_256(&id[..]); Self::do_reschedule_named(name, when) } - fn next_dispatch_time(id: Vec) -> Result { + fn next_dispatch_time(id: Vec) -> Result, ()> { let name = blake2_256(&id[..]); Lookup::::get(name) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) @@ -1235,14 +1235,14 @@ impl> } } -impl schedule::v3::Anon::RuntimeCall, T::PalletsOrigin> +impl schedule::v3::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; fn schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1256,12 +1256,12 @@ impl schedule::v3::Anon::RuntimeCall, T fn reschedule( address: Self::Address, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time((when, index): Self::Address) -> Result { + fn next_dispatch_time((when, index): Self::Address) -> Result, DispatchError> { Agenda::::get(when) .get(index as usize) .ok_or(DispatchError::Unavailable) @@ -1271,15 +1271,15 @@ impl schedule::v3::Anon::RuntimeCall, T use schedule::v3::TaskName; -impl schedule::v3::Named::RuntimeCall, T::PalletsOrigin> +impl schedule::v3::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; fn schedule_named( id: TaskName, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1293,12 +1293,12 @@ impl schedule::v3::Named::RuntimeCall, fn reschedule_named( id: TaskName, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule_named(id, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time(id: TaskName) -> Result { + fn next_dispatch_time(id: TaskName) -> Result, DispatchError> { Lookup::::get(id) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) .ok_or(DispatchError::Unavailable) diff --git a/frame/scheduler/src/migration.rs b/frame/scheduler/src/migration.rs index 78313fda66412..ad0418b9a38b5 100644 --- a/frame/scheduler/src/migration.rs +++ b/frame/scheduler/src/migration.rs @@ -34,10 +34,10 @@ pub mod v1 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, Vec< Option< - ScheduledV1<::RuntimeCall, ::BlockNumber>, + ScheduledV1<::RuntimeCall, frame_system::pallet_prelude::BlockNumberFor>, >, >, ValueQuery, @@ -48,7 +48,7 @@ pub mod v1 { Pallet, Twox64Concat, Vec, - TaskAddress<::BlockNumber>, + TaskAddress>, >; } @@ -60,7 +60,7 @@ pub mod v2 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, Vec>>, ValueQuery, >; @@ -70,7 +70,7 @@ pub mod v2 { Pallet, Twox64Concat, Vec, - TaskAddress<::BlockNumber>, + TaskAddress>, >; } @@ -82,7 +82,7 @@ pub mod v3 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, Vec>>, ValueQuery, >; @@ -92,7 +92,7 @@ pub mod v3 { Pallet, Twox64Concat, Vec, - TaskAddress<::BlockNumber>, + TaskAddress>, >; /// Migrate the scheduler pallet from V3 to V4. diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index f12fd7cdb1d1a..86c58fdd6b876 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -128,12 +128,11 @@ impl system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index f8fc0fecd492a..1221ff1a06d5f 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -170,7 +170,7 @@ pub mod pallet { /// Every `Period` blocks the `Members` are filled with the highest scoring /// members in the `Pool`. #[pallet::constant] - type Period: Get; + type Period: Get>; /// The receiver of the signal for when the membership has been initialized. /// This happens pre-genesis and will usually be the same as `MembershipChanged`. @@ -282,7 +282,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// Every `Period` blocks the `Members` set is refreshed from the /// highest scoring members in the pool. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { if n % T::Period::get() == Zero::zero() { let pool = >::get(); >::refresh_members(pool, ChangeReceiver::MembershipChanged); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 1f553349c1372..78b82dd60cff3 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -58,13 +58,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index a7e326fb27ac3..619c51df501d4 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -46,8 +46,8 @@ pub trait Config: { } -impl OnInitialize for Pallet { - fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight { +impl OnInitialize> for Pallet { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> frame_support::weights::Weight { pallet_session::Pallet::::on_initialize(n) } } @@ -156,7 +156,7 @@ fn check_membership_proof_setup( Session::::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap(); } - Pallet::::on_initialize(T::BlockNumber::one()); + Pallet::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::one()); // skip sessions until the new validator set is enacted while Session::::validators().len() < n as usize { diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 8ecab94d72612..6f546c7e4461b 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -51,13 +51,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 1219aaaf12a10..30ba2db6a2a88 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -393,12 +393,12 @@ pub mod pallet { type ValidatorIdOf: Convert>; /// Indicator for when to end the session. - type ShouldEndSession: ShouldEndSession; + type ShouldEndSession: ShouldEndSession>; /// Something that can predict the next session rotation. This should typically come from /// the same logical unit that provides [`ShouldEndSession`], yet, it gives a best effort /// estimate. It is helpful to implement [`EstimateNextNewSession`]. - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// Handler for managing new session. type SessionManager: SessionManager; @@ -559,7 +559,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Called when a block is initialized. Will rotate session if it is the last /// block of the current session. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { if T::ShouldEndSession::should_end_session(n) { Self::rotate_session(); T::BlockWeights::get().max_block @@ -901,14 +901,14 @@ impl ValidatorSet for Pallet { } } -impl EstimateNextNewSession for Pallet { - fn average_session_length() -> T::BlockNumber { +impl EstimateNextNewSession> for Pallet { + fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor:: { T::NextSessionRotation::average_session_length() } /// This session pallet always calls new_session and next_session at the same time, hence we /// do a simple proxy and pass the function to next rotation. - fn estimate_next_new_session(now: T::BlockNumber) -> (Option, Weight) { + fn estimate_next_new_session(now: frame_system::pallet_prelude::BlockNumberFor::) -> (Option>, Weight) { T::NextSessionRotation::estimate_next_session_rotation(now) } } diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index fb5f3e0d54c88..e2cb27559a7bb 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -239,13 +239,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 6f42ae00f287d..7a446d1986baa 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -417,7 +417,7 @@ impl BidKind { } pub type PayoutsFor = BoundedVec< - (::BlockNumber, BalanceOf), + (frame_system::pallet_prelude::BlockNumberFor, BalanceOf), >::MaxPayouts, >; @@ -440,7 +440,7 @@ pub struct PayoutRecord { pub type PayoutRecordFor = PayoutRecord< BalanceOf, BoundedVec< - (::BlockNumber, BalanceOf), + (frame_system::pallet_prelude::BlockNumberFor, BalanceOf), >::MaxPayouts, >, >; @@ -491,7 +491,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness>; /// The maximum number of strikes before a member gets funds slashed. #[pallet::constant] @@ -504,23 +504,23 @@ pub mod pallet { /// The number of blocks on which new candidates should be voted on. Together with /// `ClaimPeriod`, this sums to the number of blocks between candidate intake periods. #[pallet::constant] - type VotingPeriod: Get; + type VotingPeriod: Get>; /// The number of blocks on which new candidates can claim their membership and be the /// named head. #[pallet::constant] - type ClaimPeriod: Get; + type ClaimPeriod: Get>; /// The maximum duration of the payout lock. #[pallet::constant] - type MaxLockDuration: Get; + type MaxLockDuration: Get>; /// The origin that is allowed to call `found`. type FounderSetOrigin: EnsureOrigin; /// The number of blocks between membership challenges. #[pallet::constant] - type ChallengePeriod: Get; + type ChallengePeriod: Get>; /// The maximum number of payouts a member may have waiting unclaimed. #[pallet::constant] @@ -758,7 +758,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let mut weight = Weight::zero(); let weights = T::BlockWeights::get(); @@ -1409,7 +1409,7 @@ pub enum Period { impl, I: 'static> Pallet { /// Get the period we are currently in. - fn period() -> Period { + fn period() -> Period> { let claim_period = T::ClaimPeriod::get(); let voting_period = T::VotingPeriod::get(); let rotation_period = voting_period + claim_period; @@ -1902,7 +1902,7 @@ impl, I: 'static> Pallet { candidate: &T::AccountId, value: BalanceOf, kind: BidKind>, - maturity: T::BlockNumber, + maturity: frame_system::pallet_prelude::BlockNumberFor::, ) { let value = match kind { BidKind::Deposit(deposit) => { @@ -1939,7 +1939,7 @@ impl, I: 'static> Pallet { /// /// It is the caller's duty to ensure that `who` is already a member. This does nothing if `who` /// is not a member or if `value` is zero. - fn bump_payout(who: &T::AccountId, when: T::BlockNumber, value: BalanceOf) { + fn bump_payout(who: &T::AccountId, when: frame_system::pallet_prelude::BlockNumberFor::, value: BalanceOf) { if value.is_zero() { return } @@ -2022,7 +2022,7 @@ impl, I: 'static> Pallet { /// /// This is a rather opaque calculation based on the formula here: /// https://www.desmos.com/calculator/9itkal1tce - fn lock_duration(x: u32) -> T::BlockNumber { + fn lock_duration(x: u32) -> frame_system::pallet_prelude::BlockNumberFor:: { let lock_pc = 100 - 50_000 / (x + 500); Percent::from_percent(lock_pc as u8) * T::MaxLockDuration::get() } diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index bd590f9b18770..4a4215fe3988b 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -161,7 +161,7 @@ pub(crate) mod old { Pallet, Twox64Concat, ::AccountId, - Vec<(::BlockNumber, BalanceOf)>, + Vec<(frame_system::pallet_prelude::BlockNumberFor, BalanceOf)>, ValueQuery, >; #[storage_alias] diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index a03968823f74f..184c1e905ebcd 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -66,13 +66,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 783580696d3ae..f394fb136d0d8 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -125,13 +125,12 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 44d5674f2f816..fd8a14afa7494 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1021,7 +1021,7 @@ impl ElectionDataProvider for Pallet { Ok(Self::get_npos_targets(None)) } - fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { + fn next_election_prediction(now: frame_system::pallet_prelude::BlockNumberFor::) -> frame_system::pallet_prelude::BlockNumberFor:: { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1038,7 +1038,7 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: T::BlockNumber = match ForceEra::::get() { + let sessions_left: frame_system::pallet_prelude::BlockNumberFor:: = match ForceEra::::get() { Forcing::ForceNone => Bounded::max_value(), Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), @@ -1237,7 +1237,7 @@ impl historical::SessionManager pallet_authorship::EventHandler for Pallet +impl pallet_authorship::EventHandler> for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index bff51312e7121..430eb2e352001 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -87,7 +87,7 @@ pub mod pallet { /// The staking balance. type Currency: LockableCurrency< Self::AccountId, - Moment = Self::BlockNumber, + Moment = frame_system::pallet_prelude::BlockNumberFor, Balance = Self::CurrencyBalance, >; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to @@ -118,14 +118,14 @@ pub mod pallet { /// Something that provides the election functionality. type ElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, // we only accept an election provider that has staking as data provider. DataProvider = Pallet, >; /// Something that provides the election functionality at genesis. type GenesisElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, DataProvider = Pallet, >; @@ -200,7 +200,7 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. - type NextNewSession: EstimateNextNewSession; + type NextNewSession: EstimateNextNewSession>; /// The maximum number of nominators rewarded for each validator. /// diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index f14f95193d8aa..cc3c792a2a7bf 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1094,7 +1094,7 @@ mod mock { type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = sp_runtime::generic::Header; + type Header = sp_runtime::generic::Header, BlakeTwo256>; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 447a53cace0a2..903d2e62c1253 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -57,12 +57,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 4c397ba361ecd..b519470199a61 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -117,12 +117,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index bde5b55148b4b..1e5af2dbfe899 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -854,7 +854,7 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// type RuntimeOrigin = RuntimeOrigin; /// type OnSetCode = (); /// type PalletInfo = PalletInfo; -/// type Header = Header; +/// type Block = Block; /// // We decide to override this one. /// type AccountData = pallet_balances::AccountData; /// } @@ -900,7 +900,7 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// type RuntimeOrigin = RuntimeOrigin; /// type OnSetCode = (); /// type PalletInfo = PalletInfo; -/// type Header = Header; +/// type Block = Block; /// type AccountData = pallet_balances::AccountData; /// type Version = ::Version; /// type BlockWeights = ::BlockWeights; @@ -1557,7 +1557,7 @@ pub fn unbounded(_: TokenStream, _: TokenStream) -> TokenStream { /// ```ignore /// #[pallet::storage] /// #[pallet::whitelist_storage] -/// pub(super) type Number = StorageValue<_, T::BlockNumber, ValueQuery>; +/// pub(super) type Number = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; /// ``` /// /// NOTE: As with all `pallet::*` attributes, this one _must_ be written as diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 9981e5ad65b78..6ecbdb368dc4c 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -865,7 +865,7 @@ impl PaysFee for (u64, Pays) { /// in your runtime. To use the default behavior, add `fn deposit_event() = default;` to your /// `Module`. /// -/// The following reserved functions also take the block number (with type `T::BlockNumber`) as an +/// The following reserved functions also take the block number (with type `frame_system::pallet_prelude::BlockNumberFor::`) as an /// optional input: /// /// * `on_runtime_upgrade`: Executes at the beginning of a block prior to on_initialize when there @@ -3280,12 +3280,12 @@ mod tests { #[weight = (5, DispatchClass::Operational)] fn operational(_origin) { unreachable!() } - fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_parts(7, 0) } - fn on_idle(n: T::BlockNumber, remaining_weight: Weight,) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_parts(7, 0) } + fn on_idle(n: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight,) -> Weight { if n.into() == 42 || remaining_weight == Weight::from_parts(42, 0) { panic!("on_idle") } Weight::from_parts(7, 0) } - fn on_finalize(n: T::BlockNumber,) { if n.into() == 42 { panic!("on_finalize") } } + fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::,) { if n.into() == 42 { panic!("on_finalize") } } fn on_runtime_upgrade() -> Weight { Weight::from_parts(10, 0) } fn offchain_worker() {} /// Some doc @@ -3665,10 +3665,6 @@ mod weight_tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } @@ -3682,8 +3678,7 @@ mod weight_tests { } impl Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; + type AccountId = AccountId; type Balance = Balance; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 0f2b135eed323..68741c24bab41 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -882,12 +882,12 @@ pub mod tests { #[pallet::storage] #[pallet::getter(fn generic_data)] pub type GenericData = - StorageMap<_, Identity, T::BlockNumber, T::BlockNumber, ValueQuery>; + StorageMap<_, Identity, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; #[pallet::storage] #[pallet::getter(fn generic_data2)] pub type GenericData2 = - StorageMap<_, Blake2_128Concat, T::BlockNumber, T::BlockNumber, OptionQuery>; + StorageMap<_, Blake2_128Concat, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; #[pallet::storage] pub type DataDM = @@ -897,10 +897,10 @@ pub mod tests { pub type GenericDataDM = StorageDoubleMap< _, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, Identity, - T::BlockNumber, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor::, ValueQuery, >; @@ -908,10 +908,10 @@ pub mod tests { pub type GenericData2DM = StorageDoubleMap< _, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, Twox64Concat, - T::BlockNumber, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor::, OptionQuery, >; @@ -922,7 +922,7 @@ pub mod tests { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, Vec, ValueQuery, >; @@ -964,18 +964,13 @@ pub mod tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } ); impl Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; + type AccountId = AccountId; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index 349f5de3ef3bc..77b76a40b891a 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -113,18 +113,13 @@ mod tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } ); impl self::frame_system::Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; + type AccountId = AccountId; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 4eaa657b1e486..4dfada28a4965 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -58,13 +58,12 @@ impl frame_system::Config for Runtime { type Index = u128; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; + type Block = Block; type Lookup = IdentityLookup; type BlockHashCount = ConstU64<2400>; type Version = Version; type AccountData = (); type RuntimeOrigin = RuntimeOrigin; - type BlockNumber = BlockNumber; type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; @@ -84,10 +83,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic(sp_std::marker::PhantomData); -impl frame_support::traits::Randomness +impl frame_support::traits::Randomness> for TestRandomness where T: frame_system::Config, { - fn random(subject: &[u8]) -> (Output, T::BlockNumber) { + fn random(subject: &[u8]) -> (Output, frame_system::pallet_prelude::BlockNumberFor::) { use sp_runtime::traits::TrailingZeroInput; ( diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index ff999e8d41687..1ca73d178090d 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -272,7 +272,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs index d43ebed01f17f..2fefe365bb8c9 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 7d32c73820e6b..5c5685f233c6b 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -54,7 +54,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 8129dd3656f0b..47f866aa810e8 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index c0cf1ce8bad4c..7f834ff9e6cb7 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index 483b1ab21b98b..936657366cc87 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 6165fc00107a3..b1acf0360ea27 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index a13218b748f87..cf980bc40fd8b 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 73257e5842a64..51899a84487b2 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -29,7 +29,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index f56a6c9fcaaa1..2810cd2f3f0b8 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -59,7 +59,7 @@ mod no_instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] - pub type TestGenericValue = StorageValue<_, T::BlockNumber, OptionQuery>; + pub type TestGenericValue = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap = StorageDoubleMap< @@ -67,7 +67,7 @@ mod no_instance { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, u32, ValueQuery, >; @@ -75,8 +75,8 @@ mod no_instance { #[pallet::genesis_config] pub struct GenesisConfig { pub value: u32, - pub test_generic_value: T::BlockNumber, - pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, + pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor::, + pub test_generic_double_map: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, u32)>, } impl Default for GenesisConfig { @@ -136,7 +136,7 @@ mod instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] pub type TestGenericValue, I: 'static = ()> = - StorageValue<_, T::BlockNumber, OptionQuery>; + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap, I: 'static = ()> = StorageDoubleMap< @@ -144,7 +144,7 @@ mod instance { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, u32, ValueQuery, >; @@ -152,8 +152,8 @@ mod instance { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: u32, - pub test_generic_value: T::BlockNumber, - pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, + pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor::, + pub test_generic_double_map: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, u32)>, pub phantom: PhantomData, } @@ -201,10 +201,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_support_test, FinalKeysNone: no_instance, @@ -214,7 +211,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 291b250c146b2..7c4de9363b8c3 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -39,11 +39,11 @@ pub mod pallet { #[pallet::storage] #[pallet::unbounded] pub type AppendableDM = - StorageDoubleMap<_, Identity, u32, Identity, T::BlockNumber, Vec>; + StorageDoubleMap<_, Identity, u32, Identity, frame_system::pallet_prelude::BlockNumberFor::, Vec>; #[pallet::genesis_config] pub struct GenesisConfig { - pub t: Vec<(u32, T::BlockNumber, Vec)>, + pub t: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, Vec)>, } impl Default for GenesisConfig { @@ -71,10 +71,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Test - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_support_test, MyPallet: pallet, @@ -82,7 +79,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for Test { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 555602771fa40..7f9a846f77138 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -77,7 +77,7 @@ mod module1 { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: >::GenericType, - pub test: ::BlockNumber, + pub test: frame_system::pallet_prelude::BlockNumberFor, } impl, I: 'static> Default for GenesisConfig { @@ -89,7 +89,7 @@ mod module1 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - T::BlockNumber: std::fmt::Display, + frame_system::pallet_prelude::BlockNumberFor::: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -123,7 +123,7 @@ mod module1 { #[pallet::inherent] impl, I: 'static> ProvideInherent for Pallet where - T::BlockNumber: From, + frame_system::pallet_prelude::BlockNumberFor::: From, { type Call = Call; type Error = MakeFatalError<()>; @@ -198,7 +198,7 @@ mod module2 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - T::BlockNumber: std::fmt::Display, + frame_system::pallet_prelude::BlockNumberFor::: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -301,7 +301,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 3822fea030d15..bb46e68a74cf2 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -28,7 +28,7 @@ mod module { use frame_support_test as frame_system; pub type Request = - (::AccountId, Role, ::BlockNumber); + (::AccountId, Role, frame_system::pallet_prelude::BlockNumberFor); pub type Requests = Vec>; #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -46,35 +46,35 @@ mod module { pub max_actors: u32, // payouts are made at this block interval - pub reward_period: T::BlockNumber, + pub reward_period: frame_system::pallet_prelude::BlockNumberFor::, // minimum amount of time before being able to unstake - pub bonding_period: T::BlockNumber, + pub bonding_period: frame_system::pallet_prelude::BlockNumberFor::, // how long tokens remain locked for after unstaking - pub unbonding_period: T::BlockNumber, + pub unbonding_period: frame_system::pallet_prelude::BlockNumberFor::, // minimum period required to be in service. unbonding before this time is highly penalized - pub min_service_period: T::BlockNumber, + pub min_service_period: frame_system::pallet_prelude::BlockNumberFor::, // "startup" time allowed for roles that need to sync their infrastructure // with other providers before they are considered in service and punishable for // not delivering required level of service. - pub startup_grace_period: T::BlockNumber, + pub startup_grace_period: frame_system::pallet_prelude::BlockNumberFor::, } impl Default for RoleParameters { fn default() -> Self { Self { max_actors: 10, - reward_period: T::BlockNumber::default(), - unbonding_period: T::BlockNumber::default(), + reward_period: frame_system::pallet_prelude::BlockNumberFor::::default(), + unbonding_period: frame_system::pallet_prelude::BlockNumberFor::::default(), // not currently used min_actors: 5, - bonding_period: T::BlockNumber::default(), - min_service_period: T::BlockNumber::default(), - startup_grace_period: T::BlockNumber::default(), + bonding_period: frame_system::pallet_prelude::BlockNumberFor::::default(), + min_service_period: frame_system::pallet_prelude::BlockNumberFor::::default(), + startup_grace_period: frame_system::pallet_prelude::BlockNumberFor::::default(), } } } @@ -115,7 +115,7 @@ mod module { /// tokens locked until given block number #[pallet::storage] #[pallet::getter(fn bondage)] - pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber>; + pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::>; /// First step before enter a role is registering intent with a new account/key. /// This is done by sending a role_entry_request() from the new account. @@ -160,7 +160,6 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; @@ -174,10 +173,7 @@ impl module::Config for Runtime {} frame_support::construct_runtime!( pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_support_test, Module: module, diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 0bfba2dcce1a1..c35b0fbe544f5 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -163,7 +163,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for RuntimeOriginTest { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = BaseCallFilter; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 7fcb2d1e05e7c..857450ef74ca5 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -655,7 +655,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 8afe1bbdf22ec..3bb89aebe9302 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -296,7 +296,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs index db7fe7cae7d1c..9de49dff7395d 100644 --- a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs +++ b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs index b51b1a14d2b46..d1a8fbf4e7e50 100644 --- a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs +++ b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs @@ -20,7 +20,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 9f9414a193e52..3c27badeb7d7e 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -43,7 +43,7 @@ impl frame_system::Config for Runtime { type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 3e306834869bb..43b0c34e35827 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -71,12 +71,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); @@ -95,10 +94,7 @@ impl Config for Runtime {} frame_support::construct_runtime!( pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_system, MyPallet: pallet, diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 5fc4ba7cca6d9..20dcd97d0f144 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -82,10 +82,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: frame_support_test, MyPallet: pallet, @@ -93,7 +90,6 @@ frame_support::construct_runtime!( ); impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 85b07abe3e48f..11313804a92f9 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -67,13 +67,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 8e8f061e1c2df..4c5eef517d96c 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -43,13 +43,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 6cb35dad8f1ba..c004d9e55afc2 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -94,12 +94,11 @@ impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<10>; type DbWeight = DbWeight; diff --git a/frame/tips/src/benchmarking.rs b/frame/tips/src/benchmarking.rs index 613f684afdf56..4a991b11b9331 100644 --- a/frame/tips/src/benchmarking.rs +++ b/frame/tips/src/benchmarking.rs @@ -78,7 +78,7 @@ fn create_tips, I: 'static>( } Tips::::mutate(hash, |maybe_tip| { if let Some(open_tip) = maybe_tip { - open_tip.closes = Some(T::BlockNumber::zero()); + open_tip.closes = Some(frame_system::pallet_prelude::BlockNumberFor::::zero()); } }); Ok(()) diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 970e2ac152c4b..bbf36faed1d21 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -143,7 +143,7 @@ pub mod pallet { /// The period for which a tip remains open after is has achieved threshold tippers. #[pallet::constant] - type TipCountdown: Get; + type TipCountdown: Get>; /// The percent of the final tip which goes to the original reporter of the tip. #[pallet::constant] @@ -173,7 +173,7 @@ pub mod pallet { _, Twox64Concat, T::Hash, - OpenTip, T::BlockNumber, T::Hash>, + OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, OptionQuery, >; @@ -470,7 +470,7 @@ impl, I: 'static> Pallet { /// /// `O(T)` and one storage access. fn insert_tip_and_check_closing( - tip: &mut OpenTip, T::BlockNumber, T::Hash>, + tip: &mut OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, tipper: T::AccountId, tip_value: BalanceOf, ) -> bool { @@ -515,7 +515,7 @@ impl, I: 'static> Pallet { /// Plus `O(T)` (`T` is Tippers length). fn payout_tip( hash: T::Hash, - tip: OpenTip, T::BlockNumber, T::Hash>, + tip: OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, ) { let mut tips = tip.tips; Self::retain_active_tips(&mut tips); @@ -577,7 +577,7 @@ impl, I: 'static> Pallet { for (hash, old_tip) in storage_key_iter::< T::Hash, - OldOpenTip, T::BlockNumber, T::Hash>, + OldOpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, Twox64Concat, >(module, item) .drain() diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index e718ee206e824..47f1d91e14a04 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -64,13 +64,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index 740915023a32d..6017fde196285 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -41,10 +41,7 @@ type AccountId = u64; frame_support::construct_runtime!( pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { System: system, Balances: pallet_balances, @@ -86,13 +83,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 1ea2dc9f33ebb..0f2440d2ad03f 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -408,7 +408,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(_: T::BlockNumber) { + fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor::) { >::mutate(|fm| { *fm = T::FeeMultiplierUpdate::convert(*fm); }); diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index c350ead2a74f0..1d62c9207d220 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -80,13 +80,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index dfea3331569f9..390e5925e39d6 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -113,7 +113,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { assert_eq!(event, &system_event); } -pub fn run_to_block(n: T::BlockNumber) { +pub fn run_to_block(n: frame_system::pallet_prelude::BlockNumberFor::) { while frame_system::Pallet::::block_number() < n { crate::Pallet::::on_finalize(frame_system::Pallet::::block_number()); frame_system::Pallet::::on_finalize(frame_system::Pallet::::block_number()); @@ -144,7 +144,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; run_to_block::(1u32.into()); - }: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0) + }: _(RawOrigin::Signed(caller.clone()), frame_system::pallet_prelude::BlockNumberFor::::zero(), 0) verify { assert_last_event::(Event::Renewed { index: 0 }.into()); } @@ -159,7 +159,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; } - run_to_block::(StoragePeriod::::get() + T::BlockNumber::one()); + run_to_block::(StoragePeriod::::get() + frame_system::pallet_prelude::BlockNumberFor::::one()); let encoded_proof = proof(); let proof = TransactionStorageProof::decode(&mut &*encoded_proof).unwrap(); }: check_proof(RawOrigin::None, proof) diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index b99bc49fc5b6f..b2928c1e188a3 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { // Drop obsolete roots. The proof for `obsolete` will be checked later // in this block, so we drop `obsolete` - 1. let period = >::get(); @@ -158,7 +158,7 @@ pub mod pallet { T::DbWeight::get().reads_writes(2, 4) } - fn on_finalize(n: T::BlockNumber) { + fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::) { assert!( >::take() || { // Proof is not required for early or empty blocks. @@ -238,7 +238,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::renew())] pub fn renew( origin: OriginFor, - block: T::BlockNumber, + block: frame_system::pallet_prelude::BlockNumberFor::, index: u32, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -342,7 +342,7 @@ pub mod pallet { pub(super) type Transactions = StorageMap< _, Blake2_128Concat, - T::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor::, BoundedVec, OptionQuery, >; @@ -350,7 +350,7 @@ pub mod pallet { /// Count indexed chunks for each block. #[pallet::storage] pub(super) type ChunkCount = - StorageMap<_, Blake2_128Concat, T::BlockNumber, u32, ValueQuery>; + StorageMap<_, Blake2_128Concat, frame_system::pallet_prelude::BlockNumberFor::, u32, ValueQuery>; #[pallet::storage] #[pallet::getter(fn byte_fee)] @@ -365,7 +365,7 @@ pub mod pallet { /// Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD` /// for block authoring. #[pallet::storage] - pub(super) type StoragePeriod = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type StoragePeriod = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; // Intermediates #[pallet::storage] @@ -380,7 +380,7 @@ pub mod pallet { pub struct GenesisConfig { pub byte_fee: BalanceOf, pub entry_fee: BalanceOf, - pub storage_period: T::BlockNumber, + pub storage_period: frame_system::pallet_prelude::BlockNumberFor::, } impl Default for GenesisConfig { diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 641e7a4148000..04c75f119c10d 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -51,12 +51,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index a3761083e4faa..449549d6c53b7 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -135,7 +135,7 @@ benchmarks_instance_pallet! { setup_pot_account::(); create_approved_proposals::(p)?; }: { - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); } impl_benchmark_test_suite!(Treasury, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 509ab933430bb..4ca5352faaa49 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -175,7 +175,7 @@ pub mod pallet { /// Period between successive spends. #[pallet::constant] - type SpendPeriod: Get; + type SpendPeriod: Get>; /// Percentage of spare funds (if any) that are burnt per spend period. #[pallet::constant] @@ -309,7 +309,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// ## Complexity /// - `O(A)` where `A` is the number of approvals - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { let pot = Self::pot(); let deactivated = Deactivated::::get(); if pot != deactivated { diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 1668344c87334..2d66ebfc7845d 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -58,13 +58,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 2cb200ffb139a..26dd84b554a49 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -49,12 +49,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 1de5deb44fee6..e249c2329e0db 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -153,13 +153,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 15be519842992..699e94237c970 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -55,7 +55,7 @@ fn add_vesting_schedules( let source_lookup = T::Lookup::unlookup(source.clone()); T::Currency::make_free_balance_be(&source, BalanceOf::::max_value()); - System::::set_block_number(T::BlockNumber::zero()); + System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::zero()); let mut total_locked: BalanceOf = Zero::zero(); for _ in 0..n { @@ -88,7 +88,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), @@ -144,7 +144,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(other_lookup.clone(), s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&other), Some(expected_balance), @@ -284,7 +284,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // Schedules are not vesting at block 0. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 8f98295dd385a..c737d61219474 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -127,8 +127,8 @@ impl VestingAction { /// Pick the schedules that this action dictates should continue vesting undisturbed. fn pick_schedules( &self, - schedules: Vec, T::BlockNumber>>, - ) -> impl Iterator, T::BlockNumber>> + '_ { + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, + ) -> impl Iterator, frame_system::pallet_prelude::BlockNumberFor::>> + '_ { schedules.into_iter().enumerate().filter_map(move |(index, schedule)| { if self.should_remove(index) { None @@ -162,7 +162,7 @@ pub mod pallet { type Currency: LockableCurrency; /// Convert the block number into a balance. - type BlockNumberToBalance: Convert>; + type BlockNumberToBalance: Convert, BalanceOf>; /// The minimum amount transferred to call `vested_transfer`. #[pallet::constant] @@ -201,7 +201,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - BoundedVec, T::BlockNumber>, MaxVestingSchedulesGet>, + BoundedVec, frame_system::pallet_prelude::BlockNumberFor::>, MaxVestingSchedulesGet>, >; /// Storage version of the pallet. @@ -216,7 +216,7 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { - pub vesting: Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, BalanceOf)>, + pub vesting: Vec<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, BalanceOf)>, } #[pallet::genesis_build] @@ -342,7 +342,7 @@ pub mod pallet { pub fn vested_transfer( origin: OriginFor, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; let transactor = ::unlookup(transactor); @@ -371,7 +371,7 @@ pub mod pallet { origin: OriginFor, source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, ) -> DispatchResult { ensure_root(origin)?; Self::do_vested_transfer(source, target, schedule) @@ -433,10 +433,10 @@ impl Pallet { // Create a new `VestingInfo`, based off of two other `VestingInfo`s. // NOTE: We assume both schedules have had funds unlocked up through the current block. fn merge_vesting_info( - now: T::BlockNumber, - schedule1: VestingInfo, T::BlockNumber>, - schedule2: VestingInfo, T::BlockNumber>, - ) -> Option, T::BlockNumber>> { + now: frame_system::pallet_prelude::BlockNumberFor::, + schedule1: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + schedule2: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + ) -> Option, frame_system::pallet_prelude::BlockNumberFor::>> { let schedule1_ending_block = schedule1.ending_block_as_balance::(); let schedule2_ending_block = schedule2.ending_block_as_balance::(); let now_as_balance = T::BlockNumberToBalance::convert(now); @@ -483,7 +483,7 @@ impl Pallet { fn do_vested_transfer( source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, ) -> DispatchResult { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); @@ -531,9 +531,9 @@ impl Pallet { /// /// NOTE: the amount locked does not include any schedules that are filtered out via `action`. fn report_schedule_updates( - schedules: Vec, T::BlockNumber>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, action: VestingAction, - ) -> (Vec, T::BlockNumber>>, BalanceOf) { + ) -> (Vec, frame_system::pallet_prelude::BlockNumberFor::>>, BalanceOf) { let now = >::block_number(); let mut total_locked_now: BalanceOf = Zero::zero(); @@ -570,10 +570,10 @@ impl Pallet { /// Write an accounts updated vesting schedules to storage. fn write_vesting( who: &T::AccountId, - schedules: Vec, T::BlockNumber>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, ) -> Result<(), DispatchError> { let schedules: BoundedVec< - VestingInfo, T::BlockNumber>, + VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, MaxVestingSchedulesGet, > = schedules.try_into().map_err(|_| Error::::AtMaxVestingSchedules)?; @@ -602,9 +602,9 @@ impl Pallet { /// Execute a `VestingAction` against the given `schedules`. Returns the updated schedules /// and locked amount. fn exec_action( - schedules: Vec, T::BlockNumber>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, action: VestingAction, - ) -> Result<(Vec, T::BlockNumber>>, BalanceOf), DispatchError> { + ) -> Result<(Vec, frame_system::pallet_prelude::BlockNumberFor::>>, BalanceOf), DispatchError> { let (schedules, locked_now) = match action { VestingAction::Merge { index1: idx1, index2: idx2 } => { // The schedule index is based off of the schedule ordering prior to filtering out @@ -649,7 +649,7 @@ where BalanceOf: MaybeSerializeDeserialize + Debug, { type Currency = T::Currency; - type Moment = T::BlockNumber; + type Moment = frame_system::pallet_prelude::BlockNumberFor::; /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { @@ -680,7 +680,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: T::BlockNumber, + starting_block: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { if locked.is_zero() { return Ok(()) @@ -713,7 +713,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: T::BlockNumber, + starting_block: frame_system::pallet_prelude::BlockNumberFor::, ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index 69bbc97296500..d4c6193901efb 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -40,12 +40,12 @@ pub mod v1 { pub fn migrate() -> Weight { let mut reads_writes = 0; - Vesting::::translate::, T::BlockNumber>, _>( + Vesting::::translate::, frame_system::pallet_prelude::BlockNumberFor::>, _>( |_key, vesting_info| { reads_writes += 1; let v: Option< BoundedVec< - VestingInfo, T::BlockNumber>, + VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, MaxVestingSchedulesGet, >, > = vec![vesting_info].try_into().ok(); diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index effa6c1da1c17..4451754d1d0b9 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -46,14 +46,13 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockHashCount = ConstU64<250>; type BlockLength = (); - type BlockNumber = u64; type BlockWeights = (); type RuntimeCall = RuntimeCall; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; + type Block = Block; type Index = u64; type Lookup = IdentityLookup; type OnKilledAccount = (); diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 2db6800c44301..8e68b25158350 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -53,13 +53,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 8d77439f16455..edfab69a41811 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -347,12 +347,11 @@ impl frame_system::pallet::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = H256; type Hashing = Hashing; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<2400>; type DbWeight = (); diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 431bcdab03288..32e5a3b76ac04 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -64,7 +64,7 @@ use sp_storage::{StorageData, StorageKey}; /// # type Hashing = BlakeTwo256; /// # type AccountId = u64; /// # type Lookup = IdentityLookup; -/// # type Header = Header; +/// # type Block = Block; /// # type RuntimeEvent = RuntimeEvent; /// # type BlockHashCount = (); /// # type DbWeight = (); From 6e3ae77290025548f0802e64ea149bbd3ee77fb1 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 17:35:46 +0530 Subject: [PATCH 13/67] Fixes errors in cargo check --- bin/node-template/runtime/src/lib.rs | 2 - frame/authorship/src/lib.rs | 1 - frame/benchmarking/pov/src/tests.rs | 1 - .../election-provider-multi-phase/src/mock.rs | 2 + .../election-provider-support/src/onchain.rs | 3 +- frame/examples/default-config/src/lib.rs | 3 ++ frame/examples/kitchensink/src/tests.rs | 2 + frame/executive/src/lib.rs | 3 +- frame/membership/src/lib.rs | 1 - frame/nicks/src/lib.rs | 1 - frame/state-trie-migration/src/lib.rs | 5 +-- frame/support/src/dispatch.rs | 15 +++++--- frame/support/src/lib.rs | 37 +++++++++++-------- frame/support/src/storage/generator/mod.rs | 10 ++++- .../number_of_pallets_exceeds_tuple_size.rs | 1 - .../pallet_error_too_large.rs | 1 - .../undefined_call_part.rs | 1 - .../undefined_event_part.rs | 1 - .../undefined_genesis_config_part.rs | 1 - .../undefined_inherent_part.rs | 1 - .../undefined_origin_part.rs | 1 - .../undefined_validate_unsigned_part.rs | 1 - frame/support/test/tests/pallet.rs | 1 - frame/support/test/tests/pallet_instance.rs | 1 - .../tests/pallet_ui/pass/dev_mode_valid.rs | 1 - .../pallet_ui/pass/no_std_genesis_config.rs | 1 - frame/support/test/tests/runtime_metadata.rs | 1 - frame/system/src/mocking.rs | 6 +++ primitives/runtime/src/testing.rs | 2 +- test-utils/runtime/src/lib.rs | 5 +-- utils/frame/rpc/support/src/lib.rs | 1 - 31 files changed, 59 insertions(+), 54 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 60dc11d37262f..7ae033cd64679 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -174,8 +174,6 @@ impl frame_system::Config for Runtime { type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. - type Header = generic::Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 8ba5875c800f3..7ceabaa3960ae 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -126,7 +126,6 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index a5f5fd08ea75d..b6e2fded05e3d 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -182,7 +182,6 @@ mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u32; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 2c01d501ec983..29cadaacd98ad 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -318,6 +318,7 @@ impl onchain::Config for OnChainSeqPhragmen { pub struct MockFallback; impl ElectionProviderBase for MockFallback { + type BlockNumber = BlockNumber; type AccountId = AccountId; type Error = &'static str; type DataProvider = StakingMock; @@ -431,6 +432,7 @@ pub struct ExtBuilder {} pub struct StakingMock; impl ElectionDataProvider for StakingMock { + type BlockNumber = BlockNumber; type AccountId = AccountId; type MaxVotesPerVoter = MaxNominations; diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index aa4ad7dc6586e..fda5b11073d10 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -266,7 +266,8 @@ mod tests { pub struct DataProvider; impl ElectionDataProvider for DataProvider { type AccountId = AccountId; - type MaxVotesPerVoter = ConstU32<2>; + type BlockNumber = BlockNumber; + type MaxVotesPerVoter = ConstU32<2>; fn electing_voters(_: Option) -> data_provider::Result>> { Ok(vec![ (1, 10, bounded_vec![10, 20]), diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index b978241704e04..7c5effc2e38ca 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -107,6 +107,7 @@ pub mod pallet { pub mod tests { use super::*; use frame_support::derive_impl; + use sp_runtime::traits::ConstU64; use super::pallet as pallet_default_config_example; @@ -126,6 +127,8 @@ pub mod tests { // these items are defined by frame-system as `no_default`, so we must specify them here. // Note that these are types that actually rely on the outer runtime, and can't sensibly // have an _independent_ default. + type Block = Block; + type BlockHashCount = ConstU64<10>; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index debc17d95d8ee..706d6315150bd 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -41,6 +41,8 @@ frame_support::construct_runtime!( #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 4a40f13616cf1..2f46ba269e62e 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -854,12 +854,11 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Index = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Block = Block; + type Block = TestBlock; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 1f8e729561f96..0e6226376bec7 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -557,7 +557,6 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index d3636403da924..ea9180802bfe3 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -262,7 +262,6 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index cc3c792a2a7bf..294e8b6b9669f 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1066,7 +1066,7 @@ mod mock { }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( @@ -1089,12 +1089,11 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u32; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = sp_runtime::generic::Header, BlakeTwo256>; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 6ecbdb368dc4c..d00a194221cd3 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -3280,12 +3280,12 @@ mod tests { #[weight = (5, DispatchClass::Operational)] fn operational(_origin) { unreachable!() } - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_parts(7, 0) } - fn on_idle(n: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight,) -> Weight { + fn on_initialize(n: T::BlockNumber,) -> Weight { if n.into() == 42 { panic!("on_initialize") } Weight::from_parts(7, 0) } + fn on_idle(n: T::BlockNumber, remaining_weight: Weight,) -> Weight { if n.into() == 42 || remaining_weight == Weight::from_parts(42, 0) { panic!("on_idle") } Weight::from_parts(7, 0) } - fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::,) { if n.into() == 42 { panic!("on_finalize") } } + fn on_finalize(n: T::BlockNumber,) { if n.into() == 42 { panic!("on_finalize") } } fn on_runtime_upgrade() -> Weight { Weight::from_parts(10, 0) } fn offchain_worker() {} /// Some doc @@ -3587,7 +3587,7 @@ mod weight_tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber: Parameter + Default + MaxEncodedLen; + type Block: Parameter + sp_runtime::traits::Block; type AccountId; type Balance; type BaseCallFilter: crate::traits::Contains; @@ -3653,6 +3653,10 @@ mod weight_tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -3678,7 +3682,8 @@ mod weight_tests { } impl Config for Runtime { - type AccountId = AccountId; + type Block = Block; + type AccountId = AccountId; type Balance = Balance; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 68741c24bab41..1f1064335b113 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -837,7 +837,7 @@ pub mod tests { use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; use sp_std::result; - pub use self::frame_system::{Config, Pallet}; + pub use self::frame_system::{Config, Pallet, pallet_prelude::*}; #[pallet] pub mod frame_system { @@ -852,7 +852,7 @@ pub mod tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber: Parameter + Default + MaxEncodedLen; + type Block: Parameter + sp_runtime::traits::Block; type AccountId; type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; @@ -882,12 +882,12 @@ pub mod tests { #[pallet::storage] #[pallet::getter(fn generic_data)] pub type GenericData = - StorageMap<_, Identity, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; + StorageMap<_, Identity, BlockNumberFor, BlockNumberFor, ValueQuery>; #[pallet::storage] #[pallet::getter(fn generic_data2)] pub type GenericData2 = - StorageMap<_, Blake2_128Concat, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; + StorageMap<_, Blake2_128Concat, BlockNumberFor, BlockNumberFor, OptionQuery>; #[pallet::storage] pub type DataDM = @@ -897,10 +897,10 @@ pub mod tests { pub type GenericDataDM = StorageDoubleMap< _, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + BlockNumberFor, Identity, - frame_system::pallet_prelude::BlockNumberFor::, - frame_system::pallet_prelude::BlockNumberFor::, + BlockNumberFor, + BlockNumberFor, ValueQuery, >; @@ -908,10 +908,10 @@ pub mod tests { pub type GenericData2DM = StorageDoubleMap< _, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + BlockNumberFor, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor::, - frame_system::pallet_prelude::BlockNumberFor::, + BlockNumberFor, + BlockNumberFor, OptionQuery, >; @@ -922,7 +922,7 @@ pub mod tests { Blake2_128Concat, u32, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + BlockNumberFor, Vec, ValueQuery, >; @@ -953,6 +953,10 @@ pub mod tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -970,7 +974,8 @@ pub mod tests { ); impl Config for Runtime { - type AccountId = AccountId; + type Block = Block; + type AccountId = AccountId; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; @@ -1000,8 +1005,8 @@ pub mod tests { type GenericData2 = StorageMap< System, Blake2_128Concat, - ::BlockNumber, - ::BlockNumber, + BlockNumberFor, + BlockNumberFor, >; assert_eq!(Pallet::::generic_data2(5), None); @@ -1013,8 +1018,8 @@ pub mod tests { pub type GenericData = StorageMap< Test2, Blake2_128Concat, - ::BlockNumber, - ::BlockNumber, + BlockNumberFor, + BlockNumberFor, >; }); } diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index 77b76a40b891a..a2f35359c95ec 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -58,7 +58,7 @@ mod tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber; + type Block: sp_runtime::traits::Block; type AccountId; type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; @@ -102,6 +102,11 @@ mod tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -119,7 +124,8 @@ mod tests { ); impl self::frame_system::Config for Runtime { - type AccountId = AccountId; + type AccountId = AccountId; + type Block = Block; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs index 2fefe365bb8c9..8bd9d9c89e528 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 5c5685f233c6b..b97af084c26ef 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -48,7 +48,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 47f866aa810e8..8d94f18546a21 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 7f834ff9e6cb7..e5bb5fb486cb3 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index 936657366cc87..b6bc408043fbf 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index b1acf0360ea27..4fb6382c93ffa 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index cf980bc40fd8b..997c32c95055e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 51899a84487b2..f97eee993701b 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -23,7 +23,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 857450ef74ca5..1aeacbaa481f4 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -649,7 +649,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 3bb89aebe9302..d5d5982dd6d79 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -290,7 +290,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs index 9de49dff7395d..516aa1e131aca 100644 --- a/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs +++ b/frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs @@ -61,7 +61,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs index d1a8fbf4e7e50..8f28e4a9b28a7 100644 --- a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs +++ b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs @@ -14,7 +14,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 3c27badeb7d7e..44c375a9a674f 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -37,7 +37,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index b02a1b1d683dd..0406805697e8f 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -32,3 +32,9 @@ pub type MockBlock = generic::Block< generic::Header, MockUncheckedExtrinsic, >; + +/// An implementation of `sp_runtime::traits::Block` to be used in tests with u32 BlockNumber type. +pub type MockBlockU32 = generic::Block< + generic::Header, + MockUncheckedExtrinsic, +>; \ No newline at end of file diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index bc9675fe0561e..94ae3d99a7774 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -235,7 +235,7 @@ impl Deref for ExtrinsicWrapper { } /// Testing block -#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode)] +#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode, TypeInfo)] pub struct Block { /// Block header pub header: Header, diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index edfab69a41811..9911caddc967c 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -291,10 +291,7 @@ impl sp_runtime::traits::SignedExtension for CheckSubstrateCall { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = Extrinsic + pub enum Runtime { System: frame_system, Babe: pallet_babe, diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 32e5a3b76ac04..33627aca3a3e1 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -59,7 +59,6 @@ use sp_storage::{StorageData, StorageKey}; /// # type RuntimeOrigin = RuntimeOrigin; /// # type RuntimeCall = RuntimeCall; /// # type Index = u64; -/// # type BlockNumber = u64; /// # type Hash = Hash; /// # type Hashing = BlakeTwo256; /// # type AccountId = u64; From 4de134cc0407d797cff11aea1df140faeb9e0cc2 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 17:47:59 +0530 Subject: [PATCH 14/67] Fixes errors in cargo check --- frame/asset-conversion/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 68a0210b40058..4efdb70c4aa85 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -357,7 +357,7 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks for Pallet { + impl Hooks> for Pallet { fn integrity_test() { assert!( T::MaxSwapPathLength::get() > 1, From 884ceafe03d6019e5936c65a3dc9e19960cf9fa0 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 21:18:35 +0530 Subject: [PATCH 15/67] Fixes warnings in cargo check --- bin/node-template/pallets/template/src/mock.rs | 5 ++--- frame/alliance/src/mock.rs | 5 ++--- frame/asset-conversion/src/mock.rs | 5 ++--- frame/asset-rate/src/mock.rs | 5 ++--- frame/assets/src/mock.rs | 5 ++--- frame/atomic-swap/src/tests.rs | 5 ++--- frame/aura/src/mock.rs | 4 ++-- frame/authority-discovery/src/lib.rs | 4 ++-- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/bags-list/src/mock.rs | 2 +- frame/balances/src/tests/mod.rs | 5 ++--- frame/beefy-mmr/src/mock.rs | 5 ++--- frame/beefy/src/mock.rs | 4 ++-- frame/benchmarking/pov/src/benchmarking.rs | 2 +- frame/benchmarking/pov/src/tests.rs | 2 +- frame/benchmarking/src/baseline.rs | 2 +- frame/benchmarking/src/tests.rs | 4 ++-- frame/benchmarking/src/tests_instance.rs | 4 ++-- frame/bounties/src/tests.rs | 5 ++--- frame/child-bounties/src/tests.rs | 5 ++--- frame/contracts/src/tests.rs | 4 ++-- frame/conviction-voting/src/tests.rs | 5 ++--- frame/core-fellowship/src/tests.rs | 5 ++--- frame/democracy/src/tests.rs | 5 ++--- .../test-staking-e2e/src/mock.rs | 2 +- frame/examples/basic/src/tests.rs | 5 ++--- frame/examples/default-config/src/lib.rs | 2 +- frame/examples/dev-mode/src/tests.rs | 5 ++--- frame/examples/kitchensink/src/tests.rs | 2 +- frame/examples/offchain-worker/src/tests.rs | 4 ++-- frame/executive/src/lib.rs | 6 +----- frame/fast-unstake/src/mock.rs | 2 +- frame/glutton/src/mock.rs | 5 ++--- frame/grandpa/src/mock.rs | 4 ++-- frame/identity/src/tests.rs | 5 ++--- frame/im-online/src/mock.rs | 4 ++-- frame/indices/src/mock.rs | 2 -- .../insecure-randomness-collective-flip/src/lib.rs | 5 ++--- frame/lottery/src/mock.rs | 5 ++--- frame/membership/src/lib.rs | 5 ++--- frame/merkle-mountain-range/src/mock.rs | 5 ++--- frame/message-queue/src/integration_test.rs | 5 ++--- frame/message-queue/src/mock.rs | 5 ++--- frame/multisig/src/tests.rs | 5 ++--- frame/nft-fractionalization/src/mock.rs | 5 ++--- frame/nfts/src/mock.rs | 5 ++--- frame/nicks/src/lib.rs | 5 ++--- frame/nis/src/mock.rs | 5 ++--- frame/node-authorization/src/mock.rs | 5 ++--- frame/nomination-pools/benchmarking/src/mock.rs | 2 +- frame/nomination-pools/src/mock.rs | 2 +- frame/nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/offences/src/mock.rs | 5 ++--- frame/preimage/src/mock.rs | 5 ++--- frame/proxy/src/tests.rs | 5 ++--- frame/ranked-collective/src/tests.rs | 5 ++--- frame/recovery/src/mock.rs | 5 ++--- frame/referenda/src/mock.rs | 5 ++--- frame/remark/src/mock.rs | 5 ++--- frame/root-offences/src/mock.rs | 4 ++-- frame/salary/src/tests.rs | 5 ++--- frame/scheduler/src/mock.rs | 5 ++--- frame/scored-pool/src/mock.rs | 5 ++--- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 4 ++-- frame/society/src/mock.rs | 5 ++--- frame/staking/src/mock.rs | 4 ++-- frame/state-trie-migration/src/lib.rs | 2 +- frame/statement/src/mock.rs | 5 ++--- frame/sudo/src/mock.rs | 5 ++--- frame/system/benches/bench.rs | 5 ++--- frame/system/benchmarking/src/mock.rs | 3 +-- frame/system/src/mock.rs | 4 +--- frame/tips/src/tests.rs | 5 ++--- .../asset-conversion-tx-payment/src/mock.rs | 13 ++++--------- .../asset-tx-payment/src/mock.rs | 5 ++--- frame/transaction-payment/src/mock.rs | 5 ++--- frame/transaction-storage/src/mock.rs | 5 ++--- frame/treasury/src/tests.rs | 5 ++--- frame/uniques/src/mock.rs | 5 ++--- frame/utility/src/tests.rs | 5 ++--- frame/vesting/src/mock.rs | 5 ++--- frame/whitelist/src/mock.rs | 5 ++--- 85 files changed, 151 insertions(+), 217 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 30cf45cf6e4f5..55f6b3dd47ef4 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -2,11 +2,10 @@ use crate as pallet_template; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index e79f70685e561..460bf5211daca 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -20,8 +20,7 @@ pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; use sp_std::convert::{TryFrom, TryInto}; @@ -237,7 +236,7 @@ impl Config for Test { type RetirementPeriod = RetirementPeriod; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index ac5e4b281f439..0a8a66f9be167 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -31,11 +31,10 @@ use frame_system::{EnsureSigned, EnsureSignedBy}; use sp_arithmetic::Permill; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, + traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index a97cbbc3011d5..f7669a2495c0f 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -21,11 +21,10 @@ use crate as pallet_asset_rate; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 182a4c6882f70..231e368e56126 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -28,11 +28,10 @@ use frame_support::{ use sp_core::H256; use sp_io::storage; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 53a6671449153..846f4b4d33fde 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -6,11 +6,10 @@ use crate as pallet_atomic_swap; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 90908262b5785..e17c058ec40f4 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -27,11 +27,11 @@ use frame_support::{ use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; use sp_runtime::{ - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::IdentityLookup, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 1d0597d42b869..302b634a5a885 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -175,12 +175,12 @@ mod tests { use sp_core::{crypto::key_types, H256}; use sp_io::TestExternalities; use sp_runtime::{ - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, KeyTypeId, Perbill, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 7ceabaa3960ae..24ec8d76f1082 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -108,7 +108,7 @@ mod tests { traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 9b4bd390c47f0..57c92a72a588f 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -42,7 +42,7 @@ use sp_staking::{EraIndex, SessionIndex}; type DummyValidatorId = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 2f4755af057a9..a8831272a7e90 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -85,7 +85,7 @@ impl bags_list::Config for Runtime { type Score = VoteWeight; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index c521c5a240743..7ddaec998f035 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -38,8 +38,7 @@ use scale_info::TypeInfo; use sp_core::{hexdisplay::HexDisplay, H256}; use sp_io; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, + traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError, }; use std::collections::BTreeSet; @@ -50,7 +49,7 @@ mod fungible_conformance_tests; mod fungible_tests; mod reentrancy_tests; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; #[derive( diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index e9a6aeec406ba..cda4fa697cbc2 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -29,8 +29,7 @@ use sp_core::H256; use sp_runtime::{ app_crypto::ecdsa::Public, impl_opaque_keys, - testing::Header, - traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, + traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, }; use crate as pallet_beefy_mmr; @@ -45,7 +44,7 @@ impl_opaque_keys! { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 9e7d322a37168..c9eb7174cb6a9 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -32,7 +32,7 @@ use sp_runtime::{ app_crypto::ecdsa::Public, curve::PiecewiseLinear, impl_opaque_keys, - testing::{Header, TestXt}, + testing::{TestXt}, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, Perbill, }; @@ -51,7 +51,7 @@ impl_opaque_keys! { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 7a7ccdc0a63d3..85e898083359e 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -345,7 +345,7 @@ mod mock { type AccountIndex = u32; type BlockNumber = u64; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index b6e2fded05e3d..061b8c09ea0cb 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -164,7 +164,7 @@ fn noop_is_free() { mod mock { use sp_runtime::testing::H256; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 8d0bdfe5abbaa..f6630836b7deb 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -117,7 +117,7 @@ pub mod mock { type AccountIndex = u32; type BlockNumber = u64; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 57e2cb4a62070..62bd3c509f628 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::{parameter_types, traits::ConstU32}; use sp_runtime::{ - testing::{Header, H256}, + testing::{H256}, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -66,7 +66,7 @@ mod pallet_test { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index ebfac7a0a8dbc..cd11e95c9446f 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::traits::ConstU32; use sp_runtime::{ - testing::{Header, H256}, + testing::{H256}, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -76,7 +76,7 @@ mod pallet_test { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index e285755125c75..d66c3f462a53e 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -32,14 +32,13 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Storage, }; use super::Event as BountiesEvent; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index a8cdd7b07740b..2a10ebcc332de 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -33,14 +33,13 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, Perbill, Permill, TokenError, }; use super::Event as ChildBountiesEvent; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type BountiesError = pallet_bounties::Error; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index dbfc81b0adf13..8c9c7f8bc08ac 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -50,13 +50,13 @@ use sp_core::ByteArray; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - testing::{Header, H256}, + testing::{H256}, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, AccountId32, TokenError, }; use std::ops::Deref; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index a3a0ce782f7e7..976aaa0e1f66f 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -25,14 +25,13 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; use super::*; use crate as pallet_conviction_voting; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 708630c803f5c..544048eb084c3 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -28,8 +28,7 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, + traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, DispatchError, DispatchResult, }; use sp_std::cell::RefCell; @@ -37,7 +36,7 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_core_fellowship; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 54fdfeaa43c66..79d02c85ffefa 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -31,8 +31,7 @@ use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy}; use pallet_balances::{BalanceLock, Error as BalancesError}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, Perbill, }; mod cancellation; @@ -51,7 +50,7 @@ const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; const BIG_AYE: Vote = Vote { aye: true, conviction: Conviction::Locked1x }; const BIG_NAY: Vote = Vote { aye: false, conviction: Conviction::Locked1x }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( 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 71eada1a44668..b9a8db5da806b 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 @@ -50,7 +50,7 @@ pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Extrinsic = testing::TestXt; frame_support::construct_runtime!( diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 5a846427d6a7b..b3976b3b2c056 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -27,14 +27,13 @@ use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_basic; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 7c5effc2e38ca..577af5489cda3 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -111,7 +111,7 @@ pub mod tests { use super::pallet as pallet_default_config_example; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index d7db1003d51bc..4f26ba11e5a1a 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -21,14 +21,13 @@ use crate::*; use frame_support::{assert_ok, traits::ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_dev_mode; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index 706d6315150bd..95389f6dfa457 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -23,7 +23,7 @@ use sp_runtime::BuildStorage; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_kitchensink; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 665fe0612710c..3f61491d3683f 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -30,12 +30,12 @@ use sp_core::{ use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ - testing::{Header, TestXt}, + testing::{TestXt}, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, RuntimeAppPublic, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; // For testing the module, we construct a mock runtime. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 946dec1537135..f7dfebd1a9f8a 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -828,10 +828,7 @@ mod tests { } frame_support::construct_runtime!( - pub struct Runtime where - Block = TestBlock, - NodeBlock = TestBlock, - UncheckedExtrinsic = TestUncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -928,7 +925,6 @@ mod tests { ); type TestXt = sp_runtime::testing::TestXt; type TestBlock = Block; - type TestUncheckedExtrinsic = TestXt; // Will contain `true` when the custom runtime logic was called. const CUSTOM_ON_RUNTIME_KEY: &[u8] = b":custom:on_runtime"; diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index d29143cfb7fa8..29b9c0405c2e1 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -194,7 +194,7 @@ impl fast_unstake::Config for Runtime { } type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index d4775947b52cc..dc290a727d22f 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -24,11 +24,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index c0c1f43c90a89..17247804d52fe 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -36,13 +36,13 @@ use sp_keyring::Ed25519Keyring; use sp_runtime::{ curve::PiecewiseLinear, impl_opaque_keys, - testing::{Header, TestXt, UintAuthorityId}, + testing::{TestXt, UintAuthorityId}, traits::{IdentityLookup, OpaqueKeys}, DigestItem, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index bd3a1d9edb3cf..730d2417de170 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -29,11 +29,10 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index dae4ac1f05ac9..10fcf0aef796b 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -27,7 +27,7 @@ use frame_support::{ use pallet_session::historical as pallet_session_historical; use sp_core::H256; use sp_runtime::{ - testing::{Header, TestXt, UintAuthorityId}, + testing::{TestXt, UintAuthorityId}, traits::{BlakeTwo256, ConvertInto, IdentityLookup}, Permill, }; @@ -39,7 +39,7 @@ use sp_staking::{ use crate as imonline; use crate::Config; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 708181f4890a6..52e6d7d836be6 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -22,9 +22,7 @@ use crate::{self as pallet_indices, Config}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; -use sp_runtime::testing::Header; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 44395849cc1dd..7667520f7c09d 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -164,8 +164,7 @@ mod tests { use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Header as _, IdentityLookup}, + traits::{BlakeTwo256, Header as _, IdentityLookup}, }; use frame_support::{ @@ -174,7 +173,7 @@ mod tests { }; use frame_system::limits; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 75fcb54690329..65ec39af371a1 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -28,12 +28,11 @@ use frame_support_test::TestRandomness; use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 0e6226376bec7..e17007d68760e 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -524,8 +524,7 @@ mod tests { use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, }; use frame_support::{ @@ -534,7 +533,7 @@ mod tests { }; use frame_system::EnsureSignedBy; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index cb62bc201cf0b..cafe23ed94330 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -26,11 +26,10 @@ use frame_support::{ use sp_core::H256; use sp_mmr_primitives::{Compact, LeafDataProvider}; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup, Keccak256}, + traits::{BlakeTwo256, IdentityLookup, Keccak256}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index 98d70653a65fa..df399f9c46eeb 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -38,12 +38,11 @@ use rand::{rngs::StdRng, Rng, SeedableRng}; use rand_distr::Pareto; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; use std::collections::{BTreeMap, BTreeSet}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index 2a0632041f61c..a0f4c7c9a17ab 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -29,12 +29,11 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; use sp_std::collections::btree_map::BTreeMap; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 901c7724475c8..0d542b566a215 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -28,12 +28,11 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, TokenError, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 208fd1e6f32d0..1781a6592f0bf 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -29,12 +29,11 @@ use frame_system::EnsureSigned; use pallet_nfts::PalletFeatures; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, MultiSignature, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type Signature = MultiSignature; type AccountPublic = ::Signer; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 987601d1f601c..250c597b8ce2e 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -27,12 +27,11 @@ use frame_support::{ use sp_core::H256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, MultiSignature, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index ea9180802bfe3..f78a5bbd575d9 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -239,11 +239,10 @@ mod tests { use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index e36e67dab5ec7..e24ebf3f6673b 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -31,11 +31,10 @@ use frame_support::{ use pallet_balances::{Instance1, Instance2}; use sp_core::{ConstU128, H256}; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; pub type Balance = u64; diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index b4c48fc1137f0..2142afbc0c8ab 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -27,11 +27,10 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index eb69ed1989e02..7f7703c795b25 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -174,7 +174,7 @@ impl pallet_nomination_pools::Config for Runtime { impl crate::Config for Runtime {} type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + frame_support::construct_runtime!( pub struct Runtime { diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 4723a484b2f0c..55083e1833391 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -244,7 +244,7 @@ impl pools::Config for Runtime { type MaxPointsToBalance = frame_support::traits::ConstU8<10>; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 453e667a54ce2..676919f3de1d1 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -186,7 +186,7 @@ impl pallet_nomination_pools::Config for Runtime { } type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index a1ff758caf01a..9261cd16d170e 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -28,7 +28,7 @@ use frame_support::{ use frame_system as system; use pallet_session::historical as pallet_session_historical; use sp_runtime::{ - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::IdentityLookup, }; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index d843e7640810d..a02aaaf635675 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -29,8 +29,7 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; use sp_staking::{ @@ -66,7 +65,7 @@ pub fn with_on_offence_fractions) -> R>(f: F) -> OnOffencePerbill::mutate(|fractions| f(fractions)) } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 6917c9b8494d1..2fe795b108765 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -28,11 +28,10 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index b9f61c4780458..fa50486e0e0e8 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -31,11 +31,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 347a993706ea4..14e6266c7d42d 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -27,14 +27,13 @@ use frame_support::{ }; use sp_core::{Get, H256}; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup, ReduceBy}, + traits::{BlakeTwo256, IdentityLookup, ReduceBy}, }; use super::*; use crate as pallet_ranked_collective; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type Class = Rank; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index e77932de1491a..cf23462b69fa0 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -26,11 +26,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index e2d94a0ce9603..2965f2c8e7a34 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -31,12 +31,11 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Hash, IdentityLookup}, + traits::{BlakeTwo256, Hash, IdentityLookup}, DispatchResult, Perbill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index d912b6f7758cc..9111dcf0155a6 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -21,12 +21,11 @@ use crate as pallet_remark; use frame_support::traits::{ConstU16, ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 4cca2cbe76391..d71a31c03ee9b 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -27,13 +27,13 @@ use pallet_staking::StakerStatus; use sp_core::H256; use sp_runtime::{ curve::PiecewiseLinear, - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::{BlakeTwo256, IdentityLookup, Zero}, }; use sp_staking::{EraIndex, SessionIndex}; use sp_std::collections::btree_map::BTreeMap; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type AccountId = u64; type Balance = u64; diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 9e5f63afa121f..fed65d9767f07 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -27,8 +27,7 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Identity, IdentityLookup}, + traits::{BlakeTwo256, Identity, IdentityLookup}, DispatchResult, }; use sp_std::cell::RefCell; @@ -36,7 +35,7 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_salary; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 86c58fdd6b876..88872ab7c73a0 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -30,8 +30,7 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; @@ -93,7 +92,7 @@ pub mod logger { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 78b82dd60cff3..16d6b36dff38c 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -27,11 +27,10 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 6f546c7e4461b..711639effb697 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -31,7 +31,7 @@ type AccountIndex = u32; type BlockNumber = u64; type Balance = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index e2cb27559a7bb..201e1719145ce 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -27,7 +27,7 @@ use std::collections::BTreeMap; use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::{BlakeTwo256, IdentityLookup}, }; use sp_staking::SessionIndex; @@ -75,7 +75,7 @@ impl OpaqueKeys for PreUpgradeMockSessionKeys { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; #[cfg(feature = "historical")] diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 184c1e905ebcd..3081b66fa229b 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -28,13 +28,12 @@ use frame_support_test::TestRandomness; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; use RuntimeOrigin as Origin; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index f394fb136d0d8..23bbf950b6442 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -32,7 +32,7 @@ use sp_core::H256; use sp_io; use sp_runtime::{ curve::PiecewiseLinear, - testing::{Header, UintAuthorityId}, + testing::{UintAuthorityId}, traits::{IdentityLookup, Zero}, }; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; @@ -82,7 +82,7 @@ pub fn is_disabled(controller: AccountId) -> bool { Session::disabled_validators().contains(&validator_index) } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 294e8b6b9669f..17329de13464b 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1065,7 +1065,7 @@ mod mock { StorageChild, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlockU32; // Configure a mock runtime to test the pallet. diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 903d2e62c1253..f8d89db808ad3 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -27,12 +27,11 @@ use frame_support::{ }; use sp_core::{Pair, H256}; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, AccountId32, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; pub const MIN_ALLOWED_STATEMENTS: u32 = 4; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index b519470199a61..464f6f0d1d109 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -23,8 +23,7 @@ use frame_support::traits::{ConstU32, ConstU64, Contains, GenesisBuild}; use sp_core::H256; use sp_io; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; // Logger module to track execution. @@ -90,7 +89,7 @@ pub mod logger { pub(super) type I32Log = StorageValue<_, BoundedVec>, ValueQuery>; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 11313804a92f9..04e3b44f534ab 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -19,8 +19,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; @@ -43,7 +42,7 @@ mod module { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 4c5eef517d96c..75fb7af450689 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -24,9 +24,8 @@ use sp_runtime::traits::IdentityLookup; type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index c004d9e55afc2..b8325657f293e 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -22,12 +22,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; -type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; type Block = mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 47f1d91e14a04..2c8e60fdb10ed 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -21,8 +21,7 @@ use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Permill, }; use sp_storage::Storage; @@ -39,7 +38,7 @@ use frame_support::{ use super::*; use crate::{self as pallet_tips, Event as TipEvent}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs index 6e05ec6163ddb..6c74e0d4bf030 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -33,21 +33,17 @@ use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion}, + traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion}, Permill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: system, Balances: pallet_balances, @@ -90,13 +86,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index 6017fde196285..11284e2669499 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -30,11 +30,10 @@ use frame_system::EnsureRoot; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}, + traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 1d62c9207d220..35bec09bdb77b 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -20,8 +20,7 @@ use crate as pallet_transaction_payment; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; use frame_support::{ @@ -33,7 +32,7 @@ use frame_support::{ use frame_system as system; use pallet_balances::Call as BalancesCall; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 04c75f119c10d..123fc4430b6e3 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -24,12 +24,11 @@ use crate::{ use frame_support::traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 2d66ebfc7845d..06d5660f10b3d 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -21,8 +21,7 @@ use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}, }; use frame_support::{ @@ -36,7 +35,7 @@ use frame_support::{ use super::*; use crate as treasury; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; type UtilityCall = pallet_utility::Call; type TreasuryCall = crate::Call; diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 26dd84b554a49..22b06d99243ac 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -26,11 +26,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index e249c2329e0db..6d93c80129ba6 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -33,8 +33,7 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Hash, IdentityLookup}, + traits::{BlakeTwo256, Hash, IdentityLookup}, TokenError, }; @@ -125,7 +124,7 @@ mod mock_democracy { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 4451754d1d0b9..c3643877c6a0e 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -21,14 +21,13 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Identity, IdentityLookup}, + traits::{BlakeTwo256, Identity, IdentityLookup}, }; use super::*; use crate as pallet_vesting; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 8e68b25158350..1226befdbd676 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -28,12 +28,11 @@ use frame_support::{ use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; construct_runtime!( From 211138e32d3169114095a4c5b9bf556afbeeee47 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Sun, 25 Jun 2023 21:19:41 +0530 Subject: [PATCH 16/67] Formatting --- .../pallets/template/src/mock.rs | 7 +- bin/node-template/runtime/src/lib.rs | 3 +- frame/alliance/src/lib.rs | 9 +- frame/alliance/src/mock.rs | 3 +- frame/asset-conversion/src/mock.rs | 5 +- frame/asset-rate/src/mock.rs | 5 +- frame/assets/src/mock.rs | 5 +- frame/atomic-swap/src/lib.rs | 4 +- frame/atomic-swap/src/tests.rs | 5 +- frame/aura/src/lib.rs | 2 +- frame/aura/src/mock.rs | 6 +- frame/authority-discovery/src/lib.rs | 5 +- frame/authorship/src/lib.rs | 10 +- frame/babe/src/equivocation.rs | 6 +- frame/babe/src/lib.rs | 61 ++++-- frame/babe/src/mock.rs | 1 - frame/babe/src/randomness.rs | 28 ++- frame/bags-list/src/mock.rs | 1 - frame/balances/src/impl_currency.rs | 2 +- frame/balances/src/lib.rs | 4 +- frame/balances/src/tests/mod.rs | 3 +- frame/beefy-mmr/src/mock.rs | 3 +- frame/beefy/src/equivocation.rs | 5 +- frame/beefy/src/mock.rs | 3 +- frame/benchmarking/pov/src/benchmarking.rs | 3 +- frame/benchmarking/pov/src/tests.rs | 1 - frame/benchmarking/src/baseline.rs | 3 +- frame/benchmarking/src/tests.rs | 3 +- frame/benchmarking/src/tests_instance.rs | 3 +- frame/bounties/src/lib.rs | 2 +- frame/bounties/src/tests.rs | 3 +- frame/child-bounties/src/lib.rs | 4 +- frame/child-bounties/src/tests.rs | 3 +- frame/collective/src/lib.rs | 9 +- frame/contracts/src/exec.rs | 4 +- frame/contracts/src/lib.rs | 5 +- frame/contracts/src/tests.rs | 3 +- frame/conviction-voting/src/lib.rs | 6 +- frame/conviction-voting/src/tests.rs | 5 +- frame/core-fellowship/src/benchmarking.rs | 8 +- frame/core-fellowship/src/lib.rs | 7 +- frame/core-fellowship/src/tests.rs | 3 +- frame/democracy/src/lib.rs | 119 +++++++--- frame/democracy/src/migrations/v1.rs | 7 +- frame/democracy/src/tests.rs | 3 +- .../election-provider-multi-phase/src/lib.rs | 23 +- .../src/signed.rs | 2 +- .../src/unsigned.rs | 6 +- .../election-provider-support/src/onchain.rs | 2 +- frame/elections-phragmen/src/lib.rs | 12 +- frame/examples/basic/src/lib.rs | 6 +- frame/examples/basic/src/tests.rs | 3 +- frame/examples/default-config/src/lib.rs | 6 +- frame/examples/dev-mode/src/tests.rs | 3 +- frame/examples/kitchensink/src/lib.rs | 19 +- frame/examples/kitchensink/src/tests.rs | 1 - frame/examples/offchain-worker/src/lib.rs | 60 +++-- frame/examples/offchain-worker/src/tests.rs | 3 +- frame/executive/src/lib.rs | 63 ++++-- frame/fast-unstake/src/lib.rs | 11 +- frame/fast-unstake/src/mock.rs | 4 +- frame/glutton/src/mock.rs | 5 +- frame/grandpa/src/equivocation.rs | 20 +- frame/grandpa/src/lib.rs | 71 ++++-- frame/grandpa/src/mock.rs | 1 - frame/identity/src/tests.rs | 5 +- frame/im-online/src/benchmarking.rs | 5 +- frame/im-online/src/lib.rs | 23 +- frame/im-online/src/mock.rs | 1 - .../src/lib.rs | 15 +- frame/lottery/src/lib.rs | 12 +- frame/lottery/src/mock.rs | 3 +- frame/membership/src/lib.rs | 5 +- frame/merkle-mountain-range/src/lib.rs | 25 ++- frame/merkle-mountain-range/src/mock.rs | 5 +- frame/message-queue/src/integration_test.rs | 5 +- frame/message-queue/src/mock.rs | 5 +- frame/multisig/src/lib.rs | 23 +- frame/multisig/src/tests.rs | 3 +- .../nft-fractionalization/src/benchmarking.rs | 10 +- frame/nft-fractionalization/src/mock.rs | 3 +- frame/nfts/src/mock.rs | 3 +- frame/nicks/src/lib.rs | 5 +- frame/nis/src/lib.rs | 11 +- frame/nis/src/mock.rs | 5 +- frame/node-authorization/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 7 +- frame/nomination-pools/src/lib.rs | 15 +- frame/nomination-pools/src/mock.rs | 1 - .../nomination-pools/test-staking/src/mock.rs | 1 - frame/offences/benchmarking/src/mock.rs | 5 +- frame/offences/src/mock.rs | 3 +- frame/preimage/src/mock.rs | 5 +- frame/proxy/src/lib.rs | 66 ++++-- frame/proxy/src/tests.rs | 5 +- frame/ranked-collective/src/lib.rs | 6 +- frame/ranked-collective/src/tests.rs | 5 +- frame/recovery/src/lib.rs | 6 +- frame/recovery/src/mock.rs | 5 +- frame/referenda/src/benchmarking.rs | 4 +- frame/referenda/src/lib.rs | 66 ++++-- frame/referenda/src/mock.rs | 3 +- frame/remark/src/mock.rs | 3 +- frame/root-offences/src/mock.rs | 3 +- frame/salary/src/lib.rs | 9 +- frame/salary/src/tests.rs | 3 +- frame/scheduler/src/benchmarking.rs | 5 +- frame/scheduler/src/lib.rs | 206 ++++++++++++------ frame/scheduler/src/migration.rs | 5 +- frame/scheduler/src/mock.rs | 3 +- frame/scored-pool/src/lib.rs | 2 +- frame/scored-pool/src/mock.rs | 5 +- frame/session/benchmarking/src/lib.rs | 6 +- frame/session/benchmarking/src/mock.rs | 1 - frame/session/src/lib.rs | 12 +- frame/session/src/mock.rs | 3 +- frame/society/src/lib.rs | 14 +- frame/society/src/mock.rs | 5 +- frame/staking/src/mock.rs | 3 +- frame/staking/src/pallet/impls.rs | 29 ++- frame/staking/src/pallet/mod.rs | 4 +- frame/state-trie-migration/src/lib.rs | 1 - frame/statement/src/mock.rs | 3 +- frame/sudo/src/mock.rs | 5 +- .../procedural/src/construct_runtime/mod.rs | 27 +-- .../procedural/src/construct_runtime/parse.rs | 6 +- frame/support/src/dispatch.rs | 7 +- frame/support/src/lib.rs | 23 +- frame/support/src/storage/generator/mod.rs | 4 +- frame/support/test/compile_pass/src/lib.rs | 4 +- frame/support/test/src/lib.rs | 5 +- frame/support/test/tests/final_keys.rs | 21 +- frame/support/test/tests/genesisconfig.rs | 14 +- frame/support/test/tests/instance.rs | 6 +- frame/support/test/tests/issue2219.rs | 28 ++- frame/support/test/tests/storage_layers.rs | 4 +- .../support/test/tests/storage_transaction.rs | 2 +- frame/system/benches/bench.rs | 3 +- frame/system/benchmarking/src/mock.rs | 1 - frame/system/src/extensions/check_genesis.rs | 2 +- .../system/src/extensions/check_mortality.rs | 2 +- frame/system/src/lib.rs | 17 +- frame/system/src/mock.rs | 2 +- frame/system/src/mocking.rs | 2 +- frame/tips/src/lib.rs | 28 ++- frame/tips/src/tests.rs | 3 +- .../asset-conversion-tx-payment/src/mock.rs | 3 +- .../asset-tx-payment/src/mock.rs | 9 +- frame/transaction-payment/src/lib.rs | 2 +- frame/transaction-payment/src/mock.rs | 5 +- frame/transaction-storage/src/benchmarking.rs | 2 +- frame/transaction-storage/src/lib.rs | 22 +- frame/transaction-storage/src/mock.rs | 3 +- frame/treasury/src/lib.rs | 2 +- frame/treasury/src/tests.rs | 5 +- frame/uniques/src/mock.rs | 5 +- frame/utility/src/tests.rs | 3 +- frame/vesting/src/lib.rs | 64 ++++-- frame/vesting/src/migrations.rs | 39 ++-- frame/vesting/src/mock.rs | 5 +- frame/whitelist/src/mock.rs | 3 +- primitives/runtime/src/generic/block.rs | 2 +- primitives/runtime/src/testing.rs | 5 +- primitives/runtime/src/traits.rs | 24 +- 164 files changed, 1082 insertions(+), 750 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 55f6b3dd47ef4..317de54ca2bca 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -1,16 +1,13 @@ use crate as pallet_template; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test + pub enum Test { System: frame_system, TemplateModule: pallet_template, diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 7ae033cd64679..be0e60ba67b35 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -277,8 +277,7 @@ impl pallet_template::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub struct Runtime - { + pub struct Runtime { System: frame_system, Timestamp: pallet_timestamp, Aura: pallet_aura, diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 2ab541a6d858e..cd1d61f6ffaba 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -475,8 +475,13 @@ pub mod pallet { /// period stored as a future block number. #[pallet::storage] #[pallet::getter(fn retiring_members)] - pub type RetiringMembers, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; + pub type RetiringMembers, I: 'static = ()> = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + OptionQuery, + >; /// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit /// candidacy. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 460bf5211daca..58a31fdef5562 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -20,7 +20,7 @@ pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; use sp_std::convert::{TryFrom, TryInto}; @@ -236,7 +236,6 @@ impl Config for Test { type RetirementPeriod = RetirementPeriod; } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 0a8a66f9be167..9b372c8875cc0 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -30,10 +30,7 @@ use frame_support::{ use frame_system::{EnsureSigned, EnsureSignedBy}; use sp_arithmetic::Permill; use sp_core::H256; -use sp_runtime::{ - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index f7669a2495c0f..6c0a3a4be29e7 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -20,10 +20,7 @@ use crate as pallet_asset_rate; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 231e368e56126..4db698096503c 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -27,10 +27,7 @@ use frame_support::{ }; use sp_core::H256; use sp_io::storage; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 734bbcf456803..0d78a1b83400e 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -69,7 +69,7 @@ pub struct PendingSwap { /// Action of this swap. pub action: T::SwapAction, /// End block of the lock. - pub end_block: frame_system::pallet_prelude::BlockNumberFor::, + pub end_block: frame_system::pallet_prelude::BlockNumberFor, } /// Hashed proof type. @@ -249,7 +249,7 @@ pub mod pallet { target: T::AccountId, hashed_proof: HashedProof, action: T::SwapAction, - duration: frame_system::pallet_prelude::BlockNumberFor::, + duration: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { let source = ensure_signed(origin)?; ensure!( diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 846f4b4d33fde..42b9e8073b072 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -5,10 +5,7 @@ use crate as pallet_atomic_swap; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index da960496e1447..f890c5c6523a6 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -102,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor) -> Weight { if let Some(new_slot) = Self::current_slot_from_digests() { let current_slot = CurrentSlot::::get(); diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index e17c058ec40f4..31c416b27165d 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -26,11 +26,7 @@ use frame_support::{ }; use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; -use sp_runtime::{ - testing::{UintAuthorityId}, - traits::IdentityLookup, -}; - +use sp_runtime::{testing::UintAuthorityId, traits::IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 302b634a5a885..c6b7656311fdd 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -175,12 +175,11 @@ mod tests { use sp_core::{crypto::key_types, H256}; use sp_io::TestExternalities; use sp_runtime::{ - testing::{UintAuthorityId}, + testing::UintAuthorityId, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, KeyTypeId, Perbill, }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( @@ -231,7 +230,7 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 24ec8d76f1082..d7c39b2cf9ebd 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -45,7 +45,10 @@ pub mod pallet { /// Find the author of a block. type FindAuthor: FindAuthor; /// An event handler for authored blocks. - type EventHandler: EventHandler>; + type EventHandler: EventHandler< + Self::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + >; } #[pallet::pallet] @@ -53,7 +56,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor) -> Weight { if let Some(author) = Self::author() { T::EventHandler::note_author(author); } @@ -61,7 +64,7 @@ pub mod pallet { Weight::zero() } - fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor) { // ensure we never go to trie with these values. >::kill(); } @@ -108,7 +111,6 @@ mod tests { traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index 018eddf0dff1b..f9e4919d6b46b 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -106,8 +106,10 @@ impl Offence for EquivocationOffence { pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); impl - OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> - for EquivocationReportSystem + OffenceReportSystem< + Option, + (EquivocationProof>, T::KeyOwnerProof), + > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, R: ReportOffence< diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 9b3ec4fa1db3a..b22f056d9b2b2 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -78,7 +78,7 @@ pub trait WeightInfo { pub trait EpochChangeTrigger { /// Trigger an epoch change, if any should take place. This should be called /// during every block, after initialization is done. - fn trigger(now: frame_system::pallet_prelude::BlockNumberFor::); + fn trigger(now: frame_system::pallet_prelude::BlockNumberFor); } /// A type signifying to BABE that an external trigger @@ -86,7 +86,7 @@ pub trait EpochChangeTrigger { pub struct ExternalTrigger; impl EpochChangeTrigger for ExternalTrigger { - fn trigger(_: frame_system::pallet_prelude::BlockNumberFor::) {} // nothing - trigger is external. + fn trigger(_: frame_system::pallet_prelude::BlockNumberFor) {} // nothing - trigger is external. } /// A type signifying to BABE that it should perform epoch changes @@ -94,7 +94,7 @@ impl EpochChangeTrigger for ExternalTrigger { pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { - fn trigger(now: frame_system::pallet_prelude::BlockNumberFor::) { + fn trigger(now: frame_system::pallet_prelude::BlockNumberFor) { if >::should_epoch_change(now) { let authorities = >::authorities(); let next_authorities = authorities.clone(); @@ -278,8 +278,14 @@ pub mod pallet { /// entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in /// slots, which may be skipped, the block numbers may not line up with the slot numbers. #[pallet::storage] - pub(super) type EpochStart = - StorageValue<_, (frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::), ValueQuery>; + pub(super) type EpochStart = StorageValue< + _, + ( + frame_system::pallet_prelude::BlockNumberFor, + frame_system::pallet_prelude::BlockNumberFor, + ), + ValueQuery, + >; /// How late the current block is compared to its parent. /// @@ -288,7 +294,8 @@ pub mod pallet { /// execution context should always yield zero. #[pallet::storage] #[pallet::getter(fn lateness)] - pub(super) type Lateness = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; + pub(super) type Lateness = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -503,8 +510,10 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession> for Pallet { - fn should_end_session(now: frame_system::pallet_prelude::BlockNumberFor::) -> bool { +impl pallet_session::ShouldEndSession> + for Pallet +{ + fn should_end_session(now: frame_system::pallet_prelude::BlockNumberFor) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's // possible that babe's own `on_initialize` has not run yet, so let's ensure that we @@ -524,7 +533,7 @@ impl Pallet { /// Determine whether an epoch change should take place at this block. /// Assumes that initialization has already taken place. - pub fn should_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor::) -> bool { + pub fn should_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor) -> bool { // The epoch has technically ended during the passage of time // between this block and the last, but we have to "end" the epoch now, // since there is no earlier possible block we could have done it. @@ -554,11 +563,14 @@ impl Pallet { // // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. - pub fn next_expected_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor::) -> Option> { + pub fn next_expected_epoch_change( + now: frame_system::pallet_prelude::BlockNumberFor, + ) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: frame_system::pallet_prelude::BlockNumberFor:: = slots_remaining.saturated_into(); + let blocks_remaining: frame_system::pallet_prelude::BlockNumberFor = + slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) } @@ -776,7 +788,7 @@ impl Pallet { Self::deposit_consensus(ConsensusLog::NextEpochData(next)); } - fn initialize(now: frame_system::pallet_prelude::BlockNumberFor::) { + fn initialize(now: frame_system::pallet_prelude::BlockNumberFor) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block let initialized = Self::initialized().is_some(); @@ -811,7 +823,8 @@ impl Pallet { // how many slots were skipped between current and last block let lateness = current_slot.saturating_sub(CurrentSlot::::get() + 1); - let lateness = frame_system::pallet_prelude::BlockNumberFor::::from(*lateness as u32); + let lateness = + frame_system::pallet_prelude::BlockNumberFor::::from(*lateness as u32); Lateness::::put(lateness); CurrentSlot::::put(current_slot); @@ -899,12 +912,18 @@ impl OnTimestampSet for Pallet { } } -impl frame_support::traits::EstimateNextSessionRotation> for Pallet { - fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor:: { +impl + frame_support::traits::EstimateNextSessionRotation< + frame_system::pallet_prelude::BlockNumberFor, + > for Pallet +{ + fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor { T::EpochDuration::get().saturated_into() } - fn estimate_current_session_progress(_now: frame_system::pallet_prelude::BlockNumberFor::) -> (Option, Weight) { + fn estimate_current_session_progress( + _now: frame_system::pallet_prelude::BlockNumberFor, + ) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; ( @@ -914,7 +933,9 @@ impl frame_support::traits::EstimateNextSessionRotation) -> (Option>, Weight) { + fn estimate_next_session_rotation( + now: frame_system::pallet_prelude::BlockNumberFor, + ) -> (Option>, Weight) { ( Self::next_expected_epoch_change(now), // Read: Current Slot, Epoch Index, Genesis Slot @@ -923,8 +944,10 @@ impl frame_support::traits::EstimateNextSessionRotation frame_support::traits::Lateness> for Pallet { - fn lateness(&self) -> frame_system::pallet_prelude::BlockNumberFor:: { +impl frame_support::traits::Lateness> + for Pallet +{ + fn lateness(&self) -> frame_system::pallet_prelude::BlockNumberFor { Self::lateness() } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 57c92a72a588f..fe2fe92fbc196 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -42,7 +42,6 @@ use sp_staking::{EraIndex, SessionIndex}; type DummyValidatorId = u64; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index 112c4b4237d39..34752a91e8006 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -129,8 +129,10 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT> for RandomnessFromTwoEpochsAgo { - fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { +impl RandomnessT> + for RandomnessFromTwoEpochsAgo +{ + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); @@ -139,8 +141,10 @@ impl RandomnessT RandomnessT> for RandomnessFromOneEpochAgo { - fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { +impl RandomnessT> + for RandomnessFromOneEpochAgo +{ + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); @@ -149,8 +153,12 @@ impl RandomnessT RandomnessT, frame_system::pallet_prelude::BlockNumberFor::> for ParentBlockRandomness { - fn random(subject: &[u8]) -> (Option, frame_system::pallet_prelude::BlockNumberFor::) { +impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor> + for ParentBlockRandomness +{ + fn random( + subject: &[u8], + ) -> (Option, frame_system::pallet_prelude::BlockNumberFor) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -164,8 +172,12 @@ impl RandomnessT, frame_system::pallet_prelude::Block } #[allow(deprecated)] -impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor::> for CurrentBlockRandomness { - fn random(subject: &[u8]) -> (Option, frame_system::pallet_prelude::BlockNumberFor::) { +impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor> + for CurrentBlockRandomness +{ + fn random( + subject: &[u8], + ) -> (Option, frame_system::pallet_prelude::BlockNumberFor) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index a8831272a7e90..3fd66d50d12e1 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -85,7 +85,6 @@ impl bags_list::Config for Runtime { type Score = VoteWeight; } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index 32369ee988798..3f5284e4969a1 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -842,7 +842,7 @@ impl, I: 'static> LockableCurrency for Pallet where T::Balance: MaybeSerializeDeserialize + Debug, { - type Moment = frame_system::pallet_prelude::BlockNumberFor::; + type Moment = frame_system::pallet_prelude::BlockNumberFor; type MaxLocks = T::MaxLocks; diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 6faeabec75991..2ad0847877529 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -517,7 +517,9 @@ pub mod pallet { } #[pallet::hooks] - impl, I: 'static> Hooks> for Pallet { + impl, I: 'static> Hooks> + for Pallet + { #[cfg(not(feature = "insecure_zero_ed"))] fn integrity_test() { assert!( diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 7ddaec998f035..76ec74a2882b0 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -38,7 +38,7 @@ use scale_info::TypeInfo; use sp_core::{hexdisplay::HexDisplay, H256}; use sp_io; use sp_runtime::{ - traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, + traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError, }; use std::collections::BTreeSet; @@ -49,7 +49,6 @@ mod fungible_conformance_tests; mod fungible_tests; mod reentrancy_tests; - type Block = frame_system::mocking::MockBlock; #[derive( diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index cda4fa697cbc2..ea51c76a363b5 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -29,7 +29,7 @@ use sp_core::H256; use sp_runtime::{ app_crypto::ecdsa::Public, impl_opaque_keys, - traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, + traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, }; use crate as pallet_beefy_mmr; @@ -44,7 +44,6 @@ impl_opaque_keys! { } } - type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index f7ed8136e8fa5..b85ed0bc5e134 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -140,7 +140,10 @@ where R: ReportOffence< T::AccountId, P::IdentificationTuple, - EquivocationOffence>, + EquivocationOffence< + P::IdentificationTuple, + frame_system::pallet_prelude::BlockNumberFor, + >, >, P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, P::IdentificationTuple: Clone, diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index c9eb7174cb6a9..406cafb87a7e5 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -32,7 +32,7 @@ use sp_runtime::{ app_crypto::ecdsa::Public, curve::PiecewiseLinear, impl_opaque_keys, - testing::{TestXt}, + testing::TestXt, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, Perbill, }; @@ -51,7 +51,6 @@ impl_opaque_keys! { } } - type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 85e898083359e..bace7cf542e2d 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -345,7 +345,6 @@ mod mock { type AccountIndex = u32; type BlockNumber = u64; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( @@ -363,7 +362,7 @@ mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index 061b8c09ea0cb..39af1c48703d7 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -164,7 +164,6 @@ fn noop_is_free() { mod mock { use sp_runtime::testing::H256; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index f6630836b7deb..babaebc244b1f 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -117,7 +117,6 @@ pub mod mock { type AccountIndex = u32; type BlockNumber = u64; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( @@ -134,7 +133,7 @@ pub mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 62bd3c509f628..b7cd78cc89d4e 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::{parameter_types, traits::ConstU32}; use sp_runtime::{ - testing::{H256}, + testing::H256, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -66,7 +66,6 @@ mod pallet_test { } } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index cd11e95c9446f..1b675c5e577d1 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::traits::ConstU32; use sp_runtime::{ - testing::{H256}, + testing::H256, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -76,7 +76,6 @@ mod pallet_test { } } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 738cd41cf11ad..4bc7e3823172f 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -305,7 +305,7 @@ pub mod pallet { _, Twox64Concat, BountyIndex, - Bounty, frame_system::pallet_prelude::BlockNumberFor::>, + Bounty, frame_system::pallet_prelude::BlockNumberFor>, >; /// The description of each bounty. diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index d66c3f462a53e..c0bb44b409379 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -32,13 +32,12 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Storage, }; use super::Event as BountiesEvent; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 7fd181adc2256..d822476a7cb1b 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { BountyIndex, Twox64Concat, BountyIndex, - ChildBounty, frame_system::pallet_prelude::BlockNumberFor::>, + ChildBounty, frame_system::pallet_prelude::BlockNumberFor>, >; /// The description of each child-bounty. @@ -816,7 +816,7 @@ impl Pallet { fn ensure_bounty_active( bounty_id: BountyIndex, - ) -> Result<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor::), DispatchError> { + ) -> Result<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor), DispatchError> { let parent_bounty = pallet_bounties::Pallet::::bounties(bounty_id) .ok_or(BountiesError::::InvalidIndex)?; if let BountyStatus::Active { curator, update_due } = parent_bounty.get_status() { diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 2a10ebcc332de..11c3a30251816 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -33,13 +33,12 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, Perbill, Permill, TokenError, }; use super::Event as ChildBountiesEvent; - type Block = frame_system::mocking::MockBlock; type BountiesError = pallet_bounties::Error; diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 3cb0aeeba1820..4844722b94694 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -272,8 +272,13 @@ pub mod pallet { /// Votes on a given proposal, if it is ongoing. #[pallet::storage] #[pallet::getter(fn voting)] - pub type Voting, I: 'static = ()> = - StorageMap<_, Identity, T::Hash, Votes>, OptionQuery>; + pub type Voting, I: 'static = ()> = StorageMap< + _, + Identity, + T::Hash, + Votes>, + OptionQuery, + >; /// Proposals so far. #[pallet::storage] diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index afab8cc94b42c..ea431f1c87ba9 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -394,7 +394,7 @@ pub struct Stack<'a, T: Config, E> { /// The timestamp at the point of call stack instantiation. timestamp: MomentOf, /// The block number at the time of call stack instantiation. - block_number: frame_system::pallet_prelude::BlockNumberFor::, + block_number: frame_system::pallet_prelude::BlockNumberFor, /// The nonce is cached here when accessed. It is written back when the call stack /// finishes executing. Please refer to [`Nonce`] to a description of /// the nonce itself. @@ -1356,7 +1356,7 @@ where ); } - fn block_number(&self) -> frame_system::pallet_prelude::BlockNumberFor:: { + fn block_number(&self) -> frame_system::pallet_prelude::BlockNumberFor { self.block_number } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 82775baf32fac..df69e0d312922 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -341,7 +341,10 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_idle(_block: frame_system::pallet_prelude::BlockNumberFor::, mut remaining_weight: Weight) -> Weight { + fn on_idle( + _block: frame_system::pallet_prelude::BlockNumberFor, + mut remaining_weight: Weight, + ) -> Weight { use migration::MigrateResult::*; loop { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 8c9c7f8bc08ac..78d208989d070 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -50,13 +50,12 @@ use sp_core::ByteArray; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - testing::{H256}, + testing::H256, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, AccountId32, TokenError, }; use std::ops::Deref; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 3dd8f4d7d5656..027fc71c7da18 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -103,8 +103,10 @@ pub mod pallet { type WeightInfo: WeightInfo; /// Currency type with which voting happens. type Currency: ReservableCurrency - + LockableCurrency> - + fungible::Inspect; + + LockableCurrency< + Self::AccountId, + Moment = frame_system::pallet_prelude::BlockNumberFor, + > + fungible::Inspect; /// The implementation of the logic which conducts polls. type Polls: Polling< diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 976aaa0e1f66f..423db6b3d55a3 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -24,14 +24,11 @@ use frame_support::{ traits::{ConstU32, ConstU64, Contains, Polling, VoteTally}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use super::*; use crate as pallet_conviction_voting; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs index 0005b20934728..5eab4a1e728aa 100644 --- a/frame/core-fellowship/src/benchmarking.rs +++ b/frame/core-fellowship/src/benchmarking.rs @@ -75,7 +75,9 @@ mod benchmarks { let member = make_member::(0)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + frame_system::Pallet::::set_block_number( + frame_system::pallet_prelude::BlockNumberFor::::max_value(), + ); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); @@ -92,7 +94,9 @@ mod benchmarks { let member = make_member::(2)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + frame_system::Pallet::::set_block_number( + frame_system::pallet_prelude::BlockNumberFor::::max_value(), + ); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); assert_eq!(T::Members::rank_of(&member), Some(2)); diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index 98e34527431af..ca4071f9faa86 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -193,8 +193,11 @@ pub mod pallet { type EvidenceSize: Get; } - pub type ParamsOf = - ParamsType<>::Balance, frame_system::pallet_prelude::BlockNumberFor, RANK_COUNT>; + pub type ParamsOf = ParamsType< + >::Balance, + frame_system::pallet_prelude::BlockNumberFor, + RANK_COUNT, + >; pub type MemberStatusOf = MemberStatus>; pub type RankOf = <>::Members as RankedMembers>::Rank; diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 544048eb084c3..1df0c328b3eef 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -28,7 +28,7 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, + traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, DispatchError, DispatchResult, }; use sp_std::cell::RefCell; @@ -36,7 +36,6 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_core_fellowship; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index d537d6aa542e3..4bd868baebdf5 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -226,14 +226,21 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Scheduler. - type Scheduler: ScheduleNamed, CallOf, Self::PalletsOrigin>; + type Scheduler: ScheduleNamed< + frame_system::pallet_prelude::BlockNumberFor, + CallOf, + Self::PalletsOrigin, + >; /// The Preimage provider. type Preimages: QueryPreimage + StorePreimage; /// Currency type for this pallet. type Currency: ReservableCurrency - + LockableCurrency>; + + LockableCurrency< + Self::AccountId, + Moment = frame_system::pallet_prelude::BlockNumberFor, + >; /// The period between a proposal being approved and enacted. /// @@ -387,7 +394,11 @@ pub mod pallet { _, Twox64Concat, ReferendumIndex, - ReferendumInfo, BoundedCallOf, BalanceOf>, + ReferendumInfo< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, >; /// All votes for a particular voter. We store the balance for the number of votes that we @@ -399,7 +410,12 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - Voting, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, T::MaxVotes>, + Voting< + BalanceOf, + T::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + T::MaxVotes, + >, ValueQuery, >; @@ -422,7 +438,10 @@ pub mod pallet { _, Identity, H256, - (frame_system::pallet_prelude::BlockNumberFor::, BoundedVec), + ( + frame_system::pallet_prelude::BlockNumberFor, + BoundedVec, + ), >; /// Record of all proposals that have been subject to emergency cancellation. @@ -475,7 +494,11 @@ pub mod pallet { /// An account has cancelled a previous delegation operation. Undelegated { account: T::AccountId }, /// An external proposal has been vetoed. - Vetoed { who: T::AccountId, proposal_hash: H256, until: frame_system::pallet_prelude::BlockNumberFor:: }, + Vetoed { + who: T::AccountId, + proposal_hash: H256, + until: frame_system::pallet_prelude::BlockNumberFor, + }, /// A proposal_hash has been blacklisted permanently. Blacklisted { proposal_hash: H256 }, /// An account has voted in a referendum @@ -565,7 +588,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Weight: see `begin_block` - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { Self::begin_block(n) } } @@ -775,8 +798,8 @@ pub mod pallet { pub fn fast_track( origin: OriginFor, proposal_hash: H256, - voting_period: frame_system::pallet_prelude::BlockNumberFor::, - delay: frame_system::pallet_prelude::BlockNumberFor::, + voting_period: frame_system::pallet_prelude::BlockNumberFor, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { // Rather complicated bit of code to ensure that either: // - `voting_period` is at least `FastTrackVotingPeriod` and `origin` is @@ -794,7 +817,10 @@ pub mod pallet { ensure!(T::InstantAllowed::get(), Error::::InstantNotAllowed); } - ensure!(voting_period > frame_system::pallet_prelude::BlockNumberFor::::zero(), Error::::VotingPeriodLow); + ensure!( + voting_period > frame_system::pallet_prelude::BlockNumberFor::::zero(), + Error::::VotingPeriodLow + ); let (ext_proposal, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( @@ -1047,7 +1073,10 @@ pub mod pallet { T::BlacklistOrigin::ensure_origin(origin)?; // Insert the proposal into the blacklist. - let permanent = (frame_system::pallet_prelude::BlockNumberFor::::max_value(), BoundedVec::::default()); + let permanent = ( + frame_system::pallet_prelude::BlockNumberFor::::max_value(), + BoundedVec::::default(), + ); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. @@ -1200,17 +1229,31 @@ impl Pallet { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( - n: frame_system::pallet_prelude::BlockNumberFor::, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> { + n: frame_system::pallet_prelude::BlockNumberFor, + ) -> Vec<( + ReferendumIndex, + ReferendumStatus< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, + )> { let next = Self::lowest_unbaked(); let last = Self::referendum_count(); Self::maturing_referenda_at_inner(n, next..last) } fn maturing_referenda_at_inner( - n: frame_system::pallet_prelude::BlockNumberFor::, + n: frame_system::pallet_prelude::BlockNumberFor, range: core::ops::Range, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> { + ) -> Vec<( + ReferendumIndex, + ReferendumStatus< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, + )> { range .into_iter() .map(|i| (i, Self::referendum_info(i))) @@ -1228,7 +1271,7 @@ impl Pallet { pub fn internal_start_referendum( proposal: BoundedCallOf, threshold: VoteThreshold, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> ReferendumIndex { >::inject_referendum( >::block_number().saturating_add(T::VotingPeriod::get()), @@ -1249,8 +1292,19 @@ impl Pallet { /// Ok if the given referendum is active, Err otherwise fn ensure_ongoing( - r: ReferendumInfo, BoundedCallOf, BalanceOf>, - ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> { + r: ReferendumInfo< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, + ) -> Result< + ReferendumStatus< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, + DispatchError, + > { match r { ReferendumInfo::Ongoing(s) => Ok(s), _ => Err(Error::::ReferendumInvalid.into()), @@ -1259,7 +1313,14 @@ impl Pallet { fn referendum_status( ref_index: ReferendumIndex, - ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> { + ) -> Result< + ReferendumStatus< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, + DispatchError, + > { let info = ReferendumInfoOf::::get(ref_index).ok_or(Error::::ReferendumInvalid)?; Self::ensure_ongoing(info) } @@ -1514,10 +1575,10 @@ impl Pallet { /// Start a referendum fn inject_referendum( - end: frame_system::pallet_prelude::BlockNumberFor::, + end: frame_system::pallet_prelude::BlockNumberFor, proposal: BoundedCallOf, threshold: VoteThreshold, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> ReferendumIndex { let ref_index = Self::referendum_count(); ReferendumCount::::put(ref_index + 1); @@ -1530,7 +1591,7 @@ impl Pallet { } /// Table the next waiting proposal for a vote. - fn launch_next(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { + fn launch_next(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { if LastTabledWasExternal::::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { @@ -1540,7 +1601,7 @@ impl Pallet { } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { + fn launch_external(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); Self::deposit_event(Event::::ExternalTabled); @@ -1558,7 +1619,7 @@ impl Pallet { } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { + fn launch_public(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter().enumerate().max_by_key( // defensive only: All current public proposals have an amount locked @@ -1591,9 +1652,13 @@ impl Pallet { } fn bake_referendum( - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, index: ReferendumIndex, - status: ReferendumStatus, BoundedCallOf, BalanceOf>, + status: ReferendumStatus< + frame_system::pallet_prelude::BlockNumberFor, + BoundedCallOf, + BalanceOf, + >, ) -> bool { let total_issuance = T::Currency::total_issuance(); let approved = status.threshold.approved(status.tally, total_issuance); @@ -1628,7 +1693,7 @@ impl Pallet { /// ## Complexity: /// If a referendum is launched or maturing, this will take full block weight if queue is not /// empty. Otherwise, `O(R)` where `R` is the number of unbaked referenda. - fn begin_block(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn begin_block(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let max_block_weight = T::BlockWeights::get().max_block; let mut weight = Weight::zero(); diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index cd66922a5815e..78b27d6d15201 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -87,7 +87,12 @@ pub mod v1 { } ReferendumInfoOf::::translate( - |index, old: ReferendumInfo, T::Hash, BalanceOf>| { + |index, + old: ReferendumInfo< + frame_system::pallet_prelude::BlockNumberFor, + T::Hash, + BalanceOf, + >| { weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); log::info!(target: TARGET, "migrating referendum #{:?}", &index); Some(match old { diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 79d02c85ffefa..278e7dac038cf 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -31,7 +31,7 @@ use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy}; use pallet_balances::{BalanceLock, Error as BalancesError}; use sp_core::H256; use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, Perbill, }; mod cancellation; @@ -50,7 +50,6 @@ const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; const BIG_AYE: Vote = Vote { aye: true, conviction: Conviction::Locked1x }; const BIG_NAY: Vote = Vote { aye: false, conviction: Conviction::Locked1x }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 03c761cb51559..fd0a3c44aec20 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -747,7 +747,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let next_election = T::DataProvider::next_election_prediction(now).max(now); let signed_deadline = T::SignedPhase::get() + T::UnsignedPhase::get(); @@ -824,7 +824,7 @@ pub mod pallet { } } - fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { use sp_runtime::offchain::storage_lock::{BlockAndTime, StorageLock}; // Create a lock with the maximum deadline of number of blocks in the unsigned phase. @@ -886,7 +886,9 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { + fn try_state( + _n: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1155,7 +1157,11 @@ pub mod pallet { /// An account has been slashed for submitting an invalid signed submission. Slashed { account: ::AccountId, value: BalanceOf }, /// There was a phase transition in a given round. - PhaseTransitioned { from: Phase>, to: Phase>, round: u32 }, + PhaseTransitioned { + from: Phase>, + to: Phase>, + round: u32, + }, } /// Error of the pallet that can be returned in response to dispatches. @@ -1257,7 +1263,8 @@ pub mod pallet { /// Current phase. #[pallet::storage] #[pallet::getter(fn current_phase)] - pub type CurrentPhase = StorageValue<_, Phase>, ValueQuery>; + pub type CurrentPhase = + StorageValue<_, Phase>, ValueQuery>; /// Current best solution, signed or unsigned, queued to be returned upon `elect`. /// @@ -1349,7 +1356,7 @@ pub mod pallet { impl Pallet { /// Internal logic of the offchain worker, to be executed only when the offchain lock is /// acquired with success. - fn do_synchronized_offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { + fn do_synchronized_offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { let current_phase = Self::current_phase(); log!(trace, "lock for offchain worker acquired. Phase = {:?}", current_phase); match current_phase { @@ -1375,7 +1382,7 @@ impl Pallet { } /// Phase transition helper. - pub(crate) fn phase_transition(to: Phase>) { + pub(crate) fn phase_transition(to: Phase>) { log!(info, "Starting phase {:?}, round {}.", to, Self::round()); Self::deposit_event(Event::PhaseTransitioned { from: >::get(), @@ -1672,7 +1679,7 @@ impl Pallet { impl ElectionProviderBase for Pallet { type AccountId = T::AccountId; - type BlockNumber = frame_system::pallet_prelude::BlockNumberFor::; + type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; type Error = ElectionError; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 5a66ac9d7575d..c2ac8ff77b3f7 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -216,7 +216,7 @@ impl SignedSubmissions { fn swap_out_submission( &mut self, remove_pos: usize, - insert: Option<(ElectionScore, frame_system::pallet_prelude::BlockNumberFor::, u32)>, + insert: Option<(ElectionScore, frame_system::pallet_prelude::BlockNumberFor, u32)>, ) -> Option> { if remove_pos >= self.indices.len() { return None diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 78d6b4f08ec91..bb374582f9a00 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -298,12 +298,14 @@ impl Pallet { /// /// Returns `Ok(())` if offchain worker limit is respected, `Err(reason)` otherwise. If `Ok()` /// is returned, `now` is written in storage and will be used in further calls as the baseline. - pub fn ensure_offchain_repeat_frequency(now: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), MinerError> { + pub fn ensure_offchain_repeat_frequency( + now: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), MinerError> { let threshold = T::OffchainRepeat::get(); let last_block = StorageValueRef::persistent(OFFCHAIN_LAST_BLOCK); let mutate_stat = last_block.mutate::<_, &'static str, _>( - |maybe_head: Result>, _>| { + |maybe_head: Result>, _>| { match maybe_head { Ok(Some(head)) if now < head => Err("fork."), Ok(Some(head)) if now >= head && now <= head + threshold => diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index fda5b11073d10..4adcf99b3345a 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -208,7 +208,7 @@ mod tests { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = AccountId; - type RuntimeCall = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 3680dce013f13..affc474bff1ed 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -203,8 +203,10 @@ pub mod pallet { type PalletId: Get; /// The currency that people are electing with. - type Currency: LockableCurrency> - + ReservableCurrency; + type Currency: LockableCurrency< + Self::AccountId, + Moment = frame_system::pallet_prelude::BlockNumberFor, + > + ReservableCurrency; /// What to do when the members change. type ChangeMembers: ChangeMembers; @@ -285,7 +287,7 @@ pub mod pallet { /// What to do at the end of each block. /// /// Checks if an election needs to happen or not. - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let term_duration = T::TermDuration::get(); if !term_duration.is_zero() && (n % term_duration).is_zero() { Self::do_phragmen() @@ -330,7 +332,9 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { + fn try_state( + _n: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), TryRuntimeError> { Self::do_try_state() } } diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index 53caf9cc81562..d927c3ad4d9bd 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -388,21 +388,21 @@ pub mod pallet { // dispatched. // // This function must return the weight consumed by `on_initialize` and `on_finalize`. - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { // Anything that needs to be done at the start of the block. // We don't do anything here. Weight::zero() } // `on_finalize` is executed at the end of block after all extrinsic are dispatched. - fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor) { // Perform necessary data/state clean up here. } // A runtime code run after every block and have access to extended set of APIs. // // For instance you can generate extrinsics for the upcoming produced block. - fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor) { // We don't do anything here. // but we could dispatch extrinsic (transaction/unsigned/inherent) using // sp_io::submit_extrinsic. diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index b3976b3b2c056..fb5f192dbf85e 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -27,13 +27,12 @@ use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_basic; - type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 577af5489cda3..f19ef56cd59de 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -111,7 +111,6 @@ pub mod tests { use super::pallet as pallet_default_config_example; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( @@ -140,8 +139,9 @@ pub mod tests { // type Index = u32; // type BlockNumber = u32; - // type Header = sp_runtime::generic::Header, Self::Hashing>; - // type Hash = sp_core::hash::H256; + // type Header = + // sp_runtime::generic::Header, + // Self::Hashing>; type Hash = sp_core::hash::H256; // type Hashing = sp_runtime::traits::BlakeTwo256; // type AccountId = u64; // type Lookup = sp_runtime::traits::IdentityLookup; diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index 4f26ba11e5a1a..49326610dd419 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -21,13 +21,12 @@ use crate::*; use frame_support::{assert_ok, traits::ConstU64}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_dev_mode; - type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index 87ef5bb318125..389cd6bfcc27c 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -183,7 +183,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub foo: u32, - pub bar: frame_system::pallet_prelude::BlockNumberFor::, + pub bar: frame_system::pallet_prelude::BlockNumberFor, } impl Default for GenesisConfig { @@ -249,22 +249,25 @@ pub mod pallet { /// All the possible hooks that a pallet can have. See [`frame_support::traits::Hooks`] for more /// info. #[pallet::hooks] - impl Hooks> for Pallet { + impl Hooks> for Pallet { fn integrity_test() {} - fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor) { unimplemented!() } - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { unimplemented!() } - fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor) { unimplemented!() } - fn on_idle(_n: frame_system::pallet_prelude::BlockNumberFor::, _remaining_weight: Weight) -> Weight { + fn on_idle( + _n: frame_system::pallet_prelude::BlockNumberFor, + _remaining_weight: Weight, + ) -> Weight { unimplemented!() } @@ -283,7 +286,9 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { + fn try_state( + _n: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), TryRuntimeError> { unimplemented!() } } diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index 95389f6dfa457..8564c05d7f9bb 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -23,7 +23,6 @@ use sp_runtime::BuildStorage; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_kitchensink; - type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 8a3e1ba4ea480..765cfcfa04f67 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -171,7 +171,7 @@ pub mod pallet { /// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs), /// so the code should be able to handle that. /// You can use `Local Storage` API to coordinate runs of the worker. - fn offchain_worker(block_number: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(block_number: frame_system::pallet_prelude::BlockNumberFor) { // Note that having logs compiled to WASM may cause the size of the blob to increase // significantly. You can use `RuntimeDebug` custom derive to hide details of the types // in WASM. The `sp-api` crate also provides a feature `disable-logging` to disable @@ -258,7 +258,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned( origin: OriginFor, - _block_number: frame_system::pallet_prelude::BlockNumberFor::, + _block_number: frame_system::pallet_prelude::BlockNumberFor, price: u32, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -275,7 +275,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned_with_signed_payload( origin: OriginFor, - price_payload: PricePayload>, + price_payload: PricePayload>, _signature: T::Signature, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -341,7 +341,8 @@ pub mod pallet { /// This storage entry defines when new transaction is going to be accepted. #[pallet::storage] #[pallet::getter(fn next_unsigned_at)] - pub(super) type NextUnsignedAt = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; + pub(super) type NextUnsignedAt = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; } /// Payload used by this example crate to hold price @@ -353,7 +354,9 @@ pub struct PricePayload { public: Public, } -impl SignedPayload for PricePayload> { +impl SignedPayload + for PricePayload> +{ fn public(&self) -> T::Public { self.public.clone() } @@ -374,7 +377,9 @@ impl Pallet { /// and local storage usage. /// /// Returns a type of transaction that should be produced in current run. - fn choose_transaction_type(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> TransactionType { + fn choose_transaction_type( + block_number: frame_system::pallet_prelude::BlockNumberFor, + ) -> TransactionType { /// A friendlier name for the error that is going to be returned in case we are in the grace /// period. const RECENTLY_SENT: () = (); @@ -389,16 +394,21 @@ impl Pallet { // low-level method of local storage API, which means that only one worker // will be able to "acquire a lock" and send a transaction if multiple workers // happen to be executed concurrently. - let res = val.mutate(|last_send: Result>, StorageRetrievalError>| { - match last_send { - // If we already have a value in storage and the block number is recent enough - // we avoid sending another transaction at this time. - Ok(Some(block)) if block_number < block + T::GracePeriod::get() => - Err(RECENTLY_SENT), - // In every other case we attempt to acquire the lock and send a transaction. - _ => Ok(block_number), - } - }); + let res = val.mutate( + |last_send: Result< + Option>, + StorageRetrievalError, + >| { + match last_send { + // If we already have a value in storage and the block number is recent enough + // we avoid sending another transaction at this time. + Ok(Some(block)) if block_number < block + T::GracePeriod::get() => + Err(RECENTLY_SENT), + // In every other case we attempt to acquire the lock and send a transaction. + _ => Ok(block_number), + } + }, + ); // The result of `mutate` call will give us a nested `Result` type. // The first one matches the return of the closure passed to `mutate`, i.e. @@ -419,9 +429,13 @@ impl Pallet { let transaction_type = block_number % 4u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed - } else if transaction_type == frame_system::pallet_prelude::BlockNumberFor::::from(1u32) { + } else if transaction_type == + frame_system::pallet_prelude::BlockNumberFor::::from(1u32) + { TransactionType::UnsignedForAny - } else if transaction_type == frame_system::pallet_prelude::BlockNumberFor::::from(2u32) { + } else if transaction_type == + frame_system::pallet_prelude::BlockNumberFor::::from(2u32) + { TransactionType::UnsignedForAll } else { TransactionType::Raw @@ -472,7 +486,9 @@ impl Pallet { } /// A helper function to fetch the price and send a raw unsigned transaction. - fn fetch_price_and_send_raw_unsigned(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), &'static str> { + fn fetch_price_and_send_raw_unsigned( + block_number: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. let next_unsigned_at = >::get(); @@ -505,7 +521,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_any_account( - block_number: frame_system::pallet_prelude::BlockNumberFor::, + block_number: frame_system::pallet_prelude::BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -535,7 +551,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_all_accounts( - block_number: frame_system::pallet_prelude::BlockNumberFor::, + block_number: frame_system::pallet_prelude::BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -669,7 +685,7 @@ impl Pallet { } fn validate_transaction_parameters( - block_number: &frame_system::pallet_prelude::BlockNumberFor::, + block_number: &frame_system::pallet_prelude::BlockNumberFor, new_price: &u32, ) -> TransactionValidity { // Now let's check if the transaction has any chance to succeed. diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 3f61491d3683f..28ab3d8c3b8ae 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -30,12 +30,11 @@ use sp_core::{ use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ - testing::{TestXt}, + testing::TestXt, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, RuntimeAppPublic, }; - type Block = frame_system::mocking::MockBlock; // For testing the module, we construct a mock runtime. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index f7dfebd1a9f8a..446e0e13f45f3 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -178,7 +178,10 @@ pub struct Executive< impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, Hash = System::Hash>, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade @@ -212,7 +215,10 @@ where #[cfg(feature = "try-runtime")] impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, Hash = System::Hash>, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade @@ -297,10 +303,9 @@ where // run the try-state checks of all pallets, ensuring they don't alter any state. let _guard = frame_support::StorageNoopGuard::default(); - >>::try_state( - *header.number(), - select, - ) + , + >>::try_state(*header.number(), select) .map_err(|e| { frame_support::log::error!(target: LOG_TARGET, "failure: {:?}", e); e @@ -350,7 +355,9 @@ where ) -> Result { if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >>::try_state( + , + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -363,7 +370,9 @@ where if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >>::try_state( + , + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -375,7 +384,10 @@ where impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, Hash = System::Hash>, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade @@ -468,8 +480,9 @@ where let n = *header.number(); assert!( n > frame_system::pallet_prelude::BlockNumberFor::::zero() && - >::block_hash(n - frame_system::pallet_prelude::BlockNumberFor::::one()) == - *header.parent_hash(), + >::block_hash( + n - frame_system::pallet_prelude::BlockNumberFor::::one() + ) == *header.parent_hash(), "Parent hash should be valid.", ); @@ -535,17 +548,18 @@ where let remaining_weight = max_weight.saturating_sub(weight.total()); if remaining_weight.all_gt(Weight::zero()) { - let used_weight = >>::on_idle( - block_number, - remaining_weight, - ); + let used_weight = , + >>::on_idle(block_number, remaining_weight); >::register_extra_weight_unchecked( used_weight, DispatchClass::Mandatory, ); } - >>::on_finalize(block_number); + , + >>::on_finalize(block_number); } /// Apply extrinsic outside of the block execution function. @@ -671,9 +685,9 @@ where // as well. frame_system::BlockHash::::insert(header.number(), header.hash()); - >>::offchain_worker( - *header.number(), - ) + , + >>::offchain_worker(*header.number()) } } @@ -718,17 +732,20 @@ mod tests { impl Hooks> for Pallet { // module hooks. // one with block number arg and one without - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { println!("on_initialize({})", n); Weight::from_parts(175, 0) } - fn on_idle(n: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight) -> Weight { + fn on_idle( + n: frame_system::pallet_prelude::BlockNumberFor, + remaining_weight: Weight, + ) -> Weight { println!("on_idle{}, {})", n, remaining_weight); Weight::from_parts(175, 0) } - fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor) { println!("on_finalize({})", n); } @@ -737,7 +754,7 @@ mod tests { Weight::from_parts(200, 0) } - fn offchain_worker(n: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(n: frame_system::pallet_prelude::BlockNumberFor) { assert_eq!(frame_system::pallet_prelude::BlockNumberFor::::from(1u32), n); } } diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index b14ed6ce56b34..ab7acdefd3541 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -272,8 +272,11 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet { - fn on_idle(_: frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: Weight) -> Weight { + impl Hooks> for Pallet { + fn on_idle( + _: frame_system::pallet_prelude::BlockNumberFor, + remaining_weight: Weight, + ) -> Weight { if remaining_weight.any_lt(T::DbWeight::get().reads(2)) { return Weight::from_parts(0, 0) } @@ -295,7 +298,9 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Result<(), TryRuntimeError> { + fn try_state( + _n: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result<(), TryRuntimeError> { // ensure that the value of `ErasToCheckPerBlock` is less than // `T::MaxErasToCheckPerBlock`. ensure!( diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 29b9c0405c2e1..6808df73cf321 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -196,9 +196,7 @@ impl fast_unstake::Config for Runtime { type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime - - { + pub struct Runtime { System: frame_system, Timestamp: pallet_timestamp, Balances: pallet_balances, diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index dc290a727d22f..7bd66e6a577ba 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -23,10 +23,7 @@ use frame_support::{ traits::{ConstU32, ConstU64}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index cd4d7b9afdf7b..3b400dec1f037 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -118,7 +118,10 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, impl OffenceReportSystem< Option, - (EquivocationProof>, T::KeyOwnerProof), + ( + EquivocationProof>, + T::KeyOwnerProof, + ), > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -134,7 +137,10 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: ( + EquivocationProof>, + T::KeyOwnerProof, + ), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -152,7 +158,10 @@ where } fn check_evidence( - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: ( + EquivocationProof>, + T::KeyOwnerProof, + ), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -172,7 +181,10 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: ( + EquivocationProof>, + T::KeyOwnerProof, + ), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 950613b83e276..9f44d67d21e74 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -113,13 +113,16 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof>, Self::KeyOwnerProof), + ( + EquivocationProof>, + Self::KeyOwnerProof, + ), >; } #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(block_number: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(block_number: frame_system::pallet_prelude::BlockNumberFor) { // check for scheduled pending authority set changes if let Some(pending_change) = >::get() { // emit signal if we're at the block that scheduled the change @@ -191,7 +194,9 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>>, + equivocation_proof: Box< + EquivocationProof>, + >, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -217,7 +222,9 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>>, + equivocation_proof: Box< + EquivocationProof>, + >, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -245,8 +252,8 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::note_stalled())] pub fn note_stalled( origin: OriginFor, - delay: frame_system::pallet_prelude::BlockNumberFor::, - best_finalized_block_number: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, + best_finalized_block_number: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { ensure_root(origin)?; @@ -287,31 +294,45 @@ pub mod pallet { } #[pallet::type_value] - pub(super) fn DefaultForState() -> StoredState> { + pub(super) fn DefaultForState( + ) -> StoredState> { StoredState::Live } /// State of the current authority set. #[pallet::storage] #[pallet::getter(fn state)] - pub(super) type State = - StorageValue<_, StoredState>, ValueQuery, DefaultForState>; + pub(super) type State = StorageValue< + _, + StoredState>, + ValueQuery, + DefaultForState, + >; /// Pending change: (signaled at, scheduled change). #[pallet::storage] #[pallet::getter(fn pending_change)] - pub(super) type PendingChange = - StorageValue<_, StoredPendingChange, T::MaxAuthorities>>; + pub(super) type PendingChange = StorageValue< + _, + StoredPendingChange, T::MaxAuthorities>, + >; /// next block number where we can force a change. #[pallet::storage] #[pallet::getter(fn next_forced)] - pub(super) type NextForced = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::>; + pub(super) type NextForced = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor>; /// `true` if we are currently stalled. #[pallet::storage] #[pallet::getter(fn stalled)] - pub(super) type Stalled = StorageValue<_, (frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::)>; + pub(super) type Stalled = StorageValue< + _, + ( + frame_system::pallet_prelude::BlockNumberFor, + frame_system::pallet_prelude::BlockNumberFor, + ), + >; /// The number of changes (both in terms of keys and underlying economic responsibilities) /// in the "set" of Grandpa validators from genesis. @@ -427,7 +448,9 @@ impl Pallet { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { + pub fn schedule_pause( + in_blocks: frame_system::pallet_prelude::BlockNumberFor, + ) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at }); @@ -439,7 +462,9 @@ impl Pallet { } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: frame_system::pallet_prelude::BlockNumberFor::) -> DispatchResult { + pub fn schedule_resume( + in_blocks: frame_system::pallet_prelude::BlockNumberFor, + ) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at }); @@ -466,8 +491,8 @@ impl Pallet { /// an error if a change is already pending. pub fn schedule_change( next_authorities: AuthorityList, - in_blocks: frame_system::pallet_prelude::BlockNumberFor::, - forced: Option>, + in_blocks: frame_system::pallet_prelude::BlockNumberFor, + forced: Option>, ) -> DispatchResult { if !>::exists() { let scheduled_at = >::block_number(); @@ -504,7 +529,7 @@ impl Pallet { } /// Deposit one of this module's logs. - fn deposit_log(log: ConsensusLog>) { + fn deposit_log(log: ConsensusLog>) { let log = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); >::deposit_log(log); } @@ -528,13 +553,19 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof>, + equivocation_proof: EquivocationProof< + T::Hash, + frame_system::pallet_prelude::BlockNumberFor, + >, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() } - fn on_stalled(further_wait: frame_system::pallet_prelude::BlockNumberFor::, median: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_stalled( + further_wait: frame_system::pallet_prelude::BlockNumberFor, + median: frame_system::pallet_prelude::BlockNumberFor, + ) { // when we record old authority sets we could try to figure out _who_ // failed. until then, we can't meaningfully guard against // `next == last` the way that normal session changes do. diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 17247804d52fe..ecd39307396db 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -42,7 +42,6 @@ use sp_runtime::{ }; use sp_staking::{EraIndex, SessionIndex}; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 730d2417de170..a283d77e65575 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -28,10 +28,7 @@ use frame_support::{ }; use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; -use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BadOrigin, BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/im-online/src/benchmarking.rs b/frame/im-online/src/benchmarking.rs index 16c0eb5b2f5d3..d8170d4817e3e 100644 --- a/frame/im-online/src/benchmarking.rs +++ b/frame/im-online/src/benchmarking.rs @@ -36,7 +36,10 @@ const MAX_KEYS: u32 = 1000; pub fn create_heartbeat( k: u32, ) -> Result< - (crate::Heartbeat>, ::Signature), + ( + crate::Heartbeat>, + ::Signature, + ), &'static str, > { let mut keys = Vec::new(); diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 0aae15ee6fe82..8e46d02ddce22 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -287,7 +287,9 @@ pub mod pallet { /// rough time when we should start considering sending heartbeats, since the workers /// avoids sending them at the very beginning of the session, assuming there is a /// chance the authority will produce a block and they won't be necessary. - type NextSessionRotation: EstimateNextSessionRotation>; + type NextSessionRotation: EstimateNextSessionRotation< + frame_system::pallet_prelude::BlockNumberFor, + >; /// A type that gives us the ability to submit unresponsiveness offence reports. type ReportUnresponsiveness: ReportOffence< @@ -339,7 +341,8 @@ pub mod pallet { /// more accurate then the value we calculate for `HeartbeatAfter`. #[pallet::storage] #[pallet::getter(fn heartbeat_after)] - pub(super) type HeartbeatAfter = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; + pub(super) type HeartbeatAfter = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; /// The current set of keys that may issue a heartbeat. #[pallet::storage] @@ -393,7 +396,7 @@ pub mod pallet { ))] pub fn heartbeat( origin: OriginFor, - heartbeat: Heartbeat>, + heartbeat: Heartbeat>, // since signature verification is done in `validate_unsigned` // we can skip doing it here again. _signature: ::Signature, @@ -505,7 +508,8 @@ pub mod pallet { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of being online. impl - pallet_authorship::EventHandler, frame_system::pallet_prelude::BlockNumberFor::> for Pallet + pallet_authorship::EventHandler, frame_system::pallet_prelude::BlockNumberFor> + for Pallet { fn note_author(author: ValidatorId) { Self::note_authorship(author); @@ -551,7 +555,7 @@ impl Pallet { } pub(crate) fn send_heartbeats( - block_number: frame_system::pallet_prelude::BlockNumberFor::, + block_number: frame_system::pallet_prelude::BlockNumberFor, ) -> OffchainResult>> { const START_HEARTBEAT_RANDOM_PERIOD: Permill = Permill::from_percent(10); const START_HEARTBEAT_FINAL_PERIOD: Permill = Permill::from_percent(80); @@ -614,7 +618,7 @@ impl Pallet { authority_index: u32, key: T::AuthorityId, session_index: SessionIndex, - block_number: frame_system::pallet_prelude::BlockNumberFor::, + block_number: frame_system::pallet_prelude::BlockNumberFor, validators_len: u32, ) -> OffchainResult { // A helper function to prepare heartbeat call. @@ -677,7 +681,7 @@ impl Pallet { fn with_heartbeat_lock( authority_index: u32, session_index: SessionIndex, - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, f: impl FnOnce() -> OffchainResult, ) -> OffchainResult { let key = { @@ -687,7 +691,10 @@ impl Pallet { }; let storage = StorageValueRef::persistent(&key); let res = storage.mutate( - |status: Result>>, StorageRetrievalError>| { + |status: Result< + Option>>, + StorageRetrievalError, + >| { // Check if there is already a lock for that particular block. // This means that the heartbeat has already been sent, and we are just waiting // for it to be included. However if it doesn't get included for INCLUDE_THRESHOLD diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 10fcf0aef796b..6a2b27e6ece0a 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -39,7 +39,6 @@ use sp_staking::{ use crate as imonline; use crate::Config; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 7667520f7c09d..a30f95fa5e437 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -78,7 +78,9 @@ use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; -fn block_number_to_index(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> usize { +fn block_number_to_index( + block_number: frame_system::pallet_prelude::BlockNumberFor, +) -> usize { // on_initialize is called on the first block after genesis let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); index.try_into().ok().expect("Something % 81 is always smaller than usize; qed") @@ -100,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(block_number: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(block_number: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let parent_hash = >::parent_hash(); >::mutate(|ref mut values| { @@ -123,7 +125,7 @@ pub mod pallet { StorageValue<_, BoundedVec>, ValueQuery>; } -impl Randomness> for Pallet { +impl Randomness> for Pallet { /// This randomness uses a low-influence function, drawing upon the block hashes from the /// previous 81 blocks. Its result for any given subject will be known far in advance by anyone /// observing the chain. Any block producer has significant influence over their block hashes @@ -134,7 +136,7 @@ impl Randomness (T::Hash, frame_system::pallet_prelude::BlockNumberFor::) { + fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { let block_number = >::block_number(); let index = block_number_to_index::(block_number); @@ -163,9 +165,7 @@ mod tests { use crate as pallet_insecure_randomness_collective_flip; use sp_core::H256; - use sp_runtime::{ - traits::{BlakeTwo256, Header as _, IdentityLookup}, - }; + use sp_runtime::traits::{BlakeTwo256, Header as _, IdentityLookup}; use frame_support::{ parameter_types, @@ -173,7 +173,6 @@ mod tests { }; use frame_system::limits; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 86012c8f789cb..4c7d200a51569 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -207,8 +207,10 @@ pub mod pallet { /// The configuration for the current lottery. #[pallet::storage] - pub(crate) type Lottery = - StorageValue<_, LotteryConfig, BalanceOf>>; + pub(crate) type Lottery = StorageValue< + _, + LotteryConfig, BalanceOf>, + >; /// Users who have purchased a ticket. (Lottery Index, Tickets Purchased) #[pallet::storage] @@ -239,7 +241,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { Lottery::::mutate(|mut lottery| -> Weight { if let Some(config) = &mut lottery { let payout_block = @@ -350,8 +352,8 @@ pub mod pallet { pub fn start_lottery( origin: OriginFor, price: BalanceOf, - length: frame_system::pallet_prelude::BlockNumberFor::, - delay: frame_system::pallet_prelude::BlockNumberFor::, + length: frame_system::pallet_prelude::BlockNumberFor, + delay: frame_system::pallet_prelude::BlockNumberFor, repeat: bool, ) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 65ec39af371a1..c200a8ff40ba4 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -28,11 +28,10 @@ use frame_support_test::TestRandomness; use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index e17007d68760e..f87da5f93858d 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -523,9 +523,7 @@ mod tests { use crate as pallet_membership; use sp_core::H256; - use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - }; + use sp_runtime::traits::{BadOrigin, BlakeTwo256, IdentityLookup}; use frame_support::{ assert_noop, assert_ok, bounded_vec, ord_parameter_types, parameter_types, @@ -533,7 +531,6 @@ mod tests { }; use frame_system::EnsureSignedBy; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index bc19280e64dda..1e5fb35bbe8e1 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -91,7 +91,8 @@ pub struct ParentNumberAndHash { } impl LeafDataProvider for ParentNumberAndHash { - type LeafData = (frame_system::pallet_prelude::BlockNumberFor, ::Hash); + type LeafData = + (frame_system::pallet_prelude::BlockNumberFor, ::Hash); fn leaf_data() -> Self::LeafData { ( @@ -201,7 +202,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { use primitives::LeafDataProvider; let leaves = Self::mmr_leaves(); let peaks_before = sp_mmr_primitives::utils::NodesUtils::new(leaves).number_of_peaks(); @@ -298,16 +299,20 @@ impl, I: 'static> Pallet { } /// Convert a block number into a leaf index. - fn block_num_to_leaf_index(block_num: frame_system::pallet_prelude::BlockNumberFor::) -> Result + fn block_num_to_leaf_index( + block_num: frame_system::pallet_prelude::BlockNumberFor, + ) -> Result where T: frame_system::Config, { - let first_mmr_block = utils::first_mmr_block_num::>( - >::block_number(), - Self::mmr_leaves(), - )?; + let first_mmr_block = utils::first_mmr_block_num::< + frame_system::pallet_prelude::HeaderFor, + >(>::block_number(), Self::mmr_leaves())?; - utils::block_num_to_leaf_index::>(block_num, first_mmr_block) + utils::block_num_to_leaf_index::>( + block_num, + first_mmr_block, + ) } /// Generate an MMR proof for the given `block_numbers`. @@ -320,8 +325,8 @@ impl, I: 'static> Pallet { /// all the leaves to be present. /// It may return an error or panic if used incorrectly. pub fn generate_proof( - block_numbers: Vec>, - best_known_block_number: Option>, + block_numbers: Vec>, + best_known_block_number: Option>, ) -> Result<(Vec>, primitives::Proof>), primitives::Error> { // check whether best_known_block_number provided, else use current best block let best_known_block_number = diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index cafe23ed94330..ffc4b147ae5b1 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -25,10 +25,7 @@ use frame_support::{ }; use sp_core::H256; use sp_mmr_primitives::{Compact, LeafDataProvider}; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup, Keccak256}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Keccak256}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index df399f9c46eeb..172b1b4a7351f 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -37,12 +37,9 @@ use frame_support::{ use rand::{rngs::StdRng, Rng, SeedableRng}; use rand_distr::Pareto; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use std::collections::{BTreeMap, BTreeSet}; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index a0f4c7c9a17ab..51151f6318787 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -28,12 +28,9 @@ use frame_support::{ traits::{ConstU32, ConstU64}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_std::collections::btree_map::BTreeMap; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index ef475100b9bfa..56e5c6c60a947 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -183,7 +183,12 @@ pub mod pallet { T::AccountId, Blake2_128Concat, [u8; 32], - Multisig, BalanceOf, T::AccountId, T::MaxSignatories>, + Multisig< + frame_system::pallet_prelude::BlockNumberFor, + BalanceOf, + T::AccountId, + T::MaxSignatories, + >, >; #[pallet::error] @@ -226,14 +231,14 @@ pub mod pallet { /// A multisig operation has been approved by someone. MultisigApproval { approving: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, /// A multisig operation has been executed. MultisigExecuted { approving: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, result: DispatchResult, @@ -241,7 +246,7 @@ pub mod pallet { /// A multisig operation has been cancelled. MultisigCancelled { cancelling: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, @@ -366,7 +371,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call: Box<::RuntimeCall>, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -423,7 +428,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call_hash: [u8; 32], max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -465,7 +470,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - timepoint: Timepoint>, + timepoint: Timepoint>, call_hash: [u8; 32], ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -511,7 +516,7 @@ impl Pallet { who: T::AccountId, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call_or_hash: CallOrHash, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -637,7 +642,7 @@ impl Pallet { } /// The current `Timepoint`. - pub fn timepoint() -> Timepoint> { + pub fn timepoint() -> Timepoint> { Timepoint { height: >::block_number(), index: >::extrinsic_index().unwrap_or_default(), diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 0d542b566a215..bdb5ae5a18210 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -28,11 +28,10 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, TokenError, }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 51927aaa1b4a8..63b829577d46d 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -58,8 +58,14 @@ where fn mint_nft(nft_id: T::NftId) -> (T::AccountId, AccountIdLookupOf) where - T::Nfts: Create, frame_system::pallet_prelude::BlockNumberFor::, T::NftCollectionId>> - + Mutate, + T::Nfts: Create< + T::AccountId, + CollectionConfig< + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + T::NftCollectionId, + >, + > + Mutate, { let caller: T::AccountId = whitelisted_caller(); let caller_lookup = T::Lookup::unlookup(caller.clone()); diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 1781a6592f0bf..e68852b24c190 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -29,11 +29,10 @@ use frame_system::EnsureSigned; use pallet_nfts::PalletFeatures; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, MultiSignature, }; - type Block = frame_system::mocking::MockBlock; type Signature = MultiSignature; type AccountPublic = ::Signer; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 250c597b8ce2e..7a96654366df4 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -27,11 +27,10 @@ use frame_support::{ use sp_core::H256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, MultiSignature, }; - type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index f78a5bbd575d9..5f17c79f322dd 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -238,11 +238,8 @@ mod tests { }; use frame_system::EnsureSignedBy; use sp_core::H256; - use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, - }; + use sp_runtime::traits::{BadOrigin, BlakeTwo256, IdentityLookup}; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 2bebd28ee649f..cfe8a6674adc1 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -192,7 +192,8 @@ pub mod pallet { BalanceOf, >; type IssuanceInfoOf = IssuanceInfo>; - type SummaryRecordOf = SummaryRecord, BalanceOf>; + type SummaryRecordOf = + SummaryRecord, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; @@ -413,7 +414,7 @@ pub mod pallet { /// The identity of the receipt. index: ReceiptIndex, /// The block number at which the receipt may be thawed. - expiry: frame_system::pallet_prelude::BlockNumberFor::, + expiry: frame_system::pallet_prelude::BlockNumberFor, /// The owner of the receipt. who: T::AccountId, /// The proportion of the effective total issuance which the receipt represents. @@ -508,7 +509,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let mut weight_counter = WeightCounter { used: Weight::zero(), limit: T::MaxIntakeWeight::get() }; if T::IntakePeriod::get().is_zero() || (n % T::IntakePeriod::get()).is_zero() { @@ -1062,7 +1063,7 @@ pub mod pallet { pub(crate) fn process_queue( duration: u32, - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, our_account: &T::AccountId, issuance: &IssuanceInfo>, max_bids: u32, @@ -1106,7 +1107,7 @@ pub mod pallet { pub(crate) fn process_bid( mut bid: BidOf, - expiry: frame_system::pallet_prelude::BlockNumberFor::, + expiry: frame_system::pallet_prelude::BlockNumberFor, _our_account: &T::AccountId, issuance: &IssuanceInfo>, remaining: &mut BalanceOf, diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index e24ebf3f6673b..30128bbfe0dcc 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -30,10 +30,7 @@ use frame_support::{ }; use pallet_balances::{Instance1, Instance2}; use sp_core::{ConstU128, H256}; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 2ee10d55c5390..faf8400fccecd 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -169,7 +169,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Set reserved node every block. It may not be enabled depends on the offchain /// worker settings when starting the node. - fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor::) { + fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { let network_state = sp_io::offchain::network_state(); match network_state { Err(_) => log::error!( diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index 2142afbc0c8ab..6d915c2b7e048 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -26,15 +26,12 @@ use frame_support::{ }; use frame_system::EnsureSignedBy; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, NodeAuthorization: pallet_node_authorization::{ diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 556600ebf9f4e..fcc901bbfc614 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -676,10 +676,10 @@ pub struct Commission { pub max: Option, /// Optional configuration around how often commission can be updated, and when the last /// commission update took place. - pub change_rate: Option>>, + pub change_rate: Option>>, /// The block from where throttling should be checked from. This value will be updated on all /// commission updates and when setting an initial `change_rate`. - pub throttle_from: Option>, + pub throttle_from: Option>, } impl Commission { @@ -813,7 +813,7 @@ impl Commission { /// throttling can be checked from this block. fn try_update_change_rate( &mut self, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, ) -> DispatchResult { ensure!(!&self.less_restrictive(&change_rate), Error::::CommissionChangeRateNotAllowed); @@ -833,7 +833,10 @@ impl Commission { /// /// No change rate will always be less restrictive than some change rate, so where no /// `change_rate` is currently set, `false` is returned. - fn less_restrictive(&self, new: &CommissionChangeRate>) -> bool { + fn less_restrictive( + &self, + new: &CommissionChangeRate>, + ) -> bool { self.change_rate .as_ref() .map(|c| new.max_increase > c.max_increase || new.min_delay < c.min_delay) @@ -1761,7 +1764,7 @@ pub mod pallet { /// A pool's commission `change_rate` has been changed. PoolCommissionChangeRateUpdated { pool_id: PoolId, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, }, /// Pool commission has been claimed. PoolCommissionClaimed { pool_id: PoolId, commission: BalanceOf }, @@ -2597,7 +2600,7 @@ pub mod pallet { pub fn set_commission_change_rate( origin: OriginFor, pool_id: PoolId, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, ) -> DispatchResult { let who = ensure_signed(origin)?; let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 55083e1833391..84812c0b3dd83 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -244,7 +244,6 @@ impl pools::Config for Runtime { type MaxPointsToBalance = frame_support::traits::ConstU8<10>; } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( pub struct Runtime diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 676919f3de1d1..b2eb804266d59 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -187,7 +187,6 @@ impl pallet_nomination_pools::Config for Runtime { type Block = frame_system::mocking::MockBlock; - frame_support::construct_runtime!( pub struct Runtime { diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 9261cd16d170e..969c828405a27 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -27,10 +27,7 @@ use frame_support::{ }; use frame_system as system; use pallet_session::historical as pallet_session_historical; -use sp_runtime::{ - testing::{UintAuthorityId}, - traits::IdentityLookup, -}; +use sp_runtime::{testing::UintAuthorityId, traits::IdentityLookup}; type AccountId = u64; type AccountIndex = u32; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index a02aaaf635675..c7ac8f908bd01 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -29,7 +29,7 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; use sp_staking::{ @@ -65,7 +65,6 @@ pub fn with_on_offence_fractions) -> R>(f: F) -> OnOffencePerbill::mutate(|fractions| f(fractions)) } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 2fe795b108765..90b66b16d2ece 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -27,10 +27,7 @@ use frame_support::{ }; use frame_system::EnsureSignedBy; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index c38c00e1d6aa0..a985181bbb3b0 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -227,7 +227,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -247,7 +247,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -291,7 +291,7 @@ pub mod pallet { pub fn create_pure( origin: OriginFor, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, index: u16, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -341,7 +341,7 @@ pub mod pallet { spawner: AccountIdLookupOf, proxy_type: T::ProxyType, index: u16, - #[pallet::compact] height: frame_system::pallet_prelude::BlockNumberFor::, + #[pallet::compact] height: frame_system::pallet_prelude::BlockNumberFor, #[pallet::compact] ext_index: u32, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -535,14 +535,14 @@ pub mod pallet { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, }, /// A proxy was removed. ProxyRemoved { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, }, } @@ -575,7 +575,14 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec>, T::MaxProxies>, + BoundedVec< + ProxyDefinition< + T::AccountId, + T::ProxyType, + frame_system::pallet_prelude::BlockNumberFor, + >, + T::MaxProxies, + >, BalanceOf, ), ValueQuery, @@ -589,7 +596,14 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec, frame_system::pallet_prelude::BlockNumberFor::>, T::MaxPending>, + BoundedVec< + Announcement< + T::AccountId, + CallHashOf, + frame_system::pallet_prelude::BlockNumberFor, + >, + T::MaxPending, + >, BalanceOf, ), ValueQuery, @@ -612,7 +626,7 @@ impl Pallet { who: &T::AccountId, proxy_type: &T::ProxyType, index: u16, - maybe_when: Option<(frame_system::pallet_prelude::BlockNumberFor::, u32)>, + maybe_when: Option<(frame_system::pallet_prelude::BlockNumberFor, u32)>, ) -> T::AccountId { let (height, ext_index) = maybe_when.unwrap_or_else(|| { ( @@ -638,7 +652,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { ensure!(delegator != &delegatee, Error::::NoSelfProxy); Proxies::::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| { @@ -678,7 +692,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor::, + delay: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { Proxies::::try_mutate_exists(delegator, |x| { let (mut proxies, old_deposit) = x.take().ok_or(Error::::NotFound)?; @@ -734,7 +748,13 @@ impl Pallet { } fn edit_announcements< - F: FnMut(&Announcement, frame_system::pallet_prelude::BlockNumberFor::>) -> bool, + F: FnMut( + &Announcement< + T::AccountId, + CallHashOf, + frame_system::pallet_prelude::BlockNumberFor, + >, + ) -> bool, >( delegate: &T::AccountId, f: F, @@ -760,8 +780,20 @@ impl Pallet { real: &T::AccountId, delegate: &T::AccountId, force_proxy_type: Option, - ) -> Result>, DispatchError> { - let f = |x: &ProxyDefinition>| -> bool { + ) -> Result< + ProxyDefinition< + T::AccountId, + T::ProxyType, + frame_system::pallet_prelude::BlockNumberFor, + >, + DispatchError, + > { + let f = |x: &ProxyDefinition< + T::AccountId, + T::ProxyType, + frame_system::pallet_prelude::BlockNumberFor, + >| + -> bool { &x.delegate == delegate && force_proxy_type.as_ref().map_or(true, |y| &x.proxy_type == y) }; @@ -769,7 +801,11 @@ impl Pallet { } fn do_proxy( - def: ProxyDefinition>, + def: ProxyDefinition< + T::AccountId, + T::ProxyType, + frame_system::pallet_prelude::BlockNumberFor, + >, real: T::AccountId, call: ::RuntimeCall, ) { diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index fa50486e0e0e8..f3ddcba38d1a1 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -30,10 +30,7 @@ use frame_support::{ RuntimeDebug, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 2a8ab209ae85f..93886bffa2708 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -391,7 +391,11 @@ pub mod pallet { type DemoteOrigin: EnsureOrigin; /// The polling system used for our voting. - type Polls: Polling, Votes = Votes, Moment = frame_system::pallet_prelude::BlockNumberFor>; + type Polls: Polling< + TallyOf, + Votes = Votes, + Moment = frame_system::pallet_prelude::BlockNumberFor, + >; /// Convert the tally class into the minimum rank required to vote on the poll. If /// `Polls::Class` is the same type as `Rank`, then `Identity` can be used here to mean diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 14e6266c7d42d..7a728cb535447 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -26,14 +26,11 @@ use frame_support::{ traits::{ConstU16, ConstU32, ConstU64, EitherOf, Everything, MapSuccess, Polling}, }; use sp_core::{Get, H256}; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup, ReduceBy}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup, ReduceBy}; use super::*; use crate as pallet_ranked_collective; - type Block = frame_system::mocking::MockBlock; type Class = Rank; diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 6d0fe55925899..d58e88911a691 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -338,7 +338,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - RecoveryConfig, BalanceOf, FriendsOf>, + RecoveryConfig, BalanceOf, FriendsOf>, >; /// Active recovery attempts. @@ -353,7 +353,7 @@ pub mod pallet { T::AccountId, Twox64Concat, T::AccountId, - ActiveRecovery, BalanceOf, FriendsOf>, + ActiveRecovery, BalanceOf, FriendsOf>, >; /// The list of allowed proxy accounts. @@ -444,7 +444,7 @@ pub mod pallet { origin: OriginFor, friends: Vec, threshold: u16, - delay_period: frame_system::pallet_prelude::BlockNumberFor::, + delay_period: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; // Check account is not already set up for recovery diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index cf23462b69fa0..2d41a850b64c8 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -25,10 +25,7 @@ use frame_support::{ traits::{ConstU32, ConstU64, OnFinalize, OnInitialize}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 574116d042de0..d4b273c0307a3 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -172,7 +172,9 @@ fn skip_timeout_period, I: 'static>(index: ReferendumIndex) { frame_system::Pallet::::set_block_number(timeout_period_over); } -fn alarm_time, I: 'static>(index: ReferendumIndex) -> frame_system::pallet_prelude::BlockNumberFor:: { +fn alarm_time, I: 'static>( + index: ReferendumIndex, +) -> frame_system::pallet_prelude::BlockNumberFor { let status = Referenda::::ensure_ongoing(index).unwrap(); status.alarm.unwrap().0 } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 83d70a0494ec2..5d2574ce08b5b 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -161,8 +161,15 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// The Scheduler. - type Scheduler: ScheduleAnon, CallOf, PalletsOriginOf> - + ScheduleNamed, CallOf, PalletsOriginOf>; + type Scheduler: ScheduleAnon< + frame_system::pallet_prelude::BlockNumberFor, + CallOf, + PalletsOriginOf, + > + ScheduleNamed< + frame_system::pallet_prelude::BlockNumberFor, + CallOf, + PalletsOriginOf, + >; /// Currency type for this pallet. type Currency: ReservableCurrency; // Origins and unbalances. @@ -214,8 +221,14 @@ pub mod pallet { #[pallet::constant] type Tracks: Get< Vec<( - , frame_system::pallet_prelude::BlockNumberFor>>::Id, - TrackInfo, frame_system::pallet_prelude::BlockNumberFor>, + , + frame_system::pallet_prelude::BlockNumberFor, + >>::Id, + TrackInfo< + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + >, )>, > + TracksInfo< BalanceOf, @@ -432,7 +445,7 @@ pub mod pallet { origin: OriginFor, proposal_origin: Box>, proposal: BoundedCallOf, - enactment_moment: DispatchTime>, + enactment_moment: DispatchTime>, ) -> DispatchResult { let proposal_origin = *proposal_origin; let who = T::SubmitOrigin::ensure_origin(origin, &proposal_origin)?; @@ -704,7 +717,7 @@ pub mod pallet { impl, I: 'static> Polling for Pallet { type Index = ReferendumIndex; type Votes = VotesOf; - type Moment = frame_system::pallet_prelude::BlockNumberFor::; + type Moment = frame_system::pallet_prelude::BlockNumberFor; type Class = TrackIdOf; fn classes() -> Vec { @@ -713,7 +726,13 @@ impl, I: 'static> Polling for Pallet { fn access_poll( index: Self::Index, - f: impl FnOnce(PollStatus<&mut T::Tally, frame_system::pallet_prelude::BlockNumberFor::, TrackIdOf>) -> R, + f: impl FnOnce( + PollStatus< + &mut T::Tally, + frame_system::pallet_prelude::BlockNumberFor, + TrackIdOf, + >, + ) -> R, ) -> R { match ReferendumInfoFor::::get(index) { Some(ReferendumInfo::Ongoing(mut status)) => { @@ -732,7 +751,11 @@ impl, I: 'static> Polling for Pallet { fn try_access_poll( index: Self::Index, f: impl FnOnce( - PollStatus<&mut T::Tally, frame_system::pallet_prelude::BlockNumberFor::, TrackIdOf>, + PollStatus< + &mut T::Tally, + frame_system::pallet_prelude::BlockNumberFor, + TrackIdOf, + >, ) -> Result, ) -> Result { match ReferendumInfoFor::::get(index) { @@ -849,7 +872,7 @@ impl, I: 'static> Pallet { fn schedule_enactment( index: ReferendumIndex, track: &TrackInfoOf, - desired: DispatchTime>, + desired: DispatchTime>, origin: PalletsOriginOf, call: BoundedCallOf, ) { @@ -871,8 +894,8 @@ impl, I: 'static> Pallet { /// Set an alarm to dispatch `call` at block number `when`. fn set_alarm( call: BoundedCallOf, - when: frame_system::pallet_prelude::BlockNumberFor::, - ) -> Option<(frame_system::pallet_prelude::BlockNumberFor::, ScheduleAddressOf)> { + when: frame_system::pallet_prelude::BlockNumberFor, + ) -> Option<(frame_system::pallet_prelude::BlockNumberFor, ScheduleAddressOf)> { let alarm_interval = T::AlarmInterval::get().max(One::one()); // Alarm must go off no earlier than `when`. // This rounds `when` upwards to the next multiple of `alarm_interval`. @@ -905,9 +928,9 @@ impl, I: 'static> Pallet { fn begin_deciding( status: &mut ReferendumStatusOf, index: ReferendumIndex, - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, track: &TrackInfoOf, - ) -> (Option>, BeginDecidingBranch) { + ) -> (Option>, BeginDecidingBranch) { let is_passing = Self::is_passing( &status.tally, Zero::zero(), @@ -943,11 +966,11 @@ impl, I: 'static> Pallet { /// /// If `None`, then it is queued and should be nudged automatically as the queue gets drained. fn ready_for_deciding( - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, track: &TrackInfoOf, index: ReferendumIndex, status: &mut ReferendumStatusOf, - ) -> (Option>, ServiceBranch) { + ) -> (Option>, ServiceBranch) { let deciding_count = DecidingCount::::get(status.track); if deciding_count < track.max_deciding { // Begin deciding. @@ -1004,7 +1027,7 @@ impl, I: 'static> Pallet { fn ensure_alarm_at( status: &mut ReferendumStatusOf, index: ReferendumIndex, - alarm: frame_system::pallet_prelude::BlockNumberFor::, + alarm: frame_system::pallet_prelude::BlockNumberFor, ) -> bool { if status.alarm.as_ref().map_or(true, |&(when, _)| when != alarm) { // Either no alarm or one that was different @@ -1049,7 +1072,7 @@ impl, I: 'static> Pallet { /// `TrackQueue`. Basically this happens when a referendum is in the deciding queue and receives /// a vote, or when it moves into the deciding queue. fn service_referendum( - now: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, index: ReferendumIndex, mut status: ReferendumStatusOf, ) -> (ReferendumInfoOf, bool, ServiceBranch) { @@ -1192,7 +1215,8 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = if alarm < frame_system::pallet_prelude::BlockNumberFor::::max_value() { + let dirty_alarm = if alarm < frame_system::pallet_prelude::BlockNumberFor::::max_value() + { Self::ensure_alarm_at(&mut status, index, alarm) } else { Self::ensure_no_alarm(&mut status) @@ -1207,7 +1231,7 @@ impl, I: 'static> Pallet { tally: &T::Tally, track_id: TrackIdOf, track: &TrackInfoOf, - ) -> frame_system::pallet_prelude::BlockNumberFor:: { + ) -> frame_system::pallet_prelude::BlockNumberFor { deciding.confirming.unwrap_or_else(|| { // Set alarm to the point where the current voting would make it pass. let approval = tally.approval(track_id); @@ -1266,8 +1290,8 @@ impl, I: 'static> Pallet { /// `approval_needed`. fn is_passing( tally: &T::Tally, - elapsed: frame_system::pallet_prelude::BlockNumberFor::, - period: frame_system::pallet_prelude::BlockNumberFor::, + elapsed: frame_system::pallet_prelude::BlockNumberFor, + period: frame_system::pallet_prelude::BlockNumberFor, support_needed: &Curve, approval_needed: &Curve, id: TrackIdOf, diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 2965f2c8e7a34..00c976a8fe5af 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -31,11 +31,10 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Hash, IdentityLookup}, + traits::{BlakeTwo256, Hash, IdentityLookup}, DispatchResult, Perbill, }; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 9111dcf0155a6..11b7dac1130e4 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -21,11 +21,10 @@ use crate as pallet_remark; use frame_support::traits::{ConstU16, ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; - pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index d71a31c03ee9b..e5e5da061bd1f 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -27,13 +27,12 @@ use pallet_staking::StakerStatus; use sp_core::H256; use sp_runtime::{ curve::PiecewiseLinear, - testing::{UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup, Zero}, }; use sp_staking::{EraIndex, SessionIndex}; use sp_std::collections::btree_map::BTreeMap; - type Block = frame_system::mocking::MockBlock; type AccountId = u64; type Balance = u64; diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 0d0ed2f761a3e..3aa8600e9cc30 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -145,8 +145,11 @@ pub mod pallet { pub type CycleIndexOf = frame_system::pallet_prelude::BlockNumberFor; pub type BalanceOf = <>::Paymaster as Pay>::Balance; pub type IdOf = <>::Paymaster as Pay>::Id; - pub type StatusOf = - StatusType, frame_system::pallet_prelude::BlockNumberFor, BalanceOf>; + pub type StatusOf = StatusType< + CycleIndexOf, + frame_system::pallet_prelude::BlockNumberFor, + BalanceOf, + >; pub type ClaimantStatusOf = ClaimantStatus, BalanceOf, IdOf>; /// The overall status of the system. @@ -389,7 +392,7 @@ pub mod pallet { pub fn last_active(who: &T::AccountId) -> Result, DispatchError> { Ok(Claimant::::get(&who).ok_or(Error::::NotInducted)?.last_active) } - pub fn cycle_period() -> frame_system::pallet_prelude::BlockNumberFor:: { + pub fn cycle_period() -> frame_system::pallet_prelude::BlockNumberFor { T::RegistrationPeriod::get() + T::PayoutPeriod::get() } fn do_payout(who: T::AccountId, beneficiary: T::AccountId) -> DispatchResult { diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index fed65d9767f07..8f501bac4e38f 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -27,7 +27,7 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Identity, IdentityLookup}, + traits::{BlakeTwo256, Identity, IdentityLookup}, DispatchResult, }; use sp_std::cell::RefCell; @@ -35,7 +35,6 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_salary; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index b67f896b4b8e7..db9524f26ba6b 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -42,7 +42,10 @@ type SystemOrigin = ::RuntimeOrigin; /// - `None`: aborted (hash without preimage) /// - `Some(true)`: hash resolves into call if possible, plain call otherwise /// - `Some(false)`: plain call -fn fill_schedule(when: frame_system::pallet_prelude::BlockNumberFor::, n: u32) -> Result<(), &'static str> { +fn fill_schedule( + when: frame_system::pallet_prelude::BlockNumberFor, + n: u32, +) -> Result<(), &'static str> { let t = DispatchTime::At(when); let origin: ::PalletsOrigin = frame_system::RawOrigin::Root.into(); for i in 0..n { diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 255882040b68c..c3eb1d1160fc3 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -231,14 +231,15 @@ pub mod pallet { } #[pallet::storage] - pub type IncompleteSince = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::>; + pub type IncompleteSince = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor>; /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] pub type Agenda = StorageMap< _, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor, BoundedVec>, T::MaxScheduledPerBlock>, ValueQuery, >; @@ -248,29 +249,42 @@ pub mod pallet { /// For v3 -> v4 the previously unbounded identities are Blake2-256 hashed to form the v4 /// identities. #[pallet::storage] - pub(crate) type Lookup = - StorageMap<_, Twox64Concat, TaskName, TaskAddress>>; + pub(crate) type Lookup = StorageMap< + _, + Twox64Concat, + TaskName, + TaskAddress>, + >; /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Scheduled some task. - Scheduled { when: frame_system::pallet_prelude::BlockNumberFor::, index: u32 }, + Scheduled { when: frame_system::pallet_prelude::BlockNumberFor, index: u32 }, /// Canceled some task. - Canceled { when: frame_system::pallet_prelude::BlockNumberFor::, index: u32 }, + Canceled { when: frame_system::pallet_prelude::BlockNumberFor, index: u32 }, /// Dispatched some task. Dispatched { - task: TaskAddress>, + task: TaskAddress>, id: Option, result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. - CallUnavailable { task: TaskAddress>, id: Option }, + CallUnavailable { + task: TaskAddress>, + id: Option, + }, /// The given task was unable to be renewed since the agenda is full at that block. - PeriodicFailed { task: TaskAddress>, id: Option }, + PeriodicFailed { + task: TaskAddress>, + id: Option, + }, /// The given task can never be executed since it is overweight. - PermanentlyOverweight { task: TaskAddress>, id: Option }, + PermanentlyOverweight { + task: TaskAddress>, + id: Option, + }, } #[pallet::error] @@ -290,7 +304,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Execute the scheduled calls - fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let mut weight_counter = WeightMeter::from_limit(T::MaximumWeight::get()); Self::service_agendas(&mut weight_counter, now, u32::max_value()); weight_counter.consumed @@ -304,8 +318,10 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule( origin: OriginFor, - when: frame_system::pallet_prelude::BlockNumberFor::, - maybe_periodic: Option>>, + when: frame_system::pallet_prelude::BlockNumberFor, + maybe_periodic: Option< + schedule::Period>, + >, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -324,7 +340,11 @@ pub mod pallet { /// Cancel an anonymously scheduled task. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] - pub fn cancel(origin: OriginFor, when: frame_system::pallet_prelude::BlockNumberFor::, index: u32) -> DispatchResult { + pub fn cancel( + origin: OriginFor, + when: frame_system::pallet_prelude::BlockNumberFor, + index: u32, + ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; let origin = ::RuntimeOrigin::from(origin); Self::do_cancel(Some(origin.caller().clone()), (when, index))?; @@ -337,8 +357,10 @@ pub mod pallet { pub fn schedule_named( origin: OriginFor, id: TaskName, - when: frame_system::pallet_prelude::BlockNumberFor::, - maybe_periodic: Option>>, + when: frame_system::pallet_prelude::BlockNumberFor, + maybe_periodic: Option< + schedule::Period>, + >, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -370,8 +392,10 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule_after( origin: OriginFor, - after: frame_system::pallet_prelude::BlockNumberFor::, - maybe_periodic: Option>>, + after: frame_system::pallet_prelude::BlockNumberFor, + maybe_periodic: Option< + schedule::Period>, + >, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -393,8 +417,10 @@ pub mod pallet { pub fn schedule_named_after( origin: OriginFor, id: TaskName, - after: frame_system::pallet_prelude::BlockNumberFor::, - maybe_periodic: Option>>, + after: frame_system::pallet_prelude::BlockNumberFor, + maybe_periodic: Option< + schedule::Period>, + >, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -434,7 +460,14 @@ impl> Pallet { } Agenda::::translate::< - Vec::RuntimeCall, frame_system::pallet_prelude::BlockNumberFor::>>>, + Vec< + Option< + ScheduledV1< + ::RuntimeCall, + frame_system::pallet_prelude::BlockNumberFor, + >, + >, + >, _, >(|_, agenda| { Some(BoundedVec::truncate_from( @@ -669,7 +702,7 @@ impl Pallet { Scheduled< TaskName, Bounded<::RuntimeCall>, - frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor, OldOrigin, T::AccountId, >, @@ -695,7 +728,9 @@ impl Pallet { }); } - fn resolve_time(when: DispatchTime>) -> Result, DispatchError> { + fn resolve_time( + when: DispatchTime>, + ) -> Result, DispatchError> { let now = frame_system::Pallet::::block_number(); let when = match when { @@ -713,9 +748,12 @@ impl Pallet { } fn place_task( - when: frame_system::pallet_prelude::BlockNumberFor::, + when: frame_system::pallet_prelude::BlockNumberFor, what: ScheduledOf, - ) -> Result>, (DispatchError, ScheduledOf)> { + ) -> Result< + TaskAddress>, + (DispatchError, ScheduledOf), + > { let maybe_name = what.maybe_id; let index = Self::push_to_agenda(when, what)?; let address = (when, index); @@ -727,7 +765,7 @@ impl Pallet { } fn push_to_agenda( - when: frame_system::pallet_prelude::BlockNumberFor::, + when: frame_system::pallet_prelude::BlockNumberFor, what: ScheduledOf, ) -> Result)> { let mut agenda = Agenda::::get(when); @@ -749,7 +787,7 @@ impl Pallet { /// Remove trailing `None` items of an agenda at `when`. If all items are `None` remove the /// agenda record entirely. - fn cleanup_agenda(when: frame_system::pallet_prelude::BlockNumberFor::) { + fn cleanup_agenda(when: frame_system::pallet_prelude::BlockNumberFor) { let mut agenda = Agenda::::get(when); match agenda.iter().rposition(|i| i.is_some()) { Some(i) if agenda.len() > i + 1 => { @@ -764,12 +802,12 @@ impl Pallet { } fn do_schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result>, DispatchError> { + ) -> Result>, DispatchError> { let when = Self::resolve_time(when)?; let lookup_hash = call.lookup_hash(); @@ -799,7 +837,7 @@ impl Pallet { fn do_cancel( origin: Option, - (when, index): TaskAddress>, + (when, index): TaskAddress>, ) -> Result<(), DispatchError> { let scheduled = Agenda::::try_mutate(when, |agenda| { agenda.get_mut(index as usize).map_or( @@ -831,9 +869,9 @@ impl Pallet { } fn do_reschedule( - (when, index): TaskAddress>, - new_time: DispatchTime>, - ) -> Result>, DispatchError> { + (when, index): TaskAddress>, + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; if new_time == when { @@ -853,12 +891,12 @@ impl Pallet { fn do_schedule_named( id: TaskName, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result>, DispatchError> { + ) -> Result>, DispatchError> { // ensure id it is unique if Lookup::::contains_key(&id) { return Err(Error::::FailedToSchedule.into()) @@ -922,8 +960,8 @@ impl Pallet { fn do_reschedule_named( id: TaskName, - new_time: DispatchTime>, - ) -> Result>, DispatchError> { + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; let lookup = Lookup::::get(id); @@ -953,7 +991,11 @@ use ServiceTaskError::*; impl Pallet { /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. - fn service_agendas(weight: &mut WeightMeter, now: frame_system::pallet_prelude::BlockNumberFor::, max: u32) { + fn service_agendas( + weight: &mut WeightMeter, + now: frame_system::pallet_prelude::BlockNumberFor, + max: u32, + ) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { return } @@ -983,8 +1025,8 @@ impl Pallet { fn service_agenda( weight: &mut WeightMeter, executed: &mut u32, - now: frame_system::pallet_prelude::BlockNumberFor::, - when: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, + when: frame_system::pallet_prelude::BlockNumberFor, max: u32, ) -> bool { let mut agenda = Agenda::::get(when); @@ -1052,8 +1094,8 @@ impl Pallet { /// - Rescheduling the task for execution in a later agenda if periodic. fn service_task( weight: &mut WeightMeter, - now: frame_system::pallet_prelude::BlockNumberFor::, - when: frame_system::pallet_prelude::BlockNumberFor::, + now: frame_system::pallet_prelude::BlockNumberFor, + when: frame_system::pallet_prelude::BlockNumberFor, agenda_index: u32, is_first: bool, mut task: ScheduledOf, @@ -1161,14 +1203,18 @@ impl Pallet { } impl> - schedule::v2::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Anon< + frame_system::pallet_prelude::BlockNumberFor, + ::RuntimeCall, + T::PalletsOrigin, + > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1184,26 +1230,32 @@ impl> fn reschedule( address: Self::Address, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when) } - fn next_dispatch_time((when, index): Self::Address) -> Result, ()> { + fn next_dispatch_time( + (when, index): Self::Address, + ) -> Result, ()> { Agenda::::get(when).get(index as usize).ok_or(()).map(|_| when) } } impl> - schedule::v2::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Named< + frame_system::pallet_prelude::BlockNumberFor, + ::RuntimeCall, + T::PalletsOrigin, + > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule_named( id: Vec, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1221,13 +1273,15 @@ impl> fn reschedule_named( id: Vec, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { let name = blake2_256(&id[..]); Self::do_reschedule_named(name, when) } - fn next_dispatch_time(id: Vec) -> Result, ()> { + fn next_dispatch_time( + id: Vec, + ) -> Result, ()> { let name = blake2_256(&id[..]); Lookup::::get(name) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) @@ -1235,14 +1289,18 @@ impl> } } -impl schedule::v3::Anon, ::RuntimeCall, T::PalletsOrigin> - for Pallet +impl + schedule::v3::Anon< + frame_system::pallet_prelude::BlockNumberFor, + ::RuntimeCall, + T::PalletsOrigin, + > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; fn schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1256,12 +1314,14 @@ impl schedule::v3::Anon>, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time((when, index): Self::Address) -> Result, DispatchError> { + fn next_dispatch_time( + (when, index): Self::Address, + ) -> Result, DispatchError> { Agenda::::get(when) .get(index as usize) .ok_or(DispatchError::Unavailable) @@ -1271,15 +1331,19 @@ impl schedule::v3::Anon schedule::v3::Named, ::RuntimeCall, T::PalletsOrigin> - for Pallet +impl + schedule::v3::Named< + frame_system::pallet_prelude::BlockNumberFor, + ::RuntimeCall, + T::PalletsOrigin, + > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; fn schedule_named( id: TaskName, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1293,12 +1357,14 @@ impl schedule::v3::Named>, + when: DispatchTime>, ) -> Result { Self::do_reschedule_named(id, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time(id: TaskName) -> Result, DispatchError> { + fn next_dispatch_time( + id: TaskName, + ) -> Result, DispatchError> { Lookup::::get(id) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) .ok_or(DispatchError::Unavailable) diff --git a/frame/scheduler/src/migration.rs b/frame/scheduler/src/migration.rs index ad0418b9a38b5..654d3062bf6c0 100644 --- a/frame/scheduler/src/migration.rs +++ b/frame/scheduler/src/migration.rs @@ -37,7 +37,10 @@ pub mod v1 { frame_system::pallet_prelude::BlockNumberFor, Vec< Option< - ScheduledV1<::RuntimeCall, frame_system::pallet_prelude::BlockNumberFor>, + ScheduledV1< + ::RuntimeCall, + frame_system::pallet_prelude::BlockNumberFor, + >, >, >, ValueQuery, diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 88872ab7c73a0..97605a260df31 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -30,7 +30,7 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; @@ -92,7 +92,6 @@ pub mod logger { } } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 1221ff1a06d5f..adcd05fafe98f 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -282,7 +282,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// Every `Period` blocks the `Members` set is refreshed from the /// highest scoring members in the pool. - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { if n % T::Period::get() == Zero::zero() { let pool = >::get(); >::refresh_members(pool, ChangeReceiver::MembershipChanged); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 16d6b36dff38c..df42feb530852 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -26,10 +26,7 @@ use frame_support::{ }; use frame_system::EnsureSignedBy; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index 619c51df501d4..bf2abfc4a8f33 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -46,8 +46,10 @@ pub trait Config: { } -impl OnInitialize> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> frame_support::weights::Weight { +impl OnInitialize> for Pallet { + fn on_initialize( + n: frame_system::pallet_prelude::BlockNumberFor, + ) -> frame_support::weights::Weight { pallet_session::Pallet::::on_initialize(n) } } diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 711639effb697..578704fc702b6 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -31,7 +31,6 @@ type AccountIndex = u32; type BlockNumber = u64; type Balance = u64; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 30ba2db6a2a88..aa4045becd728 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -559,7 +559,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Called when a block is initialized. Will rotate session if it is the last /// block of the current session. - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { if T::ShouldEndSession::should_end_session(n) { Self::rotate_session(); T::BlockWeights::get().max_block @@ -901,14 +901,18 @@ impl ValidatorSet for Pallet { } } -impl EstimateNextNewSession> for Pallet { - fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor:: { +impl EstimateNextNewSession> + for Pallet +{ + fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor { T::NextSessionRotation::average_session_length() } /// This session pallet always calls new_session and next_session at the same time, hence we /// do a simple proxy and pass the function to next rotation. - fn estimate_next_new_session(now: frame_system::pallet_prelude::BlockNumberFor::) -> (Option>, Weight) { + fn estimate_next_new_session( + now: frame_system::pallet_prelude::BlockNumberFor, + ) -> (Option>, Weight) { T::NextSessionRotation::estimate_next_session_rotation(now) } } diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 201e1719145ce..20efffb1d5491 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -27,7 +27,7 @@ use std::collections::BTreeMap; use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, - testing::{UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup}, }; use sp_staking::SessionIndex; @@ -75,7 +75,6 @@ impl OpaqueKeys for PreUpgradeMockSessionKeys { } } - type Block = frame_system::mocking::MockBlock; #[cfg(feature = "historical")] diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 7a446d1986baa..95613e9d37776 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -758,7 +758,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let mut weight = Weight::zero(); let weights = T::BlockWeights::get(); @@ -1409,7 +1409,7 @@ pub enum Period { impl, I: 'static> Pallet { /// Get the period we are currently in. - fn period() -> Period> { + fn period() -> Period> { let claim_period = T::ClaimPeriod::get(); let voting_period = T::VotingPeriod::get(); let rotation_period = voting_period + claim_period; @@ -1902,7 +1902,7 @@ impl, I: 'static> Pallet { candidate: &T::AccountId, value: BalanceOf, kind: BidKind>, - maturity: frame_system::pallet_prelude::BlockNumberFor::, + maturity: frame_system::pallet_prelude::BlockNumberFor, ) { let value = match kind { BidKind::Deposit(deposit) => { @@ -1939,7 +1939,11 @@ impl, I: 'static> Pallet { /// /// It is the caller's duty to ensure that `who` is already a member. This does nothing if `who` /// is not a member or if `value` is zero. - fn bump_payout(who: &T::AccountId, when: frame_system::pallet_prelude::BlockNumberFor::, value: BalanceOf) { + fn bump_payout( + who: &T::AccountId, + when: frame_system::pallet_prelude::BlockNumberFor, + value: BalanceOf, + ) { if value.is_zero() { return } @@ -2022,7 +2026,7 @@ impl, I: 'static> Pallet { /// /// This is a rather opaque calculation based on the formula here: /// https://www.desmos.com/calculator/9itkal1tce - fn lock_duration(x: u32) -> frame_system::pallet_prelude::BlockNumberFor:: { + fn lock_duration(x: u32) -> frame_system::pallet_prelude::BlockNumberFor { let lock_pc = 100 - 50_000 / (x + 500); Percent::from_percent(lock_pc as u8) * T::MaxLockDuration::get() } diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 3081b66fa229b..d3eed1e6bedf4 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -27,13 +27,10 @@ use frame_support::{ use frame_support_test::TestRandomness; use frame_system::EnsureSignedBy; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use RuntimeOrigin as Origin; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 23bbf950b6442..5cfc8a6995916 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -32,7 +32,7 @@ use sp_core::H256; use sp_io; use sp_runtime::{ curve::PiecewiseLinear, - testing::{UintAuthorityId}, + testing::UintAuthorityId, traits::{IdentityLookup, Zero}, }; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; @@ -82,7 +82,6 @@ pub fn is_disabled(controller: AccountId) -> bool { Session::disabled_validators().contains(&validator_index) } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index fd8a14afa7494..b798e01609336 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1021,7 +1021,9 @@ impl ElectionDataProvider for Pallet { Ok(Self::get_npos_targets(None)) } - fn next_election_prediction(now: frame_system::pallet_prelude::BlockNumberFor::) -> frame_system::pallet_prelude::BlockNumberFor:: { + fn next_election_prediction( + now: frame_system::pallet_prelude::BlockNumberFor, + ) -> frame_system::pallet_prelude::BlockNumberFor { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1038,16 +1040,17 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: frame_system::pallet_prelude::BlockNumberFor:: = match ForceEra::::get() { - Forcing::ForceNone => Bounded::max_value(), - Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), - Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), - Forcing::NotForcing => T::SessionsPerEra::get() - .saturating_sub(era_progress) - // One session is computed in this_session_end. - .saturating_sub(1) - .into(), - }; + let sessions_left: frame_system::pallet_prelude::BlockNumberFor = + match ForceEra::::get() { + Forcing::ForceNone => Bounded::max_value(), + Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), + Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), + Forcing::NotForcing => T::SessionsPerEra::get() + .saturating_sub(era_progress) + // One session is computed in this_session_end. + .saturating_sub(1) + .into(), + }; now.saturating_add( until_this_session_end.saturating_add(sessions_left.saturating_mul(session_length)), @@ -1237,7 +1240,9 @@ impl historical::SessionManager pallet_authorship::EventHandler> for Pallet +impl + pallet_authorship::EventHandler> + for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 430eb2e352001..c5b9acb93c188 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -200,7 +200,9 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. - type NextNewSession: EstimateNextNewSession>; + type NextNewSession: EstimateNextNewSession< + frame_system::pallet_prelude::BlockNumberFor, + >; /// The maximum number of nominators rewarded for each validator. /// diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 17329de13464b..8864f9125a4d0 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1065,7 +1065,6 @@ mod mock { StorageChild, }; - type Block = frame_system::mocking::MockBlockU32; // Configure a mock runtime to test the pallet. diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index f8d89db808ad3..d99ff2e1d852c 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -27,11 +27,10 @@ use frame_support::{ }; use sp_core::{Pair, H256}; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, AccountId32, }; - type Block = frame_system::mocking::MockBlock; pub const MIN_ALLOWED_STATEMENTS: u32 = 4; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 464f6f0d1d109..b523a31efa86e 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -22,9 +22,7 @@ use crate as sudo; use frame_support::traits::{ConstU32, ConstU64, Contains, GenesisBuild}; use sp_core::H256; use sp_io; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; // Logger module to track execution. #[frame_support::pallet] @@ -89,7 +87,6 @@ pub mod logger { pub(super) type I32Log = StorageValue<_, BoundedVec>, ValueQuery>; } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 5d7d96dcb7e15..a6a1596e67c28 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -149,9 +149,7 @@ use frame_support_procedural_tools::{ generate_crate_access, generate_crate_access_2018, generate_hidden_includes, }; use itertools::Itertools; -use parse::{ - ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration, -}; +use parse::{ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration}; use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::quote; @@ -221,12 +219,7 @@ fn construct_runtime_intermediary_expansion( fn construct_runtime_final_expansion( definition: ExplicitRuntimeDeclaration, ) -> Result { - let ExplicitRuntimeDeclaration { - name, - pallets, - pallets_token, - where_section, - } = definition; + let ExplicitRuntimeDeclaration { name, pallets, pallets_token, where_section } = definition; let system_pallet = pallets.iter().find(|decl| decl.name == SYSTEM_PALLET_NAME).ok_or_else(|| { @@ -287,14 +280,14 @@ fn construct_runtime_final_expansion( let static_assertions = decl_static_assertions(&name, &pallets, &scrate); let warning = if let Some(where_section) = where_section { - Some(proc_macro_warning::Warning::new_deprecated("WhereSection") - .old("use where section") - .new("use `frame_system::Config` to set the `Block` type and remove this section") - .help_links(&[ - "https://github.com/paritytech/substrate/pull/14193" - ]) - .span(where_section.span) - .build()) + Some( + proc_macro_warning::Warning::new_deprecated("WhereSection") + .old("use where section") + .new("use `frame_system::Config` to set the `Block` type and remove this section") + .help_links(&["https://github.com/paritytech/substrate/pull/14193"]) + .span(where_section.span) + .build(), + ) } else { None }; diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 00f15daa9d823..6daedd542fda2 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -87,11 +87,7 @@ impl Parse for RuntimeDeclaration { } let name = input.parse::()?; - let where_section = if input.peek(token::Where) { - Some(input.parse()?) - } else { - None - }; + let where_section = if input.peek(token::Where) { Some(input.parse()?) } else { None }; let pallets = input.parse::>>()?; let pallets_token = pallets.token; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index d00a194221cd3..a0a36775e5c79 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -865,8 +865,8 @@ impl PaysFee for (u64, Pays) { /// in your runtime. To use the default behavior, add `fn deposit_event() = default;` to your /// `Module`. /// -/// The following reserved functions also take the block number (with type `frame_system::pallet_prelude::BlockNumberFor::`) as an -/// optional input: +/// The following reserved functions also take the block number (with type +/// `frame_system::pallet_prelude::BlockNumberFor::`) as an optional input: /// /// * `on_runtime_upgrade`: Executes at the beginning of a block prior to on_initialize when there /// is a runtime upgrade. This allows each module to upgrade its storage before the storage items @@ -3654,7 +3654,8 @@ mod weight_tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; - pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 9b12a1b2e96e5..039a0bcc1e8d5 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -834,7 +834,7 @@ pub mod tests { use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; use sp_std::result; - pub use self::frame_system::{Config, Pallet, pallet_prelude::*}; + pub use self::frame_system::{pallet_prelude::*, Config, Pallet}; #[pallet] pub mod frame_system { @@ -951,8 +951,9 @@ pub mod tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; - pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; - + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -999,12 +1000,8 @@ pub mod tests { fn storage_alias_works() { new_test_ext().execute_with(|| { #[crate::storage_alias] - type GenericData2 = StorageMap< - System, - Blake2_128Concat, - BlockNumberFor, - BlockNumberFor, - >; + type GenericData2 = + StorageMap, BlockNumberFor>; assert_eq!(Pallet::::generic_data2(5), None); GenericData2::::insert(5, 5); @@ -1012,12 +1009,8 @@ pub mod tests { /// Some random docs that ensure that docs are accepted #[crate::storage_alias] - pub type GenericData = StorageMap< - Test2, - Blake2_128Concat, - BlockNumberFor, - BlockNumberFor, - >; + pub type GenericData = + StorageMap, BlockNumberFor>; }); } diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index a2f35359c95ec..bac9f642e37d6 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -104,8 +104,8 @@ mod tests { pub type OriginFor = ::RuntimeOrigin; pub type HeaderFor = - <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; - + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 4dfada28a4965..75911d7569f80 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -82,9 +82,7 @@ pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; construct_runtime!( - pub struct Runtime - - { + pub struct Runtime { System: frame_system, } ); diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 22600937b39a6..a5b83e347acf5 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -126,12 +126,13 @@ pub mod pallet_prelude { /// tests! pub struct TestRandomness(sp_std::marker::PhantomData); -impl frame_support::traits::Randomness> +impl + frame_support::traits::Randomness> for TestRandomness where T: frame_system::Config, { - fn random(subject: &[u8]) -> (Output, frame_system::pallet_prelude::BlockNumberFor::) { + fn random(subject: &[u8]) -> (Output, frame_system::pallet_prelude::BlockNumberFor) { use sp_runtime::traits::TrailingZeroInput; ( diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 2810cd2f3f0b8..245b55bbb83b2 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -59,7 +59,8 @@ mod no_instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] - pub type TestGenericValue = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; + pub type TestGenericValue = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap = StorageDoubleMap< @@ -67,7 +68,7 @@ mod no_instance { Blake2_128Concat, u32, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor, u32, ValueQuery, >; @@ -75,8 +76,9 @@ mod no_instance { #[pallet::genesis_config] pub struct GenesisConfig { pub value: u32, - pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor::, - pub test_generic_double_map: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, u32)>, + pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor, + pub test_generic_double_map: + Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, u32)>, } impl Default for GenesisConfig { @@ -136,7 +138,7 @@ mod instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] pub type TestGenericValue, I: 'static = ()> = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, OptionQuery>; + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap, I: 'static = ()> = StorageDoubleMap< @@ -144,7 +146,7 @@ mod instance { Blake2_128Concat, u32, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor, u32, ValueQuery, >; @@ -152,8 +154,9 @@ mod instance { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: u32, - pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor::, - pub test_generic_double_map: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, u32)>, + pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor, + pub test_generic_double_map: + Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, u32)>, pub phantom: PhantomData, } @@ -201,7 +204,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - + { System: frame_support_test, FinalKeysNone: no_instance, diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 7c4de9363b8c3..332489af575b8 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -38,12 +38,18 @@ pub mod pallet { #[pallet::storage] #[pallet::unbounded] - pub type AppendableDM = - StorageDoubleMap<_, Identity, u32, Identity, frame_system::pallet_prelude::BlockNumberFor::, Vec>; + pub type AppendableDM = StorageDoubleMap< + _, + Identity, + u32, + Identity, + frame_system::pallet_prelude::BlockNumberFor, + Vec, + >; #[pallet::genesis_config] pub struct GenesisConfig { - pub t: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor::, Vec)>, + pub t: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, Vec)>, } impl Default for GenesisConfig { @@ -71,7 +77,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Test - + { System: frame_support_test, MyPallet: pallet, diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 7f9a846f77138..9e68df0961504 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -89,7 +89,7 @@ mod module1 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - frame_system::pallet_prelude::BlockNumberFor::: std::fmt::Display, + frame_system::pallet_prelude::BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -123,7 +123,7 @@ mod module1 { #[pallet::inherent] impl, I: 'static> ProvideInherent for Pallet where - frame_system::pallet_prelude::BlockNumberFor::: From, + frame_system::pallet_prelude::BlockNumberFor: From, { type Call = Call; type Error = MakeFatalError<()>; @@ -198,7 +198,7 @@ mod module2 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - frame_system::pallet_prelude::BlockNumberFor::: std::fmt::Display, + frame_system::pallet_prelude::BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index bb46e68a74cf2..89c3351c2de89 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -27,8 +27,11 @@ mod module { use frame_support::pallet_prelude::*; use frame_support_test as frame_system; - pub type Request = - (::AccountId, Role, frame_system::pallet_prelude::BlockNumberFor); + pub type Request = ( + ::AccountId, + Role, + frame_system::pallet_prelude::BlockNumberFor, + ); pub type Requests = Vec>; #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -46,21 +49,21 @@ mod module { pub max_actors: u32, // payouts are made at this block interval - pub reward_period: frame_system::pallet_prelude::BlockNumberFor::, + pub reward_period: frame_system::pallet_prelude::BlockNumberFor, // minimum amount of time before being able to unstake - pub bonding_period: frame_system::pallet_prelude::BlockNumberFor::, + pub bonding_period: frame_system::pallet_prelude::BlockNumberFor, // how long tokens remain locked for after unstaking - pub unbonding_period: frame_system::pallet_prelude::BlockNumberFor::, + pub unbonding_period: frame_system::pallet_prelude::BlockNumberFor, // minimum period required to be in service. unbonding before this time is highly penalized - pub min_service_period: frame_system::pallet_prelude::BlockNumberFor::, + pub min_service_period: frame_system::pallet_prelude::BlockNumberFor, // "startup" time allowed for roles that need to sync their infrastructure // with other providers before they are considered in service and punishable for // not delivering required level of service. - pub startup_grace_period: frame_system::pallet_prelude::BlockNumberFor::, + pub startup_grace_period: frame_system::pallet_prelude::BlockNumberFor, } impl Default for RoleParameters { @@ -115,7 +118,12 @@ mod module { /// tokens locked until given block number #[pallet::storage] #[pallet::getter(fn bondage)] - pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, frame_system::pallet_prelude::BlockNumberFor::>; + pub type Bondage = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + >; /// First step before enter a role is registering intent with a new account/key. /// This is done by sending a role_entry_request() from the new account. @@ -172,9 +180,7 @@ impl frame_support_test::Config for Runtime { impl module::Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime - - { + pub struct Runtime { System: frame_support_test, Module: module, } diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 43b0c34e35827..93a541ad91162 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -93,9 +93,7 @@ impl frame_system::Config for Runtime { impl Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime - - { + pub struct Runtime { System: frame_system, MyPallet: pallet, } diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 20dcd97d0f144..0e52909e4857f 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -82,7 +82,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - + { System: frame_support_test, MyPallet: pallet, diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 04e3b44f534ab..802b0a4c9f061 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -19,7 +19,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, Perbill, }; @@ -42,7 +42,6 @@ mod module { } } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 75fb7af450689..90a035711214a 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -25,7 +25,6 @@ use sp_runtime::traits::IdentityLookup; type AccountId = u64; type AccountIndex = u32; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/system/src/extensions/check_genesis.rs b/frame/system/src/extensions/check_genesis.rs index 39c061e0fa87f..76a711a823e7d 100644 --- a/frame/system/src/extensions/check_genesis.rs +++ b/frame/system/src/extensions/check_genesis.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Config, Pallet, pallet_prelude::BlockNumberFor}; +use crate::{pallet_prelude::BlockNumberFor, Config, Pallet}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 7d4f280606db1..148dfd4aad471 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{BlockHash, Config, Pallet, pallet_prelude::BlockNumberFor}; +use crate::{pallet_prelude::BlockNumberFor, BlockHash, Config, Pallet}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index c03c125b2121f..04c3850ef2f57 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -73,9 +73,9 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::{ generic, traits::{ - self, AtLeast32Bit, BadOrigin, BlockNumberProvider, Bounded, - CheckEqual, Dispatchable, Hash, Header, Lookup, LookupError, MaybeDisplay, - MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, + self, AtLeast32Bit, BadOrigin, BlockNumberProvider, Bounded, CheckEqual, Dispatchable, + Hash, Header, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, + Saturating, SimpleBitOps, StaticLookup, Zero, }, DispatchError, RuntimeDebug, }; @@ -1463,13 +1463,7 @@ impl Pallet { let storage_root = T::Hash::decode(&mut &sp_io::storage::root(version)[..]) .expect("Node is configured to use the same hash; qed"); - HeaderFor::::new( - number, - extrinsics_root, - storage_root, - parent_hash, - digest, - ) + HeaderFor::::new(number, extrinsics_root, storage_root, parent_hash, digest) } /// Deposits a log and ensures it matches the block's log data. @@ -1818,7 +1812,8 @@ pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; /// Type alias for the `Header`. - pub type HeaderFor = <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; /// Type alias for the `BlockNumber` associated type of system config. pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index b8325657f293e..bba3b92077de7 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -22,7 +22,7 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index 0406805697e8f..9ebda4a42b448 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -37,4 +37,4 @@ pub type MockBlock = generic::Block< pub type MockBlockU32 = generic::Block< generic::Header, MockUncheckedExtrinsic, ->; \ No newline at end of file +>; diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index bbf36faed1d21..202929cde2f35 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -173,7 +173,12 @@ pub mod pallet { _, Twox64Concat, T::Hash, - OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, + OpenTip< + T::AccountId, + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + T::Hash, + >, OptionQuery, >; @@ -470,7 +475,12 @@ impl, I: 'static> Pallet { /// /// `O(T)` and one storage access. fn insert_tip_and_check_closing( - tip: &mut OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, + tip: &mut OpenTip< + T::AccountId, + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + T::Hash, + >, tipper: T::AccountId, tip_value: BalanceOf, ) -> bool { @@ -515,7 +525,12 @@ impl, I: 'static> Pallet { /// Plus `O(T)` (`T` is Tippers length). fn payout_tip( hash: T::Hash, - tip: OpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, + tip: OpenTip< + T::AccountId, + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + T::Hash, + >, ) { let mut tips = tip.tips; Self::retain_active_tips(&mut tips); @@ -577,7 +592,12 @@ impl, I: 'static> Pallet { for (hash, old_tip) in storage_key_iter::< T::Hash, - OldOpenTip, frame_system::pallet_prelude::BlockNumberFor::, T::Hash>, + OldOpenTip< + T::AccountId, + BalanceOf, + frame_system::pallet_prelude::BlockNumberFor, + T::Hash, + >, Twox64Concat, >(module, item) .drain() diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 2c8e60fdb10ed..2cf5043331b0d 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -21,7 +21,7 @@ use sp_core::H256; use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Permill, }; use sp_storage::Storage; @@ -38,7 +38,6 @@ use frame_support::{ use super::*; use crate::{self as pallet_tips, Event as TipEvent}; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs index 6c74e0d4bf030..683b93ad1f3fe 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -33,11 +33,10 @@ use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; use sp_runtime::{ - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion}, + traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion}, Permill, }; - type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index 11284e2669499..fbc70c118da7b 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -29,19 +29,14 @@ use frame_system as system; use frame_system::EnsureRoot; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}, -}; - +use sp_runtime::traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}; type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; frame_support::construct_runtime!( - pub struct Runtime - - { + pub struct Runtime { System: system, Balances: pallet_balances, TransactionPayment: pallet_transaction_payment, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 0f2440d2ad03f..c707b7a163ffd 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -408,7 +408,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor) { >::mutate(|fm| { *fm = T::FeeMultiplierUpdate::convert(*fm); }); diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 35bec09bdb77b..023f1cf6e1f40 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -19,9 +19,7 @@ use super::*; use crate as pallet_transaction_payment; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use frame_support::{ dispatch::DispatchClass, @@ -32,7 +30,6 @@ use frame_support::{ use frame_system as system; use pallet_balances::Call as BalancesCall; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index 390e5925e39d6..c554628e15d92 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -113,7 +113,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { assert_eq!(event, &system_event); } -pub fn run_to_block(n: frame_system::pallet_prelude::BlockNumberFor::) { +pub fn run_to_block(n: frame_system::pallet_prelude::BlockNumberFor) { while frame_system::Pallet::::block_number() < n { crate::Pallet::::on_finalize(frame_system::Pallet::::block_number()); frame_system::Pallet::::on_finalize(frame_system::Pallet::::block_number()); diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index b2928c1e188a3..36b9011a41496 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { // Drop obsolete roots. The proof for `obsolete` will be checked later // in this block, so we drop `obsolete` - 1. let period = >::get(); @@ -158,7 +158,7 @@ pub mod pallet { T::DbWeight::get().reads_writes(2, 4) } - fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor::) { + fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor) { assert!( >::take() || { // Proof is not required for early or empty blocks. @@ -238,7 +238,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::renew())] pub fn renew( origin: OriginFor, - block: frame_system::pallet_prelude::BlockNumberFor::, + block: frame_system::pallet_prelude::BlockNumberFor, index: u32, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -342,15 +342,20 @@ pub mod pallet { pub(super) type Transactions = StorageMap< _, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor::, + frame_system::pallet_prelude::BlockNumberFor, BoundedVec, OptionQuery, >; /// Count indexed chunks for each block. #[pallet::storage] - pub(super) type ChunkCount = - StorageMap<_, Blake2_128Concat, frame_system::pallet_prelude::BlockNumberFor::, u32, ValueQuery>; + pub(super) type ChunkCount = StorageMap< + _, + Blake2_128Concat, + frame_system::pallet_prelude::BlockNumberFor, + u32, + ValueQuery, + >; #[pallet::storage] #[pallet::getter(fn byte_fee)] @@ -365,7 +370,8 @@ pub mod pallet { /// Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD` /// for block authoring. #[pallet::storage] - pub(super) type StoragePeriod = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; + pub(super) type StoragePeriod = + StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; // Intermediates #[pallet::storage] @@ -380,7 +386,7 @@ pub mod pallet { pub struct GenesisConfig { pub byte_fee: BalanceOf, pub entry_fee: BalanceOf, - pub storage_period: frame_system::pallet_prelude::BlockNumberFor::, + pub storage_period: frame_system::pallet_prelude::BlockNumberFor, } impl Default for GenesisConfig { diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 123fc4430b6e3..bfaf0c3c075d9 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -24,11 +24,10 @@ use crate::{ use frame_support::traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; - pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 4ca5352faaa49..22e41422c7fc2 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -309,7 +309,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// ## Complexity /// - `O(A)` where `A` is the number of approvals - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor::) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let pot = Self::pot(); let deactivated = Deactivated::::get(); if pot != deactivated { diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 06d5660f10b3d..a614b0dda5228 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -20,9 +20,7 @@ #![cfg(test)] use sp_core::H256; -use sp_runtime::{ - traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}, -}; +use sp_runtime::traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}; use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, @@ -35,7 +33,6 @@ use frame_support::{ use super::*; use crate as treasury; - type Block = frame_system::mocking::MockBlock; type UtilityCall = pallet_utility::Call; type TreasuryCall = crate::Call; diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 22b06d99243ac..dfcddc2b5fde4 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -25,10 +25,7 @@ use frame_support::{ traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, -}; - +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 6d93c80129ba6..ef6ec49349378 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -33,7 +33,7 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Hash, IdentityLookup}, + traits::{BlakeTwo256, Hash, IdentityLookup}, TokenError, }; @@ -124,7 +124,6 @@ mod mock_democracy { } } - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index c737d61219474..9a9e5d790e32a 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -127,8 +127,10 @@ impl VestingAction { /// Pick the schedules that this action dictates should continue vesting undisturbed. fn pick_schedules( &self, - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, - ) -> impl Iterator, frame_system::pallet_prelude::BlockNumberFor::>> + '_ { + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, + ) -> impl Iterator< + Item = VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + > + '_ { schedules.into_iter().enumerate().filter_map(move |(index, schedule)| { if self.should_remove(index) { None @@ -162,7 +164,10 @@ pub mod pallet { type Currency: LockableCurrency; /// Convert the block number into a balance. - type BlockNumberToBalance: Convert, BalanceOf>; + type BlockNumberToBalance: Convert< + frame_system::pallet_prelude::BlockNumberFor, + BalanceOf, + >; /// The minimum amount transferred to call `vested_transfer`. #[pallet::constant] @@ -201,7 +206,10 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - BoundedVec, frame_system::pallet_prelude::BlockNumberFor::>, MaxVestingSchedulesGet>, + BoundedVec< + VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + MaxVestingSchedulesGet, + >, >; /// Storage version of the pallet. @@ -216,7 +224,12 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { - pub vesting: Vec<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor::, frame_system::pallet_prelude::BlockNumberFor::, BalanceOf)>, + pub vesting: Vec<( + T::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + frame_system::pallet_prelude::BlockNumberFor, + BalanceOf, + )>, } #[pallet::genesis_build] @@ -342,7 +355,7 @@ pub mod pallet { pub fn vested_transfer( origin: OriginFor, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; let transactor = ::unlookup(transactor); @@ -371,7 +384,7 @@ pub mod pallet { origin: OriginFor, source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, ) -> DispatchResult { ensure_root(origin)?; Self::do_vested_transfer(source, target, schedule) @@ -433,10 +446,10 @@ impl Pallet { // Create a new `VestingInfo`, based off of two other `VestingInfo`s. // NOTE: We assume both schedules have had funds unlocked up through the current block. fn merge_vesting_info( - now: frame_system::pallet_prelude::BlockNumberFor::, - schedule1: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, - schedule2: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, - ) -> Option, frame_system::pallet_prelude::BlockNumberFor::>> { + now: frame_system::pallet_prelude::BlockNumberFor, + schedule1: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + schedule2: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + ) -> Option, frame_system::pallet_prelude::BlockNumberFor>> { let schedule1_ending_block = schedule1.ending_block_as_balance::(); let schedule2_ending_block = schedule2.ending_block_as_balance::(); let now_as_balance = T::BlockNumberToBalance::convert(now); @@ -483,7 +496,7 @@ impl Pallet { fn do_vested_transfer( source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, ) -> DispatchResult { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); @@ -531,9 +544,12 @@ impl Pallet { /// /// NOTE: the amount locked does not include any schedules that are filtered out via `action`. fn report_schedule_updates( - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, action: VestingAction, - ) -> (Vec, frame_system::pallet_prelude::BlockNumberFor::>>, BalanceOf) { + ) -> ( + Vec, frame_system::pallet_prelude::BlockNumberFor>>, + BalanceOf, + ) { let now = >::block_number(); let mut total_locked_now: BalanceOf = Zero::zero(); @@ -570,10 +586,10 @@ impl Pallet { /// Write an accounts updated vesting schedules to storage. fn write_vesting( who: &T::AccountId, - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, ) -> Result<(), DispatchError> { let schedules: BoundedVec< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, + VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, MaxVestingSchedulesGet, > = schedules.try_into().map_err(|_| Error::::AtMaxVestingSchedules)?; @@ -602,9 +618,15 @@ impl Pallet { /// Execute a `VestingAction` against the given `schedules`. Returns the updated schedules /// and locked amount. fn exec_action( - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor::>>, + schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, action: VestingAction, - ) -> Result<(Vec, frame_system::pallet_prelude::BlockNumberFor::>>, BalanceOf), DispatchError> { + ) -> Result< + ( + Vec, frame_system::pallet_prelude::BlockNumberFor>>, + BalanceOf, + ), + DispatchError, + > { let (schedules, locked_now) = match action { VestingAction::Merge { index1: idx1, index2: idx2 } => { // The schedule index is based off of the schedule ordering prior to filtering out @@ -649,7 +671,7 @@ where BalanceOf: MaybeSerializeDeserialize + Debug, { type Currency = T::Currency; - type Moment = frame_system::pallet_prelude::BlockNumberFor::; + type Moment = frame_system::pallet_prelude::BlockNumberFor; /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { @@ -680,7 +702,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: frame_system::pallet_prelude::BlockNumberFor::, + starting_block: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { if locked.is_zero() { return Ok(()) @@ -713,7 +735,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: frame_system::pallet_prelude::BlockNumberFor::, + starting_block: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index d4c6193901efb..5dd0fef28e155 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -40,26 +40,27 @@ pub mod v1 { pub fn migrate() -> Weight { let mut reads_writes = 0; - Vesting::::translate::, frame_system::pallet_prelude::BlockNumberFor::>, _>( - |_key, vesting_info| { - reads_writes += 1; - let v: Option< - BoundedVec< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor::>, - MaxVestingSchedulesGet, - >, - > = vec![vesting_info].try_into().ok(); - - if v.is_none() { - log::warn!( - target: "runtime::vesting", - "migration: Failed to move a vesting schedule into a BoundedVec" - ); - } + Vesting::::translate::< + VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + _, + >(|_key, vesting_info| { + reads_writes += 1; + let v: Option< + BoundedVec< + VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + MaxVestingSchedulesGet, + >, + > = vec![vesting_info].try_into().ok(); + + if v.is_none() { + log::warn!( + target: "runtime::vesting", + "migration: Failed to move a vesting schedule into a BoundedVec" + ); + } - v - }, - ); + v + }); T::DbWeight::get().reads_writes(reads_writes, reads_writes) } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index c3643877c6a0e..cebae13b2f1b6 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -20,14 +20,11 @@ use frame_support::{ traits::{ConstU32, ConstU64, GenesisBuild, WithdrawReasons}, }; use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, Identity, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, Identity, IdentityLookup}; use super::*; use crate as pallet_vesting; - type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 1226befdbd676..3b25cdd4d14ae 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -28,11 +28,10 @@ use frame_support::{ use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; - type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index d8602769d9a66..10bc2b8d87015 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -88,7 +88,7 @@ pub struct Block { impl traits::HeaderProvider for Block where - Header: HeaderT + Header: HeaderT, { type HeaderT = Header; } diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index 94ae3d99a7774..8dafa8e7905b1 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -243,10 +243,7 @@ pub struct Block { pub extrinsics: Vec, } -impl< - Xt - > traits::HeaderProvider for Block -{ +impl traits::HeaderProvider for Block { type HeaderT = Header; } diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 4caa904699901..f55a7f8bca174 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1154,7 +1154,9 @@ pub trait IsMember { /// `parent_hash`, as well as a `digest` and a block `number`. /// /// You can also create a `new` one from those fields. -pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + TypeInfo + 'static { +pub trait Header: + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + TypeInfo + 'static +{ /// Header number. type Number: Member + MaybeSerializeDeserialize @@ -1214,20 +1216,20 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + Ty } /// Something that provides the Header Type. -// This is needed to fix the "cyclical" issue in loading Header/BlockNumber as part of a +// This is needed to fix the "cyclical" issue in loading Header/BlockNumber as part of a // `pallet::call`. Essentially, `construct_runtime` aggregates all calls to create a `RuntimeCall` // that is then used to define `UncheckedExtrinsic`. // ```ignore // pub type UncheckedExtrinsic = -// generic::UncheckedExtrinsic; +// generic::UncheckedExtrinsic; // ``` // This `UncheckedExtrinsic` is supplied to the `Block`. // ```ignore // pub type Block = generic::Block; // ``` -// So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a +// So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a // recursive loop leading to a build error. -// +// // Note that this is a workaround and should be removed once we have a better solution. pub trait HeaderProvider { /// Header type. @@ -1238,7 +1240,17 @@ pub trait HeaderProvider { /// `Extrinsic` pieces of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. -pub trait Block: HeaderProvider::Header> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Block: + HeaderProvider::Header> + + Clone + + Send + + Sync + + Codec + + Eq + + MaybeSerialize + + Debug + + 'static +{ /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. From eaa8b29bfc471a849b86069fd33240f474b249b0 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:24:39 +0530 Subject: [PATCH 17/67] Fixes construct_runtime tests --- frame/support/test/tests/construct_runtime.rs | 107 ++++++++++++------ 1 file changed, 75 insertions(+), 32 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 1ca73d178090d..6d8e7717fbb25 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -22,9 +22,9 @@ #![recursion_limit = "128"] use codec::MaxEncodedLen; -use frame_support::{parameter_types, traits::PalletInfo as _}; +use frame_support::{derive_impl, parameter_types, traits::PalletInfo as _}; use scale_info::TypeInfo; -use sp_core::sr25519; +use sp_core::{sr25519, ConstU32}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, @@ -37,9 +37,8 @@ parameter_types! { #[frame_support::pallet(dev_mode)] mod module1 { - use self::frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -75,10 +74,9 @@ mod module1 { #[frame_support::pallet(dev_mode)] mod module2 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -122,10 +120,9 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module3 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -177,10 +174,9 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module3 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -255,7 +251,7 @@ use frame_support_test as system; frame_support::construct_runtime!( pub struct Runtime { - System: system::{Pallet, Call, Event, Origin} = 30, + System: frame_system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, Module2: module2::{Pallet, Call, Storage, Event, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, @@ -271,14 +267,18 @@ frame_support::construct_runtime!( } ); -impl frame_support_test::Config for Runtime { +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type AccountId = AccountId; + type Lookup = sp_runtime::traits::IdentityLookup; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); + type Block = Block; + type BlockHashCount = ConstU32<10>; } impl module1::Config for Runtime { @@ -326,7 +326,7 @@ fn test_pub() -> AccountId { fn check_modules_error_type() { sp_io::TestExternalities::default().execute_with(|| { assert_eq!( - Module1_1::fail(system::Origin::::Root.into()), + Module1_1::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 31, error: [0; 4], @@ -334,7 +334,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module2::fail(system::Origin::::Root.into()), + Module2::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 32, error: [0; 4], @@ -342,7 +342,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_2::fail(system::Origin::::Root.into()), + Module1_2::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 33, error: [0; 4], @@ -350,7 +350,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - NestedModule3::fail(system::Origin::::Root.into()), + NestedModule3::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 34, error: [0; 4], @@ -358,7 +358,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_3::fail(system::Origin::::Root.into()), + Module1_3::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 6, error: [0; 4], @@ -366,7 +366,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_4::fail(system::Origin::::Root.into()), + Module1_4::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 3, error: [0; 4], @@ -374,7 +374,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_5::fail(system::Origin::::Root.into()), + Module1_5::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 4, error: [0; 4], @@ -382,7 +382,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_6::fail(system::Origin::::Root.into()), + Module1_6::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 1, error: [0; 4], @@ -390,7 +390,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_7::fail(system::Origin::::Root.into()), + Module1_7::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 2, error: [0; 4], @@ -398,7 +398,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_8::fail(system::Origin::::Root.into()), + Module1_8::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 12, error: [0; 4], @@ -406,7 +406,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_9::fail(system::Origin::::Root.into()), + Module1_9::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 13, error: [0; 4], @@ -426,7 +426,7 @@ fn integrity_test_works() { fn origin_codec() { use codec::Encode; - let origin = OriginCaller::system(system::RawOrigin::None); + let origin = OriginCaller::system(frame_system::RawOrigin::None); assert_eq!(origin.encode()[0], 30); let origin = OriginCaller::Module1_1(module1::Origin(Default::default())); @@ -461,7 +461,7 @@ fn origin_codec() { fn event_codec() { use codec::Encode; - let event = system::Event::::ExtrinsicSuccess; + let event = frame_system::Event::::ExtrinsicSuccess; assert_eq!(RuntimeEvent::from(event).encode()[0], 30); let event = module1::Event::::A(test_pub()); @@ -498,7 +498,7 @@ fn event_codec() { #[test] fn call_codec() { use codec::Encode; - assert_eq!(RuntimeCall::System(system::Call::noop {}).encode()[0], 30); + assert_eq!(RuntimeCall::System(frame_system::Call::noop {}).encode()[0], 30); assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31); assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32); assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33); @@ -634,10 +634,53 @@ fn test_metadata() { PalletMetadata { name: "System", storage: None, - calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), - constants: vec![], - error: Some(meta_type::>().into()), + calls: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), + constants: vec![ + PalletConstantMetadata { + name: "BlockWeights", + ty: meta_type::(), + value: BlockWeights::default().encode(), + docs: maybe_docs(vec![" Block & extrinsics weights: base values and limits."]), + }, + PalletConstantMetadata { + name: "BlockLength", + ty: meta_type::(), + value: BlockLength::default().encode(), + docs: maybe_docs(vec![" The maximum length of a block (in bytes)."]), + }, + PalletConstantMetadata { + name: "BlockHashCount", + ty: meta_type::(), + value: 10u32.encode(), + docs: maybe_docs(vec![" Maximum number of block number to block hash mappings to keep (oldest pruned first)."]), + }, + PalletConstantMetadata { + name: "DbWeight", + ty: meta_type::(), + value: RuntimeDbWeight::default().encode(), + docs: maybe_docs(vec![" The weight of runtime database operations the runtime can invoke.",]), + }, + PalletConstantMetadata { + name: "Version", + ty: meta_type::(), + value: RuntimeVersion::default().encode(), + docs: maybe_docs(vec![ " Get the chain's current version."]), + }, + PalletConstantMetadata { + name: "SS58Prefix", + ty: meta_type::(), + value: 0u16.encode(), + docs: maybe_docs(vec![ + " The designated SS58 prefix of this chain.", + "", + " This replaces the \"ss58Format\" property declared in the chain spec. Reason is", + " that the runtime should know about the prefix in order to make use of it as", + " an identifier of the chain.", + ]), + }, + ], + error: Some(meta_type::>().into()), index: 30, }, PalletMetadata { @@ -771,7 +814,7 @@ fn test_metadata() { fn pallet_in_runtime_is_correct() { assert_eq!(PalletInfo::index::().unwrap(), 30); assert_eq!(PalletInfo::name::().unwrap(), "System"); - assert_eq!(PalletInfo::module_name::().unwrap(), "system"); + assert_eq!(PalletInfo::module_name::().unwrap(), "frame_system"); assert!(PalletInfo::crate_version::().is_some()); assert_eq!(PalletInfo::index::().unwrap(), 31); From f8c6153fb98eae9bca3a59e03b0388f333a96700 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:52:07 +0530 Subject: [PATCH 18/67] Uses import instead of full path for BlockNumber --- frame/alliance/src/lib.rs | 2 +- frame/asset-conversion/src/lib.rs | 4 +- frame/atomic-swap/src/lib.rs | 5 +- frame/aura/src/lib.rs | 2 +- frame/authorship/src/lib.rs | 6 +- frame/babe/src/lib.rs | 41 ++--- frame/babe/src/randomness.rs | 17 ++- frame/balances/src/impl_currency.rs | 3 +- frame/balances/src/lib.rs | 2 +- frame/beefy-mmr/src/lib.rs | 3 +- frame/beefy/src/equivocation.rs | 5 +- frame/bounties/src/lib.rs | 2 +- frame/child-bounties/src/lib.rs | 4 +- frame/collective/src/lib.rs | 2 +- frame/contracts/src/exec.rs | 7 +- frame/contracts/src/lib.rs | 2 +- frame/conviction-voting/src/lib.rs | 5 +- frame/core-fellowship/src/lib.rs | 4 +- frame/democracy/src/lib.rs | 47 +++--- frame/democracy/src/migrations/v1.rs | 5 +- .../election-provider-multi-phase/src/lib.rs | 19 +-- .../src/signed.rs | 5 +- .../src/unsigned.rs | 5 +- frame/elections-phragmen/src/lib.rs | 4 +- frame/examples/basic/src/lib.rs | 6 +- frame/examples/kitchensink/src/lib.rs | 14 +- frame/examples/offchain-worker/src/lib.rs | 23 +-- frame/executive/src/lib.rs | 8 +- frame/fast-unstake/src/lib.rs | 6 +- frame/grandpa/src/equivocation.rs | 9 +- frame/grandpa/src/lib.rs | 39 ++--- frame/im-online/src/lib.rs | 16 +- .../src/lib.rs | 10 +- frame/lottery/src/lib.rs | 8 +- frame/merkle-mountain-range/src/lib.rs | 14 +- frame/multisig/src/lib.rs | 19 +-- .../nft-fractionalization/src/benchmarking.rs | 4 +- frame/nfts/src/lib.rs | 16 +- frame/nfts/src/types.rs | 9 +- frame/nis/src/lib.rs | 12 +- frame/nomination-pools/src/lib.rs | 13 +- frame/proxy/src/lib.rs | 31 ++-- frame/recovery/src/lib.rs | 6 +- frame/referenda/src/lib.rs | 33 ++-- frame/referenda/src/types.rs | 12 +- frame/salary/src/lib.rs | 6 +- frame/scheduler/src/lib.rs | 143 +++++++++--------- frame/scheduler/src/migration.rs | 15 +- frame/session/benchmarking/src/lib.rs | 4 +- frame/session/src/lib.rs | 11 +- frame/society/src/lib.rs | 14 +- frame/staking/src/pallet/impls.rs | 8 +- frame/support/test/src/lib.rs | 5 +- frame/support/test/tests/final_keys.rs | 16 +- frame/support/test/tests/genesisconfig.rs | 4 +- frame/support/test/tests/instance.rs | 8 +- frame/support/test/tests/issue2219.rs | 14 +- frame/tips/src/lib.rs | 9 +- frame/transaction-storage/src/lib.rs | 14 +- frame/vesting/src/lib.rs | 43 +++--- frame/vesting/src/migrations.rs | 4 +- 61 files changed, 427 insertions(+), 400 deletions(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index cd1d61f6ffaba..a0320f39773e6 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -479,7 +479,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, OptionQuery, >; diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 4efdb70c4aa85..0494748bb31e8 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -72,7 +72,7 @@ use frame_support::{ ensure, traits::tokens::{AssetId, Balance}, }; -use frame_system::{ensure_signed, pallet_prelude::OriginFor}; +use frame_system::{ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}}; pub use pallet::*; use sp_arithmetic::traits::Unsigned; use sp_runtime::{ @@ -357,7 +357,7 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet { + impl Hooks> for Pallet { fn integrity_test() { assert!( T::MaxSwapPathLength::get() > 1, diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 0d78a1b83400e..25d53bc135e0f 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -58,6 +58,7 @@ use sp_std::{ ops::{Deref, DerefMut}, prelude::*, }; +use frame_system::pallet_prelude::BlockNumberFor; /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] @@ -69,7 +70,7 @@ pub struct PendingSwap { /// Action of this swap. pub action: T::SwapAction, /// End block of the lock. - pub end_block: frame_system::pallet_prelude::BlockNumberFor, + pub end_block: BlockNumberFor, } /// Hashed proof type. @@ -249,7 +250,7 @@ pub mod pallet { target: T::AccountId, hashed_proof: HashedProof, action: T::SwapAction, - duration: frame_system::pallet_prelude::BlockNumberFor, + duration: BlockNumberFor, ) -> DispatchResult { let source = ensure_signed(origin)?; ensure!( diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index f890c5c6523a6..067d478a1da4e 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -102,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(_: BlockNumberFor) -> Weight { if let Some(new_slot) = Self::current_slot_from_digests() { let current_slot = CurrentSlot::::get(); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index d7c39b2cf9ebd..f976951cbcecb 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -47,7 +47,7 @@ pub mod pallet { /// An event handler for authored blocks. type EventHandler: EventHandler< Self::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; } @@ -56,7 +56,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(_: BlockNumberFor) -> Weight { if let Some(author) = Self::author() { T::EventHandler::note_author(author); } @@ -64,7 +64,7 @@ pub mod pallet { Weight::zero() } - fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(_: BlockNumberFor) { // ensure we never go to trie with these values. >::kill(); } diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index b22f056d9b2b2..5427b4228f9a2 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -29,6 +29,7 @@ use frame_support::{ weights::Weight, BoundedVec, WeakBoundedVec, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_consensus_babe::{ digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest}, AllowedSlots, BabeAuthorityWeight, BabeEpochConfiguration, ConsensusLog, Epoch, @@ -78,7 +79,7 @@ pub trait WeightInfo { pub trait EpochChangeTrigger { /// Trigger an epoch change, if any should take place. This should be called /// during every block, after initialization is done. - fn trigger(now: frame_system::pallet_prelude::BlockNumberFor); + fn trigger(now: BlockNumberFor); } /// A type signifying to BABE that an external trigger @@ -86,7 +87,7 @@ pub trait EpochChangeTrigger { pub struct ExternalTrigger; impl EpochChangeTrigger for ExternalTrigger { - fn trigger(_: frame_system::pallet_prelude::BlockNumberFor) {} // nothing - trigger is external. + fn trigger(_: BlockNumberFor) {} // nothing - trigger is external. } /// A type signifying to BABE that it should perform epoch changes @@ -94,7 +95,7 @@ impl EpochChangeTrigger for ExternalTrigger { pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { - fn trigger(now: frame_system::pallet_prelude::BlockNumberFor) { + fn trigger(now: BlockNumberFor) { if >::should_epoch_change(now) { let authorities = >::authorities(); let next_authorities = authorities.clone(); @@ -281,8 +282,8 @@ pub mod pallet { pub(super) type EpochStart = StorageValue< _, ( - frame_system::pallet_prelude::BlockNumberFor, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, + BlockNumberFor, ), ValueQuery, >; @@ -295,7 +296,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn lateness)] pub(super) type Lateness = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; + StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -510,10 +511,10 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession> +impl pallet_session::ShouldEndSession> for Pallet { - fn should_end_session(now: frame_system::pallet_prelude::BlockNumberFor) -> bool { + fn should_end_session(now: BlockNumberFor) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's // possible that babe's own `on_initialize` has not run yet, so let's ensure that we @@ -533,7 +534,7 @@ impl Pallet { /// Determine whether an epoch change should take place at this block. /// Assumes that initialization has already taken place. - pub fn should_epoch_change(now: frame_system::pallet_prelude::BlockNumberFor) -> bool { + pub fn should_epoch_change(now: BlockNumberFor) -> bool { // The epoch has technically ended during the passage of time // between this block and the last, but we have to "end" the epoch now, // since there is no earlier possible block we could have done it. @@ -564,12 +565,12 @@ impl Pallet { // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. pub fn next_expected_epoch_change( - now: frame_system::pallet_prelude::BlockNumberFor, - ) -> Option> { + now: BlockNumberFor, + ) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: frame_system::pallet_prelude::BlockNumberFor = + let blocks_remaining: BlockNumberFor = slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) @@ -788,7 +789,7 @@ impl Pallet { Self::deposit_consensus(ConsensusLog::NextEpochData(next)); } - fn initialize(now: frame_system::pallet_prelude::BlockNumberFor) { + fn initialize(now: BlockNumberFor) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block let initialized = Self::initialized().is_some(); @@ -914,15 +915,15 @@ impl OnTimestampSet for Pallet { impl frame_support::traits::EstimateNextSessionRotation< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, > for Pallet { - fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor { + fn average_session_length() -> BlockNumberFor { T::EpochDuration::get().saturated_into() } fn estimate_current_session_progress( - _now: frame_system::pallet_prelude::BlockNumberFor, + _now: BlockNumberFor, ) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; @@ -934,8 +935,8 @@ impl } fn estimate_next_session_rotation( - now: frame_system::pallet_prelude::BlockNumberFor, - ) -> (Option>, Weight) { + now: BlockNumberFor, + ) -> (Option>, Weight) { ( Self::next_expected_epoch_change(now), // Read: Current Slot, Epoch Index, Genesis Slot @@ -944,10 +945,10 @@ impl } } -impl frame_support::traits::Lateness> +impl frame_support::traits::Lateness> for Pallet { - fn lateness(&self) -> frame_system::pallet_prelude::BlockNumberFor { + fn lateness(&self) -> BlockNumberFor { Self::lateness() } } diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index 34752a91e8006..34bb08a3ab627 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -22,6 +22,7 @@ use super::{ AuthorVrfRandomness, Config, EpochStart, NextRandomness, Randomness, RANDOMNESS_LENGTH, }; use frame_support::traits::Randomness as RandomnessT; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Hash, One, Saturating}; /// Randomness usable by consensus protocols that **depend** upon finality and take action @@ -129,10 +130,10 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT> +impl RandomnessT> for RandomnessFromTwoEpochsAgo { - fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); @@ -141,10 +142,10 @@ impl RandomnessT RandomnessT> +impl RandomnessT> for RandomnessFromOneEpochAgo { - fn random(subject: &[u8]) -> (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); @@ -153,12 +154,12 @@ impl RandomnessT RandomnessT, frame_system::pallet_prelude::BlockNumberFor> +impl RandomnessT, BlockNumberFor> for ParentBlockRandomness { fn random( subject: &[u8], - ) -> (Option, frame_system::pallet_prelude::BlockNumberFor) { + ) -> (Option, BlockNumberFor) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -172,12 +173,12 @@ impl RandomnessT, frame_system::pallet_prelude::Block } #[allow(deprecated)] -impl RandomnessT, frame_system::pallet_prelude::BlockNumberFor> +impl RandomnessT, BlockNumberFor> for CurrentBlockRandomness { fn random( subject: &[u8], - ) -> (Option, frame_system::pallet_prelude::BlockNumberFor) { + ) -> (Option, BlockNumberFor) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index 3f5284e4969a1..2cbe776c51297 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -32,6 +32,7 @@ use frame_support::{ ReservableCurrency, SignedImbalance, TryDrop, WithdrawReasons, }, }; +use frame_system::pallet_prelude::BlockNumberFor; pub use imbalances::{NegativeImbalance, PositiveImbalance}; // wrapping these imbalances in a private module is necessary to ensure absolute privacy @@ -842,7 +843,7 @@ impl, I: 'static> LockableCurrency for Pallet where T::Balance: MaybeSerializeDeserialize + Debug, { - type Moment = frame_system::pallet_prelude::BlockNumberFor; + type Moment = BlockNumberFor; type MaxLocks = T::MaxLocks; diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 2ad0847877529..826fb721725dd 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -517,7 +517,7 @@ pub mod pallet { } #[pallet::hooks] - impl, I: 'static> Hooks> + impl, I: 'static> Hooks> for Pallet { #[cfg(not(feature = "insecure_zero_ed"))] diff --git a/frame/beefy-mmr/src/lib.rs b/frame/beefy-mmr/src/lib.rs index 494e8b67ff88d..ec1519ac41bd3 100644 --- a/frame/beefy-mmr/src/lib.rs +++ b/frame/beefy-mmr/src/lib.rs @@ -43,6 +43,7 @@ use sp_consensus_beefy::{ }; use frame_support::{crypto::ecdsa::ECDSAExt, traits::Get}; +use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; @@ -139,7 +140,7 @@ pub mod pallet { impl LeafDataProvider for Pallet { type LeafData = MmrLeaf< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::Hash, MerkleRootOf, T::LeafExtra, diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index b85ed0bc5e134..51d7ef87d63fb 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -39,6 +39,7 @@ use frame_support::{ log, traits::{Get, KeyOwnerProofSystem}, }; +use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE}; use sp_runtime::{ @@ -126,7 +127,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, /// Equivocation evidence convenience alias. pub type EquivocationEvidenceFor = ( EquivocationProof< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::BeefyId, <::BeefyId as RuntimeAppPublic>::Signature, >, @@ -142,7 +143,7 @@ where P::IdentificationTuple, EquivocationOffence< P::IdentificationTuple, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, >, P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 4bc7e3823172f..ff8ea8289fb82 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -305,7 +305,7 @@ pub mod pallet { _, Twox64Concat, BountyIndex, - Bounty, frame_system::pallet_prelude::BlockNumberFor>, + Bounty, BlockNumberFor>, >; /// The description of each bounty. diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index d822476a7cb1b..1eedeaa5a1ae3 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { BountyIndex, Twox64Concat, BountyIndex, - ChildBounty, frame_system::pallet_prelude::BlockNumberFor>, + ChildBounty, BlockNumberFor>, >; /// The description of each child-bounty. @@ -816,7 +816,7 @@ impl Pallet { fn ensure_bounty_active( bounty_id: BountyIndex, - ) -> Result<(T::AccountId, frame_system::pallet_prelude::BlockNumberFor), DispatchError> { + ) -> Result<(T::AccountId, BlockNumberFor), DispatchError> { let parent_bounty = pallet_bounties::Pallet::::bounties(bounty_id) .ok_or(BountiesError::::InvalidIndex)?; if let BountyStatus::Active { curator, update_due } = parent_bounty.get_status() { diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 4844722b94694..e9ab173801c2d 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -276,7 +276,7 @@ pub mod pallet { _, Identity, T::Hash, - Votes>, + Votes>, OptionQuery, >; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index ea431f1c87ba9..ef8dc65e86300 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -34,6 +34,7 @@ use frame_support::{ weights::Weight, Blake2_128Concat, BoundedVec, StorageHasher, }; +use frame_system::pallet_prelude::BlockNumberFor; use frame_system::RawOrigin; use pallet_contracts_primitives::ExecReturnValue; use smallvec::{Array, SmallVec}; @@ -48,7 +49,7 @@ use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; pub type SeedOf = ::Hash; -pub type BlockNumberOf = frame_system::pallet_prelude::BlockNumberFor; +pub type BlockNumberOf = BlockNumberFor; pub type ExecResult = Result; /// A type that represents a topic of an event. At the moment a hash is used. @@ -394,7 +395,7 @@ pub struct Stack<'a, T: Config, E> { /// The timestamp at the point of call stack instantiation. timestamp: MomentOf, /// The block number at the time of call stack instantiation. - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, /// The nonce is cached here when accessed. It is written back when the call stack /// finishes executing. Please refer to [`Nonce`] to a description of /// the nonce itself. @@ -1356,7 +1357,7 @@ where ); } - fn block_number(&self) -> frame_system::pallet_prelude::BlockNumberFor { + fn block_number(&self) -> BlockNumberFor { self.block_number } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index df69e0d312922..41daefd621625 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -342,7 +342,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_idle( - _block: frame_system::pallet_prelude::BlockNumberFor, + _block: BlockNumberFor, mut remaining_weight: Weight, ) -> Weight { use migration::MigrateResult::*; diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 027fc71c7da18..86f5b78f7f528 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -35,6 +35,7 @@ use frame_support::{ ReservableCurrency, WithdrawReasons, }, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, ArithmeticError, Perbill, @@ -68,7 +69,7 @@ type BalanceOf = type VotingOf = Voting< BalanceOf, ::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, PollIndexOf, >::MaxVotes, >; @@ -76,7 +77,7 @@ type VotingOf = Voting< type DelegatingOf = Delegating< BalanceOf, ::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; pub type TallyOf = Tally, >::MaxTurnout>; pub type VotesOf = BalanceOf; diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index ca4071f9faa86..9c0e85ebc58d7 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -195,10 +195,10 @@ pub mod pallet { pub type ParamsOf = ParamsType< >::Balance, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, RANK_COUNT, >; - pub type MemberStatusOf = MemberStatus>; + pub type MemberStatusOf = MemberStatus>; pub type RankOf = <>::Members as RankedMembers>::Rank; /// The overall status of the system. diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 4bd868baebdf5..18ddeda3c13a1 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -166,6 +166,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::OriginFor; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, @@ -395,7 +396,7 @@ pub mod pallet { Twox64Concat, ReferendumIndex, ReferendumInfo< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -413,7 +414,7 @@ pub mod pallet { Voting< BalanceOf, T::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::MaxVotes, >, ValueQuery, @@ -439,7 +440,7 @@ pub mod pallet { Identity, H256, ( - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedVec, ), >; @@ -497,7 +498,7 @@ pub mod pallet { Vetoed { who: T::AccountId, proposal_hash: H256, - until: frame_system::pallet_prelude::BlockNumberFor, + until: BlockNumberFor, }, /// A proposal_hash has been blacklisted permanently. Blacklisted { proposal_hash: H256 }, @@ -588,7 +589,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Weight: see `begin_block` - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { Self::begin_block(n) } } @@ -798,8 +799,8 @@ pub mod pallet { pub fn fast_track( origin: OriginFor, proposal_hash: H256, - voting_period: frame_system::pallet_prelude::BlockNumberFor, - delay: frame_system::pallet_prelude::BlockNumberFor, + voting_period: BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { // Rather complicated bit of code to ensure that either: // - `voting_period` is at least `FastTrackVotingPeriod` and `origin` is @@ -1229,11 +1230,11 @@ impl Pallet { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( - n: frame_system::pallet_prelude::BlockNumberFor, + n: BlockNumberFor, ) -> Vec<( ReferendumIndex, ReferendumStatus< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -1244,12 +1245,12 @@ impl Pallet { } fn maturing_referenda_at_inner( - n: frame_system::pallet_prelude::BlockNumberFor, + n: BlockNumberFor, range: core::ops::Range, ) -> Vec<( ReferendumIndex, ReferendumStatus< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -1271,7 +1272,7 @@ impl Pallet { pub fn internal_start_referendum( proposal: BoundedCallOf, threshold: VoteThreshold, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> ReferendumIndex { >::inject_referendum( >::block_number().saturating_add(T::VotingPeriod::get()), @@ -1293,13 +1294,13 @@ impl Pallet { /// Ok if the given referendum is active, Err otherwise fn ensure_ongoing( r: ReferendumInfo< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, ) -> Result< ReferendumStatus< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -1315,7 +1316,7 @@ impl Pallet { ref_index: ReferendumIndex, ) -> Result< ReferendumStatus< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -1575,10 +1576,10 @@ impl Pallet { /// Start a referendum fn inject_referendum( - end: frame_system::pallet_prelude::BlockNumberFor, + end: BlockNumberFor, proposal: BoundedCallOf, threshold: VoteThreshold, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> ReferendumIndex { let ref_index = Self::referendum_count(); ReferendumCount::::put(ref_index + 1); @@ -1591,7 +1592,7 @@ impl Pallet { } /// Table the next waiting proposal for a vote. - fn launch_next(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { + fn launch_next(now: BlockNumberFor) -> DispatchResult { if LastTabledWasExternal::::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { @@ -1601,7 +1602,7 @@ impl Pallet { } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { + fn launch_external(now: BlockNumberFor) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); Self::deposit_event(Event::::ExternalTabled); @@ -1619,7 +1620,7 @@ impl Pallet { } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: frame_system::pallet_prelude::BlockNumberFor) -> DispatchResult { + fn launch_public(now: BlockNumberFor) -> DispatchResult { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter().enumerate().max_by_key( // defensive only: All current public proposals have an amount locked @@ -1652,10 +1653,10 @@ impl Pallet { } fn bake_referendum( - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, index: ReferendumIndex, status: ReferendumStatus< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, >, @@ -1693,7 +1694,7 @@ impl Pallet { /// ## Complexity: /// If a referendum is launched or maturing, this will take full block weight if queue is not /// empty. Otherwise, `O(R)` where `R` is the number of unbaked referenda. - fn begin_block(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn begin_block(now: BlockNumberFor) -> Weight { let max_block_weight = T::BlockWeights::get().max_block; let mut weight = Weight::zero(); diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index 78b27d6d15201..3c9f18516ed41 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -19,6 +19,7 @@ use crate::*; use frame_support::{pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, BoundedVec}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::H256; /// The log target. @@ -46,7 +47,7 @@ mod v0 { frame_support::Twox64Concat, ReferendumIndex, ReferendumInfo< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::Hash, BalanceOf, >, @@ -89,7 +90,7 @@ pub mod v1 { ReferendumInfoOf::::translate( |index, old: ReferendumInfo< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::Hash, BalanceOf, >| { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index fd0a3c44aec20..8be9b72c2af35 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -242,6 +242,7 @@ use frame_support::{ DefaultNoBound, EqNoBound, PartialEqNoBound, }; use frame_system::{ensure_none, offchain::SendTransactionTypes}; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_arithmetic::{ traits::{CheckedAdd, Zero}, @@ -747,7 +748,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(now: BlockNumberFor) -> Weight { let next_election = T::DataProvider::next_election_prediction(now).max(now); let signed_deadline = T::SignedPhase::get() + T::UnsignedPhase::get(); @@ -824,7 +825,7 @@ pub mod pallet { } } - fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { + fn offchain_worker(now: BlockNumberFor) { use sp_runtime::offchain::storage_lock::{BlockAndTime, StorageLock}; // Create a lock with the maximum deadline of number of blocks in the unsigned phase. @@ -887,7 +888,7 @@ pub mod pallet { #[cfg(feature = "try-runtime")] fn try_state( - _n: frame_system::pallet_prelude::BlockNumberFor, + _n: BlockNumberFor, ) -> Result<(), TryRuntimeError> { Self::do_try_state() } @@ -1158,8 +1159,8 @@ pub mod pallet { Slashed { account: ::AccountId, value: BalanceOf }, /// There was a phase transition in a given round. PhaseTransitioned { - from: Phase>, - to: Phase>, + from: Phase>, + to: Phase>, round: u32, }, } @@ -1264,7 +1265,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn current_phase)] pub type CurrentPhase = - StorageValue<_, Phase>, ValueQuery>; + StorageValue<_, Phase>, ValueQuery>; /// Current best solution, signed or unsigned, queued to be returned upon `elect`. /// @@ -1356,7 +1357,7 @@ pub mod pallet { impl Pallet { /// Internal logic of the offchain worker, to be executed only when the offchain lock is /// acquired with success. - fn do_synchronized_offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { + fn do_synchronized_offchain_worker(now: BlockNumberFor) { let current_phase = Self::current_phase(); log!(trace, "lock for offchain worker acquired. Phase = {:?}", current_phase); match current_phase { @@ -1382,7 +1383,7 @@ impl Pallet { } /// Phase transition helper. - pub(crate) fn phase_transition(to: Phase>) { + pub(crate) fn phase_transition(to: Phase>) { log!(info, "Starting phase {:?}, round {}.", to, Self::round()); Self::deposit_event(Event::PhaseTransitioned { from: >::get(), @@ -1679,7 +1680,7 @@ impl Pallet { impl ElectionProviderBase for Pallet { type AccountId = T::AccountId; - type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; + type BlockNumber = BlockNumberFor; type Error = ElectionError; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index c2ac8ff77b3f7..06477a0c581e8 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -27,6 +27,7 @@ use frame_election_provider_support::NposSolution; use frame_support::traits::{ defensive_prelude::*, Currency, Get, OnUnbalanced, ReservableCurrency, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_arithmetic::traits::SaturatedConversion; use sp_core::bounded::BoundedVec; use sp_npos_elections::ElectionScore; @@ -101,7 +102,7 @@ pub type SignedSubmissionOf = SignedSubmission< /// Always sorted vector of a score, submitted at the given block number, which can be found at the /// given index (`u32`) of the `SignedSubmissionsMap`. pub type SubmissionIndicesOf = BoundedVec< - (ElectionScore, frame_system::pallet_prelude::BlockNumberFor, u32), + (ElectionScore, BlockNumberFor, u32), ::SignedMaxSubmissions, >; @@ -216,7 +217,7 @@ impl SignedSubmissions { fn swap_out_submission( &mut self, remove_pos: usize, - insert: Option<(ElectionScore, frame_system::pallet_prelude::BlockNumberFor, u32)>, + insert: Option<(ElectionScore, BlockNumberFor, u32)>, ) -> Option> { if remove_pos >= self.indices.len() { return None diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index bb374582f9a00..d25aa448f7933 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -30,6 +30,7 @@ use frame_support::{ BoundedVec, }; use frame_system::offchain::SubmitTransaction; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, assignment_staked_to_ratio_normalized, ElectionResult, @@ -299,13 +300,13 @@ impl Pallet { /// Returns `Ok(())` if offchain worker limit is respected, `Err(reason)` otherwise. If `Ok()` /// is returned, `now` is written in storage and will be used in further calls as the baseline. pub fn ensure_offchain_repeat_frequency( - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, ) -> Result<(), MinerError> { let threshold = T::OffchainRepeat::get(); let last_block = StorageValueRef::persistent(OFFCHAIN_LAST_BLOCK); let mutate_stat = last_block.mutate::<_, &'static str, _>( - |maybe_head: Result>, _>| { + |maybe_head: Result>, _>| { match maybe_head { Ok(Some(head)) if now < head => Err("fork."), Ok(Some(head)) if now >= head && now <= head + threshold => diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index affc474bff1ed..b94581e2ed16c 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -287,7 +287,7 @@ pub mod pallet { /// What to do at the end of each block. /// /// Checks if an election needs to happen or not. - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let term_duration = T::TermDuration::get(); if !term_duration.is_zero() && (n % term_duration).is_zero() { Self::do_phragmen() @@ -333,7 +333,7 @@ pub mod pallet { #[cfg(feature = "try-runtime")] fn try_state( - _n: frame_system::pallet_prelude::BlockNumberFor, + _n: BlockNumberFor, ) -> Result<(), TryRuntimeError> { Self::do_try_state() } diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index d927c3ad4d9bd..7ccb2661117db 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -388,21 +388,21 @@ pub mod pallet { // dispatched. // // This function must return the weight consumed by `on_initialize` and `on_finalize`. - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { // Anything that needs to be done at the start of the block. // We don't do anything here. Weight::zero() } // `on_finalize` is executed at the end of block after all extrinsic are dispatched. - fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(_n: BlockNumberFor) { // Perform necessary data/state clean up here. } // A runtime code run after every block and have access to extended set of APIs. // // For instance you can generate extrinsics for the upcoming produced block. - fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor) { + fn offchain_worker(_n: BlockNumberFor) { // We don't do anything here. // but we could dispatch extrinsic (transaction/unsigned/inherent) using // sp_io::submit_extrinsic. diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index 389cd6bfcc27c..5b43d15c2559f 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -183,7 +183,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub foo: u32, - pub bar: frame_system::pallet_prelude::BlockNumberFor, + pub bar: BlockNumberFor, } impl Default for GenesisConfig { @@ -249,23 +249,23 @@ pub mod pallet { /// All the possible hooks that a pallet can have. See [`frame_support::traits::Hooks`] for more /// info. #[pallet::hooks] - impl Hooks> for Pallet { + impl Hooks> for Pallet { fn integrity_test() {} - fn offchain_worker(_n: frame_system::pallet_prelude::BlockNumberFor) { + fn offchain_worker(_n: BlockNumberFor) { unimplemented!() } - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { unimplemented!() } - fn on_finalize(_n: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(_n: BlockNumberFor) { unimplemented!() } fn on_idle( - _n: frame_system::pallet_prelude::BlockNumberFor, + _n: BlockNumberFor, _remaining_weight: Weight, ) -> Weight { unimplemented!() @@ -287,7 +287,7 @@ pub mod pallet { #[cfg(feature = "try-runtime")] fn try_state( - _n: frame_system::pallet_prelude::BlockNumberFor, + _n: BlockNumberFor, ) -> Result<(), TryRuntimeError> { unimplemented!() } diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 765cfcfa04f67..59e97c9a28a65 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -54,6 +54,7 @@ use frame_system::{ SignedPayload, Signer, SigningTypes, SubmitTransaction, }, }; +use frame_system::pallet_prelude::BlockNumberFor; use lite_json::json::JsonValue; use sp_core::crypto::KeyTypeId; use sp_runtime::{ @@ -171,7 +172,7 @@ pub mod pallet { /// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs), /// so the code should be able to handle that. /// You can use `Local Storage` API to coordinate runs of the worker. - fn offchain_worker(block_number: frame_system::pallet_prelude::BlockNumberFor) { + fn offchain_worker(block_number: BlockNumberFor) { // Note that having logs compiled to WASM may cause the size of the blob to increase // significantly. You can use `RuntimeDebug` custom derive to hide details of the types // in WASM. The `sp-api` crate also provides a feature `disable-logging` to disable @@ -258,7 +259,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned( origin: OriginFor, - _block_number: frame_system::pallet_prelude::BlockNumberFor, + _block_number: BlockNumberFor, price: u32, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -275,7 +276,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned_with_signed_payload( origin: OriginFor, - price_payload: PricePayload>, + price_payload: PricePayload>, _signature: T::Signature, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -342,7 +343,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn next_unsigned_at)] pub(super) type NextUnsignedAt = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; + StorageValue<_, BlockNumberFor, ValueQuery>; } /// Payload used by this example crate to hold price @@ -355,7 +356,7 @@ pub struct PricePayload { } impl SignedPayload - for PricePayload> + for PricePayload> { fn public(&self) -> T::Public { self.public.clone() @@ -378,7 +379,7 @@ impl Pallet { /// /// Returns a type of transaction that should be produced in current run. fn choose_transaction_type( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> TransactionType { /// A friendlier name for the error that is going to be returned in case we are in the grace /// period. @@ -396,7 +397,7 @@ impl Pallet { // happen to be executed concurrently. let res = val.mutate( |last_send: Result< - Option>, + Option>, StorageRetrievalError, >| { match last_send { @@ -487,7 +488,7 @@ impl Pallet { /// A helper function to fetch the price and send a raw unsigned transaction. fn fetch_price_and_send_raw_unsigned( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -521,7 +522,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_any_account( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -551,7 +552,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_all_accounts( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -685,7 +686,7 @@ impl Pallet { } fn validate_transaction_parameters( - block_number: &frame_system::pallet_prelude::BlockNumberFor, + block_number: &BlockNumberFor, new_price: &u32, ) -> TransactionValidity { // Now let's check if the transaction has any chance to succeed. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 446e0e13f45f3..85eca6c356406 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -732,20 +732,20 @@ mod tests { impl Hooks> for Pallet { // module hooks. // one with block number arg and one without - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { println!("on_initialize({})", n); Weight::from_parts(175, 0) } fn on_idle( - n: frame_system::pallet_prelude::BlockNumberFor, + n: BlockNumberFor, remaining_weight: Weight, ) -> Weight { println!("on_idle{}, {})", n, remaining_weight); Weight::from_parts(175, 0) } - fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(n: BlockNumberFor) { println!("on_finalize({})", n); } @@ -754,7 +754,7 @@ mod tests { Weight::from_parts(200, 0) } - fn offchain_worker(n: frame_system::pallet_prelude::BlockNumberFor) { + fn offchain_worker(n: BlockNumberFor) { assert_eq!(frame_system::pallet_prelude::BlockNumberFor::::from(1u32), n); } } diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index ab7acdefd3541..0cd6651b5a905 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -272,9 +272,9 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet { + impl Hooks> for Pallet { fn on_idle( - _: frame_system::pallet_prelude::BlockNumberFor, + _: BlockNumberFor, remaining_weight: Weight, ) -> Weight { if remaining_weight.any_lt(T::DbWeight::get().reads(2)) { @@ -299,7 +299,7 @@ pub mod pallet { #[cfg(feature = "try-runtime")] fn try_state( - _n: frame_system::pallet_prelude::BlockNumberFor, + _n: BlockNumberFor, ) -> Result<(), TryRuntimeError> { // ensure that the value of `ErasToCheckPerBlock` is less than // `T::MaxErasToCheckPerBlock`. diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index 3b400dec1f037..73472c56c33e0 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -37,6 +37,7 @@ use codec::{self as codec, Decode, Encode}; use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_grandpa::{AuthorityId, EquivocationProof, RoundNumber, SetId, KEY_TYPE}; use sp_runtime::{ @@ -119,7 +120,7 @@ impl OffenceReportSystem< Option, ( - EquivocationProof>, + EquivocationProof>, T::KeyOwnerProof, ), > for EquivocationReportSystem @@ -138,7 +139,7 @@ where fn publish_evidence( evidence: ( - EquivocationProof>, + EquivocationProof>, T::KeyOwnerProof, ), ) -> Result<(), ()> { @@ -159,7 +160,7 @@ where fn check_evidence( evidence: ( - EquivocationProof>, + EquivocationProof>, T::KeyOwnerProof, ), ) -> Result<(), TransactionValidityError> { @@ -182,7 +183,7 @@ where fn process_evidence( reporter: Option, evidence: ( - EquivocationProof>, + EquivocationProof>, T::KeyOwnerProof, ), ) -> Result<(), DispatchError> { diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 9f44d67d21e74..be8c62546006d 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -42,6 +42,7 @@ use frame_support::{ weights::Weight, WeakBoundedVec, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_consensus_grandpa::{ ConsensusLog, EquivocationProof, ScheduledChange, SetId, GRANDPA_AUTHORITIES_KEY, @@ -122,7 +123,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(block_number: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(block_number: BlockNumberFor) { // check for scheduled pending authority set changes if let Some(pending_change) = >::get() { // emit signal if we're at the block that scheduled the change @@ -195,7 +196,7 @@ pub mod pallet { pub fn report_equivocation( origin: OriginFor, equivocation_proof: Box< - EquivocationProof>, + EquivocationProof>, >, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { @@ -223,7 +224,7 @@ pub mod pallet { pub fn report_equivocation_unsigned( origin: OriginFor, equivocation_proof: Box< - EquivocationProof>, + EquivocationProof>, >, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { @@ -252,8 +253,8 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::note_stalled())] pub fn note_stalled( origin: OriginFor, - delay: frame_system::pallet_prelude::BlockNumberFor, - best_finalized_block_number: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, + best_finalized_block_number: BlockNumberFor, ) -> DispatchResult { ensure_root(origin)?; @@ -295,7 +296,7 @@ pub mod pallet { #[pallet::type_value] pub(super) fn DefaultForState( - ) -> StoredState> { + ) -> StoredState> { StoredState::Live } @@ -304,7 +305,7 @@ pub mod pallet { #[pallet::getter(fn state)] pub(super) type State = StorageValue< _, - StoredState>, + StoredState>, ValueQuery, DefaultForState, >; @@ -314,14 +315,14 @@ pub mod pallet { #[pallet::getter(fn pending_change)] pub(super) type PendingChange = StorageValue< _, - StoredPendingChange, T::MaxAuthorities>, + StoredPendingChange, T::MaxAuthorities>, >; /// next block number where we can force a change. #[pallet::storage] #[pallet::getter(fn next_forced)] pub(super) type NextForced = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor>; + StorageValue<_, BlockNumberFor>; /// `true` if we are currently stalled. #[pallet::storage] @@ -329,8 +330,8 @@ pub mod pallet { pub(super) type Stalled = StorageValue< _, ( - frame_system::pallet_prelude::BlockNumberFor, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, + BlockNumberFor, ), >; @@ -449,7 +450,7 @@ impl Pallet { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. pub fn schedule_pause( - in_blocks: frame_system::pallet_prelude::BlockNumberFor, + in_blocks: BlockNumberFor, ) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); @@ -463,7 +464,7 @@ impl Pallet { /// Schedule a resume of GRANDPA after pausing. pub fn schedule_resume( - in_blocks: frame_system::pallet_prelude::BlockNumberFor, + in_blocks: BlockNumberFor, ) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); @@ -491,8 +492,8 @@ impl Pallet { /// an error if a change is already pending. pub fn schedule_change( next_authorities: AuthorityList, - in_blocks: frame_system::pallet_prelude::BlockNumberFor, - forced: Option>, + in_blocks: BlockNumberFor, + forced: Option>, ) -> DispatchResult { if !>::exists() { let scheduled_at = >::block_number(); @@ -529,7 +530,7 @@ impl Pallet { } /// Deposit one of this module's logs. - fn deposit_log(log: ConsensusLog>) { + fn deposit_log(log: ConsensusLog>) { let log = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); >::deposit_log(log); } @@ -555,7 +556,7 @@ impl Pallet { pub fn submit_unsigned_equivocation_report( equivocation_proof: EquivocationProof< T::Hash, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { @@ -563,8 +564,8 @@ impl Pallet { } fn on_stalled( - further_wait: frame_system::pallet_prelude::BlockNumberFor, - median: frame_system::pallet_prelude::BlockNumberFor, + further_wait: BlockNumberFor, + median: BlockNumberFor, ) { // when we record old authority sets we could try to figure out _who_ // failed. until then, we can't meaningfully guard against diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 8e46d02ddce22..05c4fadd7a25a 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -245,7 +245,7 @@ pub type IdentificationTuple = ( >>::Identification, ); -type OffchainResult = Result>>; +type OffchainResult = Result>>; #[frame_support::pallet] pub mod pallet { @@ -342,7 +342,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn heartbeat_after)] pub(super) type HeartbeatAfter = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; + StorageValue<_, BlockNumberFor, ValueQuery>; /// The current set of keys that may issue a heartbeat. #[pallet::storage] @@ -396,7 +396,7 @@ pub mod pallet { ))] pub fn heartbeat( origin: OriginFor, - heartbeat: Heartbeat>, + heartbeat: Heartbeat>, // since signature verification is done in `validate_unsigned` // we can skip doing it here again. _signature: ::Signature, @@ -508,7 +508,7 @@ pub mod pallet { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of being online. impl - pallet_authorship::EventHandler, frame_system::pallet_prelude::BlockNumberFor> + pallet_authorship::EventHandler, BlockNumberFor> for Pallet { fn note_author(author: ValidatorId) { @@ -555,7 +555,7 @@ impl Pallet { } pub(crate) fn send_heartbeats( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> OffchainResult>> { const START_HEARTBEAT_RANDOM_PERIOD: Permill = Permill::from_percent(10); const START_HEARTBEAT_FINAL_PERIOD: Permill = Permill::from_percent(80); @@ -618,7 +618,7 @@ impl Pallet { authority_index: u32, key: T::AuthorityId, session_index: SessionIndex, - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, validators_len: u32, ) -> OffchainResult { // A helper function to prepare heartbeat call. @@ -681,7 +681,7 @@ impl Pallet { fn with_heartbeat_lock( authority_index: u32, session_index: SessionIndex, - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, f: impl FnOnce() -> OffchainResult, ) -> OffchainResult { let key = { @@ -692,7 +692,7 @@ impl Pallet { let storage = StorageValueRef::persistent(&key); let res = storage.mutate( |status: Result< - Option>>, + Option>>, StorageRetrievalError, >| { // Check if there is already a lock for that particular block. diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index a30f95fa5e437..0f03fc9acaf6e 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -74,12 +74,13 @@ use safe_mix::TripletMix; use codec::Encode; use frame_support::{pallet_prelude::Weight, traits::Randomness}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; fn block_number_to_index( - block_number: frame_system::pallet_prelude::BlockNumberFor, + block_number: BlockNumberFor, ) -> usize { // on_initialize is called on the first block after genesis let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); @@ -92,7 +93,6 @@ pub use pallet::*; pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -102,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(block_number: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(block_number: BlockNumberFor) -> Weight { let parent_hash = >::parent_hash(); >::mutate(|ref mut values| { @@ -125,7 +125,7 @@ pub mod pallet { StorageValue<_, BoundedVec>, ValueQuery>; } -impl Randomness> for Pallet { +impl Randomness> for Pallet { /// This randomness uses a low-influence function, drawing upon the block hashes from the /// previous 81 blocks. Its result for any given subject will be known far in advance by anyone /// observing the chain. Any block producer has significant influence over their block hashes @@ -136,7 +136,7 @@ impl Randomness (T::Hash, frame_system::pallet_prelude::BlockNumberFor) { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let block_number = >::block_number(); let index = block_number_to_index::(block_number); diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 4c7d200a51569..89e4d061e876f 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -209,7 +209,7 @@ pub mod pallet { #[pallet::storage] pub(crate) type Lottery = StorageValue< _, - LotteryConfig, BalanceOf>, + LotteryConfig, BalanceOf>, >; /// Users who have purchased a ticket. (Lottery Index, Tickets Purchased) @@ -241,7 +241,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { Lottery::::mutate(|mut lottery| -> Weight { if let Some(config) = &mut lottery { let payout_block = @@ -352,8 +352,8 @@ pub mod pallet { pub fn start_lottery( origin: OriginFor, price: BalanceOf, - length: frame_system::pallet_prelude::BlockNumberFor, - delay: frame_system::pallet_prelude::BlockNumberFor, + length: BlockNumberFor, + delay: BlockNumberFor, repeat: bool, ) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 1e5fb35bbe8e1..e197feedc39d1 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -57,6 +57,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{log, weights::Weight}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_mmr_primitives::utils; use sp_runtime::{ traits::{self, One, Saturating}, @@ -92,7 +93,7 @@ pub struct ParentNumberAndHash { impl LeafDataProvider for ParentNumberAndHash { type LeafData = - (frame_system::pallet_prelude::BlockNumberFor, ::Hash); + (BlockNumberFor, ::Hash); fn leaf_data() -> Self::LeafData { ( @@ -121,7 +122,6 @@ pub(crate) type HashOf = <>::Hashing as traits::Hash>::Outp pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -202,7 +202,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(_n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { use primitives::LeafDataProvider; let leaves = Self::mmr_leaves(); let peaks_before = sp_mmr_primitives::utils::NodesUtils::new(leaves).number_of_peaks(); @@ -287,7 +287,7 @@ impl, I: 'static> Pallet { fn leaf_index_to_parent_block_num( leaf_index: LeafIndex, leaves_count: LeafIndex, - ) -> frame_system::pallet_prelude::BlockNumberFor { + ) -> BlockNumberFor { // leaves are zero-indexed and were added one per block since pallet activation, // while block numbers are one-indexed, so block number that added `leaf_idx` is: // `block_num = block_num_when_pallet_activated + leaf_idx + 1` @@ -300,7 +300,7 @@ impl, I: 'static> Pallet { /// Convert a block number into a leaf index. fn block_num_to_leaf_index( - block_num: frame_system::pallet_prelude::BlockNumberFor, + block_num: BlockNumberFor, ) -> Result where T: frame_system::Config, @@ -325,8 +325,8 @@ impl, I: 'static> Pallet { /// all the leaves to be present. /// It may return an error or panic if used incorrectly. pub fn generate_proof( - block_numbers: Vec>, - best_known_block_number: Option>, + block_numbers: Vec>, + best_known_block_number: Option>, ) -> Result<(Vec>, primitives::Proof>), primitives::Error> { // check whether best_known_block_number provided, else use current best block let best_known_block_number = diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 56e5c6c60a947..0dcdc4df288f0 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -60,6 +60,7 @@ use frame_support::{ BoundedVec, RuntimeDebug, }; use frame_system::{self as system, RawOrigin}; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ @@ -184,7 +185,7 @@ pub mod pallet { Blake2_128Concat, [u8; 32], Multisig< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BalanceOf, T::AccountId, T::MaxSignatories, @@ -231,14 +232,14 @@ pub mod pallet { /// A multisig operation has been approved by someone. MultisigApproval { approving: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, /// A multisig operation has been executed. MultisigExecuted { approving: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, result: DispatchResult, @@ -246,7 +247,7 @@ pub mod pallet { /// A multisig operation has been cancelled. MultisigCancelled { cancelling: T::AccountId, - timepoint: Timepoint>, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, @@ -371,7 +372,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call: Box<::RuntimeCall>, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -428,7 +429,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call_hash: [u8; 32], max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -470,7 +471,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - timepoint: Timepoint>, + timepoint: Timepoint>, call_hash: [u8; 32], ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -516,7 +517,7 @@ impl Pallet { who: T::AccountId, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>>, + maybe_timepoint: Option>>, call_or_hash: CallOrHash, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -642,7 +643,7 @@ impl Pallet { } /// The current `Timepoint`. - pub fn timepoint() -> Timepoint> { + pub fn timepoint() -> Timepoint> { Timepoint { height: >::block_number(), index: >::extrinsic_index().unwrap_or_default(), diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 63b829577d46d..967bffffb0a8d 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -41,7 +41,7 @@ type BalanceOf = type CollectionConfigOf = CollectionConfig< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::NftCollectionId, >; @@ -62,7 +62,7 @@ where T::AccountId, CollectionConfig< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::NftCollectionId, >, > + Mutate, diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 137fd33ec40a2..5676ef57c2205 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -343,7 +343,7 @@ pub mod pallet { T::CollectionId, T::ItemId, PriceWithDirection>, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, OptionQuery, >; @@ -414,7 +414,7 @@ pub mod pallet { item: T::ItemId, owner: T::AccountId, delegate: T::AccountId, - deadline: Option>, + deadline: Option>, }, /// An approval for a `delegate` account to transfer the `item` of an item /// `collection` was cancelled by its `owner`. @@ -509,7 +509,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: frame_system::pallet_prelude::BlockNumberFor, + deadline: BlockNumberFor, }, /// The swap was cancelled. SwapCancelled { @@ -518,7 +518,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: frame_system::pallet_prelude::BlockNumberFor, + deadline: BlockNumberFor, }, /// The swap has been claimed. SwapClaimed { @@ -529,7 +529,7 @@ pub mod pallet { received_item: T::ItemId, received_item_owner: T::AccountId, price: Option>>, - deadline: frame_system::pallet_prelude::BlockNumberFor, + deadline: BlockNumberFor, }, /// New attributes have been set for an `item` of the `collection`. PreSignedAttributesSet { @@ -1236,7 +1236,7 @@ pub mod pallet { collection: T::CollectionId, item: T::ItemId, delegate: AccountIdLookupOf, - maybe_deadline: Option>, + maybe_deadline: Option>, ) -> DispatchResult { let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) @@ -1661,7 +1661,7 @@ pub mod pallet { collection: T::CollectionId, mint_settings: MintSettings< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::CollectionId, >, ) -> DispatchResult { @@ -1759,7 +1759,7 @@ pub mod pallet { desired_collection: T::CollectionId, maybe_desired_item: Option, maybe_price: Option>>, - duration: frame_system::pallet_prelude::BlockNumberFor, + duration: BlockNumberFor, ) -> DispatchResult { let origin = ensure_signed(origin)?; Self::do_create_swap( diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index 7c29f07e2222e..c875dc9e71253 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -26,6 +26,7 @@ use frame_support::{ traits::Get, BoundedBTreeMap, BoundedBTreeSet, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter}; pub(super) type DepositBalanceOf = @@ -34,7 +35,7 @@ pub(super) type CollectionDetailsFor = CollectionDetails<::AccountId, DepositBalanceOf>; pub(super) type ApprovalsOf = BoundedBTreeMap< ::AccountId, - Option>, + Option>, >::ApprovalsLimit, >; pub(super) type ItemAttributesApprovals = @@ -58,21 +59,21 @@ pub(super) type ItemTipOf = ItemTip< >; pub(super) type CollectionConfigFor = CollectionConfig< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >::CollectionId, >; pub(super) type PreSignedMintOf = PreSignedMint< >::CollectionId, >::ItemId, ::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BalanceOf, >; pub(super) type PreSignedAttributesOf = PreSignedAttributes< >::CollectionId, >::ItemId, ::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; /// Information about a collection. diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index cfe8a6674adc1..165946b8fb636 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -188,12 +188,12 @@ pub mod pallet { fungible::Debt<::AccountId, ::Currency>; type ReceiptRecordOf = ReceiptRecord< ::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BalanceOf, >; type IssuanceInfoOf = IssuanceInfo>; type SummaryRecordOf = - SummaryRecord, BalanceOf>; + SummaryRecord, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; @@ -414,7 +414,7 @@ pub mod pallet { /// The identity of the receipt. index: ReceiptIndex, /// The block number at which the receipt may be thawed. - expiry: frame_system::pallet_prelude::BlockNumberFor, + expiry: BlockNumberFor, /// The owner of the receipt. who: T::AccountId, /// The proportion of the effective total issuance which the receipt represents. @@ -509,7 +509,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let mut weight_counter = WeightCounter { used: Weight::zero(), limit: T::MaxIntakeWeight::get() }; if T::IntakePeriod::get().is_zero() || (n % T::IntakePeriod::get()).is_zero() { @@ -1063,7 +1063,7 @@ pub mod pallet { pub(crate) fn process_queue( duration: u32, - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, our_account: &T::AccountId, issuance: &IssuanceInfo>, max_bids: u32, @@ -1107,7 +1107,7 @@ pub mod pallet { pub(crate) fn process_bid( mut bid: BidOf, - expiry: frame_system::pallet_prelude::BlockNumberFor, + expiry: BlockNumberFor, _our_account: &T::AccountId, issuance: &IssuanceInfo>, remaining: &mut BalanceOf, diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index fcc901bbfc614..2104eadf11fb4 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -366,6 +366,7 @@ use frame_support::{ }, DefaultNoBound, PalletError, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_core::U256; use sp_runtime::{ @@ -676,10 +677,10 @@ pub struct Commission { pub max: Option, /// Optional configuration around how often commission can be updated, and when the last /// commission update took place. - pub change_rate: Option>>, + pub change_rate: Option>>, /// The block from where throttling should be checked from. This value will be updated on all /// commission updates and when setting an initial `change_rate`. - pub throttle_from: Option>, + pub throttle_from: Option>, } impl Commission { @@ -813,7 +814,7 @@ impl Commission { /// throttling can be checked from this block. fn try_update_change_rate( &mut self, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, ) -> DispatchResult { ensure!(!&self.less_restrictive(&change_rate), Error::::CommissionChangeRateNotAllowed); @@ -835,7 +836,7 @@ impl Commission { /// `change_rate` is currently set, `false` is returned. fn less_restrictive( &self, - new: &CommissionChangeRate>, + new: &CommissionChangeRate>, ) -> bool { self.change_rate .as_ref() @@ -1764,7 +1765,7 @@ pub mod pallet { /// A pool's commission `change_rate` has been changed. PoolCommissionChangeRateUpdated { pool_id: PoolId, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, }, /// Pool commission has been claimed. PoolCommissionClaimed { pool_id: PoolId, commission: BalanceOf }, @@ -2600,7 +2601,7 @@ pub mod pallet { pub fn set_commission_change_rate( origin: OriginFor, pool_id: PoolId, - change_rate: CommissionChangeRate>, + change_rate: CommissionChangeRate>, ) -> DispatchResult { let who = ensure_signed(origin)?; let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index a985181bbb3b0..b7c8d2af17b1b 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -41,6 +41,7 @@ use frame_support::{ RuntimeDebug, }; use frame_system::{self as system, ensure_signed}; +use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; @@ -227,7 +228,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -247,7 +248,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -291,7 +292,7 @@ pub mod pallet { pub fn create_pure( origin: OriginFor, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, index: u16, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -341,7 +342,7 @@ pub mod pallet { spawner: AccountIdLookupOf, proxy_type: T::ProxyType, index: u16, - #[pallet::compact] height: frame_system::pallet_prelude::BlockNumberFor, + #[pallet::compact] height: BlockNumberFor, #[pallet::compact] ext_index: u32, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -535,14 +536,14 @@ pub mod pallet { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, }, /// A proxy was removed. ProxyRemoved { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, }, } @@ -579,7 +580,7 @@ pub mod pallet { ProxyDefinition< T::AccountId, T::ProxyType, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, T::MaxProxies, >, @@ -600,7 +601,7 @@ pub mod pallet { Announcement< T::AccountId, CallHashOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, T::MaxPending, >, @@ -626,7 +627,7 @@ impl Pallet { who: &T::AccountId, proxy_type: &T::ProxyType, index: u16, - maybe_when: Option<(frame_system::pallet_prelude::BlockNumberFor, u32)>, + maybe_when: Option<(BlockNumberFor, u32)>, ) -> T::AccountId { let (height, ext_index) = maybe_when.unwrap_or_else(|| { ( @@ -652,7 +653,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { ensure!(delegator != &delegatee, Error::::NoSelfProxy); Proxies::::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| { @@ -692,7 +693,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: frame_system::pallet_prelude::BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { Proxies::::try_mutate_exists(delegator, |x| { let (mut proxies, old_deposit) = x.take().ok_or(Error::::NotFound)?; @@ -752,7 +753,7 @@ impl Pallet { &Announcement< T::AccountId, CallHashOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, ) -> bool, >( @@ -784,14 +785,14 @@ impl Pallet { ProxyDefinition< T::AccountId, T::ProxyType, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, DispatchError, > { let f = |x: &ProxyDefinition< T::AccountId, T::ProxyType, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >| -> bool { &x.delegate == delegate && @@ -804,7 +805,7 @@ impl Pallet { def: ProxyDefinition< T::AccountId, T::ProxyType, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, real: T::AccountId, call: ::RuntimeCall, diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index d58e88911a691..54a43343a7a73 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -338,7 +338,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - RecoveryConfig, BalanceOf, FriendsOf>, + RecoveryConfig, BalanceOf, FriendsOf>, >; /// Active recovery attempts. @@ -353,7 +353,7 @@ pub mod pallet { T::AccountId, Twox64Concat, T::AccountId, - ActiveRecovery, BalanceOf, FriendsOf>, + ActiveRecovery, BalanceOf, FriendsOf>, >; /// The list of allowed proxy accounts. @@ -444,7 +444,7 @@ pub mod pallet { origin: OriginFor, friends: Vec, threshold: u16, - delay_period: frame_system::pallet_prelude::BlockNumberFor, + delay_period: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; // Check account is not already set up for recovery diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 5d2574ce08b5b..ad83fd4f8e03a 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -77,6 +77,7 @@ use frame_support::{ }, BoundedVec, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Bounded, Dispatchable, One, Saturating, Zero}, @@ -445,7 +446,7 @@ pub mod pallet { origin: OriginFor, proposal_origin: Box>, proposal: BoundedCallOf, - enactment_moment: DispatchTime>, + enactment_moment: DispatchTime>, ) -> DispatchResult { let proposal_origin = *proposal_origin; let who = T::SubmitOrigin::ensure_origin(origin, &proposal_origin)?; @@ -717,7 +718,7 @@ pub mod pallet { impl, I: 'static> Polling for Pallet { type Index = ReferendumIndex; type Votes = VotesOf; - type Moment = frame_system::pallet_prelude::BlockNumberFor; + type Moment = BlockNumberFor; type Class = TrackIdOf; fn classes() -> Vec { @@ -729,7 +730,7 @@ impl, I: 'static> Polling for Pallet { f: impl FnOnce( PollStatus< &mut T::Tally, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, TrackIdOf, >, ) -> R, @@ -753,7 +754,7 @@ impl, I: 'static> Polling for Pallet { f: impl FnOnce( PollStatus< &mut T::Tally, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, TrackIdOf, >, ) -> Result, @@ -872,7 +873,7 @@ impl, I: 'static> Pallet { fn schedule_enactment( index: ReferendumIndex, track: &TrackInfoOf, - desired: DispatchTime>, + desired: DispatchTime>, origin: PalletsOriginOf, call: BoundedCallOf, ) { @@ -894,8 +895,8 @@ impl, I: 'static> Pallet { /// Set an alarm to dispatch `call` at block number `when`. fn set_alarm( call: BoundedCallOf, - when: frame_system::pallet_prelude::BlockNumberFor, - ) -> Option<(frame_system::pallet_prelude::BlockNumberFor, ScheduleAddressOf)> { + when: BlockNumberFor, + ) -> Option<(BlockNumberFor, ScheduleAddressOf)> { let alarm_interval = T::AlarmInterval::get().max(One::one()); // Alarm must go off no earlier than `when`. // This rounds `when` upwards to the next multiple of `alarm_interval`. @@ -928,9 +929,9 @@ impl, I: 'static> Pallet { fn begin_deciding( status: &mut ReferendumStatusOf, index: ReferendumIndex, - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, track: &TrackInfoOf, - ) -> (Option>, BeginDecidingBranch) { + ) -> (Option>, BeginDecidingBranch) { let is_passing = Self::is_passing( &status.tally, Zero::zero(), @@ -966,11 +967,11 @@ impl, I: 'static> Pallet { /// /// If `None`, then it is queued and should be nudged automatically as the queue gets drained. fn ready_for_deciding( - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, track: &TrackInfoOf, index: ReferendumIndex, status: &mut ReferendumStatusOf, - ) -> (Option>, ServiceBranch) { + ) -> (Option>, ServiceBranch) { let deciding_count = DecidingCount::::get(status.track); if deciding_count < track.max_deciding { // Begin deciding. @@ -1027,7 +1028,7 @@ impl, I: 'static> Pallet { fn ensure_alarm_at( status: &mut ReferendumStatusOf, index: ReferendumIndex, - alarm: frame_system::pallet_prelude::BlockNumberFor, + alarm: BlockNumberFor, ) -> bool { if status.alarm.as_ref().map_or(true, |&(when, _)| when != alarm) { // Either no alarm or one that was different @@ -1072,7 +1073,7 @@ impl, I: 'static> Pallet { /// `TrackQueue`. Basically this happens when a referendum is in the deciding queue and receives /// a vote, or when it moves into the deciding queue. fn service_referendum( - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, index: ReferendumIndex, mut status: ReferendumStatusOf, ) -> (ReferendumInfoOf, bool, ServiceBranch) { @@ -1231,7 +1232,7 @@ impl, I: 'static> Pallet { tally: &T::Tally, track_id: TrackIdOf, track: &TrackInfoOf, - ) -> frame_system::pallet_prelude::BlockNumberFor { + ) -> BlockNumberFor { deciding.confirming.unwrap_or_else(|| { // Set alarm to the point where the current voting would make it pass. let approval = tally.approval(track_id); @@ -1290,8 +1291,8 @@ impl, I: 'static> Pallet { /// `approval_needed`. fn is_passing( tally: &T::Tally, - elapsed: frame_system::pallet_prelude::BlockNumberFor, - period: frame_system::pallet_prelude::BlockNumberFor, + elapsed: BlockNumberFor, + period: BlockNumberFor, support_needed: &Curve, approval_needed: &Curve, id: TrackIdOf, diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index b9c30879cfaf1..bd4faabf48126 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -42,7 +42,7 @@ pub type PalletsOriginOf = pub type ReferendumInfoOf = ReferendumInfo< TrackIdOf, PalletsOriginOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, @@ -52,22 +52,22 @@ pub type ReferendumInfoOf = ReferendumInfo< pub type ReferendumStatusOf = ReferendumStatus< TrackIdOf, PalletsOriginOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, ::AccountId, ScheduleAddressOf, >; -pub type DecidingStatusOf = DecidingStatus>; +pub type DecidingStatusOf = DecidingStatus>; pub type TrackInfoOf = - TrackInfo, frame_system::pallet_prelude::BlockNumberFor>; + TrackInfo, BlockNumberFor>; pub type TrackIdOf = <>::Tracks as TracksInfo< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >>::Id; pub type ScheduleAddressOf = <>::Scheduler as Anon< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, CallOf, PalletsOriginOf, >>::Address; diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 3aa8600e9cc30..38a32290a1326 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -142,12 +142,12 @@ pub mod pallet { type Budget: Get>; } - pub type CycleIndexOf = frame_system::pallet_prelude::BlockNumberFor; + pub type CycleIndexOf = BlockNumberFor; pub type BalanceOf = <>::Paymaster as Pay>::Balance; pub type IdOf = <>::Paymaster as Pay>::Id; pub type StatusOf = StatusType< CycleIndexOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BalanceOf, >; pub type ClaimantStatusOf = ClaimantStatus, BalanceOf, IdOf>; @@ -392,7 +392,7 @@ pub mod pallet { pub fn last_active(who: &T::AccountId) -> Result, DispatchError> { Ok(Claimant::::get(&who).ok_or(Error::::NotInducted)?.last_active) } - pub fn cycle_period() -> frame_system::pallet_prelude::BlockNumberFor { + pub fn cycle_period() -> BlockNumberFor { T::RegistrationPeriod::get() + T::PayoutPeriod::get() } fn do_payout(who: T::AccountId, beneficiary: T::AccountId) -> DispatchResult { diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index c3eb1d1160fc3..a4223e750c01e 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -72,6 +72,7 @@ use frame_support::{ }, weights::{Weight, WeightMeter}, }; +use frame_system::pallet_prelude::BlockNumberFor; use frame_system::{self as system}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; @@ -123,7 +124,7 @@ use crate::{Scheduled as ScheduledV3, Scheduled as ScheduledV2}; pub type ScheduledV2Of = ScheduledV2< Vec, ::RuntimeCall, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -131,7 +132,7 @@ pub type ScheduledV2Of = ScheduledV2< pub type ScheduledV3Of = ScheduledV3< Vec, CallOrHashOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -139,7 +140,7 @@ pub type ScheduledV3Of = ScheduledV3< pub type ScheduledOf = Scheduled< TaskName, Bounded<::RuntimeCall>, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -232,14 +233,14 @@ pub mod pallet { #[pallet::storage] pub type IncompleteSince = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor>; + StorageValue<_, BlockNumberFor>; /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] pub type Agenda = StorageMap< _, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedVec>, T::MaxScheduledPerBlock>, ValueQuery, >; @@ -253,7 +254,7 @@ pub mod pallet { _, Twox64Concat, TaskName, - TaskAddress>, + TaskAddress>, >; /// Events type. @@ -261,28 +262,28 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Scheduled some task. - Scheduled { when: frame_system::pallet_prelude::BlockNumberFor, index: u32 }, + Scheduled { when: BlockNumberFor, index: u32 }, /// Canceled some task. - Canceled { when: frame_system::pallet_prelude::BlockNumberFor, index: u32 }, + Canceled { when: BlockNumberFor, index: u32 }, /// Dispatched some task. Dispatched { - task: TaskAddress>, + task: TaskAddress>, id: Option, result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. CallUnavailable { - task: TaskAddress>, + task: TaskAddress>, id: Option, }, /// The given task was unable to be renewed since the agenda is full at that block. PeriodicFailed { - task: TaskAddress>, + task: TaskAddress>, id: Option, }, /// The given task can never be executed since it is overweight. PermanentlyOverweight { - task: TaskAddress>, + task: TaskAddress>, id: Option, }, } @@ -304,7 +305,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Execute the scheduled calls - fn on_initialize(now: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(now: BlockNumberFor) -> Weight { let mut weight_counter = WeightMeter::from_limit(T::MaximumWeight::get()); Self::service_agendas(&mut weight_counter, now, u32::max_value()); weight_counter.consumed @@ -318,9 +319,9 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule( origin: OriginFor, - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, maybe_periodic: Option< - schedule::Period>, + schedule::Period>, >, priority: schedule::Priority, call: Box<::RuntimeCall>, @@ -342,7 +343,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] pub fn cancel( origin: OriginFor, - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, index: u32, ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; @@ -357,9 +358,9 @@ pub mod pallet { pub fn schedule_named( origin: OriginFor, id: TaskName, - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, maybe_periodic: Option< - schedule::Period>, + schedule::Period>, >, priority: schedule::Priority, call: Box<::RuntimeCall>, @@ -392,9 +393,9 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule_after( origin: OriginFor, - after: frame_system::pallet_prelude::BlockNumberFor, + after: BlockNumberFor, maybe_periodic: Option< - schedule::Period>, + schedule::Period>, >, priority: schedule::Priority, call: Box<::RuntimeCall>, @@ -417,9 +418,9 @@ pub mod pallet { pub fn schedule_named_after( origin: OriginFor, id: TaskName, - after: frame_system::pallet_prelude::BlockNumberFor, + after: BlockNumberFor, maybe_periodic: Option< - schedule::Period>, + schedule::Period>, >, priority: schedule::Priority, call: Box<::RuntimeCall>, @@ -464,7 +465,7 @@ impl> Pallet { Option< ScheduledV1< ::RuntimeCall, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, >, >, @@ -702,7 +703,7 @@ impl Pallet { Scheduled< TaskName, Bounded<::RuntimeCall>, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, OldOrigin, T::AccountId, >, @@ -729,8 +730,8 @@ impl Pallet { } fn resolve_time( - when: DispatchTime>, - ) -> Result, DispatchError> { + when: DispatchTime>, + ) -> Result, DispatchError> { let now = frame_system::Pallet::::block_number(); let when = match when { @@ -748,10 +749,10 @@ impl Pallet { } fn place_task( - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, what: ScheduledOf, ) -> Result< - TaskAddress>, + TaskAddress>, (DispatchError, ScheduledOf), > { let maybe_name = what.maybe_id; @@ -765,7 +766,7 @@ impl Pallet { } fn push_to_agenda( - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, what: ScheduledOf, ) -> Result)> { let mut agenda = Agenda::::get(when); @@ -787,7 +788,7 @@ impl Pallet { /// Remove trailing `None` items of an agenda at `when`. If all items are `None` remove the /// agenda record entirely. - fn cleanup_agenda(when: frame_system::pallet_prelude::BlockNumberFor) { + fn cleanup_agenda(when: BlockNumberFor) { let mut agenda = Agenda::::get(when); match agenda.iter().rposition(|i| i.is_some()) { Some(i) if agenda.len() > i + 1 => { @@ -802,12 +803,12 @@ impl Pallet { } fn do_schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result>, DispatchError> { + ) -> Result>, DispatchError> { let when = Self::resolve_time(when)?; let lookup_hash = call.lookup_hash(); @@ -837,7 +838,7 @@ impl Pallet { fn do_cancel( origin: Option, - (when, index): TaskAddress>, + (when, index): TaskAddress>, ) -> Result<(), DispatchError> { let scheduled = Agenda::::try_mutate(when, |agenda| { agenda.get_mut(index as usize).map_or( @@ -869,9 +870,9 @@ impl Pallet { } fn do_reschedule( - (when, index): TaskAddress>, - new_time: DispatchTime>, - ) -> Result>, DispatchError> { + (when, index): TaskAddress>, + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; if new_time == when { @@ -891,12 +892,12 @@ impl Pallet { fn do_schedule_named( id: TaskName, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result>, DispatchError> { + ) -> Result>, DispatchError> { // ensure id it is unique if Lookup::::contains_key(&id) { return Err(Error::::FailedToSchedule.into()) @@ -960,8 +961,8 @@ impl Pallet { fn do_reschedule_named( id: TaskName, - new_time: DispatchTime>, - ) -> Result>, DispatchError> { + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; let lookup = Lookup::::get(id); @@ -993,7 +994,7 @@ impl Pallet { /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. fn service_agendas( weight: &mut WeightMeter, - now: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, max: u32, ) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { @@ -1025,8 +1026,8 @@ impl Pallet { fn service_agenda( weight: &mut WeightMeter, executed: &mut u32, - now: frame_system::pallet_prelude::BlockNumberFor, - when: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, + when: BlockNumberFor, max: u32, ) -> bool { let mut agenda = Agenda::::get(when); @@ -1094,8 +1095,8 @@ impl Pallet { /// - Rescheduling the task for execution in a later agenda if periodic. fn service_task( weight: &mut WeightMeter, - now: frame_system::pallet_prelude::BlockNumberFor, - when: frame_system::pallet_prelude::BlockNumberFor, + now: BlockNumberFor, + when: BlockNumberFor, agenda_index: u32, is_first: bool, mut task: ScheduledOf, @@ -1204,17 +1205,17 @@ impl Pallet { impl> schedule::v2::Anon< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::RuntimeCall, T::PalletsOrigin, > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1230,32 +1231,32 @@ impl> fn reschedule( address: Self::Address, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when) } fn next_dispatch_time( (when, index): Self::Address, - ) -> Result, ()> { + ) -> Result, ()> { Agenda::::get(when).get(index as usize).ok_or(()).map(|_| when) } } impl> schedule::v2::Named< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::RuntimeCall, T::PalletsOrigin, > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule_named( id: Vec, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1273,7 +1274,7 @@ impl> fn reschedule_named( id: Vec, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { let name = blake2_256(&id[..]); Self::do_reschedule_named(name, when) @@ -1281,7 +1282,7 @@ impl> fn next_dispatch_time( id: Vec, - ) -> Result, ()> { + ) -> Result, ()> { let name = blake2_256(&id[..]); Lookup::::get(name) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) @@ -1291,16 +1292,16 @@ impl> impl schedule::v3::Anon< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::RuntimeCall, T::PalletsOrigin, > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; fn schedule( - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1314,14 +1315,14 @@ impl fn reschedule( address: Self::Address, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when).map_err(map_err_to_v3_err::) } fn next_dispatch_time( (when, index): Self::Address, - ) -> Result, DispatchError> { + ) -> Result, DispatchError> { Agenda::::get(when) .get(index as usize) .ok_or(DispatchError::Unavailable) @@ -1333,17 +1334,17 @@ use schedule::v3::TaskName; impl schedule::v3::Named< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ::RuntimeCall, T::PalletsOrigin, > for Pallet { - type Address = TaskAddress>; + type Address = TaskAddress>; fn schedule_named( id: TaskName, - when: DispatchTime>, - maybe_periodic: Option>>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1357,14 +1358,14 @@ impl fn reschedule_named( id: TaskName, - when: DispatchTime>, + when: DispatchTime>, ) -> Result { Self::do_reschedule_named(id, when).map_err(map_err_to_v3_err::) } fn next_dispatch_time( id: TaskName, - ) -> Result, DispatchError> { + ) -> Result, DispatchError> { Lookup::::get(id) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) .ok_or(DispatchError::Unavailable) diff --git a/frame/scheduler/src/migration.rs b/frame/scheduler/src/migration.rs index 654d3062bf6c0..6a294a7c98108 100644 --- a/frame/scheduler/src/migration.rs +++ b/frame/scheduler/src/migration.rs @@ -19,6 +19,7 @@ use super::*; use frame_support::traits::OnRuntimeUpgrade; +use frame_system::pallet_prelude::BlockNumberFor; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -34,12 +35,12 @@ pub mod v1 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, Vec< Option< ScheduledV1< ::RuntimeCall, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, >, >, @@ -51,7 +52,7 @@ pub mod v1 { Pallet, Twox64Concat, Vec, - TaskAddress>, + TaskAddress>, >; } @@ -63,7 +64,7 @@ pub mod v2 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, Vec>>, ValueQuery, >; @@ -73,7 +74,7 @@ pub mod v2 { Pallet, Twox64Concat, Vec, - TaskAddress>, + TaskAddress>, >; } @@ -85,7 +86,7 @@ pub mod v3 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, Vec>>, ValueQuery, >; @@ -95,7 +96,7 @@ pub mod v3 { Pallet, Twox64Concat, Vec, - TaskAddress>, + TaskAddress>, >; /// Migrate the scheduler pallet from V3 to V4. diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index bf2abfc4a8f33..144612fbe3dea 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -46,9 +46,9 @@ pub trait Config: { } -impl OnInitialize> for Pallet { +impl OnInitialize> for Pallet { fn on_initialize( - n: frame_system::pallet_prelude::BlockNumberFor, + n: BlockNumberFor, ) -> frame_support::weights::Weight { pallet_session::Pallet::::on_initialize(n) } diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index aa4045becd728..81f8452f3f976 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -126,6 +126,7 @@ use frame_support::{ weights::Weight, Parameter, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Convert, Member, One, OpaqueKeys, Zero}, ConsensusEngineId, KeyTypeId, Permill, RuntimeAppPublic, @@ -559,7 +560,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Called when a block is initialized. Will rotate session if it is the last /// block of the current session. - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { if T::ShouldEndSession::should_end_session(n) { Self::rotate_session(); T::BlockWeights::get().max_block @@ -901,18 +902,18 @@ impl ValidatorSet for Pallet { } } -impl EstimateNextNewSession> +impl EstimateNextNewSession> for Pallet { - fn average_session_length() -> frame_system::pallet_prelude::BlockNumberFor { + fn average_session_length() -> BlockNumberFor { T::NextSessionRotation::average_session_length() } /// This session pallet always calls new_session and next_session at the same time, hence we /// do a simple proxy and pass the function to next rotation. fn estimate_next_new_session( - now: frame_system::pallet_prelude::BlockNumberFor, - ) -> (Option>, Weight) { + now: BlockNumberFor, + ) -> (Option>, Weight) { T::NextSessionRotation::estimate_next_session_rotation(now) } } diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 95613e9d37776..8d9e688f9582f 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -417,7 +417,7 @@ impl BidKind { } pub type PayoutsFor = BoundedVec< - (frame_system::pallet_prelude::BlockNumberFor, BalanceOf), + (BlockNumberFor, BalanceOf), >::MaxPayouts, >; @@ -440,7 +440,7 @@ pub struct PayoutRecord { pub type PayoutRecordFor = PayoutRecord< BalanceOf, BoundedVec< - (frame_system::pallet_prelude::BlockNumberFor, BalanceOf), + (BlockNumberFor, BalanceOf), >::MaxPayouts, >, >; @@ -758,7 +758,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let mut weight = Weight::zero(); let weights = T::BlockWeights::get(); @@ -1409,7 +1409,7 @@ pub enum Period { impl, I: 'static> Pallet { /// Get the period we are currently in. - fn period() -> Period> { + fn period() -> Period> { let claim_period = T::ClaimPeriod::get(); let voting_period = T::VotingPeriod::get(); let rotation_period = voting_period + claim_period; @@ -1902,7 +1902,7 @@ impl, I: 'static> Pallet { candidate: &T::AccountId, value: BalanceOf, kind: BidKind>, - maturity: frame_system::pallet_prelude::BlockNumberFor, + maturity: BlockNumberFor, ) { let value = match kind { BidKind::Deposit(deposit) => { @@ -1941,7 +1941,7 @@ impl, I: 'static> Pallet { /// is not a member or if `value` is zero. fn bump_payout( who: &T::AccountId, - when: frame_system::pallet_prelude::BlockNumberFor, + when: BlockNumberFor, value: BalanceOf, ) { if value.is_zero() { @@ -2026,7 +2026,7 @@ impl, I: 'static> Pallet { /// /// This is a rather opaque calculation based on the formula here: /// https://www.desmos.com/calculator/9itkal1tce - fn lock_duration(x: u32) -> frame_system::pallet_prelude::BlockNumberFor { + fn lock_duration(x: u32) -> BlockNumberFor { let lock_pc = 100 - 50_000 / (x + 500); Percent::from_percent(lock_pc as u8) * T::MaxLockDuration::get() } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index b798e01609336..98971b0899363 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1022,8 +1022,8 @@ impl ElectionDataProvider for Pallet { } fn next_election_prediction( - now: frame_system::pallet_prelude::BlockNumberFor, - ) -> frame_system::pallet_prelude::BlockNumberFor { + now: BlockNumberFor, + ) -> BlockNumberFor { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1040,7 +1040,7 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: frame_system::pallet_prelude::BlockNumberFor = + let sessions_left: BlockNumberFor = match ForceEra::::get() { Forcing::ForceNone => Bounded::max_value(), Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), @@ -1241,7 +1241,7 @@ impl historical::SessionManager - pallet_authorship::EventHandler> + pallet_authorship::EventHandler> for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index a5b83e347acf5..cc6e74244699f 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -22,6 +22,7 @@ #![deny(warnings)] pub use frame_support::dispatch::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; pub use self::pallet::*; @@ -127,12 +128,12 @@ pub mod pallet_prelude { pub struct TestRandomness(sp_std::marker::PhantomData); impl - frame_support::traits::Randomness> + frame_support::traits::Randomness> for TestRandomness where T: frame_system::Config, { - fn random(subject: &[u8]) -> (Output, frame_system::pallet_prelude::BlockNumberFor) { + fn random(subject: &[u8]) -> (Output, BlockNumberFor) { use sp_runtime::traits::TrailingZeroInput; ( diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 245b55bbb83b2..3385c1b12539f 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -60,7 +60,7 @@ mod no_instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] pub type TestGenericValue = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, OptionQuery>; + StorageValue<_, BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap = StorageDoubleMap< @@ -68,7 +68,7 @@ mod no_instance { Blake2_128Concat, u32, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, u32, ValueQuery, >; @@ -76,9 +76,9 @@ mod no_instance { #[pallet::genesis_config] pub struct GenesisConfig { pub value: u32, - pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor, + pub test_generic_value: BlockNumberFor, pub test_generic_double_map: - Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, u32)>, + Vec<(u32, BlockNumberFor, u32)>, } impl Default for GenesisConfig { @@ -138,7 +138,7 @@ mod instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] pub type TestGenericValue, I: 'static = ()> = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, OptionQuery>; + StorageValue<_, BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap, I: 'static = ()> = StorageDoubleMap< @@ -146,7 +146,7 @@ mod instance { Blake2_128Concat, u32, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, u32, ValueQuery, >; @@ -154,9 +154,9 @@ mod instance { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: u32, - pub test_generic_value: frame_system::pallet_prelude::BlockNumberFor, + pub test_generic_value: BlockNumberFor, pub test_generic_double_map: - Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, u32)>, + Vec<(u32, BlockNumberFor, u32)>, pub phantom: PhantomData, } diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 332489af575b8..70112a4ef63a5 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -43,13 +43,13 @@ pub mod pallet { Identity, u32, Identity, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, Vec, >; #[pallet::genesis_config] pub struct GenesisConfig { - pub t: Vec<(u32, frame_system::pallet_prelude::BlockNumberFor, Vec)>, + pub t: Vec<(u32, BlockNumberFor, Vec)>, } impl Default for GenesisConfig { diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 9e68df0961504..d7f3956e48f05 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -77,7 +77,7 @@ mod module1 { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: >::GenericType, - pub test: frame_system::pallet_prelude::BlockNumberFor, + pub test: BlockNumberFor, } impl, I: 'static> Default for GenesisConfig { @@ -89,7 +89,7 @@ mod module1 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - frame_system::pallet_prelude::BlockNumberFor: std::fmt::Display, + BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -123,7 +123,7 @@ mod module1 { #[pallet::inherent] impl, I: 'static> ProvideInherent for Pallet where - frame_system::pallet_prelude::BlockNumberFor: From, + BlockNumberFor: From, { type Call = Call; type Error = MakeFatalError<()>; @@ -198,7 +198,7 @@ mod module2 { #[pallet::genesis_build] impl, I: 'static> GenesisBuild for GenesisConfig where - frame_system::pallet_prelude::BlockNumberFor: std::fmt::Display, + BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 89c3351c2de89..d52e81dbbe36d 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -30,7 +30,7 @@ mod module { pub type Request = ( ::AccountId, Role, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, ); pub type Requests = Vec>; @@ -49,21 +49,21 @@ mod module { pub max_actors: u32, // payouts are made at this block interval - pub reward_period: frame_system::pallet_prelude::BlockNumberFor, + pub reward_period: BlockNumberFor, // minimum amount of time before being able to unstake - pub bonding_period: frame_system::pallet_prelude::BlockNumberFor, + pub bonding_period: BlockNumberFor, // how long tokens remain locked for after unstaking - pub unbonding_period: frame_system::pallet_prelude::BlockNumberFor, + pub unbonding_period: BlockNumberFor, // minimum period required to be in service. unbonding before this time is highly penalized - pub min_service_period: frame_system::pallet_prelude::BlockNumberFor, + pub min_service_period: BlockNumberFor, // "startup" time allowed for roles that need to sync their infrastructure // with other providers before they are considered in service and punishable for // not delivering required level of service. - pub startup_grace_period: frame_system::pallet_prelude::BlockNumberFor, + pub startup_grace_period: BlockNumberFor, } impl Default for RoleParameters { @@ -122,7 +122,7 @@ mod module { _, Blake2_128Concat, T::AccountId, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; /// First step before enter a role is registering intent with a new account/key. diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 202929cde2f35..9dcdd71c9a746 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -74,6 +74,7 @@ use frame_support::{ }, Parameter, }; +use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; pub use weights::WeightInfo; @@ -176,7 +177,7 @@ pub mod pallet { OpenTip< T::AccountId, BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::Hash, >, OptionQuery, @@ -478,7 +479,7 @@ impl, I: 'static> Pallet { tip: &mut OpenTip< T::AccountId, BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::Hash, >, tipper: T::AccountId, @@ -528,7 +529,7 @@ impl, I: 'static> Pallet { tip: OpenTip< T::AccountId, BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::Hash, >, ) { @@ -595,7 +596,7 @@ impl, I: 'static> Pallet { OldOpenTip< T::AccountId, BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, T::Hash, >, Twox64Concat, diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index 36b9011a41496..7a1de75ccb6d7 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { // Drop obsolete roots. The proof for `obsolete` will be checked later // in this block, so we drop `obsolete` - 1. let period = >::get(); @@ -158,7 +158,7 @@ pub mod pallet { T::DbWeight::get().reads_writes(2, 4) } - fn on_finalize(n: frame_system::pallet_prelude::BlockNumberFor) { + fn on_finalize(n: BlockNumberFor) { assert!( >::take() || { // Proof is not required for early or empty blocks. @@ -238,7 +238,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::renew())] pub fn renew( origin: OriginFor, - block: frame_system::pallet_prelude::BlockNumberFor, + block: BlockNumberFor, index: u32, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -342,7 +342,7 @@ pub mod pallet { pub(super) type Transactions = StorageMap< _, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BoundedVec, OptionQuery, >; @@ -352,7 +352,7 @@ pub mod pallet { pub(super) type ChunkCount = StorageMap< _, Blake2_128Concat, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, u32, ValueQuery, >; @@ -371,7 +371,7 @@ pub mod pallet { /// for block authoring. #[pallet::storage] pub(super) type StoragePeriod = - StorageValue<_, frame_system::pallet_prelude::BlockNumberFor, ValueQuery>; + StorageValue<_, BlockNumberFor, ValueQuery>; // Intermediates #[pallet::storage] @@ -386,7 +386,7 @@ pub mod pallet { pub struct GenesisConfig { pub byte_fee: BalanceOf, pub entry_fee: BalanceOf, - pub storage_period: frame_system::pallet_prelude::BlockNumberFor, + pub storage_period: BlockNumberFor, } impl Default for GenesisConfig { diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 9a9e5d790e32a..81211cbb37cdf 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -67,6 +67,7 @@ use frame_support::{ }, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_runtime::{ traits::{ @@ -127,9 +128,9 @@ impl VestingAction { /// Pick the schedules that this action dictates should continue vesting undisturbed. fn pick_schedules( &self, - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, + schedules: Vec, BlockNumberFor>>, ) -> impl Iterator< - Item = VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + Item = VestingInfo, BlockNumberFor>, > + '_ { schedules.into_iter().enumerate().filter_map(move |(index, schedule)| { if self.should_remove(index) { @@ -207,7 +208,7 @@ pub mod pallet { Blake2_128Concat, T::AccountId, BoundedVec< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + VestingInfo, BlockNumberFor>, MaxVestingSchedulesGet, >, >; @@ -226,8 +227,8 @@ pub mod pallet { pub struct GenesisConfig { pub vesting: Vec<( T::AccountId, - frame_system::pallet_prelude::BlockNumberFor, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, + BlockNumberFor, BalanceOf, )>, } @@ -355,7 +356,7 @@ pub mod pallet { pub fn vested_transfer( origin: OriginFor, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; let transactor = ::unlookup(transactor); @@ -384,7 +385,7 @@ pub mod pallet { origin: OriginFor, source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { ensure_root(origin)?; Self::do_vested_transfer(source, target, schedule) @@ -446,10 +447,10 @@ impl Pallet { // Create a new `VestingInfo`, based off of two other `VestingInfo`s. // NOTE: We assume both schedules have had funds unlocked up through the current block. fn merge_vesting_info( - now: frame_system::pallet_prelude::BlockNumberFor, - schedule1: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, - schedule2: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, - ) -> Option, frame_system::pallet_prelude::BlockNumberFor>> { + now: BlockNumberFor, + schedule1: VestingInfo, BlockNumberFor>, + schedule2: VestingInfo, BlockNumberFor>, + ) -> Option, BlockNumberFor>> { let schedule1_ending_block = schedule1.ending_block_as_balance::(); let schedule2_ending_block = schedule2.ending_block_as_balance::(); let now_as_balance = T::BlockNumberToBalance::convert(now); @@ -496,7 +497,7 @@ impl Pallet { fn do_vested_transfer( source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); @@ -544,10 +545,10 @@ impl Pallet { /// /// NOTE: the amount locked does not include any schedules that are filtered out via `action`. fn report_schedule_updates( - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, + schedules: Vec, BlockNumberFor>>, action: VestingAction, ) -> ( - Vec, frame_system::pallet_prelude::BlockNumberFor>>, + Vec, BlockNumberFor>>, BalanceOf, ) { let now = >::block_number(); @@ -586,10 +587,10 @@ impl Pallet { /// Write an accounts updated vesting schedules to storage. fn write_vesting( who: &T::AccountId, - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, + schedules: Vec, BlockNumberFor>>, ) -> Result<(), DispatchError> { let schedules: BoundedVec< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + VestingInfo, BlockNumberFor>, MaxVestingSchedulesGet, > = schedules.try_into().map_err(|_| Error::::AtMaxVestingSchedules)?; @@ -618,11 +619,11 @@ impl Pallet { /// Execute a `VestingAction` against the given `schedules`. Returns the updated schedules /// and locked amount. fn exec_action( - schedules: Vec, frame_system::pallet_prelude::BlockNumberFor>>, + schedules: Vec, BlockNumberFor>>, action: VestingAction, ) -> Result< ( - Vec, frame_system::pallet_prelude::BlockNumberFor>>, + Vec, BlockNumberFor>>, BalanceOf, ), DispatchError, @@ -671,7 +672,7 @@ where BalanceOf: MaybeSerializeDeserialize + Debug, { type Currency = T::Currency; - type Moment = frame_system::pallet_prelude::BlockNumberFor; + type Moment = BlockNumberFor; /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { @@ -702,7 +703,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: frame_system::pallet_prelude::BlockNumberFor, + starting_block: BlockNumberFor, ) -> DispatchResult { if locked.is_zero() { return Ok(()) @@ -735,7 +736,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: frame_system::pallet_prelude::BlockNumberFor, + starting_block: BlockNumberFor, ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index 5dd0fef28e155..b01ccaa3cb137 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -41,13 +41,13 @@ pub mod v1 { let mut reads_writes = 0; Vesting::::translate::< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + VestingInfo, BlockNumberFor>, _, >(|_key, vesting_info| { reads_writes += 1; let v: Option< BoundedVec< - VestingInfo, frame_system::pallet_prelude::BlockNumberFor>, + VestingInfo, BlockNumberFor>, MaxVestingSchedulesGet, >, > = vec![vesting_info].try_into().ok(); From 3df4b156863d0a2fb978026b7b96c4216f2ca661 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:55:19 +0530 Subject: [PATCH 19/67] Uses import instead of full path for Header --- frame/babe/src/equivocation.rs | 9 +++++---- frame/babe/src/lib.rs | 7 ++++--- frame/merkle-mountain-range/src/lib.rs | 7 ++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index f9e4919d6b46b..db39ef31565ff 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -34,6 +34,7 @@ //! definition. use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_system::pallet_prelude::HeaderFor; use log::{error, info}; use sp_consensus_babe::{AuthorityId, EquivocationProof, Slot, KEY_TYPE}; @@ -108,7 +109,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, impl OffenceReportSystem< Option, - (EquivocationProof>, T::KeyOwnerProof), + (EquivocationProof>, T::KeyOwnerProof), > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -124,7 +125,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -142,7 +143,7 @@ where } fn check_evidence( - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -161,7 +162,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof>, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 5427b4228f9a2..f526e5f23a651 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -30,6 +30,7 @@ use frame_support::{ BoundedVec, WeakBoundedVec, }; use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::pallet_prelude::HeaderFor; use sp_consensus_babe::{ digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest}, AllowedSlots, BabeAuthorityWeight, BabeEpochConfiguration, ConsensusLog, Epoch, @@ -415,7 +416,7 @@ pub mod pallet { ))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -441,7 +442,7 @@ pub mod pallet { ))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -891,7 +892,7 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof>, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index e197feedc39d1..abc18786f3c7a 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -58,6 +58,7 @@ use frame_support::{log, weights::Weight}; use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::pallet_prelude::HeaderFor; use sp_mmr_primitives::utils; use sp_runtime::{ traits::{self, One, Saturating}, @@ -267,7 +268,7 @@ impl, I: 'static> Pallet { pos: NodeIndex, parent_hash: ::Hash, ) -> sp_std::prelude::Vec { - NodesUtils::node_temp_offchain_key::>( + NodesUtils::node_temp_offchain_key::>( &T::INDEXING_PREFIX, pos, parent_hash, @@ -306,10 +307,10 @@ impl, I: 'static> Pallet { T: frame_system::Config, { let first_mmr_block = utils::first_mmr_block_num::< - frame_system::pallet_prelude::HeaderFor, + HeaderFor, >(>::block_number(), Self::mmr_leaves())?; - utils::block_num_to_leaf_index::>( + utils::block_num_to_leaf_index::>( block_num, first_mmr_block, ) From cb550822dc7ed5ea36deed465c750030bb2445a3 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:55:56 +0530 Subject: [PATCH 20/67] Formatting --- frame/alliance/src/lib.rs | 9 +- frame/asset-conversion/src/lib.rs | 5 +- frame/atomic-swap/src/lib.rs | 2 +- frame/authorship/src/lib.rs | 5 +- frame/babe/src/equivocation.rs | 6 +- frame/babe/src/lib.rs | 41 ++----- frame/babe/src/randomness.rs | 24 +--- frame/balances/src/lib.rs | 4 +- frame/beefy/src/equivocation.rs | 5 +- frame/collective/src/lib.rs | 9 +- frame/contracts/src/exec.rs | 3 +- frame/contracts/src/lib.rs | 5 +- frame/conviction-voting/src/lib.rs | 7 +- frame/core-fellowship/src/lib.rs | 6 +- frame/democracy/src/lib.rs | 79 +++--------- frame/democracy/src/migrations/v1.rs | 13 +- .../election-provider-multi-phase/src/lib.rs | 10 +- .../src/signed.rs | 6 +- .../src/unsigned.rs | 7 +- frame/elections-phragmen/src/lib.rs | 4 +- frame/examples/kitchensink/src/lib.rs | 9 +- frame/examples/offchain-worker/src/lib.rs | 23 ++-- frame/executive/src/lib.rs | 5 +- frame/fast-unstake/src/lib.rs | 9 +- frame/grandpa/src/equivocation.rs | 20 +-- frame/grandpa/src/lib.rs | 54 ++------- frame/im-online/src/lib.rs | 11 +- .../src/lib.rs | 4 +- frame/lottery/src/lib.rs | 6 +- frame/merkle-mountain-range/src/lib.rs | 28 ++--- frame/multisig/src/lib.rs | 10 +- .../nft-fractionalization/src/benchmarking.rs | 17 +-- frame/nfts/src/lib.rs | 6 +- frame/nfts/src/types.rs | 7 +- frame/nis/src/lib.rs | 10 +- frame/nomination-pools/src/lib.rs | 5 +- frame/proxy/src/lib.rs | 48 ++------ frame/referenda/src/lib.rs | 14 +-- frame/referenda/src/types.rs | 9 +- frame/salary/src/lib.rs | 6 +- frame/scheduler/src/lib.rs | 114 +++++------------- frame/scheduler/src/migration.rs | 33 ++--- frame/session/benchmarking/src/lib.rs | 4 +- frame/session/src/lib.rs | 8 +- frame/society/src/lib.rs | 17 +-- frame/staking/src/pallet/impls.rs | 29 ++--- frame/support/test/src/lib.rs | 3 +- frame/support/test/tests/final_keys.rs | 9 +- frame/support/test/tests/genesisconfig.rs | 10 +- frame/support/test/tests/issue2219.rs | 13 +- frame/tips/src/lib.rs | 28 +---- frame/transaction-storage/src/lib.rs | 12 +- frame/vesting/src/lib.rs | 29 +---- frame/vesting/src/migrations.rs | 39 +++--- 54 files changed, 223 insertions(+), 676 deletions(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index a0320f39773e6..ff33a1ef9b21c 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -475,13 +475,8 @@ pub mod pallet { /// period stored as a future block number. #[pallet::storage] #[pallet::getter(fn retiring_members)] - pub type RetiringMembers, I: 'static = ()> = StorageMap< - _, - Blake2_128Concat, - T::AccountId, - BlockNumberFor, - OptionQuery, - >; + pub type RetiringMembers, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor, OptionQuery>; /// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit /// candidacy. diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 0494748bb31e8..5887295f973c3 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -72,7 +72,10 @@ use frame_support::{ ensure, traits::tokens::{AssetId, Balance}, }; -use frame_system::{ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}}; +use frame_system::{ + ensure_signed, + pallet_prelude::{BlockNumberFor, OriginFor}, +}; pub use pallet::*; use sp_arithmetic::traits::Unsigned; use sp_runtime::{ diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 25d53bc135e0f..8094c06030120 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -50,6 +50,7 @@ use frame_support::{ weights::Weight, RuntimeDebugNoBound, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::RuntimeDebug; @@ -58,7 +59,6 @@ use sp_std::{ ops::{Deref, DerefMut}, prelude::*, }; -use frame_system::pallet_prelude::BlockNumberFor; /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index f976951cbcecb..abc2adbbdafdd 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -45,10 +45,7 @@ pub mod pallet { /// Find the author of a block. type FindAuthor: FindAuthor; /// An event handler for authored blocks. - type EventHandler: EventHandler< - Self::AccountId, - BlockNumberFor, - >; + type EventHandler: EventHandler>; } #[pallet::pallet] diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index db39ef31565ff..827e7ed1babac 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -107,10 +107,8 @@ impl Offence for EquivocationOffence { pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); impl - OffenceReportSystem< - Option, - (EquivocationProof>, T::KeyOwnerProof), - > for EquivocationReportSystem + OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> + for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, R: ReportOffence< diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index f526e5f23a651..c3f86abbc5cd9 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -29,8 +29,7 @@ use frame_support::{ weights::Weight, BoundedVec, WeakBoundedVec, }; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::pallet_prelude::HeaderFor; +use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use sp_consensus_babe::{ digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest}, AllowedSlots, BabeAuthorityWeight, BabeEpochConfiguration, ConsensusLog, Epoch, @@ -280,14 +279,8 @@ pub mod pallet { /// entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in /// slots, which may be skipped, the block numbers may not line up with the slot numbers. #[pallet::storage] - pub(super) type EpochStart = StorageValue< - _, - ( - BlockNumberFor, - BlockNumberFor, - ), - ValueQuery, - >; + pub(super) type EpochStart = + StorageValue<_, (BlockNumberFor, BlockNumberFor), ValueQuery>; /// How late the current block is compared to its parent. /// @@ -296,8 +289,7 @@ pub mod pallet { /// execution context should always yield zero. #[pallet::storage] #[pallet::getter(fn lateness)] - pub(super) type Lateness = - StorageValue<_, BlockNumberFor, ValueQuery>; + pub(super) type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -512,9 +504,7 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession> - for Pallet -{ +impl pallet_session::ShouldEndSession> for Pallet { fn should_end_session(now: BlockNumberFor) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's @@ -565,14 +555,11 @@ impl Pallet { // // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. - pub fn next_expected_epoch_change( - now: BlockNumberFor, - ) -> Option> { + pub fn next_expected_epoch_change(now: BlockNumberFor) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: BlockNumberFor = - slots_remaining.saturated_into(); + let blocks_remaining: BlockNumberFor = slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) } @@ -914,18 +901,14 @@ impl OnTimestampSet for Pallet { } } -impl - frame_support::traits::EstimateNextSessionRotation< - BlockNumberFor, - > for Pallet +impl frame_support::traits::EstimateNextSessionRotation> + for Pallet { fn average_session_length() -> BlockNumberFor { T::EpochDuration::get().saturated_into() } - fn estimate_current_session_progress( - _now: BlockNumberFor, - ) -> (Option, Weight) { + fn estimate_current_session_progress(_now: BlockNumberFor) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; ( @@ -946,9 +929,7 @@ impl } } -impl frame_support::traits::Lateness> - for Pallet -{ +impl frame_support::traits::Lateness> for Pallet { fn lateness(&self) -> BlockNumberFor { Self::lateness() } diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index 34bb08a3ab627..d3d1bea2292da 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -130,9 +130,7 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT> - for RandomnessFromTwoEpochsAgo -{ +impl RandomnessT> for RandomnessFromTwoEpochsAgo { fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -142,9 +140,7 @@ impl RandomnessT> } } -impl RandomnessT> - for RandomnessFromOneEpochAgo -{ +impl RandomnessT> for RandomnessFromOneEpochAgo { fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -154,12 +150,8 @@ impl RandomnessT> } } -impl RandomnessT, BlockNumberFor> - for ParentBlockRandomness -{ - fn random( - subject: &[u8], - ) -> (Option, BlockNumberFor) { +impl RandomnessT, BlockNumberFor> for ParentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -173,12 +165,8 @@ impl RandomnessT, BlockNumberFor> } #[allow(deprecated)] -impl RandomnessT, BlockNumberFor> - for CurrentBlockRandomness -{ - fn random( - subject: &[u8], - ) -> (Option, BlockNumberFor) { +impl RandomnessT, BlockNumberFor> for CurrentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 826fb721725dd..a9c9279c52840 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -517,9 +517,7 @@ pub mod pallet { } #[pallet::hooks] - impl, I: 'static> Hooks> - for Pallet - { + impl, I: 'static> Hooks> for Pallet { #[cfg(not(feature = "insecure_zero_ed"))] fn integrity_test() { assert!( diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index 51d7ef87d63fb..1f8262cab2c80 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -141,10 +141,7 @@ where R: ReportOffence< T::AccountId, P::IdentificationTuple, - EquivocationOffence< - P::IdentificationTuple, - BlockNumberFor, - >, + EquivocationOffence>, >, P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, P::IdentificationTuple: Clone, diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index e9ab173801c2d..a113bf6294384 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -272,13 +272,8 @@ pub mod pallet { /// Votes on a given proposal, if it is ongoing. #[pallet::storage] #[pallet::getter(fn voting)] - pub type Voting, I: 'static = ()> = StorageMap< - _, - Identity, - T::Hash, - Votes>, - OptionQuery, - >; + pub type Voting, I: 'static = ()> = + StorageMap<_, Identity, T::Hash, Votes>, OptionQuery>; /// Proposals so far. #[pallet::storage] diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index ef8dc65e86300..913a89655d3c0 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -34,8 +34,7 @@ use frame_support::{ weights::Weight, Blake2_128Concat, BoundedVec, StorageHasher, }; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_contracts_primitives::ExecReturnValue; use smallvec::{Array, SmallVec}; use sp_core::{ diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 41daefd621625..bd56d19aedc3c 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -341,10 +341,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_idle( - _block: BlockNumberFor, - mut remaining_weight: Weight, - ) -> Weight { + fn on_idle(_block: BlockNumberFor, mut remaining_weight: Weight) -> Weight { use migration::MigrateResult::*; loop { diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 86f5b78f7f528..aea93c15e1621 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -74,11 +74,8 @@ type VotingOf = Voting< >::MaxVotes, >; #[allow(dead_code)] -type DelegatingOf = Delegating< - BalanceOf, - ::AccountId, - BlockNumberFor, ->; +type DelegatingOf = + Delegating, ::AccountId, BlockNumberFor>; pub type TallyOf = Tally, >::MaxTurnout>; pub type VotesOf = BalanceOf; type PollIndexOf = <>::Polls as Polling>>::Index; diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index 9c0e85ebc58d7..8f3d9633fcf22 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -193,11 +193,7 @@ pub mod pallet { type EvidenceSize: Get; } - pub type ParamsOf = ParamsType< - >::Balance, - BlockNumberFor, - RANK_COUNT, - >; + pub type ParamsOf = ParamsType<>::Balance, BlockNumberFor, RANK_COUNT>; pub type MemberStatusOf = MemberStatus>; pub type RankOf = <>::Members as RankedMembers>::Rank; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 18ddeda3c13a1..3336ddb7cdaef 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -165,8 +165,7 @@ use frame_support::{ }, weights::Weight, }; -use frame_system::pallet_prelude::OriginFor; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use sp_runtime::{ traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, @@ -395,11 +394,7 @@ pub mod pallet { _, Twox64Concat, ReferendumIndex, - ReferendumInfo< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, + ReferendumInfo, BoundedCallOf, BalanceOf>, >; /// All votes for a particular voter. We store the balance for the number of votes that we @@ -411,12 +406,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - Voting< - BalanceOf, - T::AccountId, - BlockNumberFor, - T::MaxVotes, - >, + Voting, T::AccountId, BlockNumberFor, T::MaxVotes>, ValueQuery, >; @@ -439,10 +429,7 @@ pub mod pallet { _, Identity, H256, - ( - BlockNumberFor, - BoundedVec, - ), + (BlockNumberFor, BoundedVec), >; /// Record of all proposals that have been subject to emergency cancellation. @@ -495,11 +482,7 @@ pub mod pallet { /// An account has cancelled a previous delegation operation. Undelegated { account: T::AccountId }, /// An external proposal has been vetoed. - Vetoed { - who: T::AccountId, - proposal_hash: H256, - until: BlockNumberFor, - }, + Vetoed { who: T::AccountId, proposal_hash: H256, until: BlockNumberFor }, /// A proposal_hash has been blacklisted permanently. Blacklisted { proposal_hash: H256 }, /// An account has voted in a referendum @@ -1231,14 +1214,8 @@ impl Pallet { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( n: BlockNumberFor, - ) -> Vec<( - ReferendumIndex, - ReferendumStatus< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, - )> { + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> + { let next = Self::lowest_unbaked(); let last = Self::referendum_count(); Self::maturing_referenda_at_inner(n, next..last) @@ -1247,14 +1224,8 @@ impl Pallet { fn maturing_referenda_at_inner( n: BlockNumberFor, range: core::ops::Range, - ) -> Vec<( - ReferendumIndex, - ReferendumStatus< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, - )> { + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> + { range .into_iter() .map(|i| (i, Self::referendum_info(i))) @@ -1293,19 +1264,9 @@ impl Pallet { /// Ok if the given referendum is active, Err otherwise fn ensure_ongoing( - r: ReferendumInfo< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, - ) -> Result< - ReferendumStatus< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, - DispatchError, - > { + r: ReferendumInfo, BoundedCallOf, BalanceOf>, + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> + { match r { ReferendumInfo::Ongoing(s) => Ok(s), _ => Err(Error::::ReferendumInvalid.into()), @@ -1314,14 +1275,8 @@ impl Pallet { fn referendum_status( ref_index: ReferendumIndex, - ) -> Result< - ReferendumStatus< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, - DispatchError, - > { + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> + { let info = ReferendumInfoOf::::get(ref_index).ok_or(Error::::ReferendumInvalid)?; Self::ensure_ongoing(info) } @@ -1655,11 +1610,7 @@ impl Pallet { fn bake_referendum( now: BlockNumberFor, index: ReferendumIndex, - status: ReferendumStatus< - BlockNumberFor, - BoundedCallOf, - BalanceOf, - >, + status: ReferendumStatus, BoundedCallOf, BalanceOf>, ) -> bool { let total_issuance = T::Currency::total_issuance(); let approved = status.threshold.approved(status.tally, total_issuance); diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index 3c9f18516ed41..27a500a615cff 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -46,11 +46,7 @@ mod v0 { Pallet, frame_support::Twox64Concat, ReferendumIndex, - ReferendumInfo< - BlockNumberFor, - ::Hash, - BalanceOf, - >, + ReferendumInfo, ::Hash, BalanceOf>, >; } @@ -88,12 +84,7 @@ pub mod v1 { } ReferendumInfoOf::::translate( - |index, - old: ReferendumInfo< - BlockNumberFor, - T::Hash, - BalanceOf, - >| { + |index, old: ReferendumInfo, T::Hash, BalanceOf>| { weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); log::info!(target: TARGET, "migrating referendum #{:?}", &index); Some(match old { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 8be9b72c2af35..e1330c48e1ae2 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -241,8 +241,7 @@ use frame_support::{ weights::Weight, DefaultNoBound, EqNoBound, PartialEqNoBound, }; -use frame_system::{ensure_none, offchain::SendTransactionTypes}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{ensure_none, offchain::SendTransactionTypes, pallet_prelude::BlockNumberFor}; use scale_info::TypeInfo; use sp_arithmetic::{ traits::{CheckedAdd, Zero}, @@ -887,9 +886,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state( - _n: BlockNumberFor, - ) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1264,8 +1261,7 @@ pub mod pallet { /// Current phase. #[pallet::storage] #[pallet::getter(fn current_phase)] - pub type CurrentPhase = - StorageValue<_, Phase>, ValueQuery>; + pub type CurrentPhase = StorageValue<_, Phase>, ValueQuery>; /// Current best solution, signed or unsigned, queued to be returned upon `elect`. /// diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 06477a0c581e8..226404e4afc1a 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -101,10 +101,8 @@ pub type SignedSubmissionOf = SignedSubmission< /// Always sorted vector of a score, submitted at the given block number, which can be found at the /// given index (`u32`) of the `SignedSubmissionsMap`. -pub type SubmissionIndicesOf = BoundedVec< - (ElectionScore, BlockNumberFor, u32), - ::SignedMaxSubmissions, ->; +pub type SubmissionIndicesOf = + BoundedVec<(ElectionScore, BlockNumberFor, u32), ::SignedMaxSubmissions>; /// Outcome of [`SignedSubmissions::insert`]. pub enum InsertResult { diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index d25aa448f7933..e21e6c5e6d229 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -29,8 +29,7 @@ use frame_support::{ traits::{DefensiveResult, Get}, BoundedVec, }; -use frame_system::offchain::SubmitTransaction; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{offchain::SubmitTransaction, pallet_prelude::BlockNumberFor}; use scale_info::TypeInfo; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, assignment_staked_to_ratio_normalized, ElectionResult, @@ -299,9 +298,7 @@ impl Pallet { /// /// Returns `Ok(())` if offchain worker limit is respected, `Err(reason)` otherwise. If `Ok()` /// is returned, `now` is written in storage and will be used in further calls as the baseline. - pub fn ensure_offchain_repeat_frequency( - now: BlockNumberFor, - ) -> Result<(), MinerError> { + pub fn ensure_offchain_repeat_frequency(now: BlockNumberFor) -> Result<(), MinerError> { let threshold = T::OffchainRepeat::get(); let last_block = StorageValueRef::persistent(OFFCHAIN_LAST_BLOCK); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index b94581e2ed16c..6d2e0423c93cc 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -332,9 +332,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state( - _n: BlockNumberFor, - ) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index 5b43d15c2559f..c8e706d3e7270 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -264,10 +264,7 @@ pub mod pallet { unimplemented!() } - fn on_idle( - _n: BlockNumberFor, - _remaining_weight: Weight, - ) -> Weight { + fn on_idle(_n: BlockNumberFor, _remaining_weight: Weight) -> Weight { unimplemented!() } @@ -286,9 +283,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state( - _n: BlockNumberFor, - ) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { unimplemented!() } } diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 59e97c9a28a65..f9cd4147068d0 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -53,8 +53,8 @@ use frame_system::{ AppCrypto, CreateSignedTransaction, SendSignedTransaction, SendUnsignedTransaction, SignedPayload, Signer, SigningTypes, SubmitTransaction, }, + pallet_prelude::BlockNumberFor, }; -use frame_system::pallet_prelude::BlockNumberFor; use lite_json::json::JsonValue; use sp_core::crypto::KeyTypeId; use sp_runtime::{ @@ -342,8 +342,7 @@ pub mod pallet { /// This storage entry defines when new transaction is going to be accepted. #[pallet::storage] #[pallet::getter(fn next_unsigned_at)] - pub(super) type NextUnsignedAt = - StorageValue<_, BlockNumberFor, ValueQuery>; + pub(super) type NextUnsignedAt = StorageValue<_, BlockNumberFor, ValueQuery>; } /// Payload used by this example crate to hold price @@ -355,9 +354,7 @@ pub struct PricePayload { public: Public, } -impl SignedPayload - for PricePayload> -{ +impl SignedPayload for PricePayload> { fn public(&self) -> T::Public { self.public.clone() } @@ -378,9 +375,7 @@ impl Pallet { /// and local storage usage. /// /// Returns a type of transaction that should be produced in current run. - fn choose_transaction_type( - block_number: BlockNumberFor, - ) -> TransactionType { + fn choose_transaction_type(block_number: BlockNumberFor) -> TransactionType { /// A friendlier name for the error that is going to be returned in case we are in the grace /// period. const RECENTLY_SENT: () = (); @@ -395,11 +390,8 @@ impl Pallet { // low-level method of local storage API, which means that only one worker // will be able to "acquire a lock" and send a transaction if multiple workers // happen to be executed concurrently. - let res = val.mutate( - |last_send: Result< - Option>, - StorageRetrievalError, - >| { + let res = + val.mutate(|last_send: Result>, StorageRetrievalError>| { match last_send { // If we already have a value in storage and the block number is recent enough // we avoid sending another transaction at this time. @@ -408,8 +400,7 @@ impl Pallet { // In every other case we attempt to acquire the lock and send a transaction. _ => Ok(block_number), } - }, - ); + }); // The result of `mutate` call will give us a nested `Result` type. // The first one matches the return of the closure passed to `mutate`, i.e. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 85eca6c356406..41a909afc082d 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -737,10 +737,7 @@ mod tests { Weight::from_parts(175, 0) } - fn on_idle( - n: BlockNumberFor, - remaining_weight: Weight, - ) -> Weight { + fn on_idle(n: BlockNumberFor, remaining_weight: Weight) -> Weight { println!("on_idle{}, {})", n, remaining_weight); Weight::from_parts(175, 0) } diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index 0cd6651b5a905..ca282a1615d66 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -273,10 +273,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_idle( - _: BlockNumberFor, - remaining_weight: Weight, - ) -> Weight { + fn on_idle(_: BlockNumberFor, remaining_weight: Weight) -> Weight { if remaining_weight.any_lt(T::DbWeight::get().reads(2)) { return Weight::from_parts(0, 0) } @@ -298,9 +295,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state( - _n: BlockNumberFor, - ) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { // ensure that the value of `ErasToCheckPerBlock` is less than // `T::MaxErasToCheckPerBlock`. ensure!( diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index 73472c56c33e0..c17f3d5de2ee8 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -119,10 +119,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, impl OffenceReportSystem< Option, - ( - EquivocationProof>, - T::KeyOwnerProof, - ), + (EquivocationProof>, T::KeyOwnerProof), > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -138,10 +135,7 @@ where type Longevity = L; fn publish_evidence( - evidence: ( - EquivocationProof>, - T::KeyOwnerProof, - ), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -159,10 +153,7 @@ where } fn check_evidence( - evidence: ( - EquivocationProof>, - T::KeyOwnerProof, - ), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -182,10 +173,7 @@ where fn process_evidence( reporter: Option, - evidence: ( - EquivocationProof>, - T::KeyOwnerProof, - ), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index be8c62546006d..73aaf7d0866d9 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -195,9 +195,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box< - EquivocationProof>, - >, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -223,9 +221,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box< - EquivocationProof>, - >, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -295,45 +291,31 @@ pub mod pallet { } #[pallet::type_value] - pub(super) fn DefaultForState( - ) -> StoredState> { + pub(super) fn DefaultForState() -> StoredState> { StoredState::Live } /// State of the current authority set. #[pallet::storage] #[pallet::getter(fn state)] - pub(super) type State = StorageValue< - _, - StoredState>, - ValueQuery, - DefaultForState, - >; + pub(super) type State = + StorageValue<_, StoredState>, ValueQuery, DefaultForState>; /// Pending change: (signaled at, scheduled change). #[pallet::storage] #[pallet::getter(fn pending_change)] - pub(super) type PendingChange = StorageValue< - _, - StoredPendingChange, T::MaxAuthorities>, - >; + pub(super) type PendingChange = + StorageValue<_, StoredPendingChange, T::MaxAuthorities>>; /// next block number where we can force a change. #[pallet::storage] #[pallet::getter(fn next_forced)] - pub(super) type NextForced = - StorageValue<_, BlockNumberFor>; + pub(super) type NextForced = StorageValue<_, BlockNumberFor>; /// `true` if we are currently stalled. #[pallet::storage] #[pallet::getter(fn stalled)] - pub(super) type Stalled = StorageValue< - _, - ( - BlockNumberFor, - BlockNumberFor, - ), - >; + pub(super) type Stalled = StorageValue<_, (BlockNumberFor, BlockNumberFor)>; /// The number of changes (both in terms of keys and underlying economic responsibilities) /// in the "set" of Grandpa validators from genesis. @@ -449,9 +431,7 @@ impl Pallet { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause( - in_blocks: BlockNumberFor, - ) -> DispatchResult { + pub fn schedule_pause(in_blocks: BlockNumberFor) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at }); @@ -463,9 +443,7 @@ impl Pallet { } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume( - in_blocks: BlockNumberFor, - ) -> DispatchResult { + pub fn schedule_resume(in_blocks: BlockNumberFor) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at }); @@ -554,19 +532,13 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof< - T::Hash, - BlockNumberFor, - >, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() } - fn on_stalled( - further_wait: BlockNumberFor, - median: BlockNumberFor, - ) { + fn on_stalled(further_wait: BlockNumberFor, median: BlockNumberFor) { // when we record old authority sets we could try to figure out _who_ // failed. until then, we can't meaningfully guard against // `next == last` the way that normal session changes do. diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 05c4fadd7a25a..de15f4b43e6a6 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -341,8 +341,7 @@ pub mod pallet { /// more accurate then the value we calculate for `HeartbeatAfter`. #[pallet::storage] #[pallet::getter(fn heartbeat_after)] - pub(super) type HeartbeatAfter = - StorageValue<_, BlockNumberFor, ValueQuery>; + pub(super) type HeartbeatAfter = StorageValue<_, BlockNumberFor, ValueQuery>; /// The current set of keys that may issue a heartbeat. #[pallet::storage] @@ -508,8 +507,7 @@ pub mod pallet { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of being online. impl - pallet_authorship::EventHandler, BlockNumberFor> - for Pallet + pallet_authorship::EventHandler, BlockNumberFor> for Pallet { fn note_author(author: ValidatorId) { Self::note_authorship(author); @@ -691,10 +689,7 @@ impl Pallet { }; let storage = StorageValueRef::persistent(&key); let res = storage.mutate( - |status: Result< - Option>>, - StorageRetrievalError, - >| { + |status: Result>>, StorageRetrievalError>| { // Check if there is already a lock for that particular block. // This means that the heartbeat has already been sent, and we are just waiting // for it to be included. However if it doesn't get included for INCLUDE_THRESHOLD diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 0f03fc9acaf6e..4b8564814872b 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -79,9 +79,7 @@ use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; -fn block_number_to_index( - block_number: BlockNumberFor, -) -> usize { +fn block_number_to_index(block_number: BlockNumberFor) -> usize { // on_initialize is called on the first block after genesis let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); index.try_into().ok().expect("Something % 81 is always smaller than usize; qed") diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 89e4d061e876f..093064a43f96f 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -207,10 +207,8 @@ pub mod pallet { /// The configuration for the current lottery. #[pallet::storage] - pub(crate) type Lottery = StorageValue< - _, - LotteryConfig, BalanceOf>, - >; + pub(crate) type Lottery = + StorageValue<_, LotteryConfig, BalanceOf>>; /// Users who have purchased a ticket. (Lottery Index, Tickets Purchased) #[pallet::storage] diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index abc18786f3c7a..2edef9a35d57a 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -57,8 +57,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{log, weights::Weight}; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::pallet_prelude::HeaderFor; +use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use sp_mmr_primitives::utils; use sp_runtime::{ traits::{self, One, Saturating}, @@ -93,8 +92,7 @@ pub struct ParentNumberAndHash { } impl LeafDataProvider for ParentNumberAndHash { - type LeafData = - (BlockNumberFor, ::Hash); + type LeafData = (BlockNumberFor, ::Hash); fn leaf_data() -> Self::LeafData { ( @@ -268,11 +266,7 @@ impl, I: 'static> Pallet { pos: NodeIndex, parent_hash: ::Hash, ) -> sp_std::prelude::Vec { - NodesUtils::node_temp_offchain_key::>( - &T::INDEXING_PREFIX, - pos, - parent_hash, - ) + NodesUtils::node_temp_offchain_key::>(&T::INDEXING_PREFIX, pos, parent_hash) } /// Build canonical offchain key for node `pos` in MMR. @@ -300,20 +294,16 @@ impl, I: 'static> Pallet { } /// Convert a block number into a leaf index. - fn block_num_to_leaf_index( - block_num: BlockNumberFor, - ) -> Result + fn block_num_to_leaf_index(block_num: BlockNumberFor) -> Result where T: frame_system::Config, { - let first_mmr_block = utils::first_mmr_block_num::< - HeaderFor, - >(>::block_number(), Self::mmr_leaves())?; + let first_mmr_block = utils::first_mmr_block_num::>( + >::block_number(), + Self::mmr_leaves(), + )?; - utils::block_num_to_leaf_index::>( - block_num, - first_mmr_block, - ) + utils::block_num_to_leaf_index::>(block_num, first_mmr_block) } /// Generate an MMR proof for the given `block_numbers`. diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 0dcdc4df288f0..ab117315f8985 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -59,8 +59,7 @@ use frame_support::{ weights::Weight, BoundedVec, RuntimeDebug, }; -use frame_system::{self as system, RawOrigin}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{self as system, pallet_prelude::BlockNumberFor, RawOrigin}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ @@ -184,12 +183,7 @@ pub mod pallet { T::AccountId, Blake2_128Concat, [u8; 32], - Multisig< - BlockNumberFor, - BalanceOf, - T::AccountId, - T::MaxSignatories, - >, + Multisig, BalanceOf, T::AccountId, T::MaxSignatories>, >; #[pallet::error] diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 967bffffb0a8d..fb91f953a0168 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -39,11 +39,8 @@ use crate::Pallet as NftFractionalization; type BalanceOf = <::Currency as InspectFungible<::AccountId>>::Balance; -type CollectionConfigOf = CollectionConfig< - BalanceOf, - BlockNumberFor, - ::NftCollectionId, ->; +type CollectionConfigOf = + CollectionConfig, BlockNumberFor, ::NftCollectionId>; fn default_collection_config() -> CollectionConfigOf where @@ -58,14 +55,8 @@ where fn mint_nft(nft_id: T::NftId) -> (T::AccountId, AccountIdLookupOf) where - T::Nfts: Create< - T::AccountId, - CollectionConfig< - BalanceOf, - BlockNumberFor, - T::NftCollectionId, - >, - > + Mutate, + T::Nfts: Create, BlockNumberFor, T::NftCollectionId>> + + Mutate, { let caller: T::AccountId = whitelisted_caller(); let caller_lookup = T::Lookup::unlookup(caller.clone()); diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 5676ef57c2205..8124c71682451 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -1659,11 +1659,7 @@ pub mod pallet { pub fn update_mint_settings( origin: OriginFor, collection: T::CollectionId, - mint_settings: MintSettings< - BalanceOf, - BlockNumberFor, - T::CollectionId, - >, + mint_settings: MintSettings, BlockNumberFor, T::CollectionId>, ) -> DispatchResult { let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index c875dc9e71253..e4e6165774627 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -57,11 +57,8 @@ pub(super) type ItemTipOf = ItemTip< ::AccountId, BalanceOf, >; -pub(super) type CollectionConfigFor = CollectionConfig< - BalanceOf, - BlockNumberFor, - >::CollectionId, ->; +pub(super) type CollectionConfigFor = + CollectionConfig, BlockNumberFor, >::CollectionId>; pub(super) type PreSignedMintOf = PreSignedMint< >::CollectionId, >::ItemId, diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 165946b8fb636..5db71c65a74b2 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -186,14 +186,10 @@ pub mod pallet { <::Currency as FunInspect<::AccountId>>::Balance; type DebtOf = fungible::Debt<::AccountId, ::Currency>; - type ReceiptRecordOf = ReceiptRecord< - ::AccountId, - BlockNumberFor, - BalanceOf, - >; + type ReceiptRecordOf = + ReceiptRecord<::AccountId, BlockNumberFor, BalanceOf>; type IssuanceInfoOf = IssuanceInfo>; - type SummaryRecordOf = - SummaryRecord, BalanceOf>; + type SummaryRecordOf = SummaryRecord, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 2104eadf11fb4..a69b6dcd06301 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -834,10 +834,7 @@ impl Commission { /// /// No change rate will always be less restrictive than some change rate, so where no /// `change_rate` is currently set, `false` is returned. - fn less_restrictive( - &self, - new: &CommissionChangeRate>, - ) -> bool { + fn less_restrictive(&self, new: &CommissionChangeRate>) -> bool { self.change_rate .as_ref() .map(|c| new.max_increase > c.max_increase || new.min_delay < c.min_delay) diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index b7c8d2af17b1b..33e9fcfade35a 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -40,8 +40,7 @@ use frame_support::{ traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency}, RuntimeDebug, }; -use frame_system::{self as system, ensure_signed}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{self as system, ensure_signed, pallet_prelude::BlockNumberFor}; pub use pallet::*; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; @@ -577,11 +576,7 @@ pub mod pallet { T::AccountId, ( BoundedVec< - ProxyDefinition< - T::AccountId, - T::ProxyType, - BlockNumberFor, - >, + ProxyDefinition>, T::MaxProxies, >, BalanceOf, @@ -597,14 +592,7 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec< - Announcement< - T::AccountId, - CallHashOf, - BlockNumberFor, - >, - T::MaxPending, - >, + BoundedVec, BlockNumberFor>, T::MaxPending>, BalanceOf, ), ValueQuery, @@ -749,13 +737,7 @@ impl Pallet { } fn edit_announcements< - F: FnMut( - &Announcement< - T::AccountId, - CallHashOf, - BlockNumberFor, - >, - ) -> bool, + F: FnMut(&Announcement, BlockNumberFor>) -> bool, >( delegate: &T::AccountId, f: F, @@ -781,20 +763,8 @@ impl Pallet { real: &T::AccountId, delegate: &T::AccountId, force_proxy_type: Option, - ) -> Result< - ProxyDefinition< - T::AccountId, - T::ProxyType, - BlockNumberFor, - >, - DispatchError, - > { - let f = |x: &ProxyDefinition< - T::AccountId, - T::ProxyType, - BlockNumberFor, - >| - -> bool { + ) -> Result>, DispatchError> { + let f = |x: &ProxyDefinition>| -> bool { &x.delegate == delegate && force_proxy_type.as_ref().map_or(true, |y| &x.proxy_type == y) }; @@ -802,11 +772,7 @@ impl Pallet { } fn do_proxy( - def: ProxyDefinition< - T::AccountId, - T::ProxyType, - BlockNumberFor, - >, + def: ProxyDefinition>, real: T::AccountId, call: ::RuntimeCall, ) { diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index ad83fd4f8e03a..f7737b9333fba 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -727,13 +727,7 @@ impl, I: 'static> Polling for Pallet { fn access_poll( index: Self::Index, - f: impl FnOnce( - PollStatus< - &mut T::Tally, - BlockNumberFor, - TrackIdOf, - >, - ) -> R, + f: impl FnOnce(PollStatus<&mut T::Tally, BlockNumberFor, TrackIdOf>) -> R, ) -> R { match ReferendumInfoFor::::get(index) { Some(ReferendumInfo::Ongoing(mut status)) => { @@ -752,11 +746,7 @@ impl, I: 'static> Polling for Pallet { fn try_access_poll( index: Self::Index, f: impl FnOnce( - PollStatus< - &mut T::Tally, - BlockNumberFor, - TrackIdOf, - >, + PollStatus<&mut T::Tally, BlockNumberFor, TrackIdOf>, ) -> Result, ) -> Result { match ReferendumInfoFor::::get(index) { diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index bd4faabf48126..ba89383888a7d 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -60,12 +60,9 @@ pub type ReferendumStatusOf = ReferendumStatus< ScheduleAddressOf, >; pub type DecidingStatusOf = DecidingStatus>; -pub type TrackInfoOf = - TrackInfo, BlockNumberFor>; -pub type TrackIdOf = <>::Tracks as TracksInfo< - BalanceOf, - BlockNumberFor, ->>::Id; +pub type TrackInfoOf = TrackInfo, BlockNumberFor>; +pub type TrackIdOf = + <>::Tracks as TracksInfo, BlockNumberFor>>::Id; pub type ScheduleAddressOf = <>::Scheduler as Anon< BlockNumberFor, CallOf, diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 38a32290a1326..a45f1938aaddc 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -145,11 +145,7 @@ pub mod pallet { pub type CycleIndexOf = BlockNumberFor; pub type BalanceOf = <>::Paymaster as Pay>::Balance; pub type IdOf = <>::Paymaster as Pay>::Id; - pub type StatusOf = StatusType< - CycleIndexOf, - BlockNumberFor, - BalanceOf, - >; + pub type StatusOf = StatusType, BlockNumberFor, BalanceOf>; pub type ClaimantStatusOf = ClaimantStatus, BalanceOf, IdOf>; /// The overall status of the system. diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index a4223e750c01e..4e12e0332f422 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -72,8 +72,10 @@ use frame_support::{ }, weights::{Weight, WeightMeter}, }; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::{self as system}; +use frame_system::{ + pallet_prelude::BlockNumberFor, + {self as system}, +}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ @@ -232,8 +234,7 @@ pub mod pallet { } #[pallet::storage] - pub type IncompleteSince = - StorageValue<_, BlockNumberFor>; + pub type IncompleteSince = StorageValue<_, BlockNumberFor>; /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] @@ -250,12 +251,8 @@ pub mod pallet { /// For v3 -> v4 the previously unbounded identities are Blake2-256 hashed to form the v4 /// identities. #[pallet::storage] - pub(crate) type Lookup = StorageMap< - _, - Twox64Concat, - TaskName, - TaskAddress>, - >; + pub(crate) type Lookup = + StorageMap<_, Twox64Concat, TaskName, TaskAddress>>; /// Events type. #[pallet::event] @@ -272,20 +269,11 @@ pub mod pallet { result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. - CallUnavailable { - task: TaskAddress>, - id: Option, - }, + CallUnavailable { task: TaskAddress>, id: Option }, /// The given task was unable to be renewed since the agenda is full at that block. - PeriodicFailed { - task: TaskAddress>, - id: Option, - }, + PeriodicFailed { task: TaskAddress>, id: Option }, /// The given task can never be executed since it is overweight. - PermanentlyOverweight { - task: TaskAddress>, - id: Option, - }, + PermanentlyOverweight { task: TaskAddress>, id: Option }, } #[pallet::error] @@ -320,9 +308,7 @@ pub mod pallet { pub fn schedule( origin: OriginFor, when: BlockNumberFor, - maybe_periodic: Option< - schedule::Period>, - >, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -341,11 +327,7 @@ pub mod pallet { /// Cancel an anonymously scheduled task. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] - pub fn cancel( - origin: OriginFor, - when: BlockNumberFor, - index: u32, - ) -> DispatchResult { + pub fn cancel(origin: OriginFor, when: BlockNumberFor, index: u32) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; let origin = ::RuntimeOrigin::from(origin); Self::do_cancel(Some(origin.caller().clone()), (when, index))?; @@ -359,9 +341,7 @@ pub mod pallet { origin: OriginFor, id: TaskName, when: BlockNumberFor, - maybe_periodic: Option< - schedule::Period>, - >, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -394,9 +374,7 @@ pub mod pallet { pub fn schedule_after( origin: OriginFor, after: BlockNumberFor, - maybe_periodic: Option< - schedule::Period>, - >, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -419,9 +397,7 @@ pub mod pallet { origin: OriginFor, id: TaskName, after: BlockNumberFor, - maybe_periodic: Option< - schedule::Period>, - >, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -461,14 +437,7 @@ impl> Pallet { } Agenda::::translate::< - Vec< - Option< - ScheduledV1< - ::RuntimeCall, - BlockNumberFor, - >, - >, - >, + Vec::RuntimeCall, BlockNumberFor>>>, _, >(|_, agenda| { Some(BoundedVec::truncate_from( @@ -751,10 +720,7 @@ impl Pallet { fn place_task( when: BlockNumberFor, what: ScheduledOf, - ) -> Result< - TaskAddress>, - (DispatchError, ScheduledOf), - > { + ) -> Result>, (DispatchError, ScheduledOf)> { let maybe_name = what.maybe_id; let index = Self::push_to_agenda(when, what)?; let address = (when, index); @@ -992,11 +958,7 @@ use ServiceTaskError::*; impl Pallet { /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. - fn service_agendas( - weight: &mut WeightMeter, - now: BlockNumberFor, - max: u32, - ) { + fn service_agendas(weight: &mut WeightMeter, now: BlockNumberFor, max: u32) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { return } @@ -1204,11 +1166,7 @@ impl Pallet { } impl> - schedule::v2::Anon< - BlockNumberFor, - ::RuntimeCall, - T::PalletsOrigin, - > for Pallet + schedule::v2::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet { type Address = TaskAddress>; type Hash = T::Hash; @@ -1236,19 +1194,13 @@ impl> Self::do_reschedule(address, when) } - fn next_dispatch_time( - (when, index): Self::Address, - ) -> Result, ()> { + fn next_dispatch_time((when, index): Self::Address) -> Result, ()> { Agenda::::get(when).get(index as usize).ok_or(()).map(|_| when) } } impl> - schedule::v2::Named< - BlockNumberFor, - ::RuntimeCall, - T::PalletsOrigin, - > for Pallet + schedule::v2::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet { type Address = TaskAddress>; type Hash = T::Hash; @@ -1280,9 +1232,7 @@ impl> Self::do_reschedule_named(name, when) } - fn next_dispatch_time( - id: Vec, - ) -> Result, ()> { + fn next_dispatch_time(id: Vec) -> Result, ()> { let name = blake2_256(&id[..]); Lookup::::get(name) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) @@ -1290,12 +1240,8 @@ impl> } } -impl - schedule::v3::Anon< - BlockNumberFor, - ::RuntimeCall, - T::PalletsOrigin, - > for Pallet +impl schedule::v3::Anon, ::RuntimeCall, T::PalletsOrigin> + for Pallet { type Address = TaskAddress>; @@ -1332,12 +1278,8 @@ impl use schedule::v3::TaskName; -impl - schedule::v3::Named< - BlockNumberFor, - ::RuntimeCall, - T::PalletsOrigin, - > for Pallet +impl schedule::v3::Named, ::RuntimeCall, T::PalletsOrigin> + for Pallet { type Address = TaskAddress>; @@ -1363,9 +1305,7 @@ impl Self::do_reschedule_named(id, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time( - id: TaskName, - ) -> Result, DispatchError> { + fn next_dispatch_time(id: TaskName) -> Result, DispatchError> { Lookup::::get(id) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) .ok_or(DispatchError::Unavailable) diff --git a/frame/scheduler/src/migration.rs b/frame/scheduler/src/migration.rs index 6a294a7c98108..06259768f0aa1 100644 --- a/frame/scheduler/src/migration.rs +++ b/frame/scheduler/src/migration.rs @@ -36,24 +36,13 @@ pub mod v1 { Pallet, Twox64Concat, BlockNumberFor, - Vec< - Option< - ScheduledV1< - ::RuntimeCall, - BlockNumberFor, - >, - >, - >, + Vec::RuntimeCall, BlockNumberFor>>>, ValueQuery, >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; } pub mod v2 { @@ -70,12 +59,8 @@ pub mod v2 { >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; } pub mod v3 { @@ -92,12 +77,8 @@ pub mod v3 { >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; /// Migrate the scheduler pallet from V3 to V4. pub struct MigrateToV4(sp_std::marker::PhantomData); diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index 144612fbe3dea..b0840ef83e52d 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -47,9 +47,7 @@ pub trait Config: } impl OnInitialize> for Pallet { - fn on_initialize( - n: BlockNumberFor, - ) -> frame_support::weights::Weight { + fn on_initialize(n: BlockNumberFor) -> frame_support::weights::Weight { pallet_session::Pallet::::on_initialize(n) } } diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 81f8452f3f976..0882943d781b7 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -902,18 +902,14 @@ impl ValidatorSet for Pallet { } } -impl EstimateNextNewSession> - for Pallet -{ +impl EstimateNextNewSession> for Pallet { fn average_session_length() -> BlockNumberFor { T::NextSessionRotation::average_session_length() } /// This session pallet always calls new_session and next_session at the same time, hence we /// do a simple proxy and pass the function to next rotation. - fn estimate_next_new_session( - now: BlockNumberFor, - ) -> (Option>, Weight) { + fn estimate_next_new_session(now: BlockNumberFor) -> (Option>, Weight) { T::NextSessionRotation::estimate_next_session_rotation(now) } } diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 8d9e688f9582f..8b3635bcb0373 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -416,10 +416,8 @@ impl BidKind { } } -pub type PayoutsFor = BoundedVec< - (BlockNumberFor, BalanceOf), - >::MaxPayouts, ->; +pub type PayoutsFor = + BoundedVec<(BlockNumberFor, BalanceOf), >::MaxPayouts>; /// Information concerning a member. #[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] @@ -439,10 +437,7 @@ pub struct PayoutRecord { pub type PayoutRecordFor = PayoutRecord< BalanceOf, - BoundedVec< - (BlockNumberFor, BalanceOf), - >::MaxPayouts, - >, + BoundedVec<(BlockNumberFor, BalanceOf), >::MaxPayouts>, >; /// Record for an individual new member who was elevated from a candidate recently. @@ -1939,11 +1934,7 @@ impl, I: 'static> Pallet { /// /// It is the caller's duty to ensure that `who` is already a member. This does nothing if `who` /// is not a member or if `value` is zero. - fn bump_payout( - who: &T::AccountId, - when: BlockNumberFor, - value: BalanceOf, - ) { + fn bump_payout(who: &T::AccountId, when: BlockNumberFor, value: BalanceOf) { if value.is_zero() { return } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 98971b0899363..98010bec00764 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1021,9 +1021,7 @@ impl ElectionDataProvider for Pallet { Ok(Self::get_npos_targets(None)) } - fn next_election_prediction( - now: BlockNumberFor, - ) -> BlockNumberFor { + fn next_election_prediction(now: BlockNumberFor) -> BlockNumberFor { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1040,17 +1038,16 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: BlockNumberFor = - match ForceEra::::get() { - Forcing::ForceNone => Bounded::max_value(), - Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), - Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), - Forcing::NotForcing => T::SessionsPerEra::get() - .saturating_sub(era_progress) - // One session is computed in this_session_end. - .saturating_sub(1) - .into(), - }; + let sessions_left: BlockNumberFor = match ForceEra::::get() { + Forcing::ForceNone => Bounded::max_value(), + Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), + Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), + Forcing::NotForcing => T::SessionsPerEra::get() + .saturating_sub(era_progress) + // One session is computed in this_session_end. + .saturating_sub(1) + .into(), + }; now.saturating_add( until_this_session_end.saturating_add(sessions_left.saturating_mul(session_length)), @@ -1240,9 +1237,7 @@ impl historical::SessionManager - pallet_authorship::EventHandler> - for Pallet +impl pallet_authorship::EventHandler> for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, { diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index cc6e74244699f..6b38d42d33d0d 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -128,8 +128,7 @@ pub mod pallet_prelude { pub struct TestRandomness(sp_std::marker::PhantomData); impl - frame_support::traits::Randomness> - for TestRandomness + frame_support::traits::Randomness> for TestRandomness where T: frame_system::Config, { diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 3385c1b12539f..60e90faa1ba93 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -59,8 +59,7 @@ mod no_instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] - pub type TestGenericValue = - StorageValue<_, BlockNumberFor, OptionQuery>; + pub type TestGenericValue = StorageValue<_, BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap = StorageDoubleMap< @@ -77,8 +76,7 @@ mod no_instance { pub struct GenesisConfig { pub value: u32, pub test_generic_value: BlockNumberFor, - pub test_generic_double_map: - Vec<(u32, BlockNumberFor, u32)>, + pub test_generic_double_map: Vec<(u32, BlockNumberFor, u32)>, } impl Default for GenesisConfig { @@ -155,8 +153,7 @@ mod instance { pub struct GenesisConfig, I: 'static = ()> { pub value: u32, pub test_generic_value: BlockNumberFor, - pub test_generic_double_map: - Vec<(u32, BlockNumberFor, u32)>, + pub test_generic_double_map: Vec<(u32, BlockNumberFor, u32)>, pub phantom: PhantomData, } diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 70112a4ef63a5..05175e68a2d7d 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -38,14 +38,8 @@ pub mod pallet { #[pallet::storage] #[pallet::unbounded] - pub type AppendableDM = StorageDoubleMap< - _, - Identity, - u32, - Identity, - BlockNumberFor, - Vec, - >; + pub type AppendableDM = + StorageDoubleMap<_, Identity, u32, Identity, BlockNumberFor, Vec>; #[pallet::genesis_config] pub struct GenesisConfig { diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index d52e81dbbe36d..5d474ecea95fa 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -27,11 +27,7 @@ mod module { use frame_support::pallet_prelude::*; use frame_support_test as frame_system; - pub type Request = ( - ::AccountId, - Role, - BlockNumberFor, - ); + pub type Request = (::AccountId, Role, BlockNumberFor); pub type Requests = Vec>; #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -118,12 +114,7 @@ mod module { /// tokens locked until given block number #[pallet::storage] #[pallet::getter(fn bondage)] - pub type Bondage = StorageMap< - _, - Blake2_128Concat, - T::AccountId, - BlockNumberFor, - >; + pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor>; /// First step before enter a role is registering intent with a new account/key. /// This is done by sending a role_entry_request() from the new account. diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 9dcdd71c9a746..15a53c1de3e70 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -174,12 +174,7 @@ pub mod pallet { _, Twox64Concat, T::Hash, - OpenTip< - T::AccountId, - BalanceOf, - BlockNumberFor, - T::Hash, - >, + OpenTip, BlockNumberFor, T::Hash>, OptionQuery, >; @@ -476,12 +471,7 @@ impl, I: 'static> Pallet { /// /// `O(T)` and one storage access. fn insert_tip_and_check_closing( - tip: &mut OpenTip< - T::AccountId, - BalanceOf, - BlockNumberFor, - T::Hash, - >, + tip: &mut OpenTip, BlockNumberFor, T::Hash>, tipper: T::AccountId, tip_value: BalanceOf, ) -> bool { @@ -526,12 +516,7 @@ impl, I: 'static> Pallet { /// Plus `O(T)` (`T` is Tippers length). fn payout_tip( hash: T::Hash, - tip: OpenTip< - T::AccountId, - BalanceOf, - BlockNumberFor, - T::Hash, - >, + tip: OpenTip, BlockNumberFor, T::Hash>, ) { let mut tips = tip.tips; Self::retain_active_tips(&mut tips); @@ -593,12 +578,7 @@ impl, I: 'static> Pallet { for (hash, old_tip) in storage_key_iter::< T::Hash, - OldOpenTip< - T::AccountId, - BalanceOf, - BlockNumberFor, - T::Hash, - >, + OldOpenTip, BlockNumberFor, T::Hash>, Twox64Concat, >(module, item) .drain() diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index 7a1de75ccb6d7..136184176c075 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -349,13 +349,8 @@ pub mod pallet { /// Count indexed chunks for each block. #[pallet::storage] - pub(super) type ChunkCount = StorageMap< - _, - Blake2_128Concat, - BlockNumberFor, - u32, - ValueQuery, - >; + pub(super) type ChunkCount = + StorageMap<_, Blake2_128Concat, BlockNumberFor, u32, ValueQuery>; #[pallet::storage] #[pallet::getter(fn byte_fee)] @@ -370,8 +365,7 @@ pub mod pallet { /// Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD` /// for block authoring. #[pallet::storage] - pub(super) type StoragePeriod = - StorageValue<_, BlockNumberFor, ValueQuery>; + pub(super) type StoragePeriod = StorageValue<_, BlockNumberFor, ValueQuery>; // Intermediates #[pallet::storage] diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 81211cbb37cdf..3ed1d2fb217ed 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -129,9 +129,7 @@ impl VestingAction { fn pick_schedules( &self, schedules: Vec, BlockNumberFor>>, - ) -> impl Iterator< - Item = VestingInfo, BlockNumberFor>, - > + '_ { + ) -> impl Iterator, BlockNumberFor>> + '_ { schedules.into_iter().enumerate().filter_map(move |(index, schedule)| { if self.should_remove(index) { None @@ -207,10 +205,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - BoundedVec< - VestingInfo, BlockNumberFor>, - MaxVestingSchedulesGet, - >, + BoundedVec, BlockNumberFor>, MaxVestingSchedulesGet>, >; /// Storage version of the pallet. @@ -225,12 +220,7 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { - pub vesting: Vec<( - T::AccountId, - BlockNumberFor, - BlockNumberFor, - BalanceOf, - )>, + pub vesting: Vec<(T::AccountId, BlockNumberFor, BlockNumberFor, BalanceOf)>, } #[pallet::genesis_build] @@ -547,10 +537,7 @@ impl Pallet { fn report_schedule_updates( schedules: Vec, BlockNumberFor>>, action: VestingAction, - ) -> ( - Vec, BlockNumberFor>>, - BalanceOf, - ) { + ) -> (Vec, BlockNumberFor>>, BalanceOf) { let now = >::block_number(); let mut total_locked_now: BalanceOf = Zero::zero(); @@ -621,13 +608,7 @@ impl Pallet { fn exec_action( schedules: Vec, BlockNumberFor>>, action: VestingAction, - ) -> Result< - ( - Vec, BlockNumberFor>>, - BalanceOf, - ), - DispatchError, - > { + ) -> Result<(Vec, BlockNumberFor>>, BalanceOf), DispatchError> { let (schedules, locked_now) = match action { VestingAction::Merge { index1: idx1, index2: idx2 } => { // The schedule index is based off of the schedule ordering prior to filtering out diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index b01ccaa3cb137..cac3c90b403ab 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -40,27 +40,26 @@ pub mod v1 { pub fn migrate() -> Weight { let mut reads_writes = 0; - Vesting::::translate::< - VestingInfo, BlockNumberFor>, - _, - >(|_key, vesting_info| { - reads_writes += 1; - let v: Option< - BoundedVec< - VestingInfo, BlockNumberFor>, - MaxVestingSchedulesGet, - >, - > = vec![vesting_info].try_into().ok(); - - if v.is_none() { - log::warn!( - target: "runtime::vesting", - "migration: Failed to move a vesting schedule into a BoundedVec" - ); - } + Vesting::::translate::, BlockNumberFor>, _>( + |_key, vesting_info| { + reads_writes += 1; + let v: Option< + BoundedVec< + VestingInfo, BlockNumberFor>, + MaxVestingSchedulesGet, + >, + > = vec![vesting_info].try_into().ok(); + + if v.is_none() { + log::warn!( + target: "runtime::vesting", + "migration: Failed to move a vesting schedule into a BoundedVec" + ); + } - v - }); + v + }, + ); T::DbWeight::get().reads_writes(reads_writes, reads_writes) } From 6d9286ff8313014d92a468a3df176294743bb200 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:58:10 +0530 Subject: [PATCH 21/67] Fixes construct_runtime tests --- frame/support/test/tests/construct_runtime.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 6d8e7717fbb25..4982821078f38 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -629,7 +629,16 @@ fn call_subtype_conversion() { fn test_metadata() { use frame_support::metadata::*; use scale_info::meta_type; + use sp_core::Encode; + fn maybe_docs(doc: Vec<&'static str>) -> Vec<&'static str> { + if cfg!(feature = "no-metadata-docs") { + vec![] + } else { + doc + } + } + let pallets = vec![ PalletMetadata { name: "System", From 09f50efa8f71d8fcb696c4fd89cfbe3ee03a9a37 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:17:47 +0530 Subject: [PATCH 22/67] Fixes imports in benchmarks --- frame/alliance/src/benchmarking.rs | 5 ++-- frame/bounties/src/benchmarking.rs | 17 +++++++------- frame/child-bounties/src/benchmarking.rs | 7 +++--- frame/collective/src/benchmarking.rs | 7 +++--- frame/core-fellowship/src/benchmarking.rs | 5 ++-- frame/democracy/src/benchmarking.rs | 9 ++++---- frame/democracy/src/lib.rs | 4 ++-- frame/examples/offchain-worker/src/lib.rs | 4 ++-- frame/executive/src/lib.rs | 7 +++--- .../nft-fractionalization/src/benchmarking.rs | 1 + frame/nfts/src/benchmarking.rs | 7 +++--- frame/proxy/src/benchmarking.rs | 13 ++++++----- frame/referenda/src/lib.rs | 4 ++-- frame/scheduler/src/benchmarking.rs | 7 +++--- frame/support/test/tests/issue2219.rs | 23 +++++++++++-------- frame/transaction-storage/src/benchmarking.rs | 5 ++-- frame/vesting/src/benchmarking.rs | 9 ++++---- 17 files changed, 75 insertions(+), 59 deletions(-) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 07c0ab6a80949..0df6110f81150 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -28,6 +28,7 @@ use sp_std::{ use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{Pallet as System, RawOrigin as SystemOrigin}; +use frame_system::pallet_prelude::BlockNumberFor; use super::{Call as AllianceCall, Pallet as Alliance, *}; @@ -432,7 +433,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { @@ -504,7 +505,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index a1e1681d2df40..2948a62f62122 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -25,6 +25,7 @@ use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, }; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::Bounded; use crate::Pallet as Bounties; @@ -77,7 +78,7 @@ fn create_bounty, I: 'static>( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup.clone(), fee)?; Bounties::::accept_curator(RawOrigin::Signed(curator).into(), bounty_id)?; Ok((curator_lookup, bounty_id)) @@ -115,14 +116,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); }: _(approve_origin, bounty_id, curator_lookup, fee) // Worst case when curator is inactive and any sender unassigns the curator. unassign_curator { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 2u32.into()); let caller = whitelisted_caller(); @@ -136,14 +137,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup, fee)?; }: _(RawOrigin::Signed(curator), bounty_id) award_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -154,7 +155,7 @@ benchmarks_instance_pallet! { claim_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -183,7 +184,7 @@ benchmarks_instance_pallet! { close_bounty_active { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let approve_origin = T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; @@ -195,7 +196,7 @@ benchmarks_instance_pallet! { extend_bounty_expiry { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index 3bdd6ff51c2bd..bcf5b21fe54c6 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -23,6 +23,7 @@ use super::*; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use crate::Pallet as ChildBounties; use pallet_bounties::Pallet as Bounties; @@ -114,7 +115,7 @@ fn activate_bounty( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin, child_bounty_setup.bounty_id)?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator( RawOrigin::Root.into(), child_bounty_setup.bounty_id, @@ -229,7 +230,7 @@ benchmarks! { unassign_curator { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), bounty_setup.bounty_id, @@ -303,7 +304,7 @@ benchmarks! { close_child_bounty_active { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { assert_last_event::(Event::Canceled { diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 88313696bacdf..aeba2db0ef35e 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -25,6 +25,7 @@ use sp_std::mem::size_of; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin}; +use frame_system::pallet_prelude::BlockNumberFor; const SEED: u32 = 0; @@ -516,7 +517,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime nay will close it as disapproved @@ -588,7 +589,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime aye will close it as approved @@ -637,7 +638,7 @@ benchmarks_instance_pallet! { last_hash = T::Hashing::hash_of(&proposal); } - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); }: _(SystemOrigin::Root, last_hash) diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs index 5eab4a1e728aa..b6b1784027c2b 100644 --- a/frame/core-fellowship/src/benchmarking.rs +++ b/frame/core-fellowship/src/benchmarking.rs @@ -24,6 +24,7 @@ use crate::Pallet as CoreFellowship; use frame_benchmarking::v2::*; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_arithmetic::traits::Bounded; const SEED: u32 = 0; @@ -76,7 +77,7 @@ mod benchmarks { // Set it to the max value to ensure that any possible auto-demotion period has passed. frame_system::Pallet::::set_block_number( - frame_system::pallet_prelude::BlockNumberFor::::max_value(), + BlockNumberFor::::max_value(), ); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); @@ -95,7 +96,7 @@ mod benchmarks { // Set it to the max value to ensure that any possible auto-demotion period has passed. frame_system::Pallet::::set_block_number( - frame_system::pallet_prelude::BlockNumberFor::::max_value(), + BlockNumberFor::::max_value(), ); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 36ab6c5da8ecc..ad29f5048a3cd 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -25,6 +25,7 @@ use frame_support::{ traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable}, }; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::H256; use sp_runtime::{traits::Bounded, BoundedVec}; @@ -258,7 +259,7 @@ benchmarks! { .collect::>() .try_into() .unwrap(); - Blacklist::::insert(proposal.hash(), (frame_system::pallet_prelude::BlockNumberFor::::zero(), addresses)); + Blacklist::::insert(proposal.hash(), (BlockNumberFor::::zero(), addresses)); }: _(origin, proposal) verify { // External proposal created @@ -332,7 +333,7 @@ benchmarks! { vetoers.try_push(account::("vetoer", i, SEED)).unwrap(); } vetoers.sort(); - Blacklist::::insert(proposal_hash, (frame_system::pallet_prelude::BlockNumberFor::::zero(), vetoers)); + Blacklist::::insert(proposal_hash, (BlockNumberFor::::zero(), vetoers)); let origin = T::VetoOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; ensure!(NextExternal::::get().is_some(), "no external proposal"); @@ -816,7 +817,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: frame_system::pallet_prelude::BlockNumberFor::::zero(), approved: true }, + ReferendumInfo::Finished { end: BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let caller = funded_account::("caller", 0); @@ -833,7 +834,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: frame_system::pallet_prelude::BlockNumberFor::::zero(), approved: true }, + ReferendumInfo::Finished { end: BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let hash = note_preimage::(); diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 3336ddb7cdaef..ccf5566d28d76 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -802,7 +802,7 @@ pub mod pallet { } ensure!( - voting_period > frame_system::pallet_prelude::BlockNumberFor::::zero(), + voting_period > BlockNumberFor::::zero(), Error::::VotingPeriodLow ); let (ext_proposal, threshold) = @@ -1058,7 +1058,7 @@ pub mod pallet { // Insert the proposal into the blacklist. let permanent = ( - frame_system::pallet_prelude::BlockNumberFor::::max_value(), + BlockNumberFor::::max_value(), BoundedVec::::default(), ); Blacklist::::insert(&proposal_hash, permanent); diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index f9cd4147068d0..0ddd373d3f5fd 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -422,11 +422,11 @@ impl Pallet { if transaction_type == Zero::zero() { TransactionType::Signed } else if transaction_type == - frame_system::pallet_prelude::BlockNumberFor::::from(1u32) + BlockNumberFor::::from(1u32) { TransactionType::UnsignedForAny } else if transaction_type == - frame_system::pallet_prelude::BlockNumberFor::::from(2u32) + BlockNumberFor::::from(2u32) { TransactionType::UnsignedForAll } else { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 41a909afc082d..959d238517592 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -126,6 +126,7 @@ use frame_support::{ }, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ generic::Digest, traits::{ @@ -479,9 +480,9 @@ where // Check that `parent_hash` is correct. let n = *header.number(); assert!( - n > frame_system::pallet_prelude::BlockNumberFor::::zero() && + n > BlockNumberFor::::zero() && >::block_hash( - n - frame_system::pallet_prelude::BlockNumberFor::::one() + n - BlockNumberFor::::one() ) == *header.parent_hash(), "Parent hash should be valid.", ); @@ -752,7 +753,7 @@ mod tests { } fn offchain_worker(n: BlockNumberFor) { - assert_eq!(frame_system::pallet_prelude::BlockNumberFor::::from(1u32), n); + assert_eq!(BlockNumberFor::::from(1u32), n); } } diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index fb91f953a0168..67c939bfc1d28 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -30,6 +30,7 @@ use frame_support::{ }, }; use frame_system::RawOrigin as SystemOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use pallet_nfts::{CollectionConfig, CollectionSettings, ItemConfig, MintSettings}; use sp_runtime::traits::StaticLookup; use sp_std::prelude::*; diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 4b955c6129c09..7b97a627523d6 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -31,6 +31,7 @@ use frame_support::{ BoundedVec, }; use frame_system::RawOrigin as SystemOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_io::crypto::{sr25519_generate, sr25519_sign}; use sp_runtime::{ traits::{Bounded, IdentifyAccount, One}, @@ -589,7 +590,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); - let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); + let deadline = BlockNumberFor::::max_value(); }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup, Some(deadline)) verify { assert_last_event::(Event::TransferApproved { collection, item, owner: caller, delegate, deadline: Some(deadline) }.into()); @@ -601,7 +602,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); + let deadline = BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) verify { @@ -614,7 +615,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = frame_system::pallet_prelude::BlockNumberFor::::max_value(); + let deadline = BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 72c61dd6d5de3..013bd7865d695 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -23,6 +23,7 @@ use super::*; use crate::Pallet as Proxy; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::Bounded; const SEED: u32 = 0; @@ -41,7 +42,7 @@ fn add_proxies(n: u32, maybe_who: Option) -> Result<(), RawOrigin::Signed(caller.clone()).into(), real, T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero(), + BlockNumberFor::::zero(), )?; } Ok(()) @@ -64,7 +65,7 @@ fn add_announcements( RawOrigin::Signed(real.clone()).into(), caller_lookup, T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero(), + BlockNumberFor::::zero(), )?; real }; @@ -187,7 +188,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), real, T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero() + BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -202,7 +203,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), delegate, T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero() + BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -224,7 +225,7 @@ benchmarks! { }: _( RawOrigin::Signed(caller.clone()), T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero(), + BlockNumberFor::::zero(), 0 ) verify { @@ -246,7 +247,7 @@ benchmarks! { Pallet::::create_pure( RawOrigin::Signed(whitelisted_caller()).into(), T::ProxyType::default(), - frame_system::pallet_prelude::BlockNumberFor::::zero(), + BlockNumberFor::::zero(), 0 )?; let height = system::Pallet::::block_number(); diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index f7737b9333fba..fec56e806b84f 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -1075,7 +1075,7 @@ impl, I: 'static> Pallet { }; // Default the alarm to the end of the world. let timeout = status.submitted + T::UndecidingTimeout::get(); - let mut alarm = frame_system::pallet_prelude::BlockNumberFor::::max_value(); + let mut alarm = BlockNumberFor::::max_value(); let branch; match &mut status.deciding { None => { @@ -1206,7 +1206,7 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = if alarm < frame_system::pallet_prelude::BlockNumberFor::::max_value() + let dirty_alarm = if alarm < BlockNumberFor::::max_value() { Self::ensure_alarm_at(&mut status, index, alarm) } else { diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index db9524f26ba6b..e8ec7619e164e 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -24,6 +24,7 @@ use frame_support::{ traits::{schedule::Priority, BoundedInline}, }; use frame_system::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; use sp_std::{prelude::*, vec}; use crate::Pallet as Scheduler; @@ -128,7 +129,7 @@ fn make_origin(signed: bool) -> ::PalletsOrigin { benchmarks! { // `service_agendas` when no work is done. service_agendas_base { - let now = frame_system::pallet_prelude::BlockNumberFor::::from(BLOCK_NUMBER); + let now = BlockNumberFor::::from(BLOCK_NUMBER); IncompleteSince::::put(now - One::one()); }: { Scheduler::::service_agendas(&mut WeightMeter::max_limit(), now, 0); @@ -227,7 +228,7 @@ benchmarks! { schedule { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let when = BLOCK_NUMBER.into(); - let periodic = Some((frame_system::pallet_prelude::BlockNumberFor::::one(), 100)); + let periodic = Some((BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); @@ -270,7 +271,7 @@ benchmarks! { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let id = u32_to_name(s); let when = BLOCK_NUMBER.into(); - let periodic = Some((frame_system::pallet_prelude::BlockNumberFor::::one(), 100)); + let periodic = Some((BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 5d474ecea95fa..4797da88c5533 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -25,7 +25,6 @@ use sp_runtime::{ mod module { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; pub type Request = (::AccountId, Role, BlockNumberFor); pub type Requests = Vec>; @@ -66,14 +65,14 @@ mod module { fn default() -> Self { Self { max_actors: 10, - reward_period: frame_system::pallet_prelude::BlockNumberFor::::default(), - unbonding_period: frame_system::pallet_prelude::BlockNumberFor::::default(), + reward_period: BlockNumberFor::::default(), + unbonding_period: BlockNumberFor::::default(), // not currently used min_actors: 5, - bonding_period: frame_system::pallet_prelude::BlockNumberFor::::default(), - min_service_period: frame_system::pallet_prelude::BlockNumberFor::::default(), - startup_grace_period: frame_system::pallet_prelude::BlockNumberFor::::default(), + bonding_period: BlockNumberFor::::default(), + min_service_period: BlockNumberFor::::default(), + startup_grace_period: BlockNumberFor::::default(), } } } @@ -158,21 +157,25 @@ pub type Header = generic::Header; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; pub type Block = generic::Block; -impl frame_support_test::Config for Runtime { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); + + type AccountData = pallet_balances::AccountData; } impl module::Config for Runtime {} frame_support::construct_runtime!( pub struct Runtime { - System: frame_support_test, + System: frame_system, Module: module, } ); diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index c554628e15d92..9cb7d28aed112 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -23,6 +23,7 @@ use super::*; use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Bounded, One, Zero}; use sp_std::*; use sp_transaction_storage_proof::TransactionStorageProof; @@ -144,7 +145,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; run_to_block::(1u32.into()); - }: _(RawOrigin::Signed(caller.clone()), frame_system::pallet_prelude::BlockNumberFor::::zero(), 0) + }: _(RawOrigin::Signed(caller.clone()), BlockNumberFor::::zero(), 0) verify { assert_last_event::(Event::Renewed { index: 0 }.into()); } @@ -159,7 +160,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; } - run_to_block::(StoragePeriod::::get() + frame_system::pallet_prelude::BlockNumberFor::::one()); + run_to_block::(StoragePeriod::::get() + BlockNumberFor::::one()); let encoded_proof = proof(); let proof = TransactionStorageProof::decode(&mut &*encoded_proof).unwrap(); }: check_proof(RawOrigin::None, proof) diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 699e94237c970..02455a65070da 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -22,6 +22,7 @@ use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::assert_ok; use frame_system::{Pallet as System, RawOrigin}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul}; use super::*; @@ -55,7 +56,7 @@ fn add_vesting_schedules( let source_lookup = T::Lookup::unlookup(source.clone()); T::Currency::make_free_balance_be(&source, BalanceOf::::max_value()); - System::::set_block_number(frame_system::pallet_prelude::BlockNumberFor::::zero()); + System::::set_block_number(BlockNumberFor::::zero()); let mut total_locked: BalanceOf = Zero::zero(); for _ in 0..n { @@ -88,7 +89,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), @@ -144,7 +145,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(other_lookup.clone(), s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&other), Some(expected_balance), @@ -284,7 +285,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // Schedules are not vesting at block 0. - assert_eq!(System::::block_number(), frame_system::pallet_prelude::BlockNumberFor::::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), From 67223f44a9e2558ff953f6f68d093d244fc720eb Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:18:13 +0530 Subject: [PATCH 23/67] Formatting --- frame/alliance/src/benchmarking.rs | 3 +-- frame/bounties/src/benchmarking.rs | 3 +-- frame/child-bounties/src/benchmarking.rs | 3 +-- frame/collective/src/benchmarking.rs | 5 +++-- frame/core-fellowship/src/benchmarking.rs | 11 +++-------- frame/democracy/src/benchmarking.rs | 3 +-- frame/democracy/src/lib.rs | 11 +++-------- frame/examples/offchain-worker/src/lib.rs | 8 ++------ frame/executive/src/lib.rs | 5 ++--- frame/nft-fractionalization/src/benchmarking.rs | 3 +-- frame/nfts/src/benchmarking.rs | 3 +-- frame/proxy/src/benchmarking.rs | 3 +-- frame/referenda/src/lib.rs | 3 +-- frame/scheduler/src/benchmarking.rs | 3 +-- frame/support/test/tests/construct_runtime.rs | 2 +- frame/transaction-storage/src/benchmarking.rs | 3 +-- frame/vesting/src/benchmarking.rs | 3 +-- 17 files changed, 25 insertions(+), 50 deletions(-) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 0df6110f81150..eb32c6c466c91 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -27,8 +27,7 @@ use sp_std::{ use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; -use frame_system::{Pallet as System, RawOrigin as SystemOrigin}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; use super::{Call as AllianceCall, Pallet as Alliance, *}; diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 2948a62f62122..6fff337cba450 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -24,8 +24,7 @@ use super::*; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, }; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Bounded; use crate::Pallet as Bounties; diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index bcf5b21fe54c6..1973564d0dc1d 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use crate::Pallet as ChildBounties; use pallet_bounties::Pallet as Bounties; diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index aeba2db0ef35e..503d725105309 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -24,8 +24,9 @@ use sp_runtime::traits::Bounded; use sp_std::mem::size_of; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; -use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{ + pallet_prelude::BlockNumberFor, Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin, +}; const SEED: u32 = 0; diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs index b6b1784027c2b..ea0b5c6d4495f 100644 --- a/frame/core-fellowship/src/benchmarking.rs +++ b/frame/core-fellowship/src/benchmarking.rs @@ -23,8 +23,7 @@ use super::*; use crate::Pallet as CoreFellowship; use frame_benchmarking::v2::*; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_arithmetic::traits::Bounded; const SEED: u32 = 0; @@ -76,9 +75,7 @@ mod benchmarks { let member = make_member::(0)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number( - BlockNumberFor::::max_value(), - ); + frame_system::Pallet::::set_block_number(BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); @@ -95,9 +92,7 @@ mod benchmarks { let member = make_member::(2)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number( - BlockNumberFor::::max_value(), - ); + frame_system::Pallet::::set_block_number(BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); assert_eq!(T::Members::rank_of(&member), Some(2)); diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index ad29f5048a3cd..e4a21a4e1d9b8 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -24,8 +24,7 @@ use frame_support::{ assert_noop, assert_ok, traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable}, }; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_core::H256; use sp_runtime::{traits::Bounded, BoundedVec}; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index ccf5566d28d76..897b468a7a8cb 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -801,10 +801,7 @@ pub mod pallet { ensure!(T::InstantAllowed::get(), Error::::InstantNotAllowed); } - ensure!( - voting_period > BlockNumberFor::::zero(), - Error::::VotingPeriodLow - ); + ensure!(voting_period > BlockNumberFor::::zero(), Error::::VotingPeriodLow); let (ext_proposal, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( @@ -1057,10 +1054,8 @@ pub mod pallet { T::BlacklistOrigin::ensure_origin(origin)?; // Insert the proposal into the blacklist. - let permanent = ( - BlockNumberFor::::max_value(), - BoundedVec::::default(), - ); + let permanent = + (BlockNumberFor::::max_value(), BoundedVec::::default()); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 0ddd373d3f5fd..a151cee238b6d 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -421,13 +421,9 @@ impl Pallet { let transaction_type = block_number % 4u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed - } else if transaction_type == - BlockNumberFor::::from(1u32) - { + } else if transaction_type == BlockNumberFor::::from(1u32) { TransactionType::UnsignedForAny - } else if transaction_type == - BlockNumberFor::::from(2u32) - { + } else if transaction_type == BlockNumberFor::::from(2u32) { TransactionType::UnsignedForAll } else { TransactionType::Raw diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 959d238517592..05442ff2f0405 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -481,9 +481,8 @@ where let n = *header.number(); assert!( n > BlockNumberFor::::zero() && - >::block_hash( - n - BlockNumberFor::::one() - ) == *header.parent_hash(), + >::block_hash(n - BlockNumberFor::::one()) == + *header.parent_hash(), "Parent hash should be valid.", ); diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 67c939bfc1d28..0b54acdab49ea 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -29,8 +29,7 @@ use frame_support::{ Get, }, }; -use frame_system::RawOrigin as SystemOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use pallet_nfts::{CollectionConfig, CollectionSettings, ItemConfig, MintSettings}; use sp_runtime::traits::StaticLookup; use sp_std::prelude::*; diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 7b97a627523d6..67ba29266245a 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -30,8 +30,7 @@ use frame_support::{ traits::{EnsureOrigin, Get}, BoundedVec, }; -use frame_system::RawOrigin as SystemOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use sp_io::crypto::{sr25519_generate, sr25519_sign}; use sp_runtime::{ traits::{Bounded, IdentifyAccount, One}, diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 013bd7865d695..e0d14163d21b2 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use crate::Pallet as Proxy; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Bounded; const SEED: u32 = 0; diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index fec56e806b84f..a1d63e1a447ff 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -1206,8 +1206,7 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = if alarm < BlockNumberFor::::max_value() - { + let dirty_alarm = if alarm < BlockNumberFor::::max_value() { Self::ensure_alarm_at(&mut status, index, alarm) } else { Self::ensure_no_alarm(&mut status) diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index e8ec7619e164e..b41cea449654c 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -23,8 +23,7 @@ use frame_support::{ ensure, traits::{schedule::Priority, BoundedInline}, }; -use frame_system::RawOrigin; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_std::{prelude::*, vec}; use crate::Pallet as Scheduler; diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 4982821078f38..17b54ff62a3ac 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -638,7 +638,7 @@ fn test_metadata() { doc } } - + let pallets = vec![ PalletMetadata { name: "System", diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index 9cb7d28aed112..fdbaeb1f95181 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, One, Zero}; use sp_std::*; use sp_transaction_storage_proof::TransactionStorageProof; diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 02455a65070da..4af48f5d368db 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -21,8 +21,7 @@ use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::assert_ok; -use frame_system::{Pallet as System, RawOrigin}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul}; use super::*; From 3f05c253daf016c76a56dd5136fe88d6fec7b27f Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:36:37 +0530 Subject: [PATCH 24/67] Fixes construct_runtime tests --- frame/support/test/tests/construct_runtime.rs | 18 ++++++++++-------- frame/support/test/tests/final_keys.rs | 18 ++++++++++-------- frame/support/test/tests/genesisconfig.rs | 15 +++++++++------ frame/support/test/tests/instance.rs | 17 +++++++++-------- frame/support/test/tests/issue2219.rs | 7 ++++--- frame/support/test/tests/origin.rs | 18 ++++++++++-------- .../support/test/tests/storage_transaction.rs | 16 +++++++++------- 7 files changed, 61 insertions(+), 48 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 17b54ff62a3ac..d683a8476a5af 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -22,9 +22,12 @@ #![recursion_limit = "128"] use codec::MaxEncodedLen; +use frame_system::limits::{BlockWeights, BlockLength}; +use frame_support::weights::RuntimeDbWeight; use frame_support::{derive_impl, parameter_types, traits::PalletInfo as _}; use scale_info::TypeInfo; -use sp_core::{sr25519, ConstU32}; +use sp_api::RuntimeVersion; +use sp_core::{sr25519, ConstU64}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, @@ -246,8 +249,6 @@ pub type Header = generic::Header; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; pub type Block = generic::Block; -use frame_support_test as system; - frame_support::construct_runtime!( pub struct Runtime { @@ -278,7 +279,7 @@ impl frame_system::Config for Runtime { type PalletInfo = PalletInfo; type OnSetCode = (); type Block = Block; - type BlockHashCount = ConstU32<10>; + type BlockHashCount = ConstU64<10>; } impl module1::Config for Runtime { @@ -461,7 +462,8 @@ fn origin_codec() { fn event_codec() { use codec::Encode; - let event = frame_system::Event::::ExtrinsicSuccess; + let event = + frame_system::Event::::ExtrinsicSuccess { dispatch_info: Default::default() }; assert_eq!(RuntimeEvent::from(event).encode()[0], 30); let event = module1::Event::::A(test_pub()); @@ -498,7 +500,7 @@ fn event_codec() { #[test] fn call_codec() { use codec::Encode; - assert_eq!(RuntimeCall::System(frame_system::Call::noop {}).encode()[0], 30); + assert_eq!(RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }).encode()[0], 30); assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31); assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32); assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33); @@ -660,8 +662,8 @@ fn test_metadata() { }, PalletConstantMetadata { name: "BlockHashCount", - ty: meta_type::(), - value: 10u32.encode(), + ty: meta_type::(), + value: 10u64.encode(), docs: maybe_docs(vec![" Maximum number of block number to block hash mappings to keep (oldest pruned first)."]), }, PalletConstantMetadata { diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 60e90faa1ba93..a2dcc04330309 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -16,8 +16,10 @@ // limitations under the License. use codec::Encode; -use frame_support::{storage::unhashed, StoragePrefixedMap}; -use sp_core::sr25519; +use frame_support::{derive_impl, storage::unhashed, StoragePrefixedMap}; +use frame_system::pallet_prelude::BlockNumberFor; + +use sp_core::{sr25519, ConstU32}; use sp_io::{ hashing::{blake2_128, twox_128, twox_64}, TestExternalities, @@ -31,7 +33,6 @@ use sp_runtime::{ mod no_instance { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -105,7 +106,6 @@ mod no_instance { mod instance { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -203,21 +203,23 @@ frame_support::construct_runtime!( pub enum Runtime { - System: frame_support_test, + System: frame_system, FinalKeysNone: no_instance, FinalKeysSome: instance, Instance2FinalKeysSome: instance::, } ); -impl frame_support_test::Config for Runtime { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl no_instance::Config for Runtime {} diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 05175e68a2d7d..3d7c996791fd4 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -15,17 +15,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use sp_core::sr25519; +use sp_core::{sr25519, ConstU32}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, }; +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; #[frame_support::pallet] pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -73,19 +74,21 @@ frame_support::construct_runtime!( pub enum Test { - System: frame_support_test, + System: frame_system, MyPallet: pallet, } ); -impl frame_support_test::Config for Test { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl pallet::Config for Test {} diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index d7f3956e48f05..47257ca55a910 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -18,6 +18,7 @@ #![recursion_limit = "128"] use frame_support::{ + derive_impl, inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent}, metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, @@ -25,6 +26,7 @@ use frame_support::{ }, traits::ConstU32, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::sr25519; use sp_runtime::{ generic, @@ -39,10 +41,9 @@ pub trait Currency {} // * Origin, Inherent, Event #[frame_support::pallet(dev_mode)] mod module1 { - use self::frame_system::pallet_prelude::*; + use frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -150,7 +151,6 @@ mod module1 { mod module2 { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -252,7 +252,6 @@ mod module2 { mod module3 { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -279,7 +278,7 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime { - System: frame_support_test::{Pallet, Call, Event}, + System: frame_system::{Pallet, Call, Event}, Module1_1: module1::::{ Pallet, Call, Storage, Event, Config, Origin, Inherent }, @@ -300,14 +299,16 @@ frame_support::construct_runtime!( } ); -impl frame_support_test::Config for Runtime { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl module1::Config for Runtime { diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 4797da88c5533..31a0b885072b6 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -20,6 +20,8 @@ use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, }; +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; #[frame_support::pallet] mod module { @@ -158,7 +160,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] -impl frame_system::Config for Test { +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type Block = Block; type BlockHashCount = ConstU64<10>; @@ -167,8 +169,6 @@ impl frame_system::Config for Test { type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); - - type AccountData = pallet_balances::AccountData; } impl module::Config for Runtime {} @@ -183,6 +183,7 @@ frame_support::construct_runtime!( #[test] fn create_genesis_config() { let config = RuntimeGenesisConfig { + system: Default::default(), module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true }, }; assert_eq!(config.module.request_life_time, 0); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index c35b0fbe544f5..9834776508ee1 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -19,15 +19,16 @@ #![recursion_limit = "128"] +use sp_core::ConstU32; +use frame_support::derive_impl; use frame_support::traits::{Contains, OriginTrait}; use sp_runtime::{generic, traits::BlakeTwo256}; mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use self::frame_system::pallet_prelude::*; + use frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -72,9 +73,8 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use self::frame_system::pallet_prelude::*; + use frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -156,20 +156,22 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum RuntimeOriginTest { - System: frame_support_test, + System: frame_system, NestedModule: nested::module, Module: module, } ); -impl frame_support_test::Config for RuntimeOriginTest { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for RuntimeOriginTest { type BaseCallFilter = BaseCallFilter; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl nested::module::Config for RuntimeOriginTest { diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 0e52909e4857f..a669cfec9f34d 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -19,12 +19,13 @@ #![allow(deprecated)] use frame_support::{ + derive_impl, assert_noop, assert_ok, assert_storage_noop, dispatch::DispatchResult, storage::{with_transaction, TransactionOutcome::*}, transactional, }; -use sp_core::sr25519; +use sp_core::{sr25519, ConstU32}; use sp_io::TestExternalities; use sp_runtime::{ generic, @@ -36,10 +37,9 @@ pub use self::pallet::*; #[frame_support::pallet] pub mod pallet { - use self::frame_system::pallet_prelude::*; + use frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] #[pallet::generate_store(pub (super) trait Store)] @@ -84,19 +84,21 @@ frame_support::construct_runtime!( pub enum Runtime { - System: frame_support_test, + System: frame_system, MyPallet: pallet, } ); -impl frame_support_test::Config for Runtime { - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl Config for Runtime {} From 03cffab3de73bf8351ae398a3c96128dc91fd268 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:36:59 +0530 Subject: [PATCH 25/67] Formatting --- frame/support/test/tests/construct_runtime.rs | 7 ++++--- frame/support/test/tests/genesisconfig.rs | 4 ++-- frame/support/test/tests/instance.rs | 2 +- frame/support/test/tests/issue2219.rs | 4 ++-- frame/support/test/tests/origin.rs | 10 ++++++---- frame/support/test/tests/storage_transaction.rs | 5 ++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index d683a8476a5af..d698086396a19 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -22,9 +22,10 @@ #![recursion_limit = "128"] use codec::MaxEncodedLen; -use frame_system::limits::{BlockWeights, BlockLength}; -use frame_support::weights::RuntimeDbWeight; -use frame_support::{derive_impl, parameter_types, traits::PalletInfo as _}; +use frame_support::{ + derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbWeight, +}; +use frame_system::limits::{BlockLength, BlockWeights}; use scale_info::TypeInfo; use sp_api::RuntimeVersion; use sp_core::{sr25519, ConstU64}; diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 3d7c996791fd4..4a92e299fca0d 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -15,13 +15,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::{sr25519, ConstU32}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, }; -use frame_support::derive_impl; -use frame_system::pallet_prelude::BlockNumberFor; #[frame_support::pallet] pub mod pallet { diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 47257ca55a910..31aa49131f42f 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -41,9 +41,9 @@ pub trait Currency {} // * Origin, Inherent, Event #[frame_support::pallet(dev_mode)] mod module1 { - use frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 31a0b885072b6..730ed85b0f9ab 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -15,13 +15,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::{sr25519, ConstU64}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, }; -use frame_support::derive_impl; -use frame_system::pallet_prelude::BlockNumberFor; #[frame_support::pallet] mod module { diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 9834776508ee1..dcd218e72bdbd 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -19,16 +19,18 @@ #![recursion_limit = "128"] +use frame_support::{ + derive_impl, + traits::{Contains, OriginTrait}, +}; use sp_core::ConstU32; -use frame_support::derive_impl; -use frame_support::traits::{Contains, OriginTrait}; use sp_runtime::{generic, traits::BlakeTwo256}; mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -73,8 +75,8 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index a669cfec9f34d..c477433086098 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -19,8 +19,7 @@ #![allow(deprecated)] use frame_support::{ - derive_impl, - assert_noop, assert_ok, assert_storage_noop, + assert_noop, assert_ok, assert_storage_noop, derive_impl, dispatch::DispatchResult, storage::{with_transaction, TransactionOutcome::*}, transactional, @@ -37,9 +36,9 @@ pub use self::pallet::*; #[frame_support::pallet] pub mod pallet { - use frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; #[pallet::pallet] #[pallet::generate_store(pub (super) trait Store)] From fe4e9cc1b373b15397329103ed7f076f7f010c8d Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 12:20:33 +0530 Subject: [PATCH 26/67] Minor updates --- frame/benchmarking/pov/src/benchmarking.rs | 1 - frame/benchmarking/src/baseline.rs | 1 - frame/offences/benchmarking/src/mock.rs | 6 ++++-- frame/session/benchmarking/src/lib.rs | 2 +- frame/session/benchmarking/src/mock.rs | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index bace7cf542e2d..7460f8aaaa46d 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -343,7 +343,6 @@ mod mock { type AccountId = u64; type AccountIndex = u32; - type BlockNumber = u64; type Block = frame_system::mocking::MockBlock; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index babaebc244b1f..347ca5b3d1325 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -115,7 +115,6 @@ pub mod mock { type AccountId = u64; type AccountIndex = u32; - type BlockNumber = u64; type Block = frame_system::mocking::MockBlock; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 969c828405a27..c875f2ff0011e 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -27,11 +27,13 @@ use frame_support::{ }; use frame_system as system; use pallet_session::historical as pallet_session_historical; -use sp_runtime::{testing::UintAuthorityId, traits::IdentityLookup}; +use sp_runtime::{ + testing::{Header, UintAuthorityId}, + traits::IdentityLookup, +}; type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; type Balance = u64; impl frame_system::Config for Test { diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index b0840ef83e52d..f27136e820d41 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -31,7 +31,7 @@ use frame_support::{ codec::Decode, traits::{Get, KeyOwnerProofSystem, OnInitialize}, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_session::{historical::Pallet as Historical, Pallet as Session, *}; use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 578704fc702b6..0c8af5fd1251e 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -28,7 +28,6 @@ use sp_runtime::traits::IdentityLookup; type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; type Balance = u64; type Block = frame_system::mocking::MockBlock; From 85d992e3fed434c066b31eb541ceef8e375a21ee Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 13:42:40 +0530 Subject: [PATCH 27/67] Fixes construct_runtime ui tests --- frame/state-trie-migration/src/lib.rs | 5 +- .../both_use_and_excluded_parts.stderr | 4 +- .../conflicting_module_name.stderr | 16 ++-- .../double_module_parts.stderr | 8 +- .../empty_pallet_path.stderr | 4 +- .../exclude_undefined_part.stderr | 4 +- .../feature_gated_system_pallet.stderr | 8 +- .../generics_in_invalid_module.stderr | 8 +- .../invalid_meta_literal.stderr | 8 +- .../invalid_module_details.stderr | 4 +- .../invalid_module_details_keyword.stderr | 4 +- .../invalid_module_entry.stderr | 8 +- .../invalid_token_after_module.stderr | 4 +- .../invalid_token_after_name.stderr | 4 +- ...ent_generic_on_module_with_instance.stderr | 8 +- .../missing_module_instance.stderr | 4 +- ...gin_generic_on_module_with_instance.stderr | 8 +- .../missing_system_module.stderr | 6 +- .../missing_where_block.stderr | 4 +- ...umber_of_pallets_exceeds_tuple_size.stderr | 20 ++-- .../pallet_error_too_large.stderr | 18 ++-- .../undefined_call_part.stderr | 14 +-- .../undefined_event_part.stderr | 34 +++---- .../undefined_genesis_config_part.stderr | 34 +++---- .../undefined_inherent_part.stderr | 94 +++++++++---------- .../undefined_origin_part.stderr | 34 +++---- .../undefined_validate_unsigned_part.stderr | 64 ++++++------- .../unsupported_meta_structure.stderr | 8 +- .../unsupported_pallet_attr.stderr | 8 +- .../use_undefined_part.stderr | 4 +- 30 files changed, 225 insertions(+), 226 deletions(-) diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 8864f9125a4d0..d71c25473419f 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1615,6 +1615,7 @@ pub(crate) mod remote_tests { weights::Weight, }; use frame_system::Pallet as System; + use frame_system::pallet_prelude::BlockNumberFor; use remote_externalities::Mode; use sp_core::H256; use sp_runtime::{ @@ -1625,7 +1626,7 @@ pub(crate) mod remote_tests { #[allow(dead_code)] fn run_to_block>( - n: ::BlockNumber, + n: BlockNumberFor, ) -> (H256, Weight) { let mut root = Default::default(); let mut weight_sum = Weight::zero(); @@ -1665,7 +1666,7 @@ pub(crate) mod remote_tests { frame_system::Pallet::::block_number() }); - let mut duration: ::BlockNumber = Zero::zero(); + let mut duration: BlockNumberFor = Zero::zero(); // set the version to 1, as if the upgrade happened. ext.state_version = sp_core::storage::StateVersion::V1; diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr index b1c1879aa56ad..1ea62b7d6fd65 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr @@ -1,7 +1,7 @@ error: Unexpected tokens, expected one of `=`, `,` - --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:29:43 + --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:26:43 | -29 | Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, +26 | Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, | ^^^^^^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr index 27c5644e0d736..6fb983f03a961 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr @@ -1,11 +1,11 @@ error: Two pallets with the same name! - --> $DIR/conflicting_module_name.rs:10:3 - | -10 | Balance: balances::{Pallet}, - | ^^^^^^^ + --> tests/construct_runtime_ui/conflicting_module_name.rs:7:3 + | +7 | Balance: balances::{Pallet}, + | ^^^^^^^ error: Two pallets with the same name! - --> $DIR/conflicting_module_name.rs:11:3 - | -11 | Balance: balances::{Pallet}, - | ^^^^^^^ + --> tests/construct_runtime_ui/conflicting_module_name.rs:8:3 + | +8 | Balance: balances::{Pallet}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr index 9d10474ce85ab..e3f694781441f 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr @@ -1,5 +1,5 @@ error: `Config` was already declared before. Please remove the duplicate declaration - --> $DIR/double_module_parts.rs:10:37 - | -10 | Balance: balances::{Config, Call, Config, Origin}, - | ^^^^^^ + --> tests/construct_runtime_ui/double_module_parts.rs:7:37 + | +7 | Balance: balances::{Config, Call, Config, Origin}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr index 7102076e5acb0..f0c0f17779d67 100644 --- a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr +++ b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr @@ -1,5 +1,5 @@ error: expected one of: `crate`, `self`, `super`, identifier - --> $DIR/empty_pallet_path.rs:9:11 + --> tests/construct_runtime_ui/empty_pallet_path.rs:6:11 | -9 | system: , +6 | system: , | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr index 66098898bb877..4b85613838ab5 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr @@ -1,7 +1,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> tests/construct_runtime_ui/exclude_undefined_part.rs:34:34 + --> tests/construct_runtime_ui/exclude_undefined_part.rs:31:34 | -34 | Pallet: pallet exclude_parts { Call }, +31 | Pallet: pallet exclude_parts { Call }, | ^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr index a86a839615aa0..28c95dbe37a36 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr @@ -1,5 +1,5 @@ error: `System` pallet declaration is feature gated, please remove any `#[cfg]` attributes - --> tests/construct_runtime_ui/feature_gated_system_pallet.rs:10:3 - | -10 | System: frame_system::{Pallet, Call, Storage, Config, Event}, - | ^^^^^^ + --> tests/construct_runtime_ui/feature_gated_system_pallet.rs:7:3 + | +7 | System: frame_system::{Pallet, Call, Storage, Config, Event}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr index 06caa036b91ff..22f38072747ee 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr @@ -1,5 +1,5 @@ error: `Call` is not allowed to have generics. Only the following pallets are allowed to have generics: `Event`, `Origin`, `Config`. - --> $DIR/generics_in_invalid_module.rs:10:36 - | -10 | Balance: balances::::{Call, Origin}, - | ^^^^ + --> tests/construct_runtime_ui/generics_in_invalid_module.rs:7:36 + | +7 | Balance: balances::::{Call, Origin}, + | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr index 68366a3410bf1..bfee2910cd2a4 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr @@ -1,6 +1,6 @@ error: feature = 1 ^ expected one of ``, `all`, `any`, `not` here - --> tests/construct_runtime_ui/invalid_meta_literal.rs:10:3 - | -10 | #[cfg(feature = 1)] - | ^ + --> tests/construct_runtime_ui/invalid_meta_literal.rs:7:3 + | +7 | #[cfg(feature = 1)] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr index 0a20cf4e39a88..1f9277c3f0a8e 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr @@ -1,5 +1,5 @@ error: Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,` - --> tests/construct_runtime_ui/invalid_module_details.rs:9:17 + --> tests/construct_runtime_ui/invalid_module_details.rs:6:17 | -9 | system: System::(), +6 | system: System::(), | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr index 42f79e96d4473..d4e7b97f00b4d 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr @@ -1,5 +1,5 @@ error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason` - --> $DIR/invalid_module_details_keyword.rs:9:20 + --> tests/construct_runtime_ui/invalid_module_details_keyword.rs:6:20 | -9 | system: System::{enum}, +6 | system: System::{enum}, | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr index 6d535ca4335fc..f17f04ae60aba 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr @@ -1,5 +1,5 @@ error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason` - --> $DIR/invalid_module_entry.rs:10:23 - | -10 | Balance: balances::{Error}, - | ^^^^^ + --> tests/construct_runtime_ui/invalid_module_entry.rs:7:23 + | +7 | Balance: balances::{Error}, + | ^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr index 6025de82bd206..80be1b8dd42fd 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr @@ -1,5 +1,5 @@ error: Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,` - --> $DIR/invalid_token_after_module.rs:9:18 + --> tests/construct_runtime_ui/invalid_token_after_module.rs:6:18 | -9 | system: System ? +6 | system: System ? | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr index eaae082c8460c..8988f8a35b0a4 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr @@ -1,5 +1,5 @@ error: expected `:` - --> $DIR/invalid_token_after_name.rs:9:10 + --> tests/construct_runtime_ui/invalid_token_after_name.rs:6:10 | -9 | system ? +6 | system ? | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr index b1aa9b86cd0d6..b3d9f3ac0f85f 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr @@ -1,5 +1,5 @@ error: Instantiable pallet with no generic `Event` cannot be constructed: pallet `Balance` must have generic `Event` - --> $DIR/missing_event_generic_on_module_with_instance.rs:10:3 - | -10 | Balance: balances::::{Event}, - | ^^^^^^^ + --> tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs:7:3 + | +7 | Balance: balances::::{Event}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr index 6303c74e42e5c..5072f718db12e 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr @@ -1,5 +1,5 @@ error: expected identifier - --> $DIR/missing_module_instance.rs:9:20 + --> tests/construct_runtime_ui/missing_module_instance.rs:6:20 | -9 | system: System::<>, +6 | system: System::<>, | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr index 63bb7442a8576..7300346191c0c 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr @@ -1,5 +1,5 @@ error: Instantiable pallet with no generic `Origin` cannot be constructed: pallet `Balance` must have generic `Origin` - --> $DIR/missing_origin_generic_on_module_with_instance.rs:10:3 - | -10 | Balance: balances::::{Origin}, - | ^^^^^^^ + --> tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs:7:3 + | +7 | Balance: balances::::{Origin}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index 7648f5c1bfb33..778cfe4b2196a 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,6 +1,6 @@ error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` - --> $DIR/missing_system_module.rs:8:2 + --> tests/construct_runtime_ui/missing_system_module.rs:5:2 | -8 | / { -9 | | } +5 | / { +6 | | } | |_____^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr index d2a66f95101f4..67e27f4742f1c 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr @@ -1,5 +1,5 @@ -error: expected `where` +error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` --> tests/construct_runtime_ui/missing_where_block.rs:4:21 | 4 | pub struct Runtime {} - | ^ + | ^^ 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 19a9a7bd08e32..38d5ff2a37f55 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 @@ -1,7 +1,7 @@ error: The number of pallets exceeds the maximum number of tuple elements. To increase this limit, enable the tuples-96 feature of [frame_support]. - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:50:2 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:49:2 | -50 | pub struct Runtime where +49 | pub struct Runtime | ^^^ error[E0412]: cannot find type `RuntimeCall` in this scope @@ -34,28 +34,28 @@ error[E0412]: cannot find type `RuntimeOrigin` in this scope | ^^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeOrigin` error[E0412]: cannot find type `RuntimeCall` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:27:21 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:26:21 | -27 | type RuntimeCall = RuntimeCall; +26 | type RuntimeCall = RuntimeCall; | ^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeCall` error[E0412]: cannot find type `RuntimeEvent` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:33:22 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:32:22 | -33 | type RuntimeEvent = RuntimeEvent; +32 | type RuntimeEvent = RuntimeEvent; | ^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeEvent` error[E0412]: cannot find type `PalletInfo` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:39:20 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:38:20 | -39 | type PalletInfo = PalletInfo; +38 | type PalletInfo = PalletInfo; | ^^^^^^^^^^ | help: you might have meant to use the associated type | -39 | type PalletInfo = Self::PalletInfo; +38 | type PalletInfo = Self::PalletInfo; | ~~~~~~~~~~~~~~~~ help: consider importing this trait | -1 + use frame_support::traits::PalletInfo; +1 | use frame_support::traits::PalletInfo; | diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr index b9cec02a2b092..656fc0141161e 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> tests/construct_runtime_ui/pallet_error_too_large.rs:74:1 + --> tests/construct_runtime_ui/pallet_error_too_large.rs:73:1 | -74 | / construct_runtime! { -75 | | pub struct Runtime where -76 | | Block = Block, -77 | | NodeBlock = Block, -... | -82 | | } -83 | | } - | |_^ the evaluated program panicked at 'The maximum encoded size of the error type in the `Pallet` pallet exceeds `MAX_MODULE_ERROR_ENCODED_SIZE`', $DIR/tests/construct_runtime_ui/pallet_error_too_large.rs:74:1 +73 | / construct_runtime! { +74 | | pub struct Runtime +75 | | { +76 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +77 | | Pallet: pallet::{Pallet}, +78 | | } +79 | | } + | |_^ the evaluated program panicked at 'The maximum encoded size of the error type in the `Pallet` pallet exceeds `MAX_MODULE_ERROR_ENCODED_SIZE`', $DIR/tests/construct_runtime_ui/pallet_error_too_large.rs:73:1 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr index c2092edea05b5..03a9ea928e9bd 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr @@ -4,13 +4,13 @@ error: `Pallet` does not have #[pallet::call] defined, perhaps you should remove 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Call}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_call_check::is_call_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index eb667fe04a39e..b8d08e2208d54 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -4,33 +4,33 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Event}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_event_check::is_event_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Event` in module `pallet` - --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_event_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Event}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 + use frame_support_test::Event; +1 | use frame_support_test::Event; | -1 + use frame_system::Event; +1 | use frame_system::Event; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index cdab7d3afa18c..fa3ea443474c8 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -4,33 +4,33 @@ error: `Pallet` does not have #[pallet::genesis_config] defined, perhaps you sho 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Config}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_genesis_config_check::is_genesis_config_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `GenesisConfig` in module `pallet` - --> tests/construct_runtime_ui/undefined_genesis_config_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_genesis_config_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Config}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 + use frame_system::GenesisConfig; +1 | use frame_system::GenesisConfig; | -1 + use test_pallet::GenesisConfig; +1 | use test_pallet::GenesisConfig; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr index a068cab4cb1ab..bce1c4d9efb87 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr @@ -4,31 +4,31 @@ error: `Pallet` does not have #[pallet::inherent] defined, perhaps you should re 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_inherent_check::is_inherent_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `create_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `create_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -37,19 +37,19 @@ error[E0599]: no function or associated item named `create_inherent` found for s = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `is_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `is_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -58,19 +58,19 @@ error[E0599]: no function or associated item named `is_inherent` found for struc = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `check_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `check_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -79,19 +79,19 @@ error[E0599]: no function or associated item named `check_inherent` found for st = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- associated item `INHERENT_IDENTIFIER` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -100,19 +100,19 @@ error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `p = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `is_inherent_required` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `is_inherent_required` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr index 0677340e25c12..abd4a77e3232c 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr @@ -4,33 +4,33 @@ error: `Pallet` does not have #[pallet::origin] defined, perhaps you should remo 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Origin}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_origin_check::is_origin_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Origin` in module `pallet` - --> tests/construct_runtime_ui/undefined_origin_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_origin_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Origin}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 + use frame_support_test::Origin; +1 | use frame_support_test::Origin; | -1 + use frame_system::Origin; +1 | use frame_system::Origin; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index 84f1e54d5c24e..a7ce8615093f9 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -4,48 +4,46 @@ error: `Pallet` does not have #[pallet::validate_unsigned] defined, perhaps you 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_validate_unsigned_check::is_validate_unsigned_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no variant or associated item named `Pallet` found for enum `RuntimeCall` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:56:3 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:52:3 | -49 | // construct_runtime! { -50 | || pub struct Runtime where -51 | || Block = Block, -52 | || NodeBlock = Block, -... || -55 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 | || Pallet: pallet::{Pallet, ValidateUnsigned}, +48 | // construct_runtime! { +49 | || pub struct Runtime +50 | || { +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, | || -^^^^^^ variant or associated item not found in `RuntimeCall` | ||________| | | -57 | | } -58 | | } +53 | | } +54 | | } | |__- variant or associated item `Pallet` not found for this enum error[E0599]: no function or associated item named `pre_dispatch` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `pre_dispatch` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -55,19 +53,19 @@ error[E0599]: no function or associated item named `pre_dispatch` found for stru = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `validate_unsigned` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `validate_unsigned` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr index 98d99a0d34997..34637269db617 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr @@ -1,6 +1,6 @@ error: feature(test) ^ expected one of `=`, `,`, `)` here - --> tests/construct_runtime_ui/unsupported_meta_structure.rs:10:3 - | -10 | #[cfg(feature(test))] - | ^ + --> tests/construct_runtime_ui/unsupported_meta_structure.rs:7:3 + | +7 | #[cfg(feature(test))] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr index fceb2b8a99db8..da1b61b1c3078 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr @@ -1,5 +1,5 @@ error: Unsupported attribute, only #[cfg] is supported on pallet declarations in `construct_runtime` - --> tests/construct_runtime_ui/unsupported_pallet_attr.rs:10:3 - | -10 | #[attr] - | ^ + --> tests/construct_runtime_ui/unsupported_pallet_attr.rs:7:3 + | +7 | #[attr] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr index cb6b6a44d61da..4058ccab2c5d7 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr @@ -1,7 +1,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> tests/construct_runtime_ui/use_undefined_part.rs:34:30 + --> tests/construct_runtime_ui/use_undefined_part.rs:31:30 | -34 | Pallet: pallet use_parts { Call }, +31 | Pallet: pallet use_parts { Call }, | ^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope From bae23069fc2dbb4384be39223458381275ceecb6 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 14:44:14 +0530 Subject: [PATCH 28/67] Fixes construct_runtime ui tests with 1.70 --- frame/state-trie-migration/src/lib.rs | 3 +-- .../number_of_pallets_exceeds_tuple_size.stderr | 2 +- .../tests/construct_runtime_ui/undefined_event_part.stderr | 4 ++-- .../construct_runtime_ui/undefined_genesis_config_part.stderr | 4 ++-- .../tests/construct_runtime_ui/undefined_origin_part.stderr | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index d71c25473419f..dfe7d2afb03c4 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1614,8 +1614,7 @@ pub(crate) mod remote_tests { traits::{Get, Hooks}, weights::Weight, }; - use frame_system::Pallet as System; - use frame_system::pallet_prelude::BlockNumberFor; + use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System}; use remote_externalities::Mode; use sp_core::H256; use sp_runtime::{ 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 38d5ff2a37f55..55cef6704ee3f 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 @@ -57,5 +57,5 @@ help: you might have meant to use the associated type | ~~~~~~~~~~~~~~~~ help: consider importing this trait | -1 | use frame_support::traits::PalletInfo; +1 + use frame_support::traits::PalletInfo; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index b8d08e2208d54..c9c0962d13f46 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -30,7 +30,7 @@ error[E0412]: cannot find type `Event` in module `pallet` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 | use frame_support_test::Event; +1 + use frame_support_test::Event; | -1 | use frame_system::Event; +1 + use frame_system::Event; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index fa3ea443474c8..d5db097ccd3d0 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -30,7 +30,7 @@ error[E0412]: cannot find type `GenesisConfig` in module `pallet` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 | use frame_system::GenesisConfig; +1 + use frame_system::GenesisConfig; | -1 | use test_pallet::GenesisConfig; +1 + use test_pallet::GenesisConfig; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr index abd4a77e3232c..90bf0b52cd296 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr @@ -30,7 +30,7 @@ error[E0412]: cannot find type `Origin` in module `pallet` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing one of these items | -1 | use frame_support_test::Origin; +1 + use frame_support_test::Origin; | -1 | use frame_system::Origin; +1 + use frame_system::Origin; | From 27b47ba4eda85c6642744fd09c53d13d048ee4fe Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 15:22:35 +0530 Subject: [PATCH 29/67] Fixes docs --- frame/support/src/dispatch.rs | 253 ---------------------------------- frame/support/src/error.rs | 45 ------ 2 files changed, 298 deletions(-) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index a0a36775e5c79..7dfac19c9407d 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -645,259 +645,6 @@ impl PaysFee for (u64, Pays) { // END TODO /// Declares a `Module` struct and a `Call` enum, which implements the dispatch logic. -/// -/// ## Declaration -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// -/// // Private functions are dispatchable, but not available to other -/// // FRAME pallets. -/// #[weight = 0] -/// fn my_function(origin, var: u64) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// -/// // Public functions are both dispatchable and available to other -/// // FRAME pallets. -/// #[weight = 0] -/// pub fn my_public_function(origin) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// The declaration is set with the header where: -/// -/// * `Module`: The struct generated by the macro, with type `Config`. -/// * `Call`: The enum generated for every pallet, which implements -/// [`Callable`](./dispatch/trait.Callable.html). -/// * `origin`: Alias of `T::RuntimeOrigin`. -/// * `Result`: The expected return type from pallet functions. -/// -/// The first parameter of dispatchable functions must always be `origin`. -/// -/// ### Shorthand Example -/// -/// The macro automatically expands a shorthand function declaration to return the -/// [`DispatchResult`] type. These functions are the same: -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// fn my_long_function(origin) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// -/// #[weight = 0] -/// fn my_short_function(origin) { -/// // Your implementation -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Consuming only portions of the annotated static weight -/// -/// Per default a callable function consumes all of its static weight as declared via -/// the #\[weight\] attribute. However, there are use cases where only a portion of this -/// weight should be consumed. In that case the static weight is charged pre dispatch and -/// the difference is refunded post dispatch. -/// -/// In order to make use of this feature the function must return `DispatchResultWithPostInfo` -/// in place of the default `DispatchResult`. Then the actually consumed weight can be returned. -/// To consume a non default weight while returning an error -/// [`WithPostDispatchInfo::with_weight`](./weight/trait.WithPostDispatchInfo.html) can be used -/// to augment any error with custom weight information. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::{weights::Weight, dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo, PostDispatchInfo}}; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 1_000_000] -/// fn my_long_function(origin, do_expensive_calc: bool) -> DispatchResultWithPostInfo { -/// ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_parts(100_000, 0)))?; -/// if do_expensive_calc { -/// // do the expensive calculation -/// // ... -/// // return None to indicate that we are using all weight (the default) -/// return Ok(None::.into()); -/// } -/// // expensive calculation not executed: use only a portion of the weight -/// Ok(PostDispatchInfo { actual_weight: Some(Weight::from_parts(100_000, 0)), ..Default::default() }) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Transactional Function Example -/// -/// Transactional function discards all changes to storage if it returns `Err`, or commits if -/// `Ok`, via the #\[transactional\] attribute. Note the attribute must be after #\[weight\]. -/// The #\[transactional\] attribute is deprecated since it is the default behaviour. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::transactional; -/// # use frame_system::Config; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// #[transactional] -/// fn my_short_function(origin) { -/// // Your implementation -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Privileged Function Example -/// -/// A privileged function checks that the origin of the call is `ROOT`. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed, ensure_root}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// fn my_privileged_function(origin) -> dispatch::DispatchResult { -/// ensure_root(origin)?; -/// // Your implementation -/// Ok(()) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Attributes on Functions -/// -/// Attributes on functions are supported, but must be in the order of: -/// 1. Optional #\[doc\] attribute. -/// 2. #\[weight\] attribute. -/// 3. Optional function attributes, for instance #\[transactional\]. Those function attributes will -/// be written only on the dispatchable functions implemented on `Module`, not on the `Call` enum -/// variant. -/// -/// ## Multiple Module Instances Example -/// -/// A Substrate module can be built such that multiple instances of the same module can be used -/// within a single runtime. For example, the [Balances module](../pallet_balances/index.html) can -/// be added multiple times to your runtime in order to support multiple, independent currencies for -/// your blockchain. Here is an example of how you would declare such a module using the -/// `decl_module!` macro: -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::ensure_signed; -/// # pub struct DefaultInstance; -/// # pub trait Instance: 'static {} -/// # impl Instance for DefaultInstance {} -/// pub trait Config: frame_system::Config {} -/// -/// decl_module! { -/// pub struct Module, I: Instance = DefaultInstance> for enum Call where origin: T::RuntimeOrigin { -/// // Your implementation -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// Note: `decl_storage` must be called to generate `Instance` trait and optionally -/// `DefaultInstance` type. -/// -/// ## Where clause -/// -/// Besides the default `origin: T::RuntimeOrigin`, you can also pass other bounds to the module -/// declaration. This where bound will be replicated to all types generated by this macro. The -/// chaining of multiple trait bounds with `+` is not supported. If multiple bounds for one type are -/// required, it needs to be split up into multiple bounds. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{self as system, ensure_signed}; -/// pub trait Config: system::Config where Self::AccountId: From {} -/// -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin, T::AccountId: From { -/// // Your implementation -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ## Reserved Functions -/// -/// The following are reserved function signatures: -/// -/// * `deposit_event`: Helper function for depositing an [event](https://docs.substrate.io/main-docs/build/events-errors/). -/// The default behavior is to call `deposit_event` from the [System -/// module](../frame_system/index.html). However, you can write your own implementation for events -/// in your runtime. To use the default behavior, add `fn deposit_event() = default;` to your -/// `Module`. -/// -/// The following reserved functions also take the block number (with type -/// `frame_system::pallet_prelude::BlockNumberFor::`) as an optional input: -/// -/// * `on_runtime_upgrade`: Executes at the beginning of a block prior to on_initialize when there -/// is a runtime upgrade. This allows each module to upgrade its storage before the storage items -/// are used. As such, **calling other modules must be avoided**!! Using this function will -/// implement the [`OnRuntimeUpgrade`](../sp_runtime/traits/trait.OnRuntimeUpgrade.html) trait. -/// Function signature must be `fn on_runtime_upgrade() -> frame_support::weights::Weight`. -/// -/// * `on_initialize`: Executes at the beginning of a block. Using this function will -/// implement the [`OnInitialize`](./trait.OnInitialize.html) trait. -/// Function signature can be either: -/// * `fn on_initialize(n: BlockNumber) -> frame_support::weights::Weight` or -/// * `fn on_initialize() -> frame_support::weights::Weight` -/// -/// * `on_idle`: Executes at the end of a block. Passes a remaining weight to provide a threshold -/// for when to execute non vital functions. Using this function will implement the -/// [`OnIdle`](./traits/trait.OnIdle.html) trait. -/// Function signature is: -/// * `fn on_idle(n: BlockNumber, remaining_weight: Weight) -> frame_support::weights::Weight` -/// -/// * `on_finalize`: Executes at the end of a block. Using this function will -/// implement the [`OnFinalize`](./traits/trait.OnFinalize.html) trait. -/// Function signature can be either: -/// * `fn on_finalize(n: BlockNumber) -> frame_support::weights::Weight` or -/// * `fn on_finalize() -> frame_support::weights::Weight` -/// -/// * `offchain_worker`: Executes at the beginning of a block and produces extrinsics for a future -/// block upon completion. Using this function will implement the -/// [`OffchainWorker`](./traits/trait.OffchainWorker.html) trait. -/// * `integrity_test`: Executes in a test generated by `construct_runtime`, note it doesn't execute -/// in an externalities-provided environment. Implement -/// [`IntegrityTest`](./trait.IntegrityTest.html) trait. #[macro_export] #[deprecated(note = "Will be removed after July 2023; use the attribute `#[pallet]` macro instead. For more info, see: ")] diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 14dc16d4dd5c2..5a7dd73f481ec 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -21,51 +21,6 @@ pub use sp_runtime::traits::{BadOrigin, LookupError}; /// Declare an error type for a runtime module. -/// -/// `decl_error!` supports only variants that do not hold any data. The dispatchable -/// functions return [`DispatchResult`](sp_runtime::DispatchResult). The error type -/// implements `From for DispatchResult` to make the error type usable as error -/// in the dispatchable functions. -/// -/// It is required that the error type is registered in `decl_module!` to make the error -/// exported in the metadata. -/// -/// # Usage -/// -/// ``` -/// # use frame_support::{decl_error, decl_module}; -/// # -/// decl_error! { -/// /// Errors that can occur in my module. -/// pub enum MyError for Module { -/// /// Hey this is an error message that indicates bla. -/// MyCoolErrorMessage, -/// /// You are just not cool enough for my module! -/// YouAreNotCoolEnough, -/// } -/// } -/// -/// # use frame_system::Config; -/// -/// // You need to register the error type in `decl_module!` as well to make the error -/// // exported in the metadata. -/// -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// type Error = MyError; -/// -/// #[weight = 0] -/// fn do_something(origin) -> frame_support::dispatch::DispatchResult { -/// Err(MyError::::YouAreNotCoolEnough.into()) -/// } -/// } -/// } -/// -/// # fn main() {} -/// ``` -/// -/// For instantiable modules you also need to give the instance generic type and bound to the -/// error declaration. #[macro_export] #[deprecated(note = "Will be removed after July 2023; use the attribute `#[pallet]` macro instead. For more info, see: ")] From 09fe084cc3830cdaecf328d46b1bde0d8a0424ee Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:54:11 +0530 Subject: [PATCH 30/67] Fixes docs --- utils/frame/rpc/support/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 33627aca3a3e1..c816bb739a388 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -40,10 +40,7 @@ use sp_storage::{StorageData, StorageKey}; /// # use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header}; /// # /// # construct_runtime!( -/// # pub enum TestRuntime where -/// # Block = frame_system::mocking::MockBlock, -/// # NodeBlock = frame_system::mocking::MockBlock, -/// # UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic, +/// # pub enum TestRuntime /// # { /// # System: frame_system::{Pallet, Call, Config, Storage, Event}, /// # Test: pallet_test::{Pallet, Storage}, @@ -63,7 +60,7 @@ use sp_storage::{StorageData, StorageKey}; /// # type Hashing = BlakeTwo256; /// # type AccountId = u64; /// # type Lookup = IdentityLookup; -/// # type Block = Block; +/// # type Block = frame_system::mocking::MockBlock; /// # type RuntimeEvent = RuntimeEvent; /// # type BlockHashCount = (); /// # type DbWeight = (); From 827f7e0fb42f5bd71dd03ef3af1795bf9a79186f Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 28 Jun 2023 10:44:00 +0530 Subject: [PATCH 31/67] Adds u128 mock block type --- frame/system/src/mocking.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index 9ebda4a42b448..833309e05ecc9 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -38,3 +38,10 @@ pub type MockBlockU32 = generic::Block< generic::Header, MockUncheckedExtrinsic, >; + +/// An implementation of `sp_runtime::traits::Block` to be used in tests with u128 BlockNumber +/// type. +pub type MockBlockU128 = generic::Block< + generic::Header, + MockUncheckedExtrinsic, +>; From ded2d971069890f125cd461a84cce8fe2a341eb9 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 28 Jun 2023 10:56:27 +0530 Subject: [PATCH 32/67] Fixes split example --- frame/examples/split/src/mock.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frame/examples/split/src/mock.rs b/frame/examples/split/src/mock.rs index e479e821f4262..32fd43f998eca 100644 --- a/frame/examples/split/src/mock.rs +++ b/frame/examples/split/src/mock.rs @@ -17,16 +17,13 @@ use crate as pallet_template; use frame_support::derive_impl; +use sp_core::ConstU64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, TemplatePallet: pallet_template, @@ -37,6 +34,8 @@ frame_support::construct_runtime!( /// details. #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { + type Block = Block; + type BlockHashCount = ConstU64<10>; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; From 2715d40f9a0b0f566eadd54390cc5a633870b820 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 28 Jun 2023 12:34:56 +0530 Subject: [PATCH 33/67] fixes for cumulus --- primitives/arithmetic/src/traits.rs | 2 +- primitives/runtime/src/generic/block.rs | 4 ++-- primitives/runtime/src/generic/header.rs | 5 +++-- primitives/runtime/src/traits.rs | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index 061b11b3e9c72..575a93b748e08 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -25,7 +25,7 @@ pub use ensure::{ }; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ - checked_pow, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, + checked_pow, AsPrimitive, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, }; use sp_std::ops::{ diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 10bc2b8d87015..cc332722add32 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize}; use crate::{ codec::{Codec, Decode, Encode}, - traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor}, + traits::{self, Block as BlockT, Header as HeaderT, MaybeSerializeDeserialize, MaybeSerialize, Member, NumberFor}, Justifications, }; use sp_core::RuntimeDebug; @@ -95,7 +95,7 @@ where impl traits::Block for Block where - Header: HeaderT, + Header: HeaderT + MaybeSerializeDeserialize, Extrinsic: Member + Codec + traits::Extrinsic, { type Extrinsic = Extrinsic; diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index 82ab9a61f96d8..7f434f593db1a 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -22,7 +22,7 @@ use crate::{ generic::Digest, scale_info::TypeInfo, traits::{ - self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeFromStr, + self, AsPrimitive, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeFromStr, MaybeSerializeDeserialize, Member, }, }; @@ -92,7 +92,8 @@ where + MaxEncodedLen + Into + TryFrom - + TypeInfo, + + TypeInfo + + AsPrimitive, Hash: HashT, { type Number = Number; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index f55a7f8bca174..0bc949d6a3e8f 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -32,7 +32,7 @@ use impl_trait_for_tuples::impl_for_tuples; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_application_crypto::AppCrypto; pub use sp_arithmetic::traits::{ - checked_pow, ensure_pow, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, + checked_pow, ensure_pow, AsPrimitive, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, @@ -1169,7 +1169,8 @@ pub trait Header: + Default + TypeInfo + MaxEncodedLen - + FullCodec; + + FullCodec + + AsPrimitive; /// Header hash type type Hash: HashOutput; /// Hashing algorithm @@ -1254,7 +1255,7 @@ pub trait Block: /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. - type Header: Header; + type Header: Header + MaybeSerializeDeserialize; /// Block hash type. type Hash: HashOutput; From 3226bcb4758c2c04f9683b09df7bdbabb65561c8 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 28 Jun 2023 07:17:35 +0000 Subject: [PATCH 34/67] ".git/.scripts/commands/fmt/fmt.sh" --- primitives/arithmetic/src/traits.rs | 4 ++-- primitives/runtime/src/generic/block.rs | 5 ++++- primitives/runtime/src/traits.rs | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index 575a93b748e08..28590c31cc03a 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -25,8 +25,8 @@ pub use ensure::{ }; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ - checked_pow, AsPrimitive, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, - CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, + checked_pow, AsPrimitive, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, + CheckedShl, CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, }; use sp_std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign, diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index cc332722add32..05146e880cb16 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -25,7 +25,10 @@ use serde::{Deserialize, Serialize}; use crate::{ codec::{Codec, Decode, Encode}, - traits::{self, Block as BlockT, Header as HeaderT, MaybeSerializeDeserialize, MaybeSerialize, Member, NumberFor}, + traits::{ + self, Block as BlockT, Header as HeaderT, MaybeSerialize, MaybeSerializeDeserialize, + Member, NumberFor, + }, Justifications, }; use sp_core::RuntimeDebug; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 0bc949d6a3e8f..2d51c7b737274 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -32,10 +32,10 @@ use impl_trait_for_tuples::impl_for_tuples; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_application_crypto::AppCrypto; pub use sp_arithmetic::traits::{ - checked_pow, ensure_pow, AsPrimitive, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, - CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, - EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, - EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, + checked_pow, ensure_pow, AsPrimitive, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, + CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, + EnsureDiv, EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, + EnsureMulAssign, EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, SaturatedConversion, Saturating, UniqueSaturatedFrom, UniqueSaturatedInto, Zero, }; use sp_core::{self, storage::StateVersion, Hasher, RuntimeDebug, TypeId}; From 2454cfa01ee3d88fc14cf3bfb5fe15f9d0ea5f4a Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:48:47 +0530 Subject: [PATCH 35/67] Updates new tests --- .../test/tests/pallet_outer_enums_explicit.rs | 28 ++++--------------- .../test/tests/pallet_outer_enums_implicit.rs | 28 ++++--------------- 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/frame/support/test/tests/pallet_outer_enums_explicit.rs b/frame/support/test/tests/pallet_outer_enums_explicit.rs index dc98ec43fd933..f29b5d9f3ce39 100644 --- a/frame/support/test/tests/pallet_outer_enums_explicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_explicit.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::traits::ConstU32; +use frame_support::{derive_impl, traits::ConstU32}; mod common; @@ -25,31 +25,16 @@ pub type Header = sp_runtime::generic::Header; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } impl common::outer_enums::pallet::Config for Runtime { @@ -72,10 +57,7 @@ impl common::outer_enums::pallet3::Config }, diff --git a/frame/support/test/tests/pallet_outer_enums_implicit.rs b/frame/support/test/tests/pallet_outer_enums_implicit.rs index 9a14538c35930..191f095f5d78d 100644 --- a/frame/support/test/tests/pallet_outer_enums_implicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_implicit.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::traits::ConstU32; +use frame_support::{derive_impl, traits::ConstU32}; mod common; @@ -25,31 +25,16 @@ pub type Header = sp_runtime::generic::Header; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } impl common::outer_enums::pallet::Config for Runtime { @@ -72,10 +57,7 @@ impl common::outer_enums::pallet3::Config Date: Tue, 4 Jul 2023 10:28:18 +0530 Subject: [PATCH 36/67] Fixes fully-qualified path in few places --- bin/node-template/runtime/src/lib.rs | 1 - frame/alliance/src/lib.rs | 2 +- frame/babe/src/lib.rs | 5 ++--- frame/bounties/src/lib.rs | 4 ++-- frame/collective/src/lib.rs | 2 +- frame/contracts/src/lib.rs | 2 +- frame/conviction-voting/src/lib.rs | 6 +++--- frame/democracy/src/lib.rs | 16 ++++++++-------- frame/election-provider-multi-phase/src/lib.rs | 12 ++++++------ frame/elections-phragmen/src/lib.rs | 4 ++-- frame/examples/offchain-worker/src/lib.rs | 4 ++-- frame/grandpa/src/lib.rs | 2 +- frame/im-online/src/lib.rs | 2 +- frame/lottery/src/lib.rs | 2 +- frame/nis/src/lib.rs | 6 +++--- frame/ranked-collective/src/lib.rs | 2 +- frame/referenda/src/lib.rs | 14 +++++++------- frame/salary/src/lib.rs | 4 ++-- frame/scored-pool/src/lib.rs | 2 +- frame/society/src/lib.rs | 10 +++++----- frame/staking/src/pallet/mod.rs | 8 ++++---- frame/tips/src/lib.rs | 2 +- frame/treasury/src/lib.rs | 2 +- frame/vesting/src/lib.rs | 2 +- 24 files changed, 57 insertions(+), 59 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index be0e60ba67b35..90de167e41ea7 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -169,7 +169,6 @@ impl frame_system::Config for Runtime { type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; - /// The index type for blocks. /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index ff33a1ef9b21c..fc6e9d55ee847 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -309,7 +309,7 @@ pub mod pallet { /// The number of blocks a member must wait between giving a retirement notice and retiring. /// Supposed to be greater than time required to `kick_member`. - type RetirementPeriod: Get>; + type RetirementPeriod: Get>; } #[pallet::error] diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index c3f86abbc5cd9..50620d0a64d5f 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -163,7 +163,7 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof>, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } @@ -812,8 +812,7 @@ impl Pallet { // how many slots were skipped between current and last block let lateness = current_slot.saturating_sub(CurrentSlot::::get() + 1); - let lateness = - frame_system::pallet_prelude::BlockNumberFor::::from(*lateness as u32); + let lateness = BlockNumberFor::::from(*lateness as u32); Lateness::::put(lateness); CurrentSlot::::put(current_slot); diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index ff8ea8289fb82..c64a35672c7f7 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -201,11 +201,11 @@ pub mod pallet { /// The delay period for which a bounty beneficiary need to wait before claim the payout. #[pallet::constant] - type BountyDepositPayoutDelay: Get>; + type BountyDepositPayoutDelay: Get>; /// Bounty duration in blocks. #[pallet::constant] - type BountyUpdatePeriod: Get>; + type BountyUpdatePeriod: Get>; /// The curator deposit is calculated as a percentage of the curator fee. /// diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index a113bf6294384..d8edd34fa64d9 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -201,7 +201,7 @@ pub mod pallet { + IsType<::RuntimeEvent>; /// The time-out for council motions. - type MotionDuration: Get>; + type MotionDuration: Get>; /// Maximum number of proposals allowed to be active in parallel. type MaxProposals: Get; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index bd56d19aedc3c..93a11087dcee1 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -207,7 +207,7 @@ pub mod pallet { /// be instantiated from existing codes that use this deprecated functionality. It will /// be removed eventually. Hence for new `pallet-contracts` deployments it is okay /// to supply a dummy implementation for this type (because it is never used). - type Randomness: Randomness>; + type Randomness: Randomness>; /// The currency in which fees are paid and contract balances are held. type Currency: ReservableCurrency // TODO: Move to fungible traits diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index aea93c15e1621..20f2337784c23 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -103,14 +103,14 @@ pub mod pallet { type Currency: ReservableCurrency + LockableCurrency< Self::AccountId, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, > + fungible::Inspect; /// The implementation of the logic which conducts polls. type Polls: Polling< TallyOf, Votes = BalanceOf, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, >; /// The maximum amount of tokens which may be used for voting. May just be @@ -130,7 +130,7 @@ pub mod pallet { /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get>; + type VoteLockingPeriod: Get>; } /// All voting for a particular voter in a particular voting class. We store the balance for the diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 897b468a7a8cb..9b9ed14467ace 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -227,7 +227,7 @@ pub mod pallet { /// The Scheduler. type Scheduler: ScheduleNamed< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, CallOf, Self::PalletsOrigin, >; @@ -239,7 +239,7 @@ pub mod pallet { type Currency: ReservableCurrency + LockableCurrency< Self::AccountId, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, >; /// The period between a proposal being approved and enacted. @@ -248,22 +248,22 @@ pub mod pallet { /// voting stakers have an opportunity to remove themselves from the system in the case /// where they are on the losing side of a vote. #[pallet::constant] - type EnactmentPeriod: Get>; + type EnactmentPeriod: Get>; /// How often (in blocks) new public referenda are launched. #[pallet::constant] - type LaunchPeriod: Get>; + type LaunchPeriod: Get>; /// How often (in blocks) to check for new votes. #[pallet::constant] - type VotingPeriod: Get>; + type VotingPeriod: Get>; /// The minimum period of vote locking. /// /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get>; + type VoteLockingPeriod: Get>; /// The minimum amount to be used as a deposit for a public referendum proposal. #[pallet::constant] @@ -277,11 +277,11 @@ pub mod pallet { /// Minimum voting period allowed for a fast-track referendum. #[pallet::constant] - type FastTrackVotingPeriod: Get>; + type FastTrackVotingPeriod: Get>; /// Period in blocks where an external proposal may not be re-submitted after being vetoed. #[pallet::constant] - type CooloffPeriod: Get>; + type CooloffPeriod: Get>; /// The maximum number of votes for an account. /// diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index e1330c48e1ae2..03ab5574a2180 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -585,10 +585,10 @@ pub mod pallet { /// Duration of the unsigned phase. #[pallet::constant] - type UnsignedPhase: Get>; + type UnsignedPhase: Get>; /// Duration of the signed phase. #[pallet::constant] - type SignedPhase: Get>; + type SignedPhase: Get>; /// The minimum amount of improvement to the solution score that defines a solution as /// "better" in the Signed phase. @@ -605,7 +605,7 @@ pub mod pallet { /// For example, if it is 5, that means that at least 5 blocks will elapse between attempts /// to submit the worker's solution. #[pallet::constant] - type OffchainRepeat: Get>; + type OffchainRepeat: Get>; /// The priority of the unsigned transaction submitted in the unsigned-phase #[pallet::constant] @@ -685,13 +685,13 @@ pub mod pallet { /// Something that will provide the election data. type DataProvider: ElectionDataProvider< AccountId = Self::AccountId, - BlockNumber = frame_system::pallet_prelude::BlockNumberFor, + BlockNumber = BlockNumberFor, >; /// Configuration for the fallback. type Fallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = frame_system::pallet_prelude::BlockNumberFor, + BlockNumber = BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; @@ -702,7 +702,7 @@ pub mod pallet { /// BoundedExecution<_>` if the test-net is not expected to have thousands of nominators. type GovernanceFallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = frame_system::pallet_prelude::BlockNumberFor, + BlockNumber = BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 6d2e0423c93cc..4cd6db854f300 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -205,7 +205,7 @@ pub mod pallet { /// The currency that people are electing with. type Currency: LockableCurrency< Self::AccountId, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, > + ReservableCurrency; /// What to do when the members change. @@ -251,7 +251,7 @@ pub mod pallet { /// round will happen. If set to zero, no elections are ever triggered and the module will /// be in passive mode. #[pallet::constant] - type TermDuration: Get>; + type TermDuration: Get>; /// The maximum number of candidates in a phragmen election. /// diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index a151cee238b6d..6c1fa6ea8ec42 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -137,14 +137,14 @@ pub mod pallet { /// every `GRACE_PERIOD` blocks. We use Local Storage to coordinate /// sending between distinct runs of this offchain worker. #[pallet::constant] - type GracePeriod: Get>; + type GracePeriod: Get>; /// Number of blocks of cooldown after unsigned transaction is included. /// /// This ensures that we only accept unsigned transactions once, every `UnsignedInterval` /// blocks. #[pallet::constant] - type UnsignedInterval: Get>; + type UnsignedInterval: Get>; /// A configuration for base priority of unsigned transactions. /// diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 73aaf7d0866d9..2517eb353f57e 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -115,7 +115,7 @@ pub mod pallet { type EquivocationReportSystem: OffenceReportSystem< Option, ( - EquivocationProof>, + EquivocationProof>, Self::KeyOwnerProof, ), >; diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index de15f4b43e6a6..1ae9f695fe78a 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -288,7 +288,7 @@ pub mod pallet { /// avoids sending them at the very beginning of the session, assuming there is a /// chance the authority will produce a block and they won't be necessary. type NextSessionRotation: EstimateNextSessionRotation< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; /// A type that gives us the ability to submit unresponsiveness offence reports. diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 093064a43f96f..a6a94b4ab19af 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -142,7 +142,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness>; + type Randomness: Randomness>; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 5db71c65a74b2..1bf052a39d1ed 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -272,7 +272,7 @@ pub mod pallet { /// The base period for the duration queues. This is the common multiple across all /// supported freezing durations that can be bid upon. #[pallet::constant] - type BasePeriod: Get>; + type BasePeriod: Get>; /// The minimum amount of funds that may be placed in a bid. Note that this /// does not actually limit the amount which may be represented in a receipt since bids may @@ -293,7 +293,7 @@ pub mod pallet { /// A larger value results in fewer storage hits each block, but a slower period to get to /// the target. #[pallet::constant] - type IntakePeriod: Get>; + type IntakePeriod: Get>; /// The maximum amount of bids that can consolidated into receipts in a single intake. A /// larger value here means less of the block available for transactions should there be a @@ -303,7 +303,7 @@ pub mod pallet { /// The maximum proportion which may be thawed and the period over which it is reset. #[pallet::constant] - type ThawThrottle: Get<(Perquintill, frame_system::pallet_prelude::BlockNumberFor)>; + type ThawThrottle: Get<(Perquintill, BlockNumberFor)>; } #[pallet::pallet] diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 93886bffa2708..831cfa51aad1e 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -394,7 +394,7 @@ pub mod pallet { type Polls: Polling< TallyOf, Votes = Votes, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, >; /// Convert the tally class into the minimum rank required to vote on the poll. If diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index a1d63e1a447ff..64232dc49811a 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -163,11 +163,11 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The Scheduler. type Scheduler: ScheduleAnon< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, CallOf, PalletsOriginOf, > + ScheduleNamed< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, CallOf, PalletsOriginOf, >; @@ -209,13 +209,13 @@ pub mod pallet { /// The number of blocks after submission that a referendum must begin being decided by. /// Once this passes, then anyone may cancel the referendum. #[pallet::constant] - type UndecidingTimeout: Get>; + type UndecidingTimeout: Get>; /// Quantization level for the referendum wakeup scheduler. A higher number will result in /// fewer storage reads/writes needed for smaller voters, but also result in delays to the /// automatic referendum status changes. Explicit servicing instructions are unaffected. #[pallet::constant] - type AlarmInterval: Get>; + type AlarmInterval: Get>; // The other stuff. /// Information concerning the different referendum tracks. @@ -224,16 +224,16 @@ pub mod pallet { Vec<( , - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >>::Id, TrackInfo< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >, )>, > + TracksInfo< BalanceOf, - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, RuntimeOrigin = ::PalletsOrigin, >; diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index a45f1938aaddc..53dd7224909a8 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -126,14 +126,14 @@ pub mod pallet { /// The number of blocks between sequential payout cycles is the sum of this and /// `PayoutPeriod`. #[pallet::constant] - type RegistrationPeriod: Get>; + type RegistrationPeriod: Get>; /// The number of blocks within a cycle which accounts have to claim the payout. /// /// The number of blocks between sequential payout cycles is the sum of this and /// `RegistrationPeriod`. #[pallet::constant] - type PayoutPeriod: Get>; + type PayoutPeriod: Get>; /// The total budget per cycle. /// diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index adcd05fafe98f..c5cd8e64b7115 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -170,7 +170,7 @@ pub mod pallet { /// Every `Period` blocks the `Members` are filled with the highest scoring /// members in the `Pool`. #[pallet::constant] - type Period: Get>; + type Period: Get>; /// The receiver of the signal for when the membership has been initialized. /// This happens pre-genesis and will usually be the same as `MembershipChanged`. diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 8b3635bcb0373..790af3192fb77 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -486,7 +486,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness>; + type Randomness: Randomness>; /// The maximum number of strikes before a member gets funds slashed. #[pallet::constant] @@ -499,23 +499,23 @@ pub mod pallet { /// The number of blocks on which new candidates should be voted on. Together with /// `ClaimPeriod`, this sums to the number of blocks between candidate intake periods. #[pallet::constant] - type VotingPeriod: Get>; + type VotingPeriod: Get>; /// The number of blocks on which new candidates can claim their membership and be the /// named head. #[pallet::constant] - type ClaimPeriod: Get>; + type ClaimPeriod: Get>; /// The maximum duration of the payout lock. #[pallet::constant] - type MaxLockDuration: Get>; + type MaxLockDuration: Get>; /// The origin that is allowed to call `found`. type FounderSetOrigin: EnsureOrigin; /// The number of blocks between membership challenges. #[pallet::constant] - type ChallengePeriod: Get>; + type ChallengePeriod: Get>; /// The maximum number of payouts a member may have waiting unclaimed. #[pallet::constant] diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index c5b9acb93c188..305054c0aaebd 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -87,7 +87,7 @@ pub mod pallet { /// The staking balance. type Currency: LockableCurrency< Self::AccountId, - Moment = frame_system::pallet_prelude::BlockNumberFor, + Moment = BlockNumberFor, Balance = Self::CurrencyBalance, >; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to @@ -118,14 +118,14 @@ pub mod pallet { /// Something that provides the election functionality. type ElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = frame_system::pallet_prelude::BlockNumberFor, + BlockNumber = BlockNumberFor, // we only accept an election provider that has staking as data provider. DataProvider = Pallet, >; /// Something that provides the election functionality at genesis. type GenesisElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = frame_system::pallet_prelude::BlockNumberFor, + BlockNumber = BlockNumberFor, DataProvider = Pallet, >; @@ -201,7 +201,7 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. type NextNewSession: EstimateNextNewSession< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, >; /// The maximum number of nominators rewarded for each validator. diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 15a53c1de3e70..6e8f72e0540e6 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -144,7 +144,7 @@ pub mod pallet { /// The period for which a tip remains open after is has achieved threshold tippers. #[pallet::constant] - type TipCountdown: Get>; + type TipCountdown: Get>; /// The percent of the final tip which goes to the original reporter of the tip. #[pallet::constant] diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 22e41422c7fc2..08a0a2c8cf375 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -175,7 +175,7 @@ pub mod pallet { /// Period between successive spends. #[pallet::constant] - type SpendPeriod: Get>; + type SpendPeriod: Get>; /// Percentage of spare funds (if any) that are burnt per spend period. #[pallet::constant] diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 3ed1d2fb217ed..43e597b7813d3 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -164,7 +164,7 @@ pub mod pallet { /// Convert the block number into a balance. type BlockNumberToBalance: Convert< - frame_system::pallet_prelude::BlockNumberFor, + BlockNumberFor, BalanceOf, >; From 89e66debfa20eab9d65948293886bbdde28ca353 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 4 Jul 2023 10:28:59 +0530 Subject: [PATCH 37/67] Formatting --- frame/conviction-voting/src/lib.rs | 6 ++---- frame/democracy/src/lib.rs | 11 ++--------- frame/elections-phragmen/src/lib.rs | 6 ++---- frame/grandpa/src/lib.rs | 5 +---- frame/im-online/src/lib.rs | 4 +--- frame/ranked-collective/src/lib.rs | 6 +----- frame/referenda/src/lib.rs | 21 ++++----------------- frame/staking/src/pallet/mod.rs | 4 +--- frame/vesting/src/lib.rs | 5 +---- 9 files changed, 15 insertions(+), 53 deletions(-) diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 20f2337784c23..9c2993fc5cae1 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -101,10 +101,8 @@ pub mod pallet { type WeightInfo: WeightInfo; /// Currency type with which voting happens. type Currency: ReservableCurrency - + LockableCurrency< - Self::AccountId, - Moment = BlockNumberFor, - > + fungible::Inspect; + + LockableCurrency> + + fungible::Inspect; /// The implementation of the logic which conducts polls. type Polls: Polling< diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 9b9ed14467ace..543ad4750d93e 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -226,21 +226,14 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Scheduler. - type Scheduler: ScheduleNamed< - BlockNumberFor, - CallOf, - Self::PalletsOrigin, - >; + type Scheduler: ScheduleNamed, CallOf, Self::PalletsOrigin>; /// The Preimage provider. type Preimages: QueryPreimage + StorePreimage; /// Currency type for this pallet. type Currency: ReservableCurrency - + LockableCurrency< - Self::AccountId, - Moment = BlockNumberFor, - >; + + LockableCurrency>; /// The period between a proposal being approved and enacted. /// diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 4cd6db854f300..5a19fe0d64b0f 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -203,10 +203,8 @@ pub mod pallet { type PalletId: Get; /// The currency that people are electing with. - type Currency: LockableCurrency< - Self::AccountId, - Moment = BlockNumberFor, - > + ReservableCurrency; + type Currency: LockableCurrency> + + ReservableCurrency; /// What to do when the members change. type ChangeMembers: ChangeMembers; diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 2517eb353f57e..4a01d58bd58a1 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -114,10 +114,7 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - ( - EquivocationProof>, - Self::KeyOwnerProof, - ), + (EquivocationProof>, Self::KeyOwnerProof), >; } diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 7fa74bd050bc4..0c75ed5a8c09e 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -287,9 +287,7 @@ pub mod pallet { /// rough time when we should start considering sending heartbeats, since the workers /// avoids sending them at the very beginning of the session, assuming there is a /// chance the authority will produce a block and they won't be necessary. - type NextSessionRotation: EstimateNextSessionRotation< - BlockNumberFor, - >; + type NextSessionRotation: EstimateNextSessionRotation>; /// A type that gives us the ability to submit unresponsiveness offence reports. type ReportUnresponsiveness: ReportOffence< diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 831cfa51aad1e..fe1308cd034f4 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -391,11 +391,7 @@ pub mod pallet { type DemoteOrigin: EnsureOrigin; /// The polling system used for our voting. - type Polls: Polling< - TallyOf, - Votes = Votes, - Moment = BlockNumberFor, - >; + type Polls: Polling, Votes = Votes, Moment = BlockNumberFor>; /// Convert the tally class into the minimum rank required to vote on the poll. If /// `Polls::Class` is the same type as `Rank`, then `Identity` can be used here to mean diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 64232dc49811a..8ff754dc0db8e 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -162,15 +162,8 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// The Scheduler. - type Scheduler: ScheduleAnon< - BlockNumberFor, - CallOf, - PalletsOriginOf, - > + ScheduleNamed< - BlockNumberFor, - CallOf, - PalletsOriginOf, - >; + type Scheduler: ScheduleAnon, CallOf, PalletsOriginOf> + + ScheduleNamed, CallOf, PalletsOriginOf>; /// Currency type for this pallet. type Currency: ReservableCurrency; // Origins and unbalances. @@ -222,14 +215,8 @@ pub mod pallet { #[pallet::constant] type Tracks: Get< Vec<( - , - BlockNumberFor, - >>::Id, - TrackInfo< - BalanceOf, - BlockNumberFor, - >, + , BlockNumberFor>>::Id, + TrackInfo, BlockNumberFor>, )>, > + TracksInfo< BalanceOf, diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 305054c0aaebd..363e348cf00d3 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -200,9 +200,7 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. - type NextNewSession: EstimateNextNewSession< - BlockNumberFor, - >; + type NextNewSession: EstimateNextNewSession>; /// The maximum number of nominators rewarded for each validator. /// diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 43e597b7813d3..fe7b12743aaec 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -163,10 +163,7 @@ pub mod pallet { type Currency: LockableCurrency; /// Convert the block number into a balance. - type BlockNumberToBalance: Convert< - BlockNumberFor, - BalanceOf, - >; + type BlockNumberToBalance: Convert, BalanceOf>; /// The minimum amount transferred to call `vested_transfer`. #[pallet::constant] From 64bb57776f5a60e513e0b6a86a51e7e2463c2dde Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Wed, 5 Jul 2023 09:32:51 +0530 Subject: [PATCH 38/67] Update frame/examples/default-config/src/lib.rs Co-authored-by: Juan --- frame/examples/default-config/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index f19ef56cd59de..8a577427c27b5 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -141,7 +141,8 @@ pub mod tests { // type BlockNumber = u32; // type Header = // sp_runtime::generic::Header, - // Self::Hashing>; type Hash = sp_core::hash::H256; + // Self::Hashing>; + // type Hash = sp_core::hash::H256; // type Hashing = sp_runtime::traits::BlakeTwo256; // type AccountId = u64; // type Lookup = sp_runtime::traits::IdentityLookup; From e8c14b0f3957f6bd7a5b37d8ce787ca940ba9ac6 Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Wed, 5 Jul 2023 09:33:10 +0530 Subject: [PATCH 39/67] Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Juan --- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 399934bb8311d..118e266241f86 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -408,7 +408,7 @@ fn construct_runtime_final_expansion( proc_macro_warning::Warning::new_deprecated("WhereSection") .old("use where section") .new("use `frame_system::Config` to set the `Block` type and remove this section") - .help_links(&["https://github.com/paritytech/substrate/pull/14193"]) + .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) .span(where_section.span) .build(), ) From 2f1a5140cccf42d83881b502454b40ee38e32394 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sat, 8 Jul 2023 13:50:16 +0000 Subject: [PATCH 40/67] ".git/.scripts/commands/fmt/fmt.sh" --- frame/examples/default-config/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 8a577427c27b5..a2c11e168fe27 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -141,7 +141,7 @@ pub mod tests { // type BlockNumber = u32; // type Header = // sp_runtime::generic::Header, - // Self::Hashing>; + // Self::Hashing>; // type Hash = sp_core::hash::H256; // type Hashing = sp_runtime::traits::BlakeTwo256; // type AccountId = u64; From 16f10affa16f0819bbe9cdd7d7cb545793dc593a Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:47:38 +0530 Subject: [PATCH 41/67] Addresses some review comments --- frame/contracts/src/exec.rs | 7 +++---- frame/support/procedural/src/construct_runtime/mod.rs | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index dd1ee2462a820..27311fc0c7d90 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -48,7 +48,6 @@ use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; pub type SeedOf = ::Hash; -pub type BlockNumberOf = BlockNumberFor; pub type ExecResult = Result; /// A type that represents a topic of an event. At the moment a hash is used. @@ -244,7 +243,7 @@ pub trait Ext: sealing::Sealed { fn minimum_balance(&self) -> BalanceOf; /// Returns a random number for the current block with the given subject. - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf); + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor); /// Deposit an event with the given topics. /// @@ -252,7 +251,7 @@ pub trait Ext: sealing::Sealed { fn deposit_event(&mut self, topics: Vec>, data: Vec); /// Returns the current block number. - fn block_number(&self) -> BlockNumberOf; + fn block_number(&self) -> BlockNumberFor; /// Returns the maximum allowed size of a storage item. fn max_value_size(&self) -> u32; @@ -1341,7 +1340,7 @@ where self.top_frame().value_transferred } - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf) { + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor) { T::Randomness::random(subject) } diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 118e266241f86..d2a4a482e4015 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -407,7 +407,8 @@ fn construct_runtime_final_expansion( Some( proc_macro_warning::Warning::new_deprecated("WhereSection") .old("use where section") - .new("use `frame_system::Config` to set the `Block` type and remove this section") + .new("use `frame_system::Config` to set the `Block` type and delete this section. + It is planned to be removed in December 2023") .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) .span(where_section.span) .build(), From 5754b72e1f94a5c340138379c2736600e9c6444c Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:00:24 +0530 Subject: [PATCH 42/67] Fixes build --- frame/contracts/src/wasm/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 6eca21336b48b..1d04d9641018b 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -534,7 +534,7 @@ impl Executable for WasmBlob { mod tests { use super::*; use crate::{ - exec::{AccountIdOf, BlockNumberOf, ErrorOrigin, ExecError, Executable, Ext, Key, SeedOf}, + exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Ext, Key, SeedOf}, gas::GasMeter, storage::WriteOutcome, tests::{RuntimeCall, Test, ALICE, BOB}, @@ -544,6 +544,7 @@ mod tests { use frame_support::{ assert_err, assert_ok, dispatch::DispatchResultWithPostInfo, weights::Weight, }; + use frame_system::pallet_prelude::BlockNumberFor; use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pretty_assertions::assert_eq; use sp_core::H256; @@ -749,7 +750,7 @@ mod tests { fn minimum_balance(&self) -> u64 { 666 } - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf) { + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor) { (H256::from_slice(subject), 42) } fn deposit_event(&mut self, topics: Vec, data: Vec) { From 4775cc1bdcc60990ba7fa2f6eda0b9660b50e514 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 10 Jul 2023 05:36:39 +0000 Subject: [PATCH 43/67] ".git/.scripts/commands/fmt/fmt.sh" --- frame/support/procedural/src/construct_runtime/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index d2a4a482e4015..89504514e7733 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -403,8 +403,9 @@ fn construct_runtime_final_expansion( let integrity_test = decl_integrity_test(&scrate); let static_assertions = decl_static_assertions(&name, &pallets, &scrate); - let warning = if let Some(where_section) = where_section { - Some( + let warning = + if let Some(where_section) = where_section { + Some( proc_macro_warning::Warning::new_deprecated("WhereSection") .old("use where section") .new("use `frame_system::Config` to set the `Block` type and delete this section. @@ -413,9 +414,9 @@ fn construct_runtime_final_expansion( .span(where_section.span) .build(), ) - } else { - None - }; + } else { + None + }; let res = quote!( #warning From 1571503246ac8747df655f818d263aa3d9a4426e Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:06:35 +0530 Subject: [PATCH 44/67] Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi --- frame/democracy/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 543ad4750d93e..e90113312205b 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -794,7 +794,7 @@ pub mod pallet { ensure!(T::InstantAllowed::get(), Error::::InstantNotAllowed); } - ensure!(voting_period > BlockNumberFor::::zero(), Error::::VotingPeriodLow); + ensure!(voting_period > Zero::zero(), Error::::VotingPeriodLow); let (ext_proposal, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( From ab86af20d52b185c97f3f7b6558f195c8c2a388c Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:06:52 +0530 Subject: [PATCH 45/67] Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi --- frame/democracy/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index e90113312205b..c3d95c9ba30d6 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1048,7 +1048,7 @@ pub mod pallet { // Insert the proposal into the blacklist. let permanent = - (BlockNumberFor::::max_value(), BoundedVec::::default()); + (BlockNumberFor::::max_value(), Default::default()); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. From b443c404bbc91f3bd175c71f0bd5111ed58419ff Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:08:30 +0530 Subject: [PATCH 46/67] Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi --- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 89504514e7733..479ca745e4202 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -407,7 +407,7 @@ fn construct_runtime_final_expansion( if let Some(where_section) = where_section { Some( proc_macro_warning::Warning::new_deprecated("WhereSection") - .old("use where section") + .old("use a `where` clause in `construct_runtime`") .new("use `frame_system::Config` to set the `Block` type and delete this section. It is planned to be removed in December 2023") .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) From 0f3cee15539325a0eef46ac32e4edd688307ad18 Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:08:47 +0530 Subject: [PATCH 47/67] Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi --- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 479ca745e4202..0e53f14ed7358 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -408,7 +408,7 @@ fn construct_runtime_final_expansion( Some( proc_macro_warning::Warning::new_deprecated("WhereSection") .old("use a `where` clause in `construct_runtime`") - .new("use `frame_system::Config` to set the `Block` type and delete this section. + .new("use `frame_system::Config` to set the `Block` type and delete this clause. It is planned to be removed in December 2023") .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) .span(where_section.span) From 8bb8fb9a88ea485db8849824a76138819b8b6836 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:26:57 +0530 Subject: [PATCH 48/67] Addresses review comments --- frame/democracy/src/lib.rs | 2 +- frame/executive/src/lib.rs | 42 +- .../procedural/src/construct_runtime/mod.rs | 24 +- .../deprecated_where_block.rs | 13 + .../deprecated_where_block.stderr | 430 ++++++++++++++++++ .../missing_where_block.rs | 7 - .../missing_where_block.stderr | 5 - 7 files changed, 475 insertions(+), 48 deletions(-) create mode 100644 frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr delete mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.rs delete mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index c3d95c9ba30d6..e90113312205b 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1048,7 +1048,7 @@ pub mod pallet { // Insert the proposal into the blacklist. let permanent = - (BlockNumberFor::::max_value(), Default::default()); + (BlockNumberFor::::max_value(), BoundedVec::::default()); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 05442ff2f0405..8300de5604b6c 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -186,10 +186,10 @@ impl< Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize> - + OnIdle> - + OnFinalize> - + OffchainWorker>, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > ExecuteBlock for Executive @@ -223,11 +223,11 @@ impl< Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize> - + OnIdle> - + OnFinalize> - + OffchainWorker> - + frame_support::traits::TryState>, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker> + + frame_support::traits::TryState>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -305,7 +305,7 @@ where // run the try-state checks of all pallets, ensuring they don't alter any state. let _guard = frame_support::StorageNoopGuard::default(); , + BlockNumberFor, >>::try_state(*header.number(), select) .map_err(|e| { frame_support::log::error!(target: LOG_TARGET, "failure: {:?}", e); @@ -357,7 +357,7 @@ where if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); , + BlockNumberFor, >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, @@ -372,7 +372,7 @@ where if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); , + BlockNumberFor, >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, @@ -392,10 +392,10 @@ impl< Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize> - + OnIdle> - + OnFinalize> - + OffchainWorker>, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -430,7 +430,7 @@ where } fn initialize_block_impl( - block_number: &frame_system::pallet_prelude::BlockNumberFor, + block_number: &BlockNumberFor, parent_hash: &System::Hash, digest: &Digest, ) { @@ -445,7 +445,7 @@ where } >::initialize(block_number, parent_hash, digest); weight = weight.saturating_add(, + BlockNumberFor, >>::on_initialize(*block_number)); weight = weight.saturating_add( >::get().base_block, @@ -549,7 +549,7 @@ where if remaining_weight.all_gt(Weight::zero()) { let used_weight = , + BlockNumberFor, >>::on_idle(block_number, remaining_weight); >::register_extra_weight_unchecked( used_weight, @@ -558,7 +558,7 @@ where } , + BlockNumberFor, >>::on_finalize(block_number); } @@ -686,7 +686,7 @@ where frame_system::BlockHash::::insert(header.number(), header.hash()); , + BlockNumberFor, >>::offchain_worker(*header.number()) } } diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 0e53f14ed7358..fbfcd87ec7d10 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -403,20 +403,16 @@ fn construct_runtime_final_expansion( let integrity_test = decl_integrity_test(&scrate); let static_assertions = decl_static_assertions(&name, &pallets, &scrate); - let warning = - if let Some(where_section) = where_section { - Some( - proc_macro_warning::Warning::new_deprecated("WhereSection") - .old("use a `where` clause in `construct_runtime`") - .new("use `frame_system::Config` to set the `Block` type and delete this clause. - It is planned to be removed in December 2023") - .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) - .span(where_section.span) - .build(), - ) - } else { - None - }; + let warning = where_section.map_or(None, |where_section| { + Some(proc_macro_warning::Warning::new_deprecated("WhereSection") + .old("use a `where` clause in `construct_runtime`") + .new("use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023") + .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) + .span(where_section.span) + .build(), + )} + ); let res = quote!( #warning diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs new file mode 100644 index 0000000000000..135a316ebdbfc --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs @@ -0,0 +1,13 @@ +use frame_support::construct_runtime; + +construct_runtime! { + pub struct Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = Uxt, + { + System: frame_system::{Pallet, Call, Storage, Config, Event}, + } +} + +fn main() {} 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 new file mode 100644 index 0000000000000..3479e621cb080 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr @@ -0,0 +1,430 @@ +warning: use of deprecated constant `WhereSection::_w`: + It is deprecated to use a `where` clause in `construct_runtime`. + Please instead use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023. + + For more info see: + + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | / construct_runtime! { +4 | | pub struct Runtime where +5 | | Block = Block, +6 | | NodeBlock = Block, +... | +10 | | } +11 | | } + | |_^ + | + = note: `#[warn(deprecated)]` on by default + = note: this warning originates in the macro `frame_support::match_and_insert` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required by a bound in `frame_system::Event` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub enum Event { + | ^^^^^^ required by this bound in `Event` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Clone` + --> $RUST/core/src/clone.rs + | + | pub trait Clone: Sized { + | ^^^^^ required by this bound in `Clone` + = note: this error originates in the derive macro `Clone` 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 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `EncodeLike` + --> $CARGO/parity-scale-codec-3.6.1/src/encode_like.rs + | + | pub trait EncodeLike: Sized + Encode {} + | ^^^^^ required by this bound in `EncodeLike` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Decode` + --> $CARGO/parity-scale-codec-3.6.1/src/codec.rs + | + | pub trait Decode: Sized { + | ^^^^^ required by this bound in `Decode` + = note: this error originates in the macro `frame_support::construct_runtime` 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 `frame_system::Event` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required because it appears within the type `Event` +note: required by a bound in `From` + --> $RUST/core/src/convert/mod.rs + | + | pub trait From: Sized { + | ^ required by this bound in `From` + = note: this error originates in the macro `frame_support::construct_runtime` 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 `frame_system::Event` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required because it appears within the type `Event` +note: required by a bound in `TryInto` + --> $RUST/core/src/convert/mod.rs + | + | pub trait TryInto: Sized { + | ^ required by this bound in `TryInto` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | construct_runtime! { + | ^ the trait `Config` is not implemented for `Runtime` + | + = note: this error originates in the macro `frame_support::construct_runtime` 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 `RawOrigin<_>: TryFrom` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = help: the trait `TryFrom` is implemented for `RawOrigin<::AccountId>` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = help: the trait `Callable` is implemented for `Pallet` + = note: required for `Pallet` to implement `Callable` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Clone` + --> $RUST/core/src/clone.rs + | + | pub trait Clone: Sized { + | ^^^^^ required by this bound in `Clone` + = note: this error originates in the derive macro `Clone` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `EncodeLike` + --> $CARGO/parity-scale-codec-3.6.1/src/encode_like.rs + | + | pub trait EncodeLike: Sized + Encode {} + | ^^^^^ required by this bound in `EncodeLike` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Decode` + --> $CARGO/parity-scale-codec-3.6.1/src/codec.rs + | + | pub trait Decode: Sized { + | ^^^^^ required by this bound in `Decode` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Result` + --> $RUST/core/src/result.rs + | + | 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) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `TryInto` + --> $RUST/core/src/convert/mod.rs + | + | pub trait TryInto: Sized { + | ^^^^^ required by this bound in `TryInto` + = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Result` + --> $RUST/core/src/result.rs + | + | 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) diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs deleted file mode 100644 index 303df6b03d72e..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs +++ /dev/null @@ -1,7 +0,0 @@ -use frame_support::construct_runtime; - -construct_runtime! { - pub struct Runtime {} -} - -fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr deleted file mode 100644 index 67e27f4742f1c..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` - --> tests/construct_runtime_ui/missing_where_block.rs:4:21 - | -4 | pub struct Runtime {} - | ^^ From 83f7841617c08566369a6b73081245590ecd4427 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:32:50 +0530 Subject: [PATCH 49/67] Updates trait bounds --- primitives/runtime/src/traits.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 5e43a9bf48df6..389fce142e162 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -32,7 +32,7 @@ use impl_trait_for_tuples::impl_for_tuples; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_application_crypto::AppCrypto; pub use sp_arithmetic::traits::{ - checked_pow, ensure_pow, AsPrimitive, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, + checked_pow, ensure_pow, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, @@ -1170,7 +1170,6 @@ pub trait Header: + TypeInfo + MaxEncodedLen + FullCodec - + AsPrimitive; /// Header hash type type Hash: HashOutput; /// Hashing algorithm @@ -1255,7 +1254,7 @@ pub trait Block: /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. - type Header: Header + MaybeSerializeDeserialize; + type Header: Header; /// Block hash type. type Hash: HashOutput; From 644b5be6f3faf9273750bdf25b672358d4812332 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:36:10 +0530 Subject: [PATCH 50/67] Minor fix --- primitives/runtime/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 389fce142e162..0798bc78bfc4f 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1169,7 +1169,7 @@ pub trait Header: + Default + TypeInfo + MaxEncodedLen - + FullCodec + + FullCodec; /// Header hash type type Hash: HashOutput; /// Hashing algorithm From 2d219d503d7a7dff212a89084b2da94446d006f4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 11 Jul 2023 12:06:23 +0000 Subject: [PATCH 51/67] ".git/.scripts/commands/fmt/fmt.sh" --- frame/executive/src/lib.rs | 17 ++++++++--------- .../procedural/src/construct_runtime/mod.rs | 9 +++++---- primitives/runtime/src/traits.rs | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 8300de5604b6c..771fd364ed3d6 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -548,18 +548,17 @@ where let remaining_weight = max_weight.saturating_sub(weight.total()); if remaining_weight.all_gt(Weight::zero()) { - let used_weight = , - >>::on_idle(block_number, remaining_weight); + let used_weight = >>::on_idle( + block_number, + remaining_weight, + ); >::register_extra_weight_unchecked( used_weight, DispatchClass::Mandatory, ); } - , - >>::on_finalize(block_number); + >>::on_finalize(block_number); } /// Apply extrinsic outside of the block execution function. @@ -685,9 +684,9 @@ where // as well. frame_system::BlockHash::::insert(header.number(), header.hash()); - , - >>::offchain_worker(*header.number()) + >>::offchain_worker( + *header.number(), + ) } } diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index fbfcd87ec7d10..d78636605bf71 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -403,16 +403,17 @@ fn construct_runtime_final_expansion( let integrity_test = decl_integrity_test(&scrate); let static_assertions = decl_static_assertions(&name, &pallets, &scrate); - let warning = where_section.map_or(None, |where_section| { - Some(proc_macro_warning::Warning::new_deprecated("WhereSection") + let warning = + where_section.map_or(None, |where_section| { + Some(proc_macro_warning::Warning::new_deprecated("WhereSection") .old("use a `where` clause in `construct_runtime`") .new("use `frame_system::Config` to set the `Block` type and delete this clause. It is planned to be removed in December 2023") .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) .span(where_section.span) .build(), - )} - ); + ) + }); let res = quote!( #warning diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 0798bc78bfc4f..e22348610fac4 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -32,10 +32,10 @@ use impl_trait_for_tuples::impl_for_tuples; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_application_crypto::AppCrypto; pub use sp_arithmetic::traits::{ - checked_pow, ensure_pow, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, - CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, - EnsureDiv, EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, - EnsureMulAssign, EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, + checked_pow, ensure_pow, AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, + CheckedMul, CheckedShl, CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, + EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, + EnsureOp, EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, SaturatedConversion, Saturating, UniqueSaturatedFrom, UniqueSaturatedInto, Zero, }; use sp_core::{self, storage::StateVersion, Hasher, RuntimeDebug, TypeId}; From a09d3c90d147c0c656feda2146373ed1302d702d Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:40:44 +0530 Subject: [PATCH 52/67] Removes unnecessary bound --- primitives/arithmetic/src/traits.rs | 2 +- primitives/runtime/src/generic/header.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index 28590c31cc03a..e7bfdae6b51dd 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -25,7 +25,7 @@ pub use ensure::{ }; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ - checked_pow, AsPrimitive, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, + checked_pow, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, }; use sp_std::ops::{ diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index 7f434f593db1a..82ab9a61f96d8 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -22,7 +22,7 @@ use crate::{ generic::Digest, scale_info::TypeInfo, traits::{ - self, AsPrimitive, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeFromStr, + self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeFromStr, MaybeSerializeDeserialize, Member, }, }; @@ -92,8 +92,7 @@ where + MaxEncodedLen + Into + TryFrom - + TypeInfo - + AsPrimitive, + + TypeInfo, Hash: HashT, { type Number = Number; From f624f25a4792a5ac4936c008e08b0a9e4182fc6f Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 11 Jul 2023 12:14:24 +0000 Subject: [PATCH 53/67] ".git/.scripts/commands/fmt/fmt.sh" --- primitives/arithmetic/src/traits.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primitives/arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs index e7bfdae6b51dd..061b11b3e9c72 100644 --- a/primitives/arithmetic/src/traits.rs +++ b/primitives/arithmetic/src/traits.rs @@ -25,8 +25,8 @@ pub use ensure::{ }; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ - checked_pow, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, - CheckedShl, CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, + checked_pow, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, + CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, }; use sp_std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign, From c87594ca7dacc3c23bccd8b4cee219705ba777f8 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:25:20 +0530 Subject: [PATCH 54/67] Updates test --- .../deprecated_where_block.stderr | 12 ++++++++++-- 1 file changed, 10 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 3479e621cb080..68001dd28c58d 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 @@ -148,7 +148,11 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_syste | ||_- in this macro invocation ... | | - = note: required because it appears within the type `Event` +note: required because it appears within the type `Event` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub enum Event { + | ^^^^^ note: required by a bound in `From` --> $RUST/core/src/convert/mod.rs | @@ -169,7 +173,11 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_syste | ||_- in this macro invocation ... | | - = note: required because it appears within the type `Event` +note: required because it appears within the type `Event` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub enum Event { + | ^^^^^ note: required by a bound in `TryInto` --> $RUST/core/src/convert/mod.rs | From 90c0a212444ffc868c2aae9309b3181d80799eba Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:41:35 +0530 Subject: [PATCH 55/67] Fixes build --- .../deprecated_where_block.stderr | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 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 68001dd28c58d..12af48ddbaeee 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 @@ -1,10 +1,10 @@ -warning: use of deprecated constant `WhereSection::_w`: - It is deprecated to use a `where` clause in `construct_runtime`. - Please instead use `frame_system::Config` to set the `Block` type and delete this clause. - It is planned to be removed in December 2023. +error: use of deprecated constant `WhereSection::_w`: + It is deprecated to use a `where` clause in `construct_runtime`. + Please instead use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023. - For more info see: - + For more info see: + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 | 3 | / construct_runtime! { @@ -16,8 +16,8 @@ warning: use of deprecated constant `WhereSection::_w`: 11 | | } | |_^ | - = note: `#[warn(deprecated)]` on by default - = note: this warning originates in the macro `frame_support::match_and_insert` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `-D deprecated` implied by `-D warnings` + = note: this error originates in the macro `frame_support::match_and_insert` 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 --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 @@ -148,11 +148,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_syste | ||_- in this macro invocation ... | | -note: required because it appears within the type `Event` - --> $WORKSPACE/frame/system/src/lib.rs - | - | pub enum Event { - | ^^^^^ + = note: required because it appears within the type `Event` note: required by a bound in `From` --> $RUST/core/src/convert/mod.rs | @@ -173,11 +169,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_syste | ||_- in this macro invocation ... | | -note: required because it appears within the type `Event` - --> $WORKSPACE/frame/system/src/lib.rs - | - | pub enum Event { - | ^^^^^ + = note: required because it appears within the type `Event` note: required by a bound in `TryInto` --> $RUST/core/src/convert/mod.rs | From e595d28d1a2015d3577b02ebdaf16e57ea5b7b72 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 12 Jul 2023 22:43:55 +0530 Subject: [PATCH 56/67] Adds a bound for header --- primitives/runtime/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index e22348610fac4..2637627573a5d 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1254,7 +1254,7 @@ pub trait Block: /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. - type Header: Header; + type Header: Header + MaybeSerializeDeserialize; /// Block hash type. type Hash: HashOutput; From 5e96a39c4036c7fd3ab2e5d3cf37a8338089fe22 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 12 Jul 2023 17:28:53 +0000 Subject: [PATCH 57/67] ".git/.scripts/commands/fmt/fmt.sh" --- frame/aura/src/mock.rs | 6 +----- frame/indices/src/mock.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index bc127e5f8cd59..eb6c08d17566a 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -26,11 +26,7 @@ use frame_support::{ }; use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; -use sp_runtime::{ - testing::{UintAuthorityId}, - traits::IdentityLookup, - BuildStorage, -}; +use sp_runtime::{testing::UintAuthorityId, traits::IdentityLookup, BuildStorage}; type Block = frame_system::mocking::MockBlock; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index f9cdb8a223269..3e7d6240b1087 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -22,7 +22,7 @@ use crate::{self as pallet_indices, Config}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; -use sp_runtime::{BuildStorage}; +use sp_runtime::BuildStorage; type Block = frame_system::mocking::MockBlock; From b14d234ffb87bcf6dff2eecc7232f8d079a058a5 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 12 Jul 2023 23:01:44 +0530 Subject: [PATCH 58/67] Removes where block --- frame/support/test/tests/versioned_runtime_upgrade.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index 338d0776974ad..c0185c787bfca 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -64,10 +64,7 @@ mod dummy_pallet { impl dummy_pallet::Config for Test {} construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, DummyPallet: dummy_pallet::{Pallet, Config, Storage} = 1, From ef9ca395ee60235e789eaa4faa311c90878ad48d Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 12 Jul 2023 23:06:32 +0530 Subject: [PATCH 59/67] Minor fix --- frame/support/test/tests/versioned_runtime_upgrade.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index c0185c787bfca..93d87df8ca185 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -27,9 +27,9 @@ use frame_support::{ weights::constants::RocksDbWeight, }; use frame_system::Config; +use sp_core::ConstU64; use sp_runtime::BuildStorage; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; #[frame_support::pallet] @@ -74,6 +74,8 @@ construct_runtime!( #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; From a65653ce0c7f4761eede949df7a6f4d9868e3d51 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Wed, 12 Jul 2023 23:12:18 +0530 Subject: [PATCH 60/67] Minor fix --- frame/support/test/tests/issue2219.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index c0cffc39e9cd6..4016707b51a8d 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -185,6 +185,7 @@ frame_support::construct_runtime!( #[test] fn create_genesis_config() { let config = RuntimeGenesisConfig { + system: Default::default(), module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true, From c559e512d41f68eecb87be4b80508985f58045b7 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 08:16:28 +0530 Subject: [PATCH 61/67] Fixes tests --- frame/aura/src/lib.rs | 2 +- .../support/procedural/src/construct_runtime/mod.rs | 2 +- frame/support/src/migrations.rs | 7 ++----- .../both_use_and_excluded_parts.rs | 2 +- .../construct_runtime_ui/deprecated_where_block.rs | 2 +- .../construct_runtime_ui/exclude_undefined_part.rs | 2 +- .../missing_system_module.stderr | 2 +- .../pallet_error_too_large.stderr | 2 +- .../construct_runtime_ui/undefined_call_part.stderr | 2 +- .../construct_runtime_ui/undefined_event_part.stderr | 4 ++-- .../undefined_genesis_config_part.stderr | 4 ++-- .../undefined_inherent_part.stderr | 12 ++++++------ .../undefined_origin_part.stderr | 4 ++-- .../undefined_validate_unsigned_part.stderr | 6 +++--- .../tests/construct_runtime_ui/use_undefined_part.rs | 2 +- 15 files changed, 26 insertions(+), 29 deletions(-) diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index b1bacde401b22..7a1969d905fcc 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -134,7 +134,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_: T::BlockNumber) -> Result<(), sp_runtime::TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), sp_runtime::TryRuntimeError> { Self::do_try_state() } } diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index d78636605bf71..efc2244154479 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -341,7 +341,7 @@ fn construct_runtime_final_expansion( syn::Error::new( pallets_token.span.join(), "`System` pallet declaration is missing. \ - Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},`", + Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},`", ) })?; if !system_pallet.cfg_pattern.is_empty() { diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 889439907efd2..f2ca2f55d3be1 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -255,12 +255,9 @@ pub fn migrate_from_pallet_version_to_storage_version< /// # Examples: /// ```ignore /// construct_runtime! { -/// pub enum Runtime where -/// Block = Block, -/// NodeBlock = primitives::Block, -/// UncheckedExtrinsic = UncheckedExtrinsic +/// pub enum Runtime /// { -/// System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, +/// System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, /// /// SomePalletToRemove: pallet_something::{Pallet, Call, Storage, Event} = 1, /// AnotherPalletToRemove: pallet_something_else::{Pallet, Call, Storage, Event} = 2, diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs index 215f242323c9d..4cb249714650e 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs @@ -22,7 +22,7 @@ impl pallet::Config for Runtime {} construct_runtime! { pub struct Runtime { - System: system::{Pallet, Call, Storage, Config, Event}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, } } diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs index 135a316ebdbfc..c0e325085b5e5 100644 --- a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = Uxt, { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs index bcb9075f08bd4..10cda7b4e7e8a 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs @@ -27,7 +27,7 @@ impl pallet::Config for Runtime {} construct_runtime! { pub struct Runtime { - System: system::{Pallet, Call, Storage, Config, Event}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet exclude_parts { Call }, } } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index 778cfe4b2196a..c8631f44051ca 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,4 +1,4 @@ -error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` +error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` --> tests/construct_runtime_ui/missing_system_module.rs:5:2 | 5 | / { diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr index 656fc0141161e..47504573515a2 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed 73 | / construct_runtime! { 74 | | pub struct Runtime 75 | | { -76 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +76 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, 77 | | Pallet: pallet::{Pallet}, 78 | | } 79 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr index 03a9ea928e9bd..f3f29e4c69554 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::call] defined, perhaps you should remove 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet::{Pallet, Call}, 53 | | } 54 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index fb2f5d56bbe40..81e42cec3b97a 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Event}, 53 | | } 54 | | } @@ -21,7 +21,7 @@ error[E0412]: cannot find type `Event` in module `pallet` 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Event}, 53 | | } 54 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index 871fd77ae465a..920785fc96291 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::genesis_config] defined, perhaps you sho 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Config}, 53 | | } 54 | | } @@ -21,7 +21,7 @@ error[E0412]: cannot find type `GenesisConfig` in module `pallet` 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Config}, 53 | | } 54 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr index 4b208b9b13365..659d43b151006 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::inherent] defined, perhaps you should re 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } @@ -25,7 +25,7 @@ error[E0599]: no function or associated item named `create_inherent` found for s | _^ 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } @@ -46,7 +46,7 @@ error[E0599]: no function or associated item named `is_inherent` found for struc | _^ 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } @@ -67,7 +67,7 @@ error[E0599]: no function or associated item named `check_inherent` found for st | _^ 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } @@ -88,7 +88,7 @@ error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `p | _^ 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } @@ -109,7 +109,7 @@ error[E0599]: no function or associated item named `is_inherent_required` found | _^ 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, 53 | | } 54 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr index bf9dff6c55dfb..c41dbe79421ea 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::origin] defined, perhaps you should remo 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Origin}, 53 | | } 54 | | } @@ -21,7 +21,7 @@ error[E0412]: cannot find type `Origin` in module `pallet` 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet expanded::{}::{Pallet, Origin}, 53 | | } 54 | | } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index 17395e8e99a90..007b77250736e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -7,7 +7,7 @@ error: `Pallet` does not have #[pallet::validate_unsigned] defined, perhaps you 48 | / construct_runtime! { 49 | | pub struct Runtime 50 | | { -51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, 52 | | Pallet: pallet::{Pallet, ValidateUnsigned}, 53 | | } 54 | | } @@ -40,7 +40,7 @@ error[E0599]: no function or associated item named `pre_dispatch` found for stru | || 49 | || pub struct Runtime 50 | || { -51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, 52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, 53 | || } 54 | || } @@ -65,7 +65,7 @@ error[E0599]: no function or associated item named `validate_unsigned` found for | || 49 | || pub struct Runtime 50 | || { -51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, 52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, 53 | || } 54 | || } diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs index 1490e26b98187..8563be1008cd9 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs @@ -27,7 +27,7 @@ impl pallet::Config for Runtime {} construct_runtime! { pub struct Runtime { - System: system::{Pallet, Call, Storage, Config, Event}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet use_parts { Call }, } } From d1a6169a93647afc914bb0cbf2db42015f9ba2d8 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 13 Jul 2023 03:12:14 +0000 Subject: [PATCH 62/67] ".git/.scripts/commands/update-ui/update-ui.sh" 1.70 --- .../deprecated_where_block.stderr | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 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 12af48ddbaeee..b908048ad0ee5 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 @@ -1,10 +1,10 @@ -error: use of deprecated constant `WhereSection::_w`: - It is deprecated to use a `where` clause in `construct_runtime`. - Please instead use `frame_system::Config` to set the `Block` type and delete this clause. - It is planned to be removed in December 2023. +warning: use of deprecated constant `WhereSection::_w`: + It is deprecated to use a `where` clause in `construct_runtime`. + Please instead use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023. - For more info see: - + For more info see: + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 | 3 | / construct_runtime! { @@ -16,8 +16,8 @@ error: use of deprecated constant `WhereSection::_w`: 11 | | } | |_^ | - = note: `-D deprecated` implied by `-D warnings` - = note: this error originates in the macro `frame_support::match_and_insert` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(deprecated)]` on by default + = note: this warning originates in the macro `frame_support::match_and_insert` 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 --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 @@ -332,6 +332,18 @@ note: required by a bound in `Decode` | ^^^^^ required by this bound in `Decode` = note: this error originates in the macro `frame_support::construct_runtime` 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 + --> tests/construct_runtime_ui/deprecated_where_block.rs:9:3 + | +9 | System: frame_system::{Pallet, Call, Storage, Config, Event}, + | ^^^^^^ the trait `Config` is not implemented for `Runtime` + | +note: required by a bound in `frame_system::GenesisConfig` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub struct GenesisConfig { + | ^^^^^^ required by this bound in `GenesisConfig` + error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 | From e89e93e3d0d42ede01459be49ada9e9f8ded5a5f Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 08:51:31 +0530 Subject: [PATCH 63/67] Updates test --- .../deprecated_where_block.stderr | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 b908048ad0ee5..946277e9068e3 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 @@ -1,10 +1,10 @@ -warning: use of deprecated constant `WhereSection::_w`: - It is deprecated to use a `where` clause in `construct_runtime`. - Please instead use `frame_system::Config` to set the `Block` type and delete this clause. - It is planned to be removed in December 2023. +error: use of deprecated constant `WhereSection::_w`: + It is deprecated to use a `where` clause in `construct_runtime`. + Please instead use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023. - For more info see: - + For more info see: + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 | 3 | / construct_runtime! { @@ -16,8 +16,8 @@ warning: use of deprecated constant `WhereSection::_w`: 11 | | } | |_^ | - = note: `#[warn(deprecated)]` on by default - = note: this warning originates in the macro `frame_support::match_and_insert` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `-D deprecated` implied by `-D warnings` + = note: this error originates in the macro `frame_support::match_and_insert` 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 --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 From 277300f2e85d6cee12bacb34d3695f5b394a5c27 Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:45:31 +0530 Subject: [PATCH 64/67] Update primitives/runtime/src/traits.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- primitives/runtime/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 2637627573a5d..37dd7e7e20b7c 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1230,7 +1230,7 @@ pub trait Header: // So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a // recursive loop leading to a build error. // -// Note that this is a workaround and should be removed once we have a better solution. +// Note that this is a workaround for a compiler bug and should be removed when the compiler bug is fixed. pub trait HeaderProvider { /// Header type. type HeaderT: Header; From c3be2e0e250b897d729072a893657c03a50abe19 Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:45:40 +0530 Subject: [PATCH 65/67] Update primitives/runtime/src/traits.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- primitives/runtime/src/traits.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 37dd7e7e20b7c..4070277b6130a 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1231,6 +1231,7 @@ pub trait Header: // recursive loop leading to a build error. // // Note that this is a workaround for a compiler bug and should be removed when the compiler bug is fixed. +#![doc(hidden)] pub trait HeaderProvider { /// Header type. type HeaderT: Header; From 5c823a595ec2bb05bd745151a6d7587200b2fe73 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:53:14 +0530 Subject: [PATCH 66/67] Updates doc --- primitives/runtime/src/traits.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 4070277b6130a..9d8794f8bbc47 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1215,7 +1215,9 @@ pub trait Header: } } -/// Something that provides the Header Type. +// Something that provides the Header Type. Only for internal usage and should only be used +// via `HeaderFor` or `BlockNumberFor`. +// // This is needed to fix the "cyclical" issue in loading Header/BlockNumber as part of a // `pallet::call`. Essentially, `construct_runtime` aggregates all calls to create a `RuntimeCall` // that is then used to define `UncheckedExtrinsic`. @@ -1230,7 +1232,8 @@ pub trait Header: // So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a // recursive loop leading to a build error. // -// Note that this is a workaround for a compiler bug and should be removed when the compiler bug is fixed. +// Note that this is a workaround for a compiler bug and should be removed when the compiler +// bug is fixed. #![doc(hidden)] pub trait HeaderProvider { /// Header type. From 3e41fa2c983218fe65b033f30dca0fb6854bb7cd Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:56:09 +0530 Subject: [PATCH 67/67] Updates doc --- primitives/runtime/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 9d8794f8bbc47..51d91958ab533 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1234,7 +1234,7 @@ pub trait Header: // // Note that this is a workaround for a compiler bug and should be removed when the compiler // bug is fixed. -#![doc(hidden)] +#[doc(hidden)] pub trait HeaderProvider { /// Header type. type HeaderT: Header;