Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

FRAME: General System for Recognizing and Executing Service Work #14329

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
71e16aa
initial API for Task trait
sam0x17 Jun 8, 2023
9a70eaf
Merge remote-tracking branch 'origin/master' into sam-tasks
sam0x17 Jun 16, 2023
01e3bbe
remove lifetime as per basti's suggestion
sam0x17 Jun 16, 2023
28f13cf
bound Task on FullCodec
sam0x17 Jun 19, 2023
f22054b
fix imports
sam0x17 Jun 19, 2023
4682e6f
set task_index to const
sam0x17 Jul 4, 2023
389131c
change to an associated const
sam0x17 Jul 5, 2023
4756ade
Merge remote-tracking branch 'origin/master' into sam-tasks
sam0x17 Jul 10, 2023
19f6ef6
compiles using wrapper PalletTask<T: Config> trait ... WIP
sam0x17 Jul 12, 2023
f967a80
example task impl using a wrapper task possibly working (compiles)
sam0x17 Jul 12, 2023
777c0c8
Merge remote-tracking branch 'origin/master' into sam-tasks
sam0x17 Jul 17, 2023
e07c25a
use generic ExampleTask<T: Config>
sam0x17 Jul 17, 2023
b4c57ba
use frame_support::Never
sam0x17 Jul 17, 2023
32bbd4e
refactor to be more like Call
sam0x17 Jul 20, 2023
ba54c4e
first attempt at implementing do_task
sam0x17 Jul 20, 2023
acf0d27
bind T and Task by TypeInfo
sam0x17 Jul 24, 2023
2b1083a
Merge remote-tracking branch 'origin/master' into sam-tasks
sam0x17 Aug 2, 2023
ddc2e9d
add parsing for task-related attributes
sam0x17 Aug 3, 2023
f7ca7d5
add tests for task related attribute macros
sam0x17 Aug 3, 2023
4d30f6c
first stab at validate_unsigned within tasks_example pallet
sam0x17 Aug 4, 2023
34e0990
add comments
sam0x17 Aug 4, 2023
f29f0a0
clean up
sam0x17 Aug 4, 2023
36dae43
improve scaffold a bit
sam0x17 Aug 4, 2023
d20f312
rename inner `#[pallet::tasks()]` to #[pallet::task_list(..)]` to red…
sam0x17 Aug 4, 2023
e7092b7
Merge remote-tracking branch 'origin/master' into sam-tasks
sam0x17 Aug 7, 2023
af70bd9
add Task as a composite enum
sam0x17 Aug 7, 2023
260a715
hook up RuntimeTask to construct_runtime
sam0x17 Aug 8, 2023
a0fc4c8
do_task system pallet extrinsic WIP (solved RuntimeTask issue)
sam0x17 Aug 9, 2023
49353a7
do_task extrinsic on system pallet done
sam0x17 Aug 10, 2023
4ac3fc7
fix comment
sam0x17 Aug 10, 2023
b26602d
suppress warning
sam0x17 Aug 10, 2023
a40a03e
context information on #[pallet::error] = bad
sam0x17 Aug 10, 2023
131766f
very granular task-related events (will probably reduce this)
sam0x17 Aug 10, 2023
6be3ce3
clean up old code
sam0x17 Aug 14, 2023
b553a3b
remove TaskInvalid event based on feedback
sam0x17 Aug 14, 2023
45e69f8
add AggregatedTask trait which we can use in RuntimeTask
sam0x17 Aug 14, 2023
af5f469
add tasks-example pallet to construct_runtime temporarily for testing
sam0x17 Aug 14, 2023
de82efe
refine tasks re-export paths
sam0x17 Aug 14, 2023
923cfc8
inject `RuntimeTask` into all construct_runtime!'s
sam0x17 Aug 14, 2023
0f62953
clean up
sam0x17 Aug 14, 2023
b704c87
AggregatedTask impl WIP
sam0x17 Aug 14, 2023
77f5629
include RuntimeTask in tasks-example
sam0x17 Aug 14, 2023
d74cc95
aggregation almost working, issue with `decl.find_part("Task")`
sam0x17 Aug 14, 2023
5f6e016
identify that there is an issue with decl.find_part WRT tasks
sam0x17 Aug 14, 2023
f823fc4
try Task not Tasks
sam0x17 Aug 14, 2023
b551c34
reference Task and other pallet parts in the runtime
sam0x17 Aug 16, 2023
cfda435
fix handling of tasks in expand_tt_default_parts
sam0x17 Aug 17, 2023
da2a524
item_enum
sam0x17 Aug 17, 2023
fa2b824
Fixes build
gupnik Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frame/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
43 changes: 43 additions & 0 deletions frame/support/src/traits/tasks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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 codec::FullCodec;
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 {
type Enumeration: Iterator<Item = Self>;
sam0x17 marked this conversation as resolved.
Show resolved Hide resolved

/// 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.
fn task_index(&self) -> usize;
sam0x17 marked this conversation as resolved.
Show resolved Hide resolved

/// Performs the work for this particular `Task` variant.
fn run(&self) -> Result<(), DispatchError>;
}
Loading