diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..5062feba57c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15598,18 +15598,12 @@ name = "pallet-transaction-storage" version = "27.0.0" dependencies = [ "array-bytes", - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "pallet-balances 28.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", "serde", - "sp-core 28.0.0", - "sp-inherents 26.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", "sp-transaction-storage-proof 26.0.0", ] diff --git a/substrate/frame/transaction-storage/Cargo.toml b/substrate/frame/transaction-storage/Cargo.toml index f5d6bd1c364c..e85a24af0fd3 100644 --- a/substrate/frame/transaction-storage/Cargo.toml +++ b/substrate/frame/transaction-storage/Cargo.toml @@ -20,48 +20,31 @@ array-bytes = { optional = true, workspace = true, default-features = true } codec = { workspace = true } scale-info = { features = ["derive"], workspace = true } serde = { optional = true, workspace = true, default-features = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } pallet-balances = { workspace = true } -sp-inherents = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } sp-transaction-storage-proof = { workspace = true } log = { workspace = true } [dev-dependencies] -sp-core = { workspace = true } sp-transaction-storage-proof = { default-features = true, workspace = true } [features] default = ["std"] runtime-benchmarks = [ "array-bytes", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "pallet-balances/std", "scale-info/std", "serde", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-runtime/std", "sp-transaction-storage-proof/std", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/transaction-storage/src/benchmarking.rs b/substrate/frame/transaction-storage/src/benchmarking.rs index 0b5b0dc99405..892b546a3f60 100644 --- a/substrate/frame/transaction-storage/src/benchmarking.rs +++ b/substrate/frame/transaction-storage/src/benchmarking.rs @@ -21,10 +21,13 @@ use crate::*; use alloc::{vec, vec::Vec}; +/* use frame_benchmarking::v2::*; use frame_support::traits::{Get, OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, One, Zero}; +*/ +use frame::{benchmarking::prelude::*, arithmetic::{Bounded, One, Zero} , traits::{Get, CheckedDiv}, deps::{frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System}}}; use sp_transaction_storage_proof::TransactionStorageProof; // Proof generated from max size storage: diff --git a/substrate/frame/transaction-storage/src/lib.rs b/substrate/frame/transaction-storage/src/lib.rs index 68f24526300d..2601595fbcaa 100644 --- a/substrate/frame/transaction-storage/src/lib.rs +++ b/substrate/frame/transaction-storage/src/lib.rs @@ -33,6 +33,7 @@ extern crate alloc; use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use core::result; +/* use frame_support::{ dispatch::GetDispatchInfo, traits::{ @@ -42,6 +43,8 @@ use frame_support::{ }, }; use sp_runtime::traits::{BlakeTwo256, Dispatchable, Hash, One, Saturating, Zero}; +*/ +use frame::{deps::{sp_io, sp_runtime}, prelude::*, traits::{Get, IsType, fungible::{hold::Balanced, Inspect, Mutate, MutateHold}, tokens::fungible::Credit, OnUnbalanced, BlakeTwo256, Dispatchable, Hash, One, Saturating, Zero}}; use sp_transaction_storage_proof::{ encode_index, random_chunk, InherentError, TransactionStorageProof, CHUNK_SIZE, INHERENT_IDENTIFIER, @@ -66,7 +69,7 @@ pub const DEFAULT_MAX_BLOCK_TRANSACTIONS: u32 = 512; Encode, Decode, Clone, - sp_runtime::RuntimeDebug, + frame::derive::RuntimeDebug, PartialEq, Eq, scale_info::TypeInfo, @@ -88,11 +91,14 @@ fn num_chunks(bytes: u32) -> u32 { ((bytes as u64 + CHUNK_SIZE as u64 - 1) / CHUNK_SIZE as u64) as u32 } -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + */ /// A reason for this pallet placing a hold on funds. #[pallet::composite_enum] diff --git a/substrate/frame/transaction-storage/src/mock.rs b/substrate/frame/transaction-storage/src/mock.rs index 73174b73dbac..38f8a3cfebff 100644 --- a/substrate/frame/transaction-storage/src/mock.rs +++ b/substrate/frame/transaction-storage/src/mock.rs @@ -21,16 +21,18 @@ use crate::{ self as pallet_transaction_storage, TransactionStorageProof, DEFAULT_MAX_BLOCK_TRANSACTIONS, DEFAULT_MAX_TRANSACTION_SIZE, }; +use frame::{testing_prelude::*, traits::IdentityLookup}; +/* use frame_support::{ derive_impl, traits::{ConstU32, OnFinalize, OnInitialize}, }; use sp_runtime::{traits::IdentityLookup, BuildStorage}; - +*/ pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -63,7 +65,7 @@ impl pallet_transaction_storage::Config for Test { type MaxTransactionSize = ConstU32<{ DEFAULT_MAX_TRANSACTION_SIZE }>; } -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> frame::deps::sp_io::TestExternalities { let t = RuntimeGenesisConfig { system: Default::default(), balances: pallet_balances::GenesisConfig:: { diff --git a/substrate/frame/transaction-storage/src/tests.rs b/substrate/frame/transaction-storage/src/tests.rs index b725990e6e12..f9b1baff9248 100644 --- a/substrate/frame/transaction-storage/src/tests.rs +++ b/substrate/frame/transaction-storage/src/tests.rs @@ -19,9 +19,12 @@ use super::{Pallet as TransactionStorage, *}; use crate::mock::*; +use frame::{testing_prelude::*, deps::{frame_system::RawOrigin, sp_runtime::{DispatchError, TokenError::FundsUnavailable}}}; +/* use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; use sp_runtime::{DispatchError, TokenError::FundsUnavailable}; +*/ use sp_transaction_storage_proof::registration::build_proof; const MAX_DATA_SIZE: u32 = DEFAULT_MAX_TRANSACTION_SIZE; diff --git a/substrate/frame/transaction-storage/src/weights.rs b/substrate/frame/transaction-storage/src/weights.rs index 36681f0abd8b..5d0c578c1bc3 100644 --- a/substrate/frame/transaction-storage/src/weights.rs +++ b/substrate/frame/transaction-storage/src/weights.rs @@ -46,7 +46,8 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_transaction_storage`.