Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate scheduler traits v1 and v2 #3718

13 changes: 13 additions & 0 deletions prdoc/pr_3718.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Deprecate scheduler traits v1 and v2

doc:
- audience: Runtime Dev
description: |
Add `#[deprecated]` attribute to scheduler traits v1 and v2 to deprecate old versions

crates:
- name: frame-support
- name: pallet-scheduler
3 changes: 3 additions & 0 deletions substrate/frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,7 @@ impl<T: Config> Pallet<T> {
}
}

#[allow(deprecated)]
impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
for Pallet<T>
{
Expand Down Expand Up @@ -1480,6 +1481,8 @@ impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall
}
}

// TODO: migrate `schedule::v2::Anon` to `v3`
#[allow(deprecated)]
impl<T: Config> schedule::v2::Named<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
for Pallet<T>
{
Expand Down
18 changes: 16 additions & 2 deletions substrate/frame/support/src/traits/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<T: Decode, H> MaybeHashed<T, H> {
}
}

// TODO: deprecate
#[deprecated(note = "Use `v3` instead. Will be removed after September 2024.")]
pub mod v1 {
use super::*;

Expand Down Expand Up @@ -218,10 +218,12 @@ pub mod v1 {
fn next_dispatch_time(id: Vec<u8>) -> Result<BlockNumber, ()>;
}

#[allow(deprecated)]
impl<T, BlockNumber, Call, RuntimeOrigin> Anon<BlockNumber, Call, RuntimeOrigin> for T
where
T: v2::Anon<BlockNumber, Call, RuntimeOrigin>,
{
#[allow(deprecated)]
type Address = T::Address;

fn schedule(
Expand All @@ -232,29 +234,36 @@ pub mod v1 {
call: Call,
) -> Result<Self::Address, DispatchError> {
let c = MaybeHashed::<Call, T::Hash>::Value(call);

#[allow(deprecated)]
T::schedule(when, maybe_periodic, priority, origin, c)
}

fn cancel(address: Self::Address) -> Result<(), ()> {
#[allow(deprecated)]
T::cancel(address)
}

fn reschedule(
address: Self::Address,
when: DispatchTime<BlockNumber>,
) -> Result<Self::Address, DispatchError> {
#[allow(deprecated)]
T::reschedule(address, when)
}

fn next_dispatch_time(address: Self::Address) -> Result<BlockNumber, ()> {
#[allow(deprecated)]
T::next_dispatch_time(address)
}
}

#[allow(deprecated)]
impl<T, BlockNumber, Call, RuntimeOrigin> Named<BlockNumber, Call, RuntimeOrigin> for T
where
T: v2::Named<BlockNumber, Call, RuntimeOrigin>,
{
#[allow(deprecated)]
type Address = T::Address;

fn schedule_named(
Expand All @@ -266,27 +275,31 @@ pub mod v1 {
call: Call,
) -> Result<Self::Address, ()> {
let c = MaybeHashed::<Call, T::Hash>::Value(call);
#[allow(deprecated)]
T::schedule_named(id, when, maybe_periodic, priority, origin, c)
}

fn cancel_named(id: Vec<u8>) -> Result<(), ()> {
#[allow(deprecated)]
T::cancel_named(id)
}

fn reschedule_named(
id: Vec<u8>,
when: DispatchTime<BlockNumber>,
) -> Result<Self::Address, DispatchError> {
#[allow(deprecated)]
T::reschedule_named(id, when)
}

fn next_dispatch_time(id: Vec<u8>) -> Result<BlockNumber, ()> {
#[allow(deprecated)]
T::next_dispatch_time(id)
}
}
}

// TODO: deprecate
#[deprecated(note = "Use `v3` instead. Will be removed after September 2024.")]
pub mod v2 {
use super::*;

Expand Down Expand Up @@ -478,4 +491,5 @@ pub mod v3 {
}
}

#[allow(deprecated)]
pub use v1::*;
Loading