diff --git a/operator/Cargo.lock b/operator/Cargo.lock index f72b6594..b9cd7b17 100644 --- a/operator/Cargo.lock +++ b/operator/Cargo.lock @@ -1610,6 +1610,7 @@ dependencies = [ "pallet-mmr", "pallet-multisig", "pallet-preimage", + "pallet-scheduler", "pallet-session", "pallet-sudo", "pallet-timestamp", @@ -5972,6 +5973,23 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-scheduler" +version = "39.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=stable2409#43d7b1e329f50a37cbd67e15aae70c60556cbb59" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-weights", +] + [[package]] name = "pallet-session" version = "38.0.0" diff --git a/operator/Cargo.toml b/operator/Cargo.toml index 61c997af..201edf66 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -87,6 +87,7 @@ pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } diff --git a/operator/runtime/Cargo.toml b/operator/runtime/Cargo.toml index 3e853cc8..5d203cbf 100644 --- a/operator/runtime/Cargo.toml +++ b/operator/runtime/Cargo.toml @@ -28,6 +28,7 @@ pallet-balances.workspace = true pallet-grandpa.workspace = true pallet-multisig.workspace = true pallet-preimage.workspace = true +pallet-scheduler.workspace = true pallet-session.workspace = true pallet-sudo.workspace = true pallet-timestamp.workspace = true @@ -97,6 +98,7 @@ std = [ "pallet-multisig/std", "pallet-mmr/std", "pallet-preimage/std", + "pallet-scheduler/std", "pallet-session/std", "pallet-sudo/std", "pallet-timestamp/std", @@ -146,6 +148,7 @@ runtime-benchmarks = [ "pallet-grandpa/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", @@ -169,6 +172,7 @@ try-runtime = [ "pallet-grandpa/try-runtime", "pallet-multisig/try-runtime", "pallet-preimage/try-runtime", + "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/operator/runtime/src/benchmarks.rs b/operator/runtime/src/benchmarks.rs index 71a6da76..e03bd296 100644 --- a/operator/runtime/src/benchmarks.rs +++ b/operator/runtime/src/benchmarks.rs @@ -27,8 +27,9 @@ frame_benchmarking::define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] [pallet_balances, Balances] - [pallet_preimage, Preimage] [pallet_multisig, Multisig] + [pallet_preimage, Preimage] + [pallet_scheduler, Scheduler] [pallet_timestamp, Timestamp] [pallet_utility, Utility] [pallet_sudo, Sudo] diff --git a/operator/runtime/src/configs/mod.rs b/operator/runtime/src/configs/mod.rs index d6baeee2..3413bf7e 100644 --- a/operator/runtime/src/configs/mod.rs +++ b/operator/runtime/src/configs/mod.rs @@ -23,32 +23,26 @@ // // For more information, please refer to -use crate::EvmChainId; -use crate::OriginCaller; -use crate::Timestamp; -use crate::STORAGE_BYTE_FEE; -use crate::SUPPLY_FACTOR; -use crate::UNIT; -use crate::{Historical, SessionKeys, ValidatorSet}; - // Local module imports use super::{ - deposit, AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, Hash, Nonce, - PalletInfo, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, - RuntimeOrigin, RuntimeTask, Session, System, EXISTENTIAL_DEPOSIT, SLOT_DURATION, VERSION, + deposit, AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, EvmChainId, + Hash, Historical, Nonce, OriginCaller, PalletInfo, Preimage, Runtime, RuntimeCall, + RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, + SessionKeys, System, Timestamp, ValidatorSet, EXISTENTIAL_DEPOSIT, SLOT_DURATION, + STORAGE_BYTE_FEE, SUPPLY_FACTOR, UNIT, VERSION, }; // Substrate and Polkadot dependencies use codec::{Decode, Encode}; -use datahaven_runtime_common::gas::WEIGHT_PER_GAS; -use datahaven_runtime_common::time::{EpochDurationInBlocks, MILLISECS_PER_BLOCK, MINUTES}; -use frame_support::traits::fungible::HoldConsideration; -use frame_support::traits::LinearStoragePrice; +use datahaven_runtime_common::{ + gas::WEIGHT_PER_GAS, + time::{EpochDurationInBlocks, MILLISECS_PER_BLOCK, MINUTES}, +}; use frame_support::{ derive_impl, parameter_types, traits::{ - fungible::{Balanced, Credit, Inspect}, - ConstU128, ConstU32, ConstU64, ConstU8, FindAuthor, KeyOwnerProofSystem, OnUnbalanced, - VariantCountOf, + fungible::{Balanced, Credit, HoldConsideration, Inspect}, + ConstU128, ConstU32, ConstU64, ConstU8, EqualPrivilegeOnly, FindAuthor, + KeyOwnerProofSystem, LinearStoragePrice, OnUnbalanced, VariantCountOf, }, weights::{ constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}, @@ -279,6 +273,24 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub MaximumSchedulerWeight: Weight = NORMAL_DISPATCH_RATIO * RuntimeBlockWeights::get().max_block; + pub const NoPreimagePostponement: Option = Some(10); +} + +impl pallet_scheduler::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = ConstU32<50>; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type Preimages = Preimage; + type WeightInfo = (); +} + impl pallet_validator_set::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AddRemoveOrigin = EnsureRoot; diff --git a/operator/runtime/src/lib.rs b/operator/runtime/src/lib.rs index 3048c9d4..279714fc 100644 --- a/operator/runtime/src/lib.rs +++ b/operator/runtime/src/lib.rs @@ -258,6 +258,9 @@ mod runtime { #[runtime::pallet_index(20)] pub type Utility = pallet_utility; + #[runtime::pallet_index(21)] + pub type Scheduler = pallet_scheduler; + #[runtime::pallet_index(22)] pub type Preimage = pallet_preimage;