From 8443538fb80939ec0f1c76b2b644cabc7e6f2c48 Mon Sep 17 00:00:00 2001 From: Fahrrader Date: Tue, 11 Jan 2022 11:43:19 +0000 Subject: [PATCH] refactor(scheduler): id restricted to 16 bytes [CORE-245] --- --- a/pallets/scheduler/src/lib.rs +++ b/pallets/scheduler/src/lib.rs @@ -76,6 +76,8 @@ use up_sponsorship::SponsorshipHandler; use scale_info::TypeInfo; +pub const MAX_TASK_ID_LENGTH_IN_BYTES: u32 = 16; + /// Our pallet's configuration trait. All our types and constants go in here. If the /// pallet is dependent on specific other pallets, then their configuration traits /// should be added to our implied traits list. @@ -569,8 +571,10 @@ origin: T::PalletsOrigin, call: ::Call, ) -> Result, DispatchError> { - // ensure id it is unique - if Lookup::::contains_key(&id) { + // ensure id length does not exceed expectations & is unique + if id.len() > MAX_TASK_ID_LENGTH_IN_BYTES.try_into().unwrap() + || Lookup::::contains_key(&id) + { return Err(Error::::FailedToSchedule.into()); } @@ -792,6 +796,8 @@ } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + // todo check current cumulus implementation, add changes accordingly, do something with signedExtra and (un)checked extrinsic (integral to Scheduler?) + // todo to include pallet in runtime, not only uncomment but also (implement?) trait type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( -- gitstuff