Introduce in-origin filtering (#6318)

* impl filter in origin

* remove IsCallable usage. Breaking: utility::batch(root, calls) no longer bypass BasicCallFilter

* rename BasicCallFilter -> BaseCallFilter

* refactor code

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* remove forgotten temporar comment

* better add suggestion in another PR

* refactor: use Clone instead of mem::replace

* fix tests

* fix tests

* fix tests

* fix benchmarks

* Make root bypass filter in utility::batch

* fix unused imports

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Guillaume Thiolliere
2020-06-15 17:05:41 +02:00
committed by GitHub
parent 97cac4ce8b
commit c2ad27271b
79 changed files with 536 additions and 302 deletions
+2 -13
View File
@@ -33,7 +33,7 @@ use frame_support::{
traits::{Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness, LockIdentifier},
};
use frame_system::{EnsureRoot, EnsureOneOf};
use frame_support::traits::{Filter, InstanceFilter};
use frame_support::traits::InstanceFilter;
use codec::{Encode, Decode};
use sp_core::{
crypto::KeyTypeId,
@@ -113,15 +113,6 @@ pub fn native_version() -> NativeVersion {
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_call: &Call) -> bool {
true
}
}
pub struct IsCallable;
frame_support::impl_filter_stack!(IsCallable, BaseFilter, Call, is_callable);
pub struct DealWithFees;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {
@@ -155,6 +146,7 @@ parameter_types! {
const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
impl frame_system::Trait for Runtime {
type BaseCallFilter = ();
type Origin = Origin;
type Call = Call;
type Index = Index;
@@ -183,7 +175,6 @@ impl frame_system::Trait for Runtime {
impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type IsCallable = IsCallable;
}
parameter_types! {
@@ -201,7 +192,6 @@ impl pallet_multisig::Trait for Runtime {
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
}
parameter_types! {
@@ -251,7 +241,6 @@ impl pallet_proxy::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type IsCallable = IsCallable;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;