Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

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

Merged
merged 6 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
308 changes: 154 additions & 154 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ parameter_types! {

impl frame_system::Config for Runtime {
/// 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.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
Expand Down Expand Up @@ -214,7 +214,7 @@ impl pallet_bridge_dispatch::Config for Runtime {
type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call;
type CallFilter = frame_support::traits::AllowAll;
type CallFilter = frame_support::traits::Everything;
type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall;
type SourceChainAccountId = bp_rialto::AccountId;
type TargetChainAccountPublic = MultiSigner;
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ parameter_types! {

impl frame_system::Config for Runtime {
/// 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.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
Expand Down Expand Up @@ -265,7 +265,7 @@ impl pallet_bridge_dispatch::Config for Runtime {
type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call;
type CallFilter = frame_support::traits::AllowAll;
type CallFilter = frame_support::traits::Everything;
type EncodedCall = crate::millau_messages::FromMillauEncodedCall;
type SourceChainAccountId = bp_millau::AccountId;
type TargetChainAccountPublic = MultiSigner;
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/currency-exchange/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
Expand Down
12 changes: 6 additions & 6 deletions bridges/modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use frame_support::{
decl_event, decl_module, decl_storage,
dispatch::{Dispatchable, Parameter},
ensure,
traits::{Filter, Get},
traits::{Contains, Get},
weights::{extract_actual_weight, GetDispatchInfo},
};
use frame_system::RawOrigin;
Expand Down Expand Up @@ -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
/// 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 idea behind this is to avoid `Call` conversion/decoding until we'll be sure
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<T: Config<I>, I: Instance> MessageDispatch<T::AccountId, T::MessageId> for
};

// filter the call
if !T::CallFilter::filter(&call) {
if !T::CallFilter::contains(&call) {
log::trace!(
target: "runtime::bridge-dispatch",
"Message {:?}/{:?}: the call ({:?}) is rejected by filter",
Expand Down Expand Up @@ -482,7 +482,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
Expand Down Expand Up @@ -514,8 +514,8 @@ mod tests {

pub struct TestCallFilter;

impl Filter<Call> for TestCallFilter {
fn filter(call: &Call) -> bool {
impl Contains<Call> for TestCallFilter {
fn contains(call: &Call) -> bool {
!matches!(*call, Call::System(frame_system::Call::fill_block(_)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/ethereum/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type DbWeight = ();
type BlockWeights = ();
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl frame_system::Config for TestRuntime {
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/shift-session-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ mod tests {
pub const BlockHashCount: u32 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ mod tests {
pub const BlockHashCount: u32 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/crowdloan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ mod tests {
type BlockNumber = u64;

impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
}

impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ parameter_types! {
}

impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mod multiplier_tests {
}

impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ mod tests {
}

impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
type Call = Call;
type Index = u64;
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ mod tests {
pub const BlockHashCount: u32 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ mod tests {
pub const BlockHashCount: u32 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
Expand Down
14 changes: 8 additions & 6 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
traits::{All, Filter, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade},
traits::{
Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade,
},
weights::Weight,
PalletId, RuntimeDebug,
};
Expand Down Expand Up @@ -136,8 +138,8 @@ pub fn native_version() -> NativeVersion {

/// Don't allow swaps until parathread story is more mature.
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(c: &Call) -> bool {
impl Contains<Call> for BaseFilter {
fn contains(c: &Call) -> bool {
!matches!(c, Call::Registrar(paras_registrar::Call::swap(..)))
}
}
Expand Down Expand Up @@ -1272,7 +1274,7 @@ pub type Barrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
// 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.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
);
Expand Down Expand Up @@ -1320,8 +1322,8 @@ impl pallet_xcm::Config for Runtime {
// ...but they must match our filter, which rejects all.
type XcmExecuteFilter = ();
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ parameter_types! {
pub type AccountId = u64;

impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
Expand Down
6 changes: 3 additions & 3 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
traits::{Filter, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade},
traits::{Contains, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade},
weights::Weight,
PalletId, RuntimeDebug,
};
Expand Down Expand Up @@ -119,8 +119,8 @@ pub fn native_version() -> NativeVersion {
}

pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(call: &Call) -> bool {
impl Contains<Call> for BaseFilter {
fn contains(call: &Call) -> bool {
match call {
// These modules are all allowed to be called by transactions:
Call::Democracy(_) |
Expand Down
16 changes: 8 additions & 8 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion};
use frame_support::{
construct_runtime, parameter_types,
traits::{All, Filter, IsInVec, KeyOwnerProofSystem, OnRuntimeUpgrade, Randomness},
traits::{Contains, Everything, IsInVec, KeyOwnerProofSystem, OnRuntimeUpgrade, Randomness},
weights::Weight,
PalletId,
};
Expand Down Expand Up @@ -266,8 +266,8 @@ construct_runtime! {
}

pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_call: &Call) -> bool {
impl Contains<Call> for BaseFilter {
fn contains(_call: &Call) -> bool {
true
}
}
Expand Down Expand Up @@ -650,7 +650,7 @@ parameter_types! {
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
pub type Barrier = (
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
AllowTopLevelPaidExecutionFrom<Everything>,
AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
);

Expand Down Expand Up @@ -692,8 +692,8 @@ impl pallet_xcm::Config for Runtime {
// ...but they must match our filter, which right now rejects everything.
type XcmExecuteFilter = ();
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
Expand Down Expand Up @@ -833,7 +833,7 @@ impl pallet_bridge_dispatch::Config<AtWococoFromRococoMessagesDispatch> for Runt
type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call;
type CallFilter = frame_support::traits::AllowAll;
type CallFilter = frame_support::traits::Everything;
type EncodedCall = bridge_messages::FromRococoEncodedCall;
type SourceChainAccountId = bp_wococo::AccountId;
type TargetChainAccountPublic = sp_runtime::MultiSigner;
Expand All @@ -847,7 +847,7 @@ impl pallet_bridge_dispatch::Config<AtRococoFromWococoMessagesDispatch> for Runt
type Event = Event;
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
type Call = Call;
type CallFilter = frame_support::traits::AllowAll;
type CallFilter = frame_support::traits::Everything;
type EncodedCall = bridge_messages::FromWococoEncodedCall;
type SourceChainAccountId = bp_rococo::AccountId;
type TargetChainAccountPublic = sp_runtime::MultiSigner;
Expand Down
2 changes: 1 addition & 1 deletion runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ parameter_types! {
}

impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type DbWeight = ();
Expand Down
12 changes: 6 additions & 6 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
traits::{All, Filter, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
traits::{Contains, Everything, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
weights::Weight,
PalletId, RuntimeDebug,
};
Expand Down Expand Up @@ -136,8 +136,8 @@ pub fn native_version() -> NativeVersion {

/// Allow everything.
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_: &Call) -> bool {
impl Contains<Call> for BaseFilter {
fn contains(_: &Call) -> bool {
true
}
}
Expand Down Expand Up @@ -917,7 +917,7 @@ pub type Barrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
// 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.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
);
Expand Down Expand Up @@ -953,8 +953,8 @@ impl pallet_xcm::Config for Runtime {
// ...but they must match our filter, which rejects everything.
type XcmExecuteFilter = ();
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
Expand Down
Loading