diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 3e2f14a3df..37e8adadf2 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1070,8 +1070,8 @@ mod dispatches { /// Only callable by root as it doesn't require an announcement and can be used to swap any coldkey. #[pallet::call_index(71)] #[pallet::weight(Weight::from_parts(161_700_000, 0) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(11_u64)))] + .saturating_add(T::DbWeight::get().reads(17_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)))] pub fn swap_coldkey( origin: OriginFor, old_coldkey: T::AccountId, diff --git a/runtime/src/base_call_filter.rs b/runtime/src/base_call_filter.rs deleted file mode 100644 index 8d76c422c1..0000000000 --- a/runtime/src/base_call_filter.rs +++ /dev/null @@ -1,96 +0,0 @@ -use crate::RuntimeCall; -use crate::Vec; -use crate::pallet_proxy; -use crate::pallet_utility; -use frame_support::traits::Contains; -use sp_std::boxed::Box; -use sp_std::vec; -pub struct NoNestingCallFilter; - -impl Contains for NoNestingCallFilter { - fn contains(call: &RuntimeCall) -> bool { - let calls = match call { - RuntimeCall::Utility(inner) => { - let calls = match inner { - pallet_utility::Call::force_batch { calls } => calls, - pallet_utility::Call::batch { calls } => calls, - pallet_utility::Call::batch_all { calls } => calls, - _ => return true, - }; - - calls - .iter() - .map(|call| Box::new(call.clone())) - .collect::>() - } - RuntimeCall::Proxy(inner) => { - let call = match inner { - pallet_proxy::Call::proxy { call, .. } => call, - pallet_proxy::Call::proxy_announced { call, .. } => call, - _ => return true, - }; - - vec![call.clone()] - } - RuntimeCall::Multisig(inner) => { - let call = match inner { - pallet_multisig::Call::as_multi { call, .. } => call, - pallet_multisig::Call::as_multi_threshold_1 { call, .. } => call, - _ => return true, - }; - - vec![call.clone()] - } - RuntimeCall::Crowdloan(inner) => { - let call = match inner { - pallet_crowdloan::Call::create { - call: Some(call), .. - } => call, - _ => return true, - }; - - vec![call.clone()] - } - RuntimeCall::Scheduler(inner) => { - let call = match inner { - pallet_scheduler::Call::schedule { call, .. } => call, - pallet_scheduler::Call::schedule_after { call, .. } => call, - pallet_scheduler::Call::schedule_named { call, .. } => call, - pallet_scheduler::Call::schedule_named_after { call, .. } => call, - _ => return true, - }; - - vec![call.clone()] - } - _ => return true, - }; - - !calls.iter().any(|call| { - matches!(&**call, RuntimeCall::Utility(inner) if matches!(inner, pallet_utility::Call::force_batch { .. } | pallet_utility::Call::batch_all { .. } | pallet_utility::Call::batch { .. })) || - matches!(&**call, RuntimeCall::Proxy(inner) if matches!(inner, pallet_proxy::Call::proxy { .. } | pallet_proxy::Call::proxy_announced { .. })) || - matches!(&**call, RuntimeCall::Multisig(inner) if matches!(inner, pallet_multisig::Call::as_multi { .. } | pallet_multisig::Call::as_multi_threshold_1 { .. })) || - matches!(&**call, RuntimeCall::Crowdloan(inner) if matches!(inner, pallet_crowdloan::Call::create { .. } )) || - matches!(&**call, RuntimeCall::Scheduler(inner) if matches!(inner, pallet_scheduler::Call::schedule {..} | pallet_scheduler::Call::schedule_after { .. } | pallet_scheduler::Call::schedule_named {.. } | pallet_scheduler::Call::schedule_named_after { .. } )) || - matches!(&**call, RuntimeCall::Sudo(inner) if matches!(inner, pallet_sudo::Call::sudo {..} | pallet_sudo::Call::sudo_as { .. } | pallet_sudo::Call::sudo_unchecked_weight { .. } )) - }) - } -} - -pub struct SafeModeWhitelistedCalls; -impl Contains for SafeModeWhitelistedCalls { - fn contains(call: &RuntimeCall) -> bool { - matches!( - call, - RuntimeCall::Sudo(_) - | RuntimeCall::Multisig(_) - | RuntimeCall::System(_) - | RuntimeCall::SafeMode(_) - | RuntimeCall::Timestamp(_) - | RuntimeCall::SubtensorModule( - pallet_subtensor::Call::set_weights { .. } - | pallet_subtensor::Call::serve_axon { .. } - ) - | RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. }) - ) - } -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 023e318c7f..6b5038fa61 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -10,7 +10,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use core::num::NonZeroU64; -mod base_call_filter; pub mod check_nonce; mod migrations; pub mod sudo_wrapper; @@ -76,9 +75,6 @@ use subtensor_runtime_common::{AlphaCurrency, AuthorshipInfo, TaoCurrency, time: use subtensor_swap_interface::{Order, SwapHandler}; // A few exports that help ease life for downstream crates. -use crate::base_call_filter::NoNestingCallFilter; -use crate::base_call_filter::SafeModeWhitelistedCalls; -use core::marker::PhantomData; pub use frame_support::{ StorageValue, construct_runtime, parameter_types, traits::{ @@ -98,12 +94,15 @@ pub use pallet_balances::Call as BalancesCall; use pallet_commitments::GetCommitments; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier}; -use scale_info::TypeInfo; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; use subtensor_transaction_fee::{SubtensorTxFeeHandler, TransactionFeeHandler}; +use core::marker::PhantomData; + +use scale_info::TypeInfo; + // Frontier use fp_rpc::TransactionStatus; use pallet_ethereum::{Call::transact, PostLogContent, Transaction as EthereumTransaction}; @@ -276,6 +275,28 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +pub struct NoNestingCallFilter; + +impl Contains for NoNestingCallFilter { + fn contains(call: &RuntimeCall) -> bool { + match call { + RuntimeCall::Utility(inner) => { + let calls = match inner { + pallet_utility::Call::force_batch { calls } => calls, + pallet_utility::Call::batch { calls } => calls, + pallet_utility::Call::batch_all { calls } => calls, + _ => &Vec::new(), + }; + + !calls.iter().any(|call| { + matches!(call, RuntimeCall::Utility(inner) if matches!(inner, pallet_utility::Call::force_batch { .. } | pallet_utility::Call::batch_all { .. } | pallet_utility::Call::batch { .. })) + }) + } + _ => true, + } + } +} + // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { @@ -409,6 +430,25 @@ parameter_types! { pub const DisallowPermissionlessRelease: Option = None; } +pub struct SafeModeWhitelistedCalls; +impl Contains for SafeModeWhitelistedCalls { + fn contains(call: &RuntimeCall) -> bool { + matches!( + call, + RuntimeCall::Sudo(_) + | RuntimeCall::Multisig(_) + | RuntimeCall::System(_) + | RuntimeCall::SafeMode(_) + | RuntimeCall::Timestamp(_) + | RuntimeCall::SubtensorModule( + pallet_subtensor::Call::set_weights { .. } + | pallet_subtensor::Call::serve_axon { .. } + ) + | RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. }) + ) + } +} + impl pallet_safe_mode::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances;