From 71e16aa29fc238b35b54f668b7e572908e3941d1 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 8 Jun 2023 17:30:00 -0400 Subject: [PATCH 01/44] initial API for Task trait --- frame/support/src/traits.rs | 3 +++ frame/support/src/traits/tasks.rs | 40 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 frame/support/src/traits/tasks.rs diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 3db274c1720c6..95f42887b6333 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -116,6 +116,9 @@ pub use messages::{ ProcessMessageError, ServiceQueues, TransformOrigin, }; +pub mod tasks; +pub use tasks::*; + #[cfg(feature = "try-runtime")] mod try_runtime; #[cfg(feature = "try-runtime")] diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs new file mode 100644 index 0000000000000..4f78584ebdeec --- /dev/null +++ b/frame/support/src/traits/tasks.rs @@ -0,0 +1,40 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Contains the [`Task`] trait, which defines a general-purpose way for defining and executing +//! service work, and supporting types. + +use sp_runtime::DispatchError; +use sp_std::slice::Iter; + +/// A general-purpose trait which defines a type of service work (i.e., work to performed by an +/// off-chain worker) including methods for enumerating, validating, indexing, and running +/// tasks of this type. +pub trait Task<'a>: Sized { + /// Inspects the pallet's state and enumerates tasks of this type. + fn enumerate() -> Iter<'a, Self>; + + /// Checks if a particular instance of this `Task` variant is a valid piece of work. + fn is_valid(&self) -> bool; + + /// Returns the `task_index` (analogous to `call_index`, but for tasks) of this `Task` + /// variant. + fn task_index(&self) -> usize; + + /// Performs the work for this particular `Task` variant. + fn run(&self) -> Result<(), DispatchError>; +} From 01e3bbe1fb6010f9b72a5add62973c94de05e854 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 16 Jun 2023 10:00:14 -0400 Subject: [PATCH 02/44] remove lifetime as per basti's suggestion --- frame/support/src/traits/tasks.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 4f78584ebdeec..9543ba42d3890 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -24,9 +24,11 @@ use sp_std::slice::Iter; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running /// tasks of this type. -pub trait Task<'a>: Sized { +pub trait Task: Sized { + type Enumeration: sp_std::iter::Iterator; + /// Inspects the pallet's state and enumerates tasks of this type. - fn enumerate() -> Iter<'a, Self>; + fn enumerate() -> Self::Enumeration; /// Checks if a particular instance of this `Task` variant is a valid piece of work. fn is_valid(&self) -> bool; From 28f13cf33e63ce5fcacb996af43b88a98eb6a10b Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 19 Jun 2023 09:53:40 -0400 Subject: [PATCH 03/44] bound Task on FullCodec --- frame/support/src/traits/tasks.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 9543ba42d3890..1bc3471771526 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -18,13 +18,14 @@ //! Contains the [`Task`] trait, which defines a general-purpose way for defining and executing //! service work, and supporting types. +use codec::FullCodec; use sp_runtime::DispatchError; use sp_std::slice::Iter; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running /// tasks of this type. -pub trait Task: Sized { +pub trait Task: Sized + FullCodec { type Enumeration: sp_std::iter::Iterator; /// Inspects the pallet's state and enumerates tasks of this type. From f22054b81fc5cafb06c82e0b5b7999b6fedd10d8 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 19 Jun 2023 09:54:04 -0400 Subject: [PATCH 04/44] fix imports --- frame/support/src/traits/tasks.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 1bc3471771526..86310c4cb1053 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -20,13 +20,13 @@ use codec::FullCodec; use sp_runtime::DispatchError; -use sp_std::slice::Iter; +use sp_std::iter::Iterator; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running /// tasks of this type. pub trait Task: Sized + FullCodec { - type Enumeration: sp_std::iter::Iterator; + type Enumeration: Iterator; /// Inspects the pallet's state and enumerates tasks of this type. fn enumerate() -> Self::Enumeration; From 4682e6fe96961195eab5eee38dde3f12889dacdc Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Tue, 4 Jul 2023 07:10:42 -0400 Subject: [PATCH 05/44] set task_index to const --- frame/support/src/traits/tasks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 86310c4cb1053..92a1ea3a61335 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -36,7 +36,7 @@ pub trait Task: Sized + FullCodec { /// Returns the `task_index` (analogous to `call_index`, but for tasks) of this `Task` /// variant. - fn task_index(&self) -> usize; + const fn task_index(&self) -> usize; /// Performs the work for this particular `Task` variant. fn run(&self) -> Result<(), DispatchError>; From 389131cce5e5121948c4946df8922e416802f43a Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 5 Jul 2023 11:03:52 -0400 Subject: [PATCH 06/44] change to an associated const --- frame/support/src/traits/tasks.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 92a1ea3a61335..ac783f8ce434f 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -28,16 +28,15 @@ use sp_std::iter::Iterator; pub trait Task: Sized + FullCodec { type Enumeration: Iterator; + /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. + const TASK_INDEX: usize; + /// Inspects the pallet's state and enumerates tasks of this type. fn enumerate() -> Self::Enumeration; /// Checks if a particular instance of this `Task` variant is a valid piece of work. fn is_valid(&self) -> bool; - /// Returns the `task_index` (analogous to `call_index`, but for tasks) of this `Task` - /// variant. - const fn task_index(&self) -> usize; - /// Performs the work for this particular `Task` variant. fn run(&self) -> Result<(), DispatchError>; } From 19f6ef68683554c36f290b548152e895c3d1fdff Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 12 Jul 2023 15:30:18 -0400 Subject: [PATCH 07/44] compiles using wrapper PalletTask trait ... WIP --- Cargo.lock | 15 +++ Cargo.toml | 1 + frame/examples/tasks-example/Cargo.toml | 38 ++++++ frame/examples/tasks-example/src/lib.rs | 155 ++++++++++++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 frame/examples/tasks-example/Cargo.toml create mode 100644 frame/examples/tasks-example/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 76f3459b16603..cae5cda5fa16e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12232,6 +12232,21 @@ version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +[[package]] +name = "tasks-example" +version = "4.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "tempfile" version = "3.6.0" diff --git a/Cargo.toml b/Cargo.toml index 95acf0b9702cb..7dd61c62fea28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,6 +113,7 @@ members = [ "frame/examples/dev-mode", "frame/examples/split", "frame/examples/default-config", + "frame/examples/tasks-example", "frame/executive", "frame/nis", "frame/grandpa", diff --git a/frame/examples/tasks-example/Cargo.toml b/frame/examples/tasks-example/Cargo.toml new file mode 100644 index 0000000000000..d90de4fae9602 --- /dev/null +++ b/frame/examples/tasks-example/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "tasks-example" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "MIT-0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "FRAME example pallet" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } +log = { version = "0.4.17", default-features = false } +scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } +frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } +sp-io = { version = "23.0.0", default-features = false, path = "../../../primitives/io" } +sp-runtime = { version = "24.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" } +sp-core = { version = "21.0.0", default-features = false, path = "../../../primitives/core" } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-support/std", + "frame-system/std", + "log/std", + "scale-info/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "sp-core/std", +] +try-runtime = ["frame-support/try-runtime"] diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs new file mode 100644 index 0000000000000..b5f2018769401 --- /dev/null +++ b/frame/examples/tasks-example/src/lib.rs @@ -0,0 +1,155 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! +//! # Dev Mode Example Pallet +//! +//! A simple example of a FRAME pallet demonstrating +//! the ease of requirements for a pallet in dev mode. +//! +//! Run `cargo doc --package pallet-dev-mode --open` to view this pallet's documentation. +//! +//! **Dev mode is not meant to be used in production.** + +// Ensure we're `no_std` when compiling for Wasm. +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::{Decode, Encode}; +use frame_support::{dispatch::DispatchResult, traits::Task}; +// Re-export pallet items so that they can be accessed from the crate namespace. +pub use pallet::*; +use sp_runtime::DispatchError; + +#[derive(Clone, PartialEq, Eq, Encode, Decode)] +pub enum ExampleTask { + Increment, + Decrement, +} + +pub trait PalletTask: Task { + type Config: frame_system::Config; + fn is_valid(&self, config: &Self::Config) -> bool; + fn run(&self, config: &Self::Config) -> Result<(), DispatchError>; +} + +impl Task for ExampleTask { + type Enumeration = std::vec::IntoIter; + + const TASK_INDEX: usize = 0; + + fn enumerate() -> Self::Enumeration { + vec![ExampleTask::Increment, ExampleTask::Decrement].into_iter() + } + + fn is_valid(&self) -> bool { + todo!() + } + + fn run(&self) -> Result<(), DispatchError> { + todo!() + } +} + +impl PalletTask for ExampleTask { + type Config = T; + + fn is_valid(&self, _config: &Self::Config) -> bool { + // You can implement some validation logic here + // For demonstration purposes, we'll just return true + true + } + + fn run(&self, _config: &Self::Config) -> Result<(), DispatchError> { + match self { + ExampleTask::Increment => { + // You can call some functions on your pallet here + // For demonstration purposes, we'll just print a message + println!("Increment task running"); + }, + ExampleTask::Decrement => { + // You can call some functions on your pallet here + // For demonstration purposes, we'll just print a message + println!("Decrement task running"); + }, + } + Ok(()) + } +} + +/// Enable `dev_mode` for this pallet. +#[frame_support::pallet(dev_mode)] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// The overarching event type. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and + // method. + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::storage] + #[pallet::getter(fn value)] + pub type Value = StorageValue<_, u8>; + + #[pallet::call] + impl Pallet { + // No need to define a `call_index` attribute here because of `dev_mode`. + // No need to define a `weight` attribute here because of `dev_mode`. + pub fn add_dummy(origin: OriginFor, id: T::AccountId) -> DispatchResult { + ensure_root(origin)?; + + if let Some(mut dummies) = Dummy::::get() { + dummies.push(id.clone()); + Dummy::::set(Some(dummies)); + } else { + Dummy::::set(Some(vec![id.clone()])); + } + + // Let's deposit an event to let the outside world know this happened. + Self::deposit_event(Event::AddDummy { account: id }); + + Ok(()) + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + AddDummy { account: T::AccountId }, + } + + /// The MEL requirement for bounded pallets is skipped by `dev_mode`. + /// This means that all storages are marked as unbounded. + /// This is equivalent to specifying `#[pallet::unbounded]` on this type definitions. + /// When the dev_mode is removed, we would need to implement implement `MaxEncodedLen`. + #[pallet::storage] + pub type Dummy = StorageValue<_, Vec>; + + /// The Hasher requirement is skipped by `dev_mode`. So, second parameter can be `_` + /// and `Blake2_128Concat` is used as a default. + /// When the dev_mode is removed, we would need to specify the hasher like so: + /// `pub type Bar = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance>;`. + #[pallet::storage] + pub type Bar = StorageMap<_, _, T::AccountId, u32>; +} From f967a80569dc3f42ffcd5ea77e76da74e56ce34f Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 12 Jul 2023 16:15:47 -0400 Subject: [PATCH 08/44] example task impl using a wrapper task possibly working (compiles) --- frame/examples/tasks-example/src/lib.rs | 84 ++++++++++--------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index b5f2018769401..927920c776a87 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -15,17 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! -//! # Dev Mode Example Pallet -//! -//! A simple example of a FRAME pallet demonstrating -//! the ease of requirements for a pallet in dev mode. -//! -//! Run `cargo doc --package pallet-dev-mode --open` to view this pallet's documentation. -//! -//! **Dev mode is not meant to be used in production.** - -// Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; @@ -56,11 +45,11 @@ impl Task for ExampleTask { } fn is_valid(&self) -> bool { - todo!() + unimplemented!() } fn run(&self) -> Result<(), DispatchError> { - todo!() + unimplemented!() } } @@ -68,29 +57,32 @@ impl PalletTask for ExampleTask { type Config = T; fn is_valid(&self, _config: &Self::Config) -> bool { - // You can implement some validation logic here - // For demonstration purposes, we'll just return true - true + let value = Value::::get().unwrap(); + match self { + ExampleTask::Increment => value < 255, + ExampleTask::Decrement => value > 0, + } } fn run(&self, _config: &Self::Config) -> Result<(), DispatchError> { match self { ExampleTask::Increment => { - // You can call some functions on your pallet here - // For demonstration purposes, we'll just print a message - println!("Increment task running"); + // Increment the value and emit an event + let new_val = Value::::get().unwrap().checked_add(1).ok_or("Value overflow")?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Incremented { new_val }); }, ExampleTask::Decrement => { - // You can call some functions on your pallet here - // For demonstration purposes, we'll just print a message - println!("Decrement task running"); + // Decrement the value and emit an event + let new_val = Value::::get().unwrap().checked_sub(1).ok_or("Value underflow")?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Decremented { new_val }); }, } Ok(()) } } -/// Enable `dev_mode` for this pallet. #[frame_support::pallet(dev_mode)] pub mod pallet { use super::*; @@ -99,12 +91,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; } - // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and - // method. #[pallet::pallet] pub struct Pallet(_); @@ -114,20 +103,24 @@ pub mod pallet { #[pallet::call] impl Pallet { - // No need to define a `call_index` attribute here because of `dev_mode`. - // No need to define a `weight` attribute here because of `dev_mode`. - pub fn add_dummy(origin: OriginFor, id: T::AccountId) -> DispatchResult { + pub fn increment(origin: OriginFor) -> DispatchResult { ensure_root(origin)?; - if let Some(mut dummies) = Dummy::::get() { - dummies.push(id.clone()); - Dummy::::set(Some(dummies)); - } else { - Dummy::::set(Some(vec![id.clone()])); - } + // Increment the value and emit an event + let new_val = Value::::get().unwrap().checked_add(1).ok_or("Value overflow")?; + Value::::put(new_val); + Self::deposit_event(Event::Incremented { new_val }); + + Ok(()) + } - // Let's deposit an event to let the outside world know this happened. - Self::deposit_event(Event::AddDummy { account: id }); + pub fn decrement(origin: OriginFor) -> DispatchResult { + ensure_root(origin)?; + + // Decrement the value and emit an event + let new_val = Value::::get().unwrap().checked_sub(1).ok_or("Value underflow")?; + Value::::put(new_val); + Self::deposit_event(Event::Decremented { new_val }); Ok(()) } @@ -136,20 +129,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - AddDummy { account: T::AccountId }, + Incremented { new_val: u8 }, + Decremented { new_val: u8 }, } - - /// The MEL requirement for bounded pallets is skipped by `dev_mode`. - /// This means that all storages are marked as unbounded. - /// This is equivalent to specifying `#[pallet::unbounded]` on this type definitions. - /// When the dev_mode is removed, we would need to implement implement `MaxEncodedLen`. - #[pallet::storage] - pub type Dummy = StorageValue<_, Vec>; - - /// The Hasher requirement is skipped by `dev_mode`. So, second parameter can be `_` - /// and `Blake2_128Concat` is used as a default. - /// When the dev_mode is removed, we would need to specify the hasher like so: - /// `pub type Bar = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance>;`. - #[pallet::storage] - pub type Bar = StorageMap<_, _, T::AccountId, u32>; } From e07c25ac23a7bcdfc0b2c8bccf684fb3ebd3e028 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 17 Jul 2023 15:43:49 -0400 Subject: [PATCH 09/44] use generic ExampleTask --- frame/examples/tasks-example/src/lib.rs | 34 +++++++++---------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 927920c776a87..0668c5f605461 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -17,6 +17,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +use core::marker::PhantomData; + use codec::{Decode, Encode}; use frame_support::{dispatch::DispatchResult, traits::Task}; // Re-export pallet items so that they can be accessed from the crate namespace. @@ -24,19 +26,17 @@ pub use pallet::*; use sp_runtime::DispatchError; #[derive(Clone, PartialEq, Eq, Encode, Decode)] -pub enum ExampleTask { +pub enum Never {} + +#[derive(Clone, PartialEq, Eq, Encode, Decode)] +pub enum ExampleTask { Increment, Decrement, + _Phantom(PhantomData, Never), } -pub trait PalletTask: Task { - type Config: frame_system::Config; - fn is_valid(&self, config: &Self::Config) -> bool; - fn run(&self, config: &Self::Config) -> Result<(), DispatchError>; -} - -impl Task for ExampleTask { - type Enumeration = std::vec::IntoIter; +impl Task for ExampleTask { + type Enumeration = std::vec::IntoIter>; const TASK_INDEX: usize = 0; @@ -45,26 +45,15 @@ impl Task for ExampleTask { } fn is_valid(&self) -> bool { - unimplemented!() - } - - fn run(&self) -> Result<(), DispatchError> { - unimplemented!() - } -} - -impl PalletTask for ExampleTask { - type Config = T; - - fn is_valid(&self, _config: &Self::Config) -> bool { let value = Value::::get().unwrap(); match self { ExampleTask::Increment => value < 255, ExampleTask::Decrement => value > 0, + ExampleTask::_Phantom(_, _) => unreachable!(), } } - fn run(&self, _config: &Self::Config) -> Result<(), DispatchError> { + fn run(&self) -> Result<(), DispatchError> { match self { ExampleTask::Increment => { // Increment the value and emit an event @@ -78,6 +67,7 @@ impl PalletTask for ExampleTask { Value::::put(new_val); Pallet::::deposit_event(Event::Decremented { new_val }); }, + ExampleTask::_Phantom(_, _) => unreachable!(), } Ok(()) } From b4c57ba15764b53197de88e964e80e5cc7e868a4 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 17 Jul 2023 17:03:30 -0400 Subject: [PATCH 10/44] use frame_support::Never --- frame/examples/tasks-example/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 0668c5f605461..15458e62f3050 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -20,19 +20,18 @@ use core::marker::PhantomData; use codec::{Decode, Encode}; -use frame_support::{dispatch::DispatchResult, traits::Task}; +use frame_support::{dispatch::DispatchResult, traits::Task, Never}; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; use sp_runtime::DispatchError; -#[derive(Clone, PartialEq, Eq, Encode, Decode)] -pub enum Never {} - #[derive(Clone, PartialEq, Eq, Encode, Decode)] pub enum ExampleTask { Increment, Decrement, - _Phantom(PhantomData, Never), + #[doc(hidden)] + #[codec(skip)] + __Ignore(PhantomData, Never), } impl Task for ExampleTask { @@ -49,7 +48,7 @@ impl Task for ExampleTask { match self { ExampleTask::Increment => value < 255, ExampleTask::Decrement => value > 0, - ExampleTask::_Phantom(_, _) => unreachable!(), + ExampleTask::__Ignore(_, _) => unreachable!(), } } @@ -67,7 +66,7 @@ impl Task for ExampleTask { Value::::put(new_val); Pallet::::deposit_event(Event::Decremented { new_val }); }, - ExampleTask::_Phantom(_, _) => unreachable!(), + ExampleTask::__Ignore(_, _) => unreachable!(), } Ok(()) } From 32bbd4ecc9d6b5074c42b7befca10bbcc1c65be9 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 20 Jul 2023 12:57:48 -0400 Subject: [PATCH 11/44] refactor to be more like Call --- frame/examples/tasks-example/src/lib.rs | 92 +++++++++++++------------ 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 15458e62f3050..f32339026b358 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -20,63 +20,65 @@ use core::marker::PhantomData; use codec::{Decode, Encode}; -use frame_support::{dispatch::DispatchResult, traits::Task, Never}; +use frame_support::dispatch::DispatchResult; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; use sp_runtime::DispatchError; -#[derive(Clone, PartialEq, Eq, Encode, Decode)] -pub enum ExampleTask { - Increment, - Decrement, - #[doc(hidden)] - #[codec(skip)] - __Ignore(PhantomData, Never), -} +#[frame_support::pallet(dev_mode)] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; -impl Task for ExampleTask { - type Enumeration = std::vec::IntoIter>; + #[derive(Clone, PartialEq, Eq, Encode, Decode)] + pub enum Task { + Increment, + Decrement, + #[doc(hidden)] + #[codec(skip)] + __Ignore(PhantomData, frame_support::Never), + } - const TASK_INDEX: usize = 0; + impl frame_support::traits::Task for Task { + type Enumeration = std::vec::IntoIter>; - fn enumerate() -> Self::Enumeration { - vec![ExampleTask::Increment, ExampleTask::Decrement].into_iter() - } + const TASK_INDEX: usize = 0; - fn is_valid(&self) -> bool { - let value = Value::::get().unwrap(); - match self { - ExampleTask::Increment => value < 255, - ExampleTask::Decrement => value > 0, - ExampleTask::__Ignore(_, _) => unreachable!(), + fn enumerate() -> Self::Enumeration { + vec![Task::Increment, Task::Decrement].into_iter() } - } - fn run(&self) -> Result<(), DispatchError> { - match self { - ExampleTask::Increment => { - // Increment the value and emit an event - let new_val = Value::::get().unwrap().checked_add(1).ok_or("Value overflow")?; - Value::::put(new_val); - Pallet::::deposit_event(Event::Incremented { new_val }); - }, - ExampleTask::Decrement => { - // Decrement the value and emit an event - let new_val = Value::::get().unwrap().checked_sub(1).ok_or("Value underflow")?; - Value::::put(new_val); - Pallet::::deposit_event(Event::Decremented { new_val }); - }, - ExampleTask::__Ignore(_, _) => unreachable!(), + fn is_valid(&self) -> bool { + let value = Value::::get().unwrap(); + match self { + Task::Increment => value < 255, + Task::Decrement => value > 0, + Task::__Ignore(_, _) => unreachable!(), + } } - Ok(()) - } -} -#[frame_support::pallet(dev_mode)] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; + fn run(&self) -> Result<(), DispatchError> { + match self { + Task::Increment => { + // Increment the value and emit an event + let new_val = + Value::::get().unwrap().checked_add(1).ok_or("Value overflow")?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Incremented { new_val }); + }, + Task::Decrement => { + // Decrement the value and emit an event + let new_val = + Value::::get().unwrap().checked_sub(1).ok_or("Value underflow")?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Decremented { new_val }); + }, + Task::__Ignore(_, _) => unreachable!(), + } + Ok(()) + } + } #[pallet::config] pub trait Config: frame_system::Config { From ba54c4e92a4198d1e586967b77d9d4fc3d58bcc3 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 20 Jul 2023 14:23:21 -0400 Subject: [PATCH 12/44] first attempt at implementing do_task * fixes Debug issue * does not fix TypeInfo requirement issue --- frame/examples/tasks-example/src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index f32339026b358..a8b70a1bb5136 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -27,6 +27,7 @@ use sp_runtime::DispatchError; #[frame_support::pallet(dev_mode)] pub mod pallet { + use super::*; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; @@ -40,6 +41,12 @@ pub mod pallet { __Ignore(PhantomData, frame_support::Never), } + impl core::fmt::Debug for Task { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("Task").field("value", self).finish() + } + } + impl frame_support::traits::Task for Task { type Enumeration = std::vec::IntoIter>; @@ -115,6 +122,17 @@ pub mod pallet { Ok(()) } + + pub fn do_task(origin: OriginFor, task: Task) -> DispatchResult { + use frame_support::traits::Task; + ensure_root(origin)?; + if task.is_valid() { + task.run()?; + Ok(()) + } else { + Err(DispatchError::Other("Invalid task")) + } + } } #[pallet::event] From acf0d27520006e5722cc1d2321e54984105d02ce Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 24 Jul 2023 12:02:11 -0400 Subject: [PATCH 13/44] bind T and Task by TypeInfo --- frame/examples/tasks-example/src/lib.rs | 12 +++++++++--- frame/support/src/traits/tasks.rs | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index a8b70a1bb5136..744ed4210ebb3 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -32,7 +32,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - #[derive(Clone, PartialEq, Eq, Encode, Decode)] + #[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo)] pub enum Task { Increment, Decrement, @@ -47,7 +47,10 @@ pub mod pallet { } } - impl frame_support::traits::Task for Task { + impl frame_support::traits::Task for Task + where + T: TypeInfo, + { type Enumeration = std::vec::IntoIter>; const TASK_INDEX: usize = 0; @@ -100,7 +103,10 @@ pub mod pallet { pub type Value = StorageValue<_, u8>; #[pallet::call] - impl Pallet { + impl Pallet + where + T: TypeInfo, + { pub fn increment(origin: OriginFor) -> DispatchResult { ensure_root(origin)?; diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index ac783f8ce434f..e7c8f6584fa1e 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -19,13 +19,14 @@ //! service work, and supporting types. use codec::FullCodec; +use scale_info::TypeInfo; use sp_runtime::DispatchError; use sp_std::iter::Iterator; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running /// tasks of this type. -pub trait Task: Sized + FullCodec { +pub trait Task: Sized + FullCodec + TypeInfo { type Enumeration: Iterator; /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. From ddc2e9dece7e3e4c86cba656fb42d88d4c9f6c40 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 3 Aug 2023 00:40:50 -0400 Subject: [PATCH 14/44] add parsing for task-related attributes --- .../procedural/src/pallet/parse/mod.rs | 1 + .../procedural/src/pallet/parse/tasks.rs | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 frame/support/procedural/src/pallet/parse/tasks.rs diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 0f5e5f1136610..5c4c4844607bf 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -33,6 +33,7 @@ pub mod inherent; pub mod origin; pub mod pallet_struct; pub mod storage; +pub mod tasks; pub mod type_value; pub mod validate_unsigned; diff --git a/frame/support/procedural/src/pallet/parse/tasks.rs b/frame/support/procedural/src/pallet/parse/tasks.rs new file mode 100644 index 0000000000000..94e5e8ef16440 --- /dev/null +++ b/frame/support/procedural/src/pallet/parse/tasks.rs @@ -0,0 +1,78 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use derive_syn_parse::Parse; +use syn::{ + token::{Bracket, Paren}, + Expr, Ident, LitInt, Token, +}; + +pub mod keywords { + use syn::custom_keyword; + + custom_keyword!(tasks); + custom_keyword!(condition); + custom_keyword!(task_index); + custom_keyword!(pallet); +} + +#[derive(Parse)] +pub enum TaskAttrType { + #[peek(keywords::tasks, name = "#[pallet::tasks(..)]")] + Tasks { + _tasks: keywords::tasks, + #[paren] + _paren: Paren, + #[inside(_paren)] + expr: Expr, + }, + #[peek(keywords::task_index, name = "#[pallet::task_index(..)")] + TaskIndex { + _task_index: keywords::task_index, + #[paren] + _paren: Paren, + #[inside(_paren)] + index: LitInt, + }, + #[peek(keywords::condition, name = "#[pallet::condition(..)")] + Condition { + _condition: keywords::condition, + #[paren] + _paren: Paren, + #[inside(_paren)] + _pipe1: Token![|], + #[inside(_paren)] + _ident: Ident, + #[inside(_paren)] + _pipe2: Token![|], + #[inside(_paren)] + expr: Expr, + }, +} + +#[derive(Parse)] +pub struct PalletTaskAttr { + _pound: Token![#], + #[bracket] + _bracket: Bracket, + #[inside(_bracket)] + _pallet: keywords::pallet, + #[inside(_bracket)] + _colons: Token![::], + #[inside(_bracket)] + attr: TaskAttrType, +} From f7ca7d5c601dd7bcd34a8d36fea54324c024b32f Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 3 Aug 2023 00:41:30 -0400 Subject: [PATCH 15/44] add tests for task related attribute macros --- .../procedural/src/pallet/parse/tasks.rs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/frame/support/procedural/src/pallet/parse/tasks.rs b/frame/support/procedural/src/pallet/parse/tasks.rs index 94e5e8ef16440..d8d575455da07 100644 --- a/frame/support/procedural/src/pallet/parse/tasks.rs +++ b/frame/support/procedural/src/pallet/parse/tasks.rs @@ -76,3 +76,34 @@ pub struct PalletTaskAttr { #[inside(_bracket)] attr: TaskAttrType, } + +#[cfg(test)] +use syn::parse2; + +#[cfg(test)] +use quote::quote; + +#[test] +fn test_parse_pallet_tasks() { + parse2::(quote!(#[pallet::tasks(Something::iter())])).unwrap(); + assert!(parse2::(quote!(#[pallet::tasks()])).is_err()); + assert!(parse2::(quote!(#[pallet::task(iter())])).is_err()); + assert!(parse2::(quote!(#[pallet::tasks])).is_err()); +} + +#[test] +fn test_parse_pallet_task_index() { + parse2::(quote!(#[pallet::task_index(3)])).unwrap(); + parse2::(quote!(#[pallet::task_index(0)])).unwrap(); + parse2::(quote!(#[pallet::task_index(17)])).unwrap(); + assert!(parse2::(quote!(#[pallet::task_index])).is_err()); + assert!(parse2::(quote!(#[pallet::task_index("hey")])).is_err()); +} + +#[test] +fn test_parse_pallet_condition() { + parse2::(quote!(#[pallet::condition(|x| x.is_some())])).unwrap(); + parse2::(quote!(#[pallet::condition(|_x| some_expr())])).unwrap(); + assert!(parse2::(quote!(#[pallet::condition(x.is_some())])).is_err()); + assert!(parse2::(quote!(#[pallet::condition(|| something())])).is_err()); +} From 4d30f6c04b538aa6c2545c5afd9c2ffc885ffb2e Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 4 Aug 2023 13:12:50 -0400 Subject: [PATCH 16/44] first stab at validate_unsigned within tasks_example pallet --- frame/examples/tasks-example/src/lib.rs | 25 +++++++++++++++++++++++ frame/system/src/lib.rs | 27 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 744ed4210ebb3..bed9011982ac2 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -141,6 +141,31 @@ pub mod pallet { } } + impl frame_support::unsigned::ValidateUnsigned for Pallet { + type Call = Call; + + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + // TODO: verify `source` ? + use frame_support::traits::Task; + match call { + Call::do_task { task } => { + if task.is_valid() { + Ok(ValidTransaction { + priority: 0, // TODO: make configurable on Task? + requires: vec![], + provides: vec![task.encode()], + longevity: TransactionLongevity::max_value(), + propagate: true, + }) + } else { + InvalidTransaction::Custom(1u8).into() // TODO: custom error enum for this? + } + }, + _ => InvalidTransaction::Call.into(), + } + } + } + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 56006269ab1df..e0be86c02c1ee 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -675,6 +675,33 @@ pub mod pallet { sp_io::storage::set(well_known_keys::EXTRINSIC_INDEX, &0u32.encode()); } } + + // #[pallet::validate_unsigned] + // impl ValidateUnsigned for Pallet { + // type Call = Call; + + // fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + // if let Call::do_task(task) = call { + // if task.is_valid() { + // // Specify the task priority here. The priority is used to order transactions + // // which are included in the same block. For simplicity, all tasks here are + // // given the same priority. You may want to refine this to assign different + // // priorities to different tasks. + // Ok(ValidTransaction { + // priority: 0, + // requires: vec![], + // provides: vec![], + // longevity: TransactionLongevity::max_value(), + // propagate: true, + // }) + // } else { + // Err(InvalidTransaction::Stale.into()) + // } + // } else { + // Err(InvalidTransaction::Call.into()) + // } + // } + // } } pub type Key = Vec; From 34e09905f68debca85681ab26fbb6facaa40f061 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 4 Aug 2023 13:19:27 -0400 Subject: [PATCH 17/44] add comments --- frame/examples/tasks-example/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index bed9011982ac2..04b2b2c568972 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -141,6 +141,10 @@ pub mod pallet { } } + // We can actually auto-impl this in the macros if an existing + // `ValidateUnsigned` impl is not present. If one is present, we just wouldn't emit an + // impl for this. An existing impl will be easy to find using a simple visitor pattern in + // the macros. impl frame_support::unsigned::ValidateUnsigned for Pallet { type Call = Call; From f29f0a034b39ca6fbe90103f02e80ca07552dc84 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 4 Aug 2023 13:25:12 -0400 Subject: [PATCH 18/44] clean up --- frame/examples/tasks-example/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 04b2b2c568972..4d414c0eefbc0 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -32,6 +32,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + // this can be auto-generated from the macros #[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo)] pub enum Task { Increment, @@ -41,12 +42,14 @@ pub mod pallet { __Ignore(PhantomData, frame_support::Never), } + // this can be auto-generated from the macros and will always be the same impl core::fmt::Debug for Task { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("Task").field("value", self).finish() } } + // this can be auto-generated from the macros impl frame_support::traits::Task for Task where T: TypeInfo, @@ -129,6 +132,7 @@ pub mod pallet { Ok(()) } + // this will be auto-generated by the macros and will always be the same pub fn do_task(origin: OriginFor, task: Task) -> DispatchResult { use frame_support::traits::Task; ensure_root(origin)?; @@ -141,14 +145,13 @@ pub mod pallet { } } - // We can actually auto-impl this in the macros if an existing - // `ValidateUnsigned` impl is not present. If one is present, we just wouldn't emit an - // impl for this. An existing impl will be easy to find using a simple visitor pattern in - // the macros. + // I think we can actually auto-impl this in the macros if an existing `ValidateUnsigned` + // impl is not present. If one is present, we just wouldn't emit an impl for this. An + // existing impl will be easy to find using a simple visitor pattern in the macros. impl frame_support::unsigned::ValidateUnsigned for Pallet { type Call = Call; - fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { // TODO: verify `source` ? use frame_support::traits::Task; match call { @@ -162,7 +165,9 @@ pub mod pallet { propagate: true, }) } else { - InvalidTransaction::Custom(1u8).into() // TODO: custom error enum for this? + InvalidTransaction::Custom(1u8).into() + // TODO: custom error enum for this? Maybe we can put it in some + // globally accessible place? Or just always generate the same enum? } }, _ => InvalidTransaction::Call.into(), From 36dae4333e6f49637a30141039a62dfb5155b198 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 4 Aug 2023 13:46:32 -0400 Subject: [PATCH 19/44] improve scaffold a bit --- frame/examples/tasks-example/src/lib.rs | 50 +++++++++++++++++-------- frame/system/src/lib.rs | 44 +++++++++++----------- 2 files changed, 57 insertions(+), 37 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 4d414c0eefbc0..34f9207de4254 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -49,7 +49,19 @@ pub mod pallet { } } - // this can be auto-generated from the macros + // we can automatically inject `InvalidTask` into an existing Error enum by finding it via + // visitor pattern, otherwise we can just emit an error enum containing just our + // `InvalidTask` variant. Alternatively we could just expect that `InvalidTask` is included + // in the error enum, by convention, or we could use something like + // `InvalidTransaction::Custom(1u8)` but this seems bad to me. + #[pallet::error] + pub enum Error { + InvalidTask, + ValueOverflow, + ValueUnderflow, + } + + // this will be auto-generated from `#[pallet::tasks]` impl frame_support::traits::Task for Task where T: TypeInfo, @@ -74,22 +86,31 @@ pub mod pallet { fn run(&self) -> Result<(), DispatchError> { match self { Task::Increment => { - // Increment the value and emit an event - let new_val = - Value::::get().unwrap().checked_add(1).ok_or("Value overflow")?; - Value::::put(new_val); - Pallet::::deposit_event(Event::Incremented { new_val }); + // Get the value and check if it can be incremented + let value = Value::::get().unwrap_or_default(); + if value >= 255 { + Err(Error::::ValueOverflow.into()) + } else { + let new_val = value.checked_add(1).ok_or(Error::::ValueOverflow)?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Incremented { new_val }); + Ok(()) + } }, Task::Decrement => { - // Decrement the value and emit an event - let new_val = - Value::::get().unwrap().checked_sub(1).ok_or("Value underflow")?; - Value::::put(new_val); - Pallet::::deposit_event(Event::Decremented { new_val }); + // Get the value and check if it can be decremented + let value = Value::::get().unwrap_or_default(); + if value == 0 { + Err(Error::::ValueUnderflow.into()) + } else { + let new_val = value.checked_sub(1).ok_or(Error::::ValueUnderflow)?; + Value::::put(new_val); + Pallet::::deposit_event(Event::Decremented { new_val }); + Ok(()) + } }, Task::__Ignore(_, _) => unreachable!(), } - Ok(()) } } @@ -137,10 +158,9 @@ pub mod pallet { use frame_support::traits::Task; ensure_root(origin)?; if task.is_valid() { - task.run()?; - Ok(()) + task.run() } else { - Err(DispatchError::Other("Invalid task")) + Err(Error::::InvalidTask.into()) } } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index e0be86c02c1ee..80722715e73da 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -676,32 +676,32 @@ pub mod pallet { } } - // #[pallet::validate_unsigned] - // impl ValidateUnsigned for Pallet { - // type Call = Call; - - // fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { - // if let Call::do_task(task) = call { - // if task.is_valid() { - // // Specify the task priority here. The priority is used to order transactions - // // which are included in the same block. For simplicity, all tasks here are - // // given the same priority. You may want to refine this to assign different - // // priorities to different tasks. - // Ok(ValidTransaction { - // priority: 0, - // requires: vec![], - // provides: vec![], - // longevity: TransactionLongevity::max_value(), - // propagate: true, - // }) + // #[pallet::validate_unsigned] + // impl ValidateUnsigned for Pallet { + // type Call = Call; + + // fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + // if let Call::do_task(task) = call { + // if task.is_valid() { + // // Specify the task priority here. The priority is used to order transactions + // // which are included in the same block. For simplicity, all tasks here are + // // given the same priority. You may want to refine this to assign different + // // priorities to different tasks. + // Ok(ValidTransaction { + // priority: 0, + // requires: vec![], + // provides: vec![], + // longevity: TransactionLongevity::max_value(), + // propagate: true, + // }) + // } else { + // Err(InvalidTransaction::Stale.into()) + // } // } else { - // Err(InvalidTransaction::Stale.into()) + // Err(InvalidTransaction::Call.into()) // } - // } else { - // Err(InvalidTransaction::Call.into()) // } // } - // } } pub type Key = Vec; From d20f3125f46880c51809fa37e79d3933d14ee28d Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 4 Aug 2023 13:56:09 -0400 Subject: [PATCH 20/44] rename inner `#[pallet::tasks()]` to #[pallet::task_list(..)]` to reduce confusion --- .../procedural/src/pallet/parse/tasks.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/frame/support/procedural/src/pallet/parse/tasks.rs b/frame/support/procedural/src/pallet/parse/tasks.rs index d8d575455da07..568e4657eb378 100644 --- a/frame/support/procedural/src/pallet/parse/tasks.rs +++ b/frame/support/procedural/src/pallet/parse/tasks.rs @@ -25,6 +25,7 @@ pub mod keywords { use syn::custom_keyword; custom_keyword!(tasks); + custom_keyword!(task_list); custom_keyword!(condition); custom_keyword!(task_index); custom_keyword!(pallet); @@ -32,9 +33,9 @@ pub mod keywords { #[derive(Parse)] pub enum TaskAttrType { - #[peek(keywords::tasks, name = "#[pallet::tasks(..)]")] - Tasks { - _tasks: keywords::tasks, + #[peek(keywords::task_list, name = "#[pallet::task_list(..)]")] + TaskList { + _tasks: keywords::task_list, #[paren] _paren: Paren, #[inside(_paren)] @@ -62,6 +63,7 @@ pub enum TaskAttrType { #[inside(_paren)] expr: Expr, }, + // TODO: Tasks } #[derive(Parse)] @@ -84,11 +86,11 @@ use syn::parse2; use quote::quote; #[test] -fn test_parse_pallet_tasks() { - parse2::(quote!(#[pallet::tasks(Something::iter())])).unwrap(); - assert!(parse2::(quote!(#[pallet::tasks()])).is_err()); - assert!(parse2::(quote!(#[pallet::task(iter())])).is_err()); - assert!(parse2::(quote!(#[pallet::tasks])).is_err()); +fn test_parse_pallet_task_list_() { + parse2::(quote!(#[pallet::task_list(Something::iter())])).unwrap(); + assert!(parse2::(quote!(#[pallet::task_list()])).is_err()); + assert!(parse2::(quote!(#[pallet::tasks_list(iter())])).is_err()); + assert!(parse2::(quote!(#[pallet::task_list])).is_err()); } #[test] From af70bd90b023018b05d440cd96a982996c44bc6d Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 7 Aug 2023 15:18:08 -0400 Subject: [PATCH 21/44] add Task as a composite enum --- frame/support/procedural/src/construct_runtime/parse.rs | 6 ++++++ .../procedural/src/pallet/expand/tt_default_parts.rs | 8 +++++++- frame/support/procedural/src/pallet/parse/composite.rs | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 9b08e16469754..a0554b0782de4 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -42,6 +42,7 @@ mod keyword { syn::custom_keyword!(ValidateUnsigned); syn::custom_keyword!(FreezeReason); syn::custom_keyword!(HoldReason); + syn::custom_keyword!(Task); syn::custom_keyword!(LockId); syn::custom_keyword!(SlashReason); syn::custom_keyword!(exclude_parts); @@ -404,6 +405,7 @@ pub enum PalletPartKeyword { ValidateUnsigned(keyword::ValidateUnsigned), FreezeReason(keyword::FreezeReason), HoldReason(keyword::HoldReason), + Task(keyword::Task), LockId(keyword::LockId), SlashReason(keyword::SlashReason), } @@ -434,6 +436,8 @@ impl Parse for PalletPartKeyword { Ok(Self::FreezeReason(input.parse()?)) } else if lookahead.peek(keyword::HoldReason) { Ok(Self::HoldReason(input.parse()?)) + } else if lookahead.peek(keyword::Task) { + Ok(Self::Task(input.parse()?)) } else if lookahead.peek(keyword::LockId) { Ok(Self::LockId(input.parse()?)) } else if lookahead.peek(keyword::SlashReason) { @@ -459,6 +463,7 @@ impl PalletPartKeyword { Self::ValidateUnsigned(_) => "ValidateUnsigned", Self::FreezeReason(_) => "FreezeReason", Self::HoldReason(_) => "HoldReason", + Self::Task(_) => "Task", Self::LockId(_) => "LockId", Self::SlashReason(_) => "SlashReason", } @@ -489,6 +494,7 @@ impl ToTokens for PalletPartKeyword { Self::ValidateUnsigned(inner) => inner.to_tokens(tokens), Self::FreezeReason(inner) => inner.to_tokens(tokens), Self::HoldReason(inner) => inner.to_tokens(tokens), + Self::Task(inner) => inner.to_tokens(tokens), Self::LockId(inner) => inner.to_tokens(tokens), Self::SlashReason(inner) => inner.to_tokens(tokens), } diff --git a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs index 356bdbf67e923..ac5a6561c5428 100644 --- a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs +++ b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs @@ -67,6 +67,12 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream { .any(|c| matches!(c.composite_keyword, CompositeKeyword::HoldReason(_))) .then_some(quote::quote!(HoldReason,)); + let task_part = def + .composites + .iter() + .any(|c| matches!(c.composite_keyword, CompositeKeyword::Task(_))) + .then_some(quote::quote!(Task,)); + let lock_id_part = def .composites .iter() @@ -101,7 +107,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream { tokens = [{ expanded::{ Pallet, #call_part #storage_part #event_part #error_part #origin_part #config_part - #inherent_part #validate_unsigned_part #freeze_reason_part + #inherent_part #validate_unsigned_part #freeze_reason_part #task_part #hold_reason_part #lock_id_part #slash_reason_part } }] diff --git a/frame/support/procedural/src/pallet/parse/composite.rs b/frame/support/procedural/src/pallet/parse/composite.rs index 2bbfcd2e998ab..04b853e62dc4c 100644 --- a/frame/support/procedural/src/pallet/parse/composite.rs +++ b/frame/support/procedural/src/pallet/parse/composite.rs @@ -25,11 +25,14 @@ pub mod keyword { syn::custom_keyword!(HoldReason); syn::custom_keyword!(LockId); syn::custom_keyword!(SlashReason); + syn::custom_keyword!(Task); + pub enum CompositeKeyword { FreezeReason(FreezeReason), HoldReason(HoldReason), LockId(LockId), SlashReason(SlashReason), + Task(Task), } impl ToTokens for CompositeKeyword { @@ -40,6 +43,7 @@ pub mod keyword { HoldReason(inner) => inner.to_tokens(tokens), LockId(inner) => inner.to_tokens(tokens), SlashReason(inner) => inner.to_tokens(tokens), + Task(inner) => inner.to_tokens(tokens), } } } @@ -55,6 +59,8 @@ pub mod keyword { Ok(Self::LockId(input.parse()?)) } else if lookahead.peek(SlashReason) { Ok(Self::SlashReason(input.parse()?)) + } else if lookahead.peek(Task) { + Ok(Self::Task(input.parse()?)) } else { Err(lookahead.error()) } @@ -70,6 +76,7 @@ pub mod keyword { match self { FreezeReason(_) => "FreezeReason", HoldReason(_) => "HoldReason", + Task(_) => "Task", LockId(_) => "LockId", SlashReason(_) => "SlashReason", } @@ -79,7 +86,7 @@ pub mod keyword { } pub struct CompositeDef { - /// The index of the HoldReason item in the pallet module. + /// The index of the CompositeDef item in the pallet module. pub index: usize, /// The composite keyword used (contains span). pub composite_keyword: keyword::CompositeKeyword, From 260a715f4bc4234bab02b22fa47c6e8f76721800 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Tue, 8 Aug 2023 03:32:03 -0400 Subject: [PATCH 22/44] hook up RuntimeTask to construct_runtime --- .../src/construct_runtime/expand/mod.rs | 2 + .../src/construct_runtime/expand/task.rs | 69 +++++++++++++++++++ .../procedural/src/construct_runtime/mod.rs | 3 + frame/system/src/lib.rs | 7 ++ 4 files changed, 81 insertions(+) create mode 100644 frame/support/procedural/src/construct_runtime/expand/task.rs diff --git a/frame/support/procedural/src/construct_runtime/expand/mod.rs b/frame/support/procedural/src/construct_runtime/expand/mod.rs index 830338f9265ff..9dab9f664094a 100644 --- a/frame/support/procedural/src/construct_runtime/expand/mod.rs +++ b/frame/support/procedural/src/construct_runtime/expand/mod.rs @@ -25,6 +25,7 @@ mod metadata; mod origin; mod outer_enums; mod slash_reason; +mod task; mod unsigned; pub use call::expand_outer_dispatch; @@ -37,4 +38,5 @@ pub use metadata::expand_runtime_metadata; pub use origin::expand_outer_origin; pub use outer_enums::{expand_outer_enum, OuterEnumType}; pub use slash_reason::expand_outer_slash_reason; +pub use task::expand_outer_task; pub use unsigned::expand_outer_validate_unsigned; diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs new file mode 100644 index 0000000000000..6446f8d8739a8 --- /dev/null +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -0,0 +1,69 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + +use crate::construct_runtime::{parse::PalletPath, Pallet}; +use proc_macro2::{Ident, TokenStream}; +use quote::quote; + +/// Expands aggregate `RuntimeTask` enum. +pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> TokenStream { + let mut conversion_fns = Vec::new(); + let mut task_variants = Vec::new(); + for decl in pallet_decls { + if let Some(_) = decl.find_part("Task") { + let variant_name = &decl.name; + let path = &decl.path; + let index = decl.index; + + conversion_fns.push(expand_conversion_fn(path, variant_name)); + + task_variants.push(expand_variant(index, path, variant_name)); + } + } + + quote! { + /// An aggregation of all `Task` enums across all pallets included in the current runtime. + #[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, + #scrate::codec::Encode, #scrate::codec::Decode, #scrate::codec::MaxEncodedLen, + #scrate::scale_info::TypeInfo, + #scrate::RuntimeDebug, + )] + pub enum RuntimeTask { + #( #task_variants )* + } + + #( #conversion_fns )* + } +} + +fn expand_conversion_fn(path: &PalletPath, variant_name: &Ident) -> TokenStream { + quote! { + impl From<#path::Task> for RuntimeTask { + fn from(hr: #path::Task) -> Self { + RuntimeTask::#variant_name(hr) + } + } + } +} + +fn expand_variant(index: u8, path: &PalletPath, variant_name: &Ident) -> TokenStream { + quote! { + #[codec(index = #index)] + #variant_name(#path::Task), + } +} diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index efc2244154479..c4a3c0cbd5a35 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -385,6 +385,7 @@ fn construct_runtime_final_expansion( let pallet_to_index = decl_pallet_runtime_setup(&name, &pallets, &scrate); let dispatch = expand::expand_outer_dispatch(&name, system_pallet, &pallets, &scrate); + let tasks = expand::expand_outer_task(&pallets, &scrate); let metadata = expand::expand_runtime_metadata( &name, &pallets, @@ -472,6 +473,8 @@ fn construct_runtime_final_expansion( #dispatch + #tasks + #metadata #outer_config diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 80722715e73da..0f60d73055dda 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -500,6 +500,13 @@ pub mod pallet { Self::deposit_event(Event::Remarked { sender: who, hash }); Ok(().into()) } + + // #[pallet::call_index(8)] + // #[pallet::weight(0)] + // pub fn do_task(origin: OriginFor, task: Task) -> DispatchResultWithPostInfo { + // let who = ensure_signed(origin)?; + // Ok(().into()) + // } } /// Event for the System pallet. From a0fc4c89c4289f65575741007951b7becaa39c1a Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 9 Aug 2023 14:16:28 -0400 Subject: [PATCH 23/44] do_task system pallet extrinsic WIP (solved RuntimeTask issue) --- frame/examples/tasks-example/src/lib.rs | 4 ++++ frame/support/src/traits/tasks.rs | 8 ++++++-- frame/system/src/lib.rs | 17 ++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 34f9207de4254..83eef53eb0aac 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -112,6 +112,10 @@ pub mod pallet { Task::__Ignore(_, _) => unreachable!(), } } + + fn weight(&self) -> Weight { + Weight::default() + } } #[pallet::config] diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index e7c8f6584fa1e..2a463a51ddd60 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -21,12 +21,13 @@ use codec::FullCodec; use scale_info::TypeInfo; use sp_runtime::DispatchError; -use sp_std::iter::Iterator; +use sp_std::{fmt::Debug, iter::Iterator}; +use sp_weights::Weight; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running /// tasks of this type. -pub trait Task: Sized + FullCodec + TypeInfo { +pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { type Enumeration: Iterator; /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. @@ -40,4 +41,7 @@ pub trait Task: Sized + FullCodec + TypeInfo { /// Performs the work for this particular `Task` variant. fn run(&self) -> Result<(), DispatchError>; + + /// Returns the weight of executing this `Task`. + fn weight(&self) -> Weight; } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 0f60d73055dda..580b444d648a0 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -86,7 +86,7 @@ use sp_version::RuntimeVersion; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; #[cfg(feature = "std")] -use frame_support::traits::BuildGenesisConfig; +use frame_support::traits::{BuildGenesisConfig, Task}; use frame_support::{ dispatch::{ extract_actual_pays_fee, extract_actual_weight, DispatchClass, DispatchInfo, @@ -273,6 +273,9 @@ pub mod pallet { + Debug + From>; + #[pallet::no_default] + type RuntimeTask: Task; + /// This stores the number of previous transactions associated with a sender account. type Nonce: Parameter + Member @@ -501,12 +504,12 @@ pub mod pallet { Ok(().into()) } - // #[pallet::call_index(8)] - // #[pallet::weight(0)] - // pub fn do_task(origin: OriginFor, task: Task) -> DispatchResultWithPostInfo { - // let who = ensure_signed(origin)?; - // Ok(().into()) - // } + #[pallet::call_index(8)] + #[pallet::weight(task.weight())] + pub fn do_task(origin: OriginFor, task: T::RuntimeTask) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + Ok(().into()) + } } /// Event for the System pallet. From 49353a7fd5c9e0e7c1f376be3bc26ec8fb1e5739 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 10 Aug 2023 01:55:40 -0400 Subject: [PATCH 24/44] do_task extrinsic on system pallet done --- frame/examples/tasks-example/src/lib.rs | 2 +- frame/support/src/traits/tasks.rs | 24 +++++++++++++++++++++++- frame/system/src/lib.rs | 17 ++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 83eef53eb0aac..4b0e4f3c8187e 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -68,7 +68,7 @@ pub mod pallet { { type Enumeration = std::vec::IntoIter>; - const TASK_INDEX: usize = 0; + const TASK_INDEX: u64 = 0; fn enumerate() -> Self::Enumeration { vec![Task::Increment, Task::Decrement].into_iter() diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 2a463a51ddd60..6b04bbcb22d08 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -20,6 +20,7 @@ use codec::FullCodec; use scale_info::TypeInfo; +use sp_core::blake2_128; use sp_runtime::DispatchError; use sp_std::{fmt::Debug, iter::Iterator}; use sp_weights::Weight; @@ -31,7 +32,7 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { type Enumeration: Iterator; /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. - const TASK_INDEX: usize; + const TASK_INDEX: u64; /// Inspects the pallet's state and enumerates tasks of this type. fn enumerate() -> Self::Enumeration; @@ -44,4 +45,25 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { /// Returns the weight of executing this `Task`. fn weight(&self) -> Weight; + + fn task_index(&self) -> u64 { + Self::TASK_INDEX + } + + /// Returns a 64-bit hash code uniquely identifying this task and its inputs and associated + /// data based on the full 256-bit Blake2 hash code. This is used in the `InvalidTask` + /// event to differentiate between instances of the same task. + fn hash_code(&self) -> u64 { + let full_hash = blake2_128(&self.encode()); + u64::from_le_bytes([ + full_hash[0], + full_hash[1], + full_hash[2], + full_hash[3], + full_hash[4], + full_hash[5], + full_hash[6], + full_hash[7], + ]) + } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 580b444d648a0..1a71e03edae10 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -507,7 +507,18 @@ pub mod pallet { #[pallet::call_index(8)] #[pallet::weight(task.weight())] pub fn do_task(origin: OriginFor, task: T::RuntimeTask) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; + ensure_signed(origin)?; + + if !task.is_valid() { + return Err(Error::::InvalidTask { hashcode: task.hash_code() }.into()) + } + + task.run()?; + + // Emit a success event, if your design includes events for this pallet. + Self::deposit_event(Event::TaskCompleted { task }); + + // Return success. Ok(().into()) } } @@ -527,6 +538,8 @@ pub mod pallet { KilledAccount { account: T::AccountId }, /// On on-chain remark happened. Remarked { sender: T::AccountId, hash: T::Hash }, + /// A task has finished executing. + TaskCompleted { task: T::RuntimeTask }, } /// Error for the System pallet @@ -548,6 +561,8 @@ pub mod pallet { NonZeroRefCount, /// The origin filter prevent the call to be dispatched. CallFiltered, + /// The specified `Task` is not valid + InvalidTask { hashcode: u64 }, } /// Exposed trait-generic origin type. From 4ac3fc71bb0cf76102b6d42bcf5b6910904ca3b7 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 10 Aug 2023 02:06:56 -0400 Subject: [PATCH 25/44] fix comment --- frame/support/src/traits/tasks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 6b04bbcb22d08..24fbe47f42a80 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -51,7 +51,7 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { } /// Returns a 64-bit hash code uniquely identifying this task and its inputs and associated - /// data based on the full 256-bit Blake2 hash code. This is used in the `InvalidTask` + /// data based on the full 128-bit Blake2 hash code. This is used in the `InvalidTask` /// event to differentiate between instances of the same task. fn hash_code(&self) -> u64 { let full_hash = blake2_128(&self.encode()); From b26602d1f41e9213eba8bdd0cf571c5392aa6b27 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 10 Aug 2023 12:15:10 -0400 Subject: [PATCH 26/44] suppress warning --- frame/support/procedural/src/pallet/parse/tasks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/parse/tasks.rs b/frame/support/procedural/src/pallet/parse/tasks.rs index 568e4657eb378..bdfae571cd97f 100644 --- a/frame/support/procedural/src/pallet/parse/tasks.rs +++ b/frame/support/procedural/src/pallet/parse/tasks.rs @@ -76,7 +76,7 @@ pub struct PalletTaskAttr { #[inside(_bracket)] _colons: Token![::], #[inside(_bracket)] - attr: TaskAttrType, + _attr: TaskAttrType, } #[cfg(test)] From a40a03ea891efe6eb7508797e0ced07850a2aaf6 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 10 Aug 2023 12:15:22 -0400 Subject: [PATCH 27/44] context information on #[pallet::error] = bad --- frame/support/src/traits/tasks.rs | 18 ------------------ frame/system/src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 24fbe47f42a80..145ec72483048 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -20,7 +20,6 @@ use codec::FullCodec; use scale_info::TypeInfo; -use sp_core::blake2_128; use sp_runtime::DispatchError; use sp_std::{fmt::Debug, iter::Iterator}; use sp_weights::Weight; @@ -49,21 +48,4 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { fn task_index(&self) -> u64 { Self::TASK_INDEX } - - /// Returns a 64-bit hash code uniquely identifying this task and its inputs and associated - /// data based on the full 128-bit Blake2 hash code. This is used in the `InvalidTask` - /// event to differentiate between instances of the same task. - fn hash_code(&self) -> u64 { - let full_hash = blake2_128(&self.encode()); - u64::from_le_bytes([ - full_hash[0], - full_hash[1], - full_hash[2], - full_hash[3], - full_hash[4], - full_hash[5], - full_hash[6], - full_hash[7], - ]) - } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 1a71e03edae10..a82be3170b7a8 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -510,7 +510,7 @@ pub mod pallet { ensure_signed(origin)?; if !task.is_valid() { - return Err(Error::::InvalidTask { hashcode: task.hash_code() }.into()) + return Err(Error::::InvalidTask.into()) } task.run()?; @@ -562,7 +562,7 @@ pub mod pallet { /// The origin filter prevent the call to be dispatched. CallFiltered, /// The specified `Task` is not valid - InvalidTask { hashcode: u64 }, + InvalidTask, } /// Exposed trait-generic origin type. From 131766fdc9a1a636a9007ecf5f3801eff67600bf Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 10 Aug 2023 15:16:15 -0400 Subject: [PATCH 28/44] very granular task-related events (will probably reduce this) --- frame/system/src/lib.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index a82be3170b7a8..a464df0611e67 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -203,6 +203,9 @@ pub mod pallet { use crate::{self as frame_system, pallet_prelude::*, *}; use frame_support::pallet_prelude::*; + #[cfg(doc)] + use frame_support::traits::Task; + /// Contains default types suitable for various environments pub mod config_preludes { use super::DefaultConfig; @@ -510,10 +513,15 @@ pub mod pallet { ensure_signed(origin)?; if !task.is_valid() { + Self::deposit_event(Event::TaskInvalid { task }); return Err(Error::::InvalidTask.into()) } - task.run()?; + Self::deposit_event(Event::TaskStarted { task: task.clone() }); + if let Err(err) = task.run() { + Self::deposit_event(Event::TaskFailed { task, err }); + return Err(Error::::FailedTask.into()) + } // Emit a success event, if your design includes events for this pallet. Self::deposit_event(Event::TaskCompleted { task }); @@ -538,8 +546,14 @@ pub mod pallet { KilledAccount { account: T::AccountId }, /// On on-chain remark happened. Remarked { sender: T::AccountId, hash: T::Hash }, - /// A task has finished executing. + /// A [`Task`] has started executing + TaskStarted { task: T::RuntimeTask }, + /// A [`Task`] has finished executing. TaskCompleted { task: T::RuntimeTask }, + /// An attempt was made to run an invalid [`Task`]. + TaskInvalid { task: T::RuntimeTask }, + /// A [`Task`] failed during execution. + TaskFailed { task: T::RuntimeTask, err: DispatchError }, } /// Error for the System pallet @@ -561,8 +575,10 @@ pub mod pallet { NonZeroRefCount, /// The origin filter prevent the call to be dispatched. CallFiltered, - /// The specified `Task` is not valid + /// The specified [`Task`] is not valid. InvalidTask, + /// The specified [`Task`] failed during execution. + FailedTask, } /// Exposed trait-generic origin type. From 6be3ce34567932284e0eadea43fdcae95247f7ba Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 12:26:37 -0400 Subject: [PATCH 29/44] clean up old code --- frame/system/src/lib.rs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index a464df0611e67..b463d869bbc49 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -716,33 +716,6 @@ pub mod pallet { sp_io::storage::set(well_known_keys::EXTRINSIC_INDEX, &0u32.encode()); } } - - // #[pallet::validate_unsigned] - // impl ValidateUnsigned for Pallet { - // type Call = Call; - - // fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { - // if let Call::do_task(task) = call { - // if task.is_valid() { - // // Specify the task priority here. The priority is used to order transactions - // // which are included in the same block. For simplicity, all tasks here are - // // given the same priority. You may want to refine this to assign different - // // priorities to different tasks. - // Ok(ValidTransaction { - // priority: 0, - // requires: vec![], - // provides: vec![], - // longevity: TransactionLongevity::max_value(), - // propagate: true, - // }) - // } else { - // Err(InvalidTransaction::Stale.into()) - // } - // } else { - // Err(InvalidTransaction::Call.into()) - // } - // } - // } } pub type Key = Vec; From b553a3b2e6fc997a1ee6083b58e898743f752121 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 12:33:24 -0400 Subject: [PATCH 30/44] remove TaskInvalid event based on feedback --- frame/system/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index b463d869bbc49..30f84f98821eb 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -513,7 +513,6 @@ pub mod pallet { ensure_signed(origin)?; if !task.is_valid() { - Self::deposit_event(Event::TaskInvalid { task }); return Err(Error::::InvalidTask.into()) } @@ -550,8 +549,6 @@ pub mod pallet { TaskStarted { task: T::RuntimeTask }, /// A [`Task`] has finished executing. TaskCompleted { task: T::RuntimeTask }, - /// An attempt was made to run an invalid [`Task`]. - TaskInvalid { task: T::RuntimeTask }, /// A [`Task`] failed during execution. TaskFailed { task: T::RuntimeTask, err: DispatchError }, } From 45e69f8fc9bb1efce90c9f93950bfad0edf3266b Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 13:56:47 -0400 Subject: [PATCH 31/44] add AggregatedTask trait which we can use in RuntimeTask --- frame/support/src/traits/tasks.rs | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 145ec72483048..69d46f1e0dd41 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -18,11 +18,17 @@ //! Contains the [`Task`] trait, which defines a general-purpose way for defining and executing //! service work, and supporting types. -use codec::FullCodec; -use scale_info::TypeInfo; -use sp_runtime::DispatchError; -use sp_std::{fmt::Debug, iter::Iterator}; -use sp_weights::Weight; +/// Contain's re-exports of all the supporting types for the [`Task`] trait. Used in the macro +/// expansion of `RuntimeTask`. +pub mod task_prelude { + pub use codec::FullCodec; + pub use scale_info::TypeInfo; + pub use sp_runtime::DispatchError; + pub use sp_std::{fmt::Debug, iter::Iterator}; + pub use sp_weights::Weight; +} + +use task_prelude::*; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running @@ -45,7 +51,24 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { /// Returns the weight of executing this `Task`. fn weight(&self) -> Weight; + /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. fn task_index(&self) -> u64 { Self::TASK_INDEX } } + +/// Contains a subset of [`Task`] that can be generalized over the aggregated `RuntimeTask` +/// enum. +pub trait AggregatedTask: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq { + /// Checks if a particular instance of this `Task` variant is a valid piece of work. + fn is_valid(&self) -> bool; + + /// Performs the work for this particular `Task` variant. + fn run(&self) -> Result<(), DispatchError>; + + /// Returns the weight of executing this `Task`. + fn weight(&self) -> Weight; + + /// A unique value representing this `Task`. Analogous to `call_index`, but for tasks. + fn task_index(&self) -> u64; +} From af5f4690f173a96bbd67efe073ffad229f0e2473 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 14:00:19 -0400 Subject: [PATCH 32/44] add tasks-example pallet to construct_runtime temporarily for testing --- Cargo.lock | 1 + bin/node/runtime/Cargo.toml | 1 + bin/node/runtime/src/lib.rs | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c63938f184c55..c7c97f84b1279 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3833,6 +3833,7 @@ dependencies = [ "sp-version", "static_assertions", "substrate-wasm-builder", + "tasks-example", ] [[package]] diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index de0ec1a5489a8..255a495489158 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -127,6 +127,7 @@ pallet-transaction-storage = { version = "4.0.0-dev", default-features = false, pallet-uniques = { version = "4.0.0-dev", default-features = false, path = "../../../frame/uniques" } pallet-vesting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/vesting" } pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" } +tasks-example = { version = "4.0.0-dev", path = '../../../frame/examples/tasks-example', default-features = false } [build-dependencies] substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 29aaaf5fdad5a..219c0fef012f3 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -83,6 +83,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; use static_assertions::const_assert; +use tasks_example; #[cfg(any(feature = "std", test))] pub use frame_system::Call as SystemCall; @@ -224,6 +225,7 @@ impl frame_system::Config for Runtime { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = Hash; type Hashing = BlakeTwo256; @@ -248,6 +250,7 @@ impl pallet_insecure_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -262,6 +265,7 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -344,6 +348,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -366,6 +371,7 @@ impl pallet_scheduler::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; #[cfg(feature = "runtime-benchmarks")] @@ -883,6 +889,7 @@ pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -903,6 +910,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -1231,6 +1239,7 @@ impl pallet_contracts::Config for Runtime { type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1265,6 +1274,7 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type WeightInfo = pallet_sudo::weights::SubstrateWeight; } @@ -1404,6 +1414,7 @@ impl pallet_recovery::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1476,6 +1487,7 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type RuntimeEvent = RuntimeEvent; @@ -1746,6 +1758,7 @@ impl pallet_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1757,6 +1770,7 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type Preimages = Preimage; @@ -1946,6 +1960,7 @@ construct_runtime!( MessageQueue: pallet_message_queue, Pov: frame_benchmarking_pallet_pov, Statement: pallet_statement, + Tasks: pallet_tasks, } ); From de82efec7afa6160e42f0ad4ce3cee97fa89d6ae Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 14:03:57 -0400 Subject: [PATCH 33/44] refine tasks re-export paths --- frame/support/src/traits.rs | 2 +- frame/system/src/lib.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 950e7bb4d3bc0..2d18648ce5384 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -117,7 +117,7 @@ pub use messages::{ }; pub mod tasks; -pub use tasks::*; +pub use tasks::{AggregatedTask, Task}; #[cfg(feature = "try-runtime")] mod try_runtime; diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 30f84f98821eb..0e6b24faed0aa 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -201,10 +201,7 @@ impl, MaxOverflow: Get> ConsumerLimits for (MaxNormal, #[frame_support::pallet] pub mod pallet { use crate::{self as frame_system, pallet_prelude::*, *}; - use frame_support::pallet_prelude::*; - - #[cfg(doc)] - use frame_support::traits::Task; + use frame_support::{pallet_prelude::*, traits::Task}; /// Contains default types suitable for various environments pub mod config_preludes { @@ -277,7 +274,7 @@ pub mod pallet { + From>; #[pallet::no_default] - type RuntimeTask: Task; + type RuntimeTask: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq; /// This stores the number of previous transactions associated with a sender account. type Nonce: Parameter From 923cfc8450c611532cbf76e15b9cf1f402080a35 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 14:06:18 -0400 Subject: [PATCH 34/44] inject `RuntimeTask` into all construct_runtime!'s --- bin/node-template/pallets/template/src/mock.rs | 1 + bin/node-template/runtime/src/lib.rs | 2 ++ docs/Upgrading-2.0-to-3.0.md | 1 + frame/alliance/src/mock.rs | 1 + frame/asset-conversion/src/mock.rs | 1 + frame/asset-rate/src/mock.rs | 1 + frame/assets/src/mock.rs | 1 + frame/atomic-swap/src/tests.rs | 1 + frame/aura/src/mock.rs | 1 + frame/authority-discovery/src/lib.rs | 1 + frame/authorship/src/lib.rs | 1 + frame/babe/src/mock.rs | 1 + frame/bags-list/src/mock.rs | 1 + frame/balances/src/tests/mod.rs | 1 + frame/beefy-mmr/src/mock.rs | 1 + frame/beefy/src/mock.rs | 1 + frame/benchmarking/pov/src/benchmarking.rs | 1 + frame/benchmarking/pov/src/tests.rs | 1 + frame/benchmarking/src/baseline.rs | 1 + frame/benchmarking/src/tests.rs | 1 + frame/benchmarking/src/tests_instance.rs | 1 + frame/bounties/src/tests.rs | 1 + frame/child-bounties/src/tests.rs | 1 + frame/collective/src/tests.rs | 1 + frame/contracts/src/tests.rs | 4 ++++ frame/conviction-voting/src/tests.rs | 1 + frame/core-fellowship/src/tests.rs | 1 + frame/democracy/src/tests.rs | 2 ++ frame/election-provider-multi-phase/src/mock.rs | 1 + .../test-staking-e2e/src/mock.rs | 1 + frame/election-provider-support/src/onchain.rs | 1 + frame/elections-phragmen/src/lib.rs | 1 + frame/examples/basic/src/tests.rs | 1 + frame/examples/default-config/src/lib.rs | 1 + frame/examples/dev-mode/src/tests.rs | 1 + frame/examples/kitchensink/src/tests.rs | 1 + frame/examples/offchain-worker/src/tests.rs | 1 + frame/examples/split/src/mock.rs | 1 + frame/executive/src/lib.rs | 1 + frame/fast-unstake/src/mock.rs | 1 + frame/glutton/src/mock.rs | 1 + frame/grandpa/src/mock.rs | 1 + frame/identity/src/tests.rs | 1 + frame/im-online/src/mock.rs | 1 + frame/indices/src/mock.rs | 1 + frame/insecure-randomness-collective-flip/src/lib.rs | 1 + frame/lottery/src/mock.rs | 2 ++ frame/membership/src/lib.rs | 1 + frame/merkle-mountain-range/src/mock.rs | 1 + frame/message-queue/src/integration_test.rs | 1 + frame/message-queue/src/mock.rs | 1 + frame/multisig/src/tests.rs | 2 ++ frame/nft-fractionalization/src/mock.rs | 1 + frame/nfts/src/mock.rs | 1 + frame/nicks/src/lib.rs | 1 + frame/nis/src/mock.rs | 1 + frame/node-authorization/src/mock.rs | 1 + frame/nomination-pools/benchmarking/src/mock.rs | 1 + frame/nomination-pools/src/mock.rs | 1 + frame/nomination-pools/test-staking/src/mock.rs | 1 + frame/offences/benchmarking/src/mock.rs | 1 + frame/offences/src/mock.rs | 1 + frame/paged-list/src/mock.rs | 1 + frame/preimage/src/mock.rs | 1 + frame/proxy/src/tests.rs | 3 +++ frame/ranked-collective/src/tests.rs | 1 + frame/recovery/src/mock.rs | 2 ++ frame/referenda/src/mock.rs | 3 +++ frame/remark/src/mock.rs | 1 + frame/root-offences/src/mock.rs | 1 + frame/salary/src/tests.rs | 1 + frame/scheduler/src/mock.rs | 2 ++ frame/scored-pool/src/mock.rs | 1 + frame/session/benchmarking/src/mock.rs | 1 + frame/session/src/mock.rs | 1 + frame/society/src/mock.rs | 1 + frame/staking/src/mock.rs | 1 + frame/state-trie-migration/src/lib.rs | 1 + frame/statement/src/mock.rs | 1 + frame/sudo/src/mock.rs | 2 ++ frame/support/src/dispatch.rs | 1 + frame/support/src/lib.rs | 1 + frame/support/src/storage/generator/mod.rs | 1 + frame/support/test/compile_pass/src/lib.rs | 1 + frame/support/test/tests/construct_runtime.rs | 1 + .../number_of_pallets_exceeds_tuple_size.rs | 1 + .../number_of_pallets_exceeds_tuple_size.stderr | 1 + .../test/tests/construct_runtime_ui/pallet_error_too_large.rs | 1 + .../test/tests/construct_runtime_ui/undefined_call_part.rs | 1 + .../test/tests/construct_runtime_ui/undefined_event_part.rs | 1 + .../construct_runtime_ui/undefined_genesis_config_part.rs | 1 + .../tests/construct_runtime_ui/undefined_inherent_part.rs | 1 + .../test/tests/construct_runtime_ui/undefined_origin_part.rs | 1 + .../construct_runtime_ui/undefined_validate_unsigned_part.rs | 1 + frame/support/test/tests/final_keys.rs | 1 + frame/support/test/tests/genesisconfig.rs | 1 + frame/support/test/tests/instance.rs | 1 + frame/support/test/tests/issue2219.rs | 1 + frame/support/test/tests/origin.rs | 1 + frame/support/test/tests/pallet.rs | 1 + frame/support/test/tests/pallet_instance.rs | 1 + frame/support/test/tests/pallet_outer_enums_explicit.rs | 1 + frame/support/test/tests/pallet_outer_enums_implicit.rs | 1 + frame/support/test/tests/pallet_ui/pass/dev_mode_valid.rs | 1 + .../test/tests/pallet_ui/pass/no_std_genesis_config.rs | 1 + frame/support/test/tests/runtime_metadata.rs | 1 + frame/support/test/tests/storage_layers.rs | 1 + frame/support/test/tests/storage_transaction.rs | 1 + frame/support/test/tests/versioned_runtime_upgrade.rs | 1 + frame/system/benches/bench.rs | 1 + frame/system/benchmarking/src/mock.rs | 1 + frame/system/src/mock.rs | 1 + frame/timestamp/src/mock.rs | 1 + frame/tips/src/tests.rs | 1 + .../asset-conversion-tx-payment/src/mock.rs | 1 + frame/transaction-payment/asset-tx-payment/src/mock.rs | 1 + frame/transaction-payment/src/mock.rs | 1 + frame/transaction-storage/src/mock.rs | 2 ++ frame/treasury/src/tests.rs | 2 ++ frame/uniques/src/mock.rs | 1 + frame/utility/src/tests.rs | 2 ++ frame/vesting/src/mock.rs | 1 + frame/whitelist/src/mock.rs | 2 ++ test-utils/runtime/src/lib.rs | 1 + utils/frame/rpc/support/src/lib.rs | 1 + 125 files changed, 143 insertions(+) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 244ae1b37859b..39c58d03efacb 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -24,6 +24,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index c3375d2ee601a..beec9dd4e66c1 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -165,6 +165,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The type for storing how many extrinsics an account has signed. @@ -269,6 +270,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type WeightInfo = pallet_sudo::weights::SubstrateWeight; } diff --git a/docs/Upgrading-2.0-to-3.0.md b/docs/Upgrading-2.0-to-3.0.md index 906018db9a707..3eb3b11505008 100644 --- a/docs/Upgrading-2.0-to-3.0.md +++ b/docs/Upgrading-2.0-to-3.0.md @@ -149,6 +149,7 @@ And update the overall definition for weights on frame and a few related types a + type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; +type RuntimeTask = RuntimeTask; type Index = Index; @@ -171,25 +198,19 @@ impl frame_system::Trait for Runtime { type Header = generic::Header; diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index f04e7e414ed94..3e602b7a17d11 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -51,6 +51,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 7fe81b814047d..3178ad99ba1d5 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -54,6 +54,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 5fe0d4240af58..02a4230a074ad 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -43,6 +43,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 32ad02da90412..a1741fbd8027e 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 858417e8007fb..b45fc061bf86b 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -30,6 +30,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 39b798c2f6841..fe3479e34f227 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -49,6 +49,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 87b743ae19677..0e6150f3d65f0 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -233,6 +233,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; 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 a9bd0c38cb67c..28192fe411ffd 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -127,6 +127,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index dc8e8e3499fad..180f45faa37c5 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index ae50adabd508a..a6226b6f03243 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -54,6 +54,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 45f34110a6e9e..5f0d78f6bfe69 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -94,6 +94,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 2c37ad4483f6b..207e45edcbaca 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index af770c0b49448..434d12524e224 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -75,6 +75,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 473947b171ac5..43d27466cf502 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -362,6 +362,7 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; 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 f09e37a5288a9..94aea232c6cfd 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -182,6 +182,7 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = u32; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u32; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 94c066269d91b..598da43c51121 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -133,6 +133,7 @@ pub mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; 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 4b8339f65913d..2778adf8888a3 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -85,6 +85,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 822efa70a2597..5ed8c344d52a1 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -92,6 +92,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 355483ddac94d..2d7dbacaa5ce1 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -64,6 +64,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 24a6410f29f78..4c213e070967c 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 86b85e07a8bd9..acb29b11fc301 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -98,6 +98,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3132b8e39f7da..92af27f2031a3 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -323,6 +323,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; @@ -365,6 +366,7 @@ impl pallet_timestamp::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -372,6 +374,7 @@ impl pallet_utility::Config for Test { impl pallet_proxy::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = (); type ProxyDepositBase = ConstU64<1>; @@ -446,6 +449,7 @@ impl Config for Test { type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type CallFilter = TestFilter; type CallStack = [Frame; 5]; type WeightPrice = Self; diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 656112deebfbb..b63b437e72828 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -59,6 +59,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index c95699e66e41b..9379816ef5f9a 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -58,6 +58,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index e5cfcc5b40029..373f11cbc8ccb 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -85,6 +85,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -120,6 +121,7 @@ impl pallet_scheduler::Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index c5133d89e4c82..3ad7efb9910e2 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -210,6 +210,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; 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 0d5f8872193ad..d3f54456caab7 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 @@ -89,6 +89,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index bfdc21a8fe2d6..c4e90c2bbe59d 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -210,6 +210,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; 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 b23ddda4e8d1c..a4219269a0d49 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1325,6 +1325,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index addf219dc3c39..01cd58980559b 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -54,6 +54,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 63a6a941b829f..06f6ac48d5b74 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -131,6 +131,7 @@ pub mod tests { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index ba98f5174ce20..fa4f00ce9edb1 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -48,6 +48,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index b2af7c8983f56..5b3e008bd0be4 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -44,6 +44,7 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 203a59a8af03c..38e9a48701b29 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -53,6 +53,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/examples/split/src/mock.rs b/frame/examples/split/src/mock.rs index bee3633ef68f2..35f117865ef5b 100644 --- a/frame/examples/split/src/mock.rs +++ b/frame/examples/split/src/mock.rs @@ -39,6 +39,7 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 4e24717a39e93..620604aa4c2be 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -870,6 +870,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 192d525e278d7..dd5403085b5e3 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index c79ddd53718eb..2f6a8815f7fbe 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -47,6 +47,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 86f91ba803230..15b3f85c4f3f8 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -71,6 +71,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 1532980574c2a..2508fd130aa05 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 85da061fe904a..a9a1350076f26 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -121,6 +121,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index d63081e0b73f8..28ed2a3ebdd6f 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -42,6 +42,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 474087777c46e..f7119f63a6f9b 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -197,6 +197,7 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index aefb6a1cce2bf..8b1a2588a799d 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -55,6 +55,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -96,6 +97,7 @@ parameter_types! { impl Config for Test { type PalletId = LotteryPalletId; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type Randomness = TestRandomness; type RuntimeEvent = RuntimeEvent; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 24b9fb5fe9069..c429bc03c8718 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -559,6 +559,7 @@ mod tests { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index ecc254278bf0f..ff46c0c9c3cfd 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -41,6 +41,7 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index 4fc639101a01f..ea9c9572b725b 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -59,6 +59,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index 04b763d59cffd..be450f22e152a 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 8e704b923742a..a95b5f3fb9ced 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -99,6 +100,7 @@ impl Contains for TestBaseCallFilter { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type DepositBase = ConstU64<1>; type DepositFactor = ConstU64<1>; diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 6565adaf6fc7e..6f1e553decf99 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -55,6 +55,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index f091a53f8d7c7..15f5c1166b622 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 0a68f7d7142dc..3a154e4a8ea7f 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -283,6 +283,7 @@ mod tests { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 76fdf5f3f0693..e5c259997617c 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -56,6 +56,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index 84e3336b3bd68..c1bb1538bb1f0 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -52,6 +52,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 2298f611d7fff..847b3faaf0b97 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -36,6 +36,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 7d0d729a40d41..cfd73a0c18a8a 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -170,6 +170,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index ffc1ed56d08c4..170325f29b69c 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -46,6 +46,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 0e3dfd09fe7ab..116086e0d4e69 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -45,6 +45,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 990ceae5ac01e..33516afb91e76 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -83,6 +83,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/paged-list/src/mock.rs b/frame/paged-list/src/mock.rs index 390b4a8530dce..d920676018566 100644 --- a/frame/paged-list/src/mock.rs +++ b/frame/paged-list/src/mock.rs @@ -45,6 +45,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 2fb9f36dec454..8c8e5e249fde9 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -50,6 +50,7 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 1f4d2617700e6..59ab324d7a96f 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -56,6 +56,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -91,6 +92,7 @@ impl pallet_balances::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -149,6 +151,7 @@ impl Contains for BaseFilter { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ConstU64<1>; diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index ba8c5a0f937ba..c7ece585edf37 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -53,6 +53,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 2f2bd866a7198..db41f41a2ade6 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -48,6 +48,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -99,6 +100,7 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index e44167ed561c5..c39629f1b96e8 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -97,6 +98,7 @@ impl pallet_scheduler::Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type MaximumWeight = MaxWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; @@ -209,6 +211,7 @@ impl_tracksinfo_get!(TestTracksInfo, u64, u64); impl Config for Test { type WeightInfo = (); type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index e597a1ca4dfe8..625c3cb21f840 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -42,6 +42,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 92d188f49fb92..79181127e96ee 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -90,6 +90,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 034dce24b8b38..6feb19f6ebd1b 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -57,6 +57,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 28e334958d924..886aac8d9af49 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -125,6 +125,7 @@ impl system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -208,6 +209,7 @@ impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EitherOfDiverse, EnsureSignedBy>; type MaxScheduledPerBlock = ConstU32<10>; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index d8c6ef9b0f444..e608e02369a25 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -59,6 +59,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index dbbd437bbd938..a5bedd7678074 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -50,6 +50,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index b45ebfd25c44a..ca0b155bb8558 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -240,6 +240,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index a318c2e794b7a..f4103bf48088e 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 232b37de7c1b8..c6fcb32550290 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -126,6 +126,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index c5b41cd9a4439..2d793edfe09a0 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1087,6 +1087,7 @@ mod mock { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 79d2aa7d891d5..6e6cf8cbfd93c 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -54,6 +54,7 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 9e78e474f4e5a..9412bd05f36be 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -115,6 +115,7 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -143,6 +144,7 @@ impl logger::Config for Test { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type WeightInfo = (); } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index e462066a84605..84c67a6b22b67 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -780,6 +780,7 @@ mod weight_tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type DbWeight = DbWeight; type PalletInfo = PalletInfo; } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index d37490c341724..c1e5a46ebcef2 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -978,6 +978,7 @@ pub mod tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletInfo = PalletInfo; type DbWeight = (); } diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index bac9f642e37d6..ea96f1bc0d9cf 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -129,6 +129,7 @@ mod tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletInfo = PalletInfo; type DbWeight = (); } diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index bf90d73acb320..24d8b88e94aff 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -67,6 +67,7 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index ff207ddf977c6..d5026f18b5dcc 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -282,6 +282,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); 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 0d6afbcdc2c65..c7844fde8fa66 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr index 55cef6704ee3f..3dd458ba08168 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 @@ -37,6 +37,7 @@ error[E0412]: cannot find type `RuntimeCall` in this scope --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:26:21 | 26 | type RuntimeCall = RuntimeCall; +type RuntimeTask = RuntimeTask; | ^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeCall` error[E0412]: cannot find type `RuntimeEvent` in this scope 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 8b3e26bc5e2e4..418c751cbc52f 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 @@ -49,6 +49,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 25cb5e93f652e..ce1ae7fdb733a 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 c44cceef81a12..fc3d4af5bf76f 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 4436202f04fc7..5045fd8aee976 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 8b48c4d0d6af7..e08cd1ee3643a 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 974928785f748..f2b66f71f9654 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 505b249d92d58..ba8a9486abb96 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 @@ -24,6 +24,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 765afaf1e6604..8989e8da69a27 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -217,6 +217,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index c6781220692a9..cf10a0f762bac 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -86,6 +86,7 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 2fb6d7658d6ab..5d7230e12e3c8 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -306,6 +306,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 4016707b51a8d..7373d70fe5741 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -168,6 +168,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 5682bb500c7e3..fedeb344a1392 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -177,6 +177,7 @@ impl frame_system::Config for RuntimeOriginTest { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index cb78bded1a358..71b5d2175e76e 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -688,6 +688,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 4ecb9bcb58ae9..c93b2bf934e08 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -293,6 +293,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_outer_enums_explicit.rs b/frame/support/test/tests/pallet_outer_enums_explicit.rs index a8250f8b15325..eaf0618b7cee1 100644 --- a/frame/support/test/tests/pallet_outer_enums_explicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_explicit.rs @@ -32,6 +32,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/pallet_outer_enums_implicit.rs b/frame/support/test/tests/pallet_outer_enums_implicit.rs index 191f095f5d78d..4c6a940f9f8a7 100644 --- a/frame/support/test/tests/pallet_outer_enums_implicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_implicit.rs @@ -32,6 +32,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); 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 ed779da80a188..1450b7ec2c2e5 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 @@ -58,6 +58,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 87659a0bab513..6f81b8c769b58 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 @@ -15,6 +15,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 50bad87d32eb0..1ce2436209838 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -37,6 +37,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index b825c85f9564c..34230af622fa3 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -70,6 +70,7 @@ impl frame_system::Config for Runtime { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index c477433086098..7a61a44714b38 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -95,6 +95,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index 93d87df8ca185..215fac1a6400b 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -78,6 +78,7 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index da8bb10fd4e42..5ad170fa55b27 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -65,6 +65,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 4e6b1221da356..355df92d11fae 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -42,6 +42,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index c016ea9e1cd14..670dbb266b036 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -91,6 +91,7 @@ impl Config for Test { type BlockLength = RuntimeBlockLength; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 418d257b3f005..f56b5eaab4453 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -50,6 +50,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index a700892d42703..3ce8c2ce1b6e6 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -61,6 +61,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account 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 bfbe8b4178cee..a2add7c59efad 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -86,6 +86,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index b8d7b523ca258..2b6374f7d9ce3 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -78,6 +78,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 97253be463058..79febf649077a 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -77,6 +77,7 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 243e26b559053..c974877b266cf 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -48,6 +48,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -87,6 +88,7 @@ impl pallet_balances::Config for Test { impl pallet_transaction_storage::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Currency = Balances; type FeeDestination = (); type WeightInfo = (); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 79497d55867d6..bea1821a48064 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -56,6 +56,7 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account @@ -92,6 +93,7 @@ impl pallet_balances::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 5c44a7ed7a539..d76f6d17490bd 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -47,6 +47,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index c2fd3a851c319..9e13e465b16d5 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -153,6 +153,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -246,6 +247,7 @@ impl mock_democracy::Config for Test { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index fe1779475a69a..743b1b5aef4c2 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -47,6 +47,7 @@ impl frame_system::Config for Test { type BlockLength = (); type BlockWeights = (); type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index d91f43b33af91..0d9bd5e2ee0de 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -53,6 +53,7 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -98,6 +99,7 @@ impl pallet_preimage::Config for Test { impl pallet_whitelist::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type Preimages = Preimage; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 0cc32e50956c8..4bac6a86b9c31 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -349,6 +349,7 @@ impl frame_system::pallet::Config for Runtime { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = H256; type Hashing = Hashing; diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 2d8e45cbfc69f..95c590ea0a5f0 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -55,6 +55,7 @@ use sp_storage::{StorageData, StorageKey}; /// # type BlockLength = (); /// # type RuntimeOrigin = RuntimeOrigin; /// # type RuntimeCall = RuntimeCall; +type RuntimeTask = RuntimeTask; /// # type Nonce = u64; /// # type Hash = Hash; /// # type Hashing = BlakeTwo256; From 0f629538ec2acb15218b173cfd0c2d8634d7200b Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 15:29:45 -0400 Subject: [PATCH 35/44] clean up --- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/src/lib.rs | 19 ++++------- docs/Upgrading-2.0-to-3.0.md | 1 - frame/alliance/src/mock.rs | 1 - frame/asset-conversion/src/mock.rs | 1 - frame/asset-rate/src/mock.rs | 1 - frame/assets/src/mock.rs | 1 - frame/atomic-swap/src/tests.rs | 1 - frame/aura/src/mock.rs | 1 - frame/authority-discovery/src/lib.rs | 1 - frame/authorship/src/lib.rs | 1 - frame/babe/src/mock.rs | 1 - frame/bags-list/src/mock.rs | 1 - frame/balances/src/tests/mod.rs | 1 - frame/beefy-mmr/src/mock.rs | 1 - frame/beefy/src/mock.rs | 1 - frame/benchmarking/pov/src/benchmarking.rs | 1 - frame/benchmarking/pov/src/tests.rs | 1 - frame/benchmarking/src/baseline.rs | 1 - frame/benchmarking/src/tests.rs | 1 - frame/benchmarking/src/tests_instance.rs | 1 - frame/bounties/src/tests.rs | 1 - frame/child-bounties/src/tests.rs | 1 - frame/collective/src/tests.rs | 1 - frame/contracts/src/tests.rs | 4 --- frame/conviction-voting/src/tests.rs | 1 - frame/core-fellowship/src/tests.rs | 1 - frame/democracy/src/tests.rs | 2 -- .../election-provider-multi-phase/src/mock.rs | 1 - .../test-staking-e2e/src/mock.rs | 1 - .../election-provider-support/src/onchain.rs | 1 - frame/elections-phragmen/src/lib.rs | 1 - frame/examples/basic/src/tests.rs | 1 - frame/examples/default-config/src/lib.rs | 1 - frame/examples/dev-mode/src/tests.rs | 1 - frame/examples/kitchensink/src/tests.rs | 1 - frame/examples/offchain-worker/src/tests.rs | 1 - frame/examples/split/src/mock.rs | 1 - frame/examples/tasks-example/src/lib.rs | 34 ++----------------- frame/executive/src/lib.rs | 1 - frame/fast-unstake/src/mock.rs | 1 - frame/glutton/src/mock.rs | 1 - frame/grandpa/src/mock.rs | 1 - frame/identity/src/tests.rs | 1 - frame/im-online/src/mock.rs | 1 - frame/indices/src/mock.rs | 1 - .../src/lib.rs | 1 - frame/lottery/src/mock.rs | 2 -- frame/membership/src/lib.rs | 1 - frame/merkle-mountain-range/src/mock.rs | 1 - frame/message-queue/src/integration_test.rs | 1 - frame/message-queue/src/mock.rs | 1 - frame/multisig/src/tests.rs | 2 -- frame/nft-fractionalization/src/mock.rs | 1 - frame/nfts/src/mock.rs | 1 - frame/nicks/src/lib.rs | 1 - frame/nis/src/mock.rs | 1 - frame/node-authorization/src/mock.rs | 1 - .../nomination-pools/benchmarking/src/mock.rs | 1 - frame/nomination-pools/src/mock.rs | 1 - .../nomination-pools/test-staking/src/mock.rs | 1 - frame/offences/benchmarking/src/mock.rs | 1 - frame/offences/src/mock.rs | 1 - frame/paged-list/src/mock.rs | 1 - frame/preimage/src/mock.rs | 1 - frame/proxy/src/tests.rs | 3 -- frame/ranked-collective/src/tests.rs | 1 - frame/recovery/src/mock.rs | 2 -- frame/referenda/src/mock.rs | 3 -- frame/remark/src/mock.rs | 1 - frame/root-offences/src/mock.rs | 1 - frame/salary/src/tests.rs | 1 - frame/scheduler/src/mock.rs | 2 -- frame/scored-pool/src/mock.rs | 1 - frame/session/benchmarking/src/mock.rs | 1 - frame/session/src/mock.rs | 1 - frame/society/src/mock.rs | 1 - frame/staking/src/mock.rs | 1 - frame/state-trie-migration/src/lib.rs | 1 - frame/statement/src/mock.rs | 1 - frame/sudo/src/mock.rs | 2 -- frame/support/src/dispatch.rs | 2 +- frame/support/src/lib.rs | 7 ++-- frame/support/src/storage/generator/mod.rs | 2 +- frame/support/src/traits/tasks.rs | 4 +-- frame/support/test/compile_pass/src/lib.rs | 1 - frame/support/test/src/lib.rs | 2 ++ frame/support/test/tests/construct_runtime.rs | 1 - .../number_of_pallets_exceeds_tuple_size.rs | 1 - ...umber_of_pallets_exceeds_tuple_size.stderr | 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/final_keys.rs | 1 - frame/support/test/tests/genesisconfig.rs | 1 - frame/support/test/tests/instance.rs | 1 - frame/support/test/tests/issue2219.rs | 1 - frame/support/test/tests/origin.rs | 1 - frame/support/test/tests/pallet.rs | 1 - frame/support/test/tests/pallet_instance.rs | 1 - .../test/tests/pallet_outer_enums_explicit.rs | 1 - .../test/tests/pallet_outer_enums_implicit.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/support/test/tests/storage_layers.rs | 1 - .../support/test/tests/storage_transaction.rs | 1 - .../test/tests/versioned_runtime_upgrade.rs | 1 - frame/system/benches/bench.rs | 1 - frame/system/benchmarking/src/mock.rs | 1 - frame/system/src/lib.rs | 7 ++-- frame/system/src/mock.rs | 1 - frame/timestamp/src/mock.rs | 1 - frame/tips/src/tests.rs | 1 - .../asset-conversion-tx-payment/src/mock.rs | 1 - .../asset-tx-payment/src/mock.rs | 1 - frame/transaction-payment/src/mock.rs | 1 - frame/transaction-storage/src/mock.rs | 2 -- frame/treasury/src/tests.rs | 2 -- frame/uniques/src/mock.rs | 1 - frame/utility/src/tests.rs | 2 -- frame/vesting/src/mock.rs | 1 - frame/whitelist/src/mock.rs | 2 -- test-utils/runtime/src/lib.rs | 1 - utils/frame/rpc/support/src/lib.rs | 1 - 129 files changed, 23 insertions(+), 193 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index beec9dd4e66c1..469f5218f5d27 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -165,6 +165,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; + /// The aggregated task type that is available for extrinsics. type RuntimeTask = RuntimeTask; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; @@ -270,7 +271,6 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type WeightInfo = pallet_sudo::weights::SubstrateWeight; } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 219c0fef012f3..455ded4194737 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -247,10 +247,13 @@ impl frame_system::Config for Runtime { impl pallet_insecure_randomness_collective_flip::Config for Runtime {} +impl tasks_example::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -265,7 +268,6 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -348,7 +350,6 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -371,7 +372,6 @@ impl pallet_scheduler::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; #[cfg(feature = "runtime-benchmarks")] @@ -889,7 +889,6 @@ pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -910,7 +909,6 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -1239,7 +1237,6 @@ impl pallet_contracts::Config for Runtime { type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1274,7 +1271,6 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type WeightInfo = pallet_sudo::weights::SubstrateWeight; } @@ -1414,7 +1410,6 @@ impl pallet_recovery::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1487,7 +1482,6 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type RuntimeEvent = RuntimeEvent; @@ -1758,7 +1752,6 @@ impl pallet_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1770,7 +1763,6 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type Preimages = Preimage; @@ -1960,7 +1952,7 @@ construct_runtime!( MessageQueue: pallet_message_queue, Pov: frame_benchmarking_pallet_pov, Statement: pallet_statement, - Tasks: pallet_tasks, + TasksExample: tasks_example, } ); @@ -2046,6 +2038,7 @@ mod benches { [pallet_conviction_voting, ConvictionVoting] [pallet_contracts, Contracts] [pallet_core_fellowship, CoreFellowship] + [tasks_example, TasksExample] [pallet_democracy, Democracy] [pallet_asset_conversion, AssetConversion] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] diff --git a/docs/Upgrading-2.0-to-3.0.md b/docs/Upgrading-2.0-to-3.0.md index 3eb3b11505008..906018db9a707 100644 --- a/docs/Upgrading-2.0-to-3.0.md +++ b/docs/Upgrading-2.0-to-3.0.md @@ -149,7 +149,6 @@ And update the overall definition for weights on frame and a few related types a + type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; -type RuntimeTask = RuntimeTask; type Index = Index; @@ -171,25 +198,19 @@ impl frame_system::Trait for Runtime { type Header = generic::Header; diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 3e602b7a17d11..f04e7e414ed94 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -51,7 +51,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 3178ad99ba1d5..7fe81b814047d 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -54,7 +54,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 02a4230a074ad..5fe0d4240af58 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -43,7 +43,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index a1741fbd8027e..32ad02da90412 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index b45fc061bf86b..858417e8007fb 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -30,7 +30,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index fe3479e34f227..39b798c2f6841 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -49,7 +49,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 0e6150f3d65f0..87b743ae19677 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -233,7 +233,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; 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 28192fe411ffd..a9bd0c38cb67c 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -127,7 +127,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 180f45faa37c5..dc8e8e3499fad 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index a6226b6f03243..ae50adabd508a 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -54,7 +54,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 5f0d78f6bfe69..45f34110a6e9e 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -94,7 +94,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 207e45edcbaca..2c37ad4483f6b 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 434d12524e224..af770c0b49448 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -75,7 +75,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 43d27466cf502..473947b171ac5 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -362,7 +362,6 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; 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 94aea232c6cfd..f09e37a5288a9 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -182,7 +182,6 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = u32; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u32; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 598da43c51121..94c066269d91b 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -133,7 +133,6 @@ pub mod mock { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; 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 2778adf8888a3..4b8339f65913d 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -85,7 +85,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 5ed8c344d52a1..822efa70a2597 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -92,7 +92,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 2d7dbacaa5ce1..355483ddac94d 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -64,7 +64,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 4c213e070967c..24a6410f29f78 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index acb29b11fc301..86b85e07a8bd9 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -98,7 +98,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 92af27f2031a3..3132b8e39f7da 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -323,7 +323,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; @@ -366,7 +365,6 @@ impl pallet_timestamp::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -374,7 +372,6 @@ impl pallet_utility::Config for Test { impl pallet_proxy::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = (); type ProxyDepositBase = ConstU64<1>; @@ -449,7 +446,6 @@ impl Config for Test { type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type CallFilter = TestFilter; type CallStack = [Frame; 5]; type WeightPrice = Self; diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index b63b437e72828..656112deebfbb 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -59,7 +59,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index 9379816ef5f9a..c95699e66e41b 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -58,7 +58,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 373f11cbc8ccb..e5cfcc5b40029 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -85,7 +85,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -121,7 +120,6 @@ impl pallet_scheduler::Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 3ad7efb9910e2..c5133d89e4c82 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -210,7 +210,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; 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 d3f54456caab7..0d5f8872193ad 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 @@ -89,7 +89,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index c4e90c2bbe59d..bfdc21a8fe2d6 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -210,7 +210,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; 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 a4219269a0d49..b23ddda4e8d1c 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1325,7 +1325,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 01cd58980559b..addf219dc3c39 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -54,7 +54,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 06f6ac48d5b74..63a6a941b829f 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -131,7 +131,6 @@ pub mod tests { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index fa4f00ce9edb1..ba98f5174ce20 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -48,7 +48,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index 5b3e008bd0be4..b2af7c8983f56 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -44,7 +44,6 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 38e9a48701b29..203a59a8af03c 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -53,7 +53,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/examples/split/src/mock.rs b/frame/examples/split/src/mock.rs index 35f117865ef5b..bee3633ef68f2 100644 --- a/frame/examples/split/src/mock.rs +++ b/frame/examples/split/src/mock.rs @@ -39,7 +39,6 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 4b0e4f3c8187e..97548a66cb791 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -66,12 +66,12 @@ pub mod pallet { where T: TypeInfo, { - type Enumeration = std::vec::IntoIter>; + type Enumeration = sp_std::vec::IntoIter>; const TASK_INDEX: u64 = 0; fn enumerate() -> Self::Enumeration { - vec![Task::Increment, Task::Decrement].into_iter() + sp_std::vec![Task::Increment, Task::Decrement].into_iter() } fn is_valid(&self) -> bool { @@ -169,36 +169,6 @@ pub mod pallet { } } - // I think we can actually auto-impl this in the macros if an existing `ValidateUnsigned` - // impl is not present. If one is present, we just wouldn't emit an impl for this. An - // existing impl will be easy to find using a simple visitor pattern in the macros. - impl frame_support::unsigned::ValidateUnsigned for Pallet { - type Call = Call; - - fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { - // TODO: verify `source` ? - use frame_support::traits::Task; - match call { - Call::do_task { task } => { - if task.is_valid() { - Ok(ValidTransaction { - priority: 0, // TODO: make configurable on Task? - requires: vec![], - provides: vec![task.encode()], - longevity: TransactionLongevity::max_value(), - propagate: true, - }) - } else { - InvalidTransaction::Custom(1u8).into() - // TODO: custom error enum for this? Maybe we can put it in some - // globally accessible place? Or just always generate the same enum? - } - }, - _ => InvalidTransaction::Call.into(), - } - } - } - #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 620604aa4c2be..4e24717a39e93 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -870,7 +870,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index dd5403085b5e3..192d525e278d7 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index 2f6a8815f7fbe..c79ddd53718eb 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -47,7 +47,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 15b3f85c4f3f8..86f91ba803230 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -71,7 +71,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 2508fd130aa05..1532980574c2a 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index a9a1350076f26..85da061fe904a 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -121,7 +121,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 28ed2a3ebdd6f..d63081e0b73f8 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -42,7 +42,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index f7119f63a6f9b..474087777c46e 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -197,7 +197,6 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 8b1a2588a799d..aefb6a1cce2bf 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -55,7 +55,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -97,7 +96,6 @@ parameter_types! { impl Config for Test { type PalletId = LotteryPalletId; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type Randomness = TestRandomness; type RuntimeEvent = RuntimeEvent; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index c429bc03c8718..24b9fb5fe9069 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -559,7 +559,6 @@ mod tests { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index ff46c0c9c3cfd..ecc254278bf0f 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -41,7 +41,6 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index ea9c9572b725b..4fc639101a01f 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -59,7 +59,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index be450f22e152a..04b763d59cffd 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index a95b5f3fb9ced..8e704b923742a 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -100,7 +99,6 @@ impl Contains for TestBaseCallFilter { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type DepositBase = ConstU64<1>; type DepositFactor = ConstU64<1>; diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 6f1e553decf99..6565adaf6fc7e 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -55,7 +55,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 15f5c1166b622..f091a53f8d7c7 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 3a154e4a8ea7f..0a68f7d7142dc 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -283,7 +283,6 @@ mod tests { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index e5c259997617c..76fdf5f3f0693 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -56,7 +56,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index c1bb1538bb1f0..84e3336b3bd68 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -52,7 +52,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 847b3faaf0b97..2298f611d7fff 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -36,7 +36,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index cfd73a0c18a8a..7d0d729a40d41 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -170,7 +170,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 170325f29b69c..ffc1ed56d08c4 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -46,7 +46,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 116086e0d4e69..0e3dfd09fe7ab 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -45,7 +45,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 33516afb91e76..990ceae5ac01e 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -83,7 +83,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/paged-list/src/mock.rs b/frame/paged-list/src/mock.rs index d920676018566..390b4a8530dce 100644 --- a/frame/paged-list/src/mock.rs +++ b/frame/paged-list/src/mock.rs @@ -45,7 +45,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 8c8e5e249fde9..2fb9f36dec454 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -50,7 +50,6 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 59ab324d7a96f..1f4d2617700e6 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -56,7 +56,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -92,7 +91,6 @@ impl pallet_balances::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -151,7 +149,6 @@ impl Contains for BaseFilter { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ConstU64<1>; diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index c7ece585edf37..ba8c5a0f937ba 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -53,7 +53,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index db41f41a2ade6..2f2bd866a7198 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -48,7 +48,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -100,7 +99,6 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index c39629f1b96e8..e44167ed561c5 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -98,7 +97,6 @@ impl pallet_scheduler::Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type MaximumWeight = MaxWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; @@ -211,7 +209,6 @@ impl_tracksinfo_get!(TestTracksInfo, u64, u64); impl Config for Test { type WeightInfo = (); type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 625c3cb21f840..e597a1ca4dfe8 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -42,7 +42,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 79181127e96ee..92d188f49fb92 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -90,7 +90,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 6feb19f6ebd1b..034dce24b8b38 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -57,7 +57,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 886aac8d9af49..28e334958d924 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -125,7 +125,6 @@ impl system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -209,7 +208,6 @@ impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EitherOfDiverse, EnsureSignedBy>; type MaxScheduledPerBlock = ConstU32<10>; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index e608e02369a25..d8c6ef9b0f444 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -59,7 +59,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index a5bedd7678074..dbbd437bbd938 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -50,7 +50,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index ca0b155bb8558..b45ebfd25c44a 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -240,7 +240,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index f4103bf48088e..a318c2e794b7a 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index c6fcb32550290..232b37de7c1b8 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -126,7 +126,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 2d793edfe09a0..c5b41cd9a4439 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1087,7 +1087,6 @@ mod mock { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index 6e6cf8cbfd93c..79d2aa7d891d5 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -54,7 +54,6 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 9412bd05f36be..9e78e474f4e5a 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -115,7 +115,6 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -144,7 +143,6 @@ impl logger::Config for Test { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type WeightInfo = (); } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 84c67a6b22b67..9233c6df66a97 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -684,6 +684,7 @@ mod weight_tests { type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; type RuntimeCall; + type RuntimeTask; type PalletInfo: crate::traits::PalletInfo; type DbWeight: Get; } @@ -780,7 +781,6 @@ mod weight_tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type DbWeight = DbWeight; type PalletInfo = PalletInfo; } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index c1e5a46ebcef2..a3aa57b595653 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -849,6 +849,7 @@ pub mod tests { type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; type RuntimeCall; + type RuntimeTask; type PalletInfo: crate::traits::PalletInfo; type DbWeight: Get; } @@ -978,7 +979,6 @@ pub mod tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletInfo = PalletInfo; type DbWeight = (); } @@ -1552,8 +1552,9 @@ pub mod pallet_prelude { StorageList, }, traits::{ - BuildGenesisConfig, ConstU32, EnsureOrigin, Get, GetDefault, GetStorageVersion, Hooks, - IsType, PalletInfoAccess, StorageInfoTrait, StorageVersion, TypedGet, + AggregatedTask, BuildGenesisConfig, ConstU32, EnsureOrigin, Get, GetDefault, + GetStorageVersion, Hooks, IsType, PalletInfoAccess, StorageInfoTrait, StorageVersion, + Task, TypedGet, }, Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity, PartialEqNoBound, RuntimeDebug, RuntimeDebugNoBound, Twox128, Twox256, Twox64Concat, diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index ea96f1bc0d9cf..7ea98b9635bbc 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -63,6 +63,7 @@ mod tests { type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; type RuntimeCall; + type RuntimeTask; type PalletInfo: crate::traits::PalletInfo; type DbWeight: Get; } @@ -129,7 +130,6 @@ mod tests { type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletInfo = PalletInfo; type DbWeight = (); } diff --git a/frame/support/src/traits/tasks.rs b/frame/support/src/traits/tasks.rs index 69d46f1e0dd41..c52fc7d179179 100644 --- a/frame/support/src/traits/tasks.rs +++ b/frame/support/src/traits/tasks.rs @@ -20,7 +20,7 @@ /// Contain's re-exports of all the supporting types for the [`Task`] trait. Used in the macro /// expansion of `RuntimeTask`. -pub mod task_prelude { +pub mod prelude { pub use codec::FullCodec; pub use scale_info::TypeInfo; pub use sp_runtime::DispatchError; @@ -28,7 +28,7 @@ pub mod task_prelude { pub use sp_weights::Weight; } -use task_prelude::*; +use prelude::*; /// A general-purpose trait which defines a type of service work (i.e., work to performed by an /// off-chain worker) including methods for enumerating, validating, indexing, and running diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 24d8b88e94aff..bf90d73acb320 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -67,7 +67,6 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 6b38d42d33d0d..a8a723375033a 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -50,6 +50,8 @@ pub mod pallet { + From>; /// The runtime call type. type RuntimeCall; + /// Contains an aggregation of all tasks in this runtime. + type RuntimeTask; /// The runtime event type. type RuntimeEvent: Parameter + Member diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index d5026f18b5dcc..ff207ddf977c6 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -282,7 +282,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); 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 c7844fde8fa66..0d6afbcdc2c65 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 3dd458ba08168..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 @@ -37,7 +37,6 @@ error[E0412]: cannot find type `RuntimeCall` in this scope --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:26:21 | 26 | type RuntimeCall = RuntimeCall; -type RuntimeTask = RuntimeTask; | ^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeCall` error[E0412]: cannot find type `RuntimeEvent` in this scope 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 418c751cbc52f..8b3e26bc5e2e4 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 @@ -49,7 +49,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 ce1ae7fdb733a..25cb5e93f652e 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 fc3d4af5bf76f..c44cceef81a12 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 5045fd8aee976..4436202f04fc7 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 e08cd1ee3643a..8b48c4d0d6af7 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 f2b66f71f9654..974928785f748 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 ba8a9486abb96..505b249d92d58 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 @@ -24,7 +24,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 8989e8da69a27..765afaf1e6604 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -217,7 +217,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index cf10a0f762bac..c6781220692a9 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -86,7 +86,6 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 5d7230e12e3c8..2fb6d7658d6ab 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -306,7 +306,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 7373d70fe5741..4016707b51a8d 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -168,7 +168,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index fedeb344a1392..5682bb500c7e3 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -177,7 +177,6 @@ impl frame_system::Config for RuntimeOriginTest { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 71b5d2175e76e..cb78bded1a358 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -688,7 +688,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index c93b2bf934e08..4ecb9bcb58ae9 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -293,7 +293,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_outer_enums_explicit.rs b/frame/support/test/tests/pallet_outer_enums_explicit.rs index eaf0618b7cee1..a8250f8b15325 100644 --- a/frame/support/test/tests/pallet_outer_enums_explicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_explicit.rs @@ -32,7 +32,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/pallet_outer_enums_implicit.rs b/frame/support/test/tests/pallet_outer_enums_implicit.rs index 4c6a940f9f8a7..191f095f5d78d 100644 --- a/frame/support/test/tests/pallet_outer_enums_implicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_implicit.rs @@ -32,7 +32,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); 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 1450b7ec2c2e5..ed779da80a188 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 @@ -58,7 +58,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; 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 6f81b8c769b58..87659a0bab513 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 @@ -15,7 +15,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 1ce2436209838..50bad87d32eb0 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 RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 34230af622fa3..b825c85f9564c 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -70,7 +70,6 @@ impl frame_system::Config for Runtime { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 7a61a44714b38..c477433086098 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -95,7 +95,6 @@ impl frame_system::Config for Runtime { type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index 215fac1a6400b..93d87df8ca185 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -78,7 +78,6 @@ impl frame_system::Config for Test { type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type OnSetCode = (); diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 5ad170fa55b27..da8bb10fd4e42 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -65,7 +65,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 355df92d11fae..4e6b1221da356 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -42,7 +42,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = Nonce; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 0e6b24faed0aa..8aa2bbd00f25a 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -86,7 +86,7 @@ use sp_version::RuntimeVersion; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; #[cfg(feature = "std")] -use frame_support::traits::{BuildGenesisConfig, Task}; +use frame_support::traits::BuildGenesisConfig; use frame_support::{ dispatch::{ extract_actual_pays_fee, extract_actual_weight, DispatchClass, DispatchInfo, @@ -201,7 +201,7 @@ impl, MaxOverflow: Get> ConsumerLimits for (MaxNormal, #[frame_support::pallet] pub mod pallet { use crate::{self as frame_system, pallet_prelude::*, *}; - use frame_support::{pallet_prelude::*, traits::Task}; + use frame_support::{pallet_prelude::*, traits::AggregatedTask}; /// Contains default types suitable for various environments pub mod config_preludes { @@ -273,8 +273,9 @@ pub mod pallet { + Debug + From>; + /// The aggregated `RuntimeTask` type. #[pallet::no_default] - type RuntimeTask: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq; + type RuntimeTask: AggregatedTask; /// This stores the number of previous transactions associated with a sender account. type Nonce: Parameter diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 670dbb266b036..c016ea9e1cd14 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -91,7 +91,6 @@ impl Config for Test { type BlockLength = RuntimeBlockLength; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index f56b5eaab4453..418d257b3f005 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -50,7 +50,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 3ce8c2ce1b6e6..a700892d42703 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -61,7 +61,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account 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 a2add7c59efad..bfbe8b4178cee 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -86,7 +86,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index 2b6374f7d9ce3..b8d7b523ca258 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -78,7 +78,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 79febf649077a..97253be463058 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -77,7 +77,6 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index c974877b266cf..243e26b559053 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -48,7 +48,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -88,7 +87,6 @@ impl pallet_balances::Config for Test { impl pallet_transaction_storage::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Currency = Balances; type FeeDestination = (); type WeightInfo = (); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index bea1821a48064..79497d55867d6 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -56,7 +56,6 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Nonce = u64; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account @@ -93,7 +92,6 @@ impl pallet_balances::Config for Test { impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index d76f6d17490bd..5c44a7ed7a539 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -47,7 +47,6 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 9e13e465b16d5..c2fd3a851c319 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -153,7 +153,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -247,7 +246,6 @@ impl mock_democracy::Config for Test { impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type PalletsOrigin = OriginCaller; type WeightInfo = (); } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 743b1b5aef4c2..fe1779475a69a 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -47,7 +47,6 @@ impl frame_system::Config for Test { type BlockLength = (); type BlockWeights = (); type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 0d9bd5e2ee0de..d91f43b33af91 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -53,7 +53,6 @@ impl frame_system::Config for Test { type Nonce = u64; type Hash = H256; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -99,7 +98,6 @@ impl pallet_preimage::Config for Test { impl pallet_whitelist::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type Preimages = Preimage; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 4bac6a86b9c31..0cc32e50956c8 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -349,7 +349,6 @@ impl frame_system::pallet::Config for Runtime { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = H256; type Hashing = Hashing; diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 95c590ea0a5f0..2d8e45cbfc69f 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -55,7 +55,6 @@ use sp_storage::{StorageData, StorageKey}; /// # type BlockLength = (); /// # type RuntimeOrigin = RuntimeOrigin; /// # type RuntimeCall = RuntimeCall; -type RuntimeTask = RuntimeTask; /// # type Nonce = u64; /// # type Hash = Hash; /// # type Hashing = BlakeTwo256; From b704c8737ac5161813e00b69832a818a1f3c3a05 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 15:33:59 -0400 Subject: [PATCH 36/44] AggregatedTask impl WIP --- .../src/construct_runtime/expand/task.rs | 29 +++++++++++++++++++ frame/support/procedural/src/lib.rs | 2 -- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs index 6446f8d8739a8..1991180930255 100644 --- a/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -34,6 +34,16 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token task_variants.push(expand_variant(index, path, variant_name)); } } + use quote::ToTokens; + if !task_variants.is_empty() { + println!( + "{:#?}", + task_variants + .iter() + .map(|item| item.to_token_stream().to_string()) + .collect::>() + ); + } quote! { /// An aggregation of all `Task` enums across all pallets included in the current runtime. @@ -47,6 +57,25 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token #( #task_variants )* } + impl #scrate::traits::AggregatedTask for RuntimeTask { + fn is_valid(&self) -> bool { + use #scrate::traits::tasks::prelude::*; + todo!(); + } + + fn run(&self) -> Result<(), #scrate::traits::tasks::prelude::DispatchError> { + todo!(); + } + + fn weight(&self) -> Weight { + todo!(); + } + + fn task_index(&self) -> u64 { + todo!(); + } + } + #( #conversion_fns )* } } diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index f0d4c30a939c1..707295e70af16 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -633,7 +633,6 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// ``` /// /// where `TestDefaultConfig` was defined and registered as follows: -/// /// ```ignore /// pub struct TestDefaultConfig; /// @@ -660,7 +659,6 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// ``` /// /// The above call to `derive_impl` would expand to roughly the following: -/// /// ```ignore /// impl frame_system::Config for Test { /// use frame_system::config_preludes::TestDefaultConfig; From 77f5629dc37cc5908619f3319060b1a24cc07b75 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 15:41:11 -0400 Subject: [PATCH 37/44] include RuntimeTask in tasks-example --- bin/node/runtime/src/lib.rs | 1 + frame/examples/tasks-example/src/lib.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 455ded4194737..391646f55ec52 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -249,6 +249,7 @@ impl pallet_insecure_randomness_collective_flip::Config for Runtime {} impl tasks_example::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type RuntimeTask = RuntimeTask; } impl pallet_utility::Config for Runtime { diff --git a/frame/examples/tasks-example/src/lib.rs b/frame/examples/tasks-example/src/lib.rs index 97548a66cb791..2223ecbd0d30c 100644 --- a/frame/examples/tasks-example/src/lib.rs +++ b/frame/examples/tasks-example/src/lib.rs @@ -29,7 +29,7 @@ use sp_runtime::DispatchError; pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; + use frame_support::{pallet_prelude::*, traits::AggregatedTask}; use frame_system::pallet_prelude::*; // this can be auto-generated from the macros @@ -121,6 +121,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeTask: AggregatedTask; } #[pallet::pallet] From d74cc954d5d011b048ff21bb2d52ba3ea2fcbe72 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 16:08:49 -0400 Subject: [PATCH 38/44] aggregation almost working, issue with `decl.find_part("Task")` --- frame/support/procedural/src/construct_runtime/expand/task.rs | 2 ++ frame/support/procedural/src/construct_runtime/parse.rs | 2 +- frame/system/src/mock.rs | 1 + test-utils/runtime/src/lib.rs | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs index 1991180930255..948ed67689ffd 100644 --- a/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -25,6 +25,8 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token let mut task_variants = Vec::new(); for decl in pallet_decls { if let Some(_) = decl.find_part("Task") { + // TODO: for some reason `find_part` above never finds `Task` even when it is + // clearly in the pallet let variant_name = &decl.name; let path = &decl.path; let index = decl.index; diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index a0554b0782de4..88f3f14dc86c5 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -476,7 +476,7 @@ impl PalletPartKeyword { /// Returns the names of all pallet parts that allow to have a generic argument. fn all_generic_arg() -> &'static [&'static str] { - &["Event", "Error", "Origin", "Config"] + &["Event", "Error", "Origin", "Config", "Task"] } } diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index c016ea9e1cd14..670dbb266b036 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -91,6 +91,7 @@ impl Config for Test { type BlockLength = RuntimeBlockLength; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 0cc32e50956c8..4bac6a86b9c31 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -349,6 +349,7 @@ impl frame_system::pallet::Config for Runtime { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = Nonce; type Hash = H256; type Hashing = Hashing; From 5f6e016c53b51714f5fc8785f98c51a307f2db91 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 16:13:39 -0400 Subject: [PATCH 39/44] identify that there is an issue with decl.find_part WRT tasks --- frame/support/procedural/src/construct_runtime/expand/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs index 948ed67689ffd..c5f0807bd975e 100644 --- a/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -24,7 +24,7 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token let mut conversion_fns = Vec::new(); let mut task_variants = Vec::new(); for decl in pallet_decls { - if let Some(_) = decl.find_part("Task") { + if let Some(_) = decl.find_part("Tasks") { // TODO: for some reason `find_part` above never finds `Task` even when it is // clearly in the pallet let variant_name = &decl.name; From f823fc4951ffa751cc301cefb51fc7ddea89e6f4 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 14 Aug 2023 16:24:27 -0400 Subject: [PATCH 40/44] try Task not Tasks --- frame/support/procedural/src/construct_runtime/expand/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs index c5f0807bd975e..948ed67689ffd 100644 --- a/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -24,7 +24,7 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token let mut conversion_fns = Vec::new(); let mut task_variants = Vec::new(); for decl in pallet_decls { - if let Some(_) = decl.find_part("Tasks") { + if let Some(_) = decl.find_part("Task") { // TODO: for some reason `find_part` above never finds `Task` even when it is // clearly in the pallet let variant_name = &decl.name; From b551c344afce3d83bf6f40aecde79aab5259f75f Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 16 Aug 2023 13:55:59 -0400 Subject: [PATCH 41/44] reference Task and other pallet parts in the runtime * still has inexplicable import error --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 391646f55ec52..4ca0d5ef152c4 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1953,7 +1953,7 @@ construct_runtime!( MessageQueue: pallet_message_queue, Pov: frame_benchmarking_pallet_pov, Statement: pallet_statement, - TasksExample: tasks_example, + TasksExample: tasks_example::{Pallet, Storage, Call, Event, Task}, } ); From cfda4359bc9c08223036e660821ade2a4c4c7eda Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 17 Aug 2023 08:45:04 -0400 Subject: [PATCH 42/44] fix handling of tasks in expand_tt_default_parts --- bin/node/runtime/src/lib.rs | 2 +- .../src/pallet/expand/tt_default_parts.rs | 19 +++++++++++++------ .../procedural/src/pallet/parse/mod.rs | 10 ++++++++++ .../procedural/src/pallet/parse/tasks.rs | 12 +++++++++++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4ca0d5ef152c4..3ed10df2ba569 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1953,7 +1953,7 @@ construct_runtime!( MessageQueue: pallet_message_queue, Pov: frame_benchmarking_pallet_pov, Statement: pallet_statement, - TasksExample: tasks_example::{Pallet, Storage, Call, Event, Task}, + TasksExample: tasks_example::{Pallet, Storage, Call, Event, Task}, } ); diff --git a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs index ac5a6561c5428..abf72845b82f1 100644 --- a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs +++ b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs @@ -31,6 +31,19 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream { let call_part = def.call.as_ref().map(|_| quote::quote!(Call,)); + // TODO: maybe allow `task_enum: Option` to sit on `Def` itself? + let task_part = def.item.content.as_ref().and_then(|(_, items)| { + items.iter().find_map(|item| { + if let syn::Item::Enum(item_enum) = item { + if item_enum.ident == "Task" { + println!("found task enum!"); + return Some(item_enum) + } + } + None + }) + }); + let storage_part = (!def.storages.is_empty()).then(|| quote::quote!(Storage,)); let event_part = def.event.as_ref().map(|event| { @@ -67,12 +80,6 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream { .any(|c| matches!(c.composite_keyword, CompositeKeyword::HoldReason(_))) .then_some(quote::quote!(HoldReason,)); - let task_part = def - .composites - .iter() - .any(|c| matches!(c.composite_keyword, CompositeKeyword::Task(_))) - .then_some(quote::quote!(Task,)); - let lock_id_part = def .composites .iter() diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 5c4c4844607bf..bd40f62a68ba6 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -50,6 +50,7 @@ pub struct Def { pub pallet_struct: pallet_struct::PalletStructDef, pub hooks: Option, pub call: Option, + pub tasks: Option, pub storages: Vec, pub error: Option, pub event: Option, @@ -85,6 +86,7 @@ impl Def { let mut pallet_struct = None; let mut hooks = None; let mut call = None; + let mut tasks = None; let mut error = None; let mut event = None; let mut origin = None; @@ -119,6 +121,8 @@ impl Def { }, Some(PalletAttr::RuntimeCall(cw, span)) if call.is_none() => call = Some(call::CallDef::try_from(span, index, item, dev_mode, cw)?), + Some(PalletAttr::Tasks(span)) if tasks.is_none() => + tasks = Some(tasks::TasksDef::try_from(span, index, item)?), Some(PalletAttr::Error(span)) if error.is_none() => error = Some(error::ErrorDef::try_from(span, index, item)?), Some(PalletAttr::RuntimeEvent(span)) if event.is_none() => @@ -199,6 +203,7 @@ impl Def { .ok_or_else(|| syn::Error::new(item_span, "Missing `#[pallet::pallet]`"))?, hooks, call, + tasks, extra_constants, genesis_config, genesis_build, @@ -409,6 +414,7 @@ impl GenericKind { mod keyword { syn::custom_keyword!(origin); syn::custom_keyword!(call); + syn::custom_keyword!(tasks); syn::custom_keyword!(weight); syn::custom_keyword!(event); syn::custom_keyword!(config); @@ -472,6 +478,7 @@ enum PalletAttr { /// to zero. Now when there is a `weight` attribute on the `#[pallet::call]`, then that is used /// instead of the zero weight. So to say: it works together with `dev_mode`. RuntimeCall(Option, proc_macro2::Span), + Tasks(proc_macro2::Span), Error(proc_macro2::Span), RuntimeEvent(proc_macro2::Span), RuntimeOrigin(proc_macro2::Span), @@ -492,6 +499,7 @@ impl PalletAttr { Self::Pallet(span) => *span, Self::Hooks(span) => *span, Self::RuntimeCall(_, span) => *span, + Self::Tasks(span) => *span, Self::Error(span) => *span, Self::RuntimeEvent(span) => *span, Self::RuntimeOrigin(span) => *span, @@ -536,6 +544,8 @@ impl syn::parse::Parse for PalletAttr { false => Some(InheritedCallWeightAttr::parse(&content)?), }; Ok(PalletAttr::RuntimeCall(attr, span)) + } else if lookahead.peek(keyword::tasks) { + Ok(PalletAttr::Tasks(content.parse::()?.span())) } else if lookahead.peek(keyword::error) { Ok(PalletAttr::Error(content.parse::()?.span())) } else if lookahead.peek(keyword::event) { diff --git a/frame/support/procedural/src/pallet/parse/tasks.rs b/frame/support/procedural/src/pallet/parse/tasks.rs index bdfae571cd97f..23715014585aa 100644 --- a/frame/support/procedural/src/pallet/parse/tasks.rs +++ b/frame/support/procedural/src/pallet/parse/tasks.rs @@ -16,9 +16,10 @@ // limitations under the License. use derive_syn_parse::Parse; +use proc_macro2::Span; use syn::{ token::{Bracket, Paren}, - Expr, Ident, LitInt, Token, + Expr, Ident, Item, LitInt, Result, Token, }; pub mod keywords { @@ -31,6 +32,15 @@ pub mod keywords { custom_keyword!(pallet); } +pub struct TasksDef; + +impl TasksDef { + pub fn try_from(_span: Span, _index: usize, _item: &mut Item) -> Result { + // TODO: fill in + Ok(TasksDef {}) + } +} + #[derive(Parse)] pub enum TaskAttrType { #[peek(keywords::task_list, name = "#[pallet::task_list(..)]")] From da2a52436e9efebc081846b19cedf31f1ccd9c58 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 17 Aug 2023 11:18:33 -0400 Subject: [PATCH 43/44] item_enum --- .../procedural/src/pallet/expand/tt_default_parts.rs | 2 +- frame/support/procedural/src/pallet/parse/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs index abf72845b82f1..704151e6ec450 100644 --- a/frame/support/procedural/src/pallet/expand/tt_default_parts.rs +++ b/frame/support/procedural/src/pallet/expand/tt_default_parts.rs @@ -36,7 +36,7 @@ pub fn expand_tt_default_parts(def: &mut Def) -> proc_macro2::TokenStream { items.iter().find_map(|item| { if let syn::Item::Enum(item_enum) = item { if item_enum.ident == "Task" { - println!("found task enum!"); + println!("found task enum in tt_default_parts!"); return Some(item_enum) } } diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index bd40f62a68ba6..44bf12dc19f79 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -51,6 +51,7 @@ pub struct Def { pub hooks: Option, pub call: Option, pub tasks: Option, + pub task_enum: Option, pub storages: Vec, pub error: Option, pub event: Option, @@ -87,6 +88,7 @@ impl Def { let mut hooks = None; let mut call = None; let mut tasks = None; + let mut task_enum = None; let mut error = None; let mut event = None; let mut origin = None; @@ -100,6 +102,14 @@ impl Def { let mut composites: Vec = vec![]; for (index, item) in items.iter_mut().enumerate() { + // find manually specified `Task` enum, if present + if let syn::Item::Enum(item_enum) = item { + if item_enum.ident == "Task" { + println!("found task enum while parsing Def!"); + task_enum = Some(item_enum.clone()); + } + } + let pallet_attr: Option = helper::take_first_item_pallet_attr(item)?; match pallet_attr { @@ -204,6 +214,7 @@ impl Def { hooks, call, tasks, + task_enum, extra_constants, genesis_config, genesis_build, From fa2b824594a2ee0a79adf1038e073cd84b6a75be Mon Sep 17 00:00:00 2001 From: Nikhil Gupta <17176722+gupnik@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:59:12 +0530 Subject: [PATCH 44/44] Fixes build --- .../src/construct_runtime/expand/task.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/task.rs b/frame/support/procedural/src/construct_runtime/expand/task.rs index 948ed67689ffd..8d857ee4c07ef 100644 --- a/frame/support/procedural/src/construct_runtime/expand/task.rs +++ b/frame/support/procedural/src/construct_runtime/expand/task.rs @@ -50,8 +50,10 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token quote! { /// An aggregation of all `Task` enums across all pallets included in the current runtime. #[derive( - Copy, Clone, Eq, PartialEq, Ord, PartialOrd, - #scrate::codec::Encode, #scrate::codec::Decode, #scrate::codec::MaxEncodedLen, + Clone, Eq, PartialEq, + // Ord, PartialOrd, + #scrate::codec::Encode, #scrate::codec::Decode, + // #scrate::codec::MaxEncodedLen, #scrate::scale_info::TypeInfo, #scrate::RuntimeDebug, )] @@ -83,9 +85,11 @@ pub fn expand_outer_task(pallet_decls: &[Pallet], scrate: &TokenStream) -> Token } fn expand_conversion_fn(path: &PalletPath, variant_name: &Ident) -> TokenStream { + // Todo: Replace `Runtime` with the actual runtime ident + // `pallet` will probably not be needed when `Task` is generated by macro quote! { - impl From<#path::Task> for RuntimeTask { - fn from(hr: #path::Task) -> Self { + impl From<#path::pallet::Task> for RuntimeTask { + fn from(hr: #path::pallet::Task) -> Self { RuntimeTask::#variant_name(hr) } } @@ -93,8 +97,10 @@ fn expand_conversion_fn(path: &PalletPath, variant_name: &Ident) -> TokenStream } fn expand_variant(index: u8, path: &PalletPath, variant_name: &Ident) -> TokenStream { + // Todo: Replace `Runtime` with the actual runtime ident + // `pallet` will probably not be needed when `Task` is generated by macro quote! { #[codec(index = #index)] - #variant_name(#path::Task), + #variant_name(#path::pallet::Task), } }