From 0fc5a4206da6c9a46fc3b8d727aba220a63f0bce Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 25 Sep 2024 10:52:49 +0300 Subject: [PATCH] Remove support for disabling of non-root calls --- .../src/benchmarking.rs | 8 ---- crates/pallet-runtime-configs/src/lib.rs | 26 ------------ crates/pallet-runtime-configs/src/weights.rs | 21 ---------- .../src/chain_spec.rs | 4 -- .../src/malicious_bundle_producer.rs | 6 +-- crates/subspace-node/src/chain_spec.rs | 6 --- crates/subspace-runtime/src/lib.rs | 3 +- .../subspace-runtime/src/signed_extensions.rs | 41 ------------------- 8 files changed, 2 insertions(+), 113 deletions(-) diff --git a/crates/pallet-runtime-configs/src/benchmarking.rs b/crates/pallet-runtime-configs/src/benchmarking.rs index 14773bbe5d..43741644ab 100644 --- a/crates/pallet-runtime-configs/src/benchmarking.rs +++ b/crates/pallet-runtime-configs/src/benchmarking.rs @@ -30,12 +30,4 @@ mod benchmarks { assert!(Pallet::::enable_balance_transfers()); } - - #[benchmark] - fn set_enable_non_root_calls() { - #[extrinsic_call] - _(RawOrigin::Root, true); - - assert!(Pallet::::enable_non_root_calls()); - } } diff --git a/crates/pallet-runtime-configs/src/lib.rs b/crates/pallet-runtime-configs/src/lib.rs index 515c640f3d..175f396597 100644 --- a/crates/pallet-runtime-configs/src/lib.rs +++ b/crates/pallet-runtime-configs/src/lib.rs @@ -49,13 +49,6 @@ mod pallet { #[pallet::getter(fn enable_balance_transfers)] pub type EnableBalanceTransfers = StorageValue<_, bool, ValueQuery>; - /// Whether to enable calls from non-root account. - // TODO: Find a way to work around `Sudo::key()` - // (https://github.com/paritytech/polkadot-sdk/pull/3370) or remove this feature - #[pallet::storage] - #[pallet::getter(fn enable_non_root_calls)] - pub type EnableNonRootCalls = StorageValue<_, bool, ValueQuery>; - #[pallet::storage] pub type ConfirmationDepthK = StorageValue<_, BlockNumberFor, ValueQuery>; @@ -77,8 +70,6 @@ mod pallet { pub enable_dynamic_cost_of_storage: bool, /// Whether to enable balance transfers pub enable_balance_transfers: bool, - /// Whether to enable calls from non-root account - pub enable_non_root_calls: bool, /// Confirmation depth k to use in the archiving process pub confirmation_depth_k: BlockNumberFor, /// Council and democracy config params. @@ -92,7 +83,6 @@ mod pallet { enable_domains: false, enable_dynamic_cost_of_storage: false, enable_balance_transfers: false, - enable_non_root_calls: false, confirmation_depth_k: BlockNumberFor::::from(100u32), council_democracy_config_params: CouncilDemocracyConfigParams::>::default(), @@ -107,7 +97,6 @@ mod pallet { enable_domains, enable_dynamic_cost_of_storage, enable_balance_transfers, - enable_non_root_calls, confirmation_depth_k, council_democracy_config_params, } = self; @@ -120,7 +109,6 @@ mod pallet { >::put(enable_domains); >::put(enable_dynamic_cost_of_storage); >::put(enable_balance_transfers); - >::put(enable_non_root_calls); >::put(confirmation_depth_k); CouncilDemocracyConfig::::put(council_democracy_config_params); } @@ -166,19 +154,5 @@ mod pallet { Ok(()) } - - /// Enable or disable calls from non-root users. - #[pallet::call_index(3)] - #[pallet::weight(< T as Config >::WeightInfo::set_enable_non_root_calls())] - pub fn set_enable_non_root_calls( - origin: OriginFor, - enable_non_root_calls: bool, - ) -> DispatchResult { - ensure_root(origin)?; - - EnableNonRootCalls::::put(enable_non_root_calls); - - Ok(()) - } } } diff --git a/crates/pallet-runtime-configs/src/weights.rs b/crates/pallet-runtime-configs/src/weights.rs index bd02547fd5..326777e916 100644 --- a/crates/pallet-runtime-configs/src/weights.rs +++ b/crates/pallet-runtime-configs/src/weights.rs @@ -34,7 +34,6 @@ pub trait WeightInfo { fn set_enable_domains() -> Weight; fn set_enable_dynamic_cost_of_storage() -> Weight; fn set_enable_balance_transfers() -> Weight; - fn set_enable_non_root_calls() -> Weight; } /// Weights for pallet_runtime_configs using the Substrate node and recommended hardware. @@ -70,16 +69,6 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(3_216_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `RuntimeConfigs::EnableNonRootCalls` (r:0 w:1) - /// Proof: `RuntimeConfigs::EnableNonRootCalls` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - fn set_enable_non_root_calls() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_095_000 picoseconds. - Weight::from_parts(3_249_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } } // For backwards compatibility and tests @@ -114,14 +103,4 @@ impl WeightInfo for () { Weight::from_parts(3_216_000, 0) .saturating_add(ParityDbWeight::get().writes(1_u64)) } - /// Storage: `RuntimeConfigs::EnableNonRootCalls` (r:0 w:1) - /// Proof: `RuntimeConfigs::EnableNonRootCalls` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - fn set_enable_non_root_calls() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_095_000 picoseconds. - Weight::from_parts(3_249_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 2782aef3d2..4539f2e7bd 100644 --- a/crates/subspace-malicious-operator/src/chain_spec.rs +++ b/crates/subspace-malicious-operator/src/chain_spec.rs @@ -130,7 +130,6 @@ struct GenesisParams { enable_domains: bool, enable_dynamic_cost_of_storage: bool, enable_balance_transfers: bool, - enable_non_root_calls: bool, confirmation_depth_k: u32, rewards_config: RewardsConfig, } @@ -179,7 +178,6 @@ pub fn dev_config() -> Result { enable_domains: true, enable_dynamic_cost_of_storage: false, enable_balance_transfers: true, - enable_non_root_calls: true, confirmation_depth_k: 5, rewards_config: RewardsConfig { remaining_issuance: 1_000_000 * SSC, @@ -215,7 +213,6 @@ fn subspace_genesis_config( enable_domains, enable_dynamic_cost_of_storage, enable_balance_transfers, - enable_non_root_calls, confirmation_depth_k, rewards_config, } = genesis_params; @@ -241,7 +238,6 @@ fn subspace_genesis_config( enable_domains, enable_dynamic_cost_of_storage, enable_balance_transfers, - enable_non_root_calls, confirmation_depth_k, council_democracy_config_params: CouncilDemocracyConfigParams::::fast_params(), diff --git a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs index d75953cbb5..d87c81232a 100644 --- a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs +++ b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs @@ -31,9 +31,7 @@ use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use std::error::Error; use std::sync::Arc; use subspace_core_primitives::PotOutput; -use subspace_runtime::{ - CheckStorageAccess, 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}; @@ -427,7 +425,6 @@ pub fn construct_signed_extrinsic( frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(0u128), - CheckStorageAccess, DisablePallets, ); let raw_payload = generic::SignedPayload::::from_raw( @@ -443,7 +440,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 e5e7acc378..d6da8010c5 100644 --- a/crates/subspace-node/src/chain_spec.rs +++ b/crates/subspace-node/src/chain_spec.rs @@ -50,7 +50,6 @@ struct GenesisParams { enable_domains: bool, enable_dynamic_cost_of_storage: bool, enable_balance_transfers: bool, - enable_non_root_calls: bool, confirmation_depth_k: u32, rewards_config: RewardsConfig, } @@ -105,7 +104,6 @@ pub fn gemini_3h_compiled() -> Result { enable_domains: false, enable_dynamic_cost_of_storage: false, enable_balance_transfers: true, - enable_non_root_calls: false, // TODO: Proper value here confirmation_depth_k: 100, // TODO: Proper value here @@ -275,7 +273,6 @@ pub fn devnet_config_compiled() -> Result { enable_domains: true, enable_dynamic_cost_of_storage: false, enable_balance_transfers: true, - enable_non_root_calls: false, // TODO: Proper value here confirmation_depth_k: 100, // TODO: Proper value here @@ -338,7 +335,6 @@ pub fn dev_config() -> Result { enable_domains: true, enable_dynamic_cost_of_storage: false, enable_balance_transfers: true, - enable_non_root_calls: true, confirmation_depth_k: 5, rewards_config: RewardsConfig { remaining_issuance: 1_000_000 * SSC, @@ -379,7 +375,6 @@ fn subspace_genesis_config( enable_domains, enable_dynamic_cost_of_storage, enable_balance_transfers, - enable_non_root_calls, confirmation_depth_k, rewards_config, } = genesis_params; @@ -435,7 +430,6 @@ fn subspace_genesis_config( enable_domains, enable_dynamic_cost_of_storage, enable_balance_transfers, - enable_non_root_calls, confirmation_depth_k, council_democracy_config_params, }, diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 6db35d1892..5e70238013 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -33,7 +33,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::{CheckStorageAccess, DisablePallets}; +pub use crate::signed_extensions::DisablePallets; use codec::{Decode, Encode, MaxEncodedLen}; use core::num::NonZeroU64; use domain_runtime_primitives::opaque::Header as DomainHeader; @@ -976,7 +976,6 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, - CheckStorageAccess, DisablePallets, ); /// Unchecked extrinsic type as expected by this runtime. diff --git a/crates/subspace-runtime/src/signed_extensions.rs b/crates/subspace-runtime/src/signed_extensions.rs index bd9e338ff4..1e4ae2a619 100644 --- a/crates/subspace-runtime/src/signed_extensions.rs +++ b/crates/subspace-runtime/src/signed_extensions.rs @@ -6,47 +6,6 @@ use sp_runtime::transaction_validity::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }; use sp_std::prelude::*; -/// Controls non-root access to feeds and object store -#[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, Default, TypeInfo)] -pub struct CheckStorageAccess; - -impl SignedExtension for CheckStorageAccess { - const IDENTIFIER: &'static str = "CheckStorageAccess"; - type AccountId = ::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 { - // TODO: Find a way to work around `Sudo::key()` - // (https://github.com/paritytech/polkadot-sdk/pull/3370) or remove this feature - // if RuntimeConfigs::enable_non_root_calls() || Some(who) == Sudo::key().as_ref() { - Ok(ValidTransaction::default()) - // } else { - // InvalidTransaction::BadSigner.into() - // } - } - - fn pre_dispatch( - self, - _who: &Self::AccountId, - _call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> Result { - Ok(()) - } -} /// Disable specific pallets. #[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, Default, TypeInfo)]