From 238fb534b4d3c46a827e2a997ec983f9cbd185ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Wed, 2 Jun 2021 15:57:35 +0200 Subject: [PATCH 1/9] contracts: Allow contracts to dispatch calls into the runtime --- Cargo.lock | 1 + bin/node/runtime/src/lib.rs | 17 ++- frame/contracts/Cargo.toml | 1 + frame/contracts/common/src/lib.rs | 9 ++ frame/contracts/fixtures/call_runtime.wat | 33 +++++ frame/contracts/fixtures/call_with_limit.wat | 37 +++++ frame/contracts/src/chain_extension.rs | 16 ++- frame/contracts/src/exec.rs | 135 ++++++++++++++++++- frame/contracts/src/gas.rs | 35 ++++- frame/contracts/src/lib.rs | 49 ++++++- frame/contracts/src/tests.rs | 116 ++++++++++++++-- frame/contracts/src/wasm/mod.rs | 99 +++++++++++++- frame/contracts/src/wasm/runtime.rs | 77 ++++++++++- 13 files changed, 589 insertions(+), 36 deletions(-) create mode 100644 frame/contracts/fixtures/call_runtime.wat create mode 100644 frame/contracts/fixtures/call_with_limit.wat diff --git a/Cargo.lock b/Cargo.lock index 1905090baa10a..5ca2c8e5094c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4893,6 +4893,7 @@ dependencies = [ "pallet-contracts-proc-macro", "pallet-randomness-collective-flip", "pallet-timestamp", + "pallet-utility", "parity-scale-codec", "paste 1.0.4", "pretty_assertions 0.7.2", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 109a492e2c713..23c5b645007b1 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -33,7 +33,7 @@ use frame_support::{ }, traits::{ Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, LockIdentifier, - U128CurrencyToVote, MaxEncodedLen, + U128CurrencyToVote, MaxEncodedLen, Filter, }, }; use frame_system::{ @@ -821,11 +821,26 @@ parameter_types! { pub Schedule: pallet_contracts::Schedule = Default::default(); } +/// The safest default is to allow no calls at all. +/// +/// Runtimes should whitelist dispatchables that areallowed to be called from contracts +/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to +/// change because that would break already deployed contracts. The `Call` structure itself +/// is not allowed to change the indices of existing pallets, too. +pub struct ContractsCallFilter; +impl Filter for ContractsCallFilter { + fn filter(_: &Call) -> bool { + false + } +} + impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type Event = Event; + type Call = Call; + type CallFilter = ContractsCallFilter; type RentPayment = (); type SignedClaimHandicap = SignedClaimHandicap; type TombstoneDeposit = TombstoneDeposit; diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 9d344fb6866d7..82412ce616a5e 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -48,6 +48,7 @@ wat = "1" pallet-balances = { version = "3.0.0", path = "../balances" } pallet-timestamp = { version = "3.0.0", path = "../timestamp" } pallet-randomness-collective-flip = { version = "3.0.0", path = "../randomness-collective-flip" } +pallet-utility = { version = "3.0.0", path = "../utility" } [features] default = ["std"] diff --git a/frame/contracts/common/src/lib.rs b/frame/contracts/common/src/lib.rs index 04c541a59a39f..098ffd64b8e8e 100644 --- a/frame/contracts/common/src/lib.rs +++ b/frame/contracts/common/src/lib.rs @@ -37,6 +37,15 @@ use serde::{Serialize, Deserialize}; pub struct ContractResult { /// How much gas was consumed during execution. pub gas_consumed: u64, + /// How much gas is required as gas limit in order to execute this call. + /// + /// This value should be used to determine the gas limit for on-chain execution. + /// + /// # Note + /// + /// This can only different from [`Self::gas_consumed`] when weight pre charging + /// is used. Currently, only `seal_call_runtime` makes use of pre charging. + pub gas_required: u64, /// An optional debug message. This message is only filled when explicitly requested /// by the code that calls into the contract. Otherwise it is empty. /// diff --git a/frame/contracts/fixtures/call_runtime.wat b/frame/contracts/fixtures/call_runtime.wat new file mode 100644 index 0000000000000..d5467f6e95e3e --- /dev/null +++ b/frame/contracts/fixtures/call_runtime.wat @@ -0,0 +1,33 @@ +;; This passes its input to `seal_call_runtime` and returns the return value to its caller. +(module + (import "__unstable__" "seal_call_runtime" (func $seal_call_runtime (param i32 i32) (result i32))) + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "env" "memory" (memory 1 1)) + + ;; 0x1000 = 4k in little endian + ;; size of input buffer + (data (i32.const 0) "\00\10") + + (func (export "call") + ;; Receive the encoded call + (call $seal_input + (i32.const 4) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the length buffer + ) + ;; Just use the call passed as input and store result to memory + (i32.store (i32.const 0) + (call $seal_call_runtime + (i32.const 4) ;; Pointer where the call is stored + (i32.load (i32.const 0)) ;; Size of the call + ) + ) + (call $seal_return + (i32.const 0) ;; flags + (i32.const 0) ;; returned value + (i32.const 4) ;; length of returned value + ) + ) + + (func (export "deploy")) +) diff --git a/frame/contracts/fixtures/call_with_limit.wat b/frame/contracts/fixtures/call_with_limit.wat new file mode 100644 index 0000000000000..abb8708267271 --- /dev/null +++ b/frame/contracts/fixtures/call_with_limit.wat @@ -0,0 +1,37 @@ +;; This expects [account_id, gas_limit] as input and calls the account_id with the supplied gas_limit. +;; It returns the result of the call as output data. +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "env" "memory" (memory 1 1)) + + ;; 0x1000 = 4k in little endian + ;; size of input buffer + (data (i32.const 0) "\00\10") + + (func (export "deploy")) + + (func (export "call") + ;; Receive the encoded call + gas_limit + (call $seal_input + (i32.const 4) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the length buffer + ) + (i32.store + (i32.const 0) + (call $seal_call + (i32.const 4) ;; Pointer to "callee" address. + (i32.const 32) ;; Length of "callee" address. + (i64.load (i32.const 36)) ;; How much gas to devote for the execution. + (i32.const 0) ;; Pointer to the buffer with value to transfer + (i32.const 0) ;; Length of the buffer with value to transfer. + (i32.const 0) ;; Pointer to input data buffer address + (i32.const 0) ;; Length of input data buffer + (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output + (i32.const 0) ;; Ptr to output buffer len + ) + ) + (call $seal_return (i32.const 0) (i32.const 0) (i32.const 4)) + ) +) diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 01c362f613a51..b386e537e5420 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -57,6 +57,7 @@ use crate::{ Error, wasm::{Runtime, RuntimeCosts}, + gas::ChargedAmount, }; use codec::Decode; use frame_support::{weights::Weight, traits::MaxEncodedLen}; @@ -167,11 +168,22 @@ where /// `weight`. It returns `Err` otherwise. In this case the chain extension should /// abort the execution and pass through the error. /// + /// The returned value can be used to with [`Self::adjust_weight`]. Other than that + /// it has no purpose. + /// /// # Note /// /// Weight is synonymous with gas in substrate. - pub fn charge_weight(&mut self, amount: Weight) -> Result<()> { - self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount)).map(|_| ()) + pub fn charge_weight(&mut self, amount: Weight) -> Result { + self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount)) + } + + /// Adjust a previously charged amount down to its actual amount. + /// + /// This is when a maximum a priori amount was charged and then should be partially + /// refunded to match the actual amount. + pub fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { + self.inner.runtime.adjust_gas(charged, RuntimeCosts::ChainExtension(actual_weight)) } /// Grants access to the execution environment of the current contract call. diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 2b595ea6ce8d4..ae1585afbb890 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -28,12 +28,13 @@ use sp_std::{ }; use sp_runtime::{Perbill, traits::{Convert, Saturating}}; use frame_support::{ - dispatch::{DispatchResult, DispatchError}, + dispatch::{DispatchResult, DispatchError, DispatchResultWithPostInfo, Dispatchable}, storage::{with_transaction, TransactionOutcome}, - traits::{ExistenceRequirement, Currency, Time, Randomness, Get}, + traits::{ExistenceRequirement, Currency, Time, Randomness, Get, OriginTrait, Filter}, weights::Weight, ensure, DefaultNoBound, }; +use frame_system::RawOrigin; use pallet_contracts_primitives::{ExecReturnValue}; use smallvec::{SmallVec, Array}; @@ -300,6 +301,9 @@ pub trait Ext: sealing::Sealed { /// /// Returns `true` if debug message recording is enabled. Otherwise `false` is returned. fn append_debug_buffer(&mut self, msg: &str) -> bool; + + /// Call some dispatchable and return the result. + fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -1291,6 +1295,12 @@ where false } } + + fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo { + let mut origin: T::Origin = RawOrigin::Signed(self.address().clone()).into(); + origin.add_filter(T::CallFilter::filter); + call.dispatch(origin) + } } fn deposit_event( @@ -1326,10 +1336,10 @@ mod sealing { mod tests { use super::*; use crate::{ - gas::GasMeter, tests::{ExtBuilder, Test, Event as MetaEvent}, + gas::GasMeter, storage::Storage, tests::{ - ALICE, BOB, CHARLIE, + ALICE, BOB, CHARLIE, Call, TestFilter, ExtBuilder, Test, Event as MetaEvent, test_utils::{place_contract, set_balance, get_balance}, }, exec::ExportedFunction::*, @@ -1337,12 +1347,15 @@ mod tests { }; use codec::{Encode, Decode}; use sp_core::Bytes; - use sp_runtime::DispatchError; + use sp_runtime::{DispatchError, traits::{BadOrigin, Hash}}; use assert_matches::assert_matches; use std::{cell::RefCell, collections::HashMap, rc::Rc}; use pretty_assertions::{assert_eq, assert_ne}; use pallet_contracts_primitives::ReturnFlags; use frame_support::{assert_ok, assert_err}; + use frame_system::{EventRecord, Phase}; + + type System = frame_system::Pallet; type MockStack<'a> = Stack<'a, Test, MockExecutable>; @@ -1353,7 +1366,7 @@ mod tests { } fn events() -> Vec> { - >::events() + System::events() .into_iter() .filter_map(|meta| match meta.event { MetaEvent::Contracts(contract_event) => Some(contract_event), @@ -2503,4 +2516,114 @@ mod tests { ); }); } + + #[test] + fn call_runtime_works() { + let code_hash = MockLoader::insert(Call, |ctx, _| { + let call = Call::System(frame_system::Call::remark_with_event(b"Hello World".to_vec())); + ctx.ext.call_runtime(call).unwrap(); + exec_success() + }); + + ExtBuilder::default().build().execute_with(|| { + let subsistence = Contracts::::subsistence_threshold(); + let schedule = ::Schedule::get(); + let mut gas_meter = GasMeter::::new(GAS_LIMIT); + set_balance(&ALICE, subsistence * 10); + place_contract(&BOB, code_hash); + System::reset_events(); + MockStack::run_call( + ALICE, + BOB, + &mut gas_meter, + &schedule, + 0, + vec![], + None, + ).unwrap(); + + let remark_hash = ::Hashing::hash(b"Hello World"); + assert_eq!(System::events(), vec![ + EventRecord { + phase: Phase::Initialization, + event: MetaEvent::System(frame_system::Event::Remarked(BOB, remark_hash)), + topics: vec![], + }, + ]); + }); + } + + #[test] + fn call_runtime_filter() { + let code_hash = MockLoader::insert(Call, |ctx, _| { + use frame_system::Call as SysCall; + use pallet_balances::Call as BalanceCall; + use pallet_utility::Call as UtilCall; + + // remark should still be allowed + let allowed_call = Call::System(SysCall::remark_with_event(b"Hello".to_vec())); + + // transfers are disallowed by the `TestFiler` (see below) + let forbidden_call = Call::Balances(BalanceCall::transfer(CHARLIE, 22)); + + // simple cases: direct call + assert_err!( + ctx.ext.call_runtime(forbidden_call.clone()), + BadOrigin, + ); + + // as part of a patch: return is OK (but it interrupted the batch) + assert_ok!( + ctx.ext.call_runtime(Call::Utility(UtilCall::batch(vec![ + allowed_call.clone(), forbidden_call, allowed_call + ]))), + ); + + // the transfer wasn't performed + assert_eq!(get_balance(&CHARLIE), 0); + + exec_success() + }); + + TestFilter::set_filter(|call| { + match call { + Call::Balances(pallet_balances::Call::transfer(_, _)) => false, + _ => true, + } + }); + + ExtBuilder::default().build().execute_with(|| { + let subsistence = Contracts::::subsistence_threshold(); + let schedule = ::Schedule::get(); + let mut gas_meter = GasMeter::::new(GAS_LIMIT); + set_balance(&ALICE, subsistence * 10); + place_contract(&BOB, code_hash); + System::reset_events(); + MockStack::run_call( + ALICE, + BOB, + &mut gas_meter, + &schedule, + 0, + vec![], + None, + ).unwrap(); + + let remark_hash = ::Hashing::hash(b"Hello"); + assert_eq!(System::events(), vec![ + EventRecord { + phase: Phase::Initialization, + event: MetaEvent::System(frame_system::Event::Remarked(BOB, remark_hash)), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: MetaEvent::Utility( + pallet_utility::Event::BatchInterrupted(1, BadOrigin.into()), + ), + topics: vec![], + }, + ]); + }); + } } diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index 34ddb3ceb0434..13695b46a1daa 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -79,6 +79,8 @@ pub struct GasMeter { gas_limit: Weight, /// Amount of gas left from initial gas limit. Can reach zero. gas_left: Weight, + /// Due to `adjust_gas` and `nested` the `gas_left` can temporarily dip below its final value. + gas_left_lowest: Option, _phantom: PhantomData, #[cfg(test)] tokens: Vec, @@ -92,6 +94,7 @@ where GasMeter { gas_limit, gas_left: gas_limit, + gas_left_lowest: None, _phantom: PhantomData, #[cfg(test)] tokens: Vec::new(), @@ -122,6 +125,16 @@ where /// Absorb the remaining gas of a nested meter after we are done using it. pub fn absorb_nested(&mut self, nested: Self) { + if self.gas_left == 0 { + // All of the remaining gas was inherited by the nested gas meter. When absorbing + // we can also safely inherit the lowest gas that the nested gas meter experienced. + self.gas_left_lowest = Some(nested.gas_left_lowest().min(self.gas_left_lowest())) + } else { + // The nested gas meter was created with a fixed amount that did not consume all of the + // parents (self) gas. The lowest gas that self will experience is when the nested + // gas was pre charged. + self.gas_left_lowest = Some(self.gas_left_lowest()); + } self.gas_left += nested.gas_left; } @@ -163,12 +176,21 @@ where /// This is when a maximum a priori amount was charged and then should be partially /// refunded to match the actual amount. pub fn adjust_gas>(&mut self, charged_amount: ChargedAmount, token: Tok) { + self.gas_left_lowest = Some(self.gas_left_lowest()); let adjustment = charged_amount.0.saturating_sub(token.weight()); self.gas_left = self.gas_left.saturating_add(adjustment).min(self.gas_limit); } - /// Returns how much gas was used. - pub fn gas_spent(&self) -> Weight { + /// Returns the amount of gas that is required to run the same call. + /// + /// This can be different from `gas_spent` because due to `adjust_gas` the amount of + /// spent gas can temporarily drop and be refunded later. + pub fn gas_required(&self) -> Weight { + self.gas_limit - self.gas_left_lowest() + } + + /// Returns how much gas was spent + pub fn gas_consumed(&self) -> Weight { self.gas_limit - self.gas_left } @@ -179,14 +201,15 @@ where /// Turn this GasMeter into a DispatchResult that contains the actually used gas. pub fn into_dispatch_result( - self, result: Result, + self, + result: Result, base_weight: Weight, ) -> DispatchResultWithPostInfo where E: Into, { let post_info = PostDispatchInfo { - actual_weight: Some(self.gas_spent().saturating_add(base_weight)), + actual_weight: Some(self.gas_consumed().saturating_add(base_weight)), pays_fee: Default::default(), }; @@ -195,6 +218,10 @@ where .map_err(|e| DispatchErrorWithPostInfo { post_info, error: e.into().error }) } + fn gas_left_lowest(&self) -> Weight { + self.gas_left_lowest.map(|d| d.min(self.gas_left)).unwrap_or(self.gas_left) + } + #[cfg(test)] pub fn tokens(&self) -> &[ErasedToken] { &self.tokens diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 3ac56d8980cb2..116ca6ce18881 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -118,8 +118,9 @@ use sp_runtime::{ Perbill, }; use frame_support::{ - traits::{OnUnbalanced, Currency, Get, Time, Randomness}, - weights::{Weight, PostDispatchInfo, WithPostDispatchInfo}, + traits::{OnUnbalanced, Currency, Get, Time, Randomness, Filter}, + weights::{Weight, PostDispatchInfo, WithPostDispatchInfo, GetDispatchInfo}, + dispatch::Dispatchable, }; use frame_system::Pallet as System; use pallet_contracts_primitives::{ @@ -154,6 +155,41 @@ pub mod pallet { /// The overarching event type. type Event: From> + IsType<::Event>; + /// The overarching call type. + type Call: + Dispatchable + + GetDispatchInfo + + codec::Decode + + IsType<::Call>; + + /// Filter that is applied to calls dispatched by contracts. + /// + /// Use this filter to control which dispatchables are callable by contracts. + /// This is applied in **addition** to [`frame_system::Config::BaseCallFilter`]. + /// It is recommended to treat this as a whitelist. + /// + /// # Subsistence Threshold + /// + /// The runtime **must** make sure that any allowed dispatchable makes sure that the + /// `total_balance` of the contract stays above [`Pallet::subsistence_threshold()`]. + /// Otherwise contracts can clutter the storage with their tombstones without + /// deposting the correct amount of balance. + /// + /// # Stability + /// + /// The runtime **must** make sure that all dispatchables that are callable by + /// contracts remain stable. In addition [`Self::Call`] itself must remain stable. + /// This means that no existing variants are allowed to switch their positions. + /// + /// # Note + /// + /// Note that dispatchables that are called via contracts do not spawn their + /// own wasm instance for each call (as opposed to when called via a transaction). + /// Therefore please make sure to be restrictive about which dispatchables are allowed + /// in order to not introduce a new DoS vector like memory allocation patterns that can + /// be exploited to drive the runtime into a panic. + type CallFilter: Filter<::Call>; + /// Handler for rent payments. type RentPayment: OnUnbalanced>; @@ -658,7 +694,8 @@ where ); ContractExecResult { result: result.map_err(|r| r.error), - gas_consumed: gas_meter.gas_spent(), + gas_consumed: gas_meter.gas_consumed(), + gas_required: gas_meter.gas_required(), debug_message: debug_message.unwrap_or_default(), } } @@ -699,7 +736,8 @@ where Ok(executable) => executable, Err(error) => return ContractInstantiateResult { result: Err(error.into()), - gas_consumed: gas_meter.gas_spent(), + gas_consumed: gas_meter.gas_consumed(), + gas_required: gas_meter.gas_required(), debug_message: Vec::new(), } }; @@ -727,7 +765,8 @@ where }); ContractInstantiateResult { result: result.map_err(|e| e.error), - gas_consumed: gas_meter.gas_spent(), + gas_consumed: gas_meter.gas_consumed(), + gas_required: gas_meter.gas_required(), debug_message: debug_message.unwrap_or_default(), } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index b3ee139008bc5..63e8f2171fd8c 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -40,13 +40,14 @@ use sp_io::hashing::blake2_256; use frame_support::{ assert_ok, assert_err, assert_err_ignore_postinfo, parameter_types, assert_storage_noop, - traits::{Currency, ReservableCurrency, OnInitialize}, + traits::{Currency, ReservableCurrency, OnInitialize, Filter}, weights::{Weight, PostDispatchInfo, DispatchClass, constants::WEIGHT_PER_SECOND}, dispatch::DispatchErrorWithPostInfo, storage::child, }; use frame_system::{self as system, EventRecord, Phase}; use pretty_assertions::assert_eq; +use std::cell::RefCell; use crate as pallet_contracts; @@ -63,6 +64,7 @@ frame_support::construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Randomness: pallet_randomness_collective_flip::{Pallet, Storage}, + Utility: pallet_utility::{Pallet, Call, Storage, Event}, Contracts: pallet_contracts::{Pallet, Call, Storage, Event}, } ); @@ -125,7 +127,7 @@ pub mod test_utils { } thread_local! { - static TEST_EXTENSION: sp_std::cell::RefCell = Default::default(); + static TEST_EXTENSION: RefCell = Default::default(); } pub struct TestExtension { @@ -256,6 +258,11 @@ impl pallet_timestamp::Config for Test { type MinimumPeriod = MinimumPeriod; type WeightInfo = (); } +impl pallet_utility::Config for Test { + type Event = Event; + type Call = Call; + type WeightInfo = (); +} parameter_types! { pub const SignedClaimHandicap: u64 = 2; pub const TombstoneDeposit: u64 = 16; @@ -269,9 +276,6 @@ parameter_types! { pub const DeletionWeightLimit: Weight = 500_000_000_000; pub const MaxCodeSize: u32 = 2 * 1024; pub MySchedule: Schedule = >::default(); -} - -parameter_types! { pub const TransactionByteFee: u64 = 0; } @@ -281,11 +285,32 @@ impl Convert> for Test { } } +/// A filter whose filter function can be swapped at runtime. +pub struct TestFilter; + +thread_local! { + static CALL_FILTER: RefCell bool> = RefCell::new(|_| true); +} + +impl TestFilter { + pub fn set_filter(filter: fn(&Call) -> bool) { + CALL_FILTER.with(|fltr| *fltr.borrow_mut() = filter); + } +} + +impl Filter for TestFilter { + fn filter(call: &Call) -> bool { + CALL_FILTER.with(|fltr| fltr.borrow()(call)) + } +} + impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; type Event = Event; + type Call = Call; + type CallFilter = TestFilter; type RentPayment = (); type SignedClaimHandicap = SignedClaimHandicap; type TombstoneDeposit = TombstoneDeposit; @@ -2944,8 +2969,8 @@ fn debug_message_invalid_utf8() { } #[test] -fn gas_estimation_correct() { - let (caller_code, caller_hash) = compile_module::("call_return_code").unwrap(); +fn gas_estimation_nested_call_fixed_limit() { + let (caller_code, caller_hash) = compile_module::("call_with_limit").unwrap(); let (callee_code, callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let subsistence = Pallet::::subsistence_threshold(); @@ -2976,24 +3001,93 @@ fn gas_estimation_correct() { ); let addr_callee = Contracts::contract_address(&ALICE, &callee_hash, &[1]); + let input: Vec = AsRef::<[u8]>::as_ref(&addr_callee) + .iter() + .cloned() + .chain((GAS_LIMIT / 5).to_le_bytes()) + .collect(); + // Call in order to determine the gas that is required for this call let result = Contracts::bare_call( ALICE, addr_caller.clone(), 0, GAS_LIMIT, - AsRef::<[u8]>::as_ref(&addr_callee).to_vec(), + input.clone(), false, ); - assert_ok!(result.result); + assert_ok!(&result.result); + + assert!(result.gas_required > result.gas_consumed); // Make the same call using the estimated gas. Should succeed. assert_ok!(Contracts::bare_call( ALICE, addr_caller, 0, - result.gas_consumed, - AsRef::<[u8]>::as_ref(&addr_callee).to_vec(), + result.gas_required, + input, + false, + ).result); + }); +} + +#[test] +#[cfg(feature = "unstable-interface")] +fn gas_estimation_call_runtime() { + let (caller_code, caller_hash) = compile_module::("call_runtime").unwrap(); + let (callee_code, callee_hash) = compile_module::("dummy").unwrap(); + ExtBuilder::default().existential_deposit(50).build().execute_with(|| { + let subsistence = Pallet::::subsistence_threshold(); + let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); + let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence); + + assert_ok!( + Contracts::instantiate_with_code( + Origin::signed(ALICE), + subsistence * 100, + GAS_LIMIT, + caller_code, + vec![], + vec![0], + ), + ); + let addr_caller = Contracts::contract_address(&ALICE, &caller_hash, &[0]); + + assert_ok!( + Contracts::instantiate_with_code( + Origin::signed(ALICE), + subsistence * 100, + GAS_LIMIT, + callee_code, + vec![], + vec![1], + ), + ); + let addr_callee = Contracts::contract_address(&ALICE, &callee_hash, &[1]); + + // Call something trivial with a huge gas limit so that we can observe the effects + // of pre-charging. This should create a difference between consumed and required. + let call = Call::Contracts(crate::Call::call(addr_callee, 0, GAS_LIMIT / 3, vec![])); + let result = Contracts::bare_call( + ALICE, + addr_caller.clone(), + 0, + GAS_LIMIT, + call.encode(), + false, + ); + assert_ok!(&result.result); + + assert!(result.gas_required > result.gas_consumed); + + // Make the same call using the required gas. Should succeed. + assert_ok!(Contracts::bare_call( + ALICE, + addr_caller, + 0, + result.gas_required, + call.encode(), false, ).result); }); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 03a409bb12fe2..ef45f35d0dae9 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -254,18 +254,22 @@ mod tests { rent::RentStatus, tests::{Test, Call, ALICE, BOB}, }; - use std::collections::HashMap; + use std::{ + borrow::BorrowMut, + cell::RefCell, + collections::HashMap, + }; use sp_core::{Bytes, H256}; use hex_literal::hex; use sp_runtime::DispatchError; - use frame_support::{assert_ok, dispatch::DispatchResult, weights::Weight}; + use frame_support::{ + assert_ok, + dispatch::{DispatchResult, DispatchResultWithPostInfo}, + weights::Weight, + }; use assert_matches::assert_matches; use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pretty_assertions::assert_eq; - use sp_std::borrow::BorrowMut; - - #[derive(Debug, PartialEq, Eq)] - struct DispatchEntry(Call); #[derive(Debug, PartialEq, Eq)] struct RestoreEntry { @@ -313,6 +317,7 @@ mod tests { restores: Vec, // (topics, data) events: Vec<(Vec, Vec)>, + runtime_calls: RefCell>, schedule: Schedule, rent_params: RentParams, gas_meter: GasMeter, @@ -335,6 +340,7 @@ mod tests { transfers: Default::default(), restores: Default::default(), events: Default::default(), + runtime_calls: Default::default(), schedule: Default::default(), rent_params: Default::default(), gas_meter: GasMeter::new(10_000_000_000), @@ -481,6 +487,10 @@ mod tests { self.debug_buffer.extend(msg.as_bytes()); true } + fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo { + self.runtime_calls.borrow_mut().push(call); + Ok(Default::default()) + } } fn execute>( @@ -2160,4 +2170,81 @@ mod tests { }) ); } + + #[cfg(feature = "unstable-interface")] + const CODE_CALL_RUNTIME: &str = r#" +(module + (import "__unstable__" "seal_call_runtime" (func $seal_call_runtime (param i32 i32) (result i32))) + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "env" "memory" (memory 1 1)) + + ;; 0x1000 = 4k in little endian + ;; size of input buffer + (data (i32.const 0) "\00\10") + + (func (export "call") + ;; Receive the encoded call + (call $seal_input + (i32.const 4) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the length buffer + ) + ;; Just use the call passed as input and store result to memory + (i32.store (i32.const 0) + (call $seal_call_runtime + (i32.const 4) ;; Pointer where the call is stored + (i32.load (i32.const 0)) ;; Size of the call + ) + ) + (call $seal_return + (i32.const 0) ;; flags + (i32.const 0) ;; returned value + (i32.const 4) ;; length of returned value + ) + ) + + (func (export "deploy")) +) +"#; + + #[test] + #[cfg(feature = "unstable-interface")] + fn call_runtime_works() { + use std::convert::TryInto; + let call = Call::System(frame_system::Call::remark(b"Hello World".to_vec())); + let mut ext = MockExt::default(); + let result = execute( + CODE_CALL_RUNTIME, + call.encode(), + &mut ext, + ).unwrap(); + assert_eq!( + *ext.runtime_calls.borrow(), + vec![call], + ); + // 0 = ReturnCode::Success + assert_eq!(u32::from_le_bytes(result.data.0.try_into().unwrap()), 0); + } + + #[test] + #[cfg(feature = "unstable-interface")] + fn call_runtime_panics_on_invalid_call() { + let mut ext = MockExt::default(); + let result = execute( + CODE_CALL_RUNTIME, + vec![0x42], + &mut ext, + ); + assert_eq!( + result, + Err(ExecError { + error: Error::::DecodingFailed.into(), + origin: ErrorOrigin::Caller, + }) + ); + assert_eq!( + *ext.runtime_calls.borrow(), + vec![], + ); + } } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 28987bba9d700..d288c768f1ab3 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -76,6 +76,9 @@ pub enum ReturnCode { /// recording was disabled. #[cfg(feature = "unstable-interface")] LoggingDisabled = 9, + /// The call dispatched by `seal_call_runtime` was executed but returned an error. + #[cfg(feature = "unstable-interface")] + CallRuntimeReturnedError = 10, } impl ConvertibleToWasm for ReturnCode { @@ -213,6 +216,12 @@ pub enum RuntimeCosts { HashBlake128(u32), /// Weight charged by a chain extension through `seal_call_chain_extension`. ChainExtension(u64), + /// Weight charged for copying data from the sandbox. + #[cfg(feature = "unstable-interface")] + CopyIn(u32), + /// Weight charged for calling into the runtime. + #[cfg(feature = "unstable-interface")] + CallRuntime(Weight), } impl RuntimeCosts { @@ -273,6 +282,10 @@ impl RuntimeCosts { HashBlake128(len) => s.hash_blake2_128 .saturating_add(s.hash_blake2_128_per_byte.saturating_mul(len.into())), ChainExtension(amount) => amount, + #[cfg(feature = "unstable-interface")] + CopyIn(len) => s.return_per_byte.saturating_mul(len.into()), + #[cfg(feature = "unstable-interface")] + CallRuntime(weight) => weight, }; RuntimeToken { #[cfg(test)] @@ -457,6 +470,15 @@ where self.ext.gas_meter().charge(token) } + /// Adjust a previously charged amount down to its actual amount. + /// + /// This is when a maximum a priori amount was charged and then should be partially + /// refunded to match the actual amount. + pub fn adjust_gas(&mut self, charged: ChargedAmount, actual_costs: RuntimeCosts) { + let token = actual_costs.token(&self.ext.schedule().host_fn_weights); + self.ext.gas_meter().adjust_gas(charged, token); + } + /// Read designated chunk from the sandbox memory. /// /// Returns `Err` if one of the following conditions occurs: @@ -797,7 +819,6 @@ where // data passed to the supervisor will lead to a trap. This is not documented explicitly // for every function. define_env!(Env, , - // Account for used gas. Traps if gas used is greater than gas limit. // // NOTE: This is a implementation defined call and is NOT a part of the public API. @@ -1808,4 +1829,58 @@ define_env!(Env, , out_ptr, out_len_ptr, &rent_status, false, already_charged )?) }, + + // Call some dispatchable of the runtime. + // + // This function decodes the passed in data as the overarching `Call` type of the + // runtime and dispatches it. The weight as specified in the runtime is charged + // from the gas meter. Any weight refunds made by the dispatchable are considered. + // + // The filter specified by `Config::CallFilter` is attached to the origin of + // the dispatched call. + // + // # Parameters + // + // - `input_ptr`: the pointer into the linear memory where the input data is placed. + // - `input_len`: the length of the input data in bytes. + // + // # Return Value + // + // Returns `ReturnCode::Success` when the dispatchable was succesfully executed and + // returned `Ok`. When the dispatchable was exeuted but returned an error + // `ReturnCode::CallRuntimeReturnedError` is returned. The full error is not + // provided because it is not guaranteed to be stable. + // + // # Comparison with `ChainExtension` + // + // Just as a chain extension this API allows the runtime to extend the functionality + // of contracts. While making use of this function is generelly easier it cannot be + // used in call cases. Consider writing a chain extension if you need to do perform + // one of the following tasks: + // + // - Return data. + // - Provide functionality **exclusively** to contracts. + // - Provide custom weights. + // - Avoid the need to keep the `Call` data structure stable. + // + // # Unstable + // + // This function is unstable and subject to change (or removal) in the future. Do not + // deploy a contract using it to a production chain. + [__unstable__] seal_call_runtime(ctx, call_ptr: u32, call_len: u32) -> ReturnCode => { + use frame_support::{dispatch::GetDispatchInfo, weights::extract_actual_weight}; + ctx.charge_gas(RuntimeCosts::CopyIn(call_len))?; + let call: ::Call = ctx.read_sandbox_memory_as_unbounded( + call_ptr, call_len + )?; + let dispatch_info = call.get_dispatch_info(); + let charged = ctx.charge_gas(RuntimeCosts::CallRuntime(dispatch_info.weight))?; + let result = ctx.ext.call_runtime(call); + let actual_weight = extract_actual_weight(&result, &dispatch_info); + ctx.adjust_gas(charged, RuntimeCosts::CallRuntime(actual_weight)); + match result { + Ok(_) => Ok(ReturnCode::Success), + Err(_) => Ok(ReturnCode::CallRuntimeReturnedError), + } + }, ); From 0da592cf7afc0ac068831598fc223672117753a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 5 Jul 2021 22:38:02 +0200 Subject: [PATCH 2/9] Fix RPC tests --- frame/contracts/rpc/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 1250d3cb285e7..3b95e98501656 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -385,7 +385,8 @@ mod tests { } test(r#"{ "gasConsumed": 5000, - "debugMessage": "0x68656c704f6b", + "gasRequired": 8000, + "debugMessage": "HelloWorld", "result": { "Ok": { "flags": 5, @@ -395,7 +396,8 @@ mod tests { }"#); test(r#"{ "gasConsumed": 3400, - "debugMessage": "0x68656c70457272", + "gasRequired": 5200, + "debugMessage": "HelloWorld", "result": { "Err": "BadOrigin" } @@ -411,7 +413,8 @@ mod tests { } test(r#"{ "gasConsumed": 5000, - "debugMessage": "0x68656c704f6b", + "gasRequired": 8000, + "debugMessage": "HelloWorld", "result": { "Ok": { "result": { @@ -425,7 +428,8 @@ mod tests { }"#); test(r#"{ "gasConsumed": 3400, - "debugMessage": "0x68656c70457272", + "gasRequired": 5200, + "debugMessage": "HelloWorld", "result": { "Err": "BadOrigin" } From fba4b34c96a0c48ce1f34ecb1d4058983a8914c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 5 Jul 2021 22:58:52 +0200 Subject: [PATCH 3/9] Fix typo --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 96bf9ba3a158a..4f436bf7275e8 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -823,7 +823,7 @@ parameter_types! { /// The safest default is to allow no calls at all. /// -/// Runtimes should whitelist dispatchables that areallowed to be called from contracts +/// Runtimes should whitelist dispatchables that are allowed to be called from contracts /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. From 14858d705877388e210e90745d2919f176d8cc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 6 Jul 2021 09:08:55 +0200 Subject: [PATCH 4/9] Replace () by AllowAllFilter and DenyAllFilter --- .../pallets/template/src/mock.rs | 2 +- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/src/lib.rs | 25 +++++++------------ docs/Upgrading-2.0-to-3.0.md | 2 +- frame/assets/src/mock.rs | 2 +- frame/atomic-swap/src/tests.rs | 2 +- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 4 +-- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/balances/src/tests_composite.rs | 2 +- frame/balances/src/tests_local.rs | 2 +- frame/balances/src/tests_reentrancy.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/bounties/src/tests.rs | 2 +- frame/collective/src/lib.rs | 2 +- frame/contracts/src/tests.rs | 2 +- .../election-provider-multi-phase/src/mock.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/elections/src/mock.rs | 2 +- frame/example-offchain-worker/src/tests.rs | 2 +- frame/example-parallel/src/tests.rs | 2 +- frame/example/src/tests.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/gilt/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/identity/src/tests.rs | 2 +- frame/im-online/src/mock.rs | 2 +- frame/indices/src/mock.rs | 2 +- frame/lottery/src/mock.rs | 2 +- frame/membership/src/lib.rs | 2 +- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/nicks/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/offences/src/mock.rs | 2 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/recovery/src/mock.rs | 2 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/staking/fuzzer/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/support/src/dispatch.rs | 2 +- frame/support/src/traits.rs | 1 + frame/support/src/traits/filter.rs | 10 +++++++- frame/support/test/tests/construct_runtime.rs | 2 +- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/pallet.rs | 2 +- .../test/tests/pallet_compatibility.rs | 2 +- .../tests/pallet_compatibility_instance.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 2 +- frame/support/test/tests/pallet_version.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/system/benches/bench.rs | 2 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/mock.rs | 2 +- frame/timestamp/src/lib.rs | 2 +- frame/tips/src/tests.rs | 2 +- frame/transaction-payment/src/lib.rs | 2 +- frame/transaction-storage/src/mock.rs | 2 +- frame/treasury/src/tests.rs | 2 +- frame/uniques/src/mock.rs | 2 +- frame/vesting/src/mock.rs | 2 +- test-utils/runtime/src/lib.rs | 2 +- 66 files changed, 83 insertions(+), 81 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 8719bcb4df2d5..ab01c94f6df6d 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -27,7 +27,7 @@ parameter_types! { } impl system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 940eb2379b114..b653615921edb 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -146,7 +146,7 @@ parameter_types! { impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4f436bf7275e8..0e8d3d5b3340a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -33,7 +33,7 @@ use frame_support::{ }, traits::{ Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, LockIdentifier, - U128CurrencyToVote, Filter, + U128CurrencyToVote, AllowAllFilter, DenyAllFilter, }, }; use frame_system::{ @@ -193,7 +193,7 @@ parameter_types! { const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = AllowAllFilter; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; @@ -821,26 +821,19 @@ parameter_types! { pub Schedule: pallet_contracts::Schedule = Default::default(); } -/// The safest default is to allow no calls at all. -/// -/// Runtimes should whitelist dispatchables that are allowed to be called from contracts -/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to -/// change because that would break already deployed contracts. The `Call` structure itself -/// is not allowed to change the indices of existing pallets, too. -pub struct ContractsCallFilter; -impl Filter for ContractsCallFilter { - fn filter(_: &Call) -> bool { - false - } -} - impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type Event = Event; type Call = Call; - type CallFilter = ContractsCallFilter; + /// The safest default is to allow no calls at all. + /// + /// Runtimes should whitelist dispatchables that are allowed to be called from contracts + /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to + /// change because that would break already deployed contracts. The `Call` structure itself + /// is not allowed to change the indices of existing pallets, too. + type CallFilter = DenyAllFilter; type RentPayment = (); type SignedClaimHandicap = SignedClaimHandicap; type TombstoneDeposit = TombstoneDeposit; diff --git a/docs/Upgrading-2.0-to-3.0.md b/docs/Upgrading-2.0-to-3.0.md index 46f01ab7824cd..039c3059caea6 100644 --- a/docs/Upgrading-2.0-to-3.0.md +++ b/docs/Upgrading-2.0-to-3.0.md @@ -143,7 +143,7 @@ And update the overall definition for weights on frame and a few related types a +const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); + +impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type DbWeight = RocksDbWeight; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index cf99eed703cdf..0ad8be77a74bc 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index f41874a1eec48..0758fabd39bfa 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -31,7 +31,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 443ac9890ac79..ca6becdefa95c 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 791fbda103820..75fce6929384b 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -52,7 +52,7 @@ pub mod pallet { Vec, ValueQuery, >; - + #[pallet::storage] #[pallet::getter(fn next_keys)] /// Keys of the next authority set. @@ -224,7 +224,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index d40fb93b901a0..496f29b947893 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -440,7 +440,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 6c1cc89cf1ed0..7ad75cf3dfff3 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -70,7 +70,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 07ec0f377ecfc..6c3aa3bfaf983 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -54,7 +54,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index a6a1a09d9cbfe..05d4af9d2fcd6 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -56,7 +56,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index caca7d78d0ff5..b8b38ca54976d 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -64,7 +64,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 0869ae68c7e09..a234276f5ffd7 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -82,7 +82,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 3a53ffd56ac1a..0b992414b9d6b 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -59,7 +59,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index a7039887db606..ef31b8e54cee6 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -986,7 +986,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 63e8f2171fd8c..db463f0a9c8b8 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -213,7 +213,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 8840e2b935d35..30b9cfbadb80a 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -199,7 +199,7 @@ pub fn witness() -> SolutionOrSnapshotSize { impl frame_system::Config for Runtime { type SS58Prefix = (); - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u64; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 8a1680633ef7b..c828b7728459d 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1123,7 +1123,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 7eef7f4909982..71632e2c9dcfd 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -36,7 +36,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/example-offchain-worker/src/tests.rs b/frame/example-offchain-worker/src/tests.rs index ee47aa5629fd9..139aa4b365344 100644 --- a/frame/example-offchain-worker/src/tests.rs +++ b/frame/example-offchain-worker/src/tests.rs @@ -60,7 +60,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/example-parallel/src/tests.rs b/frame/example-parallel/src/tests.rs index 56cb73ebb08bb..647364f184a82 100644 --- a/frame/example-parallel/src/tests.rs +++ b/frame/example-parallel/src/tests.rs @@ -44,7 +44,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Call = Call; type PalletInfo = PalletInfo; diff --git a/frame/example/src/tests.rs b/frame/example/src/tests.rs index c699a0bfad36c..f82674ee98383 100644 --- a/frame/example/src/tests.rs +++ b/frame/example/src/tests.rs @@ -54,7 +54,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index c5f39e14f5fc1..5e1be1591aa90 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -694,7 +694,7 @@ mod tests { }; } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index fb888515496b1..3048411dff964 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index ebe5996c9dab5..fa92fca43bf2f 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -75,7 +75,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 262b3211b6d1b..41115148eec82 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -49,7 +49,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 4bc976476a676..be4c178f2ffca 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -118,7 +118,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index bd9e9c33af25e..d1f0f6b650d47 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -46,7 +46,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 07593c17e5086..5e224ce4ba64e 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -56,7 +56,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 62c9e5eae1a65..368b5f92b7cc0 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -491,7 +491,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 3c8a5d284566f..05892037b79ab 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -49,7 +49,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Call = Call; type Index = u64; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 1e0ef90e0a3ac..2e4d32eaa077b 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -275,7 +275,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index 3f4f894cdf7e3..341f32f176a50 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type DbWeight = (); type BlockWeights = (); type BlockLength = (); diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index cd72780ec5ad2..e5637c22ba266 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index fff1973e334ea..de07a498899f0 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -85,7 +85,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND); } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = RocksDbWeight; diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index eaefa9ac86c3b..7b0c1218c6fb2 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -195,7 +195,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = BlockLength; type DbWeight = (); diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 6a0abab2bd12b..7b519904f848d 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 44a28234a2a82..da5c4274290e2 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -57,7 +57,7 @@ ord_parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 591e54f067bb5..fe6e6b8d333f9 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 3459ab73d6afe..bd606b68f0bf4 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -228,7 +228,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 5e156caa282eb..89c3912b4bbf5 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -69,7 +69,7 @@ ord_parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/staking/fuzzer/src/mock.rs b/frame/staking/fuzzer/src/mock.rs index 4ac1a10364e6c..c6fe48fdb2f70 100644 --- a/frame/staking/fuzzer/src/mock.rs +++ b/frame/staking/fuzzer/src/mock.rs @@ -42,7 +42,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index e0079cc3f375a..dfaef154ab9fd 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -128,7 +128,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = RocksDbWeight; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index ee290a31d5a41..7d04999ca4c9a 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2800,7 +2800,7 @@ mod tests { type Origin = OuterOrigin; type AccountId = u32; type Call = OuterCall; - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockNumber = u32; type PalletInfo = Self; type DbWeight = (); diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index e8ce07528c8a0..92096b24ae8fc 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -45,6 +45,7 @@ pub use validation::{ mod filter; pub use filter::{ Filter, FilterStack, FilterStackGuard, ClearFilterGuard, InstanceFilter, IntegrityTest, + AllowAllFilter, DenyAllFilter, }; mod misc; diff --git a/frame/support/src/traits/filter.rs b/frame/support/src/traits/filter.rs index f884a8ece72e5..b2f5638fdb2cf 100644 --- a/frame/support/src/traits/filter.rs +++ b/frame/support/src/traits/filter.rs @@ -25,10 +25,18 @@ pub trait Filter { fn filter(_: &T) -> bool; } -impl Filter for () { +pub enum AllowAllFilter {} + +pub enum DenyAllFilter {} + +impl Filter for AllowAllFilter { fn filter(_: &T) -> bool { true } } +impl Filter for DenyAllFilter { + fn filter(_: &T) -> bool { false } +} + /// Trait to add a constraint onto the filter. pub trait FilterStack: Filter { /// The type used to archive the stack. diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 98d0c45d2425a..8197514727c93 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -225,7 +225,7 @@ pub type BlockNumber = u64; pub type Index = u64; impl system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 4525e8c1a1fe2..bc0333c386b1e 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -158,7 +158,7 @@ pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index f204de69b84bf..bcb1774fa38fa 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -448,7 +448,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index db01d15e5daa9..3cc3092b775a5 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -203,7 +203,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 63e71c8bf255c..76187f0ebacff 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -198,7 +198,7 @@ impl frame_system::Config for Runtime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index ccac97100a4be..d26f0d0ba4385 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -250,7 +250,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_version.rs b/frame/support/test/tests/pallet_version.rs index 5c33d45aea644..ba4c1d8a1a5b0 100644 --- a/frame/support/test/tests/pallet_version.rs +++ b/frame/support/test/tests/pallet_version.rs @@ -144,7 +144,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 6f35b122f6399..cdf57b1fdbb94 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -126,7 +126,7 @@ mod tests { } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type Origin = Origin; type Index = u64; type BlockNumber = u64; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 47980a88164e5..3302ac74cca93 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -67,7 +67,7 @@ frame_support::parameter_types! { ); } impl system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = BlockLength; type DbWeight = (); diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 253945a598bdc..2b0d3d57e2a21 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -39,7 +39,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 0f53532eb8f6b..99a1b5c2dd02f 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -85,7 +85,7 @@ impl OnKilledAccount for RecordKilled { } impl Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index f7dd7378d8ab5..2b5ac09e54cdf 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -326,7 +326,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 6063f0954bd8a..01686db1f0b77 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -58,7 +58,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 416439e7f200c..797288e81512b 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -715,7 +715,7 @@ mod tests { } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 03dacf8a98e89..370b63084403f 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -51,7 +51,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index e4b6f2d664fc2..c9bcfc3ea8a93 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -54,7 +54,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 336a262358b24..d8f13f508ff87 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 6fdd44aed140e..5d2cce37d8ea9 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { impl frame_system::Config for Test { type AccountData = pallet_balances::AccountData; type AccountId = u64; - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockHashCount = BlockHashCount; type BlockLength = (); type BlockNumber = u64; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 084f1338cd261..81efd2e43bc71 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -488,7 +488,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = (); + type BaseCallFilter = frame_support::traits::AllowAllFilter; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; From eaeab0cb3dc30168c6097686d5d2bee47c42df2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 6 Jul 2021 09:11:07 +0200 Subject: [PATCH 5/9] Add rust doc --- frame/support/src/traits/filter.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/support/src/traits/filter.rs b/frame/support/src/traits/filter.rs index b2f5638fdb2cf..3ef65f8adaa85 100644 --- a/frame/support/src/traits/filter.rs +++ b/frame/support/src/traits/filter.rs @@ -25,8 +25,10 @@ pub trait Filter { fn filter(_: &T) -> bool; } +/// A [`Filter`] that allows any value. pub enum AllowAllFilter {} +/// A [`Filter`] that denies any value. pub enum DenyAllFilter {} impl Filter for AllowAllFilter { From 8b1ba6662cc2964e70269ba7eb55243e7d2ccbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 6 Jul 2021 12:49:51 +0200 Subject: [PATCH 6/9] Fixup for `()` removal --- frame/support/test/tests/instance.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index d952fd82eb0df..45d464c6c7c44 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -255,7 +255,7 @@ pub type BlockNumber = u64; pub type Index = u64; impl system::Config for Runtime { - type BaseCallFilter= (); + type BaseCallFilter= frame_support::traits::AllowAllFilter; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; From 05ead101321ecd3a0f45693dfcb8f9d5b531e11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 8 Jul 2021 09:25:47 +0200 Subject: [PATCH 7/9] Fix lowest gas calculation --- frame/contracts/src/gas.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index 13695b46a1daa..64f410c4cef2b 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -80,7 +80,7 @@ pub struct GasMeter { /// Amount of gas left from initial gas limit. Can reach zero. gas_left: Weight, /// Due to `adjust_gas` and `nested` the `gas_left` can temporarily dip below its final value. - gas_left_lowest: Option, + gas_left_lowest: Weight, _phantom: PhantomData, #[cfg(test)] tokens: Vec, @@ -94,7 +94,7 @@ where GasMeter { gas_limit, gas_left: gas_limit, - gas_left_lowest: None, + gas_left_lowest: gas_limit, _phantom: PhantomData, #[cfg(test)] tokens: Vec::new(), @@ -127,13 +127,16 @@ where pub fn absorb_nested(&mut self, nested: Self) { if self.gas_left == 0 { // All of the remaining gas was inherited by the nested gas meter. When absorbing - // we can also safely inherit the lowest gas that the nested gas meter experienced. - self.gas_left_lowest = Some(nested.gas_left_lowest().min(self.gas_left_lowest())) + // we can therefore safely inherit the lowest gas that the nested gas meter experienced + // as long as it is lower than the lowest gas that was experienced by the parent. + // We cannot call `self.gas_left_lowest()` here because in the state that this + // code is run the parent gas meter has `0` gas left. + self.gas_left_lowest = nested.gas_left_lowest().min(self.gas_left_lowest); } else { // The nested gas meter was created with a fixed amount that did not consume all of the // parents (self) gas. The lowest gas that self will experience is when the nested - // gas was pre charged. - self.gas_left_lowest = Some(self.gas_left_lowest()); + // gas was pre charged with the fixed amount. + self.gas_left_lowest = self.gas_left_lowest(); } self.gas_left += nested.gas_left; } @@ -176,7 +179,7 @@ where /// This is when a maximum a priori amount was charged and then should be partially /// refunded to match the actual amount. pub fn adjust_gas>(&mut self, charged_amount: ChargedAmount, token: Tok) { - self.gas_left_lowest = Some(self.gas_left_lowest()); + self.gas_left_lowest = self.gas_left_lowest(); let adjustment = charged_amount.0.saturating_sub(token.weight()); self.gas_left = self.gas_left.saturating_add(adjustment).min(self.gas_limit); } @@ -219,7 +222,7 @@ where } fn gas_left_lowest(&self) -> Weight { - self.gas_left_lowest.map(|d| d.min(self.gas_left)).unwrap_or(self.gas_left) + self.gas_left_lowest.min(self.gas_left) } #[cfg(test)] From 0d0a4d7ac533ba6da960f20e98eeeb73b7ebdc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 8 Jul 2021 10:23:41 +0200 Subject: [PATCH 8/9] Rename AllowAllFilter and DenyAllFilter --- bin/node-template/pallets/template/src/mock.rs | 2 +- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/src/lib.rs | 6 +++--- docs/Upgrading-2.0-to-3.0.md | 2 +- frame/assets/src/mock.rs | 2 +- frame/atomic-swap/src/tests.rs | 2 +- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 2 +- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/balances/src/tests_composite.rs | 2 +- frame/balances/src/tests_local.rs | 2 +- frame/balances/src/tests_reentrancy.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/bounties/src/tests.rs | 2 +- frame/collective/src/lib.rs | 2 +- frame/contracts/src/tests.rs | 2 +- frame/election-provider-multi-phase/src/mock.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/elections/src/mock.rs | 2 +- frame/example-offchain-worker/src/tests.rs | 2 +- frame/example-parallel/src/tests.rs | 2 +- frame/example/src/tests.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/gilt/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/identity/src/tests.rs | 2 +- frame/im-online/src/mock.rs | 2 +- frame/indices/src/mock.rs | 2 +- frame/lottery/src/mock.rs | 2 +- frame/membership/src/lib.rs | 2 +- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/nicks/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/offences/src/mock.rs | 2 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/recovery/src/mock.rs | 2 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/staking/fuzzer/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/support/src/dispatch.rs | 2 +- frame/support/src/traits.rs | 2 +- frame/support/src/traits/filter.rs | 8 ++++---- frame/support/test/tests/construct_runtime.rs | 2 +- frame/support/test/tests/instance.rs | 2 +- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/pallet.rs | 2 +- frame/support/test/tests/pallet_compatibility.rs | 2 +- frame/support/test/tests/pallet_compatibility_instance.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 2 +- frame/support/test/tests/pallet_version.rs | 2 +- .../support/test/tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/system/benches/bench.rs | 2 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/mock.rs | 2 +- frame/timestamp/src/lib.rs | 2 +- frame/tips/src/tests.rs | 2 +- frame/transaction-payment/src/lib.rs | 2 +- frame/transaction-storage/src/mock.rs | 2 +- frame/treasury/src/tests.rs | 2 +- frame/uniques/src/mock.rs | 2 +- frame/vesting/src/mock.rs | 2 +- test-utils/runtime/src/lib.rs | 2 +- 67 files changed, 72 insertions(+), 72 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index ab01c94f6df6d..9bea61df22edb 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -27,7 +27,7 @@ parameter_types! { } impl system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index b439e9870ce62..c92eb8a1aadf8 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -146,7 +146,7 @@ parameter_types! { impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 2953a3fb615b2..6dae1e946c4a4 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -33,7 +33,7 @@ use frame_support::{ }, traits::{ Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, LockIdentifier, - U128CurrencyToVote, AllowAllFilter, DenyAllFilter, + U128CurrencyToVote, AllowAll, DenyAll, }, }; use frame_system::{ @@ -193,7 +193,7 @@ parameter_types! { const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); impl frame_system::Config for Runtime { - type BaseCallFilter = AllowAllFilter; + type BaseCallFilter = AllowAll; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; @@ -833,7 +833,7 @@ impl pallet_contracts::Config for Runtime { /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. - type CallFilter = DenyAllFilter; + type CallFilter = DenyAll; type RentPayment = (); type SignedClaimHandicap = SignedClaimHandicap; type TombstoneDeposit = TombstoneDeposit; diff --git a/docs/Upgrading-2.0-to-3.0.md b/docs/Upgrading-2.0-to-3.0.md index 039c3059caea6..914b7b788d2ea 100644 --- a/docs/Upgrading-2.0-to-3.0.md +++ b/docs/Upgrading-2.0-to-3.0.md @@ -143,7 +143,7 @@ And update the overall definition for weights on frame and a few related types a +const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); + +impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type DbWeight = RocksDbWeight; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 0ad8be77a74bc..429548a5d1c28 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 0758fabd39bfa..11e74be9b4e7f 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -31,7 +31,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index ca6becdefa95c..aff6b76a7a49f 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 9246e494a3564..1f480926209ec 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -212,7 +212,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 496f29b947893..de60d1a4caacd 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -440,7 +440,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 7ad75cf3dfff3..ea54e9f7cea83 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -70,7 +70,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 6c3aa3bfaf983..1d90b3e70b924 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -54,7 +54,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 05d4af9d2fcd6..36351252b445c 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -56,7 +56,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index b8b38ca54976d..2a3a60dfde842 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -64,7 +64,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index a234276f5ffd7..646609c7c1e16 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -82,7 +82,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 0b992414b9d6b..54973bf9b2fda 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -59,7 +59,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index ef31b8e54cee6..c14ef9df64fee 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -986,7 +986,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index db463f0a9c8b8..ea5fbccb0f2a1 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -213,7 +213,7 @@ parameter_types! { pub static ExistentialDeposit: u64 = 0; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 30b9cfbadb80a..16be149c8ac55 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -199,7 +199,7 @@ pub fn witness() -> SolutionOrSnapshotSize { impl frame_system::Config for Runtime { type SS58Prefix = (); - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u64; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index c828b7728459d..db4af14328bf1 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1123,7 +1123,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 71632e2c9dcfd..4df6da829a18e 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -36,7 +36,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/example-offchain-worker/src/tests.rs b/frame/example-offchain-worker/src/tests.rs index 139aa4b365344..7d16e59490342 100644 --- a/frame/example-offchain-worker/src/tests.rs +++ b/frame/example-offchain-worker/src/tests.rs @@ -60,7 +60,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/example-parallel/src/tests.rs b/frame/example-parallel/src/tests.rs index 647364f184a82..395290c0bf6e7 100644 --- a/frame/example-parallel/src/tests.rs +++ b/frame/example-parallel/src/tests.rs @@ -44,7 +44,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Call = Call; type PalletInfo = PalletInfo; diff --git a/frame/example/src/tests.rs b/frame/example/src/tests.rs index f82674ee98383..68a9237921805 100644 --- a/frame/example/src/tests.rs +++ b/frame/example/src/tests.rs @@ -54,7 +54,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 5e1be1591aa90..719a94e6fb1b3 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -694,7 +694,7 @@ mod tests { }; } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index 3048411dff964..aeff70610d4bb 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index fa92fca43bf2f..768564c30105f 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -75,7 +75,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index e56475ab8509a..7a8bb4fa6d92e 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -50,7 +50,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index be4c178f2ffca..3d7d6d73cd83a 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -118,7 +118,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index d1f0f6b650d47..46c1d814acb6b 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -46,7 +46,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 5e224ce4ba64e..885e81bb32ea3 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -56,7 +56,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 368b5f92b7cc0..0d95af4e6f4a4 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -491,7 +491,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 05892037b79ab..0d89021ae9668 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -49,7 +49,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Call = Call; type Index = u64; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 2e4d32eaa077b..afdcca7e91a5c 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -275,7 +275,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index 341f32f176a50..e952ed900d4be 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type DbWeight = (); type BlockWeights = (); type BlockLength = (); diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index e5637c22ba266..4e7a63c58a40b 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index de07a498899f0..5818ae71687b2 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -85,7 +85,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND); } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = RocksDbWeight; diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 7b0c1218c6fb2..1ff7d4382da14 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -195,7 +195,7 @@ mod tests { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = BlockLength; type DbWeight = (); diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 7b519904f848d..9139cc12ce54a 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index da5c4274290e2..30dc48dd19d0a 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -57,7 +57,7 @@ ord_parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index fe6e6b8d333f9..a3f9b6b447c38 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index bd606b68f0bf4..1462b2326777e 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -228,7 +228,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 89c3912b4bbf5..18cdda678da6f 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -69,7 +69,7 @@ ord_parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/staking/fuzzer/src/mock.rs b/frame/staking/fuzzer/src/mock.rs index c6fe48fdb2f70..98181ca2694d2 100644 --- a/frame/staking/fuzzer/src/mock.rs +++ b/frame/staking/fuzzer/src/mock.rs @@ -42,7 +42,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index dfaef154ab9fd..3242a40ccd45e 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -128,7 +128,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = RocksDbWeight; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 7d04999ca4c9a..f4737dd56bb40 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2800,7 +2800,7 @@ mod tests { type Origin = OuterOrigin; type AccountId = u32; type Call = OuterCall; - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockNumber = u32; type PalletInfo = Self; type DbWeight = (); diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 92096b24ae8fc..ec47331285ef8 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -45,7 +45,7 @@ pub use validation::{ mod filter; pub use filter::{ Filter, FilterStack, FilterStackGuard, ClearFilterGuard, InstanceFilter, IntegrityTest, - AllowAllFilter, DenyAllFilter, + AllowAll, DenyAll, }; mod misc; diff --git a/frame/support/src/traits/filter.rs b/frame/support/src/traits/filter.rs index 3ef65f8adaa85..4b70fa177e5ca 100644 --- a/frame/support/src/traits/filter.rs +++ b/frame/support/src/traits/filter.rs @@ -26,16 +26,16 @@ pub trait Filter { } /// A [`Filter`] that allows any value. -pub enum AllowAllFilter {} +pub enum AllowAll {} /// A [`Filter`] that denies any value. -pub enum DenyAllFilter {} +pub enum DenyAll {} -impl Filter for AllowAllFilter { +impl Filter for AllowAll { fn filter(_: &T) -> bool { true } } -impl Filter for DenyAllFilter { +impl Filter for DenyAll { fn filter(_: &T) -> bool { false } } diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 8197514727c93..dde7f6d53f8ed 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -225,7 +225,7 @@ pub type BlockNumber = u64; pub type Index = u64; impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 45d464c6c7c44..7d18a8368edab 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -255,7 +255,7 @@ pub type BlockNumber = u64; pub type Index = u64; impl system::Config for Runtime { - type BaseCallFilter= frame_support::traits::AllowAllFilter; + type BaseCallFilter= frame_support::traits::AllowAll; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index bc0333c386b1e..78a79055a389d 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -158,7 +158,7 @@ pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Hash = H256; type Origin = Origin; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 92644b22b5780..59ebd2e71e599 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -448,7 +448,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 3cc3092b775a5..3c055b9f45aef 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -203,7 +203,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 76187f0ebacff..fd5d5fb7fdbbd 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -198,7 +198,7 @@ impl frame_system::Config for Runtime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index d26f0d0ba4385..11f9497b7bec2 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -250,7 +250,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u32; diff --git a/frame/support/test/tests/pallet_version.rs b/frame/support/test/tests/pallet_version.rs index ba4c1d8a1a5b0..ed0bf52a0346f 100644 --- a/frame/support/test/tests/pallet_version.rs +++ b/frame/support/test/tests/pallet_version.rs @@ -144,7 +144,7 @@ frame_support::parameter_types!( ); impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index cdf57b1fdbb94..665bbc2b5c513 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -126,7 +126,7 @@ mod tests { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type Origin = Origin; type Index = u64; type BlockNumber = u64; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 3302ac74cca93..02ea48bdde032 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -67,7 +67,7 @@ frame_support::parameter_types! { ); } impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = BlockLength; type DbWeight = (); diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 2b0d3d57e2a21..b375c9fcb5093 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -39,7 +39,7 @@ frame_support::construct_runtime!( ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 99a1b5c2dd02f..e9b6fb7d968ec 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -85,7 +85,7 @@ impl OnKilledAccount for RecordKilled { } impl Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 2b5ac09e54cdf..e9b6388340b2f 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -326,7 +326,7 @@ mod tests { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 01686db1f0b77..cb58ba6aabd6d 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -58,7 +58,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 797288e81512b..25fce83e69930 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -715,7 +715,7 @@ mod tests { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 370b63084403f..344d7b7369533 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -51,7 +51,7 @@ parameter_types! { } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index c9bcfc3ea8a93..dbd5b22741ba5 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -54,7 +54,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(1024); } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type DbWeight = (); diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index d8f13f508ff87..254acd6c419cf 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -43,7 +43,7 @@ parameter_types! { pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = (); type BlockLength = (); type Origin = Origin; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 5d2cce37d8ea9..45bfb788ba728 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -48,7 +48,7 @@ parameter_types! { impl frame_system::Config for Test { type AccountData = pallet_balances::AccountData; type AccountId = u64; - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockHashCount = BlockHashCount; type BlockLength = (); type BlockNumber = u64; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 81efd2e43bc71..a85f1cb85bc53 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -488,7 +488,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::AllowAllFilter; + type BaseCallFilter = frame_support::traits::AllowAll; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; From c0ee73514556a72ef639ef83530248a81899b190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 12 Jul 2021 10:01:36 +0200 Subject: [PATCH 9/9] Updated changelog --- frame/contracts/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frame/contracts/CHANGELOG.md b/frame/contracts/CHANGELOG.md index 03945d7b2e346..494c041d1bc84 100644 --- a/frame/contracts/CHANGELOG.md +++ b/frame/contracts/CHANGELOG.md @@ -20,6 +20,9 @@ In other words: Upgrading this pallet will not break pre-existing contracts. ### Added +- Allow contracts to dispatch calls into the runtime (**unstable**) +[#9276](https://github.com/paritytech/substrate/pull/9276) + - New **unstable** version of `seal_call` that offers more features. [#8909](https://github.com/paritytech/substrate/pull/8909)