diff --git a/Cargo.lock b/Cargo.lock index c79adee6f38e..23bde87ef746 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15780,18 +15780,14 @@ 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", ] diff --git a/prdoc/pr_6515.prdoc b/prdoc/pr_6515.prdoc new file mode 100644 index 000000000000..c64db4aea22d --- /dev/null +++ b/prdoc/pr_6515.prdoc @@ -0,0 +1,17 @@ +# 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: migrate pallet-verify-signature to umbrella crate + +doc: + - audience: Runtime Dev + description: | + This pull request adapts the frame umbrella crate into pallet-verify-signature + by importing existing systems into the pallet. + + +crates: + - name: polkadot-sdk-frame + bump: minor + - name: pallet-verify-signature + bump: minor \ No newline at end of file diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 03d815e349df..1eac042c518c 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -202,7 +202,7 @@ 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::{GetDispatchInfo, PostDispatchInfo, DispatchInfo}; pub use frame_support::traits::{Contains, IsSubType, OnRuntimeUpgrade}; /// Pallet prelude of `frame-system`. @@ -392,7 +392,7 @@ pub mod runtime { }; pub use sp_inherents::{CheckInherentsResult, InherentData}; pub use sp_keyring::AccountKeyring; - pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode}; + pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode, impl_tx_ext_default}; } /// Types and traits for runtimes that implement runtime APIs. @@ -494,6 +494,7 @@ pub mod runtime { pub mod testing_prelude { pub use sp_core::storage::Storage; pub use sp_runtime::BuildStorage; + pub use sp_runtime::{testing::{TestSignature, UintAuthorityId}, generic::ExtensionVersion}; } } diff --git a/substrate/frame/verify-signature/Cargo.toml b/substrate/frame/verify-signature/Cargo.toml index 3c5fd5e65157..7443f5be9e0a 100644 --- a/substrate/frame/verify-signature/Cargo.toml +++ b/substrate/frame/verify-signature/Cargo.toml @@ -18,12 +18,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true } scale-info = { features = ["derive"], workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } frame-system = { workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } sp-weights = { features = ["serde"], workspace = true } [dev-dependencies] @@ -31,40 +27,32 @@ pallet-balances = { workspace = true, default-features = true } pallet-root-testing = { workspace = true, default-features = true } pallet-collective = { 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/std", "frame-system/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/runtime-benchmarks", "frame-system/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/try-runtime", "frame-system/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..947f26ac5143 100644 --- a/substrate/frame/verify-signature/src/benchmarking.rs +++ b/substrate/frame/verify-signature/src/benchmarking.rs @@ -20,23 +20,18 @@ #![cfg(feature = "runtime-benchmarks")] extern crate alloc; - use super::*; +use frame::{ + benchmarking::prelude::*, + prelude::{DispatchInfo, Dispatchable}, + testing_prelude::ExtensionVersion, + traits::{AsTransactionAuthorizedOrigin, DispatchTransaction}, +}; #[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}, -}; +use frame_system::Call as SystemCall; 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..7ef355bb0480 100644 --- a/substrate/frame/verify-signature/src/extension.rs +++ b/substrate/frame/verify-signature/src/extension.rs @@ -20,17 +20,18 @@ use crate::{Config, WeightInfo}; use codec::{Decode, Encode}; -use frame_support::{pallet_prelude::TransactionSource, traits::OriginTrait}; -use scale_info::TypeInfo; -use sp_io::hashing::blake2_256; -use sp_runtime::{ - impl_tx_ext_default, +use frame::{ + hashing::blake2_256, + runtime::prelude::{ + impl_tx_ext_default, InvalidTransaction, TransactionSource, TransactionValidityError, + ValidTransaction, + }, traits::{ - transaction_extension::TransactionExtension, AsTransactionAuthorizedOrigin, DispatchInfoOf, - Dispatchable, Verify, + AsTransactionAuthorizedOrigin, DispatchInfoOf, Dispatchable, OriginTrait, + TransactionExtension, Verify, }, - transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction}, }; +use scale_info::TypeInfo; use sp_weights::Weight; /// Extension that, if enabled, validates a signature type against the payload constructed from the diff --git a/substrate/frame/verify-signature/src/lib.rs b/substrate/frame/verify-signature/src/lib.rs index 96d83dbef9f7..e4f1370e2c5d 100644 --- a/substrate/frame/verify-signature/src/lib.rs +++ b/substrate/frame/verify-signature/src/lib.rs @@ -34,15 +34,17 @@ extern crate alloc; pub use benchmarking::BenchmarkHelper; use codec::{Decode, Encode}; pub use extension::VerifySignature; -use frame_support::Parameter; +use frame::{ + prelude::*, + traits::{IdentifyAccount, Verify}, +}; 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..6364cfd809a7 100644 --- a/substrate/frame/verify-signature/src/tests.rs +++ b/substrate/frame/verify-signature/src/tests.rs @@ -22,23 +22,15 @@ use super::*; use extension::VerifySignature; -use frame_support::{ - derive_impl, - dispatch::GetDispatchInfo, - pallet_prelude::{InvalidTransaction, TransactionSource, TransactionValidityError}, - traits::OriginTrait, +use frame::{ + pallet_macros::derive_impl, + testing_prelude::*, + traits::{DispatchTransaction, OriginTrait}, }; use frame_system::Call as SystemCall; -use sp_io::hashing::blake2_256; -use sp_runtime::{ - generic::ExtensionVersion, - testing::{TestSignature, UintAuthorityId}, - traits::DispatchTransaction, -}; - type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -69,10 +61,10 @@ 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 { + // use sp_runtime::BuildStorage; 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`.