diff --git a/Cargo.lock b/Cargo.lock index 3c55a14256c5..639cfe7d9741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15978,19 +15978,13 @@ dependencies = [ name = "pallet-verify-signature" version = "1.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "pallet-balances 28.0.0", "pallet-collective 28.0.0", "pallet-root-testing 4.0.0", "pallet-timestamp 27.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", - "sp-weights 27.0.0", ] [[package]] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index b3e340cbcbff..4b5640b082eb 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -202,9 +202,10 @@ pub mod prelude { /// Dispatch types from `frame-support`, other fundamental traits #[doc(no_inline)] - pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; + pub use frame_support::dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo}; pub use frame_support::traits::{ Contains, EstimateNextSessionRotation, IsSubType, OnRuntimeUpgrade, OneSessionHandler, + OriginTrait, }; /// Pallet prelude of `frame-system`. @@ -219,8 +220,13 @@ pub mod prelude { #[doc(no_inline)] pub use super::derive::*; - /// All hashing related things - pub use super::hashing::*; + /// All crypto related things. + pub use super::cryptography::*; + + /// All account related things. + pub use super::account::*; + + pub use crate::transaction::*; /// All arithmetic types and traits used for safe math. pub use super::arithmetic::*; @@ -375,7 +381,7 @@ pub mod runtime { }; /// Used for simple fee calculation. - pub use frame_support::weights::{self, FixedFee, NoFee}; + pub use frame_support::weights::{self, FixedFee, NoFee, Weight}; /// Primary types used to parameterize `EnsureOrigin` and `EnsureRootWithArg`. pub use frame_system::{ @@ -504,7 +510,7 @@ pub mod runtime { #[cfg(feature = "std")] pub mod testing_prelude { pub use sp_core::storage::Storage; - pub use sp_runtime::BuildStorage; + pub use sp_runtime::{testing::UintAuthorityId, BuildStorage}; } } @@ -540,9 +546,36 @@ pub mod derive { pub use sp_runtime::RuntimeDebug; } -pub mod hashing { - pub use sp_core::{hashing::*, H160, H256, H512, U256, U512}; - pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256}; +pub mod cryptography { + pub use sp_core::{ + crypto::{VrfPublic, VrfSecret, Wraps}, + hashing::*, + Pair, H160, H256, H512, U256, U512, + }; + pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256, Verify}; +} + +/// All account management related traits. +/// +/// This is already part of the [`prelude`]. +pub mod account { + pub use frame_support::traits::{ChangeMembers, EitherOfDiverse, InitializeMembers}; + pub use sp_runtime::traits::IdentifyAccount; +} + +/// Systems involved in transaction fulfilment. +/// +/// This is already part of the [`prelude`]. +pub mod transaction { + pub use sp_runtime::{ + generic::ExtensionVersion, + impl_tx_ext_default, + traits::{ + AsTransactionAuthorizedOrigin, DispatchTransaction, TransactionExtension, + ValidateResult, + }, + transaction_validity::{InvalidTransaction, ValidTransaction}, + }; } /// Access to all of the dependencies of this crate. In case the prelude re-exports are not enough, diff --git a/substrate/frame/verify-signature/Cargo.toml b/substrate/frame/verify-signature/Cargo.toml index 37cc6c0b3065..4bfc73e3c0b8 100644 --- a/substrate/frame/verify-signature/Cargo.toml +++ b/substrate/frame/verify-signature/Cargo.toml @@ -17,54 +17,36 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } -sp-weights = { features = ["serde"], workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } pallet-collective = { workspace = true, default-features = true } pallet-root-testing = { workspace = true, default-features = true } pallet-timestamp = { workspace = true, default-features = true } -sp-core = { workspace = true, default-features = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "pallet-balances/std", "pallet-collective/std", "pallet-root-testing/std", "pallet-timestamp/std", "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-weights/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", "pallet-collective/try-runtime", "pallet-root-testing/try-runtime", "pallet-timestamp/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/verify-signature/src/benchmarking.rs b/substrate/frame/verify-signature/src/benchmarking.rs index 99e893e6f6ab..8407aea95309 100644 --- a/substrate/frame/verify-signature/src/benchmarking.rs +++ b/substrate/frame/verify-signature/src/benchmarking.rs @@ -20,23 +20,12 @@ #![cfg(feature = "runtime-benchmarks")] extern crate alloc; - use super::*; +use frame::benchmarking::prelude::{frame_system::Call as SystemCall, *}; #[allow(unused)] use crate::{extension::VerifySignature, Config, Pallet as VerifySignaturePallet}; use alloc::vec; -use frame_benchmarking::{v2::*, BenchmarkError}; -use frame_support::{ - dispatch::{DispatchInfo, GetDispatchInfo}, - pallet_prelude::TransactionSource, -}; -use frame_system::{Call as SystemCall, RawOrigin}; -use sp_io::hashing::blake2_256; -use sp_runtime::{ - generic::ExtensionVersion, - traits::{AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable}, -}; pub trait BenchmarkHelper { fn create_signature(entropy: &[u8], msg: &[u8]) -> (Signature, Signer); diff --git a/substrate/frame/verify-signature/src/extension.rs b/substrate/frame/verify-signature/src/extension.rs index d48991e7a1da..aa802d6238b4 100644 --- a/substrate/frame/verify-signature/src/extension.rs +++ b/substrate/frame/verify-signature/src/extension.rs @@ -20,23 +20,13 @@ use crate::{Config, WeightInfo}; use codec::{Decode, Encode}; -use frame_support::{pallet_prelude::TransactionSource, traits::OriginTrait}; +use frame::runtime::prelude::*; use scale_info::TypeInfo; -use sp_io::hashing::blake2_256; -use sp_runtime::{ - impl_tx_ext_default, - traits::{ - transaction_extension::TransactionExtension, AsTransactionAuthorizedOrigin, DispatchInfoOf, - Dispatchable, Verify, - }, - transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction}, -}; -use sp_weights::Weight; /// Extension that, if enabled, validates a signature type against the payload constructed from the /// call and the rest of the transaction extension pipeline. This extension provides the /// functionality that traditionally signed transactions had with the implicit signature checking -/// implemented in [`Checkable`](sp_runtime::traits::Checkable). It is meant to be placed ahead of +/// implemented in [`Checkable`](frame::traits::Checkable). It is meant to be placed ahead of /// any other extensions that do authorization work in the [`TransactionExtension`] pipeline. #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] diff --git a/substrate/frame/verify-signature/src/lib.rs b/substrate/frame/verify-signature/src/lib.rs index 96d83dbef9f7..caad11d75e16 100644 --- a/substrate/frame/verify-signature/src/lib.rs +++ b/substrate/frame/verify-signature/src/lib.rs @@ -34,15 +34,14 @@ extern crate alloc; pub use benchmarking::BenchmarkHelper; use codec::{Decode, Encode}; pub use extension::VerifySignature; -use frame_support::Parameter; +use frame::prelude::*; pub use weights::WeightInfo; pub use pallet::*; -#[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; - use sp_runtime::traits::{IdentifyAccount, Verify}; #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/verify-signature/src/tests.rs b/substrate/frame/verify-signature/src/tests.rs index 63a310506eec..5f83257b52db 100644 --- a/substrate/frame/verify-signature/src/tests.rs +++ b/substrate/frame/verify-signature/src/tests.rs @@ -22,23 +22,11 @@ use super::*; use extension::VerifySignature; -use frame_support::{ - derive_impl, - dispatch::GetDispatchInfo, - pallet_prelude::{InvalidTransaction, TransactionSource, TransactionValidityError}, - traits::OriginTrait, -}; +use frame::{deps::sp_runtime::testing::TestSignature, testing_prelude::*}; use frame_system::Call as SystemCall; -use sp_io::hashing::blake2_256; -use sp_runtime::{ - generic::ExtensionVersion, - testing::{TestSignature, UintAuthorityId}, - traits::DispatchTransaction, -}; +type Block = MockBlock; -type Block = frame_system::mocking::MockBlock; - -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -69,10 +57,9 @@ impl crate::Config for Test { } #[cfg(feature = "runtime-benchmarks")] -pub fn new_test_ext() -> sp_io::TestExternalities { - use sp_runtime::BuildStorage; +pub fn new_test_ext() -> TestExternalities { let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/substrate/frame/verify-signature/src/weights.rs b/substrate/frame/verify-signature/src/weights.rs index a8bfa9ea902d..d9779da9fc85 100644 --- a/substrate/frame/verify-signature/src/weights.rs +++ b/substrate/frame/verify-signature/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_verify_signature`.