Unverified Commit 292ba8a7 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Companion to #9514 (Remove Filter and use Contains instead) (#3591)

* Remove Filter and use Contains instead

* Fixes

* Remove patch

* Formatting

* update Substrate

Co-authored-by: parity-processbot <>
parent 73dc743c
Pipeline #151781 failed with stages
in 15 minutes and 55 seconds
This diff is collapsed.
...@@ -157,7 +157,7 @@ parameter_types! { ...@@ -157,7 +157,7 @@ parameter_types! {
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable. /// The basic call filter to use in dispatchable.
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
/// The identifier used to distinguish between accounts. /// The identifier used to distinguish between accounts.
type AccountId = AccountId; type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics. /// The aggregated dispatch type that is available for extrinsics.
...@@ -214,7 +214,7 @@ impl pallet_bridge_dispatch::Config for Runtime { ...@@ -214,7 +214,7 @@ impl pallet_bridge_dispatch::Config for Runtime {
type Event = Event; type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call; type Call = Call;
type CallFilter = frame_support::traits::AllowAll; type CallFilter = frame_support::traits::Everything;
type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall; type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall;
type SourceChainAccountId = bp_rialto::AccountId; type SourceChainAccountId = bp_rialto::AccountId;
type TargetChainAccountPublic = MultiSigner; type TargetChainAccountPublic = MultiSigner;
......
...@@ -165,7 +165,7 @@ parameter_types! { ...@@ -165,7 +165,7 @@ parameter_types! {
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable. /// The basic call filter to use in dispatchable.
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
/// The identifier used to distinguish between accounts. /// The identifier used to distinguish between accounts.
type AccountId = AccountId; type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics. /// The aggregated dispatch type that is available for extrinsics.
...@@ -265,7 +265,7 @@ impl pallet_bridge_dispatch::Config for Runtime { ...@@ -265,7 +265,7 @@ impl pallet_bridge_dispatch::Config for Runtime {
type Event = Event; type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call; type Call = Call;
type CallFilter = frame_support::traits::AllowAll; type CallFilter = frame_support::traits::Everything;
type EncodedCall = crate::millau_messages::FromMillauEncodedCall; type EncodedCall = crate::millau_messages::FromMillauEncodedCall;
type SourceChainAccountId = bp_millau::AccountId; type SourceChainAccountId = bp_millau::AccountId;
type TargetChainAccountPublic = MultiSigner; type TargetChainAccountPublic = MultiSigner;
......
...@@ -355,7 +355,7 @@ mod tests { ...@@ -355,7 +355,7 @@ mod tests {
type AccountData = (); type AccountData = ();
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
......
...@@ -37,7 +37,7 @@ use frame_support::{ ...@@ -37,7 +37,7 @@ use frame_support::{
decl_event, decl_module, decl_storage, decl_event, decl_module, decl_storage,
dispatch::{Dispatchable, Parameter}, dispatch::{Dispatchable, Parameter},
ensure, ensure,
traits::{Filter, Get}, traits::{Contains, Get},
weights::{extract_actual_weight, GetDispatchInfo}, weights::{extract_actual_weight, GetDispatchInfo},
}; };
use frame_system::RawOrigin; use frame_system::RawOrigin;
...@@ -73,7 +73,7 @@ pub trait Config<I = DefaultInstance>: frame_system::Config { ...@@ -73,7 +73,7 @@ pub trait Config<I = DefaultInstance>: frame_system::Config {
/// ///
/// The pallet will filter all incoming calls right before they're dispatched. If this filter /// The pallet will filter all incoming calls right before they're dispatched. If this filter
/// rejects the call, special event (`Event::MessageCallRejected`) is emitted. /// rejects the call, special event (`Event::MessageCallRejected`) is emitted.
type CallFilter: Filter<<Self as Config<I>>::Call>; type CallFilter: Contains<<Self as Config<I>>::Call>;
/// The type that is used to wrap the `Self::Call` when it is moved over bridge. /// The type that is used to wrap the `Self::Call` when it is moved over bridge.
/// ///
/// The idea behind this is to avoid `Call` conversion/decoding until we'll be sure /// The idea behind this is to avoid `Call` conversion/decoding until we'll be sure
...@@ -244,7 +244,7 @@ impl<T: Config<I>, I: Instance> MessageDispatch<T::AccountId, T::MessageId> for ...@@ -244,7 +244,7 @@ impl<T: Config<I>, I: Instance> MessageDispatch<T::AccountId, T::MessageId> for
}; };
// filter the call // filter the call
if !T::CallFilter::filter(&call) { if !T::CallFilter::contains(&call) {
log::trace!( log::trace!(
target: "runtime::bridge-dispatch", target: "runtime::bridge-dispatch",
"Message {:?}/{:?}: the call ({:?}) is rejected by filter", "Message {:?}/{:?}: the call ({:?}) is rejected by filter",
...@@ -482,7 +482,7 @@ mod tests { ...@@ -482,7 +482,7 @@ mod tests {
type AccountData = (); type AccountData = ();
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
...@@ -514,8 +514,8 @@ mod tests { ...@@ -514,8 +514,8 @@ mod tests {
pub struct TestCallFilter; pub struct TestCallFilter;
impl Filter<Call> for TestCallFilter { impl Contains<Call> for TestCallFilter {
fn filter(call: &Call) -> bool { fn contains(call: &Call) -> bool {
!matches!(*call, Call::System(frame_system::Call::fill_block(_))) !matches!(*call, Call::System(frame_system::Call::fill_block(_)))
} }
} }
......
...@@ -73,7 +73,7 @@ impl frame_system::Config for TestRuntime { ...@@ -73,7 +73,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = (); type AccountData = ();
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
......
...@@ -70,7 +70,7 @@ impl frame_system::Config for TestRuntime { ...@@ -70,7 +70,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = (); type AccountData = ();
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type DbWeight = (); type DbWeight = ();
type BlockWeights = (); type BlockWeights = ();
......
...@@ -106,7 +106,7 @@ impl frame_system::Config for TestRuntime { ...@@ -106,7 +106,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = pallet_balances::AccountData<Balance>; type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
......
...@@ -139,7 +139,7 @@ mod tests { ...@@ -139,7 +139,7 @@ mod tests {
type AccountData = (); type AccountData = ();
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
......
...@@ -683,7 +683,7 @@ mod tests { ...@@ -683,7 +683,7 @@ mod tests {
pub const BlockHashCount: u32 = 250; pub const BlockHashCount: u32 = 250;
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -731,7 +731,7 @@ mod tests { ...@@ -731,7 +731,7 @@ mod tests {
pub const BlockHashCount: u32 = 250; pub const BlockHashCount: u32 = 250;
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -838,7 +838,7 @@ mod tests { ...@@ -838,7 +838,7 @@ mod tests {
type BlockNumber = u64; type BlockNumber = u64;
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -111,7 +111,7 @@ mod tests { ...@@ -111,7 +111,7 @@ mod tests {
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin; type Origin = Origin;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
......
...@@ -79,7 +79,7 @@ parameter_types! { ...@@ -79,7 +79,7 @@ parameter_types! {
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -216,7 +216,7 @@ mod multiplier_tests { ...@@ -216,7 +216,7 @@ mod multiplier_tests {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -592,7 +592,7 @@ mod tests { ...@@ -592,7 +592,7 @@ mod tests {
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
type Index = u64; type Index = u64;
......
...@@ -497,7 +497,7 @@ mod tests { ...@@ -497,7 +497,7 @@ mod tests {
pub const BlockHashCount: u32 = 250; pub const BlockHashCount: u32 = 250;
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
...@@ -507,7 +507,7 @@ mod tests { ...@@ -507,7 +507,7 @@ mod tests {
pub const BlockHashCount: u32 = 250; pub const BlockHashCount: u32 = 250;
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Origin = Origin; type Origin = Origin;
......
...@@ -49,7 +49,9 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; ...@@ -49,7 +49,9 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId; use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{ use frame_support::{
construct_runtime, parameter_types, construct_runtime, parameter_types,
traits::{All, Filter, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade}, traits::{
Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade,
},
weights::Weight, weights::Weight,
PalletId, RuntimeDebug, PalletId, RuntimeDebug,
}; };
...@@ -136,8 +138,8 @@ pub fn native_version() -> NativeVersion { ...@@ -136,8 +138,8 @@ pub fn native_version() -> NativeVersion {
/// Don't allow swaps until parathread story is more mature. /// Don't allow swaps until parathread story is more mature.
pub struct BaseFilter; pub struct BaseFilter;
impl Filter<Call> for BaseFilter { impl Contains<Call> for BaseFilter {
fn filter(c: &Call) -> bool { fn contains(c: &Call) -> bool {
!matches!(c, Call::Registrar(paras_registrar::Call::swap(..))) !matches!(c, Call::Registrar(paras_registrar::Call::swap(..)))
} }
} }
...@@ -1272,7 +1274,7 @@ pub type Barrier = ( ...@@ -1272,7 +1274,7 @@ pub type Barrier = (
// Weight that is paid for may be consumed. // Weight that is paid for may be consumed.
TakeWeightCredit, TakeWeightCredit,
// If the message is one that immediately attemps to pay for execution, then allow it. // If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<All<MultiLocation>>, AllowTopLevelPaidExecutionFrom<Everything>,
// Messages coming from system parachains need not pay for execution. // Messages coming from system parachains need not pay for execution.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>, AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
); );
...@@ -1320,8 +1322,8 @@ impl pallet_xcm::Config for Runtime { ...@@ -1320,8 +1322,8 @@ impl pallet_xcm::Config for Runtime {
// ...but they must match our filter, which rejects all. // ...but they must match our filter, which rejects all.
type XcmExecuteFilter = (); type XcmExecuteFilter = ();
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>; type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
} }
......
...@@ -65,7 +65,7 @@ parameter_types! { ...@@ -65,7 +65,7 @@ parameter_types! {
pub type AccountId = u64; pub type AccountId = u64;
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment