diff --git a/auction/Cargo.toml b/auction/Cargo.toml index 4acb9c171bc73a113c4f34797c75e31ab0b22c0f..49aa08a88c6e21e5cadd59897f4468ef10eaf4dd 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/auction/src/mock.rs b/auction/src/mock.rs index 5ea015b2faac29422bf687de5c79fa783c7f3170..b4b44ca55e72b3b8cc86b10667bfb1723e44a4e3 100644 --- a/auction/src/mock.rs +++ b/auction/src/mock.rs @@ -63,6 +63,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub struct Handler; diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 94e45c6b2e24c878aac678849386870c79212b5d..bc46be4c14ed7acbaff2e9c3968500eeb687ca6b 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 [features] diff --git a/authority/src/lib.rs b/authority/src/lib.rs index f5807b3178d4cbbc60508693d1c5cf4009138137..2b0ecbdffdc1ce43d83cce89dceab83251c81fc3 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -5,13 +5,11 @@ #![allow(clippy::borrowed_box)] use frame_support::{ - decl_error, - decl_module, + decl_error, decl_module, dispatch::PostDispatchInfo, ensure, traits::{EnsureOrigin, Get}, - weights::{FunctionOf, GetDispatchInfo, Pays}, - //weights::{GetDispatchInfo}, + weights::GetDispatchInfo, Parameter, }; use frame_system::{self as system}; @@ -88,21 +86,13 @@ decl_module! { const MinimumDelay: T::BlockNumber = T::MinimumDelay::get(); - #[weight = FunctionOf( - |args: (&Box<CallOf<T>>,)| args.0.get_dispatch_info().weight + 10_000, - |args: (&Box<CallOf<T>>,)| args.0.get_dispatch_info().class, - Pays::Yes, - )] + #[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)] pub fn dispatch_root(origin, call: Box<CallOf<T>>) { T::RootDispatchOrigin::try_origin(origin).map_err(|_| BadOrigin)?; call.dispatch(frame_system::RawOrigin::Root.into()).map(|_| ()).map_err(|e| e.error)?; } - #[weight = FunctionOf( - |args: (&Box<CallOf<T>>, &DelayedDispatchTime<T::BlockNumber>)| args.0.get_dispatch_info().weight + 10_000, - |args: (&Box<CallOf<T>>, &DelayedDispatchTime<T::BlockNumber>)| args.0.get_dispatch_info().class, - Pays::Yes, - )] + #[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)] pub fn schedule_dispatch_root(origin, call: Box<CallOf<T>>, when: DelayedDispatchTime<T::BlockNumber>) { let now = <frame_system::Module<T>>::block_number(); let when_block = match when { @@ -125,11 +115,7 @@ decl_module! { let _ = T::Scheduler::schedule(frame_system::RawOrigin::Root.into(), *call, when); } - #[weight = FunctionOf( - |args: (&Box<CallOf<T>>, &DelayedDispatchTime<T::BlockNumber>)| args.0.get_dispatch_info().weight + 10_000, - |args: (&Box<CallOf<T>>, &DelayedDispatchTime<T::BlockNumber>)| args.0.get_dispatch_info().class, - Pays::Yes, - )] + #[weight = (call.get_dispatch_info().weight + 10_000, call.get_dispatch_info().class)] pub fn schedule_dispatch_delayed(origin, call: Box<CallOf<T>>, when: DelayedDispatchTime<T::BlockNumber>) { T::DelayedDispatchOrigin::try_origin(origin.clone()).map_err(|_| BadOrigin)?; diff --git a/authority/src/mock.rs b/authority/src/mock.rs index 7486f1aee7a74dcbcfee2eabe6b9b732e832e0e8..fa050371b142732a814d67a740653b0188739819 100644 --- a/authority/src/mock.rs +++ b/authority/src/mock.rs @@ -28,7 +28,7 @@ impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; - type Call = (); + type Call = Call; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; @@ -48,6 +48,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub struct MockScheduler; diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index 93f0bfe14a043d9ce8cf3e84aa850136a2edab21..2e2bb0de3786095b0fb531802353c8323f685bdb 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -10,14 +10,14 @@ edition = "2018" [dependencies] paste = "0.1.16" codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-api = { version = "2.0.0-rc3", default-features = false } -sp-runtime-interface = { version = "2.0.0-rc3", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } -frame-benchmarking = { version = "2.0.0-rc3", default-features = false } +sp-api = { version = "2.0.0-rc4", default-features = false } +sp-runtime-interface = { version = "2.0.0-rc4", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } +frame-benchmarking = { version = "2.0.0-rc4", default-features = false } [features] default = [ "std" ] diff --git a/benchmarking/src/lib.rs b/benchmarking/src/lib.rs index b0c06c657ccaa2947496f3562b37c034261fe4a3..1c7b554288c9f14f25e435d1d40e67f47a76732b 100644 --- a/benchmarking/src/lib.rs +++ b/benchmarking/src/lib.rs @@ -11,6 +11,7 @@ pub use frame_benchmarking::{ benchmarking, BenchmarkBatch, BenchmarkParameter, BenchmarkResults, Benchmarking, BenchmarkingSetup, BenchmarkingSetupInstance, }; +pub use frame_support; pub use paste; #[doc(hidden)] pub use sp_io::storage::root as storage_root; @@ -183,6 +184,7 @@ macro_rules! runtime_benchmarks { } } +/// Same as [`benchmarks`] but for instantiable module. #[macro_export] macro_rules! runtime_benchmarks_instance { ( @@ -206,7 +208,7 @@ macro_rules! runtime_benchmarks_instance { } #[macro_export] -#[allow(missing_docs)] +#[doc(hidden)] macro_rules! benchmarks_iter { // mutation arm: ( @@ -248,7 +250,9 @@ macro_rules! benchmarks_iter { { $( $common )* } ( $( $names )* ) $name { $( $code )* }: { - <$pallet::Call<$runtime> as $crate::Dispatchable>::dispatch($pallet::Call::<$runtime>::$dispatch($($arg),*), $origin.into())?; + < + $pallet::Call<$runtime> as $crate::frame_support::traits::UnfilteredDispatchable + >::dispatch_bypass_filter($pallet::Call::<$runtime>::$dispatch($($arg),*), $origin.into())?; } verify $postcode $( $rest )* @@ -272,7 +276,9 @@ macro_rules! benchmarks_iter { { $( $common )* } ( $( $names )* ) $name { $( $code )* }: { - <$pallet::Call<$runtime, $instance> as $crate::Dispatchable>::dispatch($pallet::Call::<$runtime, $instance>::$dispatch($($arg),*), $origin.into())?; + < + $pallet::Call<$runtime, $instance> as $crate::frame_support::traits::UnfilteredDispatchable + >::dispatch_bypass_filter($pallet::Call::<$runtime, $instance>::$dispatch($($arg),*), $origin.into())?; } verify $postcode $( $rest )* @@ -300,6 +306,10 @@ macro_rules! benchmarks_iter { { $( $code )* } $postcode } + + #[cfg(test)] + $crate::impl_benchmark_test!( $instance $runtime $pallet $name); + $crate::benchmarks_iter!( $instance $runtime @@ -313,8 +323,6 @@ macro_rules! benchmarks_iter { ( $instance:ident $runtime:ident $pallet:ident { $( $common:tt )* } ( $( $names:ident )* ) ) => { $crate::selected_benchmark!( $instance $runtime $pallet $( $names ),* ); $crate::impl_benchmark!( $instance $runtime $pallet $( $names ),* ); - #[cfg(test)] - $crate::impl_benchmark_tests!( $instance $runtime $pallet $( $names ),* ); }; // add verify block to _() format ( @@ -382,7 +390,7 @@ macro_rules! benchmarks_iter { } #[macro_export] -#[allow(missing_docs)] +#[doc(hidden)] macro_rules! benchmark_backend { // parsing arms ($instance:ident $runtime:ident $pallet:ident $name:ident { @@ -536,7 +544,9 @@ macro_rules! benchmark_backend { )* $( // Prepare instance - let $param = components.iter().find(|&c| c.0 == $crate::BenchmarkParameter::$param).unwrap().1; + let $param = components.iter() + .find(|&c| c.0 == $crate::BenchmarkParameter::$param) + .unwrap().1; )* $( let $pre_id : $pre_ty = $pre_ex; @@ -555,7 +565,9 @@ macro_rules! benchmark_backend { )* $( // Prepare instance - let $param = components.iter().find(|&c| c.0 == $crate::BenchmarkParameter::$param).unwrap().1; + let $param = components.iter() + .find(|&c| c.0 == $crate::BenchmarkParameter::$param) + .unwrap().1; )* $( let $pre_id : $pre_ty = $pre_ex; @@ -594,7 +606,9 @@ macro_rules! benchmark_backend { )* $( // Prepare instance - let $param = components.iter().find(|&c| c.0 == $crate::BenchmarkParameter::$param).unwrap().1; + let $param = components.iter() + .find(|&c| c.0 == $crate::BenchmarkParameter::$param) + .unwrap().1; )* $( let $pre_id : $pre_ty = $pre_ex; @@ -613,7 +627,9 @@ macro_rules! benchmark_backend { )* $( // Prepare instance - let $param = components.iter().find(|&c| c.0 == $crate::BenchmarkParameter::$param).unwrap().1; + let $param = components.iter() + .find(|&c| c.0 == $crate::BenchmarkParameter::$param) + .unwrap().1; )* $( let $pre_id : $pre_ty = $pre_ex; @@ -627,21 +643,22 @@ macro_rules! benchmark_backend { } } -/// Creates a `SelectedBenchmark` enum implementing `BenchmarkingSetup`. -/// -/// Every variant must implement [`BenchmarkingSetup`]. -/// -/// ```nocompile -/// -/// struct Transfer; -/// impl BenchmarkingSetup for Transfer { ... } -/// -/// struct SetBalance; -/// impl BenchmarkingSetup for SetBalance { ... } -/// -/// selected_benchmark!(Transfer, SetBalance); -/// ``` +// Creates a `SelectedBenchmark` enum implementing `BenchmarkingSetup`. +// +// Every variant must implement [`BenchmarkingSetup`]. +// +// ```nocompile +// +// struct Transfer; +// impl BenchmarkingSetup for Transfer { ... } +// +// struct SetBalance; +// impl BenchmarkingSetup for SetBalance { ... } +// +// selected_benchmark!(Transfer, SetBalance); +// ``` #[macro_export] +#[doc(hidden)] macro_rules! selected_benchmark { ( NO_INSTANCE $runtime:ident $pallet:ident $( $bench:ident ),* @@ -714,12 +731,15 @@ macro_rules! selected_benchmark { } #[macro_export] +#[doc(hidden)] macro_rules! impl_benchmark { ( NO_INSTANCE $runtime:ident $pallet:ident $( $name:ident ),* ) => { + #[cfg(feature="runtime-benchmarks")] pub struct Benchmark; + #[cfg(feature="runtime-benchmarks")] impl $crate::Benchmarking<$crate::BenchmarkResults> for Benchmark { fn benchmarks() -> Vec<&'static [u8]> { vec![ $( stringify!($name).as_ref() ),* ] @@ -731,6 +751,7 @@ macro_rules! impl_benchmark { highest_range_values: &[u32], steps: &[u32], repeat: u32, + whitelist: &[Vec<u8>] ) -> Result<Vec<$crate::BenchmarkResults>, &'static str> { // Map the input to the selected benchmark. let extrinsic = sp_std::str::from_utf8(extrinsic) @@ -740,6 +761,8 @@ macro_rules! impl_benchmark { _ => return Err("Could not find extrinsic."), }; + $crate::benchmarking::set_whitelist(whitelist.to_vec()); + // Warm up the DB $crate::benchmarking::commit_db(); $crate::benchmarking::wipe_db(); @@ -786,8 +809,11 @@ macro_rules! impl_benchmark { // Run the benchmark `repeat` times. for _ in 0..repeat { - // Set up the externalities environment for the setup we want to benchmark. - let closure_to_benchmark = <SelectedBenchmark as $crate::BenchmarkingSetup<$runtime>>::instance(&selected_benchmark, &c)?; + // Set up the externalities environment for the setup we want to + // benchmark. + let closure_to_benchmark = < + SelectedBenchmark as $crate::BenchmarkingSetup<$runtime> + >::instance(&selected_benchmark, &c)?; // Set the block number to at least 1 so events are deposited. if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { @@ -798,13 +824,29 @@ macro_rules! impl_benchmark { // This will enable worst case scenario for reading from the database. $crate::benchmarking::commit_db(); + $crate::benchmarking::reset_read_write_count(); + // Time the extrinsic logic. - frame_support::debug::trace!(target: "benchmark", "Start Benchmark: {:?} {:?}", name, component_value); + frame_support::debug::trace!( + target: "benchmark", + "Start Benchmark: {:?} {:?}", name, component_value + ); + let start_extrinsic = $crate::benchmarking::current_time(); closure_to_benchmark()?; let finish_extrinsic = $crate::benchmarking::current_time(); let elapsed_extrinsic = finish_extrinsic - start_extrinsic; - frame_support::debug::trace!(target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic); + + $crate::benchmarking::commit_db(); + frame_support::debug::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = $crate::benchmarking::read_write_count(); + frame_support::debug::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); @@ -812,7 +854,15 @@ macro_rules! impl_benchmark { let finish_storage_root = $crate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; - results.push((c.clone(), elapsed_extrinsic, elapsed_storage_root)); + results.push($crate::BenchmarkResults { + components: c.clone(), + extrinsic_time: elapsed_extrinsic, + storage_root_time: elapsed_storage_root, + reads: read_write_count.0, + repeat_reads: read_write_count.1, + writes: read_write_count.2, + repeat_writes: read_write_count.3, + }); // Wipe the DB back to the genesis state. $crate::benchmarking::wipe_db(); @@ -826,8 +876,10 @@ macro_rules! impl_benchmark { ( $instance:ident $runtime:ident $pallet:ident $( $name:ident ),* ) => { + #[cfg(feature="runtime-benchmarks")] pub struct Benchmark; + #[cfg(feature="runtime-benchmarks")] impl $crate::Benchmarking<$crate::BenchmarkResults> for Benchmark { fn benchmarks() -> Vec<&'static [u8]> { vec![ $( stringify!($name).as_ref() ),* ] @@ -839,6 +891,7 @@ macro_rules! impl_benchmark { highest_range_values: &[u32], steps: &[u32], repeat: u32, + whitelist: &[Vec<u8>] ) -> Result<Vec<$crate::BenchmarkResults>, &'static str> { // Map the input to the selected benchmark. let extrinsic = sp_std::str::from_utf8(extrinsic) @@ -848,11 +901,15 @@ macro_rules! impl_benchmark { _ => return Err("Could not find extrinsic."), }; + $crate::benchmarking::set_whitelist(whitelist.to_vec()); + // Warm up the DB $crate::benchmarking::commit_db(); $crate::benchmarking::wipe_db(); - let components = <SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance>>::components(&selected_benchmark); + let components = < + SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance> + >::components(&selected_benchmark); let mut results: Vec<$crate::BenchmarkResults> = Vec::new(); // Default number of steps for a component. @@ -895,7 +952,9 @@ macro_rules! impl_benchmark { // Run the benchmark `repeat` times. for _ in 0..repeat { // Set up the externalities environment for the setup we want to benchmark. - let closure_to_benchmark = <SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance>>::instance(&selected_benchmark, &c)?; + let closure_to_benchmark = < + SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance> + >::instance(&selected_benchmark, &c)?; // Set the block number to at least 1 so events are deposited. if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { @@ -906,13 +965,29 @@ macro_rules! impl_benchmark { // This will enable worst case scenario for reading from the database. $crate::benchmarking::commit_db(); + // Reset the read/write counter so we don't count operations in the setup process. + $crate::benchmarking::reset_read_write_count(); + // Time the extrinsic logic. - frame_support::debug::trace!(target: "benchmark", "Start Benchmark: {:?} {:?}", name, component_value); + frame_support::debug::trace!( + target: "benchmark", + "Start Benchmark: {:?} {:?}", name, component_value + ); let start_extrinsic = $crate::benchmarking::current_time(); closure_to_benchmark()?; let finish_extrinsic = $crate::benchmarking::current_time(); let elapsed_extrinsic = finish_extrinsic - start_extrinsic; - frame_support::debug::trace!(target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic); + + $crate::benchmarking::commit_db(); + frame_support::debug::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = $crate::benchmarking::read_write_count(); + frame_support::debug::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); @@ -920,7 +995,15 @@ macro_rules! impl_benchmark { let finish_storage_root = $crate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; - results.push((c.clone(), elapsed_extrinsic, elapsed_storage_root)); + results.push($crate::BenchmarkResults { + components: c.clone(), + extrinsic_time: elapsed_extrinsic, + storage_root_time: elapsed_storage_root, + reads: read_write_count.0, + repeat_reads: read_write_count.1, + writes: read_write_count.2, + repeat_writes: read_write_count.3, + }); // Wipe the DB back to the genesis state. $crate::benchmarking::wipe_db(); @@ -933,58 +1016,65 @@ macro_rules! impl_benchmark { } } -// This creates unit tests from the main benchmark macro. -// They run the benchmark using the `high` and `low` value for each component +// This creates a unit test for one benchmark of the main benchmark macro. +// It runs the benchmark using the `high` and `low` value for each component // and ensure that everything completes successfully. #[macro_export] -macro_rules! impl_benchmark_tests { +#[doc(hidden)] +macro_rules! impl_benchmark_test { ( NO_INSTANCE $runtime:ident $pallet:ident - $( $name:ident ),* + $name:ident ) => { - $( - $crate::paste::item! { - fn [<test_benchmark_ $name>] () -> Result<(), &'static str> - { - let selected_benchmark = SelectedBenchmark::$name; - let components = <SelectedBenchmark as $crate::BenchmarkingSetup<$runtime>>::components(&selected_benchmark); - - for (_, (name, low, high)) in components.iter().enumerate() { - // Test only the low and high value, assuming values in the middle won't break - for component_value in vec![low, high] { - // Select the max value for all the other components. - let c: Vec<($crate::BenchmarkParameter, u32)> = components.iter() - .enumerate() - .map(|(_, (n, _, h))| - if n == name { - (*n, *component_value) - } else { - (*n, *h) - } - ) - .collect(); - - // Set up the verification state - let closure_to_verify = <SelectedBenchmark as $crate::BenchmarkingSetup<$runtime>>::verify(&selected_benchmark, &c)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { - frame_system::Module::<$runtime>::set_block_number($crate::One::one()); - } + $crate::paste::item! { + fn [<test_benchmark_ $name>] () -> Result<(), &'static str> + { + let selected_benchmark = SelectedBenchmark::$name; + let components = < + SelectedBenchmark as $crate::BenchmarkingSetup<$runtime> + >::components(&selected_benchmark); + + assert!( + components.len() != 0, + "You need to add components to your benchmark!", + ); + for (_, (name, low, high)) in components.iter().enumerate() { + // Test only the low and high value, assuming values in the middle won't break + for component_value in vec![low, high] { + // Select the max value for all the other components. + let c: Vec<($crate::BenchmarkParameter, u32)> = components.iter() + .enumerate() + .map(|(_, (n, _, h))| + if n == name { + (*n, *component_value) + } else { + (*n, *h) + } + ) + .collect(); - // Run verification - closure_to_verify()?; + // Set up the verification state + let closure_to_verify = < + SelectedBenchmark as $crate::BenchmarkingSetup<$runtime> + >::verify(&selected_benchmark, &c)?; - // Reset the state - $crate::benchmarking::wipe_db(); + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { + frame_system::Module::<$runtime>::set_block_number($crate::One::one()); } + + // Run verification + closure_to_verify()?; + + // Reset the state + $crate::benchmarking::wipe_db(); } - Ok(()) } + Ok(()) } - )* + } }; ( $instance:ident @@ -992,47 +1082,49 @@ macro_rules! impl_benchmark_tests { $pallet:ident $( $name:ident ),* ) => { - $( - $crate::paste::item! { - fn [<test_benchmark_ $name>] () -> Result<(), &'static str> - { - let selected_benchmark = SelectedBenchmark::$name; - let components = <SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance>>::components(&selected_benchmark); - - for (_, (name, low, high)) in components.iter().enumerate() { - // Test only the low and high value, assuming values in the middle won't break - for component_value in vec![low, high] { - // Select the max value for all the other components. - let c: Vec<($crate::BenchmarkParameter, u32)> = components.iter() - .enumerate() - .map(|(_, (n, _, h))| - if n == name { - (*n, *component_value) - } else { - (*n, *h) - } - ) - .collect(); - - // Set up the verification state - let closure_to_verify = <SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance>>::verify(&selected_benchmark, &c)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { - frame_system::Module::<$runtime>::set_block_number($crate::One::one()); - } + $crate::paste::item! { + fn [<test_benchmark_ $name>] () -> Result<(), &'static str> + { + let selected_benchmark = SelectedBenchmark::$name; + let components = < + SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance> + >::components(&selected_benchmark); + + for (_, (name, low, high)) in components.iter().enumerate() { + // Test only the low and high value, assuming values in the middle won't break + for component_value in vec![low, high] { + // Select the max value for all the other components. + let c: Vec<($crate::BenchmarkParameter, u32)> = components.iter() + .enumerate() + .map(|(_, (n, _, h))| + if n == name { + (*n, *component_value) + } else { + (*n, *h) + } + ) + .collect(); - // Run verification - closure_to_verify()?; + // Set up the verification state + let closure_to_verify = < + SelectedBenchmark as $crate::BenchmarkingSetupInstance<$runtime, $instance> + >::verify(&selected_benchmark, &c)?; - // Reset the state - $crate::benchmarking::wipe_db(); + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) { + frame_system::Module::<$runtime>::set_block_number($crate::One::one()); } + + // Run verification + closure_to_verify()?; + + // Reset the state + $crate::benchmarking::wipe_db(); } - Ok(()) } + Ok(()) } - )* + } }; } @@ -1064,7 +1156,7 @@ macro_rules! impl_benchmark_tests { #[macro_export] macro_rules! add_benchmark { ( $params:ident, $batches:ident, $name:literal, $( $location:tt )* ) => ( - let (pallet, benchmark, lowest_range_values, highest_range_values, steps, repeat) = $params; + let (pallet, benchmark, lowest_range_values, highest_range_values, steps, repeat, whitelist) = $params; if &pallet[..] == &$name[..] || &pallet[..] == &b"*"[..] { if &pallet[..] == &b"*"[..] || &benchmark[..] == &b"*"[..] { for benchmark in $( $location )*::Benchmark::benchmarks().into_iter() { @@ -1075,6 +1167,7 @@ macro_rules! add_benchmark { &highest_range_values[..], &steps[..], repeat, + whitelist, )?, pallet: $name.to_vec(), benchmark: benchmark.to_vec(), @@ -1088,6 +1181,7 @@ macro_rules! add_benchmark { &highest_range_values[..], &steps[..], repeat, + whitelist, )?, pallet: $name.to_vec(), benchmark: benchmark.clone(), diff --git a/benchmarking/src/tests.rs b/benchmarking/src/tests.rs index 35e4361232f4229973950c6fb08182ad73ef5ada..d1d0a6e9298d2698f614ce891bef75f5b91152c3 100644 --- a/benchmarking/src/tests.rs +++ b/benchmarking/src/tests.rs @@ -78,6 +78,7 @@ impl frame_system::Trait for Test { type OnNewAccount = (); type OnKilledAccount = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } impl Trait for Test { diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index 110ed5ac14ebc55ac261f6548438e058941c4668..4da4e39f025ed13c9618b02c819e9c02ef1aef18 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -10,18 +10,18 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } -pallet-balances = "2.0.0-rc3" +sp-core = { version = "2.0.0-rc4", default-features = false } +pallet-balances = "2.0.0-rc4" tokens = { package = "orml-tokens", path = "../tokens" } clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/currencies/src/mock.rs b/currencies/src/mock.rs index 63be37cc6e234fd88376e4f6866e3fe009a8bb4e..4f7ffb384a583d954d9e3effaa6994fe5fffe354 100644 --- a/currencies/src/mock.rs +++ b/currencies/src/mock.rs @@ -63,6 +63,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub type System = system::Module<Runtime>; diff --git a/currencies/src/tests.rs b/currencies/src/tests.rs index 4e35ed787ed7cf4ea2f5f1920741d05d37f7065c..39383358309fee83403c6fe5c28140f1973122f2 100644 --- a/currencies/src/tests.rs +++ b/currencies/src/tests.rs @@ -223,10 +223,15 @@ fn update_balance_call_should_work() { .one_hundred_for_alice_n_bob() .build() .execute_with(|| { - assert_ok!(Currencies::update_balance(Origin::ROOT, ALICE, NATIVE_CURRENCY_ID, -10)); + assert_ok!(Currencies::update_balance( + Origin::root(), + ALICE, + NATIVE_CURRENCY_ID, + -10 + )); assert_eq!(NativeCurrency::free_balance(&ALICE), 90); assert_eq!(Currencies::free_balance(X_TOKEN_ID, &ALICE), 100); - assert_ok!(Currencies::update_balance(Origin::ROOT, ALICE, X_TOKEN_ID, 10)); + assert_ok!(Currencies::update_balance(Origin::root(), ALICE, X_TOKEN_ID, 10)); assert_eq!(Currencies::free_balance(X_TOKEN_ID, &ALICE), 110); }); } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index f8916504131ffb5477c1cfefa312966b968a6eeb..5f5dd6937e25650a71694ccb0d5143f034abf95d 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -9,12 +9,12 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } -sp-core = { version = "2.0.0-rc3", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } [features] default = ["std"] diff --git a/gradually-update/src/mock.rs b/gradually-update/src/mock.rs index 2c7abd5e458ba7e8f7c7d717e509e6cb1044fcdc..fecd4be8334af771a6d9dce13a8fef073848e24c 100644 --- a/gradually-update/src/mock.rs +++ b/gradually-update/src/mock.rs @@ -61,6 +61,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub type System = system::Module<Runtime>; diff --git a/gradually-update/src/tests.rs b/gradually-update/src/tests.rs index 6565a94f9a45371a4529a1f847c81a388ab2afdb..ea721d1ddb027cba608d63756ee69e1b0d9b2e58 100644 --- a/gradually-update/src/tests.rs +++ b/gradually-update/src/tests.rs @@ -25,7 +25,7 @@ fn gradually_update_should_work() { target_value: vec![9], per_block: vec![1], }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); let gradually_update_event = TestEvent::gradually_update(RawEvent::GraduallyUpdate( update.key, @@ -47,7 +47,7 @@ fn gradually_update_should_fail() { per_block: 1u64.encode(), }; assert_noop!( - GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone()), + GraduallyUpdateModule::gradually_update(Origin::root(), update.clone()), Error::<Runtime>::InvalidPerBlockOrTargetValue ); @@ -56,7 +56,7 @@ fn gradually_update_should_fail() { target_value: 90u32.encode(), per_block: 1u32.encode(), }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); GraduallyUpdateModule::on_finalize(20); @@ -66,12 +66,12 @@ fn gradually_update_should_fail() { per_block: 1u64.encode(), }; assert_noop!( - GraduallyUpdateModule::gradually_update(Origin::ROOT, new_update.clone()), + GraduallyUpdateModule::gradually_update(Origin::root(), new_update.clone()), Error::<Runtime>::InvalidTargetValue ); assert_noop!( - GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone()), + GraduallyUpdateModule::gradually_update(Origin::root(), update.clone()), Error::<Runtime>::GraduallyUpdateHasExisted ); }); @@ -87,7 +87,7 @@ fn cancel_gradually_update_should_work() { target_value: vec![9], per_block: vec![1], }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); let gradually_update_event = TestEvent::gradually_update(RawEvent::GraduallyUpdate( update.key.clone(), update.per_block, @@ -98,7 +98,7 @@ fn cancel_gradually_update_should_work() { .any(|record| record.event == gradually_update_event)); assert_ok!(GraduallyUpdateModule::cancel_gradually_update( - Origin::ROOT, + Origin::root(), update.key.clone() )); let cancel_gradually_update_event = TestEvent::gradually_update(RawEvent::CancelGraduallyUpdate(update.key)); @@ -117,14 +117,14 @@ fn cancel_gradually_update_should_fail() { per_block: 1u32.encode(), }; assert_noop!( - GraduallyUpdateModule::cancel_gradually_update(Origin::ROOT, update.key.clone()), + GraduallyUpdateModule::cancel_gradually_update(Origin::root(), update.key.clone()), Error::<Runtime>::CancelGradullyUpdateNotExisted ); - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_ok!(GraduallyUpdateModule::cancel_gradually_update( - Origin::ROOT, + Origin::root(), update.key.clone() )); }); @@ -140,7 +140,7 @@ fn add_on_finalize_should_work() { target_value: vec![30], per_block: vec![1], }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![]); GraduallyUpdateModule::on_finalize(10); @@ -187,7 +187,7 @@ fn sub_on_finalize_should_work() { }; storage_set(&update.key, &vec![30]); - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![30]); GraduallyUpdateModule::on_finalize(10); @@ -230,7 +230,7 @@ fn u32_should_work() { target_value: 30u32.encode(), per_block: 1u32.encode(), }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![]); GraduallyUpdateModule::on_finalize(10); assert_eq!(storage_get(&update.key), vec![10, 0, 0, 0]); @@ -251,7 +251,7 @@ fn u128_should_work() { target_value: 30u128.encode(), per_block: 1u128.encode(), }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![]); GraduallyUpdateModule::on_finalize(10); assert_eq!( @@ -284,7 +284,7 @@ fn permill_should_work() { target_value: Permill::from_percent(30).encode(), per_block: Permill::from_percent(1).encode(), }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![]); GraduallyUpdateModule::on_finalize(10); assert_eq!(storage_get(&update.key), vec![160, 134, 1, 0]); @@ -305,7 +305,7 @@ fn fixedu128_should_work() { target_value: FixedU128::saturating_from_rational(30, 1).encode(), per_block: FixedU128::saturating_from_rational(1, 1).encode(), }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); assert_eq!(storage_get(&update.key), vec![]); GraduallyUpdateModule::on_finalize(10); assert_eq!( @@ -350,9 +350,9 @@ fn finish_multiple_on_finalize_should_work() { target_value: vec![100], per_block: vec![3], }; - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update.clone())); - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update2.clone())); - assert_ok!(GraduallyUpdateModule::gradually_update(Origin::ROOT, update3.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update2.clone())); + assert_ok!(GraduallyUpdateModule::gradually_update(Origin::root(), update3.clone())); GraduallyUpdateModule::on_finalize(10); assert_eq!(storage_get(&update.key), vec![10]); diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 4485583cca4d6b2a1746349cc467dd58a0ee3548..7bb6dea26da4e2507e6201620c543b22d74ac38a 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -11,19 +11,19 @@ edition = "2018" serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-application-crypto = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-application-crypto = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } orml-utilities = { path = "../utilities", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/oracle/rpc/Cargo.toml b/oracle/rpc/Cargo.toml index 6a435f9d9c634588d80a83cc87d7b723916ac816..74d6f182867ade9e30a3b97b5c86e290e46020f1 100644 --- a/oracle/rpc/Cargo.toml +++ b/oracle/rpc/Cargo.toml @@ -9,7 +9,7 @@ codec = { package = "parity-scale-codec", version = "1.3.0" } jsonrpc-core = "14.0.5" jsonrpc-core-client = "14.0.5" jsonrpc-derive = "14.0.5" -sp-runtime = { version = "2.0.0-rc3" } -sp-api = { version = "2.0.0-rc3" } -sp-blockchain = { version = "2.0.0-rc3" } +sp-runtime = { version = "2.0.0-rc4" } +sp-api = { version = "2.0.0-rc4" } +sp-blockchain = { version = "2.0.0-rc4" } orml-oracle-rpc-runtime-api = { path = "runtime-api" } diff --git a/oracle/rpc/runtime-api/Cargo.toml b/oracle/rpc/runtime-api/Cargo.toml index 1ccba8e3683799ae809a921e4cd2e62b5527fcf4..5e9c84747b17f4457d4cd8743625729c2a8d663d 100644 --- a/oracle/rpc/runtime-api/Cargo.toml +++ b/oracle/rpc/runtime-api/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] } -sp-api = { default-features = false, version = "2.0.0-rc3" } -sp-std = { default-features = false, version = "2.0.0-rc3" } +sp-api = { default-features = false, version = "2.0.0-rc4" } +sp-std = { default-features = false, version = "2.0.0-rc4" } [features] default = ["std"] diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index 8871cf1596f46b84bcf20c4189f49a8fd505d38b..e2a0896df0cc828b6556ea4644d7782d678c9755 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -12,7 +12,7 @@ pub use default_combine_data::DefaultCombineData; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, ensure, traits::{ChangeMembers, Get, InitializeMembers, Time}, - weights::{DispatchClass, FunctionOf, Pays}, + weights::{DispatchClass, Pays}, IterableStorageMap, Parameter, }; use sp_runtime::{ @@ -115,7 +115,7 @@ decl_module! { fn deposit_event() = default; - #[weight = FunctionOf(0, DispatchClass::Operational, Pays::No)] + #[weight = (0, DispatchClass::Operational, Pays::No)] pub fn feed_values( origin, values: Vec<(T::OracleKey, T::OracleValue)>, diff --git a/oracle/src/mock.rs b/oracle/src/mock.rs index 05be4597666b553aa2924e4bc79fa00aed1e4919..d5d6cfcaf6d0e2fb96cd5928c6b0214c077b6afe 100644 --- a/oracle/src/mock.rs +++ b/oracle/src/mock.rs @@ -39,7 +39,7 @@ parameter_types! { } impl frame_system::Trait for Test { type Origin = Origin; - type Call = (); + type Call = Call; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -61,6 +61,7 @@ impl frame_system::Trait for Test { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } thread_local! { diff --git a/oracle/src/tests.rs b/oracle/src/tests.rs index f96a9b0a2af21761a2477d68f32d94c96b7397be..9814d0fd8524a78cad20a71dac1c99d92a7f3d51 100644 --- a/oracle/src/tests.rs +++ b/oracle/src/tests.rs @@ -29,7 +29,7 @@ fn feed_values_from_session_key( &OracleCall::feed_values(values.clone(), index, sig.clone()), )?; - Ok(ModuleOracle::feed_values(Origin::NONE, values, index, sig)) + Ok(ModuleOracle::feed_values(Origin::none(), values, index, sig)) } fn feed_values( @@ -82,7 +82,7 @@ fn should_feed_values_from_root() { let account_id: AccountId = 1; assert_ok!(ModuleOracle::feed_values( - Origin::ROOT, + Origin::root(), vec![(50, 1000), (51, 900), (52, 800)], 0, TestSignature(0, vec![]) diff --git a/prices/Cargo.toml b/prices/Cargo.toml index 5dc9a723d643234222c3e7b42fa0d877f3fccccc..bafb773564f23124c016bdca558c34fd605f9fe6 100644 --- a/prices/Cargo.toml +++ b/prices/Cargo.toml @@ -9,9 +9,9 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] diff --git a/schedule-update/Cargo.toml b/schedule-update/Cargo.toml index e975d1bf20797fee6655c56c572a511d68488a00..b1785461fbd28b512d3ffe1367a4d90c3b37bbf0 100644 --- a/schedule-update/Cargo.toml +++ b/schedule-update/Cargo.toml @@ -10,16 +10,16 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-core = { version = "2.0.0-rc3", default-features = false } -pallet-balances = "2.0.0-rc3" +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } +pallet-balances = "2.0.0-rc4" clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/schedule-update/src/mock.rs b/schedule-update/src/mock.rs index 484fcded58cca0028eeb4871d185a9f29753d11f..2f3b3be12e0a9890dc8be7ae194a815745dfd014 100644 --- a/schedule-update/src/mock.rs +++ b/schedule-update/src/mock.rs @@ -2,10 +2,7 @@ #![cfg(test)] -use frame_support::{ - impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types, - weights::{FunctionOf, Pays}, -}; +use frame_support::{impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types}; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, Perbill}; @@ -35,11 +32,7 @@ mod logger { pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin { fn deposit_event() = default; - #[weight = FunctionOf( - |args: (&u32, &Weight)| *args.1, - |_: (&u32, &Weight)| DispatchClass::Normal, - Pays::Yes, - )] + #[weight = *weight] fn log(origin, i: u32, weight: Weight) { ensure_root(origin)?; Self::deposit_event(Event::Logged(i, weight)); @@ -113,6 +106,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub type System = frame_system::Module<Runtime>; diff --git a/schedule-update/src/tests.rs b/schedule-update/src/tests.rs index ba328b7d4bc70511bb009e301858163ea4da5c3e..693b88a67bb47d9f52eade2ab422d842e388b638 100644 --- a/schedule-update/src/tests.rs +++ b/schedule-update/src/tests.rs @@ -30,7 +30,7 @@ fn schedule_dispatch_should_work() { // OperationalDispatches let call = Call::Balances(BalancesCall::set_balance(1, 10, 11)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::After(3) )); @@ -47,7 +47,7 @@ fn schedule_dispatch_works_for_root_origin() { ExtBuilder::default().build().execute_with(|| { let call = Call::Balances(BalancesCall::transfer(2, 11)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::At(10) )); @@ -118,7 +118,7 @@ fn cancel_delayed_dispatch_should_work() { .iter() .any(|record| record.event == schedule_dispatch_event)); - assert_ok!(ScheduleUpdateModule::cancel_delayed_dispatch(Origin::ROOT, 4, 1)); + assert_ok!(ScheduleUpdateModule::cancel_delayed_dispatch(Origin::root(), 4, 1)); let schedule_dispatch_event = TestEvent::schedule_update(RawEvent::CancelDelayedDispatch(1)); assert!(System::events() @@ -128,7 +128,7 @@ fn cancel_delayed_dispatch_should_work() { // OperationalDispatches let call = Call::Balances(BalancesCall::set_balance(2, 10, 13)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::At(5) )); @@ -138,7 +138,7 @@ fn cancel_delayed_dispatch_should_work() { .iter() .any(|record| record.event == schedule_dispatch_event)); - assert_ok!(ScheduleUpdateModule::cancel_delayed_dispatch(Origin::ROOT, 5, 2)); + assert_ok!(ScheduleUpdateModule::cancel_delayed_dispatch(Origin::root(), 5, 2)); let schedule_dispatch_event = TestEvent::schedule_update(RawEvent::CancelDelayedDispatch(2)); assert!(System::events() @@ -178,7 +178,7 @@ fn cancel_delayed_dispatch_should_fail() { // OperationalDispatches let call = Call::Balances(BalancesCall::set_balance(2, 10, 13)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::At(5) )); @@ -236,7 +236,7 @@ fn on_initialize_should_work() { // OperationalDispatches let call = Call::Balances(BalancesCall::set_balance(3, 10, 11)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::After(10) )); @@ -248,7 +248,7 @@ fn on_initialize_should_work() { let call = Call::Balances(BalancesCall::set_balance(3, 20, 21)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(call), DelayedDispatchTime::After(12) )); @@ -340,21 +340,21 @@ fn on_initialize_weight_exceed() { // NormalDispatches let half_max_weight_call = Call::Logger(LoggerCall::log(1, MaxScheduleDispatchWeight::get() / 2)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(half_max_weight_call), DelayedDispatchTime::At(2) )); let half_max_weight_call = Call::Logger(LoggerCall::log(2, MaxScheduleDispatchWeight::get() / 2)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(half_max_weight_call), DelayedDispatchTime::At(2) )); let half_max_weight_call = Call::Logger(LoggerCall::log(3, MaxScheduleDispatchWeight::get() / 2)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(half_max_weight_call), DelayedDispatchTime::At(2) )); @@ -380,7 +380,7 @@ fn execute_at_least_one_task() { let large_weight_call = Call::Logger(LoggerCall::log(42, MaxScheduleDispatchWeight::get() + 1)); assert_ok!(ScheduleUpdateModule::schedule_dispatch( - Origin::ROOT, + Origin::root(), Box::new(large_weight_call), DelayedDispatchTime::At(2) )); diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 6709d9bb8ea039a400fd28ea3fabebea72aaef41..dd602d47290facb38c8123674ee50d788510cefd 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } orml-traits = { path = "../traits", version = "0.1.3-dev", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } +sp-core = { version = "2.0.0-rc4", default-features = false } clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index 6a6ece8a01d25550c354d52b06f52edbdec54870..041ab9ce5e502a458114b9c7cf3aad2116594cc7 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -61,6 +61,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub type System = system::Module<Runtime>; diff --git a/traits/Cargo.toml b/traits/Cargo.toml index df42fcc1c7a4f3ab1362789d19e1305f349afa81..58b2dd6f4b98bd706bce8acd1700a846b3508387 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -10,12 +10,12 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } num-traits = { version = "0.2.11", default-features = false } impl-trait-for-tuples = "0.1.3" -frame-support = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } [dev-dependencies] clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index 95f6a468e5c84a8a758a6d3d76079a00cde3752a..5d73bc2022bedac33aa2030e06b376a98de1e5f9 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -10,8 +10,8 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } [dev-dependencies] serde_json = "1.0.53" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 3b9b7b8f0ebb1ea7da0174519d2679306857b37d..dc18e97b8110f71c0fd2593433c8a6f3abd0454e 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -10,16 +10,16 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false } -sp-runtime = { version = "2.0.0-rc3", default-features = false } -sp-io = { version = "2.0.0-rc3", default-features = false } -sp-std = { version = "2.0.0-rc3", default-features = false } +sp-runtime = { version = "2.0.0-rc4", default-features = false } +sp-io = { version = "2.0.0-rc4", default-features = false } +sp-std = { version = "2.0.0-rc4", default-features = false } -frame-support = { version = "2.0.0-rc3", default-features = false } -frame-system = { version = "2.0.0-rc3", default-features = false } +frame-support = { version = "2.0.0-rc4", default-features = false } +frame-system = { version = "2.0.0-rc4", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-rc3", default-features = false } -pallet-balances = "2.0.0-rc3" +sp-core = { version = "2.0.0-rc4", default-features = false } +pallet-balances = "2.0.0-rc4" clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179 diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index fcd13e19cfade7e71e5ed5b630e30e6b15e7aa3e..953f3eb0d2bb1439a94f3f7485abe9644924fb83 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -59,6 +59,7 @@ impl frame_system::Trait for Runtime { type BlockExecutionWeight = (); type ExtrinsicBaseWeight = (); type MaximumExtrinsicWeight = (); + type BaseCallFilter = (); } pub type System = system::Module<Runtime>; diff --git a/vesting/src/tests.rs b/vesting/src/tests.rs index 7c905bb9a7b736b0ddddcb6921dcc6a7b45badac..ecf65b294bed261cd2506043bf24b6bd8537c7a8 100644 --- a/vesting/src/tests.rs +++ b/vesting/src/tests.rs @@ -212,7 +212,7 @@ fn update_vesting_schedules_works() { per_period: 10u64, }; assert_ok!(Vesting::update_vesting_schedules( - Origin::ROOT, + Origin::root(), BOB, vec![updated_schedule] ));