Add retry mechanics to pallet-scheduler (#3060)

Fixes #3014 

This PR adds retry mechanics to `pallet-scheduler`, as described in the
issue above.

Users can now set a retry configuration for a task so that, in case its
scheduled run fails, it will be retried after a number of blocks, for a
specified number of times or until it succeeds.

If a retried task runs successfully before running out of retries, its
remaining retry counter will be reset to the initial value. If a retried
task runs out of retries, it will be removed from the schedule.

Tasks which need to be scheduled for a retry are still subject to weight
metering and agenda space, same as a regular task. Periodic tasks will
have their periodic schedule put on hold while the task is retrying.

---------

Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
georgepisaltu
2024-02-16 12:59:10 +02:00
committed by GitHub
parent ad68a05079
commit 9346019dad
9 changed files with 2292 additions and 377 deletions
@@ -17,27 +17,25 @@
//! Autogenerated weights for `pallet_scheduler`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner--ss9ysm1-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
//! HOSTNAME: `runner-grjcggob-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot
// target/production/polkadot
// benchmark
// pallet
// --chain=westend-dev
// --steps=50
// --repeat=20
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_scheduler
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --header=./file_header.txt
// --output=./runtime/westend/src/weights/
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_scheduler
// --chain=westend-dev
// --header=./polkadot/file_header.txt
// --output=./polkadot/runtime/westend/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -50,30 +48,30 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_scheduler`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_scheduler::WeightInfo for WeightInfo<T> {
/// Storage: Scheduler IncompleteSince (r:1 w:1)
/// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: `Scheduler::IncompleteSince` (r:1 w:1)
/// Proof: `Scheduler::IncompleteSince` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn service_agendas_base() -> Weight {
// Proof Size summary in bytes:
// Measured: `69`
// Estimated: `1489`
// Minimum execution time: 3_991_000 picoseconds.
Weight::from_parts(4_160_000, 0)
// Minimum execution time: 3_220_000 picoseconds.
Weight::from_parts(3_512_000, 0)
.saturating_add(Weight::from_parts(0, 1489))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Scheduler Agenda (r:1 w:1)
/// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 50]`.
fn service_agenda_base(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 3_647_000 picoseconds.
Weight::from_parts(6_608_270, 0)
// Minimum execution time: 3_565_000 picoseconds.
Weight::from_parts(6_102_216, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 2_516
.saturating_add(Weight::from_parts(892_866, 0).saturating_mul(s.into()))
// Standard Error: 1_413
.saturating_add(Weight::from_parts(339_016, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -81,36 +79,38 @@ impl<T: frame_system::Config> pallet_scheduler::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_552_000 picoseconds.
Weight::from_parts(5_836_000, 0)
// Minimum execution time: 2_940_000 picoseconds.
Weight::from_parts(3_070_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: Preimage PreimageFor (r:1 w:1)
/// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured)
/// Storage: Preimage StatusFor (r:1 w:1)
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
/// Storage: `Preimage::PreimageFor` (r:1 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `Measured`)
/// Storage: `Preimage::StatusFor` (r:1 w:0)
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// The range of component `s` is `[128, 4194304]`.
fn service_task_fetched(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `217 + s * (1 ±0)`
// Estimated: `3682 + s * (1 ±0)`
// Minimum execution time: 20_583_000 picoseconds.
Weight::from_parts(20_771_000, 0)
// Minimum execution time: 16_602_000 picoseconds.
Weight::from_parts(16_834_000, 0)
.saturating_add(Weight::from_parts(0, 3682))
// Standard Error: 11
.saturating_add(Weight::from_parts(2_250, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
// Standard Error: 10
.saturating_add(Weight::from_parts(1_307, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into()))
}
/// Storage: Scheduler Lookup (r:0 w:1)
/// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: `Scheduler::Lookup` (r:0 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
fn service_task_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_271_000 picoseconds.
Weight::from_parts(7_447_000, 0)
// Minimum execution time: 4_202_000 picoseconds.
Weight::from_parts(4_383_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -118,90 +118,169 @@ impl<T: frame_system::Config> pallet_scheduler::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_547_000 picoseconds.
Weight::from_parts(5_776_000, 0)
// Minimum execution time: 2_917_000 picoseconds.
Weight::from_parts(3_043_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_dispatch_signed() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_480_000 picoseconds.
Weight::from_parts(2_628_000, 0)
// Minimum execution time: 1_707_000 picoseconds.
Weight::from_parts(1_802_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_dispatch_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_479_000 picoseconds.
Weight::from_parts(2_626_000, 0)
// Minimum execution time: 1_671_000 picoseconds.
Weight::from_parts(1_796_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: Scheduler Agenda (r:1 w:1)
/// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 49]`.
fn schedule(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 13_350_000 picoseconds.
Weight::from_parts(15_289_847, 0)
// Minimum execution time: 9_313_000 picoseconds.
Weight::from_parts(12_146_613, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 5_375
.saturating_add(Weight::from_parts(974_567, 0).saturating_mul(s.into()))
// Standard Error: 1_381
.saturating_add(Weight::from_parts(360_418, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Scheduler Agenda (r:1 w:1)
/// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen)
/// Storage: Scheduler Lookup (r:0 w:1)
/// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Lookup` (r:0 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn cancel(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 17_646_000 picoseconds.
Weight::from_parts(15_858_434, 0)
// Minimum execution time: 13_079_000 picoseconds.
Weight::from_parts(12_921_017, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 5_354
.saturating_add(Weight::from_parts(1_697_642, 0).saturating_mul(s.into()))
// Standard Error: 1_112
.saturating_add(Weight::from_parts(538_089, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Scheduler Lookup (r:1 w:1)
/// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: Scheduler Agenda (r:1 w:1)
/// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen)
/// Storage: `Scheduler::Lookup` (r:1 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 49]`.
fn schedule_named(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `293 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 16_419_000 picoseconds.
Weight::from_parts(19_868_760, 0)
// Minimum execution time: 12_458_000 picoseconds.
Weight::from_parts(16_009_539, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 6_915
.saturating_add(Weight::from_parts(1_010_225, 0).saturating_mul(s.into()))
// Standard Error: 2_260
.saturating_add(Weight::from_parts(399_245, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Scheduler Lookup (r:1 w:1)
/// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: Scheduler Agenda (r:1 w:1)
/// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen)
/// Storage: `Scheduler::Lookup` (r:1 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn cancel_named(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `319 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 19_574_000 picoseconds.
Weight::from_parts(18_453_197, 0)
// Minimum execution time: 15_173_000 picoseconds.
Weight::from_parts(15_602_728, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 6_009
.saturating_add(Weight::from_parts(1_707_130, 0).saturating_mul(s.into()))
// Standard Error: 1_302
.saturating_add(Weight::from_parts(557_878, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Scheduler::Retries` (r:1 w:2)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Lookup` (r:0 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn schedule_retry(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `197`
// Estimated: `42428`
// Minimum execution time: 13_531_000 picoseconds.
Weight::from_parts(13_985_249, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 619
.saturating_add(Weight::from_parts(39_068, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn set_retry() -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 8_050_000 picoseconds.
Weight::from_parts(8_440_627, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Lookup` (r:1 w:0)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn set_retry_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `325 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 10_876_000 picoseconds.
Weight::from_parts(11_708_172, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn cancel_retry() -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 8_050_000 picoseconds.
Weight::from_parts(8_440_627, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Lookup` (r:1 w:0)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn cancel_retry_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `325 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 10_876_000 picoseconds.
Weight::from_parts(11_708_172, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}