diff --git a/Cargo.lock b/Cargo.lock index 397d0c7fe823..302b86ac47c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15688,17 +15688,10 @@ name = "pallet-timestamp" version = "27.0.0" dependencies = [ "docify", - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-core 28.0.0", - "sp-inherents 26.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", - "sp-storage 19.0.0", "sp-timestamp 26.0.0", ] diff --git a/substrate/frame/timestamp/Cargo.toml b/substrate/frame/timestamp/Cargo.toml index 75788aef348a..f078bce3f0c7 100644 --- a/substrate/frame/timestamp/Cargo.toml +++ b/substrate/frame/timestamp/Cargo.toml @@ -18,48 +18,25 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive", "max-encoded-len"], workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } +frame = { workspace = true, features = ["runtime"] } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-inherents = { workspace = true } -sp-io = { optional = true, workspace = true } -sp-runtime = { workspace = true } -sp-storage = { workspace = true } sp-timestamp = { workspace = true } docify = { workspace = true } -[dev-dependencies] -sp-core = { workspace = true, default-features = true } -sp-io = { workspace = true, default-features = true } - [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "scale-info/std", - "sp-core/std", - "sp-inherents/std", - "sp-io?/std", - "sp-runtime/std", - "sp-storage/std", "sp-timestamp/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-io", - "sp-runtime/runtime-benchmarks", + "frame/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "sp-runtime/try-runtime", + "frame/try-runtime", ] diff --git a/substrate/frame/timestamp/src/benchmarking.rs b/substrate/frame/timestamp/src/benchmarking.rs index ef4d36c57691..cf9a8c971a1f 100644 --- a/substrate/frame/timestamp/src/benchmarking.rs +++ b/substrate/frame/timestamp/src/benchmarking.rs @@ -18,13 +18,8 @@ //! Timestamp pallet benchmarking. #![cfg(feature = "runtime-benchmarks")] - -use frame_benchmarking::{benchmarking::add_to_whitelist, v2::*}; -use frame_support::traits::OnFinalize; -use frame_system::RawOrigin; -use sp_storage::TrackedStorageKey; - use crate::*; +use frame::benchmarking::prelude::*; const MAX_TIME: u32 = 100; @@ -37,7 +32,7 @@ mod benchmarks { let t = MAX_TIME; // Ignore write to `DidUpdate` since it transient. let did_update_key = DidUpdate::::hashed_key().to_vec(); - add_to_whitelist(TrackedStorageKey { + add_to_whitelist(frame::traits::TrackedStorageKey { key: did_update_key, reads: 0, writes: 1, diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index 5cb6c859c417..3992701f806c 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -52,12 +52,11 @@ //! //! ``` //! use pallet_timestamp::{self as timestamp}; +//! use frame::prelude::*; //! -//! #[frame_support::pallet] +//! #[frame::pallet] //! pub mod pallet { //! use super::*; -//! use frame_support::pallet_prelude::*; -//! use frame_system::pallet_prelude::*; //! //! #[pallet::pallet] //! pub struct Pallet(_); @@ -88,22 +87,22 @@ //! included in a block. //! //! To provide inherent data to the runtime, this pallet implements -//! [`ProvideInherent`](frame_support::inherent::ProvideInherent). It will only create an inherent -//! if the [`Call::set`] dispatchable is called, using the -//! [`inherent`](frame_support::pallet_macros::inherent) macro which enables validator nodes to call +//! [`ProvideInherent`](frame::deps::frame_support::inherent::ProvideInherent). It will only create +//! an inherent if the [`Call::set`] dispatchable is called, using the +//! [`inherent`](frame::pallet_macros::inherent) macro which enables validator nodes to call //! into the runtime to check that the timestamp provided is valid. -//! The implementation of [`ProvideInherent`](frame_support::inherent::ProvideInherent) specifies a -//! constant called `MAX_TIMESTAMP_DRIFT_MILLIS` which is used to determine the acceptable range for -//! a valid timestamp. If a block author sets a timestamp to anything that is more than this -//! constant, a validator node will reject the block. +//! The implementation of [`ProvideInherent`](frame::deps::frame_support::inherent::ProvideInherent) +//! specifies a constant called `MAX_TIMESTAMP_DRIFT_MILLIS` which is used to determine the +//! acceptable range for a valid timestamp. If a block author sets a timestamp to anything that is +//! more than this constant, a validator node will reject the block. //! //! The pallet also ensures that a timestamp is set at the start of each block by running an -//! assertion in the `on_finalize` runtime hook. See [`frame_support::traits::Hooks`] for more +//! assertion in the `on_finalize` runtime hook. See [`frame::traits::Hooks`] for more //! information about how hooks work. //! //! Because inherents are applied to a block in the order they appear in the runtime //! construction, the index of this pallet in -//! [`construct_runtime`](frame_support::construct_runtime) must always be less than any other +//! [`construct_runtime`](construct_runtime) must always be less than any other //! pallet that depends on it. //! //! The [`Config::OnTimestampSet`] configuration trait can be set to another pallet we want to @@ -134,18 +133,18 @@ mod tests; pub mod weights; use core::{cmp, result}; -use frame_support::traits::{OnTimestampSet, Time, UnixTime}; -use sp_runtime::traits::{AtLeast32Bit, SaturatedConversion, Scale, Zero}; +use frame::{ + runtime::prelude::*, + traits::{OnTimestampSet, Scale, Time, UnixTime}, +}; use sp_timestamp::{InherentError, InherentType, INHERENT_IDENTIFIER}; pub use weights::WeightInfo; pub use pallet::*; -#[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; - use frame_support::{derive_impl, pallet_prelude::*}; - use frame_system::pallet_prelude::*; /// Default preludes for [`Config`]. pub mod config_preludes { @@ -157,7 +156,7 @@ pub mod pallet { #[derive_impl(frame_system::config_preludes::TestDefaultConfig, no_aggregated_types)] impl frame_system::DefaultConfig for TestDefaultConfig {} - #[frame_support::register_default_impl(TestDefaultConfig)] + #[register_default_impl(TestDefaultConfig)] impl DefaultConfig for TestDefaultConfig { type Moment = u64; type OnTimestampSet = (); @@ -354,7 +353,7 @@ impl Time for Pallet { /// A type that represents a unit of time. type Moment = T::Moment; - fn now() -> Self::Moment { + fn now() -> as Time>::Moment { Now::::get() } } diff --git a/substrate/frame/timestamp/src/mock.rs b/substrate/frame/timestamp/src/mock.rs index eb4fdbe71fa7..e13ccdbdc4e0 100644 --- a/substrate/frame/timestamp/src/mock.rs +++ b/substrate/frame/timestamp/src/mock.rs @@ -19,15 +19,11 @@ use super::*; use crate as pallet_timestamp; - -use frame_support::{derive_impl, parameter_types, traits::ConstU64}; -use sp_io::TestExternalities; -use sp_runtime::BuildStorage; - -type Block = frame_system::mocking::MockBlock; +use frame::testing_prelude::*; +type Block = MockBlock; type Moment = u64; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, diff --git a/substrate/frame/timestamp/src/tests.rs b/substrate/frame/timestamp/src/tests.rs index a83855561889..bd45f554e1eb 100644 --- a/substrate/frame/timestamp/src/tests.rs +++ b/substrate/frame/timestamp/src/tests.rs @@ -18,7 +18,7 @@ //! Tests for the Timestamp module. use crate::mock::*; -use frame_support::assert_ok; +use frame::testing_prelude::*; #[test] fn timestamp_works() { diff --git a/substrate/frame/timestamp/src/weights.rs b/substrate/frame/timestamp/src/weights.rs index 9f16a82653a9..f0fed92780ee 100644 --- a/substrate/frame/timestamp/src/weights.rs +++ b/substrate/frame/timestamp/src/weights.rs @@ -46,7 +46,7 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_timestamp`.