Skip to content

Commit b6c5aa5

Browse files
authored
Merge pull request #2457 from opentensor/revert-call-filter
Revert "Update base call filter"
2 parents d72581d + f67ae84 commit b6c5aa5

File tree

3 files changed

+47
-103
lines changed

3 files changed

+47
-103
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,8 @@ mod dispatches {
10701070
/// Only callable by root as it doesn't require an announcement and can be used to swap any coldkey.
10711071
#[pallet::call_index(71)]
10721072
#[pallet::weight(Weight::from_parts(161_700_000, 0)
1073-
.saturating_add(T::DbWeight::get().reads(16_u64))
1074-
.saturating_add(T::DbWeight::get().writes(11_u64)))]
1073+
.saturating_add(T::DbWeight::get().reads(17_u64))
1074+
.saturating_add(T::DbWeight::get().writes(10_u64)))]
10751075
pub fn swap_coldkey(
10761076
origin: OriginFor<T>,
10771077
old_coldkey: T::AccountId,

runtime/src/base_call_filter.rs

Lines changed: 0 additions & 96 deletions
This file was deleted.

runtime/src/lib.rs

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
1010

1111
use core::num::NonZeroU64;
1212

13-
mod base_call_filter;
1413
pub mod check_nonce;
1514
mod migrations;
1615
pub mod sudo_wrapper;
@@ -76,9 +75,6 @@ use subtensor_runtime_common::{AlphaCurrency, AuthorshipInfo, TaoCurrency, time:
7675
use subtensor_swap_interface::{Order, SwapHandler};
7776

7877
// A few exports that help ease life for downstream crates.
79-
use crate::base_call_filter::NoNestingCallFilter;
80-
use crate::base_call_filter::SafeModeWhitelistedCalls;
81-
use core::marker::PhantomData;
8278
pub use frame_support::{
8379
StorageValue, construct_runtime, parameter_types,
8480
traits::{
@@ -98,12 +94,15 @@ pub use pallet_balances::Call as BalancesCall;
9894
use pallet_commitments::GetCommitments;
9995
pub use pallet_timestamp::Call as TimestampCall;
10096
use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};
101-
use scale_info::TypeInfo;
10297
#[cfg(any(feature = "std", test))]
10398
pub use sp_runtime::BuildStorage;
10499
pub use sp_runtime::{Perbill, Permill};
105100
use subtensor_transaction_fee::{SubtensorTxFeeHandler, TransactionFeeHandler};
106101

102+
use core::marker::PhantomData;
103+
104+
use scale_info::TypeInfo;
105+
107106
// Frontier
108107
use fp_rpc::TransactionStatus;
109108
use pallet_ethereum::{Call::transact, PostLogContent, Transaction as EthereumTransaction};
@@ -276,6 +275,28 @@ parameter_types! {
276275
pub const SS58Prefix: u8 = 42;
277276
}
278277

278+
pub struct NoNestingCallFilter;
279+
280+
impl Contains<RuntimeCall> for NoNestingCallFilter {
281+
fn contains(call: &RuntimeCall) -> bool {
282+
match call {
283+
RuntimeCall::Utility(inner) => {
284+
let calls = match inner {
285+
pallet_utility::Call::force_batch { calls } => calls,
286+
pallet_utility::Call::batch { calls } => calls,
287+
pallet_utility::Call::batch_all { calls } => calls,
288+
_ => &Vec::new(),
289+
};
290+
291+
!calls.iter().any(|call| {
292+
matches!(call, RuntimeCall::Utility(inner) if matches!(inner, pallet_utility::Call::force_batch { .. } | pallet_utility::Call::batch_all { .. } | pallet_utility::Call::batch { .. }))
293+
})
294+
}
295+
_ => true,
296+
}
297+
}
298+
}
299+
279300
// Configure FRAME pallets to include in runtime.
280301

281302
impl frame_system::Config for Runtime {
@@ -409,6 +430,25 @@ parameter_types! {
409430
pub const DisallowPermissionlessRelease: Option<BlockNumber> = None;
410431
}
411432

433+
pub struct SafeModeWhitelistedCalls;
434+
impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
435+
fn contains(call: &RuntimeCall) -> bool {
436+
matches!(
437+
call,
438+
RuntimeCall::Sudo(_)
439+
| RuntimeCall::Multisig(_)
440+
| RuntimeCall::System(_)
441+
| RuntimeCall::SafeMode(_)
442+
| RuntimeCall::Timestamp(_)
443+
| RuntimeCall::SubtensorModule(
444+
pallet_subtensor::Call::set_weights { .. }
445+
| pallet_subtensor::Call::serve_axon { .. }
446+
)
447+
| RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. })
448+
)
449+
}
450+
}
451+
412452
impl pallet_safe_mode::Config for Runtime {
413453
type RuntimeEvent = RuntimeEvent;
414454
type Currency = Balances;

0 commit comments

Comments
 (0)