diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 41edbb02f59ad866e96223f7a1e38f0eca6018fb..e2d0ca4cddf6b3b9c9438f9b418296a38c2b2071 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -123,15 +123,20 @@ macro_rules! runtime_apis { } } - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: <Block as BlockT>::Extrinsic, + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: <Block as BlockT>::Extrinsic, block_hash: <Block as BlockT>::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } + ) -> TransactionValidity { + // Filtered calls should not enter the tx pool. + if !<Runtime as frame_system::Config>::BaseCallFilter::contains(&tx.function) + { + return sp_runtime::transaction_validity::InvalidTransaction::Call.into(); + } + Executive::validate_transaction(source, tx, block_hash) + } + } impl sp_offchain::OffchainWorkerApi<Block> for Runtime { fn offchain_worker(header: &<Block as BlockT>::Header) { diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 6ab4dcb8af6530fe1703eadbd5847f0c96cfb39c..2546c4f3c94466953e96609b3c9d578e297db9aa 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; +use frame_support::traits::Contains; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -121,7 +122,7 @@ pub type Executive = frame_executive::Executive< >; pub struct BaseCallFilter; -impl frame_support::traits::Contains<Call> for BaseCallFilter { +impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { !matches!( call, diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index d064ffe75265bdd2c9113f87bcc4cc7e5c4a8dc9..7bc127edf7622df35cbc6961d352eabe7fe1fd98 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; +use frame_support::traits::Contains; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -123,7 +124,7 @@ pub type Executive = frame_executive::Executive< >; pub struct BaseCallFilter; -impl frame_support::traits::Contains<Call> for BaseCallFilter { +impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { !matches!( call, diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 179d226908ed856a9113a89619b9495b3a7542cf..be6b0723a3f5c6cc02dd470c761def90904cbc55 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; +use frame_support::traits::Contains; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; @@ -122,7 +123,7 @@ pub type Executive = frame_executive::Executive< >; pub struct BaseCallFilter; -impl frame_support::traits::Contains<Call> for BaseCallFilter { +impl Contains<Call> for BaseCallFilter { fn contains(call: &Call) -> bool { !matches!( call,