mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
Adds ability to trigger tasks via unsigned transactions (#4075)
This PR updates the `validate_unsigned` hook for `frame_system` to allow valid tasks to be submitted as unsigned transactions. It also updates the task example to be able to submit such transactions via an off-chain worker. --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -2465,6 +2465,9 @@ pub mod pallet_macros {
|
||||
/// Finally, the `RuntimeTask` can then used by a script or off-chain worker to create and
|
||||
/// submit such tasks via an extrinsic defined in `frame_system` called `do_task`.
|
||||
///
|
||||
/// When submitted as unsigned transactions (for example via an off-chain workder), note
|
||||
/// that the tasks will be executed in a random order.
|
||||
///
|
||||
/// ## Example
|
||||
#[doc = docify::embed!("src/tests/tasks.rs", tasks_example)]
|
||||
/// Now, this can be executed as follows:
|
||||
|
||||
@@ -46,6 +46,10 @@ pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq {
|
||||
fn iter() -> Self::Enumeration;
|
||||
|
||||
/// Checks if a particular instance of this `Task` variant is a valid piece of work.
|
||||
///
|
||||
/// This is used to validate tasks for unsigned execution. Hence, it MUST be cheap
|
||||
/// with minimal to no storage reads. Else, it can make the blockchain vulnerable
|
||||
/// to DoS attacks.
|
||||
fn is_valid(&self) -> bool;
|
||||
|
||||
/// Performs the work for this particular `Task` variant.
|
||||
|
||||
Reference in New Issue
Block a user