Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pallet-transaction-storage to umbrella crate. #6627

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 4 additions & 21 deletions substrate/frame/transaction-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
3 changes: 3 additions & 0 deletions substrate/frame/transaction-storage/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions substrate/frame/transaction-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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]
Expand Down
8 changes: 5 additions & 3 deletions substrate/frame/transaction-storage/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test>;

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand Down Expand Up @@ -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::<Test> {
Expand Down
3 changes: 3 additions & 0 deletions substrate/frame/transaction-storage/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/transaction-storage/src/weights.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.