From 3a0ca7f8d3b0cb43fc7937069eff92134cbcfc88 Mon Sep 17 00:00:00 2001 From: Dariia Porechna <35382599+dariolina@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:54:01 +0100 Subject: [PATCH] remove pallet-history-seeding and all related stuff --- Cargo.lock | 18 --- crates/pallet-history-seeding/Cargo.toml | 45 ------- crates/pallet-history-seeding/README.md | 5 - .../src/benchmarking.rs | 37 ------ crates/pallet-history-seeding/src/lib.rs | 69 ---------- crates/pallet-history-seeding/src/tests.rs | 72 ---------- crates/pallet-history-seeding/src/weights.rs | 93 ------------- .../src/chain_spec.rs | 5 +- .../src/malicious_bundle_producer.rs | 6 +- crates/subspace-node/src/chain_spec.rs | 15 +-- crates/subspace-runtime/Cargo.toml | 3 - crates/subspace-runtime/src/lib.rs | 10 +- crates/subspace-runtime/src/object_mapping.rs | 7 - .../subspace-runtime/src/signed_extensions.rs | 125 ------------------ test/subspace-test-client/src/chain_spec.rs | 8 +- test/subspace-test-runtime/Cargo.toml | 2 - test/subspace-test-runtime/src/lib.rs | 13 -- 17 files changed, 7 insertions(+), 526 deletions(-) delete mode 100644 crates/pallet-history-seeding/Cargo.toml delete mode 100644 crates/pallet-history-seeding/README.md delete mode 100644 crates/pallet-history-seeding/src/benchmarking.rs delete mode 100644 crates/pallet-history-seeding/src/lib.rs delete mode 100644 crates/pallet-history-seeding/src/tests.rs delete mode 100644 crates/pallet-history-seeding/src/weights.rs diff --git a/Cargo.lock b/Cargo.lock index 35d19fbc46..e5417999ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7808,22 +7808,6 @@ dependencies = [ "sp-io", ] -[[package]] -name = "pallet-history-seeding" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-sudo", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-messenger" version = "0.1.0" @@ -13065,7 +13049,6 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-domains", - "pallet-history-seeding", "pallet-messenger", "pallet-mmr", "pallet-preimage", @@ -13272,7 +13255,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "pallet-balances", "pallet-domains", - "pallet-history-seeding", "pallet-messenger", "pallet-mmr", "pallet-rewards", diff --git a/crates/pallet-history-seeding/Cargo.toml b/crates/pallet-history-seeding/Cargo.toml deleted file mode 100644 index 72c5c30730..0000000000 --- a/crates/pallet-history-seeding/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "pallet-history-seeding" -version = "0.1.0" -edition = "2021" -description = "A pallet for seeding history of the network" -authors = ["Dariia Porechna "] -repository = "https://github.com/autonomys/subspace" -license = "Apache-2.0" -readme = "README.md" -include = [ - "/src", - "/Cargo.toml", - "/README.md", -] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } -frame-benchmarking = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", optional = true } -frame-support = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } -frame-system = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } -scale-info = { version = "2.11.2", default-features = false, features = ["derive"] } -sp-std = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } - -[dev-dependencies] -pallet-sudo = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", features = ["std"] } -sp-core = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } -sp-io = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } -sp-runtime = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", - "scale-info/std", - "sp-std/std", -] -runtime-benchmarks = [ - "frame-benchmarking", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", -] diff --git a/crates/pallet-history-seeding/README.md b/crates/pallet-history-seeding/README.md deleted file mode 100644 index 54855ad78f..0000000000 --- a/crates/pallet-history-seeding/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Pallet History Seeding - -The history seeding pallet allows an authorized account to add remarks to the blockchain, which can be used to seed historical data or important information into the chain's history. The authorized account for seeding can be set by root. - -License: Apache-2.0 diff --git a/crates/pallet-history-seeding/src/benchmarking.rs b/crates/pallet-history-seeding/src/benchmarking.rs deleted file mode 100644 index c059eb40b7..0000000000 --- a/crates/pallet-history-seeding/src/benchmarking.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Benchmarking for the pallet-history-seeding - -use super::*; -use frame_benchmarking::v2::*; - -#[benchmarks] -mod benchmarks { - use super::*; - use crate::Pallet; - use frame_support::pallet_prelude::*; - use frame_system::RawOrigin; - use sp_std::vec; - - #[benchmark] - fn seed_history( - b: Linear<0, { *T::BlockLength::get().max.get(DispatchClass::Normal) }>, - ) -> Result<(), BenchmarkError> { - let remark_message = vec![1; b as usize]; - let seeder: T::AccountId = account("HistorySeeder", 1, 0); - - Pallet::::set_history_seeder(RawOrigin::Root.into(), seeder.clone()).unwrap(); - - #[extrinsic_call] - _(RawOrigin::Signed(seeder), remark_message); - - Ok(()) - } - - #[benchmark] - fn set_history_seeder() { - let seeder = account("HistorySeeder", 1, 0); - #[extrinsic_call] - _(RawOrigin::Root, seeder); - } - - impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); -} diff --git a/crates/pallet-history-seeding/src/lib.rs b/crates/pallet-history-seeding/src/lib.rs deleted file mode 100644 index 5760d460a6..0000000000 --- a/crates/pallet-history-seeding/src/lib.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - -#[cfg(test)] -mod tests; -pub mod weights; - -pub use pallet::*; - -#[frame_support::pallet] -pub mod pallet { - use crate::weights::WeightInfo; - use frame_support::pallet_prelude::*; - use frame_support::traits::BuildGenesisConfig; - use frame_system::pallet_prelude::*; - use scale_info::prelude::vec::Vec; - - #[pallet::config] - pub trait Config: frame_system::Config { - type WeightInfo: WeightInfo; - } - - #[pallet::pallet] - pub struct Pallet(_); - - #[pallet::storage] - #[pallet::getter(fn history_seeder)] - pub(super) type HistorySeeder = StorageValue<_, T::AccountId, OptionQuery>; - - #[pallet::call] - impl Pallet { - /// Seed history with a remark - #[pallet::call_index(0)] - #[pallet::weight((T::WeightInfo::seed_history(remark.len() as u32), Pays::No))] - pub fn seed_history(_origin: OriginFor, remark: Vec) -> DispatchResult { - let _ = remark; - - Ok(()) - } - - #[pallet::call_index(1)] - #[pallet::weight(T::WeightInfo::set_history_seeder())] - pub fn set_history_seeder( - origin: OriginFor, - new_seeder: T::AccountId, - ) -> DispatchResult { - ensure_root(origin)?; - HistorySeeder::::put(new_seeder); - Ok(()) - } - } - - #[derive(frame_support::DefaultNoBound)] - #[pallet::genesis_config] - pub struct GenesisConfig { - pub history_seeder: Option, - } - - #[pallet::genesis_build] - impl BuildGenesisConfig for GenesisConfig { - fn build(&self) { - if let Some(seeder) = &self.history_seeder { - HistorySeeder::::put(seeder); - } - } - } -} diff --git a/crates/pallet-history-seeding/src/tests.rs b/crates/pallet-history-seeding/src/tests.rs deleted file mode 100644 index 32f82a2111..0000000000 --- a/crates/pallet-history-seeding/src/tests.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::{self as pallet_history_seeding}; -use frame_support::traits::BuildGenesisConfig; -use frame_support::{assert_noop, assert_ok, construct_runtime, derive_impl}; -use frame_system as system; -use sp_runtime::BuildStorage; - -type Block = frame_system::mocking::MockBlock; - -construct_runtime!( - pub struct Test { - System: frame_system, - HistorySeeding: pallet_history_seeding, - } -); - -#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] -impl frame_system::Config for Test { - type Block = Block; -} - -impl pallet_history_seeding::Config for Test { - type WeightInfo = (); -} - -pub fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::::default() - .build_storage() - .unwrap(); - t.into() -} - -#[test] -fn genesis_config_works() { - new_test_ext().execute_with(|| { - let genesis_config = pallet_history_seeding::GenesisConfig:: { - history_seeder: Some(1), - }; - genesis_config.build(); - assert_eq!(HistorySeeding::history_seeder(), Some(1)); - }); -} - -#[test] -fn set_history_seeder_works() { - new_test_ext().execute_with(|| { - assert_ok!(HistorySeeding::set_history_seeder(RuntimeOrigin::root(), 1)); - assert_eq!(HistorySeeding::history_seeder(), Some(1)); - - // Ensure only root can set the history seeder - assert_noop!( - HistorySeeding::set_history_seeder(RuntimeOrigin::signed(1), 2), - sp_runtime::DispatchError::BadOrigin - ); - }); -} - -#[test] -fn seed_history_works() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - - // Set the history seeder - assert_ok!(HistorySeeding::set_history_seeder(RuntimeOrigin::root(), 1)); - - // Seed history - let remark = vec![1, 2, 3]; - assert_ok!(HistorySeeding::seed_history( - RuntimeOrigin::signed(1), - remark.clone() - )); - }); -} diff --git a/crates/pallet-history-seeding/src/weights.rs b/crates/pallet-history-seeding/src/weights.rs deleted file mode 100644 index 6d807cd646..0000000000 --- a/crates/pallet-history-seeding/src/weights.rs +++ /dev/null @@ -1,93 +0,0 @@ - -//! Autogenerated weights for pallet_history_seeding -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 -//! DATE: 2024-09-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `MacBook-Pro.local`, CPU: `` -//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 - -// Executed Command: -// /Users/dastansamat/.cargo/target/release/subspace-node -// benchmark -// pallet -// --runtime -// /Users/dastansamat/.cargo/target/release/wbuild/subspace-runtime/subspace_runtime.compact.compressed.wasm -// --steps=50 -// --repeat=20 -// --pallet=pallet_history_seeding -// --extrinsic -// * -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./crates/pallet-history-seeding/src/weights.rs -// --template -// ./frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::ParityDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for pallet_history_seeding. -pub trait WeightInfo { - fn seed_history(b: u32, ) -> Weight; - fn set_history_seeder() -> Weight; -} - -/// Weights for pallet_history_seeding using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: `HistorySeeding::HistorySeeder` (r:1 w:0) - /// Proof: `HistorySeeding::HistorySeeder` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// The range of component `b` is `[0, 3932160]`. - fn seed_history(b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `37` - // Estimated: `1517` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 1517) - // Standard Error: 0 - .saturating_add(Weight::from_parts(211, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - } - /// Storage: `HistorySeeding::HistorySeeder` (r:0 w:1) - /// Proof: `HistorySeeding::HistorySeeder` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - fn set_history_seeder() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - /// Storage: `HistorySeeding::HistorySeeder` (r:1 w:0) - /// Proof: `HistorySeeding::HistorySeeder` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// The range of component `b` is `[0, 3932160]`. - fn seed_history(b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `37` - // Estimated: `1517` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 1517) - // Standard Error: 0 - .saturating_add(Weight::from_parts(211, 0).saturating_mul(b.into())) - .saturating_add(ParityDbWeight::get().reads(1_u64)) - } - /// Storage: `HistorySeeding::HistorySeeder` (r:0 w:1) - /// Proof: `HistorySeeding::HistorySeeder` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - fn set_history_seeder() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(ParityDbWeight::get().writes(1_u64)) - } -} diff --git a/crates/subspace-malicious-operator/src/chain_spec.rs b/crates/subspace-malicious-operator/src/chain_spec.rs index e74d79f086..cc1df3e2e5 100644 --- a/crates/subspace-malicious-operator/src/chain_spec.rs +++ b/crates/subspace-malicious-operator/src/chain_spec.rs @@ -14,7 +14,7 @@ use std::marker::PhantomData; use std::num::NonZeroU32; use subspace_runtime::{ AllowAuthoringBy, CouncilConfig, DemocracyConfig, DomainsConfig, EnableRewardsAt, - HistorySeedingConfig, RewardsConfig, RuntimeConfigsConfig, SubspaceConfig, + RewardsConfig, RuntimeConfigsConfig, SubspaceConfig, }; use subspace_runtime_primitives::{ AccountId, Balance, BlockNumber, CouncilDemocracyConfigParams, SSC, @@ -262,8 +262,5 @@ fn subspace_genesis_config( initial_balances: genesis_domain_params.initial_balances, }], }, - history_seeding: HistorySeedingConfig { - history_seeder: Some(sudo_account), - }, } } diff --git a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs index d80594d78b..679bcfccb8 100644 --- a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs +++ b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs @@ -28,9 +28,7 @@ use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use std::error::Error; use std::sync::Arc; use subspace_core_primitives::pot::PotOutput; -use subspace_runtime::{ - CheckHistorySeeder, DisablePallets, Runtime, RuntimeCall, SignedExtra, UncheckedExtrinsic, -}; +use subspace_runtime::{DisablePallets, Runtime, RuntimeCall, SignedExtra, UncheckedExtrinsic}; use subspace_runtime_primitives::opaque::Block as CBlock; use subspace_runtime_primitives::{AccountId, Balance, Nonce}; @@ -418,7 +416,6 @@ pub fn construct_signed_extrinsic( frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(0u128), DisablePallets, - CheckHistorySeeder::::new(), ); let raw_payload = generic::SignedPayload::::from_raw( call.clone(), @@ -433,7 +430,6 @@ pub fn construct_signed_extrinsic( (), (), (), - (), ), ); diff --git a/crates/subspace-node/src/chain_spec.rs b/crates/subspace-node/src/chain_spec.rs index dc6120d7a9..8cf80065b8 100644 --- a/crates/subspace-node/src/chain_spec.rs +++ b/crates/subspace-node/src/chain_spec.rs @@ -34,8 +34,8 @@ use subspace_core_primitives::pot::PotKey; use subspace_core_primitives::PublicKey; use subspace_runtime::{ AllowAuthoringBy, BalancesConfig, CouncilConfig, DemocracyConfig, DomainsConfig, - EnableRewardsAt, HistorySeedingConfig, RewardPoint, RewardsConfig, RuntimeConfigsConfig, - RuntimeGenesisConfig, SubspaceConfig, SudoConfig, SystemConfig, WASM_BINARY, + EnableRewardsAt, RewardPoint, RewardsConfig, RuntimeConfigsConfig, RuntimeGenesisConfig, + SubspaceConfig, SudoConfig, SystemConfig, WASM_BINARY, }; use subspace_runtime_primitives::{ AccountId, Balance, BlockNumber, CouncilDemocracyConfigParams, SSC, @@ -102,9 +102,6 @@ pub fn mainnet_compiled() -> Result { let sudo_account = AccountId::from_ss58check("5EHHtxGtDEPFX2x2PCVg8uhhg6kDdt9znQLr2oqUA9sYL5n6") .expect("Wrong root account address"); - let history_seeder = - AccountId::from_ss58check("5EXKjeN6GXua85mHygsS95UwwrnNwTTEbzeAj9nqkXrgqQp6") - .expect("Wrong history seeder account address"); let council_members = [ "5EhEcKAfGXzEkEqYdN9Ntc4f2KJrVvabWTUceCVtDPTYxVit", "5G9GUNK2Vp1jgpENPmcy9TLoprkmHBTSg9bgvMa8er5ZLYjb", @@ -249,7 +246,6 @@ pub fn mainnet_compiled() -> Result { }, CouncilDemocracyConfigParams::::production_params(), council_config, - history_seeder.clone(), )?) .map_err(|error| format!("Failed to serialize genesis config: {error}"))? }) @@ -325,7 +321,6 @@ pub fn devnet_config_compiled() -> Result { }, CouncilDemocracyConfigParams::::fast_params(), CouncilConfig::default(), - sudo_account.clone(), )?) .map_err(|error| format!("Failed to serialize genesis config: {error}"))? }) @@ -335,7 +330,6 @@ pub fn devnet_config_compiled() -> Result { pub fn dev_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; let sudo_account = get_account_id_from_seed("Alice"); - let history_seeder = get_account_id_from_seed("Bob"); Ok(GenericChainSpec::builder(wasm_binary, None) .with_name("Subspace development") @@ -385,7 +379,6 @@ pub fn dev_config() -> Result { }, CouncilDemocracyConfigParams::::fast_params(), CouncilConfig::default(), - history_seeder.clone(), )?) .map_err(|error| format!("Failed to serialize genesis config: {error}"))?, ) @@ -400,7 +393,6 @@ fn subspace_genesis_config( genesis_domain_params: GenesisDomainParams, council_democracy_config_params: CouncilDemocracyConfigParams, council_config: CouncilConfig, - history_seeder_account: AccountId, ) -> Result { let GenesisParams { enable_rewards_at, @@ -469,8 +461,5 @@ fn subspace_genesis_config( .then_some(genesis_domain_params.permissioned_action_allowed_by), genesis_domains, }, - history_seeding: HistorySeedingConfig { - history_seeder: Some(history_seeder_account), - }, }) } diff --git a/crates/subspace-runtime/Cargo.toml b/crates/subspace-runtime/Cargo.toml index 7f3b59542d..2a1a40bf7c 100644 --- a/crates/subspace-runtime/Cargo.toml +++ b/crates/subspace-runtime/Cargo.toml @@ -28,7 +28,6 @@ pallet-balances = { default-features = false, git = "https://github.com/subspace pallet-collective = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-democracy = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-domains = { version = "0.1.0", default-features = false, path = "../pallet-domains" } -pallet-history-seeding = { version = "0.1.0", default-features = false, path = "../pallet-history-seeding" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } pallet-mmr = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-preimage = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } @@ -92,7 +91,6 @@ std = [ "pallet-collective/std", "pallet-democracy/std", "pallet-domains/std", - "pallet-history-seeding/std", "pallet-messenger/std", "pallet-mmr/std", "pallet-preimage/std", @@ -145,7 +143,6 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-domains/runtime-benchmarks", - "pallet-history-seeding/runtime-benchmarks", "pallet-mmr/runtime-benchmarks", "pallet-messenger/runtime-benchmarks", "pallet-rewards/runtime-benchmarks", diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 7ba9312dff..79392ad9e4 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -37,7 +37,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use crate::fees::{OnChargeTransaction, TransactionByteFee}; use crate::object_mapping::extract_block_object_mapping; -pub use crate::signed_extensions::{CheckHistorySeeder, DisablePallets}; +pub use crate::signed_extensions::DisablePallets; use alloc::borrow::Cow; use codec::{Decode, Encode, MaxEncodedLen}; use core::mem; @@ -576,10 +576,6 @@ impl pallet_democracy::Config for Runtime { type WeightInfo = pallet_democracy::weights::SubstrateWeight; } -impl pallet_history_seeding::Config for Runtime { - type WeightInfo = pallet_history_seeding::weights::SubstrateWeight; -} - parameter_types! { pub const SelfChainId: ChainId = ChainId::Consensus; } @@ -941,8 +937,6 @@ construct_runtime!( Democracy: pallet_democracy = 83, Preimage: pallet_preimage = 84, - HistorySeeding: pallet_history_seeding = 91, - // Reserve some room for other pallets as we'll remove sudo pallet eventually. Sudo: pallet_sudo = 100, } @@ -966,7 +960,6 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, DisablePallets, - CheckHistorySeeder, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = @@ -1084,7 +1077,6 @@ mod benches { [pallet_timestamp, Timestamp] [pallet_messenger, Messenger] [pallet_transporter, Transporter] - [pallet_history_seeding, HistorySeeding] ); } diff --git a/crates/subspace-runtime/src/object_mapping.rs b/crates/subspace-runtime/src/object_mapping.rs index f511c17ffb..8d581cc5e5 100644 --- a/crates/subspace-runtime/src/object_mapping.rs +++ b/crates/subspace-runtime/src/object_mapping.rs @@ -92,13 +92,6 @@ pub(crate) fn extract_call_block_object_mapping( offset: base_offset + 1, }); } - RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { remark }) => { - objects.push(BlockObject { - hash: hashes::blake3_hash(remark), - // Add pallet_history_seeding::Call enum variant to the base offset. - offset: base_offset + 1, - }); - } // Recursively extract object mappings for the call. RuntimeCall::Utility(call) => { diff --git a/crates/subspace-runtime/src/signed_extensions.rs b/crates/subspace-runtime/src/signed_extensions.rs index 343faf0aff..5d42cca058 100644 --- a/crates/subspace-runtime/src/signed_extensions.rs +++ b/crates/subspace-runtime/src/signed_extensions.rs @@ -1,6 +1,5 @@ use crate::{Runtime, RuntimeCall, RuntimeConfigs}; use codec::{Decode, Encode}; -use core::marker::PhantomData; use scale_info::TypeInfo; use sp_runtime::traits::{DispatchInfoOf, SignedExtension}; use sp_runtime::transaction_validity::{ @@ -83,127 +82,3 @@ fn contains_balance_transfer(call: &RuntimeCall) -> bool { _ => false, } } - -/// A custom signed extension to check if the caller is an authorized history seeder for -/// the `history_seeding` pallet. -#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] -#[scale_info(skip_type_params(T))] -pub struct CheckHistorySeeder(PhantomData); - -impl core::fmt::Debug for CheckHistorySeeder { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("CheckHistorySeeder").finish() - } -} - -impl CheckHistorySeeder { - pub fn new() -> Self { - Self(core::marker::PhantomData) - } -} - -impl Default for CheckHistorySeeder { - fn default() -> Self { - Self::new() - } -} - -impl SignedExtension for CheckHistorySeeder { - const IDENTIFIER: &'static str = "CheckHistorySeeder"; - - type AccountId = T::AccountId; - type Call = ::RuntimeCall; - type AdditionalSigned = (); - type Pre = (); - - fn additional_signed(&self) -> Result { - Ok(()) - } - - fn validate( - &self, - who: &Self::AccountId, - call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> TransactionValidity { - match call { - crate::RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { - .. - }) => { - if Some(who.clone()) != pallet_history_seeding::Pallet::::history_seeder() { - return Err(TransactionValidityError::Invalid( - InvalidTransaction::BadSigner, - )); - } - - Ok(ValidTransaction::default()) - } - _ => Ok(ValidTransaction::default()), - } - } - - fn pre_dispatch( - self, - who: &Self::AccountId, - _call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> Result { - self.validate(who, _call, _info, _len)?; - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use crate::{CheckHistorySeeder, Runtime, RuntimeCall, RuntimeOrigin}; - use codec::Encode; - use frame_support::dispatch::DispatchInfo; - use frame_support::pallet_prelude::{InvalidTransaction, TransactionValidityError}; - use frame_support::{assert_err, assert_ok}; - use sp_runtime::traits::SignedExtension; - use sp_runtime::{AccountId32, BuildStorage}; - - pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::::default() - .build_storage() - .unwrap(); - t.into() - } - - #[test] - fn test_check_history_seeder_works() { - new_test_ext().execute_with(|| { - let call = RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { - remark: vec![0u8; 256], - }); - - let who = AccountId32::new([0u8; 32]); - - assert_err!( - CheckHistorySeeder::::new().pre_dispatch( - &who, - &call, - &DispatchInfo::default(), - call.encoded_size() - ), - TransactionValidityError::Invalid(InvalidTransaction::BadSigner), - ); - - // set seeder - pallet_history_seeding::Pallet::::set_history_seeder( - RuntimeOrigin::root(), - who.clone(), - ) - .unwrap(); - - assert_ok!(CheckHistorySeeder::::new().pre_dispatch( - &who, - &call, - &DispatchInfo::default(), - call.encoded_size() - )); - }); - } -} diff --git a/test/subspace-test-client/src/chain_spec.rs b/test/subspace-test-client/src/chain_spec.rs index 8694e1a984..704a7d9a18 100644 --- a/test/subspace-test-client/src/chain_spec.rs +++ b/test/subspace-test-client/src/chain_spec.rs @@ -7,9 +7,8 @@ use std::marker::PhantomData; use std::num::NonZeroU32; use subspace_runtime_primitives::{AccountId, Balance, Signature}; use subspace_test_runtime::{ - AllowAuthoringBy, BalancesConfig, DomainsConfig, EnableRewardsAt, HistorySeedingConfig, - RewardsConfig, RuntimeGenesisConfig, SubspaceConfig, SudoConfig, SystemConfig, SSC, - WASM_BINARY, + AllowAuthoringBy, BalancesConfig, DomainsConfig, EnableRewardsAt, RewardsConfig, + RuntimeGenesisConfig, SubspaceConfig, SudoConfig, SystemConfig, SSC, WASM_BINARY, }; /// Generate a crypto pair from seed. @@ -95,9 +94,6 @@ fn create_genesis_config( .expect("Must success"), ], }, - history_seeding: HistorySeedingConfig { - history_seeder: Some(sudo_account), - }, runtime_configs: Default::default(), }) } diff --git a/test/subspace-test-runtime/Cargo.toml b/test/subspace-test-runtime/Cargo.toml index 27a534638b..318b1a9a8b 100644 --- a/test/subspace-test-runtime/Cargo.toml +++ b/test/subspace-test-runtime/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { default-features = false, git = "https://github.com/subspace/p frame-system = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-balances = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-domains = { version = "0.1.0", default-features = false, path = "../../crates/pallet-domains" } -pallet-history-seeding = { version = "0.1.0", default-features = false, path = "../../crates/pallet-history-seeding" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } pallet-mmr = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" } pallet-rewards = { version = "0.1.0", default-features = false, path = "../../crates/pallet-rewards" } @@ -80,7 +79,6 @@ std = [ "frame-system-rpc-runtime-api/std", "pallet-balances/std", "pallet-domains/std", - "pallet-history-seeding/std", "pallet-messenger/std", "pallet-mmr/std", "pallet-rewards/std", diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 383e0e9d17..89289f6101 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -292,10 +292,6 @@ parameter_types! { pub TransactionWeightFee: Balance = 100_000 * SHANNON; } -impl pallet_history_seeding::Config for Runtime { - type WeightInfo = pallet_history_seeding::weights::SubstrateWeight; -} - impl pallet_subspace::Config for Runtime { type RuntimeEvent = RuntimeEvent; type BlockAuthoringDelay = BlockAuthoringDelay; @@ -874,8 +870,6 @@ construct_runtime!( Messenger: pallet_messenger exclude_parts { Inherent } = 60, Transporter: pallet_transporter = 61, - HistorySeeding: pallet_history_seeding = 91, - // Reserve some room for other pallets as we'll remove sudo pallet eventually. Sudo: pallet_sudo = 100, } @@ -1035,13 +1029,6 @@ fn extract_call_block_object_mapping( offset: base_offset + 1, }); } - RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { remark }) => { - objects.push(BlockObject { - hash: hashes::blake3_hash(remark), - // Add pallet_history_seeding::Call enum variant to the base offset. - offset: base_offset + 1, - }); - } // Recursively extract object mappings for the call. RuntimeCall::Utility(call) => {