diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 17519cbf20..56e9e9c34b 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -60,7 +60,7 @@ use sp_core::{u32_trait::*, OpaqueMetadata, H160, H256, U256}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{BlakeTwo256, Block as BlockT, IdentityLookup}, - transaction_validity::{TransactionSource, TransactionValidity}, + transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidity}, AccountId32, ApplyExtrinsicResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill, }; use sp_std::{convert::TryFrom, prelude::*}; @@ -869,7 +869,15 @@ runtime_common::impl_runtime_apis_plus_common! { tx: ::Extrinsic, block_hash: ::Hash, ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) + // Filtered calls should not enter the tx pool as they'll fail if inserted. + let allowed = + ::BaseCallFilter::filter(&tx.function); + + if allowed { + Executive::validate_transaction(source, tx, block_hash) + } else { + InvalidTransaction::Call.into() + } } } } diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index ab9796e0ce..5f0449d6fc 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -212,7 +212,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type DbWeight = RocksDbWeight; - type BaseCallFilter = BaseFilter; + type BaseCallFilter = MaintenanceMode; type SystemWeightInfo = (); /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = SS58Prefix; @@ -786,7 +786,7 @@ impl Filter for PhaseThreeFilter { impl pallet_maintenance_mode::Config for Runtime { type Event = Event; - type NormalCallFilter = (); + type NormalCallFilter = BaseFilter; type MaintenanceCallFilter = PhaseThreeFilter; type MaintenanceOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechCommitteeInstance>; diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index 39ef7e6601..2f4a01c4aa 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -60,7 +60,7 @@ use sp_core::{u32_trait::*, OpaqueMetadata, H160, H256, U256}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{BlakeTwo256, Block as BlockT, IdentityLookup}, - transaction_validity::{TransactionSource, TransactionValidity}, + transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidity}, AccountId32, ApplyExtrinsicResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill, }; use sp_std::{convert::TryFrom, prelude::*}; @@ -197,7 +197,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type DbWeight = RocksDbWeight; - type BaseCallFilter = (); + type BaseCallFilter = MaintenanceMode; type SystemWeightInfo = (); /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = SS58Prefix; @@ -881,7 +881,15 @@ runtime_common::impl_runtime_apis_plus_common! { tx: ::Extrinsic, block_hash: ::Hash, ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) + // Filtered calls should not enter the tx pool as they'll fail if inserted. + let allowed = + ::BaseCallFilter::filter(&tx.function); + + if allowed { + Executive::validate_transaction(source, tx, block_hash) + } else { + InvalidTransaction::Call.into() + } } } }